Search in sources :

Example 1 with PermissionAssistant

use of com.axelor.auth.db.PermissionAssistant in project axelor-open-suite by axelor.

the class PermissionAssistantController method fillObjects.

public void fillObjects(ActionRequest request, ActionResponse response) {
    try {
        PermissionAssistant assistant = request.getContext().asType(PermissionAssistant.class);
        MetaField metaField = assistant.getMetaField();
        if (metaField != null && (assistant.getObjectSet() == null || assistant.getObjectSet().isEmpty())) {
            List<MetaModel> models = Beans.get(MetaModelRepository.class).all().filter("self.metaFields.relationship = 'ManyToOne'" + " and self.metaFields.typeName = ?1", metaField.getTypeName()).fetch();
            Set<MetaModel> objectSet = new HashSet<>();
            objectSet.addAll(models);
            response.setValue("objectSet", objectSet);
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : MetaModel(com.axelor.meta.db.MetaModel) MetaModelRepository(com.axelor.meta.db.repo.MetaModelRepository) MetaField(com.axelor.meta.db.MetaField) PermissionAssistant(com.axelor.auth.db.PermissionAssistant) HashSet(java.util.HashSet)

Aggregations

PermissionAssistant (com.axelor.auth.db.PermissionAssistant)1 MetaField (com.axelor.meta.db.MetaField)1 MetaModel (com.axelor.meta.db.MetaModel)1 MetaModelRepository (com.axelor.meta.db.repo.MetaModelRepository)1 HashSet (java.util.HashSet)1