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;
}
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");
}
}
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);
}
}
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;
}
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);
}
Aggregations