diff --git a/framework/data/EntityTypeData.xml b/framework/data/EntityTypeData.xml index b47f50a32..cb62ec320 100644 --- a/framework/data/EntityTypeData.xml +++ b/framework/data/EntityTypeData.xml @@ -26,6 +26,9 @@ along with this software (see the LICENSE.md file). If not, see + + + diff --git a/framework/src/main/groovy/org/moqui/impl/entity/EntityConditionFactoryImpl.groovy b/framework/src/main/groovy/org/moqui/impl/entity/EntityConditionFactoryImpl.groovy index 281f164fe..b41c8605c 100644 --- a/framework/src/main/groovy/org/moqui/impl/entity/EntityConditionFactoryImpl.groovy +++ b/framework/src/main/groovy/org/moqui/impl/entity/EntityConditionFactoryImpl.groovy @@ -99,6 +99,12 @@ class EntityConditionFactoryImpl implements EntityConditionFactory { EntityCondition makeConditionToField(String fieldName, ComparisonOperator operator, String toFieldName) { return new FieldToFieldCondition(new ConditionField(fieldName), operator, new ConditionField(toFieldName)) } + @Override + EntityCondition makeConditionToField(String fieldName, ComparisonOperator operator, String toFieldName, Object value) { + // TODO: This needs some work + return null + // return new FieldToFieldCondition(new ConditionField(fieldName), operator, new ConditionField(toFieldName)) + } @Override EntityCondition makeCondition(List conditionList) { @@ -316,6 +322,9 @@ class EntityConditionFactoryImpl implements EntityConditionFactory { case "ENTCO_NOT_BETWEEN": return EntityCondition.NOT_BETWEEN case "ENTCO_LIKE": return EntityCondition.LIKE case "ENTCO_NOT_LIKE": return EntityCondition.NOT_LIKE + case "ENTCO_BEGINS_FIELD": return EntityCondition.BEGINS_FIELD + case "ENTCO_ENDS_FIELD": return EntityCondition.ENDS_FIELD + case "ENTCO_CONTAINS_FIELD": return EntityCondition.CONTAINS_FIELD case "ENTCO_IS_NULL": return EntityCondition.IS_NULL case "ENTCO_IS_NOT_NULL": return EntityCondition.IS_NOT_NULL default: return null @@ -361,8 +370,27 @@ class EntityConditionFactoryImpl implements EntityConditionFactory { if (efi.ecfi.resourceFacade.condition(ignore, null)) return null if (toFieldName != null && toFieldName.length() > 0) { - EntityCondition ec = makeConditionToField(fieldName, getComparisonOperator(operator), toFieldName) + EntityCondition ec = null; + ComparisonOperator compOp = getComparisonOperator(operator) + if (compOp == ComparisonOperator.BEGINS_FIELD || compOp == ComparisonOperator.ENDS_FIELD || compOp == ComparisonOperator.CONTAINS_FIELD) { + Object condValue + if (value != null && value.length() > 0) { + // NOTE: have to convert value (if needed) later on because we don't know which entity/field this is for, or change to pass in entity? + condValue = value + } else { + condValue = fromObj + } + logger.warn(value) + logger.warn(fromObj.toString()) + logger.warn(condValue.toString()) + + // TODO: This also needs some work! + ec = makeConditionWhere("'moc.elgoog.fdsa' LIKE prefix || '%'") + } else { + ec = makeConditionToField(fieldName, compOp, toFieldName) + } if (ignoreCase) ec.ignoreCase() + return ec } else { Object condValue @@ -493,6 +521,15 @@ class EntityConditionFactoryImpl implements EntityConditionFactory { "not-like":ComparisonOperator.NOT_LIKE, "NOT LIKE":ComparisonOperator.NOT_LIKE, + "begins-field":ComparisonOperator.BEGINS_FIELD, + "BEGINS FIELD":ComparisonOperator.BEGINS_FIELD, + + "ends-field":ComparisonOperator.ENDS_FIELD, + "ENDS FIELD":ComparisonOperator.ENDS_FIELD, + + "contains-field":ComparisonOperator.CONTAINS_FIELD, + "CONTAINS FIELD":ComparisonOperator.CONTAINS_FIELD, + "is-null":ComparisonOperator.IS_NULL, "IS NULL":ComparisonOperator.IS_NULL, diff --git a/framework/src/main/java/org/moqui/entity/EntityCondition.java b/framework/src/main/java/org/moqui/entity/EntityCondition.java index e3379e182..ef936ba87 100644 --- a/framework/src/main/java/org/moqui/entity/EntityCondition.java +++ b/framework/src/main/java/org/moqui/entity/EntityCondition.java @@ -37,6 +37,9 @@ public interface EntityCondition extends Externalizable { ComparisonOperator NOT_BETWEEN = ComparisonOperator.NOT_BETWEEN; ComparisonOperator LIKE = ComparisonOperator.LIKE; ComparisonOperator NOT_LIKE = ComparisonOperator.NOT_LIKE; + ComparisonOperator BEGINS_FIELD = ComparisonOperator.BEGINS_FIELD; + ComparisonOperator ENDS_FIELD = ComparisonOperator.ENDS_FIELD; + ComparisonOperator CONTAINS_FIELD = ComparisonOperator.CONTAINS_FIELD; ComparisonOperator IS_NULL = ComparisonOperator.IS_NULL; ComparisonOperator IS_NOT_NULL = ComparisonOperator.IS_NOT_NULL; @@ -45,6 +48,7 @@ public interface EntityCondition extends Externalizable { enum ComparisonOperator { EQUALS, NOT_EQUAL, LESS_THAN, GREATER_THAN, LESS_THAN_EQUAL_TO, GREATER_THAN_EQUAL_TO, + BEGINS_FIELD, ENDS_FIELD, CONTAINS_FIELD, IN, NOT_IN, BETWEEN, NOT_BETWEEN, LIKE, NOT_LIKE, IS_NULL, IS_NOT_NULL } enum JoinOperator { AND, OR } diff --git a/framework/src/main/java/org/moqui/entity/EntityConditionFactory.java b/framework/src/main/java/org/moqui/entity/EntityConditionFactory.java index bae6dd04a..5e66a2248 100644 --- a/framework/src/main/java/org/moqui/entity/EntityConditionFactory.java +++ b/framework/src/main/java/org/moqui/entity/EntityConditionFactory.java @@ -34,6 +34,7 @@ public interface EntityConditionFactory { EntityCondition makeCondition(String fieldName, EntityCondition.ComparisonOperator operator, Object value, boolean orNull); EntityCondition makeConditionToField(String fieldName, EntityCondition.ComparisonOperator operator, String toFieldName); + EntityCondition makeConditionToField(String fieldName, EntityCondition.ComparisonOperator operator, String toFieldName, Object value); /** Default to JoinOperator of AND */ EntityCondition makeCondition(List conditionList); diff --git a/framework/xsd/common-types-3.xsd b/framework/xsd/common-types-3.xsd index f6932bf3f..b92f3b03d 100644 --- a/framework/xsd/common-types-3.xsd +++ b/framework/xsd/common-types-3.xsd @@ -103,6 +103,9 @@ along with this software (see the LICENSE.md file). If not, see + + +