Search in sources :

Example 1 with JoinFieldHolder

use of com.qcadoo.model.api.types.JoinFieldHolder in project qcadoo by qcadoo.

the class DataAccessServiceImpl method performCascadeNullification.

private EntityOpResult performCascadeNullification(final InternalDataDefinition childDataDefinition, final Collection<Entity> children, final Entity entity, final FieldType fieldType) {
    String joinFieldName = ((JoinFieldHolder) fieldType).getJoinFieldName();
    for (Entity child : children) {
        child.setField(joinFieldName, null);
        child = save(childDataDefinition, child);
        if (!child.isValid()) {
            String msg = String.format("Can not nullify field '%s' in %s because of following validation errors:", joinFieldName, child);
            logEntityErrors(child, msg);
            EntityMessagesHolder msgHolder = new EntityMessagesHolderImpl(child);
            msgHolder.addGlobalError("qcadooView.errorPage.error.dataIntegrityViolationException.objectInUse.explanation");
            return EntityOpResult.failure(msgHolder);
        }
    }
    return EntityOpResult.successfull();
}
Also used : Entity(com.qcadoo.model.api.Entity) JoinFieldHolder(com.qcadoo.model.api.types.JoinFieldHolder) EntityMessagesHolder(com.qcadoo.model.api.EntityMessagesHolder)

Example 2 with JoinFieldHolder

use of com.qcadoo.model.api.types.JoinFieldHolder in project qcadoo by qcadoo.

the class LookupComponentPattern method getComponentStateInstance.

@Override
public ComponentState getComponentStateInstance() {
    if (getScopeFieldDefinition() == null) {
        return new LookupComponentState(null, fieldCode, expression, this);
    }
    String joinFieldName = null;
    if (getScopeFieldDefinition().getType() instanceof JoinFieldHolder) {
        joinFieldName = ((JoinFieldHolder) getScopeFieldDefinition().getType()).getJoinFieldName();
    }
    FieldDefinition fieldDefinition = getDataDefinition().getField(joinFieldName);
    return new LookupComponentState(fieldDefinition, fieldCode, expression, this);
}
Also used : JoinFieldHolder(com.qcadoo.model.api.types.JoinFieldHolder) FieldDefinition(com.qcadoo.model.api.FieldDefinition)

Aggregations

JoinFieldHolder (com.qcadoo.model.api.types.JoinFieldHolder)2 Entity (com.qcadoo.model.api.Entity)1 EntityMessagesHolder (com.qcadoo.model.api.EntityMessagesHolder)1 FieldDefinition (com.qcadoo.model.api.FieldDefinition)1