diff --git a/de.metas.adempiere.adempiere/base/src/main/java/org/adempiere/ad/column/model/interceptor/AD_Column.java b/de.metas.adempiere.adempiere/base/src/main/java/org/adempiere/ad/column/model/interceptor/AD_Column.java index bd8ac30bb62..7cb2aad82c7 100644 --- a/de.metas.adempiere.adempiere/base/src/main/java/org/adempiere/ad/column/model/interceptor/AD_Column.java +++ b/de.metas.adempiere.adempiere/base/src/main/java/org/adempiere/ad/column/model/interceptor/AD_Column.java @@ -1,5 +1,6 @@ package org.adempiere.ad.column.model.interceptor; +import org.adempiere.ad.expression.api.impl.LogicExpressionCompiler; import org.adempiere.ad.modelvalidator.annotations.Interceptor; import org.adempiere.ad.modelvalidator.annotations.ModelChange; import org.compiere.model.AccessSqlParser; @@ -21,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% */ @@ -39,7 +40,7 @@ public class AD_Column public void lowerCaseWhereClause(final I_AD_Column column) { final String columnSQL = column.getColumnSQL(); - if(Check.isEmpty(columnSQL, true)) + if (Check.isEmpty(columnSQL, true)) { // nothing to do return; @@ -50,4 +51,19 @@ public void lowerCaseWhereClause(final I_AD_Column column) column.setColumnSQL(adaptedWhereClause); } + + @ModelChange(timings = { ModelValidator.TYPE_BEFORE_NEW, ModelValidator.TYPE_BEFORE_CHANGE }, // + ifColumnsChanged = { I_AD_Column.COLUMNNAME_MandatoryLogic, I_AD_Column.COLUMNNAME_ReadOnlyLogic }) + public void validateLogicExpressions(final I_AD_Column column) + { + if (!Check.isEmpty(column.getReadOnlyLogic(), true)) + { + LogicExpressionCompiler.instance.compile(column.getReadOnlyLogic()); + } + + if (!Check.isEmpty(column.getMandatoryLogic(), true)) + { + LogicExpressionCompiler.instance.compile(column.getMandatoryLogic()); + } + } } diff --git a/de.metas.adempiere.adempiere/base/src/main/java/org/adempiere/ad/field/model/interceptor/AD_Field.java b/de.metas.adempiere.adempiere/base/src/main/java/org/adempiere/ad/field/model/interceptor/AD_Field.java index b6c3bf4a8ed..196b54a9a54 100644 --- a/de.metas.adempiere.adempiere/base/src/main/java/org/adempiere/ad/field/model/interceptor/AD_Field.java +++ b/de.metas.adempiere.adempiere/base/src/main/java/org/adempiere/ad/field/model/interceptor/AD_Field.java @@ -2,6 +2,7 @@ import java.sql.SQLException; +import org.adempiere.ad.expression.api.impl.LogicExpressionCompiler; import org.adempiere.ad.modelvalidator.annotations.Interceptor; import org.adempiere.ad.modelvalidator.annotations.ModelChange; import org.compiere.model.I_AD_Column; @@ -11,6 +12,7 @@ import org.springframework.stereotype.Component; import de.metas.translation.api.IElementTranslationBL; +import de.metas.util.Check; import de.metas.util.Services; /* @@ -93,4 +95,15 @@ public void updateTranslationsForElement(final I_AD_Field field) // in the end, make sure the translation fields are also updated Services.get(IElementTranslationBL.class).updateFieldTranslationsFromAD_Name(fieldElement.getAD_Element_ID()); } + + @ModelChange(timings = { ModelValidator.TYPE_BEFORE_NEW, ModelValidator.TYPE_BEFORE_CHANGE }, // + ifColumnsChanged = { I_AD_Field.COLUMNNAME_DisplayLogic }) + public void validateLogicExpressions(final I_AD_Field field) + { + if (!Check.isEmpty(field.getDisplayLogic(), true)) + { + LogicExpressionCompiler.instance.compile(field.getDisplayLogic()); + } + } + }