use of com.qcadoo.model.api.aop.Monitorable in project qcadoo by qcadoo.
the class DictionaryServiceImpl method getKeyValues.
@Override
@Transactional(readOnly = true)
@Monitorable
public Map<String, String> getKeyValues(final String dictionary, final Locale locale) {
checkArgument(hasText(dictionary), "dictionary name must be given");
List<Entity> items = createCriteriaForActiveItemsFrom(dictionary).addOrder(SearchOrders.asc(DictionaryItemFields.NAME)).list().getEntities();
Map<String, String> values = new LinkedHashMap<>();
for (Entity item : items) {
values.put(item.getStringField(DictionaryItemFields.TECHNICAL_CODE), item.getStringField(DictionaryItemFields.NAME));
}
return values;
}
use of com.qcadoo.model.api.aop.Monitorable in project qcadoo by qcadoo.
the class DictionaryServiceImpl method getDictionaries.
@Override
@Transactional(readOnly = true)
@Monitorable
public Set<String> getDictionaries() {
List<Entity> dictionaries = getDictionaryDataDefinition().find().addOrder(SearchOrders.asc(DictionaryFields.NAME)).list().getEntities();
Set<String> names = new HashSet<>();
for (Entity dictionary : dictionaries) {
if ((Boolean) dictionary.getField(DictionaryFields.ACTIVE)) {
names.add(dictionary.getStringField(DictionaryFields.NAME));
}
}
return names;
}
use of com.qcadoo.model.api.aop.Monitorable in project qcadoo by qcadoo.
the class MenuServiceImpl method getMenu.
@Override
@Transactional(readOnly = true)
@Monitorable
public MenuDefinition getMenu(final Locale locale) {
MenuDefinition menuDefinition = new MenuDefinition();
List<Entity> menuCategories = menuCrudService.getSortedMenuCategories();
for (Entity menuCategory : menuCategories) {
String authRoleIdentifier = menuCategory.getStringField(MenuCategoryFields.AUTH_ROLE);
if (!currentUserHasPrivilegesOf(authRoleIdentifier)) {
continue;
}
MenuItemsGroup category = buildCategoryWithItems(menuCategory, locale);
if (ADMINISTRATION_CATEGORY.equals(category.getName())) {
menuDefinition.setAdministrationCategory(category);
} else if (HOME_CATEGORY.equals(category.getName())) {
menuDefinition.setHomeCategory(category);
} else if (!category.getItems().isEmpty()) {
menuDefinition.addItem(category);
}
}
return menuDefinition;
}
use of com.qcadoo.model.api.aop.Monitorable in project qcadoo by qcadoo.
the class DataAccessServiceImpl method move.
@Transactional
@Monitorable
private void move(final InternalDataDefinition dataDefinition, final Long entityId, final int position, final int offset) {
InternalDataDefinition dataDefinitionToMove = getDataDefinitionByMasterModel(dataDefinition);
checkNotNull(dataDefinitionToMove, L_DATA_DEFINITION_MUST_BE_GIVEN);
checkState(dataDefinitionToMove.isPrioritizable(), "Entity must be prioritizable");
checkState(dataDefinitionToMove.isEnabled(), L_DATA_DEFINITION_BELONGS_TO_DISABLED_PLUGIN);
checkNotNull(entityId, "EntityId must be given");
Object databaseEntity = getDatabaseEntity(dataDefinitionToMove, entityId);
if (databaseEntity == null) {
logEntityInfo(dataDefinitionToMove, entityId, "hasn't been prioritized, because it doesn't exist");
return;
}
priorityService.move(dataDefinitionToMove, databaseEntity, position, offset);
logEntityInfo(dataDefinitionToMove, entityId, "has been prioritized");
}
use of com.qcadoo.model.api.aop.Monitorable in project qcadoo by qcadoo.
the class DataAccessServiceImpl method activate.
@Override
@Transactional
@Monitorable
public List<Entity> activate(final InternalDataDefinition dataDefinition, final Long... entityIds) {
if (!dataDefinition.isActivable()) {
return Collections.emptyList();
}
InternalDataDefinition dataDefinitionToActivate = getDataDefinitionByMasterModel(dataDefinition);
List<Entity> activatedEntities = new ArrayList<Entity>();
for (Long entityId : entityIds) {
Entity entity = get(dataDefinitionToActivate, entityId);
if (entity == null) {
throw new IllegalStateException("Cannot activate " + entityId);
}
if (!entity.isActive()) {
entity.setActive(true);
entity = save(dataDefinitionToActivate, entity);
if (!entity.isValid()) {
throw new IllegalStateException("Cannot activate " + entity);
}
LOG.debug(entity + " has been activated");
activatedEntities.add(entity);
}
}
return activatedEntities;
}
Aggregations