Search in sources :

Example 11 with LogicExpressionResult

use of org.adempiere.ad.expression.api.LogicExpressionResult in project metasfresh-webui-api by metasfresh.

the class IncludedDocumentsCollectionActions method setAllowNewAndCollect.

private LogicExpressionResult setAllowNewAndCollect(final LogicExpressionResult allowNew, final IncludedDocumentsCollectionActionsContext context) {
    final LogicExpressionResult allowNewOld = this.allowNew;
    this.allowNew = allowNew;
    if (!allowNewOld.equalsByNameAndValue(allowNew)) {
        context.collectAllowNew(parentDocumentPath, detailId, allowNew);
    }
    return allowNew;
}
Also used : LogicExpressionResult(org.adempiere.ad.expression.api.LogicExpressionResult)

Example 12 with LogicExpressionResult

use of org.adempiere.ad.expression.api.LogicExpressionResult in project metasfresh-webui-api by metasfresh.

the class DocumentCollection method assertNewDocumentAllowed.

private void assertNewDocumentAllowed(final DocumentEntityDescriptor entityDescriptor) {
    final ILogicExpression allowExpr = entityDescriptor.getAllowCreateNewLogic();
    final LogicExpressionResult allow = allowExpr.evaluateToResult(userSession.toEvaluatee(), OnVariableNotFound.ReturnNoResult);
    if (allow.isFalse()) {
        throw new AdempiereException("Create not allowed");
    }
}
Also used : ILogicExpression(org.adempiere.ad.expression.api.ILogicExpression) AdempiereException(org.adempiere.exceptions.AdempiereException) LogicExpressionResult(org.adempiere.ad.expression.api.LogicExpressionResult)

Example 13 with LogicExpressionResult

use of org.adempiere.ad.expression.api.LogicExpressionResult in project metasfresh-webui-api by metasfresh.

the class DocumentField method setMandatory.

@Override
public void setMandatory(@NonNull final LogicExpressionResult mandatory, final IDocumentChangesCollector changesCollector) {
    final LogicExpressionResult mandatoryOld = _mandatory;
    _mandatory = mandatory;
    // Update validStatus if mandatory flag changed
    if (!mandatoryOld.equalsByValue(mandatory)) {
        updateValid(changesCollector);
    }
}
Also used : LogicExpressionResult(org.adempiere.ad.expression.api.LogicExpressionResult)

Example 14 with LogicExpressionResult

use of org.adempiere.ad.expression.api.LogicExpressionResult in project metasfresh-webui-api by metasfresh.

the class Document method computeReadonly.

private final DocumentReadonly computeReadonly() {
    final ILogicExpression allFieldsReadonlyLogic = getEntityDescriptor().getReadonlyLogic();
    LogicExpressionResult allFieldsReadonly;
    try {
        allFieldsReadonly = allFieldsReadonlyLogic.evaluateToResult(asEvaluatee(), OnVariableNotFound.Fail);
    } catch (final Exception e) {
        allFieldsReadonly = LogicExpressionResult.FALSE;
        logger.warn("Failed evaluating entity readonly logic {} for {}. Considering {}", allFieldsReadonlyLogic, this, allFieldsReadonly, e);
    }
    final DocumentReadonly readonlyComputed = DocumentReadonly.builder().parentActive(parentReadonly.isActive()).active(isActive()).processed(parentReadonly.isProcessed() || isProcessed()).processing(parentReadonly.isProcessing() || isProcessing()).fieldsReadonly(allFieldsReadonly.booleanValue()).build();
    return readonlyComputed;
}
Also used : ILogicExpression(org.adempiere.ad.expression.api.ILogicExpression) LogicExpressionResult(org.adempiere.ad.expression.api.LogicExpressionResult) DocumentFieldReadonlyException(de.metas.ui.web.window.exceptions.DocumentFieldReadonlyException) InvalidDocumentStateException(de.metas.ui.web.window.exceptions.InvalidDocumentStateException) DocumentNotFoundException(de.metas.ui.web.window.exceptions.DocumentNotFoundException) DocumentProcessingException(de.metas.document.exceptions.DocumentProcessingException) AdempiereException(org.adempiere.exceptions.AdempiereException) DocumentFieldNotFoundException(de.metas.ui.web.window.exceptions.DocumentFieldNotFoundException)

Example 15 with LogicExpressionResult

use of org.adempiere.ad.expression.api.LogicExpressionResult in project metasfresh-webui-api by metasfresh.

the class DocumentChangesCollector method collectReadonlyIfChanged.

@Override
public void collectReadonlyIfChanged(final IDocumentFieldView documentField, final LogicExpressionResult valueOld, final ReasonSupplier reason) {
    // If there is no change, don't collect the value
    final LogicExpressionResult value = documentField.getReadonly();
    if (value.equalsByNameAndValue(valueOld)) {
        return;
    }
    final ReasonSupplier reasonNew = reason.add("readonly", value);
    documentChanges(documentField).collectReadonlyChanged(documentField, reasonNew);
}
Also used : LogicExpressionResult(org.adempiere.ad.expression.api.LogicExpressionResult)

Aggregations

LogicExpressionResult (org.adempiere.ad.expression.api.LogicExpressionResult)17 ILogicExpression (org.adempiere.ad.expression.api.ILogicExpression)6 AdempiereException (org.adempiere.exceptions.AdempiereException)6 DocumentProcessingException (de.metas.document.exceptions.DocumentProcessingException)4 DocumentFieldNotFoundException (de.metas.ui.web.window.exceptions.DocumentFieldNotFoundException)4 DocumentFieldReadonlyException (de.metas.ui.web.window.exceptions.DocumentFieldReadonlyException)4 DocumentNotFoundException (de.metas.ui.web.window.exceptions.DocumentNotFoundException)4 InvalidDocumentStateException (de.metas.ui.web.window.exceptions.InvalidDocumentStateException)4 ReasonSupplier (de.metas.ui.web.window.model.IDocumentChangesCollector.ReasonSupplier)2 DocumentValidStatus (de.metas.ui.web.window.model.DocumentValidStatus)1 Evaluatee (org.compiere.util.Evaluatee)1