Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a helper method to create an aggregate function for string #964

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -956,9 +956,9 @@ public static Number aggregateFunctionWithQualifier(EOEditingContext ec,
}

/**
* Computes an aggregate function for a given attribute
* Computes an aggregate function for a given string attribute
* restricted by a given qualifier. For instance
* select MAX(AGE) from User where name like 'M*'
* select MAX(age) from User where name like 'M*'
*
* @param ec editing context used for the fetch
* @param entityName name of the entity
Expand All @@ -983,7 +983,32 @@ public static Number aggregateFunctionWithQualifier(EOEditingContext ec,
/**
* Computes an aggregate function for a given attribute
* restricted by a given qualifier. For instance
* select MAX(AGE) from User where name like 'M*'
* select MAX(invoiceNumber) from Invoice where invoiceNumber like 'INV22*'
*
* @param ec editing context used for the fetch
* @param entityName name of the entity
* @param attributeName attribute for the function to be performed on
* @param function name, ie MAX, MIN, AVG, etc.
* @param qualifier to restrict data set
* @return aggregate result of the fuction call
*/
public static String aggregateStringWithQualifier(EOEditingContext ec,
String entityName,
String attributeName,
String function,
EOQualifier qualifier) {
String string = null;
Object obj = _aggregateFunctionWithQualifier(ec, entityName, attributeName, function, String.class, null, qualifier);
if (obj instanceof String) {
string = (String)obj;
}
return string;
}

/**
* Computes an aggregate function for a given attribute
* restricted by a given qualifier. For instance
* select MAX(birthdate) from User where name like 'M*'
*
* @param ec editing context used for the fetch
* @param entityName name of the entity
Expand Down