Created
January 18, 2011 10:10
-
-
Save mariussoutier/784253 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Best of both worlds - WebObjects + Scala | |
// valueForKeyPath operators | |
def parameters: NSArray[Parameter] = ... | |
def maxSortOrder = parameters.valueForKeyPath("sortOrder.@max").asInstanceOf[Int] | |
// Clone attributes of an EnterpriseObject (aka DB row with all non-relationship columns) | |
trait Cloning extends EOEnterpriseObject { | |
type EOType <: EOEnterpriseObject | |
def attributesWithoutNull = for (attributeKey <- attributeKeys toList; if valueForKey(attributeKey) != null) yield attributeKey | |
def cloneEO: EOType = { | |
val clone = ERXEOControlUtilities.createAndInsertObject(editingContext, entityName).asInstanceOf[EOType] | |
val thisSnapshot = snapshot | |
for (key <- attributesWithoutNull) clone.takeValueForKey(thisSnapshot.valueForKey(key), key) | |
clone | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment