use of org.adempiere.ad.expression.api.LogicExpressionResult in project metasfresh-webui-api by metasfresh.
the class JSONDocument method createIncludedTabInfo.
private static JSONIncludedTabInfo createIncludedTabInfo(final DocumentChanges.IncludedDetailInfo includedDetailInfo) {
final JSONIncludedTabInfo tabInfo = JSONIncludedTabInfo.newInstance(includedDetailInfo.getDetailId());
if (includedDetailInfo.isStale()) {
tabInfo.setStale();
}
final LogicExpressionResult allowCreateNew = includedDetailInfo.getAllowNew();
if (allowCreateNew != null) {
tabInfo.setAllowCreateNew(allowCreateNew.booleanValue(), allowCreateNew.getName());
}
final LogicExpressionResult allowDelete = includedDetailInfo.getAllowDelete();
if (allowDelete != null) {
tabInfo.setAllowDelete(allowDelete.booleanValue(), allowDelete.getName());
}
return tabInfo;
}
use of org.adempiere.ad.expression.api.LogicExpressionResult in project metasfresh-webui-api by metasfresh.
the class JSONDocument method createIncludedTabInfo.
private static JSONIncludedTabInfo createIncludedTabInfo(final IIncludedDocumentsCollection includedDocumentsCollection) {
final JSONIncludedTabInfo tabInfo = JSONIncludedTabInfo.newInstance(includedDocumentsCollection.getDetailId());
if (includedDocumentsCollection.isStale()) {
tabInfo.setStale();
}
final LogicExpressionResult allowCreateNew = includedDocumentsCollection.getAllowCreateNewDocument();
if (allowCreateNew != null) {
tabInfo.setAllowCreateNew(allowCreateNew.booleanValue(), allowCreateNew.getName());
}
final LogicExpressionResult allowDelete = includedDocumentsCollection.getAllowDeleteDocument();
if (allowDelete != null) {
tabInfo.setAllowDelete(allowDelete.booleanValue(), allowDelete.getName());
}
return tabInfo;
}
use of org.adempiere.ad.expression.api.LogicExpressionResult in project metasfresh-webui-api by metasfresh.
the class JSONDocumentField method ofDocumentFieldChangedEvent.
public static JSONDocumentField ofDocumentFieldChangedEvent(final DocumentFieldChange event, final JSONOptions jsonOpts) {
final JSONLayoutWidgetType widgetType = JSONLayoutWidgetType.fromNullable(event.getWidgetType());
final JSONDocumentField jsonField = new JSONDocumentField(event.getFieldName(), widgetType);
if (event.isValueSet()) {
jsonField.setValue(event.getValueAsJsonObject(), ReasonSupplier.toDebugString(event.getValueReason()));
}
final LogicExpressionResult readonly = event.getReadonly();
if (readonly != null) {
jsonField.setReadonly(readonly.booleanValue(), ReasonSupplier.toDebugString(event.getReadonlyReason()));
}
final LogicExpressionResult mandatory = event.getMandatory();
if (mandatory != null) {
jsonField.setMandatory(mandatory.booleanValue(), ReasonSupplier.toDebugString(event.getMandatoryReason()));
}
final LogicExpressionResult displayed = event.getDisplayed();
if (displayed != null) {
jsonField.setDisplayed(displayed.booleanValue(), ReasonSupplier.toDebugString(event.getDisplayedReason()));
}
final Boolean lookupValuesStale = event.getLookupValuesStale();
if (lookupValuesStale != null) {
jsonField.setLookupValuesStale(lookupValuesStale, ReasonSupplier.toDebugString(event.getLookupValuesStaleReason()));
}
final DocumentValidStatus validStatus = event.getValidStatus();
if (validStatus != null) {
jsonField.setValidStatus(validStatus);
}
jsonField.setFieldWarning(JSONDocumentFieldWarning.ofNullable(event.getFieldWarning(), jsonOpts.getAD_Language()));
jsonField.putDebugProperties(event.getDebugProperties());
return jsonField;
}
use of org.adempiere.ad.expression.api.LogicExpressionResult in project metasfresh-webui-api by metasfresh.
the class DocumentChanges method collectFrom.
private boolean collectFrom(final IDocumentFieldView documentField, final ReasonSupplier reason) {
final DocumentFieldChange toEvent = fieldChangesOf(documentField);
boolean collected = false;
// Value
if (!toEvent.isValueSet()) {
final Object value = documentField.getValue();
toEvent.setValue(value, reason);
collected = true;
} else {
final Object value = documentField.getValue();
final Object previousValue = toEvent.getValue();
if (!DataTypes.equals(value, previousValue)) {
final ReasonSupplier reasonNew = reason.addPreviousReason(toEvent.getValueReason(), previousValue == null ? "<NULL>" : previousValue);
toEvent.setValue(value, reasonNew);
collected = true;
}
}
//
// Readonly
final LogicExpressionResult readonly = documentField.getReadonly();
if (!readonly.equals(toEvent.getReadonly())) {
final ReasonSupplier reasonNew = reason.add("readonly", readonly).addPreviousReason(toEvent.getReadonlyReason());
toEvent.setReadonly(readonly, reasonNew);
collected = true;
}
//
// Mandatory
final LogicExpressionResult mandatory = documentField.getMandatory();
if (!mandatory.equals(toEvent.getMandatory())) {
final ReasonSupplier reasonNew = reason.add("mandatory", mandatory).addPreviousReason(toEvent.getMandatoryReason());
toEvent.setMandatory(mandatory, reasonNew);
collected = true;
}
//
// Displayed
final LogicExpressionResult displayed = documentField.getDisplayed();
if (!displayed.equals(toEvent.getDisplayed())) {
final ReasonSupplier reasonNew = reason.add("displayed", displayed).addPreviousReason(toEvent.getDisplayedReason());
toEvent.setDisplayed(displayed, reasonNew);
collected = true;
}
return collected;
}
use of org.adempiere.ad.expression.api.LogicExpressionResult in project metasfresh-webui-api by metasfresh.
the class DocumentCollection method assertDeleteDocumentAllowed.
private void assertDeleteDocumentAllowed(final DocumentEntityDescriptor entityDescriptor) {
final Evaluatee evalCtx = Evaluatees.mapBuilder().put(WindowConstants.FIELDNAME_Processed, false).build().andComposeWith(userSession.toEvaluatee());
final ILogicExpression allowExpr = entityDescriptor.getAllowDeleteLogic();
final LogicExpressionResult allow = allowExpr.evaluateToResult(evalCtx, OnVariableNotFound.ReturnNoResult);
if (allow.isFalse()) {
throw new AdempiereException("Delete not allowed");
}
}
Aggregations