Example usage for com.liferay.portal.kernel.search Field ENTRY_CLASS_NAME

List of usage examples for com.liferay.portal.kernel.search Field ENTRY_CLASS_NAME

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.search Field ENTRY_CLASS_NAME.

Prototype

String ENTRY_CLASS_NAME

To view the source code for com.liferay.portal.kernel.search Field ENTRY_CLASS_NAME.

Click Source Link

Usage

From source file:vn.com.ecopharma.emp.service.impl.PromotedHistoryLocalServiceImpl.java

License:Open Source License

public List<Document> searchAllDocuments(SearchContext searchContext, List<Query> filterQueries, long companyId,
        Sort sort, int start, int end) {

    LOGGER.info("FilterQueries size: " + filterQueries.size());
    final BooleanQuery fullQuery = BooleanQueryFactoryUtil.create(searchContext);
    final BooleanQuery allEmployeeEntriesBooleanQuery = BooleanQueryFactoryUtil.create(searchContext);
    final BooleanQuery noneDeletedEmployeesBooleanQuery = BooleanQueryFactoryUtil.create(searchContext);

    allEmployeeEntriesBooleanQuery.addRequiredTerm(Field.ENTRY_CLASS_NAME, PromotedHistory.class.getName());
    noneDeletedEmployeesBooleanQuery.addExactTerm(PromotedHistoryField.IS_DELETED, "false");

    try {//from   w w w.  ja  v  a  2s  . c  om
        // add filter queries
        fullQuery.add(allEmployeeEntriesBooleanQuery, BooleanClauseOccur.MUST);
        if (filterQueries != null && filterQueries.size() > 0) {
            for (Query query : filterQueries) {
                fullQuery.add(query, BooleanClauseOccur.MUST);
            }
        }

        // always filter for none-delete item
        fullQuery.add(noneDeletedEmployeesBooleanQuery, BooleanClauseOccur.MUST);

        final List<Document> documents = SearchEngineUtil
                .search(SearchEngineUtil.getDefaultSearchEngineId(), companyId, fullQuery, sort, start, end)
                .toList();
        System.out.println("RESULT SIZE: " + documents.size());

        return documents;

    } catch (SearchException e) {
        LOGGER.info(e);
    } catch (ParseException e) {
        LOGGER.info(e);
    }
    return null;
}

From source file:vn.com.ecopharma.emp.service.impl.PromotedHistoryLocalServiceImpl.java

License:Open Source License

public Document getIndexedDocument(long id, SearchContext searchContext) {
    searchContext.setPortletIds(new String[] { EMInfo.PORTLET_ID });
    BooleanQuery fullQuery = BooleanQueryFactoryUtil.create(searchContext);
    BooleanQuery booleanQuery = BooleanQueryFactoryUtil.create(searchContext);
    booleanQuery.addRequiredTerm(Field.ENTRY_CLASS_NAME, PromotedHistory.class.getName());
    booleanQuery.addExactTerm(PromotedHistoryField.ID, id);

    try {//from  w  ww.  j  ava2 s  . c  o  m
        fullQuery.add(booleanQuery, BooleanClauseOccur.MUST);
        Hits hits = SearchEngineUtil.search(searchContext, fullQuery);
        return !hits.toList().isEmpty() ? hits.toList().get(0) : null;
    } catch (ParseException e) {
        LOGGER.info(e);
    } catch (SearchException e) {
        LOGGER.info(e);
    }

    return null;
}

From source file:vn.com.ecopharma.emp.service.impl.PromotedHistoryLocalServiceImpl.java

License:Open Source License

public void removeAllIndexes(SearchContext searchContext, long companyId) {
    final BooleanQuery booleanQuery = BooleanQueryFactoryUtil.create(searchContext);
    booleanQuery.addExactTerm(Field.ENTRY_CLASS_NAME, PromotedHistory.class.getName());
    try {//  ww w  .j  a v  a  2s  . c om
        final Hits hits = SearchEngineUtil.search(SearchEngineUtil.getDefaultSearchEngineId(), companyId,
                booleanQuery, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
        final List<Document> docs = hits.toList();
        for (Document doc : docs) {
            LOGGER.info("DELETE ResignationHistory Index UID: " + doc.getUID());
            SearchEngineUtil.deleteDocument(SearchEngineUtil.getDefaultSearchEngineId(), companyId,
                    doc.getUID());

        }
    } catch (SearchException e) {
        e.printStackTrace();
    }
}

From source file:vn.com.ecopharma.emp.service.impl.ResignationHistoryLocalServiceImpl.java

License:Open Source License

public List<Document> searchAllDocuments(SearchContext searchContext, List<Query> filterQueries, long companyId,
        Sort sort, int start, int end) {

    LOGGER.info("FilterQueries size: " + filterQueries.size());
    final BooleanQuery fullQuery = BooleanQueryFactoryUtil.create(searchContext);
    final BooleanQuery allEmployeeEntriesBooleanQuery = BooleanQueryFactoryUtil.create(searchContext);
    final BooleanQuery noneDeletedEmployeesBooleanQuery = BooleanQueryFactoryUtil.create(searchContext);

    allEmployeeEntriesBooleanQuery.addRequiredTerm(Field.ENTRY_CLASS_NAME, ResignationHistory.class.getName());
    noneDeletedEmployeesBooleanQuery.addExactTerm(ResignationHistoryField.IS_DELETED, "false");

    try {/*from w w  w.ja  va 2 s . com*/
        // add filter queries
        fullQuery.add(allEmployeeEntriesBooleanQuery, BooleanClauseOccur.MUST);
        if (filterQueries != null && filterQueries.size() > 0) {
            for (Query query : filterQueries) {
                fullQuery.add(query, BooleanClauseOccur.MUST);
            }
        }

        // always filter for none-delete item
        fullQuery.add(noneDeletedEmployeesBooleanQuery, BooleanClauseOccur.MUST);

        final List<Document> documents = SearchEngineUtil
                .search(SearchEngineUtil.getDefaultSearchEngineId(), companyId, fullQuery, sort, start, end)
                .toList();
        return documents;

    } catch (SearchException e) {
        LOGGER.info(e);
    } catch (ParseException e) {
        LOGGER.info(e);
    }
    return null;
}

From source file:vn.com.ecopharma.emp.service.impl.ResignationHistoryLocalServiceImpl.java

License:Open Source License

public Document getIndexedDocument(long id, SearchContext searchContext) {
    searchContext.setPortletIds(new String[] { EMInfo.PORTLET_ID });
    BooleanQuery fullQuery = BooleanQueryFactoryUtil.create(searchContext);
    BooleanQuery booleanQuery = BooleanQueryFactoryUtil.create(searchContext);
    booleanQuery.addRequiredTerm(Field.ENTRY_CLASS_NAME, ResignationHistory.class.getName());
    booleanQuery.addExactTerm(ResignationHistoryField.ID, id);

    try {//from  w w  w  .j a  v  a  2 s.  co m
        fullQuery.add(booleanQuery, BooleanClauseOccur.MUST);
        Hits hits = SearchEngineUtil.search(searchContext, fullQuery);
        return !hits.toList().isEmpty() ? hits.toList().get(0) : null;
    } catch (ParseException e) {
        LOGGER.info(e);
    } catch (SearchException e) {
        LOGGER.info(e);
    }

    return null;
}

From source file:vn.com.ecopharma.emp.service.impl.ResignationHistoryLocalServiceImpl.java

License:Open Source License

public void removeAllIndexes(SearchContext searchContext, long companyId) {
    final BooleanQuery booleanQuery = BooleanQueryFactoryUtil.create(searchContext);
    booleanQuery.addExactTerm(Field.ENTRY_CLASS_NAME, ResignationHistory.class.getName());
    try {//w ww. j a  v  a  2 s  . c om
        final Hits hits = SearchEngineUtil.search(SearchEngineUtil.getDefaultSearchEngineId(), companyId,
                booleanQuery, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
        final List<Document> docs = hits.toList();
        for (Document doc : docs) {
            LOGGER.info("DELETE ResignationHistory Index UID: " + doc.getUID());
            SearchEngineUtil.deleteDocument(SearchEngineUtil.getDefaultSearchEngineId(), companyId,
                    doc.getUID());

        }
    } catch (SearchException e) {
        LOGGER.info(e);
    }
}

From source file:vn.com.ecopharma.emp.service.impl.VacationLeaveLocalServiceImpl.java

License:Open Source License

public List<Document> searchAllUnDeletedDocuments(SearchContext searchContext, List<Query> filterQueries,
        long companyId, Sort sort, int start, int end) {

    LOGGER.info("FilterQueries size: " + filterQueries.size());
    final BooleanQuery fullQuery = BooleanQueryFactoryUtil.create(searchContext);
    final BooleanQuery allVacationLeaveEntriesBooleanQuery = BooleanQueryFactoryUtil.create(searchContext);
    final BooleanQuery noneDeletedVacationLeaveBooleanQuery = BooleanQueryFactoryUtil.create(searchContext);

    allVacationLeaveEntriesBooleanQuery.addRequiredTerm(Field.ENTRY_CLASS_NAME, VacationLeave.class.getName());
    noneDeletedVacationLeaveBooleanQuery.addExactTerm(VacationLeaveField.IS_DELETED, "false");

    try {//from  ww  w  . j  a  v a 2 s.  c o  m
        // add filter queries
        fullQuery.add(allVacationLeaveEntriesBooleanQuery, BooleanClauseOccur.MUST);
        if (filterQueries != null && filterQueries.size() > 0) {
            for (Query query : filterQueries) {
                fullQuery.add(query, BooleanClauseOccur.MUST);
            }
        }

        // always filter for none-delete item
        fullQuery.add(noneDeletedVacationLeaveBooleanQuery, BooleanClauseOccur.MUST);

        sort = sort != null ? sort : new Sort(VacationLeaveField.ID, true);

        final List<Document> documents = SearchEngineUtil
                .search(SearchEngineUtil.getDefaultSearchEngineId(), companyId, fullQuery, sort, start, end)
                .toList();
        return documents;

    } catch (SearchException e) {
        LOGGER.info(e);
    } catch (ParseException e) {
        LOGGER.info(e);
    }
    return new ArrayList<>();
}

From source file:vn.com.ecopharma.emp.service.impl.VacationLeaveLocalServiceImpl.java

License:Open Source License

public void removeAllIndexes(SearchContext searchContext, long companyId) {
    final BooleanQuery booleanQuery = BooleanQueryFactoryUtil.create(searchContext);
    booleanQuery.addExactTerm(Field.ENTRY_CLASS_NAME, VacationLeave.class.getName());
    try {//from  w ww .  ja  va2 s  .  co m
        final Hits hits = SearchEngineUtil.search(SearchEngineUtil.getDefaultSearchEngineId(), companyId,
                booleanQuery, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
        final List<Document> docs = hits.toList();
        for (Document doc : docs) {
            SearchEngineUtil.deleteDocument(SearchEngineUtil.getDefaultSearchEngineId(), companyId,
                    doc.getUID());

        }
    } catch (SearchException e) {
        LOGGER.info(e);
    }
}

From source file:vn.com.ecopharma.emp.service.impl.VacationLeaveLocalServiceImpl.java

License:Open Source License

public Document getIndexedDocument(long id, SearchContext searchContext) {
    searchContext.setPortletIds(new String[] { EMInfo.PORTLET_ID });
    BooleanQuery fullQuery = BooleanQueryFactoryUtil.create(searchContext);
    BooleanQuery booleanQuery = BooleanQueryFactoryUtil.create(searchContext);
    booleanQuery.addRequiredTerm(Field.ENTRY_CLASS_NAME, VacationLeave.class.getName());
    booleanQuery.addExactTerm(VacationLeaveField.ID, id);

    try {/*from   w ww .  j av  a2  s .  c o  m*/
        fullQuery.add(booleanQuery, BooleanClauseOccur.MUST);
        Hits hits = SearchEngineUtil.search(searchContext, fullQuery);
        return !hits.toList().isEmpty() ? hits.toList().get(0) : null;
    } catch (ParseException e) {
        LOGGER.info(e);
    } catch (SearchException e) {
        LOGGER.info(e);
    }

    return null;
}

From source file:vn.com.ecopharma.hrm.rc.service.impl.CandidateLocalServiceImpl.java

License:Open Source License

public List<Document> searchAllUnDeletedCandidatesIndexedDocument(SearchContext searchContext,
        List<Query> filterQueries, long companyId, Sort sort, int start, int end) {

    LOGGER.info("FilterQueries size: " + filterQueries.size());
    final BooleanQuery fullQuery = BooleanQueryFactoryUtil.create(searchContext);
    final BooleanQuery allCandidateEntriesBooleanQuery = BooleanQueryFactoryUtil.create(searchContext);
    final BooleanQuery noneDeletedCandidateBooleanQuery = BooleanQueryFactoryUtil.create(searchContext);

    allCandidateEntriesBooleanQuery.addRequiredTerm(Field.ENTRY_CLASS_NAME, Candidate.class.getName());
    noneDeletedCandidateBooleanQuery.addExactTerm(CandidateField.IS_DELETED, "false");

    try {/*from w  w  w.  ja  va 2  s  .c  om*/
        // add filter queries
        fullQuery.add(allCandidateEntriesBooleanQuery, BooleanClauseOccur.MUST);
        if (filterQueries != null && !filterQueries.isEmpty()) {
            for (Query query : filterQueries) {
                fullQuery.add(query, BooleanClauseOccur.MUST);
            }
        }

        // always filter for none-delete item
        fullQuery.add(noneDeletedCandidateBooleanQuery, BooleanClauseOccur.MUST);

        /* SORT */
        if (sort == null) {
            sort = new Sort(CandidateField.CANDIDATE_ID, false);
        }

        return SearchEngineUtil
                .search(SearchEngineUtil.getDefaultSearchEngineId(), companyId, fullQuery, sort, start, end)
                .toList();
    } catch (SearchException e) {
        LOGGER.info(e);
    } catch (ParseException e) {
        LOGGER.info(e);
    }
    return new ArrayList<>();
}