Skip to content

Commit adc7824

Browse files
committed
fix bug #448
1 parent 9886177 commit adc7824

File tree

5 files changed

+199
-25
lines changed

5 files changed

+199
-25
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
*
3+
* * Copyright 2019 WeBank
4+
* *
5+
* * Licensed under the Apache License, Version 2.0 (the "License");
6+
* * you may not use this file except in compliance with the License.
7+
* * You may obtain a copy of the License at
8+
* *
9+
* * http://www.apache.org/licenses/LICENSE-2.0
10+
* *
11+
* * Unless required by applicable law or agreed to in writing, software
12+
* * distributed under the License is distributed on an "AS IS" BASIS,
13+
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* * See the License for the specific language governing permissions and
15+
* * limitations under the License.
16+
*
17+
*/
18+
19+
package com.webank.wedatasphere.dss.appconn.visualis.publish;
20+
21+
import com.google.common.collect.Maps;
22+
import com.webank.wedatasphere.dss.standard.app.development.ref.ExportRequestRef;
23+
import com.webank.wedatasphere.dss.standard.app.sso.Workspace;
24+
25+
import java.util.Map;
26+
27+
public class VisualisExportRequestRef implements ExportRequestRef {
28+
29+
Map<String, Object> parameters = Maps.newHashMap();
30+
Workspace workspace;
31+
32+
@Override
33+
public Object getParameter(String key) {
34+
return parameters.get(key);
35+
}
36+
37+
@Override
38+
public void setParameter(String key, Object value) {
39+
parameters.put(key, value);
40+
}
41+
42+
@Override
43+
public Map<String, Object> getParameters() {
44+
return parameters;
45+
}
46+
47+
@Override
48+
public String getName() {
49+
return parameters.get("name").toString();
50+
}
51+
52+
@Override
53+
public String getType() {
54+
return parameters.get("type").toString();
55+
}
56+
57+
@Override
58+
public Workspace getWorkspace() {
59+
return workspace;
60+
}
61+
62+
@Override
63+
public void setWorkspace(Workspace workspace) {
64+
this.workspace = workspace;
65+
}
66+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
*
3+
* * Copyright 2019 WeBank
4+
* *
5+
* * Licensed under the Apache License, Version 2.0 (the "License");
6+
* * you may not use this file except in compliance with the License.
7+
* * You may obtain a copy of the License at
8+
* *
9+
* * http://www.apache.org/licenses/LICENSE-2.0
10+
* *
11+
* * Unless required by applicable law or agreed to in writing, software
12+
* * distributed under the License is distributed on an "AS IS" BASIS,
13+
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* * See the License for the specific language governing permissions and
15+
* * limitations under the License.
16+
*
17+
*/
18+
19+
package com.webank.wedatasphere.dss.appconn.visualis.publish;
20+
21+
import com.google.common.collect.Maps;
22+
import com.webank.wedatasphere.dss.standard.app.development.ref.ImportRequestRef;
23+
import com.webank.wedatasphere.dss.standard.app.sso.Workspace;
24+
25+
import java.util.Map;
26+
27+
public class VisualisImportRequestRef implements ImportRequestRef {
28+
29+
Map<String, Object> parameters = Maps.newHashMap();
30+
Workspace workspace;
31+
32+
@Override
33+
public Object getParameter(String key) {
34+
return parameters.get(key);
35+
}
36+
37+
@Override
38+
public void setParameter(String key, Object value) {
39+
parameters.put(key, value);
40+
}
41+
42+
@Override
43+
public Map<String, Object> getParameters() {
44+
return parameters;
45+
}
46+
47+
@Override
48+
public String getName() {
49+
return parameters.get("name").toString();
50+
}
51+
52+
@Override
53+
public String getType() {
54+
return parameters.get("type").toString();
55+
}
56+
57+
@Override
58+
public boolean equals(Object ref) {
59+
return false;
60+
}
61+
62+
@Override
63+
public String toString() {
64+
return parameters.toString();
65+
}
66+
67+
@Override
68+
public Workspace getWorkspace() {
69+
return workspace;
70+
}
71+
72+
@Override
73+
public void setWorkspace(Workspace workspace) {
74+
this.workspace = workspace;
75+
}
76+
}

dss-appconn/appconns/dss-visualis-appconn/src/main/java/com/webank/wedatasphere/dss/appconn/visualis/publish/VisualisImportResponseRef.java

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,36 +23,58 @@
2323
import java.util.Map;
2424

2525
public class VisualisImportResponseRef extends DSSCommonResponseRef {
26-
2726
Map<String, Object> importedMap = Maps.newHashMap();
2827
Map<String, Object> newJobContent = Maps.newHashMap();
2928

3029
public VisualisImportResponseRef(Map<String, Object> jobContent, String responseBody, String nodeType, Object projectId) throws Exception {
3130
super(responseBody);
32-
3331
if("linkis.appconn.visualis.widget".equalsIgnoreCase(nodeType)){
3432
Map<String, Object> payload = (Map<String, Object>) jobContent.get("data");
3533
Long id = ((Double) Double.parseDouble(payload.get("widgetId").toString())).longValue();
36-
payload.put("widgetId", ((Double) ((Map<String, Integer>) ((Map<String, Object>) responseMap.get("data")).get("widget")).get(id.toString()).doubleValue()).toString());
34+
Map<String, Object> tempDataMap = (Map<String, Object>) responseMap.get("data");
35+
Map<String, Object> tempValueMap = (Map<String, Object>) tempDataMap.get("widget");
36+
payload.put("widgetId", getIdByMap(tempValueMap, id));
3737
} else if("linkis.appconn.visualis.display".equalsIgnoreCase(nodeType)){
3838
Map<String, Object> payload = (Map<String, Object>) jobContent.get("payload");
3939
Long id = ((Double) Double.parseDouble(payload.get("id").toString())).longValue();
4040
payload.put("projectId", projectId);
41-
payload.put("id", ((Double) ((Map<String, Integer>) ((Map<String, Object>) responseMap.get("data")).get("display")).get(id.toString()).doubleValue()).toString());
41+
Map<String, Object> tempDataMap = (Map<String, Object>) responseMap.get("data");
42+
Map<String, Object> tempValueMap = (Map<String, Object>) tempDataMap.get("display");
43+
payload.put("id", getIdByMap(tempValueMap, id));
4244
} else if("linkis.appconn.visualis.dashboard".equalsIgnoreCase(nodeType)){
4345
Map<String, Object> payload = (Map<String, Object>) jobContent.get("payload");
4446
Long id = ((Double) Double.parseDouble(payload.get("id").toString())).longValue();
4547
payload.put("projectId", projectId);
46-
payload.put("id", ((Double) ((Map<String, Integer>) ((Map<String, Object>) responseMap.get("data")).get("dashboardPortal")).get(id.toString()).doubleValue()).toString());
48+
Map<String, Object> tempDataMap = (Map<String, Object>) responseMap.get("data");
49+
Map<String, Object> tempValueMap = (Map<String, Object>) tempDataMap.get("dashboardPortal");
50+
payload.put("id", getIdByMap(tempValueMap, id));
4751
} else {
4852
throw new ExternalOperationFailedException(90177, "Unknown task type " + nodeType, null);
4953
}
5054
this.newJobContent = jobContent;
5155
}
5256

57+
/**
58+
* 获取对应的Id
59+
* @param tempValueMap
60+
* @param id
61+
* @return
62+
*/
63+
public String getIdByMap(Map<String, Object> tempValueMap, Long id) {
64+
Object tempObjectVal = tempValueMap.get(id.toString());
65+
if (tempObjectVal instanceof Double) {
66+
Double t = ((Double) tempObjectVal).doubleValue();
67+
return t.toString();
68+
} else if (tempObjectVal instanceof Integer) {
69+
Integer t = (Integer) tempObjectVal;
70+
return t.toString();
71+
} else {
72+
return null;
73+
}
74+
}
75+
5376
@Override
5477
public Map<String, Object> toMap() {
5578
return newJobContent;
5679
}
57-
5880
}

dss-commons/dss-contextservice/src/main/java/com/webank/wedatasphere/dss/contextservice/service/impl/ContextServiceImpl.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ public void checkAndSaveContext(String jsonFlow,String parentFlowID) throws DSSE
152152
workTypes.add(WorkType.PROJECT);
153153
workTypes.add(WorkType.FLOW);
154154
csWorkService.initContextServiceInfo(contextIDStr, workTypes);
155-
156155
// ②解析和保存新的 UDF、Resource、Variable
157156
// 保存Workspace和Project的资源参数等
158157
// if (null != project.getProjectResources() && project.getProjectResources().size() > 0) {
@@ -175,18 +174,21 @@ public void checkAndSaveContext(String jsonFlow,String parentFlowID) throws DSSE
175174
JsonArray nodes = flowObject.get(DSSCommonUtils.FLOW_NODE_NAME).getAsJsonArray();
176175
for (JsonElement node : nodes) {
177176
JsonObject json = node.getAsJsonObject();
177+
String nodeName =json.get(DSSCommonUtils.NODE_NAME_NAME).getAsString();
178+
initContextNodeVarInfo(contextIDStr,nodeName,contextClient);
178179
if (json.has(DSSCommonUtils.NODE_RESOURCE_NAME)) {
179180
JsonArray nodeRes = json.get(DSSCommonUtils.NODE_RESOURCE_NAME).getAsJsonArray();
180181
saveContextResource(contextIDStr, nodeRes, contextClient,
181182
CSCommonUtils.NODE_PREFIX, json.get(DSSCommonUtils.NODE_NAME_NAME).getAsString());
182183
}
183184
if (json.has(DSSCommonUtils.NODE_PROP_NAME)) {
184185
JsonObject nodePropObj = json.get(DSSCommonUtils.NODE_PROP_NAME).getAsJsonObject();
185-
if (nodePropObj.has(DSSCommonUtils.NODE_PROP_VARIABLE_NAME)) {
186-
JsonElement nodeVariables = nodePropObj.get(DSSCommonUtils.NODE_PROP_VARIABLE_NAME);
187-
saveContextVariable(contextIDStr, nodeVariables, contextClient,
188-
CSCommonUtils.NODE_PREFIX, json.get(DSSCommonUtils.NODE_NAME_NAME).getAsString());
189-
}
186+
//节点的CS变量先不做存储,解决脚本节点执行变量没有及时清理问题
187+
// if (nodePropObj.has(DSSCommonUtils.NODE_PROP_VARIABLE_NAME)) {
188+
// JsonElement nodeVariables = nodePropObj.get(DSSCommonUtils.NODE_PROP_VARIABLE_NAME);
189+
// saveContextVariable(contextIDStr, nodeVariables, contextClient,
190+
// CSCommonUtils.NODE_PREFIX, json.get(DSSCommonUtils.NODE_NAME_NAME).getAsString());
191+
// }
190192
}
191193
}
192194
}
@@ -199,6 +201,15 @@ public void checkAndSaveContext(String jsonFlow,String parentFlowID) throws DSSE
199201
}
200202
}
201203

204+
private void initContextNodeVarInfo(String contextIDStr,String nodeName,ContextClient contextClient){
205+
try {
206+
ContextID contextID = SerializeHelper.deserializeContextID(contextIDStr);
207+
contextClient.removeAllValueByKeyPrefixAndContextType(contextID, ContextType.Variable, CSCommonUtils.NODE_PREFIX + nodeName);
208+
} catch (ErrorException e) {
209+
logger.error("CheckAndSaveContext error. ContextID : {}, nodeName : {}, e : ", contextIDStr,nodeName, e);
210+
}
211+
}
212+
202213
@Override
203214
public String checkAndInitContext(String jsonFlow, String parentFlowId, String workspace, String projectName, String flowName, String flowVersion, String user) throws DSSErrorException {
204215
if (StringUtils.isBlank(jsonFlow) ) {
@@ -258,7 +269,7 @@ private void saveContextVariableKeyValue(String contextIDStr, ContextClient cont
258269
contextKeyPrefix = uniKeyPrefix;
259270
break;
260271
case CSCommonUtils.NODE_PREFIX:
261-
contextKeyPrefix = uniKeyPrefix + nodeName + "." + CSCommonUtils.RESOURCE_PREFIX;
272+
contextKeyPrefix = uniKeyPrefix + nodeName + "." + CSCommonUtils.VARIABLE_PREFIX;
262273
break;
263274
default:
264275
logger.error("Invalid contextKeyPrefix : {}", uniKeyPrefix);
@@ -269,7 +280,7 @@ private void saveContextVariableKeyValue(String contextIDStr, ContextClient cont
269280
linkisVariable.setValue(entry.getValue().getAsString());
270281
ContextKey contextKey = new CommonContextKey();
271282
contextKey.setKey(contextKeyPrefix + linkisVariable.getKey());
272-
contextKey.setContextType(ContextType.OBJECT);
283+
contextKey.setContextType(ContextType.Variable);
273284
contextKey.setContextScope(ContextScope.PUBLIC);
274285
ContextValue contextValue = new CommonContextValue();
275286
contextValue.setValue(linkisVariable);
@@ -406,7 +417,4 @@ private void saveFlowInfo(String contextIDStr, String parentFlowID, String flowJ
406417
logger.error("Set ContextKeyValue error. contextIDStr ");
407418
}
408419
}
409-
410-
411-
412-
}
420+
}

dss-orchestrator/orchestrators/dss-workflow/dss-workflow-server/src/main/java/com/webank/wedatasphere/dss/workflow/restful/NodeRestfulApi.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,14 +233,16 @@ public Message deleteExternalNode(@Context HttpServletRequest req, @RequestBody
233233
Long projectID = updateExternalNodeRequest.getProjectID();
234234
String nodeType = updateExternalNodeRequest.getNodeType();
235235
Map<String, Object> params = updateExternalNodeRequest.getParams();
236-
logger.info("DeletepwdExternalNode request params is " + params + ",nodeType:" + nodeType);
237236
CommonAppConnNode node = new CommonAppConnNode();
238-
node.setProjectId(projectID);
239-
node.setNodeType(nodeType);
240-
String label = updateExternalNodeRequest.getLabels().getRoute();
241-
params.put(DSSCommonUtils.DSS_LABELS_KEY, label);
242-
params.put("workspace", workspace);
243-
functionInvoker.nodeServiceFunction(userName, params, node, FunctionPool.deleteNode);
237+
if(params!=null){
238+
logger.info("DeletepwdExternalNode request params is " + params + ",nodeType:" + nodeType);
239+
node.setProjectId(projectID);
240+
node.setNodeType(nodeType);
241+
String label = updateExternalNodeRequest.getLabels().getRoute();
242+
params.put(DSSCommonUtils.DSS_LABELS_KEY, label);
243+
params.put("workspace", workspace);
244+
functionInvoker.nodeServiceFunction(userName, params, node, FunctionPool.deleteNode);
245+
}
244246
return Message.ok().data("result", node.getJobContent());
245247
}
246248

0 commit comments

Comments
 (0)