use of com.qcadoo.model.api.aop.Monitorable in project qcadoo by qcadoo.
the class DataAccessServiceImpl method find.
@Override
@Transactional(readOnly = true)
@Monitorable
public SearchResult find(final SearchQuery searchQuery) {
checkArgument(searchQuery != null, "SearchCriteria must be given");
Query query = searchQuery.createQuery(hibernateService.getCurrentSession());
searchQuery.addParameters(query);
searchQuery.addCacheable(query);
int totalNumberOfEntities = -1;
if (searchQuery.hasFirstAndMaxResults()) {
totalNumberOfEntities = hibernateService.list(query).size();
searchQuery.addFirstAndMaxResults(query);
}
if (totalNumberOfEntities == 0) {
if (LOG.isDebugEnabled()) {
LOG.debug("There is no entity matching criteria " + searchQuery);
}
return getResultSet(null, totalNumberOfEntities, Collections.emptyList());
}
List<?> results = hibernateService.list(query);
if (totalNumberOfEntities == -1) {
totalNumberOfEntities = results.size();
if (totalNumberOfEntities == 0) {
if (LOG.isDebugEnabled()) {
LOG.debug("There is no entity matching criteria " + searchQuery);
}
return getResultSet(null, totalNumberOfEntities, Collections.emptyList());
}
}
if (LOG.isDebugEnabled()) {
LOG.debug("There are " + totalNumberOfEntities + " entities matching criteria " + searchQuery);
}
InternalDataDefinition searchQueryDataDefinition = (InternalDataDefinition) searchQuery.getDataDefinition();
if (searchQueryDataDefinition == null) {
searchQueryDataDefinition = hibernateService.resolveDataDefinition(query);
}
return getResultSet(searchQueryDataDefinition, totalNumberOfEntities, results);
}
use of com.qcadoo.model.api.aop.Monitorable in project qcadoo by qcadoo.
the class DataAccessServiceImpl method delete.
@Override
@Transactional
@Monitorable
public EntityOpResult delete(final InternalDataDefinition dataDefinition, final Long... entityIds) {
InternalDataDefinition dataDefinitionToDelete = getDataDefinitionByMasterModel(dataDefinition);
checkState(dataDefinitionToDelete.isDeletable(), "Entity must be deletable");
checkState(dataDefinitionToDelete.isEnabled(), L_DATA_DEFINITION_BELONGS_TO_DISABLED_PLUGIN);
checkState(entityIds.length > 0, "EntityIds must be given");
for (Long entityId : entityIds) {
EntityOpResult result = deleteEntity(dataDefinitionToDelete, entityId);
if (!result.isSuccessfull()) {
return result;
}
}
return EntityOpResult.successfull();
}
use of com.qcadoo.model.api.aop.Monitorable in project qcadoo by qcadoo.
the class DataDefinitionServiceImpl method get.
@Override
@Monitorable
public DataDefinition get(final String pluginIdentifier, final String modelName) {
DataDefinition dataDefinition = dataDefinitions.get(pluginIdentifier + "." + modelName);
checkNotNull(dataDefinition, "data definition for %s#%s cannot be found", pluginIdentifier, modelName);
return dataDefinition;
}
use of com.qcadoo.model.api.aop.Monitorable in project qcadoo by qcadoo.
the class DictionaryServiceImpl method getActiveKeys.
@Override
@Transactional(readOnly = true)
@Monitorable
public List<String> getActiveKeys(final String dictionary) {
checkArgument(hasText(dictionary), "dictionary name must be given");
List<Entity> items = createCriteriaForItemsFrom(dictionary).add(SearchRestrictions.eq("active", true)).addOrder(SearchOrders.asc(DictionaryItemFields.NAME)).list().getEntities();
List<String> keys = new ArrayList<>();
for (Entity item : items) {
keys.add(item.getStringField(DictionaryItemFields.NAME));
}
return keys;
}
use of com.qcadoo.model.api.aop.Monitorable in project qcadoo by qcadoo.
the class DictionaryServiceImpl method getKeys.
@Override
@Transactional(readOnly = true)
@Monitorable
public List<String> getKeys(final String dictionary) {
checkArgument(hasText(dictionary), "dictionary name must be given");
List<Entity> items = createCriteriaForItemsFrom(dictionary).addOrder(SearchOrders.asc(DictionaryItemFields.NAME)).list().getEntities();
List<String> keys = new ArrayList<>();
for (Entity item : items) {
keys.add(item.getStringField(DictionaryItemFields.NAME));
}
return keys;
}
Aggregations