List of usage examples for com.liferay.portal.kernel.service ServiceContextThreadLocal getServiceContext
public static ServiceContext getServiceContext()
From source file:at.graz.meduni.bibbox.liferay.portlet.service.persistence.impl.ApplicationInstanceContainerPersistenceImpl.java
License:Open Source License
@Override public ApplicationInstanceContainer updateImpl(ApplicationInstanceContainer applicationInstanceContainer) { applicationInstanceContainer = toUnwrappedModel(applicationInstanceContainer); boolean isNew = applicationInstanceContainer.isNew(); ApplicationInstanceContainerModelImpl applicationInstanceContainerModelImpl = (ApplicationInstanceContainerModelImpl) applicationInstanceContainer; ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date now = new Date(); if (isNew && (applicationInstanceContainer.getCreateDate() == null)) { if (serviceContext == null) { applicationInstanceContainer.setCreateDate(now); } else {//from w w w.j a v a2 s .c o m applicationInstanceContainer.setCreateDate(serviceContext.getCreateDate(now)); } } if (!applicationInstanceContainerModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { applicationInstanceContainer.setModifiedDate(now); } else { applicationInstanceContainer.setModifiedDate(serviceContext.getModifiedDate(now)); } } Session session = null; try { session = openSession(); if (applicationInstanceContainer.isNew()) { session.save(applicationInstanceContainer); applicationInstanceContainer.setNew(false); } else { applicationInstanceContainer = (ApplicationInstanceContainer) session .merge(applicationInstanceContainer); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (isNew || !ApplicationInstanceContainerModelImpl.COLUMN_BITMASK_ENABLED) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else { if ((applicationInstanceContainerModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_APPLICATIONINSTANCE.getColumnBitmask()) != 0) { Object[] args = new Object[] { applicationInstanceContainerModelImpl.getOriginalApplicationInstanceId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_APPLICATIONINSTANCE, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_APPLICATIONINSTANCE, args); args = new Object[] { applicationInstanceContainerModelImpl.getApplicationInstanceId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_APPLICATIONINSTANCE, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_APPLICATIONINSTANCE, args); } if ((applicationInstanceContainerModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_APPLICATIONINSTANCERUNNING.getColumnBitmask()) != 0) { Object[] args = new Object[] { applicationInstanceContainerModelImpl.getOriginalApplicationInstanceId(), applicationInstanceContainerModelImpl.getOriginalNeedrunning() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_APPLICATIONINSTANCERUNNING, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_APPLICATIONINSTANCERUNNING, args); args = new Object[] { applicationInstanceContainerModelImpl.getApplicationInstanceId(), applicationInstanceContainerModelImpl.getNeedrunning() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_APPLICATIONINSTANCERUNNING, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_APPLICATIONINSTANCERUNNING, args); } } entityCache.putResult(ApplicationInstanceContainerModelImpl.ENTITY_CACHE_ENABLED, ApplicationInstanceContainerImpl.class, applicationInstanceContainer.getPrimaryKey(), applicationInstanceContainer, false); applicationInstanceContainer.resetOriginalValues(); return applicationInstanceContainer; }
From source file:at.graz.meduni.bibbox.liferay.portlet.service.persistence.impl.ApplicationInstancePersistenceImpl.java
License:Open Source License
@Override public ApplicationInstance updateImpl(ApplicationInstance applicationInstance) { applicationInstance = toUnwrappedModel(applicationInstance); boolean isNew = applicationInstance.isNew(); ApplicationInstanceModelImpl applicationInstanceModelImpl = (ApplicationInstanceModelImpl) applicationInstance; ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date now = new Date(); if (isNew && (applicationInstance.getCreateDate() == null)) { if (serviceContext == null) { applicationInstance.setCreateDate(now); } else {//w ww . j a v a2s. com applicationInstance.setCreateDate(serviceContext.getCreateDate(now)); } } if (!applicationInstanceModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { applicationInstance.setModifiedDate(now); } else { applicationInstance.setModifiedDate(serviceContext.getModifiedDate(now)); } } Session session = null; try { session = openSession(); if (applicationInstance.isNew()) { session.save(applicationInstance); applicationInstance.setNew(false); } else { applicationInstance = (ApplicationInstance) session.merge(applicationInstance); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (isNew || !ApplicationInstanceModelImpl.COLUMN_BITMASK_ENABLED) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else { if ((applicationInstanceModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FOLDERNAME.getColumnBitmask()) != 0) { Object[] args = new Object[] { applicationInstanceModelImpl.getOriginalFolderName() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_FOLDERNAME, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FOLDERNAME, args); args = new Object[] { applicationInstanceModelImpl.getFolderName() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_FOLDERNAME, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FOLDERNAME, args); } if ((applicationInstanceModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_INSTANCESNOTDELETED.getColumnBitmask()) != 0) { Object[] args = new Object[] { applicationInstanceModelImpl.getOriginalDeleted() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_INSTANCESNOTDELETED, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_INSTANCESNOTDELETED, args); args = new Object[] { applicationInstanceModelImpl.getDeleted() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_INSTANCESNOTDELETED, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_INSTANCESNOTDELETED, args); } } entityCache.putResult(ApplicationInstanceModelImpl.ENTITY_CACHE_ENABLED, ApplicationInstanceImpl.class, applicationInstance.getPrimaryKey(), applicationInstance, false); clearUniqueFindersCache(applicationInstanceModelImpl); cacheUniqueFindersCache(applicationInstanceModelImpl, isNew); applicationInstance.resetOriginalValues(); return applicationInstance; }
From source file:at.graz.meduni.bibbox.liferay.portlet.service.persistence.impl.ApplicationInstancePortPersistenceImpl.java
License:Open Source License
@Override public ApplicationInstancePort updateImpl(ApplicationInstancePort applicationInstancePort) { applicationInstancePort = toUnwrappedModel(applicationInstancePort); boolean isNew = applicationInstancePort.isNew(); ApplicationInstancePortModelImpl applicationInstancePortModelImpl = (ApplicationInstancePortModelImpl) applicationInstancePort; ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date now = new Date(); if (isNew && (applicationInstancePort.getCreateDate() == null)) { if (serviceContext == null) { applicationInstancePort.setCreateDate(now); } else {/*from ww w . j a va 2s . c om*/ applicationInstancePort.setCreateDate(serviceContext.getCreateDate(now)); } } if (!applicationInstancePortModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { applicationInstancePort.setModifiedDate(now); } else { applicationInstancePort.setModifiedDate(serviceContext.getModifiedDate(now)); } } Session session = null; try { session = openSession(); if (applicationInstancePort.isNew()) { session.save(applicationInstancePort); applicationInstancePort.setNew(false); } else { applicationInstancePort = (ApplicationInstancePort) session.merge(applicationInstancePort); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (isNew || !ApplicationInstancePortModelImpl.COLUMN_BITMASK_ENABLED) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else { if ((applicationInstancePortModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_APPLICATIONINSTANCE.getColumnBitmask()) != 0) { Object[] args = new Object[] { applicationInstancePortModelImpl.getOriginalApplicationInstanceId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_APPLICATIONINSTANCE, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_APPLICATIONINSTANCE, args); args = new Object[] { applicationInstancePortModelImpl.getApplicationInstanceId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_APPLICATIONINSTANCE, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_APPLICATIONINSTANCE, args); } if ((applicationInstancePortModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PRIMARYAPPLICATIONINSTANCEPORT .getColumnBitmask()) != 0) { Object[] args = new Object[] { applicationInstancePortModelImpl.getOriginalApplicationInstanceId(), applicationInstancePortModelImpl.getOriginalPrimary() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_PRIMARYAPPLICATIONINSTANCEPORT, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PRIMARYAPPLICATIONINSTANCEPORT, args); args = new Object[] { applicationInstancePortModelImpl.getApplicationInstanceId(), applicationInstancePortModelImpl.getPrimary() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_PRIMARYAPPLICATIONINSTANCEPORT, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PRIMARYAPPLICATIONINSTANCEPORT, args); } } entityCache.putResult(ApplicationInstancePortModelImpl.ENTITY_CACHE_ENABLED, ApplicationInstancePortImpl.class, applicationInstancePort.getPrimaryKey(), applicationInstancePort, false); applicationInstancePort.resetOriginalValues(); return applicationInstancePort; }
From source file:at.graz.meduni.bibbox.liferay.portlet.service.persistence.impl.ApplicationInstanceStatusPersistenceImpl.java
License:Open Source License
@Override public ApplicationInstanceStatus updateImpl(ApplicationInstanceStatus applicationInstanceStatus) { applicationInstanceStatus = toUnwrappedModel(applicationInstanceStatus); boolean isNew = applicationInstanceStatus.isNew(); ApplicationInstanceStatusModelImpl applicationInstanceStatusModelImpl = (ApplicationInstanceStatusModelImpl) applicationInstanceStatus; ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date now = new Date(); if (isNew && (applicationInstanceStatus.getCreateDate() == null)) { if (serviceContext == null) { applicationInstanceStatus.setCreateDate(now); } else {//from w ww . j ava2s . c o m applicationInstanceStatus.setCreateDate(serviceContext.getCreateDate(now)); } } if (!applicationInstanceStatusModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { applicationInstanceStatus.setModifiedDate(now); } else { applicationInstanceStatus.setModifiedDate(serviceContext.getModifiedDate(now)); } } Session session = null; try { session = openSession(); if (applicationInstanceStatus.isNew()) { session.save(applicationInstanceStatus); applicationInstanceStatus.setNew(false); } else { applicationInstanceStatus = (ApplicationInstanceStatus) session.merge(applicationInstanceStatus); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (isNew || !ApplicationInstanceStatusModelImpl.COLUMN_BITMASK_ENABLED) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } entityCache.putResult(ApplicationInstanceStatusModelImpl.ENTITY_CACHE_ENABLED, ApplicationInstanceStatusImpl.class, applicationInstanceStatus.getPrimaryKey(), applicationInstanceStatus, false); clearUniqueFindersCache(applicationInstanceStatusModelImpl); cacheUniqueFindersCache(applicationInstanceStatusModelImpl, isNew); applicationInstanceStatus.resetOriginalValues(); return applicationInstanceStatus; }
From source file:at.graz.meduni.liferay.portlet.saat.service.persistence.impl.DictionaryDictionaryLinkPersistenceImpl.java
License:Open Source License
@Override public DictionaryDictionaryLink updateImpl(DictionaryDictionaryLink dictionaryDictionaryLink) { dictionaryDictionaryLink = toUnwrappedModel(dictionaryDictionaryLink); boolean isNew = dictionaryDictionaryLink.isNew(); DictionaryDictionaryLinkModelImpl dictionaryDictionaryLinkModelImpl = (DictionaryDictionaryLinkModelImpl) dictionaryDictionaryLink; ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date now = new Date(); if (isNew && (dictionaryDictionaryLink.getCreateDate() == null)) { if (serviceContext == null) { dictionaryDictionaryLink.setCreateDate(now); } else {//from ww w. j a va 2 s . c o m dictionaryDictionaryLink.setCreateDate(serviceContext.getCreateDate(now)); } } if (!dictionaryDictionaryLinkModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { dictionaryDictionaryLink.setModifiedDate(now); } else { dictionaryDictionaryLink.setModifiedDate(serviceContext.getModifiedDate(now)); } } Session session = null; try { session = openSession(); if (dictionaryDictionaryLink.isNew()) { session.save(dictionaryDictionaryLink); dictionaryDictionaryLink.setNew(false); } else { dictionaryDictionaryLink = (DictionaryDictionaryLink) session.merge(dictionaryDictionaryLink); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (isNew || !DictionaryDictionaryLinkModelImpl.COLUMN_BITMASK_ENABLED) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else { if ((dictionaryDictionaryLinkModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTID.getColumnBitmask()) != 0) { Object[] args = new Object[] { dictionaryDictionaryLinkModelImpl.getOriginalDictionaryId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_PARENTID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTID, args); args = new Object[] { dictionaryDictionaryLinkModelImpl.getDictionaryId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_PARENTID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTID, args); } if ((dictionaryDictionaryLinkModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CHILDRENID.getColumnBitmask()) != 0) { Object[] args = new Object[] { dictionaryDictionaryLinkModelImpl.getOriginalDictionaryAddictionId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_CHILDRENID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CHILDRENID, args); args = new Object[] { dictionaryDictionaryLinkModelImpl.getDictionaryAddictionId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_CHILDRENID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CHILDRENID, args); } } entityCache.putResult(DictionaryDictionaryLinkModelImpl.ENTITY_CACHE_ENABLED, DictionaryDictionaryLinkImpl.class, dictionaryDictionaryLink.getPrimaryKey(), dictionaryDictionaryLink, false); dictionaryDictionaryLink.resetOriginalValues(); return dictionaryDictionaryLink; }
From source file:at.graz.meduni.liferay.portlet.saat.service.persistence.impl.DictionaryPersistenceImpl.java
License:Open Source License
@Override public Dictionary updateImpl(Dictionary dictionary) { dictionary = toUnwrappedModel(dictionary); boolean isNew = dictionary.isNew(); DictionaryModelImpl dictionaryModelImpl = (DictionaryModelImpl) dictionary; ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date now = new Date(); if (isNew && (dictionary.getCreateDate() == null)) { if (serviceContext == null) { dictionary.setCreateDate(now); } else {/*ww w . j a va2 s. co m*/ dictionary.setCreateDate(serviceContext.getCreateDate(now)); } } if (!dictionaryModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { dictionary.setModifiedDate(now); } else { dictionary.setModifiedDate(serviceContext.getModifiedDate(now)); } } Session session = null; try { session = openSession(); if (dictionary.isNew()) { session.save(dictionary); dictionary.setNew(false); } else { dictionary = (Dictionary) session.merge(dictionary); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (isNew || !DictionaryModelImpl.COLUMN_BITMASK_ENABLED) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else { if ((dictionaryModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CODETYPE.getColumnBitmask()) != 0) { Object[] args = new Object[] { dictionaryModelImpl.getOriginalCodeType() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_CODETYPE, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CODETYPE, args); args = new Object[] { dictionaryModelImpl.getCodeType() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_CODETYPE, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CODETYPE, args); } } entityCache.putResult(DictionaryModelImpl.ENTITY_CACHE_ENABLED, DictionaryImpl.class, dictionary.getPrimaryKey(), dictionary, false); dictionary.resetOriginalValues(); return dictionary; }
From source file:blade.servicebuilder.service.persistence.impl.FooPersistenceImpl.java
License:Open Source License
@Override public Foo updateImpl(Foo foo) { foo = toUnwrappedModel(foo);// ww w. j av a2 s.c om boolean isNew = foo.isNew(); FooModelImpl fooModelImpl = (FooModelImpl) foo; if (Validator.isNull(foo.getUuid())) { String uuid = PortalUUIDUtil.generate(); foo.setUuid(uuid); } ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date now = new Date(); if (isNew && (foo.getCreateDate() == null)) { if (serviceContext == null) { foo.setCreateDate(now); } else { foo.setCreateDate(serviceContext.getCreateDate(now)); } } if (!fooModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { foo.setModifiedDate(now); } else { foo.setModifiedDate(serviceContext.getModifiedDate(now)); } } Session session = null; try { session = openSession(); if (foo.isNew()) { session.save(foo); foo.setNew(false); } else { foo = (Foo) session.merge(foo); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (isNew || !FooModelImpl.COLUMN_BITMASK_ENABLED) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else { if ((fooModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) { Object[] args = new Object[] { fooModelImpl.getOriginalUuid() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); args = new Object[] { fooModelImpl.getUuid() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); } if ((fooModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) { Object[] args = new Object[] { fooModelImpl.getOriginalUuid(), fooModelImpl.getOriginalCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C, args); args = new Object[] { fooModelImpl.getUuid(), fooModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C, args); } if ((fooModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FIELD2.getColumnBitmask()) != 0) { Object[] args = new Object[] { fooModelImpl.getOriginalField2() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_FIELD2, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FIELD2, args); args = new Object[] { fooModelImpl.getField2() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_FIELD2, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FIELD2, args); } } entityCache.putResult(FooModelImpl.ENTITY_CACHE_ENABLED, FooImpl.class, foo.getPrimaryKey(), foo, false); clearUniqueFindersCache(fooModelImpl); cacheUniqueFindersCache(fooModelImpl, isNew); foo.resetOriginalValues(); return foo; }
From source file:ca.efendi.datafeeds.service.persistence.impl.CJProductPersistenceImpl.java
License:Open Source License
@Override public CJProduct updateImpl(CJProduct cjProduct) { cjProduct = toUnwrappedModel(cjProduct); boolean isNew = cjProduct.isNew(); CJProductModelImpl cjProductModelImpl = (CJProductModelImpl) cjProduct; if (Validator.isNull(cjProduct.getUuid())) { String uuid = PortalUUIDUtil.generate(); cjProduct.setUuid(uuid);//from w ww . j a v a 2 s. com } ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date now = new Date(); if (isNew && (cjProduct.getCreateDate() == null)) { if (serviceContext == null) { cjProduct.setCreateDate(now); } else { cjProduct.setCreateDate(serviceContext.getCreateDate(now)); } } if (!cjProductModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { cjProduct.setModifiedDate(now); } else { cjProduct.setModifiedDate(serviceContext.getModifiedDate(now)); } } Session session = null; try { session = openSession(); if (cjProduct.isNew()) { session.save(cjProduct); cjProduct.setNew(false); } else { cjProduct = (CJProduct) session.merge(cjProduct); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (isNew || !CJProductModelImpl.COLUMN_BITMASK_ENABLED) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else { if ((cjProductModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) { Object[] args = new Object[] { cjProductModelImpl.getOriginalUuid() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); args = new Object[] { cjProductModelImpl.getUuid() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); } if ((cjProductModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) { Object[] args = new Object[] { cjProductModelImpl.getOriginalUuid(), cjProductModelImpl.getOriginalCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C, args); args = new Object[] { cjProductModelImpl.getUuid(), cjProductModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C, args); } if ((cjProductModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_MANUFACTURER.getColumnBitmask()) != 0) { Object[] args = new Object[] { cjProductModelImpl.getOriginalManufacturer() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_MANUFACTURER, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_MANUFACTURER, args); args = new Object[] { cjProductModelImpl.getManufacturer() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_MANUFACTURER, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_MANUFACTURER, args); } if ((cjProductModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) { Object[] args = new Object[] { cjProductModelImpl.getOriginalGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID, args); args = new Object[] { cjProductModelImpl.getGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID, args); } if ((cjProductModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) { Object[] args = new Object[] { cjProductModelImpl.getOriginalCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID, args); args = new Object[] { cjProductModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID, args); } } entityCache.putResult(CJProductModelImpl.ENTITY_CACHE_ENABLED, CJProductImpl.class, cjProduct.getPrimaryKey(), cjProduct, false); clearUniqueFindersCache(cjProductModelImpl); cacheUniqueFindersCache(cjProductModelImpl, isNew); cjProduct.resetOriginalValues(); return cjProduct; }
From source file:ca.efendi.datafeeds.service.persistence.impl.FtpSubscriptionPersistenceImpl.java
License:Open Source License
@Override public FtpSubscription updateImpl(FtpSubscription ftpSubscription) { ftpSubscription = toUnwrappedModel(ftpSubscription); boolean isNew = ftpSubscription.isNew(); FtpSubscriptionModelImpl ftpSubscriptionModelImpl = (FtpSubscriptionModelImpl) ftpSubscription; ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date now = new Date(); if (isNew && (ftpSubscription.getCreateDate() == null)) { if (serviceContext == null) { ftpSubscription.setCreateDate(now); } else {/* w w w . j a v a 2s .co m*/ ftpSubscription.setCreateDate(serviceContext.getCreateDate(now)); } } if (!ftpSubscriptionModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { ftpSubscription.setModifiedDate(now); } else { ftpSubscription.setModifiedDate(serviceContext.getModifiedDate(now)); } } Session session = null; try { session = openSession(); if (ftpSubscription.isNew()) { session.save(ftpSubscription); ftpSubscription.setNew(false); } else { ftpSubscription = (FtpSubscription) session.merge(ftpSubscription); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (isNew || !FtpSubscriptionModelImpl.COLUMN_BITMASK_ENABLED) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else { if ((ftpSubscriptionModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) { Object[] args = new Object[] { ftpSubscriptionModelImpl.getOriginalGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID, args); args = new Object[] { ftpSubscriptionModelImpl.getGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID, args); } } entityCache.putResult(FtpSubscriptionModelImpl.ENTITY_CACHE_ENABLED, FtpSubscriptionImpl.class, ftpSubscription.getPrimaryKey(), ftpSubscription, false); ftpSubscription.resetOriginalValues(); return ftpSubscription; }
From source file:com.bemis.portal.carriers.service.persistence.impl.CarrierPersistenceImpl.java
License:Open Source License
@Override public Carrier updateImpl(Carrier carrier) { carrier = toUnwrappedModel(carrier); boolean isNew = carrier.isNew(); CarrierModelImpl carrierModelImpl = (CarrierModelImpl) carrier; if (Validator.isNull(carrier.getUuid())) { String uuid = PortalUUIDUtil.generate(); carrier.setUuid(uuid);//from ww w .j a va 2 s . co m } ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date now = new Date(); if (isNew && (carrier.getCreateDate() == null)) { if (serviceContext == null) { carrier.setCreateDate(now); } else { carrier.setCreateDate(serviceContext.getCreateDate(now)); } } if (!carrierModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { carrier.setModifiedDate(now); } else { carrier.setModifiedDate(serviceContext.getModifiedDate(now)); } } Session session = null; try { session = openSession(); if (carrier.isNew()) { session.save(carrier); carrier.setNew(false); } else { carrier = (Carrier) session.merge(carrier); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (isNew || !CarrierModelImpl.COLUMN_BITMASK_ENABLED) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else { if ((carrierModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) { Object[] args = new Object[] { carrierModelImpl.getOriginalUuid() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); args = new Object[] { carrierModelImpl.getUuid() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); } if ((carrierModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) { Object[] args = new Object[] { carrierModelImpl.getOriginalUuid(), carrierModelImpl.getOriginalCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C, args); args = new Object[] { carrierModelImpl.getUuid(), carrierModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C, args); } if ((carrierModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) { Object[] args = new Object[] { carrierModelImpl.getOriginalGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID, args); args = new Object[] { carrierModelImpl.getGroupId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID, args); } } entityCache.putResult(CarrierModelImpl.ENTITY_CACHE_ENABLED, CarrierImpl.class, carrier.getPrimaryKey(), carrier, false); clearUniqueFindersCache(carrierModelImpl); cacheUniqueFindersCache(carrierModelImpl, isNew); carrier.resetOriginalValues(); return carrier; }