Oswaldo Bueno's FetchSpecification Addition
Last modified by David Avendasora on 2008/01/25 10:41
Add this code to the end of any other _Entity superclass template to add Model-Specified FetchSpecifications to the _Entity.java file.
#foreach ($fetchSpecification in $entity.sortedFetchSpecs)
#if (true || $fetchSpecification.distinctBindings.size() > 0)
public static NSArray<${entity.className}> fs${fetchSpecification.capitalizedName}(EOEditingContext context, NSDictionary<String, Object> bindings) {
EOFetchSpecification spec = EOFetchSpecification.fetchSpecificationNamed("${fetchSpecification.name}", "${entity.name}");
spec = spec.fetchSpecificationWithQualifierBindings(bindings);
return context.objectsWithFetchSpecification(spec);
}
#end
public static NSArray<${entity.className}> fs${fetchSpecification.capitalizedName}(EOEditingContext context#foreach ($binding in $fetchSpecification.distinctBindings),
${binding.attributePath.childClassName} ${binding.name}Binding#end)
{
EOFetchSpecification spec = EOFetchSpecification.fetchSpecificationNamed("${fetchSpecification.name}", "${entity.name}");
#if ($fetchSpecification.distinctBindings.size() > 0)
NSMutableDictionary bindings = new NSMutableDictionary();
#foreach ($binding in $fetchSpecification.distinctBindings)
bindings.takeValueForKey(${binding.name}Binding, "${binding.name}");
#end
spec = spec.fetchSpecificationWithQualifierBindings(bindings);
#end
return context.objectsWithFetchSpecification(spec);
}
#end