Search in sources :

Example 16 with Entity

use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.

the class GroupRolesValidationService method isCurrentUserShopOrSuperAdmin.

private boolean isCurrentUserShopOrSuperAdmin(final DataDefinition userDataDefinition) {
    if (isCalledFromShop()) {
        return true;
    }
    final Long currentUserId = securityService.getCurrentUserId();
    final Entity currentUserEntity = userDataDefinition.get(currentUserId);
    return securityService.hasRole(currentUserEntity, QcadooSecurityConstants.ROLE_SUPERADMIN);
}
Also used : Entity(com.qcadoo.model.api.Entity)

Example 17 with Entity

use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.

the class RoleModule method multiTenantEnable.

@Override
public void multiTenantEnable() {
    if (dataDefinitionService.get("qcadooSecurity", "role").find().add(SearchRestrictions.eq("identifier", identifier)).list().getTotalNumberOfEntities() > 0) {
        return;
    }
    Entity entity = dataDefinitionService.get("qcadooSecurity", "role").create();
    entity.setField("identifier", identifier);
    entity.setField("description", description);
    dataDefinitionService.get("qcadooSecurity", "role").save(entity);
}
Also used : Entity(com.qcadoo.model.api.Entity)

Example 18 with Entity

use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.

the class UserGroupModule method multiTenantEnable.

@Override
public void multiTenantEnable() {
    if (dataDefinitionService.get("qcadooSecurity", "group").find().add(SearchRestrictions.eq("identifier", identifier)).list().getTotalNumberOfEntities() > 0) {
        return;
    }
    Entity entity = dataDefinitionService.get("qcadooSecurity", "group").create();
    entity.setField("name", name);
    entity.setField("identifier", identifier);
    DataDefinition roleDD = dataDefinitionService.get("qcadooSecurity", "role");
    entity.setField("roles", roleDD.find().add(SearchRestrictions.in("identifier", (Object[]) roles.split(","))).list().getEntities());
    dataDefinitionService.get("qcadooSecurity", "group").save(entity);
}
Also used : Entity(com.qcadoo.model.api.Entity) DataDefinition(com.qcadoo.model.api.DataDefinition)

Example 19 with Entity

use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.

the class AwesomeDynamicListState method setFieldValue.

@SuppressWarnings("unchecked")
@Override
public void setFieldValue(final Object value) {
    requestRender();
    forms = new LinkedList<>();
    if (value instanceof List) {
        List<Entity> entities = (List<Entity>) value;
        for (Entity entity : entities) {
            InternalViewDefinitionState innerFormState = new ViewDefinitionStateImpl();
            FormComponentState formState = (FormComponentState) innerFormPattern.createComponentState(innerFormState);
            innerFormPattern.updateComponentStateListeners(innerFormState);
            try {
                formState.initialize(new JSONObject(), getLocale());
            } catch (JSONException e) {
                throw new IllegalStateException(e);
            }
            formState.setEntity(entity);
            forms.add(formState);
        }
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) JSONObject(org.json.JSONObject) InternalViewDefinitionState(com.qcadoo.view.internal.api.InternalViewDefinitionState) JSONException(org.json.JSONException) List(java.util.List) LinkedList(java.util.LinkedList) ViewDefinitionStateImpl(com.qcadoo.view.internal.internal.ViewDefinitionStateImpl) FormComponentState(com.qcadoo.view.internal.components.form.FormComponentState)

Example 20 with Entity

use of com.qcadoo.model.api.Entity in project qcadoo by qcadoo.

the class FormComponentState method getPersistedEntityWithIncludedFormValues.

@Override
public Entity getPersistedEntityWithIncludedFormValues() {
    if (entityId == null) {
        return getEntity();
    }
    Entity entity = getDataDefinition().get(entityId);
    if (entity == null) {
        return getEntity();
    }
    copyFieldsAndContextTo(entity);
    return entity;
}
Also used : Entity(com.qcadoo.model.api.Entity)

Aggregations

Entity (com.qcadoo.model.api.Entity)2833 FormComponent (com.qcadoo.view.api.components.FormComponent)514 Test (org.junit.Test)491 BigDecimal (java.math.BigDecimal)376 DataDefinition (com.qcadoo.model.api.DataDefinition)337 FieldComponent (com.qcadoo.view.api.components.FieldComponent)210 LookupComponent (com.qcadoo.view.api.components.LookupComponent)188 Date (java.util.Date)185 List (java.util.List)149 GridComponent (com.qcadoo.view.api.components.GridComponent)141 Map (java.util.Map)124 Autowired (org.springframework.beans.factory.annotation.Autowired)114 Service (org.springframework.stereotype.Service)112 SearchCriteriaBuilder (com.qcadoo.model.api.search.SearchCriteriaBuilder)105 Transactional (org.springframework.transaction.annotation.Transactional)101 DefaultEntity (com.qcadoo.model.internal.DefaultEntity)100 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)95 Collectors (java.util.stream.Collectors)87 Lists (com.google.common.collect.Lists)75 SampleSimpleDatabaseObject (com.qcadoo.model.beans.sample.SampleSimpleDatabaseObject)75