public static <T extends PersistentObject> SelectOneDescriptor<T> getElementByNameDescriptor(final Class<T> clazz, final String elementName, final String name) { final Map<String, Object> parameters = Collections.singletonMap("name", name); return new SelectOneDescriptor<>("get" + elementName + "ByName", parameters, clazz); }
@SuppressWarnings("unchecked") private <T> T selectOne(final Session session, final SelectOneDescriptor<T> selectDescriptor) throws SBonitaReadException { try { checkClassMapping(selectDescriptor.getEntityType()); } catch (final SPersistenceException e) { throw new SBonitaReadException(e); } final Query query = session.getNamedQuery(selectDescriptor.getQueryName()); setQueryCache(query, selectDescriptor.getQueryName()); final Map<String, Object> parameters = selectDescriptor.getInputParameters(); if (parameters != null) { setParameters(query, parameters); } query.setMaxResults(1); try { return disconnectIfReadOnly((T) query.uniqueResult(), query, session); } catch (final AssertionFailure | LockAcquisitionException | StaleStateException e) { throw new SRetryableException(e); } catch (final HibernateException he) { throw new SBonitaReadException(he); } }
@SuppressWarnings("unchecked") private <T> T selectOne(final Session session, final SelectOneDescriptor<T> selectDescriptor) throws SBonitaReadException { try { checkClassMapping(selectDescriptor.getEntityType()); } catch (final SPersistenceException e) { throw new SBonitaReadException(e); } final Query query = session.getNamedQuery(selectDescriptor.getQueryName()); setQueryCache(query, selectDescriptor.getQueryName()); final Map<String, Object> parameters = selectDescriptor.getInputParameters(); if (parameters != null) { setParameters(query, parameters); } query.setMaxResults(1); try { return disconnectIfReadOnly((T) query.uniqueResult(), query, session); } catch (final AssertionFailure | LockAcquisitionException | StaleStateException e) { throw new SRetryableException(e); } catch (final HibernateException he) { throw new SBonitaReadException(he); } }
public static SelectOneDescriptor<Long> getNumberOfProcessInstances() { final Map<String, Object> emptyMap = Collections.emptyMap(); return new SelectOneDescriptor<>("getNumberOfProcessInstances", emptyMap, SProcessInstance.class, Long.class); }
public static SelectOneDescriptor<Long> getNumberOfOpenActivities(final long rootContainerId) { final Map<String, Object> parameters = Collections.singletonMap("rootContainerId", (Object) rootContainerId); return new SelectOneDescriptor<>("getNumberOfOpenActivities", parameters, SActivityInstance.class, Long.class); }
public static SelectOneDescriptor<Long> getNumberOfSupervisors(final long processDefId) { final Map<String, Object> parameters = Collections.singletonMap("processDefId", (Object) processDefId); return new SelectOneDescriptor<Long>("getNumberOfSupervisorsOfProcessDef", parameters, SProcessSupervisor.class); }
public static SelectOneDescriptor<Long> getNumberOfCategoriesOfProcess(final long processId) { final Map<String, Object> parameters = Collections.singletonMap(PROCESS_ID, (Object) processId); return new SelectOneDescriptor<Long>("getNumberOfCategoriesOfProcess", parameters, SProcessCategoryMapping.class); }
public static SelectOneDescriptor<Long> getNumberOfCategorizedProcessIds(final List<Long> processIds) { final Map<String, Object> parameters = Collections.singletonMap("processIds", (Object) processIds); return new SelectOneDescriptor<Long>("getNumberOfCategorizedProcessIds", parameters, SProcessCategoryMapping.class, Long.class); }
public static SelectOneDescriptor<Long> getNumberOfGroupsOfActor(final long actorId) { final Map<String, Object> parameters = Collections.singletonMap("actorId", (Object) actorId); return new SelectOneDescriptor<Long>("getNumberOfGroupsOfActor", parameters, SActorMember.class); }
public static SelectOneDescriptor<SAMappedDocument> getArchivedVersionOfDocument(final long documentId) { final Map<String, Object> parameters = new HashMap<>(1); parameters.put("sourceObjectId", documentId); return new SelectOneDescriptor<>("getArchivedVersionOfDocument", parameters, SAMappedDocument.class); }
public static SelectOneDescriptor<Long> getLastUpdateDate(SThemeType type) { final Map<String, Object> inputParameters = new HashMap<String, Object>(1); inputParameters.put("type", type); return new SelectOneDescriptor<Long>("getLastUpdateDate", inputParameters, STheme.class); } }
public static SelectOneDescriptor<Long> getNumberOfSMappedDocumentOfProcess(final long processInstanceId) { final Map<String, Object> parameters = new HashMap<>(1); parameters.put("processInstanceId", processInstanceId); return new SelectOneDescriptor<>("getNumberOfSMappedDocumentOfProcess", parameters, SDocument.class); }
public static SelectOneDescriptor<SAMappedDocument> getArchivedVersionOfDocument(final long documentId) { final Map<String, Object> parameters = new HashMap<>(1); parameters.put("sourceObjectId", documentId); return new SelectOneDescriptor<>("getArchivedVersionOfDocument", parameters, SAMappedDocument.class); }
public static SelectOneDescriptor<SAActivityInstance> getMostRecentArchivedActivityInstance(final long activityInstanceId) { final Map<String, Object> parameters = new HashMap<>(1); parameters.put("activityInstanceId", activityInstanceId); return new SelectOneDescriptor<>("getMostRecentArchivedActivityInstance", parameters, SAActivityInstance.class); }
public static SelectOneDescriptor<STheme> getLastModifiedTheme(SThemeType type) { final Map<String, Object> inputParameters = new HashMap<String, Object>(1); inputParameters.put("type", type); return new SelectOneDescriptor<STheme>("getLastModifiedTheme", inputParameters, STheme.class); }
public static SelectOneDescriptor<Long> getNumberOfSMappedDocumentOfProcess(final long processInstanceId) { final Map<String, Object> parameters = new HashMap<>(1); parameters.put("processInstanceId", processInstanceId); return new SelectOneDescriptor<>("getNumberOfSMappedDocumentOfProcess", parameters, SDocument.class); }
public static SelectOneDescriptor<SAActivityInstance> getMostRecentArchivedActivityInstance(final long activityInstanceId) { final Map<String, Object> parameters = new HashMap<>(1); parameters.put("activityInstanceId", activityInstanceId); return new SelectOneDescriptor<>("getMostRecentArchivedActivityInstance", parameters, SAActivityInstance.class); }
public static SelectOneDescriptor<Long> getNumberOfUsersByGroup(final long groupId) { final Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("groupId", groupId); return new SelectOneDescriptor<Long>("getNumberOfUsersByGroup", parameters, SUser.class, Long.class); }
public static SelectOneDescriptor<Long> getLastUpdateDate(SThemeType type) { final Map<String, Object> inputParameters = new HashMap<String, Object>(1); inputParameters.put("type", type); return new SelectOneDescriptor<Long>("getLastUpdateDate", inputParameters, STheme.class); } }
public static SelectOneDescriptor<SActor> getActor(final String actorName, final long scopeId) { final Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("name", actorName); parameters.put("scopeId", scopeId); return new SelectOneDescriptor<SActor>("getActorFromNameAndScopeId", parameters, SActor.class); }