Created
March 28, 2014 09:57
-
-
Save amusarra/9829212 to your computer and use it in GitHub Desktop.
Listato 2 Implementazione del metodo getUsersCompanyByTagName per l’interfaccia locale.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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