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

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

Introduction

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

Prototype

String TITLE

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

Click Source Link

Usage

From source file:com.vportal.portlet.vcms.util.SearchIndexer.java

License:Open Source License

public static Document getAddArticleDocument(long companyId, long groupId, String articleId, String title,
        String description, String content) throws NumberFormatException, PortalException, SystemException {

    InputStream is = null;/*from   w ww  .j a  v  a2s.  co  m*/
    List addedAttachments = AttachmentLocalServiceUtil.getAttachments(Long.parseLong(articleId),
            VcmsArticle.class);
    for (int i = 0; i < addedAttachments.size(); i++) {
        Attachment attachment = (Attachment) addedAttachments.get(i);
        DLFileEntry entry = null;
        try {
            entry = (DLFileEntry) DLFileEntryLocalServiceUtil.getFileEntry(attachment.getFileEntryId());
            /*String fileExtension = entry.getTitleWithExtension();
            String extension = fileExtension.substring(fileExtension.lastIndexOf(".")+1,fileExtension.length());*/
            String extension = entry.getExtension();
            is = DLLocalServiceUtil.getFileAsStream(companyId, entry.getFolderId(), entry.getName());
            content = FileUtilExt.getContentFile(is, content, extension);
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }
    }
    content = HtmlUtil.extractText(content);
    Document doc = new DocumentImpl();
    doc.addUID(PORTLET_ID, articleId);

    doc.addKeyword(Field.COMPANY_ID, companyId);
    doc.addKeyword(Field.PORTLET_ID, PORTLET_ID);
    doc.addKeyword(Field.GROUP_ID, groupId);

    doc.addText(Field.TITLE, title);
    doc.addText(Field.CONTENT, content);
    doc.addText(Field.DESCRIPTION, description);
    doc.addModifiedDate();

    doc.addKeyword(Field.ENTRY_CLASS_NAME, VcmsArticle.class.getName());
    doc.addKeyword(Field.ENTRY_CLASS_PK, articleId);
    return doc;
}

From source file:com.vportal.portlet.vcms.util.SearchIndexer.java

License:Open Source License

public Summary getDocumentSummary(com.liferay.portal.kernel.search.Document doc, PortletURL portletURL) {

    // Title/* w  w  w .  j av a  2 s  . c  o m*/

    String title = doc.get(Field.TITLE);

    // Content

    String content = doc.get(Field.CONTENT);

    content = StringUtil.shorten(content, 200);

    // Portlet URL

    String articleId = doc.get(Field.ENTRY_CLASS_PK);

    portletURL.setParameter("struts_action", "/vcmsviewcontent/view");
    portletURL.setParameter("articleId", articleId);
    VcmsCARelation category = null;
    try {
        category = VcmsCARelationServiceUtil.findRelationsByArticle(articleId);
    } catch (Exception e) {
        // TODO: handle exception
    }
    String categoryId = "";
    if (category != null) {
        categoryId = String.valueOf(category.getCategoryId());
    }
    portletURL.setParameter("categoryId", categoryId);
    return new Summary(title, content, portletURL);
}

From source file:com.vportal.portlet.vfaq.service.impl.FAQQuestionLocalServiceImpl.java

License:Open Source License

public Hits search(long companyId, long groupId, long userId, String keywords, int start, int end)
        throws SystemException {
    try {/* w  ww .  j ava  2s .c o  m*/
        BooleanQuery contextQuery = BooleanQueryFactoryUtil.create();

        contextQuery.addRequiredTerm(Field.PORTLET_ID, PortletKeysExt.FAQ_QUESTION);

        if (groupId > 0) {
            contextQuery.addRequiredTerm(Field.GROUP_ID, groupId);
        }

        if (userId > 0) {
            contextQuery.addRequiredTerm(Field.USER_ID, userId);
        }

        BooleanQuery searchQuery = BooleanQueryFactoryUtil.create();

        if (Validator.isNotNull(keywords)) {
            searchQuery.addTerm(Field.TITLE, keywords);
            searchQuery.addTerm(Field.CONTENT, keywords);
            /*searchQuery.addTerm(Field.TAGS_ENTRIES, keywords);*/
        }

        BooleanQuery fullQuery = BooleanQueryFactoryUtil.create();

        fullQuery.add(contextQuery, BooleanClauseOccur.MUST);

        if (searchQuery.clauses().size() > 0) {
            fullQuery.add(searchQuery, BooleanClauseOccur.MUST);
        }

        return SearchEngineUtil.search(companyId, fullQuery, start, end);
    } catch (Exception e) {
        throw new SystemException(e);
    }
}

From source file:com.vportal.portlet.vlegal.service.impl.VLegalDocumentServiceImpl.java

License:Open Source License

public Hits search(long companyId, long groupId, long userId, String keywords, int start, int end)
        throws SystemException {
    try {//from www  .j a  v  a 2 s . c om
        BooleanQuery contextQuery = BooleanQueryFactoryUtil.create();

        contextQuery.addRequiredTerm(Field.PORTLET_ID, PortletKeysExt.VLEGAL);

        if (groupId > 0) {
            contextQuery.addRequiredTerm(Field.GROUP_ID, groupId);
        }

        if (userId > 0) {
            contextQuery.addRequiredTerm(Field.USER_ID, userId);
        }

        BooleanQuery searchQuery = BooleanQueryFactoryUtil.create();

        if (Validator.isNotNull(keywords)) {
            searchQuery.addTerm(Field.TITLE, keywords);
            searchQuery.addTerm(Field.CONTENT, keywords);
            searchQuery.addTerm(Field.ASSET_TAG_NAMES, keywords);
        }

        BooleanQuery fullQuery = BooleanQueryFactoryUtil.create();

        fullQuery.add(contextQuery, BooleanClauseOccur.MUST);

        if (searchQuery.clauses().size() > 0) {
            fullQuery.add(searchQuery, BooleanClauseOccur.MUST);
        }

        return SearchEngineUtil.search(companyId, fullQuery, start, end);
    } catch (Exception e) {
        throw new SystemException(e);
    }
}

From source file:gr.open.loglevelsmanager.loglevel.util.LogLevelIndexer.java

License:Open Source License

@Override
protected Summary doGetSummary(Document document, Locale locale, String snippet, PortletURL portletURL) {

    String title = document.get(Field.TITLE);

    String content = snippet;//  ww w.  ja  v a  2s . co  m

    if (Validator.isNull(snippet)) {
        content = StringUtil.shorten(document.get(Field.CONTENT), 200);
    }

    String entryId = document.get(Field.ENTRY_CLASS_PK);
    String groupId = document.get(Field.GROUP_ID);

    long plid = 0;

    try {
        plid = LogLevelUtil.getPlid(Long.parseLong(groupId));
    } catch (Exception e) {
    }

    portletURL.setParameter("p_l_id", String.valueOf(plid));
    portletURL.setParameter("view", "editLogLevel");
    portletURL.setParameter("LogLevelId", String.valueOf(entryId));
    portletURL.setParameter("editType", "view");

    return new Summary(title, content, portletURL);
}

From source file:org.fit.portlet.service.service.impl.InserFitxaPersonalLocalServiceImpl.java

License:Open Source License

private Hits searchFitxaPersonalHits(long companyId, long groupId, long[] organizationIds, String searchText,
        long tecnicReferent, long codiProjecte, long serveiSocial, int start, int end, String orderByCol,
        String orderByType) {//from  w ww.  j  a  v a 2 s. c  o  m

    try {
        String searchEngineId = SearchEngineUtil.getDefaultSearchEngineId();

        SearchEngine searchEngine = SearchEngineUtil.getSearchEngine(searchEngineId);

        BooleanQueryFactory booleanQueryFactory = searchEngine.getBooleanQueryFactory();

        BooleanQuery query = booleanQueryFactory.create();

        // Context query
        query.addRequiredTerm(Field.COMPANY_ID, companyId);

        query.addRequiredTerm(Field.CLASS_NAME_ID, InserFitxaPersonal.class.getName());

        if (groupId > -1) {
            query.addRequiredTerm(Field.GROUP_ID, groupId);
        }

        if (Validator.isNotNull(organizationIds)) {

            BooleanQuery organizationQuery = booleanQueryFactory.create();

            if (organizationIds.length > 1 && organizationIds[0] == -2) {

                BooleanQuery q = booleanQueryFactory.create();

                SearchContext searchContext = new SearchContext();
                TermRangeQuery oq = TermRangeQueryFactoryUtil.create(searchContext, Field.ORGANIZATION_ID, "-1",
                        "0", true, false);

                q.add(oq, BooleanClauseOccur.SHOULD);

                // L'usuari vol veure tots els que estan sense localitzaci
                query.add(q, BooleanClauseOccur.MUST);
            } else {

                for (long idorg : organizationIds) {
                    if (idorg > -1) {
                        organizationQuery.addTerm(Field.ORGANIZATION_ID, idorg);
                    }
                }
            }

            if (organizationQuery.hasClauses()) {
                query.add(organizationQuery, BooleanClauseOccur.MUST);
            }

        }

        if (Validator.isNotNull(searchText)) {

            BooleanQuery searchTextQuery = booleanQueryFactory.create();

            searchTextQuery.addExactTerm(GestioPersonesIndexConstants.NUM_EXPEDIENT, searchText);
            searchTextQuery.addExactTerm(GestioPersonesIndexConstants.DNI, searchText);
            searchTextQuery.addTerm(Field.DESCRIPTION, searchText);
            searchTextQuery.addTerm(Field.TITLE, searchText);
            searchTextQuery.addTerm(GestioPersonesIndexConstants.TECNIC_REFERENT, searchText);
            searchTextQuery.addTerm(GestioPersonesIndexConstants.OBSERVACIONS, searchText);
            searchTextQuery.addTerm(GestioPersonesIndexConstants.SEGUIMENT_ITINERARI, searchText);
            searchTextQuery.addTerm(GestioPersonesIndexConstants.SEGUIMENT_ITINERARI, searchText);

            query.add(searchTextQuery, BooleanClauseOccur.MUST);

        }
        // Cerca avanada
        if (tecnicReferent > -1) {
            query.addRequiredTerm(GestioPersonesIndexConstants.TECNIC_REFERENT_ID, tecnicReferent);
        }

        if (codiProjecte > -1) {
            query.addRequiredTerm(GestioPersonesIndexConstants.CODI_PROJECTE_ID, codiProjecte);
        }

        if (serveiSocial > -1) {
            query.addRequiredTerm(GestioPersonesIndexConstants.SERVEI_SOCIAL_ID, serveiSocial);
        }

        Sort sort = new Sort();
        sort.setReverse(false);

        if (Validator.isNotNull(orderByCol)) {

            int type = getType(orderByCol);

            sort.setType(type);

            sort.setFieldName(orderByCol);

            if (Validator.isNotNull(orderByType)) {

                if (orderByType.equalsIgnoreCase("desc")) {
                    sort.setReverse(true);
                }

            }

        }

        log.info(query.toString() + " " + sort.toString());

        Hits search = SearchEngineUtil.search(searchEngineId, companyId, query, sort, start, end);

        return search;
    } catch (SearchException e) {
        log.error(e);
    } catch (ParseException e) {
        log.error(e);
    }

    return null;
}

From source file:org.liferay.jukebox.util.AlbumIndexer.java

License:Open Source License

@Override
public void postProcessSearchQuery(BooleanQuery searchQuery, SearchContext searchContext) throws Exception {

    if (searchContext.getAttributes() == null) {
        return;//from w  ww. ja va  2 s.c o  m
    }

    addSearchTerm(searchQuery, searchContext, Field.TITLE, true);
    addSearchTerm(searchQuery, searchContext, "artist", true);
    addSearchTerm(searchQuery, searchContext, "year", false);
}

From source file:org.liferay.jukebox.util.AlbumIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(Object obj) throws Exception {
    Album album = (Album) obj;//from   w ww  .  ja  v a  2s.  c o  m

    Document document = getBaseModelDocument(PORTLET_ID, album);

    document.addDate(Field.MODIFIED_DATE, album.getModifiedDate());
    document.addText(Field.TITLE, album.getName());
    document.addKeyword("year", album.getYear());

    Artist artist = ArtistLocalServiceUtil.getArtist(album.getArtistId());

    document.addText("artist", artist.getName());
    document.addKeyword("artistId", artist.getArtistId());

    return document;
}

From source file:org.liferay.jukebox.util.ArtistIndexer.java

License:Open Source License

@Override
public void postProcessSearchQuery(BooleanQuery searchQuery, SearchContext searchContext) throws Exception {

    if (searchContext.getAttributes() == null) {
        return;//  w w w. j av a  2s .  c  o  m
    }

    addSearchTerm(searchQuery, searchContext, Field.TITLE, true);
    addSearchTerm(searchQuery, searchContext, "bio", true);
}

From source file:org.liferay.jukebox.util.ArtistIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(Object obj) throws Exception {
    Artist artist = (Artist) obj;//from ww w  .j  a  v  a 2 s  .  co  m

    Document document = getBaseModelDocument(PORTLET_ID, artist);

    document.addDate(Field.MODIFIED_DATE, artist.getModifiedDate());
    document.addText(Field.TITLE, artist.getName());
    document.addKeyword("artistId", artist.getArtistId());
    document.addText("bio", artist.getBio());

    return document;
}