@Override public <T extends PersistentObject> List<T> searchEntity(final Class<T> entityClass, final String querySuffix, final QueryOptions options, final Map<String, Object> parameters) throws SBonitaReadException { final String queryName = getQueryName("search", querySuffix, entityClass, options.getFilters()); final SelectListDescriptor<T> descriptor = new SelectListDescriptor<T>(queryName, parameters, entityClass, options); return selectList(descriptor); }
@Override public SIcon getIcon(long id) throws SBonitaReadException { return persistenceService.selectById(new SelectByIdDescriptor<>(SIcon.class, id)); } }
@Override public long getNumberOfCustomUserInfoValue(final QueryOptions options) throws SBonitaReadException { try { return persistenceService.getNumberOfEntities(SCustomUserInfoValue.class, options, null); } catch (final SBonitaReadException e) { throw new SBonitaReadException(e); } }
@Override public List<Long> getProcessDefinitionIds(final int fromIndex, final int numberOfResults) throws SBonitaReadException { final Map<String, Object> parameters = Collections.emptyMap(); final List<OrderByOption> orderByOptions = Collections.singletonList(new OrderByOption(SProcessDefinitionDeployInfo.class, "id", OrderByType.ASC)); final SelectListDescriptor<Long> selectDescriptor = new SelectListDescriptor<>("getProcessDefinitionsIds", parameters, SProcessDefinitionDeployInfo.class, new QueryOptions(fromIndex, numberOfResults, orderByOptions)); return persistenceService.selectList(selectDescriptor); }
@Override public List<SMappedDocument> searchDocuments(final QueryOptions queryOptions) throws SBonitaReadException { try { return persistenceService.searchEntity(SMappedDocument.class, queryOptions, null); } catch (final SBonitaReadException e) { throw new SBonitaReadException(e); } }
@Override public <T extends PersistentObject> T selectById(final SelectByIdDescriptor<T> selectDescriptor) throws SBonitaReadException { try { final Session session = getSession(true); final T object = this.selectById(session, selectDescriptor); if (selectDescriptor.isReadOnly()) { disconnectEntityFromSession(session, object); } return object; } catch (final SPersistenceException e) { throw new SBonitaReadException(e, selectDescriptor); } }
@Override public <T> T selectOne(final SelectOneDescriptor<T> selectDescriptor) throws SBonitaReadException { try { return selectOne(getSession(true), selectDescriptor); } catch (final SPersistenceException e) { throw new SBonitaReadException(e, selectDescriptor); } }
@Override protected Object processValue(Object fieldValue) { Object value = super.processValue(fieldValue); if (value instanceof Boolean) { if (useIntegerForBoolean(vendor)) { value = (Boolean) value ? 1 : 0; } } return value; }
private static final String formatMessage(final Throwable cause) { String message = null; if (cause instanceof SBonitaReadException) { final AbstractSelectDescriptor<?> descriptor = ((SBonitaReadException) cause).getSelectDescriptor(); if (descriptor != null) { message = descriptor.toString(); } } return message; }
@Override protected Session getSession(final boolean useTenant) throws SPersistenceException { final Session session = super.getSession(useTenant); updateTenantFilter(session, useTenant); return session; }
@Override public void insertInBatch(final List<? extends PersistentObject> entities) throws SPersistenceException { for (final PersistentObject entity : entities) { setTenant(entity); } super.insertInBatch(entities); }
@Override public SIcon getIcon(long id) throws SBonitaReadException { return persistenceService.selectById(new SelectByIdDescriptor<>(SIcon.class, id)); } }
@Override public <T extends PersistentObject> List<T> searchEntity(final Class<T> entityClass, final String querySuffix, final QueryOptions options, final Map<String, Object> parameters) throws SBonitaReadException { final String queryName = getQueryName("search", querySuffix, entityClass, options.getFilters()); final SelectListDescriptor<T> descriptor = new SelectListDescriptor<T>(queryName, parameters, entityClass, options); return selectList(descriptor); }
@Override public List<SMappedDocument> searchDocuments(final QueryOptions queryOptions) throws SBonitaReadException { try { return persistenceService.searchEntity(SMappedDocument.class, queryOptions, null); } catch (final SBonitaReadException e) { throw new SBonitaReadException(e); } }
@Override public long getNumberOfCustomUserInfoValue(final QueryOptions options) throws SBonitaReadException { try { return persistenceService.getNumberOfEntities(SCustomUserInfoValue.class, options, null); } catch (final SBonitaReadException e) { throw new SBonitaReadException(e); } }
@Override public <T> T selectOne(final SelectOneDescriptor<T> selectDescriptor) throws SBonitaReadException { try { return selectOne(getSession(true), selectDescriptor); } catch (final SPersistenceException e) { throw new SBonitaReadException(e, selectDescriptor); } }
@Override protected Object processValue(Object fieldValue) { Object value = super.processValue(fieldValue); if (value instanceof Boolean) { if (useIntegerForBoolean(vendor)) { value = (Boolean) value ? 1 : 0; } } return value; }
private static final String formatMessage(final Throwable cause) { String message = null; if (cause instanceof SBonitaReadException) { final AbstractSelectDescriptor<?> descriptor = ((SBonitaReadException) cause).getSelectDescriptor(); if (descriptor != null) { message = descriptor.toString(); } } return message; }