Skip to content

Commit 2576aa8

Browse files
authored
Merge pull request #35 from aliyun/feature/release-v1.1.7-workflow-preview3
release 1.1.7-workflow-preview3
2 parents 7eaf6f5 + c249684 commit 2576aa8

File tree

79 files changed

+3225
-1505
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+3225
-1505
lines changed

client/migrationx-common/pom.xml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<parent>
2323
<artifactId>migrationx</artifactId>
2424
<groupId>com.aliyun.dataworks</groupId>
25-
<version>1.1.7-1</version>
25+
<version>1.1.7-workflow-preview3</version>
2626
<relativePath>../pom.xml</relativePath>
2727
</parent>
2828

@@ -103,6 +103,19 @@
103103

104104
<build>
105105
<plugins>
106+
<plugin>
107+
<groupId>org.apache.maven.plugins</groupId>
108+
<artifactId>maven-source-plugin</artifactId>
109+
<version>3.0.1</version>
110+
<executions>
111+
<execution>
112+
<id>attach-sources</id>
113+
<goals>
114+
<goal>jar</goal>
115+
</goals>
116+
</execution>
117+
</executions>
118+
</plugin>
106119
<plugin>
107120
<groupId>org.apache.maven.plugins</groupId>
108121
<artifactId>maven-dependency-plugin</artifactId>

client/migrationx-domain/migrationx-domain-airflow/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<parent>
2121
<artifactId>migrationx-domain</artifactId>
2222
<groupId>com.aliyun.dataworks</groupId>
23-
<version>1.1.7-1</version>
23+
<version>1.1.7-workflow-preview3</version>
2424
<relativePath>../pom.xml</relativePath>
2525
</parent>
2626
<modelVersion>4.0.0</modelVersion>

client/migrationx-domain/migrationx-domain-aliyunemr/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<parent>
2121
<artifactId>migrationx-domain</artifactId>
2222
<groupId>com.aliyun.dataworks</groupId>
23-
<version>1.1.7-1</version>
23+
<version>1.1.7-workflow-preview3</version>
2424
<relativePath>../pom.xml</relativePath>
2525
</parent>
2626
<modelVersion>4.0.0</modelVersion>

client/migrationx-domain/migrationx-domain-azkaban/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<parent>
2121
<artifactId>migrationx-domain</artifactId>
2222
<groupId>com.aliyun.dataworks</groupId>
23-
<version>1.1.7-1</version>
23+
<version>1.1.7-workflow-preview3</version>
2424
<relativePath>../pom.xml</relativePath>
2525
</parent>
2626
<modelVersion>4.0.0</modelVersion>

client/migrationx-domain/migrationx-domain-caiyunjian/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<parent>
2121
<artifactId>migrationx-domain</artifactId>
2222
<groupId>com.aliyun.dataworks</groupId>
23-
<version>1.1.7-1</version>
23+
<version>1.1.7-workflow-preview3</version>
2424
<relativePath>../pom.xml</relativePath>
2525
</parent>
2626
<modelVersion>4.0.0</modelVersion>

client/migrationx-domain/migrationx-domain-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<parent>
2222
<groupId>com.aliyun.dataworks</groupId>
2323
<artifactId>migrationx-domain</artifactId>
24-
<version>1.1.7-1</version>
24+
<version>1.1.7-workflow-preview3</version>
2525
<relativePath>../pom.xml</relativePath>
2626
</parent>
2727

client/migrationx-domain/migrationx-domain-datago/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<parent>
2121
<artifactId>migrationx-domain</artifactId>
2222
<groupId>com.aliyun.dataworks</groupId>
23-
<version>1.1.7-1</version>
23+
<version>1.1.7-workflow-preview3</version>
2424
<relativePath>../pom.xml</relativePath>
2525
</parent>
2626
<modelVersion>4.0.0</modelVersion>

client/migrationx-domain/migrationx-domain-dataworks/pom.xml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<parent>
2121
<artifactId>migrationx-domain</artifactId>
2222
<groupId>com.aliyun.dataworks</groupId>
23-
<version>1.1.7-1</version>
23+
<version>1.1.7-workflow-preview3</version>
2424
<relativePath>../pom.xml</relativePath>
2525
</parent>
2626
<modelVersion>4.0.0</modelVersion>
@@ -64,12 +64,6 @@
6464
<groupId>org.springframework</groupId>
6565
<artifactId>spring-beans</artifactId>
6666
</dependency>
67-
<dependency>
68-
<groupId>org.codehaus.jackson</groupId>
69-
<artifactId>jackson-core-asl</artifactId>
70-
<version>1.9.13</version>
71-
<scope>compile</scope>
72-
</dependency>
7367
</dependencies>
7468
<build>
7569
<plugins>
@@ -79,6 +73,19 @@
7973
<skipAssembly>true</skipAssembly>
8074
</configuration>
8175
</plugin>
76+
<plugin>
77+
<groupId>org.apache.maven.plugins</groupId>
78+
<artifactId>maven-source-plugin</artifactId>
79+
<version>3.0.1</version>
80+
<executions>
81+
<execution>
82+
<id>attach-sources</id>
83+
<goals>
84+
<goal>jar</goal>
85+
</goals>
86+
</execution>
87+
</executions>
88+
</plugin>
8289
</plugins>
8390
</build>
8491
</project>

client/migrationx-domain/migrationx-domain-dataworks/src/main/java/com/aliyun/dataworks/migrationx/domain/dataworks/objects/entity/Node.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
@JsonTypeInfo(
4848
use = Id.MINIMAL_CLASS,
4949
property = "@class")
50-
public abstract class Node extends DmObject {
50+
public class Node extends DmObject {
5151
@JacksonXmlProperty(isAttribute = true, localName = "name")
5252
private String name;
5353

client/migrationx-domain/migrationx-domain-dataworks/src/main/java/com/aliyun/dataworks/migrationx/domain/dataworks/service/converter/DataWorksSpecNodeConverter.java

Lines changed: 93 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.aliyun.dataworks.migrationx.domain.dataworks.service.converter;
22

33
import java.nio.file.Paths;
4+
import java.util.List;
45
import java.util.Objects;
56
import java.util.Optional;
67
import java.util.stream.Collectors;
@@ -10,6 +11,7 @@
1011
import com.aliyun.dataworks.common.spec.domain.SpecRefEntity;
1112
import com.aliyun.dataworks.common.spec.domain.Specification;
1213
import com.aliyun.dataworks.common.spec.domain.dw.nodemodel.DataWorksNodeAdapter;
14+
import com.aliyun.dataworks.common.spec.domain.dw.nodemodel.DataWorksNodeAdapter.Context;
1315
import com.aliyun.dataworks.common.spec.domain.dw.nodemodel.DwNodeDependentTypeInfo;
1416
import com.aliyun.dataworks.common.spec.domain.dw.nodemodel.OutputContext;
1517
import com.aliyun.dataworks.common.spec.domain.dw.types.CodeProgramType;
@@ -45,6 +47,7 @@
4547
import lombok.extern.slf4j.Slf4j;
4648
import org.apache.commons.collections4.CollectionUtils;
4749
import org.apache.commons.collections4.ListUtils;
50+
import org.apache.commons.collections4.MapUtils;
4851
import org.apache.commons.lang3.StringUtils;
4952

5053
/**
@@ -99,6 +102,46 @@ public static FileDetail functionSpecToFileDetail(Specification<DataWorksWorkflo
99102
return functionSpecToFileDetail(spec, null);
100103
}
101104

105+
public static FileDetail componentSpecToFileDetail(Specification<DataWorksWorkflowSpec> spec) {
106+
return componentSpecToFileDetail(spec, null);
107+
}
108+
109+
private static FileDetail componentSpecToFileDetail(Specification<DataWorksWorkflowSpec> spec, String resourceId) {
110+
FileDetail fileDetail = new FileDetail();
111+
File file = componentSpecToFile(spec, resourceId);
112+
if (file == null) {
113+
log.error("get file from function spec is null");
114+
return null;
115+
}
116+
117+
fileDetail.setFile(file);
118+
fileDetail.setNodeCfg(initFileNodeCfgByFile(file));
119+
return fileDetail;
120+
}
121+
122+
private static File componentSpecToFile(Specification<DataWorksWorkflowSpec> spec, String functionId) {
123+
DataWorksWorkflowSpec dataWorksWorkflowSpec = spec.getSpec();
124+
if (spec.getSpec() == null) {
125+
log.warn("dataworks component spec is null");
126+
return null;
127+
}
128+
129+
return ListUtils.emptyIfNull(dataWorksWorkflowSpec.getComponents()).stream()
130+
.filter(x -> StringUtils.isBlank(functionId) || StringUtils.equals(x.getId(), functionId))
131+
.findFirst()
132+
.map(specCom -> {
133+
File fileCom = new File();
134+
fileCom.setFileName(specCom.getName());
135+
fileCom.setOwner(Optional.ofNullable(specCom.getMetadata()).map(m -> (String)m.get("owner")).orElse(null));
136+
fileCom.setFileTypeStr(Optional.ofNullable(specCom.getScript()).map(SpecScript::getRuntime).map(SpecScriptRuntime::getCommand)
137+
.orElse(null));
138+
fileCom.setFileType(getScriptCommandTypeId(specCom.getScript()));
139+
fileCom.setUseType(NodeUseType.COMPONENT.getValue());
140+
fileCom.setContent(Optional.ofNullable(specCom.getScript()).map(SpecScript::getContent).orElse(null));
141+
return fileCom;
142+
}).orElse(null);
143+
}
144+
102145
private static File functionSpecToFile(Specification<DataWorksWorkflowSpec> spec, String functionId) {
103146
DataWorksWorkflowSpec dataWorksWorkflowSpec = spec.getSpec();
104147
if (spec.getSpec() == null) {
@@ -154,20 +197,26 @@ private static Integer getScriptCommandTypeId(SpecScript script) {
154197
}
155198

156199
public static FileDetail nodeSpecToFileDetail(Specification<DataWorksWorkflowSpec> spec, String nodeId) {
200+
return nodeSpecToFileDetail(spec, nodeId, null);
201+
}
202+
203+
public static FileDetail nodeSpecToFileDetail(Specification<DataWorksWorkflowSpec> spec, String nodeId, String content) {
157204
FileDetail fileDetail = new FileDetail();
158-
fileDetail.setFile(nodeSpecToFile(spec, nodeId));
205+
fileDetail.setFile(nodeSpecToFile(spec, nodeId, content));
159206
fileDetail.setNodeCfg(nodeSpecToNodeCfg(spec, nodeId));
160207
return fileDetail;
161208
}
162209

163210
public static FileDetail nodeSpecToFileDetail(Specification<DataWorksWorkflowSpec> spec) {
164211
FileDetail fileDetail = new FileDetail();
165-
fileDetail.setFile(nodeSpecToFile(spec, null));
212+
String nodeId = Optional.ofNullable(MapUtils.emptyIfNull(spec.getMetadata()).get("uuid"))
213+
.map(String::valueOf).orElse(null);
214+
fileDetail.setFile(nodeSpecToFile(spec, nodeId));
166215
fileDetail.setNodeCfg(nodeSpecToNodeCfg(spec, null));
167216
return fileDetail;
168217
}
169218

170-
public static File nodeSpecToFile(Specification<DataWorksWorkflowSpec> spec, String nodeId) {
219+
public static File nodeSpecToFile(Specification<DataWorksWorkflowSpec> spec, String nodeId, String content) {
171220
DataWorksWorkflowSpec dataWorksWorkflowSpec = spec.getSpec();
172221
if (spec.getSpec() == null) {
173222
log.warn("dataworks workflow spec is null");
@@ -181,7 +230,8 @@ public static File nodeSpecToFile(Specification<DataWorksWorkflowSpec> spec, Str
181230
file.setCloudUuid(null);
182231
file.setCommitStatus(null);
183232
file.setConnName(Optional.ofNullable(specNode.getDatasource()).map(SpecDatasource::getName).orElse(null));
184-
file.setContent(Optional.ofNullable(specNode.getScript()).map(SpecScript::getContent).orElse(null));
233+
Optional.ofNullable(content).ifPresent(x -> Optional.ofNullable(specNode.getScript()).ifPresent(s -> s.setContent(x)));
234+
file.setContent(new DataWorksNodeAdapter(spec, specNode, Context.builder().deployToScheduler(true).build()).getCode());
185235
file.setCreateTime(null);
186236
file.setCreateUser(null);
187237
file.setCurrentVersion(null);
@@ -251,18 +301,47 @@ public static File nodeSpecToFile(Specification<DataWorksWorkflowSpec> spec, Str
251301
}).orElse(null);
252302
}
253303

304+
public static File nodeSpecToFile(Specification<DataWorksWorkflowSpec> spec, String nodeId) {
305+
return nodeSpecToFile(spec, nodeId, null);
306+
}
307+
254308
public static SpecNode getMatchSpecNode(DataWorksWorkflowSpec dataWorksWorkflowSpec, String nodeId) {
255-
for (SpecNode node : dataWorksWorkflowSpec.getNodes()) {
309+
for (SpecNode node : ListUtils.emptyIfNull(dataWorksWorkflowSpec.getNodes())) {
310+
// normal nodes
256311
if (StringUtils.isBlank(nodeId) || StringUtils.equalsIgnoreCase(node.getId(), nodeId)) {
257312
return node;
258313
}
314+
315+
// inner nodes of normal nodes
259316
for (SpecNode innerNode : node.getInnerNodes()) {
260317
if (StringUtils.isBlank(nodeId) || StringUtils.equalsIgnoreCase(innerNode.getId(), nodeId)) {
261318
return innerNode;
262319
}
263320
}
264321
}
265-
return null;
322+
323+
// workflow inner node
324+
SpecNode node = ListUtils.emptyIfNull(dataWorksWorkflowSpec.getWorkflows()).stream()
325+
.map(wf -> ListUtils.emptyIfNull(wf.getNodes()))
326+
.map(nodes -> nodes.stream().filter(n -> StringUtils.equalsIgnoreCase(nodeId, n.getId())).findAny().orElse(null))
327+
.filter(Objects::nonNull)
328+
.findAny()
329+
.orElse(null);
330+
if (node != null) {
331+
return node;
332+
}
333+
334+
// inner nodes of workflow inner node
335+
return ListUtils.emptyIfNull(dataWorksWorkflowSpec.getWorkflows()).stream()
336+
// workflow nodes
337+
.map(wf -> ListUtils.emptyIfNull(wf.getNodes()))
338+
.flatMap(List::stream)
339+
// inner nodes of workflow nodes
340+
.map(nodes -> ListUtils.emptyIfNull(nodes.getInnerNodes()))
341+
.map(nodes -> nodes.stream().filter(n -> StringUtils.equalsIgnoreCase(nodeId, n.getId())).findAny().orElse(null))
342+
.filter(Objects::nonNull)
343+
.findAny()
344+
.orElse(null);
266345
}
267346

268347
/**
@@ -283,7 +362,11 @@ public static FileNodeCfg nodeSpecToNodeCfg(Specification<DataWorksWorkflowSpec>
283362
FileNodeCfg nodeCfg = new FileNodeCfg();
284363
nodeCfg.setAppId(null);
285364
nodeCfg.setBaselineId(null);
286-
nodeCfg.setCreateTime(null);
365+
Optional.ofNullable(specNode.getMetadata())
366+
.map(x -> x.get("createTime"))
367+
.map(String::valueOf)
368+
.map(DateUtils::convertStringToDate)
369+
.ifPresent(nodeCfg::setCreateTime);
287370
nodeCfg.setCreateUser(null);
288371
nodeCfg.setCronExpress(Optional.ofNullable(specNode.getTrigger()).map(SpecTrigger::getCron).orElse(null));
289372
nodeCfg.setCycleType(CronExpressUtil.parseCronToCycleType(nodeCfg.getCronExpress()));
@@ -411,8 +494,9 @@ public static FileDetail snapshotContentToFileDetail(DataSnapshot snapshotDto) {
411494
.flatMap(snapshot -> Optional.ofNullable(DataSnapshotContent.of(snapshot.getContent()))
412495
.map(content -> {
413496
Specification<DataWorksWorkflowSpec> specification = SpecUtil.parseToDomain(content.getSpec());
414-
FileDetail fileDetail = nodeSpecToFileDetail(specification);
415-
Optional.ofNullable(fileDetail.getFile()).ifPresent(file -> file.setContent(content.getContent()));
497+
String nodeId = Optional.ofNullable(MapUtils.emptyIfNull(specification.getMetadata()).get("uuid"))
498+
.map(String::valueOf).orElse(snapshot.getEntityUuid());
499+
FileDetail fileDetail = nodeSpecToFileDetail(specification, nodeId, content.getContent());
416500
return fileDetail;
417501
}))
418502
.orElse(null);

0 commit comments

Comments
 (0)