List of usage examples for com.liferay.portal.kernel.util StringUtil merge
public static String merge(short[] array)
From source file:at.graz.hmmc.liferay.portlet.puch.service.persistence.ConfigurationPersistenceImpl.java
License:Open Source License
/** * Returns the configuration where scope = ? and optionkey = ? or returns <code>null</code> if it could not be found, optionally using the finder cache. * * @param scope the scope/* w w w . ja v a 2s.c o m*/ * @param optionkey the optionkey * @param retrieveFromCache whether to use the finder cache * @return the matching configuration, or <code>null</code> if a matching configuration could not be found * @throws SystemException if a system exception occurred */ @Override public Configuration fetchByoptionFinder(String scope, String optionkey, boolean retrieveFromCache) throws SystemException { Object[] finderArgs = new Object[] { scope, optionkey }; Object result = null; if (retrieveFromCache) { result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_OPTIONFINDER, finderArgs, this); } if (result instanceof Configuration) { Configuration configuration = (Configuration) result; if (!Validator.equals(scope, configuration.getScope()) || !Validator.equals(optionkey, configuration.getOptionkey())) { result = null; } } if (result == null) { StringBundler query = new StringBundler(4); query.append(_SQL_SELECT_CONFIGURATION_WHERE); boolean bindScope = false; if (scope == null) { query.append(_FINDER_COLUMN_OPTIONFINDER_SCOPE_1); } else if (scope.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_OPTIONFINDER_SCOPE_3); } else { bindScope = true; query.append(_FINDER_COLUMN_OPTIONFINDER_SCOPE_2); } boolean bindOptionkey = false; if (optionkey == null) { query.append(_FINDER_COLUMN_OPTIONFINDER_OPTIONKEY_1); } else if (optionkey.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_OPTIONFINDER_OPTIONKEY_3); } else { bindOptionkey = true; query.append(_FINDER_COLUMN_OPTIONFINDER_OPTIONKEY_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindScope) { qPos.add(scope); } if (bindOptionkey) { qPos.add(optionkey); } List<Configuration> list = q.list(); if (list.isEmpty()) { FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_OPTIONFINDER, finderArgs, list); } else { if ((list.size() > 1) && _log.isWarnEnabled()) { _log.warn( "ConfigurationPersistenceImpl.fetchByoptionFinder(String, String, boolean) with parameters (" + StringUtil.merge(finderArgs) + ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder."); } Configuration configuration = list.get(0); result = configuration; cacheResult(configuration); if ((configuration.getScope() == null) || !configuration.getScope().equals(scope) || (configuration.getOptionkey() == null) || !configuration.getOptionkey().equals(optionkey)) { FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_OPTIONFINDER, finderArgs, configuration); } } } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_OPTIONFINDER, finderArgs); throw processException(e); } finally { closeSession(session); } } if (result instanceof List<?>) { return null; } else { return (Configuration) result; } }
From source file:at.graz.hmmc.liferay.portlet.puch.service.persistence.ConfigurationPersistenceImpl.java
License:Open Source License
/** * Returns the configuration where scope = ? and optionvalue = ? or returns <code>null</code> if it could not be found, optionally using the finder cache. * * @param scope the scope//from w ww. ja v a2 s. c o m * @param optionvalue the optionvalue * @param retrieveFromCache whether to use the finder cache * @return the matching configuration, or <code>null</code> if a matching configuration could not be found * @throws SystemException if a system exception occurred */ @Override public Configuration fetchByoptionsFinderValue(String scope, String optionvalue, boolean retrieveFromCache) throws SystemException { Object[] finderArgs = new Object[] { scope, optionvalue }; Object result = null; if (retrieveFromCache) { result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_OPTIONSFINDERVALUE, finderArgs, this); } if (result instanceof Configuration) { Configuration configuration = (Configuration) result; if (!Validator.equals(scope, configuration.getScope()) || !Validator.equals(optionvalue, configuration.getOptionvalue())) { result = null; } } if (result == null) { StringBundler query = new StringBundler(4); query.append(_SQL_SELECT_CONFIGURATION_WHERE); boolean bindScope = false; if (scope == null) { query.append(_FINDER_COLUMN_OPTIONSFINDERVALUE_SCOPE_1); } else if (scope.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_OPTIONSFINDERVALUE_SCOPE_3); } else { bindScope = true; query.append(_FINDER_COLUMN_OPTIONSFINDERVALUE_SCOPE_2); } boolean bindOptionvalue = false; if (optionvalue == null) { query.append(_FINDER_COLUMN_OPTIONSFINDERVALUE_OPTIONVALUE_1); } else if (optionvalue.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_OPTIONSFINDERVALUE_OPTIONVALUE_3); } else { bindOptionvalue = true; query.append(_FINDER_COLUMN_OPTIONSFINDERVALUE_OPTIONVALUE_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindScope) { qPos.add(scope); } if (bindOptionvalue) { qPos.add(optionvalue); } List<Configuration> list = q.list(); if (list.isEmpty()) { FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_OPTIONSFINDERVALUE, finderArgs, list); } else { if ((list.size() > 1) && _log.isWarnEnabled()) { _log.warn( "ConfigurationPersistenceImpl.fetchByoptionsFinderValue(String, String, boolean) with parameters (" + StringUtil.merge(finderArgs) + ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder."); } Configuration configuration = list.get(0); result = configuration; cacheResult(configuration); if ((configuration.getScope() == null) || !configuration.getScope().equals(scope) || (configuration.getOptionvalue() == null) || !configuration.getOptionvalue().equals(optionvalue)) { FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_OPTIONSFINDERVALUE, finderArgs, configuration); } } } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_OPTIONSFINDERVALUE, finderArgs); throw processException(e); } finally { closeSession(session); } } if (result instanceof List<?>) { return null; } else { return (Configuration) result; } }
From source file:at.graz.hmmc.liferay.portlet.puch.service.persistence.ObjectDataPersistenceImpl.java
License:Open Source License
/** * Returns the object data where puchmuseumsobjectId = ? and objectkey = ? or returns <code>null</code> if it could not be found, optionally using the finder cache. * * @param puchmuseumsobjectId the puchmuseumsobject ID * @param objectkey the objectkey/*from w w w. j av a2 s.c om*/ * @param retrieveFromCache whether to use the finder cache * @return the matching object data, or <code>null</code> if a matching object data could not be found * @throws SystemException if a system exception occurred */ @Override public ObjectData fetchByDataByOntology(long puchmuseumsobjectId, String objectkey, boolean retrieveFromCache) throws SystemException { Object[] finderArgs = new Object[] { puchmuseumsobjectId, objectkey }; Object result = null; if (retrieveFromCache) { result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_DATABYONTOLOGY, finderArgs, this); } if (result instanceof ObjectData) { ObjectData objectData = (ObjectData) result; if ((puchmuseumsobjectId != objectData.getPuchmuseumsobjectId()) || !Validator.equals(objectkey, objectData.getObjectkey())) { result = null; } } if (result == null) { StringBundler query = new StringBundler(4); query.append(_SQL_SELECT_OBJECTDATA_WHERE); query.append(_FINDER_COLUMN_DATABYONTOLOGY_PUCHMUSEUMSOBJECTID_2); boolean bindObjectkey = false; if (objectkey == null) { query.append(_FINDER_COLUMN_DATABYONTOLOGY_OBJECTKEY_1); } else if (objectkey.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_DATABYONTOLOGY_OBJECTKEY_3); } else { bindObjectkey = true; query.append(_FINDER_COLUMN_DATABYONTOLOGY_OBJECTKEY_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(puchmuseumsobjectId); if (bindObjectkey) { qPos.add(objectkey); } List<ObjectData> list = q.list(); if (list.isEmpty()) { FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DATABYONTOLOGY, finderArgs, list); } else { if ((list.size() > 1) && _log.isWarnEnabled()) { _log.warn( "ObjectDataPersistenceImpl.fetchByDataByOntology(long, String, boolean) with parameters (" + StringUtil.merge(finderArgs) + ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder."); } ObjectData objectData = list.get(0); result = objectData; cacheResult(objectData); if ((objectData.getPuchmuseumsobjectId() != puchmuseumsobjectId) || (objectData.getObjectkey() == null) || !objectData.getObjectkey().equals(objectkey)) { FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DATABYONTOLOGY, finderArgs, objectData); } } } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_DATABYONTOLOGY, finderArgs); throw processException(e); } finally { closeSession(session); } } if (result instanceof List<?>) { return null; } else { return (ObjectData) result; } }
From source file:at.graz.hmmc.liferay.portlet.puch.service.persistence.TransaktionDataPersistenceImpl.java
License:Open Source License
/** * Returns the transaktion data where transaktionId = ? and objectkey = ? or returns <code>null</code> if it could not be found, optionally using the finder cache. * * @param transaktionId the transaktion ID * @param objectkey the objectkey//from w w w.j ava 2 s . c om * @param retrieveFromCache whether to use the finder cache * @return the matching transaktion data, or <code>null</code> if a matching transaktion data could not be found * @throws SystemException if a system exception occurred */ @Override public TransaktionData fetchByDataByOntology(long transaktionId, String objectkey, boolean retrieveFromCache) throws SystemException { Object[] finderArgs = new Object[] { transaktionId, objectkey }; Object result = null; if (retrieveFromCache) { result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_DATABYONTOLOGY, finderArgs, this); } if (result instanceof TransaktionData) { TransaktionData transaktionData = (TransaktionData) result; if ((transaktionId != transaktionData.getTransaktionId()) || !Validator.equals(objectkey, transaktionData.getObjectkey())) { result = null; } } if (result == null) { StringBundler query = new StringBundler(4); query.append(_SQL_SELECT_TRANSAKTIONDATA_WHERE); query.append(_FINDER_COLUMN_DATABYONTOLOGY_TRANSAKTIONID_2); boolean bindObjectkey = false; if (objectkey == null) { query.append(_FINDER_COLUMN_DATABYONTOLOGY_OBJECTKEY_1); } else if (objectkey.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_DATABYONTOLOGY_OBJECTKEY_3); } else { bindObjectkey = true; query.append(_FINDER_COLUMN_DATABYONTOLOGY_OBJECTKEY_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(transaktionId); if (bindObjectkey) { qPos.add(objectkey); } List<TransaktionData> list = q.list(); if (list.isEmpty()) { FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DATABYONTOLOGY, finderArgs, list); } else { if ((list.size() > 1) && _log.isWarnEnabled()) { _log.warn( "TransaktionDataPersistenceImpl.fetchByDataByOntology(long, String, boolean) with parameters (" + StringUtil.merge(finderArgs) + ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder."); } TransaktionData transaktionData = list.get(0); result = transaktionData; cacheResult(transaktionData); if ((transaktionData.getTransaktionId() != transaktionId) || (transaktionData.getObjectkey() == null) || !transaktionData.getObjectkey().equals(objectkey)) { FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DATABYONTOLOGY, finderArgs, transaktionData); } } } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_DATABYONTOLOGY, finderArgs); throw processException(e); } finally { closeSession(session); } } if (result instanceof List<?>) { return null; } else { return (TransaktionData) result; } }
From source file:at.graz.meduni.bibbox.liferay.portlet.service.persistence.impl.ApplicationInstancePersistenceImpl.java
License:Open Source License
/** * Returns the application instance where instanceId = ? or returns <code>null</code> if it could not be found, optionally using the finder cache. * * @param instanceId the instance ID//from w w w . j av a 2 s . c om * @param retrieveFromCache whether to retrieve from the finder cache * @return the matching application instance, or <code>null</code> if a matching application instance could not be found */ @Override public ApplicationInstance fetchByInstanceId(String instanceId, boolean retrieveFromCache) { Object[] finderArgs = new Object[] { instanceId }; Object result = null; if (retrieveFromCache) { result = finderCache.getResult(FINDER_PATH_FETCH_BY_INSTANCEID, finderArgs, this); } if (result instanceof ApplicationInstance) { ApplicationInstance applicationInstance = (ApplicationInstance) result; if (!Objects.equals(instanceId, applicationInstance.getInstanceId())) { result = null; } } if (result == null) { StringBundler query = new StringBundler(3); query.append(_SQL_SELECT_APPLICATIONINSTANCE_WHERE); boolean bindInstanceId = false; if (instanceId == null) { query.append(_FINDER_COLUMN_INSTANCEID_INSTANCEID_1); } else if (instanceId.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_INSTANCEID_INSTANCEID_3); } else { bindInstanceId = true; query.append(_FINDER_COLUMN_INSTANCEID_INSTANCEID_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindInstanceId) { qPos.add(instanceId); } List<ApplicationInstance> list = q.list(); if (list.isEmpty()) { finderCache.putResult(FINDER_PATH_FETCH_BY_INSTANCEID, finderArgs, list); } else { if ((list.size() > 1) && _log.isWarnEnabled()) { _log.warn( "ApplicationInstancePersistenceImpl.fetchByInstanceId(String, boolean) with parameters (" + StringUtil.merge(finderArgs) + ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder."); } ApplicationInstance applicationInstance = list.get(0); result = applicationInstance; cacheResult(applicationInstance); if ((applicationInstance.getInstanceId() == null) || !applicationInstance.getInstanceId().equals(instanceId)) { finderCache.putResult(FINDER_PATH_FETCH_BY_INSTANCEID, finderArgs, applicationInstance); } } } catch (Exception e) { finderCache.removeResult(FINDER_PATH_FETCH_BY_INSTANCEID, finderArgs); throw processException(e); } finally { closeSession(session); } } if (result instanceof List<?>) { return null; } else { return (ApplicationInstance) result; } }
From source file:at.graz.meduni.bibbox.liferay.portlet.service.persistence.impl.ApplicationInstanceStatusPersistenceImpl.java
License:Open Source License
/** * Returns the application instance status where applicationInstanceId = ? or returns <code>null</code> if it could not be found, optionally using the finder cache. * * @param applicationInstanceId the application instance ID * @param retrieveFromCache whether to retrieve from the finder cache * @return the matching application instance status, or <code>null</code> if a matching application instance status could not be found *///from www . j a v a 2 s . c o m @Override public ApplicationInstanceStatus fetchByApplicationInstance(long applicationInstanceId, boolean retrieveFromCache) { Object[] finderArgs = new Object[] { applicationInstanceId }; Object result = null; if (retrieveFromCache) { result = finderCache.getResult(FINDER_PATH_FETCH_BY_APPLICATIONINSTANCE, finderArgs, this); } if (result instanceof ApplicationInstanceStatus) { ApplicationInstanceStatus applicationInstanceStatus = (ApplicationInstanceStatus) result; if ((applicationInstanceId != applicationInstanceStatus.getApplicationInstanceId())) { result = null; } } if (result == null) { StringBundler query = new StringBundler(3); query.append(_SQL_SELECT_APPLICATIONINSTANCESTATUS_WHERE); query.append(_FINDER_COLUMN_APPLICATIONINSTANCE_APPLICATIONINSTANCEID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(applicationInstanceId); List<ApplicationInstanceStatus> list = q.list(); if (list.isEmpty()) { finderCache.putResult(FINDER_PATH_FETCH_BY_APPLICATIONINSTANCE, finderArgs, list); } else { if ((list.size() > 1) && _log.isWarnEnabled()) { _log.warn( "ApplicationInstanceStatusPersistenceImpl.fetchByApplicationInstance(long, boolean) with parameters (" + StringUtil.merge(finderArgs) + ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder."); } ApplicationInstanceStatus applicationInstanceStatus = list.get(0); result = applicationInstanceStatus; cacheResult(applicationInstanceStatus); if ((applicationInstanceStatus.getApplicationInstanceId() != applicationInstanceId)) { finderCache.putResult(FINDER_PATH_FETCH_BY_APPLICATIONINSTANCE, finderArgs, applicationInstanceStatus); } } } catch (Exception e) { finderCache.removeResult(FINDER_PATH_FETCH_BY_APPLICATIONINSTANCE, finderArgs); throw processException(e); } finally { closeSession(session); } } if (result instanceof List<?>) { return null; } else { return (ApplicationInstanceStatus) result; } }
From source file:at.graz.meduni.liferay.portlet.bibbox.kdssmp.service.service.persistence.EventDataPersistenceImpl.java
License:Open Source License
/** * Returns the event data where eventId = ? and ontology = ? or returns <code>null</code> if it could not be found, optionally using the finder cache. * * @param eventId the event ID// ww w . j a v a 2 s.com * @param ontology the ontology * @param retrieveFromCache whether to use the finder cache * @return the matching event data, or <code>null</code> if a matching event data could not be found * @throws SystemException if a system exception occurred */ @Override public EventData fetchByDataByOntology(long eventId, String ontology, boolean retrieveFromCache) throws SystemException { Object[] finderArgs = new Object[] { eventId, ontology }; Object result = null; if (retrieveFromCache) { result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_DATABYONTOLOGY, finderArgs, this); } if (result instanceof EventData) { EventData eventData = (EventData) result; if ((eventId != eventData.getEventId()) || !Validator.equals(ontology, eventData.getOntology())) { result = null; } } if (result == null) { StringBundler query = new StringBundler(4); query.append(_SQL_SELECT_EVENTDATA_WHERE); query.append(_FINDER_COLUMN_DATABYONTOLOGY_EVENTID_2); boolean bindOntology = false; if (ontology == null) { query.append(_FINDER_COLUMN_DATABYONTOLOGY_ONTOLOGY_1); } else if (ontology.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_DATABYONTOLOGY_ONTOLOGY_3); } else { bindOntology = true; query.append(_FINDER_COLUMN_DATABYONTOLOGY_ONTOLOGY_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(eventId); if (bindOntology) { qPos.add(ontology); } List<EventData> list = q.list(); if (list.isEmpty()) { FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DATABYONTOLOGY, finderArgs, list); } else { if ((list.size() > 1) && _log.isWarnEnabled()) { _log.warn( "EventDataPersistenceImpl.fetchByDataByOntology(long, String, boolean) with parameters (" + StringUtil.merge(finderArgs) + ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder."); } EventData eventData = list.get(0); result = eventData; cacheResult(eventData); if ((eventData.getEventId() != eventId) || (eventData.getOntology() == null) || !eventData.getOntology().equals(ontology)) { FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DATABYONTOLOGY, finderArgs, eventData); } } } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_DATABYONTOLOGY, finderArgs); throw processException(e); } finally { closeSession(session); } } if (result instanceof List<?>) { return null; } else { return (EventData) result; } }
From source file:at.graz.meduni.liferay.portlet.bibbox.kdssmp.service.service.persistence.EventPersistenceImpl.java
License:Open Source License
/** * Returns the event where layoutId = ? or returns <code>null</code> if it could not be found, optionally using the finder cache. * * @param layoutId the layout ID// w w w .ja va 2 s . c o m * @param retrieveFromCache whether to use the finder cache * @return the matching event, or <code>null</code> if a matching event could not be found * @throws SystemException if a system exception occurred */ @Override public Event fetchByLayoutId(long layoutId, boolean retrieveFromCache) throws SystemException { Object[] finderArgs = new Object[] { layoutId }; Object result = null; if (retrieveFromCache) { result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_LAYOUTID, finderArgs, this); } if (result instanceof Event) { Event event = (Event) result; if ((layoutId != event.getLayoutId())) { result = null; } } if (result == null) { StringBundler query = new StringBundler(3); query.append(_SQL_SELECT_EVENT_WHERE); query.append(_FINDER_COLUMN_LAYOUTID_LAYOUTID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(layoutId); List<Event> list = q.list(); if (list.isEmpty()) { FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LAYOUTID, finderArgs, list); } else { if ((list.size() > 1) && _log.isWarnEnabled()) { _log.warn("EventPersistenceImpl.fetchByLayoutId(long, boolean) with parameters (" + StringUtil.merge(finderArgs) + ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder."); } Event event = list.get(0); result = event; cacheResult(event); if ((event.getLayoutId() != layoutId)) { FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LAYOUTID, finderArgs, event); } } } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LAYOUTID, finderArgs); throw processException(e); } finally { closeSession(session); } } if (result instanceof List<?>) { return null; } else { return (Event) result; } }
From source file:at.graz.meduni.liferay.portlet.bibbox.kdssmp.service.service.persistence.KdssmpConfigurationPersistenceImpl.java
License:Open Source License
/** * Returns the kdssmp configuration where scope = ? and optionkey = ? or returns <code>null</code> if it could not be found, optionally using the finder cache. * * @param scope the scope//from w w w. j a v a 2 s . c o m * @param optionkey the optionkey * @param retrieveFromCache whether to use the finder cache * @return the matching kdssmp configuration, or <code>null</code> if a matching kdssmp configuration could not be found * @throws SystemException if a system exception occurred */ @Override public KdssmpConfiguration fetchByoptionfinder(String scope, String optionkey, boolean retrieveFromCache) throws SystemException { Object[] finderArgs = new Object[] { scope, optionkey }; Object result = null; if (retrieveFromCache) { result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_OPTIONFINDER, finderArgs, this); } if (result instanceof KdssmpConfiguration) { KdssmpConfiguration kdssmpConfiguration = (KdssmpConfiguration) result; if (!Validator.equals(scope, kdssmpConfiguration.getScope()) || !Validator.equals(optionkey, kdssmpConfiguration.getOptionkey())) { result = null; } } if (result == null) { StringBundler query = new StringBundler(4); query.append(_SQL_SELECT_KDSSMPCONFIGURATION_WHERE); boolean bindScope = false; if (scope == null) { query.append(_FINDER_COLUMN_OPTIONFINDER_SCOPE_1); } else if (scope.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_OPTIONFINDER_SCOPE_3); } else { bindScope = true; query.append(_FINDER_COLUMN_OPTIONFINDER_SCOPE_2); } boolean bindOptionkey = false; if (optionkey == null) { query.append(_FINDER_COLUMN_OPTIONFINDER_OPTIONKEY_1); } else if (optionkey.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_OPTIONFINDER_OPTIONKEY_3); } else { bindOptionkey = true; query.append(_FINDER_COLUMN_OPTIONFINDER_OPTIONKEY_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindScope) { qPos.add(scope); } if (bindOptionkey) { qPos.add(optionkey); } List<KdssmpConfiguration> list = q.list(); if (list.isEmpty()) { FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_OPTIONFINDER, finderArgs, list); } else { if ((list.size() > 1) && _log.isWarnEnabled()) { _log.warn( "KdssmpConfigurationPersistenceImpl.fetchByoptionfinder(String, String, boolean) with parameters (" + StringUtil.merge(finderArgs) + ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder."); } KdssmpConfiguration kdssmpConfiguration = list.get(0); result = kdssmpConfiguration; cacheResult(kdssmpConfiguration); if ((kdssmpConfiguration.getScope() == null) || !kdssmpConfiguration.getScope().equals(scope) || (kdssmpConfiguration.getOptionkey() == null) || !kdssmpConfiguration.getOptionkey().equals(optionkey)) { FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_OPTIONFINDER, finderArgs, kdssmpConfiguration); } } } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_OPTIONFINDER, finderArgs); throw processException(e); } finally { closeSession(session); } } if (result instanceof List<?>) { return null; } else { return (KdssmpConfiguration) result; } }
From source file:at.graz.meduni.liferay.portlet.bibbox.kdssmp.service.service.persistence.KdssmpConfigurationPersistenceImpl.java
License:Open Source License
/** * Returns the kdssmp configuration where scope = ? and optionvalue = ? or returns <code>null</code> if it could not be found, optionally using the finder cache. * * @param scope the scope//from w ww .j a v a 2 s . c om * @param optionvalue the optionvalue * @param retrieveFromCache whether to use the finder cache * @return the matching kdssmp configuration, or <code>null</code> if a matching kdssmp configuration could not be found * @throws SystemException if a system exception occurred */ @Override public KdssmpConfiguration fetchByoptionsfindervalue(String scope, String optionvalue, boolean retrieveFromCache) throws SystemException { Object[] finderArgs = new Object[] { scope, optionvalue }; Object result = null; if (retrieveFromCache) { result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_OPTIONSFINDERVALUE, finderArgs, this); } if (result instanceof KdssmpConfiguration) { KdssmpConfiguration kdssmpConfiguration = (KdssmpConfiguration) result; if (!Validator.equals(scope, kdssmpConfiguration.getScope()) || !Validator.equals(optionvalue, kdssmpConfiguration.getOptionvalue())) { result = null; } } if (result == null) { StringBundler query = new StringBundler(4); query.append(_SQL_SELECT_KDSSMPCONFIGURATION_WHERE); boolean bindScope = false; if (scope == null) { query.append(_FINDER_COLUMN_OPTIONSFINDERVALUE_SCOPE_1); } else if (scope.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_OPTIONSFINDERVALUE_SCOPE_3); } else { bindScope = true; query.append(_FINDER_COLUMN_OPTIONSFINDERVALUE_SCOPE_2); } boolean bindOptionvalue = false; if (optionvalue == null) { query.append(_FINDER_COLUMN_OPTIONSFINDERVALUE_OPTIONVALUE_1); } else if (optionvalue.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_OPTIONSFINDERVALUE_OPTIONVALUE_3); } else { bindOptionvalue = true; query.append(_FINDER_COLUMN_OPTIONSFINDERVALUE_OPTIONVALUE_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindScope) { qPos.add(scope); } if (bindOptionvalue) { qPos.add(optionvalue); } List<KdssmpConfiguration> list = q.list(); if (list.isEmpty()) { FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_OPTIONSFINDERVALUE, finderArgs, list); } else { if ((list.size() > 1) && _log.isWarnEnabled()) { _log.warn( "KdssmpConfigurationPersistenceImpl.fetchByoptionsfindervalue(String, String, boolean) with parameters (" + StringUtil.merge(finderArgs) + ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder."); } KdssmpConfiguration kdssmpConfiguration = list.get(0); result = kdssmpConfiguration; cacheResult(kdssmpConfiguration); if ((kdssmpConfiguration.getScope() == null) || !kdssmpConfiguration.getScope().equals(scope) || (kdssmpConfiguration.getOptionvalue() == null) || !kdssmpConfiguration.getOptionvalue().equals(optionvalue)) { FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_OPTIONSFINDERVALUE, finderArgs, kdssmpConfiguration); } } } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_OPTIONSFINDERVALUE, finderArgs); throw processException(e); } finally { closeSession(session); } } if (result instanceof List<?>) { return null; } else { return (KdssmpConfiguration) result; } }