本文整理汇总了Java中com.liferay.portal.kernel.search.IndexerRegistryUtil.getIndexer方法的典型用法代码示例。如果您正苦于以下问题:Java IndexerRegistryUtil.getIndexer方法的具体用法?Java IndexerRegistryUtil.getIndexer怎么用?Java IndexerRegistryUtil.getIndexer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.liferay.portal.kernel.search.IndexerRegistryUtil
的用法示例。
在下文中一共展示了IndexerRegistryUtil.getIndexer方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSortedRecords
import com.liferay.portal.kernel.search.IndexerRegistryUtil; //导入方法依赖的package包/类
private List<DDLRecord> getSortedRecords(final HttpServletRequest request, final DDLRecordSet recordSet,
final String sortByStructureColumnName) throws Exception {
DDMStructure structure = recordSet.getDDMStructure();
String indexedSortColumn = DDMIndexerUtil.encodeName(structure.getStructureId(), sortByStructureColumnName, Locale.US);
SearchContext searchContext = SearchContextFactory.getInstance(request);
String fieldType = structure.getFieldType(sortByStructureColumnName);
int sortType = getSortType(fieldType);
Sort sort = SortFactoryUtil.create(indexedSortColumn, sortType, false);
searchContext.setSorts(sort);
Indexer indexer = IndexerRegistryUtil.getIndexer("com.liferay.portlet.dynamicdatalists.util.DDLIndexer");
Hits results = indexer.search(searchContext);
return adapt(results);
}
示例2: isFilterSearch
import com.liferay.portal.kernel.search.IndexerRegistryUtil; //导入方法依赖的package包/类
private boolean isFilterSearch(SearchContext searchContext) {
if (searchContext.getEntryClassNames() == null) {
return false;
}
for (String entryClassName : searchContext.getEntryClassNames()) {
Indexer indexer = IndexerRegistryUtil.getIndexer(entryClassName);
if (indexer == null) {
continue;
}
if (indexer.isFilterSearch()) {
return true;
}
}
return false;
}
示例3: getIndexer
import com.liferay.portal.kernel.search.IndexerRegistryUtil; //导入方法依赖的package包/类
/**
* Get indexer for the item class name.
*
* @param name
* of the item class
* @return indexer object
*/
protected Indexer<Object> getIndexer(String className) {
if (_indexerRegistry != null) {
return _indexerRegistry.getIndexer(className);
}
return IndexerRegistryUtil.getIndexer(className);
}
示例4: addPermissionsClassNameGroupIdFields
import com.liferay.portal.kernel.search.IndexerRegistryUtil; //导入方法依赖的package包/类
public void addPermissionsClassNameGroupIdFields(Data data)
throws SystemException {
String className = getPermissionsClassName(data);
long classPK = getPermissionsClassPK(data);
if (Validator.isNull(classPK) || Validator.isNull(className) ||
(classPK <= 0)) {
return;
}
Indexer indexer = IndexerRegistryUtil.getIndexer(className);
if (!indexer.isPermissionAware()) {
return;
}
long groupId = 0L;
Object groupIdObj = data.get("groupId", 0L);
if (groupIdObj instanceof Number) {
groupId = ((Number)groupIdObj).longValue();
Group group = GroupLocalServiceUtil.fetchGroup(groupId);
if ((group != null) && group.isLayout()) {
groupId = group.getParentGroupId();
}
}
data.set("permissionsClassName", className);
data.set("permissionsClassPK", classPK);
data.set("permissionsGroupId", groupId);
}
示例5: hasIndexerEnabled
import com.liferay.portal.kernel.search.IndexerRegistryUtil; //导入方法依赖的package包/类
public static boolean hasIndexerEnabled(String className) {
Object indexer = IndexerRegistryUtil.getIndexer(className);
if (indexer == null) {
return false;
}
if (indexer instanceof Proxy) {
try {
ClassLoaderBeanHandler classLoaderBeanHandler =
(ClassLoaderBeanHandler)
Proxy.getInvocationHandler(indexer);
indexer = classLoaderBeanHandler.getBean();
if (indexer == null) {
return false;
}
}
catch (Exception e) {
if (_log.isDebugEnabled()) {
_log.debug(e, e);
}
}
}
if (indexer instanceof BaseIndexer) {
BaseIndexer baseIndexer = (BaseIndexer)indexer;
return baseIndexer.isIndexerEnabled();
}
return false;
}
示例6: reindexAllIndices
import com.liferay.portal.kernel.search.IndexerRegistryUtil; //导入方法依赖的package包/类
protected static void reindexAllIndices(final Class modelClass, final long id) {
Indexer indexer = IndexerRegistryUtil.getIndexer(modelClass);
try {
indexer.reindex(modelClass.getName(), id);
} catch (SearchException e) {
e.printStackTrace();
}
}
示例7: deleteApplication
import com.liferay.portal.kernel.search.IndexerRegistryUtil; //导入方法依赖的package包/类
public Application deleteApplication(Application application) throws SystemException {
_log.debug("deleteApplication: " + application.getApplicationId());
// Indexer
Indexer indexer = IndexerRegistryUtil.getIndexer(Application.class);
try {
indexer.delete(application);
} catch (SearchException e) {
e.printStackTrace();
}
applicationPersistence.remove(application);
return application;
}
示例8: getPermissionQuery
import com.liferay.portal.kernel.search.IndexerRegistryUtil; //导入方法依赖的package包/类
private Query getPermissionQuery(SearchContext searchContext, Query query) {
if (searchContext.getEntryClassNames() == null) {
return query;
}
for (String className : searchContext.getEntryClassNames()) {
Indexer indexer = IndexerRegistryUtil.getIndexer(className);
if (indexer != null) {
if (indexer.isFilterSearch() && indexer.isPermissionAware()) {
SearchPermissionChecker searchPermissionChecker = SearchEngineUtil.getSearchPermissionChecker();
query = searchPermissionChecker.getPermissionQuery(searchContext.getCompanyId(), searchContext.getGroupIds(), searchContext.getUserId(), className, query, searchContext);
}
}
}
return query;
}
示例9: buildQuerySearch
import com.liferay.portal.kernel.search.IndexerRegistryUtil; //导入方法依赖的package包/类
/**
* @param pattern
* @param params
* @param searchContext
* @return
*/
public static BooleanQuery buildQuerySearch(String pattern,
List<Object> params, SearchContext searchContext) {
searchContext
.setEntryClassNames(new String[] { Dossier.class.getName() });
Indexer indexer = IndexerRegistryUtil.getIndexer(Dossier.class
.getName());
searchContext.setSearchEngineId(indexer.getSearchEngineId());
BooleanQuery query = BooleanQueryFactoryUtil.create(searchContext);
List<String> subQueries = new ArrayList<String>();
try {
pattern = validPattern(pattern);
if (Validator.isNull(pattern)) {
throw new Exception();
}
getSubQueries(pattern, subQueries);
if (subQueries != null && !subQueries.isEmpty()) {
List<BooleanQuery> booleanQueries = createBooleanQueries(
subQueries, params, searchContext);
List<BooleanClauseOccur> conditions = getBooleanClauseOccurs(
pattern, subQueries);
if (booleanQueries.size() - 1 != conditions.size()) {
throw new Exception();
}
int count = 0;
for (BooleanQuery booleanQuery : booleanQueries) {
if (count == 0) {
query.add(booleanQuery, BooleanClauseOccur.MUST);
} else {
query.add(booleanQuery, conditions.get(count - 1));
}
count++;
}
}
TermQuery entryClassNameTerm = TermQueryFactoryUtil.create(
searchContext, "entryClassName", Dossier.class.getName());
query.add(entryClassNameTerm, BooleanClauseOccur.MUST);
} catch (Exception e) {
_log.error(e);
}
return query;
}
示例10: addApplication
import com.liferay.portal.kernel.search.IndexerRegistryUtil; //导入方法依赖的package包/类
public Application addApplication(Application application) throws SystemException {
try {
long applicationID = CounterLocalServiceUtil.increment(Application.class.getName());
_log.debug("addApplication:applicationID: " + applicationID);
_log.debug("application.getCompanyId(): " + application.getCompanyId());
_log.debug("application.getDescription(): " + application.getDescription());
_log.debug("application.getFee(): " + application.getFee());
_log.debug("application.getTargetOS(): " + application.getTargetOS());
_log.debug("application.getTargetCategory(): " + application.getTargetCategory());
_log.debug("application.getLegalDetails(): " + application.getLegalDetails());
_log.debug("application.getDeveloper(): " + application.getDeveloper());
_log.debug("application.getMinTargetOSVersion(): " + application.getMinTargetOSVersion());
_log.debug("application.getName(): " + application.getName());
_log.debug("application.getSize(): " + application.getSize());
_log.debug("application.getUserId(): " + application.getUserId());
_log.debug("application.getVersion(): " + application.getVersion());
_log.debug("application.getVersionInformation(): " + application.getVersionInformation());
Application model = applicationPersistence.create(applicationID);
model.setCompanyId(application.getCompanyId());
model.setCreateDate(new Date());
model.setDescription(application.getDescription());
model.setFee(application.getFee());
model.setLifeCycleStatus(Constants.APPLICATION_STATUS_SUBMITTED);
// model.setLifeCycleStatusString("neu erstellt - warten auf Freigabe");
model.setLogoImageId(application.getLogoImageId());
model.setMinTargetOSVersion(application.getMinTargetOSVersion());
model.setModifiedDate(new Date());
model.setName(application.getName());
model.setSize(application.getSize());
model.setTargetOS(application.getTargetOS());
model.setUserId(application.getUserId());
// model.setVerifiedDate(application.getVerifiedDate());
model.setVersion(application.getVersion());
model.setVersionInformation(application.getVersionInformation());
model.setTargetCategory(application.getTargetCategory());
model.setDeveloper(application.getDeveloper());
model.setFirstPublishingDate(application.getFirstPublishingDate());
model.setLastModifiedDate(application.getLastModifiedDate());
model.setLegalDetails(application.getLegalDetails());
if (application.getUseOpenData() == 1) {
model.setUseOpenData(application.getUseOpenData());
model.setLicense(application.getLicense());
model.setSector(application.getSector());
}
// Indexer
Indexer indexer = IndexerRegistryUtil.getIndexer(Application.class);
indexer.reindex(model);
Application res = applicationPersistence.update(model, true);
_log.debug("getApplicationId: " +res.getApplicationId());
_log.debug("getCompanyId: " +res.getCompanyId());
return res;
} catch (Exception e) {
_log.debug("Exception: " + e.getMessage());
_log.info("application.getCompanyId(): " + application.getCompanyId());
_log.info("application.getDescription(): " + application.getDescription());
_log.info("application.getFee(): " + application.getFee());
_log.info("application.getTargetOS(): " + application.getTargetOS());
_log.info("application.getTargetCategory(): " + application.getTargetCategory());
_log.info("application.getLegalDetails(): " + application.getLegalDetails());
_log.info("application.getDeveloper(): " + application.getDeveloper());
_log.info("application.getMinTargetOSVersion(): " + application.getMinTargetOSVersion());
_log.info("application.getName(): " + application.getName());
_log.info("application.getSize(): " + application.getSize());
_log.info("application.getUserId(): " + application.getUserId());
_log.info("application.getVersion(): " + application.getVersion());
_log.info("application.getVersionInformation(): " + application.getVersionInformation());
e.printStackTrace();
}
return null;
}
示例11: deleteOldApplication
import com.liferay.portal.kernel.search.IndexerRegistryUtil; //导入方法依赖的package包/类
public void deleteOldApplication(long oldApplicationId, long newApplicationId) throws SystemException, PortalException {
_log.debug("deleteOldApplication(long " + oldApplicationId +", long " + newApplicationId + ")");
Application oldApplication = applicationPersistence.fetchByPrimaryKey(oldApplicationId);
Application newApplication = applicationPersistence.fetchByPrimaryKey(newApplicationId);
// applicationPersistence.clearCategories(applicationId);
// applicationPersistence.clearLanguages(applicationId);
// applicationPersistence.clearRegions(applicationId);
List<MultiMedia> multiMedias = multiMediaPersistence.findByapp(oldApplicationId);
for (MultiMedia multiMedia: multiMedias) {
MultiMediaLocalServiceUtil.deleteMultiMedia(multiMedia);
}
List<Link> links = linkPersistence.findByapp(oldApplicationId);
for (Link link: links) {
linkPersistence.remove(link);
}
List<Application_Entitlement> applicationEntitlements = application_EntitlementPersistence.findByca(10154, oldApplicationId);
for (Application_Entitlement applicationEntitlement: applicationEntitlements) {
application_EntitlementPersistence.remove(applicationEntitlement);
}
String relatedApplicationId = oldApplication.getRelatedApplicationId();
newApplication.setRelatedApplicationId(relatedApplicationId);
applicationPersistence.update(newApplication, true);
if (relatedApplicationId.length() > 0) {
String [] relatedApplicationIds = relatedApplicationId.split(";");
long [] relatedApplicationIdsLong = new long[relatedApplicationIds.length];
for (int i = 0; i<relatedApplicationIds.length; i++) {
relatedApplicationIdsLong[i] = Long.parseLong(relatedApplicationIds[i]);
Application app = applicationLocalService.getApplication(Long.parseLong(relatedApplicationIds[i]));
String oldRelatedApplicationString = app.getRelatedApplicationId();
String newRelatedApplicationString = replaceRelatedIds(oldRelatedApplicationString, String.valueOf(oldApplicationId));
if (newRelatedApplicationString.length() > 0) {
newRelatedApplicationString = newRelatedApplicationString + ";" + String.valueOf(newApplicationId);
} else {
newRelatedApplicationString = String.valueOf(newApplicationId);
}
app.setRelatedApplicationId(newRelatedApplicationString);
applicationPersistence.update(app, true);
long new_AppId = 0;
new_AppId = app.getNewVersionId();
if (new_AppId > 0) {
Application newApp = applicationLocalService.getApplication(new_AppId);
String newAppOldRelatedApplicationString = newApp.getRelatedApplicationId();
String newAppNewRelatedApplicationString = replaceRelatedIds(newAppOldRelatedApplicationString, String.valueOf(oldApplicationId));
if (newAppNewRelatedApplicationString.length() > 0) {
newAppNewRelatedApplicationString = newAppNewRelatedApplicationString + ";" + String.valueOf(newApplicationId);
} else {
newAppNewRelatedApplicationString = String.valueOf(newApplicationId);
}
newApp.setRelatedApplicationId(newAppNewRelatedApplicationString);
applicationPersistence.update(newApp, true);
}
}
}
// Indexer
Indexer indexer = IndexerRegistryUtil.getIndexer(Application.class);
indexer.delete(oldApplication);
applicationPersistence.remove(oldApplication);
}
示例12: updateApplication
import com.liferay.portal.kernel.search.IndexerRegistryUtil; //导入方法依赖的package包/类
public Application updateApplication(Application application, File imageFile) throws SystemException, PortalException {
Application model = applicationPersistence.fetchByPrimaryKey(application.getApplicationId());
model.setCompanyId(application.getCompanyId());
// model.setCreateDate(new Date());
model.setDescription(application.getDescription());
model.setFee(application.getFee());
model.setTargetCategory(application.getTargetCategory());
model.setDeveloper(application.getDeveloper());
model.setFirstPublishingDate(application.getFirstPublishingDate());
model.setLastModifiedDate(application.getLastModifiedDate());
model.setLifeCycleStatus(application.getLifeCycleStatus());
// model.setLifeCycleStatusString("geändert - warten auf Freigabe");
try {
_log.debug("imageFile.getName(): " + imageFile.getName());
byte[] imageBytes = null;
imageBytes = FileUtil.getBytes(imageFile);
if(imageBytes!=null) {
_log.debug("updateApplication::imageBytes.length: " + imageBytes.length);
if (imageBytes.length > 0) {
model.setLogoImageId(counterLocalService.increment());
saveImages(model.getLogoImageId(), imageFile, imageBytes);
} else {
_log.debug("updateApplication::imageBytes.length == 0");
_log.debug("model.getLogoImageId(): "+ model.getLogoImageId());
// model.setLogoImageId(model.getLogoImageId());
}
} else {
_log.debug("updateApplication::imageBytes == null! ");
_log.debug("model.getLogoImageId(): "+ model.getLogoImageId());
// model.setLogoImageId(model.getLogoImageId());
}
} catch (Exception e) {
_log.debug(e.getMessage());
}
_log.debug("model.getLogoImageId(): "+ model.getLogoImageId());
model.setMinTargetOSVersion(application.getMinTargetOSVersion());
model.setModifiedDate(new Date());
model.setName(application.getName());
model.setSize(application.getSize());
model.setTargetOS(application.getTargetOS());
model.setUserId(application.getUserId());
if (application.getLifeCycleStatus() >= Constants.APPLICATION_STATUS_VERIFIED ) {
model.setVerifiedDate(application.getVerifiedDate());
}
model.setVersion(application.getVersion());
model.setVersionInformation(application.getVersionInformation());
model.setLegalDetails(application.getLegalDetails());
// Indexer
Indexer indexer = IndexerRegistryUtil.getIndexer(Application.class);
indexer.reindex(model);
model = applicationPersistence.update(model, true);
_log.debug("model.getLogoImageId(): "+ model.getLogoImageId());
return model;
}
示例13: updateApplicationFileEntryWithOutRelIds
import com.liferay.portal.kernel.search.IndexerRegistryUtil; //导入方法依赖的package包/类
private Application updateApplicationFileEntryWithOutRelIds(long newApplicationId, Application application, FileEntry tempImageFileEntry) throws SystemException, PortalException {
Application model = applicationPersistence.fetchByPrimaryKey(newApplicationId);
model.setCompanyId(application.getCompanyId());
// model.setCreateDate(new Date());
model.setDescription(application.getDescription());
model.setFee(application.getFee());
model.setTargetCategory(application.getTargetCategory());
model.setDeveloper(application.getDeveloper());
model.setFirstPublishingDate(application.getFirstPublishingDate());
model.setLastModifiedDate(application.getLastModifiedDate());
// model.setLifeCycleStatus(application.getLifeCycleStatus());
if(tempImageFileEntry!=null) {
model.setLogoImageId(tempImageFileEntry.getFileEntryId());
}
_log.debug("model.getLogoImageId(): "+ model.getLogoImageId());
model.setMinTargetOSVersion(application.getMinTargetOSVersion());
model.setModifiedDate(new Date());
model.setName(application.getName());
model.setSize(application.getSize());
model.setTargetOS(application.getTargetOS());
model.setUserId(application.getUserId());
if (application.getLifeCycleStatus() >= Constants.APPLICATION_STATUS_VERIFIED ) {
model.setVerifiedDate(application.getVerifiedDate());
}
model.setVersion(application.getVersion());
model.setVersionInformation(application.getVersionInformation());
model.setLegalDetails(application.getLegalDetails());
model.setRelatedApplicationId(application.getRelatedApplicationId());
model.setUseOpenData(application.getUseOpenData());
model.setLicense(application.getLicense());
model.setSector(application.getSector());
// Indexer
Indexer indexer = IndexerRegistryUtil.getIndexer(Application.class);
indexer.reindex(model);
Application result = applicationPersistence.update(model, true);
return result;
}
示例14: getSearchResults
import com.liferay.portal.kernel.search.IndexerRegistryUtil; //导入方法依赖的package包/类
/**
*Method that get list of results for the keyword search by user
*/
public static List<MBThread> getSearchResults(HttpServletRequest request,long searchCategoryId,SearchContainer searchContainer){
_log.debug("Entry : getSearchResults");
List<MBThread> threadsList=new ArrayList<>();
try{
String keywords = ParamUtil.getString(request, CustomConstants.KEYWORDS);
ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
long[] finalSearchCategoryIdsArray = null;
List<Long> searchCategoryIds = new ArrayList<>();
List<Long> finalSearchCategoryIds=new ArrayList<>();
PortletPreferences preference=(PortletPreferences)request.getAttribute(CustomConstants.PREFERENCE_REQUEST_ATTRIBUTE);
long preferenceCatId=GetterUtil.getLong(preference.getValue(CustomConstants.PREFERENCE_CATEGORYID, String.valueOf(QueryUtil.ALL_POS)));
List<Long> categoryIds=new ArrayList<Long>();
MBCategoryServiceUtil.getSubcategoryIds(
searchCategoryIds, themeDisplay.getScopeGroupId(), searchCategoryId);
searchCategoryIds.add(Long.valueOf(searchCategoryId));
if(preferenceCatId != QueryUtil.ALL_POS){
categoryIds=getPreferenceCatChildList(preferenceCatId, request);
for(long preferenceCat:categoryIds){
for(long searchCat:searchCategoryIds){
if(preferenceCat == searchCat){
finalSearchCategoryIds.add(searchCat);
}
}
}
}
else{
finalSearchCategoryIds.addAll(searchCategoryIds);
}
finalSearchCategoryIdsArray= StringUtil.split(
StringUtil.merge(finalSearchCategoryIds), 0L);
Indexer indexer = IndexerRegistryUtil.getIndexer(MBMessage.class);
SearchContext searchContext = SearchContextFactory.getInstance(
request);
searchContext.setAttribute(CustomConstants.PAGINATION_TYPE, CustomConstants.PAGINATION_TYPE_VALUE);
searchContext.setCategoryIds(finalSearchCategoryIdsArray);
searchContext.setEnd(searchContainer.getEnd());
searchContext.setIncludeAttachments(true);
searchContext.setKeywords(keywords);
searchContext.setStart(searchContainer.getStart());
Hits hits = indexer.search(searchContext);
List<SearchResult> searchResults=SearchResultUtil.getSearchResults(hits, request.getLocale());
for(SearchResult searchResult:searchResults){
threadsList.add(MBThreadLocalServiceUtil.getMBThread(MBMessageLocalServiceUtil.getMBMessage(searchResult.getClassPK()).getThreadId()));
}
_log.debug("List Size:=>"+threadsList.size());
searchContainer.setSearch(true);
searchContainer.setTotal(hits.getLength());
}
catch(Exception e){
_log.error("Exception while searching",e);
}
return threadsList;
}