diff --git a/src/main/java/de/metas/ui/web/process/adprocess/ADProcessParametersRepository.java b/src/main/java/de/metas/ui/web/process/adprocess/ADProcessParametersRepository.java index 7921235f0..5d88ba38a 100644 --- a/src/main/java/de/metas/ui/web/process/adprocess/ADProcessParametersRepository.java +++ b/src/main/java/de/metas/ui/web/process/adprocess/ADProcessParametersRepository.java @@ -12,6 +12,7 @@ import de.metas.process.IADPInstanceDAO; import de.metas.process.ProcessInfoParameter; import de.metas.ui.web.exceptions.EntityNotFoundException; +import de.metas.ui.web.window.WindowConstants; import de.metas.ui.web.window.datatypes.DocumentId; import de.metas.ui.web.window.datatypes.LookupValue; import de.metas.ui.web.window.descriptor.DocumentEntityDescriptor; @@ -130,7 +131,10 @@ public Document createNewDocument(final DocumentEntityDescriptor parametersDescr Document createNewParametersDocument(final DocumentEntityDescriptor parametersDescriptor, final DocumentId adPInstanceId, final IDocumentEvaluatee evalCtx) { return Document.builder(parametersDescriptor) - .setShadowParentDocumentEvaluatee(evalCtx) + .setShadowParentDocumentEvaluatee(evalCtx.excludingFields( + WindowConstants.FIELDNAME_Processed, + WindowConstants.FIELDNAME_Processing, + WindowConstants.FIELDNAME_IsActive)) .initializeAsNewDocument(adPInstanceId, VERSION_DEFAULT); } diff --git a/src/main/java/de/metas/ui/web/window/model/DocumentEvaluatee.java b/src/main/java/de/metas/ui/web/window/model/DocumentEvaluatee.java index 37d01fde4..1957555b7 100644 --- a/src/main/java/de/metas/ui/web/window/model/DocumentEvaluatee.java +++ b/src/main/java/de/metas/ui/web/window/model/DocumentEvaluatee.java @@ -7,6 +7,7 @@ import java.util.Optional; import java.util.Properties; +import javax.annotation.Nullable; import javax.validation.constraints.NotNull; import org.adempiere.ad.validationRule.IValidationContext; @@ -18,6 +19,7 @@ import org.slf4j.Logger; import com.google.common.base.MoreObjects; +import com.google.common.collect.ImmutableSet; import de.metas.logging.LogManager; import de.metas.printing.esb.base.util.Check; @@ -28,6 +30,7 @@ import de.metas.ui.web.window.datatypes.json.JSONDate; import de.metas.ui.web.window.descriptor.DetailId; import de.metas.ui.web.window.descriptor.DocumentFieldWidgetType; +import lombok.NonNull; /* * #%L @@ -56,22 +59,23 @@ private static final Logger logger = LogManager.getLogger(DocumentEvaluatee.class); private final Document _document; - - // - // Scope private final String _fieldNameInScope; + private final ImmutableSet _fieldNamesToExclude; + /* package */ DocumentEvaluatee(@NotNull final Document document) { _document = document; // note: we assume it's not null _fieldNameInScope = null; + _fieldNamesToExclude = ImmutableSet.of(); } - private DocumentEvaluatee(@NotNull final Document document, final String fieldNameInScope) + private DocumentEvaluatee(@NotNull final Document document, @Nullable final String fieldNameInScope, @NonNull final ImmutableSet fieldNamesToExclude) { super(); _document = document; // note: we assume it's not null _fieldNameInScope = fieldNameInScope; // null is also ok + _fieldNamesToExclude = fieldNamesToExclude; } @Override @@ -92,13 +96,25 @@ public IDocumentEvaluatee fieldInScope(final String fieldNameInScope) return this; } - return new DocumentEvaluatee(_document, fieldNameInScope); + return new DocumentEvaluatee(_document, fieldNameInScope, ImmutableSet.of()); } private final boolean isFieldInScope(final String fieldName) { return Objects.equals(_fieldNameInScope, fieldName); } + + @Override + public IDocumentEvaluatee excludingFields(final String ... fieldNamesToExclude) + { + return new DocumentEvaluatee(_document, _fieldNameInScope, ImmutableSet.copyOf(fieldNamesToExclude)); + } + + private boolean isExcludedField(final String fieldName) + { + return _fieldNamesToExclude.contains(fieldName); + } + private Properties getCtx() { @@ -205,6 +221,11 @@ public Optional get_ValueIfExists(final String variableName, final Class { return Optional.empty(); } + + if(isExcludedField(variableName)) + { + return Optional.empty(); + } if (WindowConstants.CONTEXTVAR_NextLineNo.equals(variableName)) { diff --git a/src/main/java/de/metas/ui/web/window/model/IDocumentEvaluatee.java b/src/main/java/de/metas/ui/web/window/model/IDocumentEvaluatee.java index 072974b0a..7685bf85c 100644 --- a/src/main/java/de/metas/ui/web/window/model/IDocumentEvaluatee.java +++ b/src/main/java/de/metas/ui/web/window/model/IDocumentEvaluatee.java @@ -37,4 +37,11 @@ public interface IDocumentEvaluatee extends Evaluatee * @return new evaluatee instance which has the given field in scope */ IDocumentEvaluatee fieldInScope(String fieldNameInScope); + + /** + * Creates a new evaluatee which will exclude given field names. + * + * @param fieldNamesToExclude + */ + IDocumentEvaluatee excludingFields(String... fieldNamesToExclude); }