Skip to content

Commit

Permalink
#2378 add dme operation support
Browse files Browse the repository at this point in the history
  • Loading branch information
gavin2lee committed Jun 14, 2023
1 parent a87f4c9 commit 4f1da5d
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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<EntityQueryExprNodeInfo> exprNodeInfos = new ArrayList<>();

private String exprOperation;

private String rawExpr;

public List<EntityQueryExprNodeInfo> getExprNodeInfos() {
return exprNodeInfos;
}

public void setExprNodeInfos(List<EntityQueryExprNodeInfo> 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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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<EntityQueryExprNodeInfo> 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());

Expand Down Expand Up @@ -72,7 +86,9 @@ public List<EntityQueryExprNodeInfo> parse(String expr) {
parseEntityQueryNodeInfoDetails(singleNodeInfo, expr);
queryNodeInfos.add(singleNodeInfo);
}
return queryNodeInfos;

entityQueryExpr.setExprNodeInfos(queryNodeInfos);
return entityQueryExpr;
}

protected void parseEntityQueryNodeInfoDetails(EntityQueryExprNodeInfo nodeInfo, String entityQueryNodeExpr) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ private List<String> calculateDataModelExpressions(FlowNodeDefDto f, boolean nee

String trimmedExprPart = exprPart.trim();

//TODO:DMEOP
if (StringUtils.isNoneBlank(additionalFilterRule)) {
trimmedExprPart = trimmedExprPart + additionalFilterRule.trim();
}
Expand Down

0 comments on commit 4f1da5d

Please sign in to comment.