Skip to content

Instantly share code, notes, and snippets.

@amusarra
Created March 28, 2014 09:57
Show Gist options
  • Save amusarra/9829212 to your computer and use it in GitHub Desktop.
Save amusarra/9829212 to your computer and use it in GitHub Desktop.
Listato 2 Implementazione del metodo getUsersCompanyByTagName per l’interfaccia locale.
public com.liferay.portal.model.UserSoap[] getUsersCompanyByTagName(long companyId, String tagName,
Integer userStatus, int start, int end) throws PortalException,
SystemException {
SearchContext searchContext = new SearchContext();
searchContext.setCompanyId(companyId);
searchContext.setEntryClassNames(new String[] { User.class.getName() });
searchContext.setStart(start);
searchContext.setEnd(end);
searchContext.setAndSearch(true);
BooleanQuery searchQuery = BooleanQueryFactoryUtil.create(searchContext);
searchQuery.addRequiredTerm(Field.COMPANY_ID, companyId);
searchQuery.addRequiredTerm(Field.ASSET_TAG_NAMES, tagName);
searchQuery.addRequiredTerm(Field.STATUS, userStatus);
Hits hits = SearchEngineUtil.search(searchContext, searchQuery);
Tuple tuple = UsersAdminUtil.getUsers(hits);
if (hits.getLength() == 0) {
throw new UsersNotFoundException("No data available for the search parameters you set.");
}
List<User> results = (List<User>) tuple.getObject(0);
UserSoap[] userSoap = new UserSoap[results.size()];
for (int i = 0; i < userSoap.length; i++) {
userSoap[i] = UserSoap.toSoapModel(results.get(i));
}
return userSoap;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment