List of usage examples for com.liferay.portal.kernel.search Indexer reindex
@Bufferable
public void reindex(T object) throws SearchException;
From source file:at.meduni.liferay.portlet.bbmrieric.service.impl.D2BiobankLocalServiceImpl.java
License:Open Source License
/** * // w w w. ja v a2s . c o m * @param biobankId * @param serviceContext * @return */ public D2Biobank addD2Biobank(long biobankId, long companyId, long groupId, long userId, String biobankName, String ldapbiobankID, String ldapupdateuuid, String contactIDRef, long contactPriority, String biobankJurisdicalPerson, String biobankCountry, boolean biobankPartnerCharterSigned, String bioresourceReference, String biobankNetworkIDRef, String geoLatitude, String geoLongitude, boolean collaborationPartnersCommercial, boolean collaborationPartnersNonforprofit, boolean biobankITSupportAvailable, long biobankITStaffSize, boolean biobankISAvailable, boolean biobankHISAvailable, String biobankAcronym, String biobankDescription, String biobankURL, String biobankHeadFirstName, String biobankHeadLastName, String biobankHeadRole, boolean biobankClinical, boolean biobankPopulation, boolean biobankResearchStudy, boolean biobankNonHuman, boolean biobankCollection, String biobankType, ServiceContext serviceContext) { try { // Create the Biobank Entry // Set Primary Key if (biobankId == 0) { biobankId = counterLocalService.increment(); } D2Biobank d2biobank = d2BiobankPersistence.create(biobankId); // Set provenance fields if (companyId == 0) { companyId = serviceContext.getCompanyId(); } if (groupId == 0) { groupId = serviceContext.getScopeGroupId(); } if (userId == 0) { userId = serviceContext.getUserId(); } Date now = new Date(); d2biobank.setCreateDate(serviceContext.getCreateDate(now)); d2biobank.setModifiedDate(serviceContext.getModifiedDate(now)); d2biobank.setUserId(userId); d2biobank.setGroupId(groupId); d2biobank.setCompanyId(companyId); // Set mandatory fields d2biobank.setBiobankName(biobankName); d2biobank.setBbmribiobankID(ldapbiobankID); d2biobank.setUpdateuuid(ldapupdateuuid); d2biobank.setContactIDRef(contactIDRef); d2biobank.setContactPriority(contactPriority); d2biobank.setBiobankJurisdicalPerson(biobankJurisdicalPerson); d2biobank.setBiobankCountry(biobankCountry.toUpperCase()); d2biobank.setBiobankPartnerCharterSigned(biobankPartnerCharterSigned); // Set optional fields d2biobank.setBioresourceReference(bioresourceReference); d2biobank.setBiobankNetworkIDRef(biobankNetworkIDRef); d2biobank.setGeoLatitude(geoLatitude); d2biobank.setGeoLongitude(geoLongitude); d2biobank.setCollaborationPartnersCommercial(collaborationPartnersCommercial); d2biobank.setCollaborationPartnersNonforprofit(collaborationPartnersNonforprofit); d2biobank.setBiobankITSupportAvailable(biobankITSupportAvailable); d2biobank.setBiobankITStaffSize(biobankITStaffSize); d2biobank.setBiobankISAvailable(biobankISAvailable); d2biobank.setBiobankHISAvailable(biobankHISAvailable); d2biobank.setBiobankAcronym(biobankAcronym); d2biobank.setBiobankDescription(biobankDescription); d2biobank.setBiobankURL(biobankURL); d2biobank.setBiobankHeadFirstName(biobankHeadFirstName); d2biobank.setBiobankHeadLastName(biobankHeadLastName); d2biobank.setBiobankHeadRole(biobankHeadRole); d2biobank.setBiobankClinical(biobankClinical); d2biobank.setBiobankPopulation(biobankPopulation); d2biobank.setBiobankResearchStudy(biobankResearchStudy); d2biobank.setBiobankNonHuman(biobankNonHuman); d2biobank.setBiobankCollection(biobankCollection); d2biobank.setBiobankType(biobankType); // Liferay Expension Fields d2biobank.setExpandoBridgeAttributes(serviceContext); d2BiobankPersistence.update(d2biobank); // Add Asset Entry to Liferay resourceLocalService.addResources(companyId, groupId, userId, D2Biobank.class.getName(), biobankId, false, true, true); AssetEntry assetEntry = assetEntryLocalService.updateEntry(userId, groupId, d2biobank.getCreateDate(), d2biobank.getModifiedDate(), D2Biobank.class.getName(), d2biobank.getBiobankId(), d2biobank.getUuid(), 0, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), true, null, null, null, ContentTypes.TEXT_HTML, d2biobank.getBiobankName(), d2biobank.getBiobankDescription(), null, null, null, 0, 0, null, false); //updateEntry(userId, groupId, createDate, modifiedDate, className, classPK, classUuid, classTypeId=0, categoryIds, tagNames, visible, startDate, endDate, expirationDate, mimeType, title, description, summary, url, layoutUuid, height, width, priority, sync) assetLinkLocalService.updateLinks(userId, assetEntry.getEntryId(), serviceContext.getAssetLinkEntryIds(), AssetLinkConstants.TYPE_RELATED); Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(D2Biobank.class); indexer.reindex(d2biobank); return d2biobank; } catch (Exception e) { System.out.println("[" + date_format_apache_error.format(new Date()) + "] [error] [BBMRIERICDatabase-portlet::at.meduni.liferay.portlet.bbmrieric.service.impl.D2BiobankLocalServiceImpl::addD2Biobank] Error creating D2Biobank with (D2Biobank newbiobank, ServiceContext serviceContext)."); e.printStackTrace(); } return null; }
From source file:at.meduni.liferay.portlet.bbmrieric.service.impl.D2BiobankLocalServiceImpl.java
License:Open Source License
/** * //from w w w. j ava 2 s. co m * @param newbiobank * @param serviceContext * @return */ public D2Biobank updateD2Biobank(D2Biobank d2biobank, ServiceContext serviceContext) { try { // Set provenance fields if (d2biobank.getUserId() == 0) { d2biobank.setUserId(serviceContext.getUserId()); } Date now = new Date(); d2biobank.setModifiedDate(serviceContext.getModifiedDate(now)); d2biobank.setBiobankCountry(d2biobank.getBiobankCountry().toUpperCase()); // Liferay Expension Fields d2biobank.setExpandoBridgeAttributes(serviceContext); d2BiobankPersistence.update(d2biobank); // Add Asset Entry to Liferay resourceLocalService.updateResources(d2biobank.getCompanyId(), d2biobank.getGroupId(), d2biobank.getBiobankName(), d2biobank.getBiobankId(), serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions()); AssetEntry assetEntry = assetEntryLocalService.updateEntry(d2biobank.getUserId(), d2biobank.getGroupId(), d2biobank.getCreateDate(), d2biobank.getModifiedDate(), D2Biobank.class.getName(), d2biobank.getBiobankId(), d2biobank.getUuid(), 0, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), true, null, null, null, ContentTypes.TEXT_HTML, d2biobank.getBiobankName(), d2biobank.getBiobankDescription(), null, null, null, 0, 0, null, false); //updateEntry(userId, groupId, createDate, modifiedDate, className, classPK, classUuid, classTypeId=0, categoryIds, tagNames, visible, startDate, endDate, expirationDate, mimeType, title, description, summary, url, layoutUuid, height, width, priority, sync) assetLinkLocalService.updateLinks(d2biobank.getUserId(), assetEntry.getEntryId(), serviceContext.getAssetLinkEntryIds(), AssetLinkConstants.TYPE_RELATED); Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(D2Biobank.class); indexer.reindex(d2biobank); return d2biobank; } catch (Exception e) { System.out.println("[" + date_format_apache_error.format(new Date()) + "] [error] [BBMRIERICDatabase-portlet::at.meduni.liferay.portlet.bbmrieric.service.impl.D2BiobankLocalServiceImpl::updateD2Biobank] Error updateing D2Biobank with (D2Biobank newbiobank, ServiceContext serviceContext)."); e.printStackTrace(); } return null; }
From source file:at.meduni.liferay.portlet.bbmrieric.service.impl.D2BiobankLocalServiceImpl.java
License:Open Source License
/** * //from w ww .java 2s.co m * @param biobankId * @param serviceContext * @return */ public D2Biobank updateD2Biobank(long biobankId, long userId, String biobankName, String ldapbiobankID, String ldapupdateuuid, String contactIDRef, long contactPriority, String biobankJurisdicalPerson, String biobankCountry, boolean biobankPartnerCharterSigned, String bioresourceReference, String biobankNetworkIDRef, String geoLatitude, String geoLongitude, boolean collaborationPartnersCommercial, boolean collaborationPartnersNonforprofit, boolean biobankITSupportAvailable, long biobankITStaffSize, boolean biobankISAvailable, boolean biobankHISAvailable, String biobankAcronym, String biobankDescription, String biobankURL, String biobankHeadFirstName, String biobankHeadLastName, String biobankHeadRole, boolean biobankClinical, boolean biobankPopulation, boolean biobankResearchStudy, boolean biobankNonHuman, boolean biobankCollection, String biobankType, ServiceContext serviceContext) { try { // Update the Biobank Entry D2Biobank d2biobank = getD2Biobank(biobankId); // Set provenance fields if (userId == 0) { userId = serviceContext.getUserId(); } Date now = new Date(); d2biobank.setModifiedDate(serviceContext.getModifiedDate(now)); d2biobank.setUserId(userId); // Set mandatory fields d2biobank.setBiobankName(biobankName); d2biobank.setBbmribiobankID(ldapbiobankID); d2biobank.setUpdateuuid(ldapupdateuuid); d2biobank.setContactIDRef(contactIDRef); d2biobank.setContactPriority(contactPriority); d2biobank.setBiobankJurisdicalPerson(biobankJurisdicalPerson); if (biobankCountry.equalsIgnoreCase("ee")) { biobankCountry = "et"; } d2biobank.setBiobankCountry(biobankCountry); d2biobank.setBiobankPartnerCharterSigned(biobankPartnerCharterSigned); // Set optional fields d2biobank.setBioresourceReference(bioresourceReference); d2biobank.setBiobankNetworkIDRef(biobankNetworkIDRef); d2biobank.setGeoLatitude(geoLatitude); d2biobank.setGeoLongitude(geoLongitude); d2biobank.setCollaborationPartnersCommercial(collaborationPartnersCommercial); d2biobank.setCollaborationPartnersNonforprofit(collaborationPartnersNonforprofit); d2biobank.setBiobankITSupportAvailable(biobankITSupportAvailable); d2biobank.setBiobankITStaffSize(biobankITStaffSize); d2biobank.setBiobankISAvailable(biobankISAvailable); d2biobank.setBiobankHISAvailable(biobankHISAvailable); d2biobank.setBiobankAcronym(biobankAcronym); d2biobank.setBiobankDescription(biobankDescription); d2biobank.setBiobankURL(biobankURL); d2biobank.setBiobankHeadFirstName(biobankHeadFirstName); d2biobank.setBiobankHeadLastName(biobankHeadLastName); d2biobank.setBiobankHeadRole(biobankHeadRole); d2biobank.setBiobankClinical(biobankClinical); d2biobank.setBiobankPopulation(biobankPopulation); d2biobank.setBiobankResearchStudy(biobankResearchStudy); d2biobank.setBiobankNonHuman(biobankNonHuman); d2biobank.setBiobankCollection(biobankCollection); d2biobank.setBiobankType(biobankType); // Liferay Expension Fields d2biobank.setExpandoBridgeAttributes(serviceContext); d2BiobankPersistence.update(d2biobank); // Add Asset Entry to Liferay resourceLocalService.updateResources(d2biobank.getCompanyId(), d2biobank.getGroupId(), d2biobank.getBiobankName(), biobankId, serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions()); AssetEntry assetEntry = assetEntryLocalService.updateEntry(userId, d2biobank.getGroupId(), d2biobank.getCreateDate(), d2biobank.getModifiedDate(), D2Biobank.class.getName(), d2biobank.getBiobankId(), d2biobank.getUuid(), 0, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), true, null, null, null, ContentTypes.TEXT_HTML, d2biobank.getBiobankName(), d2biobank.getBiobankDescription(), null, null, null, 0, 0, null, false); //updateEntry(userId, groupId, createDate, modifiedDate, className, classPK, classUuid, classTypeId=0, categoryIds, tagNames, visible, startDate, endDate, expirationDate, mimeType, title, description, summary, url, layoutUuid, height, width, priority, sync) assetLinkLocalService.updateLinks(userId, assetEntry.getEntryId(), serviceContext.getAssetLinkEntryIds(), AssetLinkConstants.TYPE_RELATED); Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(D2Biobank.class); indexer.reindex(d2biobank); return d2biobank; } catch (Exception e) { System.out.println("[" + date_format_apache_error.format(new Date()) + "] [error] [BBMRIERICDatabase-portlet::at.meduni.liferay.portlet.bbmrieric.service.impl.D2BiobankLocalServiceImpl::updateD2Biobank] Error updateing D2Biobank with (D2Biobank newbiobank, ServiceContext serviceContext)."); e.printStackTrace(); } return null; }
From source file:br.com.seatecnologia.banner.service.base.BannerLocalServiceBaseImpl.java
License:Open Source License
/** * Adds the banner to the database. Also notifies the appropriate model listeners. * * @param banner the banner//from w ww . j a v a2 s. co m * @return the banner that was added * @throws SystemException if a system exception occurred */ public Banner addBanner(Banner banner) throws SystemException { banner.setNew(true); banner = bannerPersistence.update(banner, false); Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName()); if (indexer != null) { try { indexer.reindex(banner); } catch (SearchException se) { if (_log.isWarnEnabled()) { _log.warn(se, se); } } } return banner; }
From source file:br.com.seatecnologia.banner.service.base.BannerLocalServiceBaseImpl.java
License:Open Source License
/** * Updates the banner in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners. * * @param banner the banner/*from w w w .j av a 2 s .c o m*/ * @param merge whether to merge the banner with the current session. See {@link com.liferay.portal.service.persistence.BatchSession#update(com.liferay.portal.kernel.dao.orm.Session, com.liferay.portal.model.BaseModel, boolean)} for an explanation. * @return the banner that was updated * @throws SystemException if a system exception occurred */ public Banner updateBanner(Banner banner, boolean merge) throws SystemException { banner.setNew(false); banner = bannerPersistence.update(banner, merge); Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName()); if (indexer != null) { try { indexer.reindex(banner); } catch (SearchException se) { if (_log.isWarnEnabled()) { _log.warn(se, se); } } } return banner; }
From source file:br.com.seatecnologia.cldf.enquetenoticia.service.base.EnqueteNoticiaLocalServiceBaseImpl.java
License:Open Source License
/** * Adds the enquete noticia to the database. Also notifies the appropriate model listeners. * * @param enqueteNoticia the enquete noticia * @return the enquete noticia that was added * @throws SystemException if a system exception occurred *///from w ww . ja va2 s . c om public EnqueteNoticia addEnqueteNoticia(EnqueteNoticia enqueteNoticia) throws SystemException { enqueteNoticia.setNew(true); enqueteNoticia = enqueteNoticiaPersistence.update(enqueteNoticia, false); Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName()); if (indexer != null) { try { indexer.reindex(enqueteNoticia); } catch (SearchException se) { if (_log.isWarnEnabled()) { _log.warn(se, se); } } } return enqueteNoticia; }
From source file:br.com.seatecnologia.cldf.enquetenoticia.service.base.EnqueteNoticiaLocalServiceBaseImpl.java
License:Open Source License
/** * Updates the enquete noticia in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners. * * @param enqueteNoticia the enquete noticia * @param merge whether to merge the enquete noticia with the current session. See {@link com.liferay.portal.service.persistence.BatchSession#update(com.liferay.portal.kernel.dao.orm.Session, com.liferay.portal.model.BaseModel, boolean)} for an explanation. * @return the enquete noticia that was updated * @throws SystemException if a system exception occurred *//* ww w .j a va2s.c o m*/ public EnqueteNoticia updateEnqueteNoticia(EnqueteNoticia enqueteNoticia, boolean merge) throws SystemException { enqueteNoticia.setNew(false); enqueteNoticia = enqueteNoticiaPersistence.update(enqueteNoticia, merge); Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName()); if (indexer != null) { try { indexer.reindex(enqueteNoticia); } catch (SearchException se) { if (_log.isWarnEnabled()) { _log.warn(se, se); } } } return enqueteNoticia; }
From source file:br.com.seatecnologia.treinamento.service.impl.ModeloLocalServiceImpl.java
License:Open Source License
@Override public Modelo addModelo(Modelo modelo) throws SystemException { Long modeloId = counterLocalService.increment(Modelo.class.getName()); modelo.setModeloId(modeloId);/*from ww w . j a va 2 s . c om*/ modelo.setNew(true); Indexer indexer = IndexerRegistryUtil.getIndexer(Modelo.class.getName()); try { indexer.reindex(modelo); return super.addModelo(modelo); } catch (SearchException e) { e.printStackTrace(); return null; } }
From source file:ca.efendi.datafeeds.service.impl.CJProductLocalServiceImpl.java
License:Open Source License
@Override @Indexable(type = IndexableType.REINDEX) public CJProduct refresh(final FtpSubscription subscription, final CJProduct newCJProduct) throws PortalException { final Date now = new Date(); CJProduct cjProduct;// www. j a v a 2s . c o m try { cjProduct = cjProductPersistence.findByPROGRAM_CATALOG_SKU(newCJProduct.getProgramName(), newCJProduct.getCatalogName(), newCJProduct.getSku()); } catch (final NoSuchCJProductException e) { final long productId = counterLocalService.increment(CJProduct.class.getName()); cjProduct = cjProductPersistence.create(productId); resourceLocalService.addModelResources(subscription.getCompanyId(), subscription.getGroupId(), subscription.getUserId(), CJProduct.class.getName(), productId, new String[] { "VIEW" }, new String[] { "VIEW" }); cjProduct.setUuid(PortalUUIDUtil.generate()); cjProduct.setGroupId(subscription.getGroupId()); cjProduct.setCompanyId(subscription.getCompanyId()); cjProduct.setUserId(subscription.getUserId()); cjProduct.setUserName(subscription.getUserName()); cjProduct.setProgramName(newCJProduct.getProgramName()); cjProduct.setCatalogName(newCJProduct.getCatalogName()); cjProduct.setSku(newCJProduct.getSku()); // TODO: is it already implemented by Liferay? //cjProduct.setCreateDate(now); } cjProduct.setProgramUrl(newCJProduct.getProgramUrl()); cjProduct.setLastUpdated(newCJProduct.getLastUpdated()); cjProduct.setName(newCJProduct.getName()); cjProduct.setKeywords(newCJProduct.getKeywords()); cjProduct.setDescription(newCJProduct.getDescription()); cjProduct.setManufacturer(newCJProduct.getManufacturer()); cjProduct.setManufacturerId(newCJProduct.getManufacturerId()); cjProduct.setCurrency(newCJProduct.getCurrency()); cjProduct.setPrice(newCJProduct.getPrice()); cjProduct.setBuyUrl(newCJProduct.getBuyUrl()); cjProduct.setImpressionUrl(newCJProduct.getImpressionUrl()); cjProduct.setImageUrl(newCJProduct.getImageUrl()); cjProduct.setInStock(newCJProduct.getInStock()); // TODO: is it already implemented by Liferay? //cjProduct.setModifiedDate(now); //cjProduct.setCompanyId(COMPANY_ID); //cjProduct.setGroupId(GROUP_ID); //cjProduct.setUserId(USER_ID); Date current = new Date(); Calendar cal = Calendar.getInstance(); cal.add(Calendar.MONTH, 1); Date expire = cal.getTime(); /* assetEntryLocalService.updateEntry( cjProduct.getUserId(), cjProduct.getGroupId(), CJProduct.class.getName(), cjProduct.getProductId(), new long[]{}, //serviceContext.getAssetCategoryIds(), new String[]{"shopping"}); //serviceContext.getAssetTagNames()); assetEntryLocalService.updateEntry( CJProduct.class.getName(), cjProduct.getProductId(), current, expire, true, true); */ String summary = HtmlUtil.extractText(StringUtil.shorten(cjProduct.getDescription(), 500)); long[] assetCategoryIds = null; String[] assetTagNames = null; boolean visible = true; Double priority = null; AssetEntry assetEntry = assetEntryLocalService.updateEntry(cjProduct.getUserId(), cjProduct.getGroupId(), cjProduct.getCreateDate(), cjProduct.getModifiedDate(), CJProduct.class.getName(), cjProduct.getProductId(), cjProduct.getUuid(), 0, assetCategoryIds, assetTagNames, true, visible, current, expire, current, expire, ContentTypes.TEXT_HTML, cjProduct.getName(), cjProduct.getDescription(), summary, cjProduct.getBuyUrl(), null, 0, 0, priority); long[] assetLinkEntryIds = null; assetLinkLocalService.updateLinks(cjProduct.getUserId(), assetEntry.getEntryId(), assetLinkEntryIds, AssetLinkConstants.TYPE_RELATED); Indexer<CJProduct> indexer = IndexerRegistryUtil.nullSafeGetIndexer(CJProduct.class); indexer.reindex(cjProduct); return cjProductPersistence.update(cjProduct); }
From source file:com.amf.user.profile.service.impl.GeneralProfileLocalServiceImpl.java
License:Open Source License
private void reindex(GeneralProfile generalProfile) { Indexer indexer = IndexerRegistryUtil.getIndexer(GeneralProfile.class); try {//w ww. j a v a2s .c o m indexer.reindex(generalProfile); } catch (SearchException e) { System.out.println("Search Exception: " + e.getMessage()); } }