diff --git a/metasfresh-webui-api/src/main/java/de/metas/ui/web/window/WindowConstants.java b/metasfresh-webui-api/src/main/java/de/metas/ui/web/window/WindowConstants.java index 44886b0dc..3afa2e303 100644 --- a/metasfresh-webui-api/src/main/java/de/metas/ui/web/window/WindowConstants.java +++ b/metasfresh-webui-api/src/main/java/de/metas/ui/web/window/WindowConstants.java @@ -22,11 +22,11 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public - * License along with this program. If not, see + * License along with this program. If not, see * . * #L% */ @@ -61,11 +61,17 @@ public final class WindowConstants public static final String FIELDNAME_OrderType = "OrderType"; public static final String FIELDNAME_M_AttributeSetInstance_ID = "M_AttributeSetInstance_ID"; public static final String FIELDNAME_Line = "Line"; - public static final Set FIELDNAMES_CreatedUpdated = ImmutableSet.of("Created", "CreatedBy", "Updated", "UpdatedBy"); - + + public static final String FIELDNAME_AD_Client_ID = "AD_Client_ID"; + public static final String FIELDNAME_AD_Org_ID = "AD_Org_ID"; + public static final String FIELDNAME_Created = "Created"; + public static final String FIELDNAME_CreatedBy = "CreatedBy"; + public static final String FIELDNAME_Updated = "Updated"; + public static final String FIELDNAME_UpdatedBy = "UpdatedBy"; + public static final Set FIELDNAMES_CreatedUpdated = ImmutableSet.of(FIELDNAME_Created, FIELDNAME_CreatedBy, FIELDNAME_Updated, FIELDNAME_UpdatedBy); + public static final String FIELDNAME_DocumentSummary = "V$DocumentSummary"; - public static final String CONTEXTVAR_NextLineNo = "CtxVar_NextLineNo"; private WindowConstants() @@ -82,8 +88,8 @@ public static boolean isProtocolDebugging() public static void setProtocolDebugging(final boolean protocolDebugging) { final boolean protocolDebuggingPrev = WindowConstants.protocolDebugging.getAndSet(protocolDebugging); - - if(protocolDebuggingPrev == protocolDebugging) + + if (protocolDebuggingPrev == protocolDebugging) { return; } diff --git a/metasfresh-webui-api/src/main/java/de/metas/ui/web/window/descriptor/factory/standard/DefaultValueExpressionsFactory.java b/metasfresh-webui-api/src/main/java/de/metas/ui/web/window/descriptor/factory/standard/DefaultValueExpressionsFactory.java index 9b04a88da..7908a8778 100644 --- a/metasfresh-webui-api/src/main/java/de/metas/ui/web/window/descriptor/factory/standard/DefaultValueExpressionsFactory.java +++ b/metasfresh-webui-api/src/main/java/de/metas/ui/web/window/descriptor/factory/standard/DefaultValueExpressionsFactory.java @@ -33,14 +33,14 @@ * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 2 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public - * License along with this program. If not, see + * License along with this program. If not, see * . * #L% */ @@ -58,6 +58,10 @@ public class DefaultValueExpressionsFactory private static final Optional> DEFAULT_VALUE_EXPRESSION_Zero_Integer; private static final Optional> DEFAULT_VALUE_EXPRESSION_M_AttributeSetInstance_ID; private static final Optional> DEFAULT_VALUE_EXPRESSION_NextLineNo; + private static final Optional> DEFAULT_VALUE_AD_Client_ID; + private static final Optional> DEFAULT_VALUE_AD_Org_ID; + private static final Optional> DEFAULT_VALUE_ContextDate; + private static final Optional> DEFAULT_VALUE_ContextUser_ID; static { @@ -69,18 +73,23 @@ public class DefaultValueExpressionsFactory DEFAULT_VALUE_EXPRESSION_Zero_Integer = Optional.of(expressionFactory.compile("0", IntegerStringExpression.class)); DEFAULT_VALUE_EXPRESSION_M_AttributeSetInstance_ID = Optional.of(expressionFactory.compile(String.valueOf(IAttributeDAO.M_AttributeSetInstance_ID_None), IntegerStringExpression.class)); DEFAULT_VALUE_EXPRESSION_NextLineNo = Optional.of(expressionFactory.compile("@" + WindowConstants.CONTEXTVAR_NextLineNo + "@", IntegerStringExpression.class)); + + DEFAULT_VALUE_AD_Client_ID = Optional.of(expressionFactory.compile("@" + WindowConstants.FIELDNAME_AD_Client_ID + "@", IntegerStringExpression.class)); + DEFAULT_VALUE_AD_Org_ID = Optional.of(expressionFactory.compile("@" + WindowConstants.FIELDNAME_AD_Org_ID + "@", IntegerStringExpression.class)); + DEFAULT_VALUE_ContextUser_ID = Optional.of(expressionFactory.compile("@#AD_User_ID@", IntegerStringExpression.class)); + DEFAULT_VALUE_ContextDate = Optional.of(expressionFactory.compile("@#Date@", DateStringExpression.class)); } // // Parameters private final boolean _isDetailTab; - + public DefaultValueExpressionsFactory(final boolean isDetailTab) { super(); - this._isDetailTab = isDetailTab; + _isDetailTab = isDetailTab; } - + private boolean isDetailTab() { return _isDetailTab; @@ -92,10 +101,10 @@ public Optional> extractDefaultValueExpression( , final DocumentFieldWidgetType widgetType // , final Class fieldValueClass // , final boolean isMandatory // - ) + ) { final boolean isDetailTab = isDetailTab(); - + // // Case: "Line" field in included tabs if (WindowConstants.FIELDNAME_Line.equals(columnName) @@ -109,7 +118,25 @@ public Optional> extractDefaultValueExpression( // If there is no default value expression, use some defaults if (defaultValueStr == null || defaultValueStr.isEmpty()) { - if (Boolean.class.equals(fieldValueClass)) + if (WindowConstants.FIELDNAME_AD_Client_ID.equals(columnName)) + { + return DEFAULT_VALUE_AD_Client_ID; + } + else if (WindowConstants.FIELDNAME_AD_Org_ID.equals(columnName)) + { + return DEFAULT_VALUE_AD_Org_ID; + } + else if (WindowConstants.FIELDNAME_Created.equals(columnName) + || WindowConstants.FIELDNAME_Updated.equals(columnName)) + { + return DEFAULT_VALUE_ContextDate; + } + else if (WindowConstants.FIELDNAME_CreatedBy.equals(columnName) + || WindowConstants.FIELDNAME_UpdatedBy.equals(columnName)) + { + return DEFAULT_VALUE_ContextUser_ID; + } + else if (Boolean.class.equals(fieldValueClass)) { if (WindowConstants.FIELDNAME_IsActive.equals(columnName)) { @@ -221,7 +248,7 @@ else if (Boolean.class.equals(fieldValueClass)) *
  • we have some cases where a List default value is something like 'P' *
  • we have some cases where a Table's reference default value is something like 'de.metas.swat' * - * + * * @param expressionStr * @return fixed expression or same expression if does not apply */