Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
// 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