private Query createSearchPageQuery(QueryCriteria queryCriteria, QueryManager queryManager) throws Exception { SQLQueryBuilder queryBuilder = new SQLQueryBuilder(); List<String> mopPages = this.searchPageByTitle(queryCriteria.getSiteName(), queryCriteria.getKeyword()); List<QueryProperty> queryProps = new ArrayList<QueryCriteria.QueryProperty>(); for (String page : mopPages) { QueryProperty prop = queryCriteria.new QueryProperty(); prop.setName("mop:page"); prop.setValue(page); prop.setComparisonType(COMPARISON_TYPE.EQUAL); queryProps.add(prop); } QueryProperty prop = queryCriteria.new QueryProperty(); prop.setName("exo:name"); prop.setValue("mop:" + queryCriteria.getKeyword().toLowerCase()); queryProps.add(prop); queryCriteria.setQueryMetadatas(queryProps.toArray(new QueryProperty[queryProps.size()])); mapQueryTypes(queryCriteria, queryBuilder); if (queryCriteria.isFulltextSearch()) { mapQueryPath(queryCriteria, queryBuilder); mapFulltextQueryTearm(queryCriteria, queryBuilder, LOGICAL.OR); } else { searchByNodeName(queryCriteria, queryBuilder); } mapCategoriesCondition(queryCriteria, queryBuilder); mapDatetimeRangeSelected(queryCriteria, queryBuilder); mapMetadataProperties(queryCriteria, queryBuilder, LOGICAL.OR); orderBy(queryCriteria, queryBuilder); String queryStatement = queryBuilder.createQueryStatement(); Query query = queryManager.createQuery(queryStatement, Query.SQL); return query; }
/** * Gets the site path. * * @param queryCriteria the query criteria * @return the site path * @throws Exception the exception */ private String getSitePath(final QueryCriteria queryCriteria) throws Exception { String siteName = queryCriteria.getSiteName(); if (queryCriteria.isSearchWebpage()) { if ("all".equals(siteName) || siteName == null || siteName.trim().length() == 0) { return "/production/mop:workspace/mop:portalsites"; } return "/production/mop:workspace/mop:portalsites/mop:" + siteName; } String sitePath = null; if (siteName != null) { sitePath = livePortalManagerService.getPortalPathByName(siteName); } else { sitePath = configurationService.getLivePortalsLocation().getPath(); } return sitePath; }
/** * Gets the site path. * * @param queryCriteria the query criteria * @return the site path * @throws Exception the exception */ private String getPath(final QueryCriteria queryCriteria) throws Exception { String siteName = queryCriteria.getSiteName(); // search page path if (queryCriteria.isSearchWebpage()) { if ("all".equals(siteName) || siteName == null || siteName.trim().length() == 0) { return PATH_PORTAL_SITES; } return PATH_PORTAL_SITES.concat("/mop:").concat(siteName); } // search document path if (queryCriteria.getSearchPath() != null) { return queryCriteria.getSearchPath(); } String sitePath = null; if (siteName != null) { sitePath = livePortalManagerService.getPortalPathByName(siteName); } else { sitePath = configurationService.getLivePortalsLocation().getPath(); } return sitePath; }