List of usage examples for com.liferay.portal.kernel.util SetUtil fromArray
public static Set<Short> fromArray(short[] array)
From source file:com.beorn.onlinepayment.service.persistence.PaymentMethodPersistenceImpl.java
License:Open Source License
/** * Sets the payment plugins associated with the payment method, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the payment method * @param paymentPluginPKs the primary keys of the payment plugins to be associated with the payment method * @throws SystemException if a system exception occurred */// ww w. jav a 2s. c o m public void setPaymentPlugins(long pk, long[] paymentPluginPKs) throws SystemException { try { Set<Long> paymentPluginPKSet = SetUtil.fromArray(paymentPluginPKs); List<com.beorn.onlinepayment.model.PaymentPlugin> paymentPlugins = getPaymentPlugins(pk); for (com.beorn.onlinepayment.model.PaymentPlugin paymentPlugin : paymentPlugins) { if (!paymentPluginPKSet.remove(paymentPlugin.getPrimaryKey())) { removePaymentPlugin.remove(pk, paymentPlugin.getPrimaryKey()); } } for (Long paymentPluginPK : paymentPluginPKSet) { addPaymentPlugin.add(pk, paymentPluginPK); } } catch (Exception e) { throw processException(e); } finally { FinderCacheUtil .clearCache(PaymentMethodModelImpl.MAPPING_TABLE_PAYMENT_PAYMENTPLUGIN_PAYMENTMETHOD_NAME); } }
From source file:com.beorn.onlinepayment.service.persistence.PaymentPluginPersistenceImpl.java
License:Open Source License
/** * Sets the payment methods associated with the payment plugin, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the payment plugin * @param paymentMethodPKs the primary keys of the payment methods to be associated with the payment plugin * @throws SystemException if a system exception occurred *//*from w w w. ja v a 2 s .co m*/ public void setPaymentMethods(long pk, long[] paymentMethodPKs) throws SystemException { try { Set<Long> paymentMethodPKSet = SetUtil.fromArray(paymentMethodPKs); List<com.beorn.onlinepayment.model.PaymentMethod> paymentMethods = getPaymentMethods(pk); for (com.beorn.onlinepayment.model.PaymentMethod paymentMethod : paymentMethods) { if (!paymentMethodPKSet.remove(paymentMethod.getPrimaryKey())) { removePaymentMethod.remove(pk, paymentMethod.getPrimaryKey()); } } for (Long paymentMethodPK : paymentMethodPKSet) { addPaymentMethod.add(pk, paymentMethodPK); } } catch (Exception e) { throw processException(e); } finally { FinderCacheUtil .clearCache(PaymentPluginModelImpl.MAPPING_TABLE_PAYMENT_PAYMENTPLUGIN_PAYMENTMETHOD_NAME); } }
From source file:com.blogspot.chingovan.customjsp.servicebuilder.service.persistence.AuthorPersistenceImpl.java
License:Open Source License
/** * Sets the books associated with the author, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the author * @param bookPKs the primary keys of the books to be associated with the author * @throws SystemException if a system exception occurred */// ww w. j a va2s. c o m @Override public void setBooks(long pk, long[] bookPKs) throws SystemException { Set<Long> newBookPKsSet = SetUtil.fromArray(bookPKs); Set<Long> oldBookPKsSet = SetUtil.fromArray(authorToBookTableMapper.getRightPrimaryKeys(pk)); Set<Long> removeBookPKsSet = new HashSet<Long>(oldBookPKsSet); removeBookPKsSet.removeAll(newBookPKsSet); for (long removeBookPK : removeBookPKsSet) { authorToBookTableMapper.deleteTableMapping(pk, removeBookPK); } newBookPKsSet.removeAll(oldBookPKsSet); for (long newBookPK : newBookPKsSet) { authorToBookTableMapper.addTableMapping(pk, newBookPK); } }
From source file:com.blogspot.chingovan.customjsp.servicebuilder.service.persistence.BookPersistenceImpl.java
License:Open Source License
/** * Sets the authors associated with the book, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the book * @param authorPKs the primary keys of the authors to be associated with the book * @throws SystemException if a system exception occurred *//* ww w . jav a 2s . co m*/ @Override public void setAuthors(long pk, long[] authorPKs) throws SystemException { Set<Long> newAuthorPKsSet = SetUtil.fromArray(authorPKs); Set<Long> oldAuthorPKsSet = SetUtil.fromArray(bookToAuthorTableMapper.getRightPrimaryKeys(pk)); Set<Long> removeAuthorPKsSet = new HashSet<Long>(oldAuthorPKsSet); removeAuthorPKsSet.removeAll(newAuthorPKsSet); for (long removeAuthorPK : removeAuthorPKsSet) { bookToAuthorTableMapper.deleteTableMapping(pk, removeAuthorPK); } newAuthorPKsSet.removeAll(oldAuthorPKsSet); for (long newAuthorPK : newAuthorPKsSet) { bookToAuthorTableMapper.addTableMapping(pk, newAuthorPK); } }
From source file:com.evozon.evoportal.my_account.validator.UserAccountValidation.java
public boolean isSitesValid(ActionRequest actionRequest) { boolean hasValidSites = true; try {/*from w w w.j a v a2s . com*/ long[] groupIdSplit = ParamUtil.getLongValues(actionRequest, "groupsSearchContainerPrimaryKeys", new long[] {}); if (groupIdSplit.length > 0) { Set<Long> asSet = SetUtil.fromArray(groupIdSplit); long guestGroupId = GroupLocalServiceUtil .getGroup(PortalUtil.getCompanyId(actionRequest), GroupConstants.GUEST).getGroupId(); if (asSet.contains(guestGroupId)) { asSet.remove(guestGroupId); } if (asSet.isEmpty()) { // the user has to be on EvoPortal and at least another // department logger.warn("At least one department has to be specified besides Evoportal."); hasValidSites = false; } } else { logger.debug("No departments are specified."); hasValidSites = false; } } catch (Exception e) { logger.error("Error getting new user sites.", e); } if (!hasValidSites) { SessionErrors.add(actionRequest, NO_DEPARTMENT_DETECTED); } return hasValidSites; }
From source file:com.hitss.layer.service.persistence.EvaluacionPersistenceImpl.java
License:Open Source License
/** * Sets the fase postulacions associated with the evaluacion, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the evaluacion * @param fasePostulacionPKs the primary keys of the fase postulacions to be associated with the evaluacion * @throws SystemException if a system exception occurred *///w ww .j av a 2 s . co m @Override public void setFasePostulacions(long pk, long[] fasePostulacionPKs) throws SystemException { Set<Long> newFasePostulacionPKsSet = SetUtil.fromArray(fasePostulacionPKs); Set<Long> oldFasePostulacionPKsSet = SetUtil .fromArray(evaluacionToFasePostulacionTableMapper.getRightPrimaryKeys(pk)); Set<Long> removeFasePostulacionPKsSet = new HashSet<Long>(oldFasePostulacionPKsSet); removeFasePostulacionPKsSet.removeAll(newFasePostulacionPKsSet); for (long removeFasePostulacionPK : removeFasePostulacionPKsSet) { evaluacionToFasePostulacionTableMapper.deleteTableMapping(pk, removeFasePostulacionPK); } newFasePostulacionPKsSet.removeAll(oldFasePostulacionPKsSet); for (long newFasePostulacionPK : newFasePostulacionPKsSet) { evaluacionToFasePostulacionTableMapper.addTableMapping(pk, newFasePostulacionPK); } }
From source file:com.hitss.layer.service.persistence.FasePostulacionPersistenceImpl.java
License:Open Source License
/** * Sets the evaluacions associated with the fase postulacion, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the fase postulacion * @param evaluacionPKs the primary keys of the evaluacions to be associated with the fase postulacion * @throws SystemException if a system exception occurred *//*from www .j a v a2 s. c o m*/ @Override public void setEvaluacions(long pk, long[] evaluacionPKs) throws SystemException { Set<Long> newEvaluacionPKsSet = SetUtil.fromArray(evaluacionPKs); Set<Long> oldEvaluacionPKsSet = SetUtil .fromArray(fasePostulacionToEvaluacionTableMapper.getRightPrimaryKeys(pk)); Set<Long> removeEvaluacionPKsSet = new HashSet<Long>(oldEvaluacionPKsSet); removeEvaluacionPKsSet.removeAll(newEvaluacionPKsSet); for (long removeEvaluacionPK : removeEvaluacionPKsSet) { fasePostulacionToEvaluacionTableMapper.deleteTableMapping(pk, removeEvaluacionPK); } newEvaluacionPKsSet.removeAll(oldEvaluacionPKsSet); for (long newEvaluacionPK : newEvaluacionPKsSet) { fasePostulacionToEvaluacionTableMapper.addTableMapping(pk, newEvaluacionPK); } }
From source file:com.hitss.layer.service.persistence.PreguntaPersistenceImpl.java
License:Open Source License
/** * Sets the respuestas associated with the pregunta, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the pregunta * @param respuestaPKs the primary keys of the respuestas to be associated with the pregunta * @throws SystemException if a system exception occurred *///from ww w. ja v a2 s .c om @Override public void setRespuestas(long pk, long[] respuestaPKs) throws SystemException { Set<Long> newRespuestaPKsSet = SetUtil.fromArray(respuestaPKs); Set<Long> oldRespuestaPKsSet = SetUtil.fromArray(preguntaToRespuestaTableMapper.getRightPrimaryKeys(pk)); Set<Long> removeRespuestaPKsSet = new HashSet<Long>(oldRespuestaPKsSet); removeRespuestaPKsSet.removeAll(newRespuestaPKsSet); for (long removeRespuestaPK : removeRespuestaPKsSet) { preguntaToRespuestaTableMapper.deleteTableMapping(pk, removeRespuestaPK); } newRespuestaPKsSet.removeAll(oldRespuestaPKsSet); for (long newRespuestaPK : newRespuestaPKsSet) { preguntaToRespuestaTableMapper.addTableMapping(pk, newRespuestaPK); } }
From source file:com.hitss.layer.service.persistence.RespuestaPersistenceImpl.java
License:Open Source License
/** * Sets the preguntas associated with the respuesta, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache. * * @param pk the primary key of the respuesta * @param preguntaPKs the primary keys of the preguntas to be associated with the respuesta * @throws SystemException if a system exception occurred *///w ww.j a v a 2 s.c om @Override public void setPreguntas(long pk, long[] preguntaPKs) throws SystemException { Set<Long> newPreguntaPKsSet = SetUtil.fromArray(preguntaPKs); Set<Long> oldPreguntaPKsSet = SetUtil.fromArray(respuestaToPreguntaTableMapper.getRightPrimaryKeys(pk)); Set<Long> removePreguntaPKsSet = new HashSet<Long>(oldPreguntaPKsSet); removePreguntaPKsSet.removeAll(newPreguntaPKsSet); for (long removePreguntaPK : removePreguntaPKsSet) { respuestaToPreguntaTableMapper.deleteTableMapping(pk, removePreguntaPK); } newPreguntaPKsSet.removeAll(oldPreguntaPKsSet); for (long newPreguntaPK : newPreguntaPKsSet) { respuestaToPreguntaTableMapper.addTableMapping(pk, newPreguntaPK); } }
From source file:com.liferay.asset.categories.navigation.web.internal.display.context.AssetCategoriesNavigationDisplayContext.java
License:Open Source License
public List<KeyValuePair> getAvailableVocabularyNames() { List<KeyValuePair> availableVocabularNames = new ArrayList<>(); long[] assetVocabularyIds = getAssetVocabularyIds(); Arrays.sort(assetVocabularyIds); Set<Long> availableAssetVocabularyIdsSet = SetUtil.fromArray(getAvailableAssetVocabularyIds()); for (long assetVocabularyId : availableAssetVocabularyIdsSet) { if (Arrays.binarySearch(assetVocabularyIds, assetVocabularyId) < 0) { AssetVocabulary assetVocabulary = AssetVocabularyLocalServiceUtil .fetchAssetVocabulary(assetVocabularyId); availableVocabularNames// www . j av a2 s . c o m .add(new KeyValuePair(String.valueOf(assetVocabularyId), getTitle(assetVocabulary))); } } return ListUtil.sort(availableVocabularNames, new KeyValuePairComparator(false, true)); }