diff --git a/platform-core/src/main/java/com/webank/wecube/platform/core/service/dme/EntityQueryExpr.java b/platform-core/src/main/java/com/webank/wecube/platform/core/service/dme/EntityQueryExpr.java new file mode 100644 index 0000000000..056ca339f8 --- /dev/null +++ b/platform-core/src/main/java/com/webank/wecube/platform/core/service/dme/EntityQueryExpr.java @@ -0,0 +1,48 @@ +package com.webank.wecube.platform.core.service.dme; + +import java.util.ArrayList; +import java.util.List; + +public class EntityQueryExpr { + + private List exprNodeInfos = new ArrayList<>(); + + private String exprOperation; + + private String rawExpr; + + public List getExprNodeInfos() { + return exprNodeInfos; + } + + public void setExprNodeInfos(List exprNodeInfos) { + this.exprNodeInfos = exprNodeInfos; + } + + public String getExprOperation() { + return exprOperation; + } + + public void setExprOperation(String exprOperation) { + this.exprOperation = exprOperation; + } + + public String getRawExpr() { + return rawExpr; + } + + public void setRawExpr(String rawExpr) { + this.rawExpr = rawExpr; + } + + public EntityQueryExpr addExprNode(EntityQueryExprNodeInfo exprNodeInfo) { + if(exprNodeInfo == null) { + return this; + } + + exprNodeInfos.add(exprNodeInfo); + + return this; + } + +} diff --git a/platform-core/src/main/java/com/webank/wecube/platform/core/service/dme/EntityQueryExpressionParser.java b/platform-core/src/main/java/com/webank/wecube/platform/core/service/dme/EntityQueryExpressionParser.java index 0c7bc3d412..ee1bb388f3 100644 --- a/platform-core/src/main/java/com/webank/wecube/platform/core/service/dme/EntityQueryExpressionParser.java +++ b/platform-core/src/main/java/com/webank/wecube/platform/core/service/dme/EntityQueryExpressionParser.java @@ -16,13 +16,27 @@ public class EntityQueryExpressionParser { public static final String PKG_DELIMITER = ":"; public static final String REG_ENTITY_ID = "@@\\w+@@"; + public static final String DME_OPERATION_DELIMITER = "#DMEOP#"; private Pattern entityIdPattern = Pattern.compile(REG_ENTITY_ID); - public List parse(String expr) { + public EntityQueryExpr parse(String rawExpr) { - if(StringUtils.isBlank(expr)) { + if(StringUtils.isBlank(rawExpr)) { throw new IllegalArgumentException("Expression to parse cannot be blank."); } + + String[] rawExprParts = rawExpr.trim().split(DME_OPERATION_DELIMITER); + + EntityQueryExpr entityQueryExpr = new EntityQueryExpr(); + entityQueryExpr.setRawExpr(rawExpr); + + String expr = null; + if(rawExprParts.length >= 2) { + expr = rawExprParts[0]; + entityQueryExpr.setExprOperation(rawExprParts[1]); + }else { + expr = rawExpr; + } String exprOpReg = String.format("[%s%s]", EntityLinkType.REF_TO.symbol(), EntityLinkType.REF_BY.symbol()); @@ -72,7 +86,9 @@ public List parse(String expr) { parseEntityQueryNodeInfoDetails(singleNodeInfo, expr); queryNodeInfos.add(singleNodeInfo); } - return queryNodeInfos; + + entityQueryExpr.setExprNodeInfos(queryNodeInfos); + return entityQueryExpr; } protected void parseEntityQueryNodeInfoDetails(EntityQueryExprNodeInfo nodeInfo, String entityQueryNodeExpr) { diff --git a/platform-core/src/main/java/com/webank/wecube/platform/core/service/workflow/WorkflowPublicAccessService.java b/platform-core/src/main/java/com/webank/wecube/platform/core/service/workflow/WorkflowPublicAccessService.java index f373b1ad70..3572c0ba2e 100644 --- a/platform-core/src/main/java/com/webank/wecube/platform/core/service/workflow/WorkflowPublicAccessService.java +++ b/platform-core/src/main/java/com/webank/wecube/platform/core/service/workflow/WorkflowPublicAccessService.java @@ -508,6 +508,7 @@ private List calculateDataModelExpressions(FlowNodeDefDto f, boolean nee String trimmedExprPart = exprPart.trim(); + //TODO:DMEOP if (StringUtils.isNoneBlank(additionalFilterRule)) { trimmedExprPart = trimmedExprPart + additionalFilterRule.trim(); }