Dashboard > WOProject / WOLips > ... > EOGenerator Templates and Additions > Oswaldo Bueno's FetchSpecification Addition
  WOProject / WOLips Log In View a printable version of the current page.  
  Oswaldo Bueno's FetchSpecification Addition
Added by David Avendasora, last edited by David Avendasora on Jan 25, 2008
Labels: 
(None)

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

Site running on a free Atlassian Confluence Open Source Project License granted to ObjectStyle. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.4 Build:#809 Jun 12, 2007) - Bug/feature request - Contact Administrators