-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature][scaleph-engine-seatunnel] replace job graph by scaleph-dag …
…module (#678) * feature: replace dag * feature: replace dag attrs * feature: replace dag * feature: replace dag * fix: npe --------- Co-authored-by: wangqi <wangqi@xinxuan.net>
- Loading branch information
Showing
18 changed files
with
355 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...src/main/java/cn/sliew/scaleph/engine/seatunnel/service/convert/WsDiJobAttrVOConvert.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package cn.sliew.scaleph.engine.seatunnel.service.convert; | ||
|
||
import cn.sliew.milky.common.util.JacksonUtil; | ||
import cn.sliew.scaleph.common.convert.BaseConvert; | ||
import cn.sliew.scaleph.common.dict.job.JobAttrType; | ||
import cn.sliew.scaleph.common.util.PropertyUtil; | ||
import cn.sliew.scaleph.engine.seatunnel.service.vo.DiJobAttrVO; | ||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import org.mapstruct.Mapper; | ||
import org.mapstruct.ReportingPolicy; | ||
import org.mapstruct.factory.Mappers; | ||
|
||
import java.util.Map; | ||
|
||
@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
public interface WsDiJobAttrVOConvert extends BaseConvert<JsonNode, DiJobAttrVO> { | ||
WsDiJobAttrVOConvert INSTANCE = Mappers.getMapper(WsDiJobAttrVOConvert.class); | ||
|
||
@Override | ||
default JsonNode toDo(DiJobAttrVO dto) { | ||
ObjectNode objectNode = JacksonUtil.createObjectNode(); | ||
objectNode.putPOJO(JobAttrType.VARIABLE.getValue(), PropertyUtil.formatPropFromStr(dto.getJobAttr())); | ||
objectNode.putPOJO(JobAttrType.ENV.getValue(), PropertyUtil.formatPropFromStr(dto.getJobProp())); | ||
objectNode.putPOJO(JobAttrType.PROPERTIES.getValue(), PropertyUtil.formatPropFromStr(dto.getEngineProp())); | ||
return objectNode; | ||
} | ||
|
||
@Override | ||
default DiJobAttrVO toDto(JsonNode entity) { | ||
DiJobAttrVO vo = new DiJobAttrVO(); | ||
if (entity == null) { | ||
return vo; | ||
} | ||
ObjectNode dagAttrs = (ObjectNode) entity; | ||
Map<String, String> variable = JacksonUtil.toObject(dagAttrs.get(JobAttrType.VARIABLE.getValue()), new TypeReference<Map<String, String>>() {}); | ||
Map<String, String> env = JacksonUtil.toObject(dagAttrs.get(JobAttrType.ENV.getValue()), new TypeReference<Map<String, String>>() {}); | ||
Map<String, String> properties = JacksonUtil.toObject(dagAttrs.get(JobAttrType.PROPERTIES.getValue()), new TypeReference<Map<String, String>>() {}); | ||
vo.setJobAttr(PropertyUtil.mapToFormatProp(variable)); | ||
vo.setJobProp(PropertyUtil.mapToFormatProp(env)); | ||
vo.setEngineProp(PropertyUtil.mapToFormatProp(properties)); | ||
return vo; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
.../src/main/java/cn/sliew/scaleph/engine/seatunnel/service/convert/WsDiJobLinkConvert2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package cn.sliew.scaleph.engine.seatunnel.service.convert; | ||
|
||
import cn.sliew.scaleph.common.convert.BaseConvert; | ||
import cn.sliew.scaleph.dag.service.dto.DagLinkDTO; | ||
import cn.sliew.scaleph.engine.seatunnel.service.dto.WsDiJobLinkDTO; | ||
import org.mapstruct.Mapper; | ||
import org.mapstruct.ReportingPolicy; | ||
import org.mapstruct.factory.Mappers; | ||
import org.springframework.beans.BeanUtils; | ||
|
||
@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
public interface WsDiJobLinkConvert2 extends BaseConvert<DagLinkDTO, WsDiJobLinkDTO> { | ||
WsDiJobLinkConvert2 INSTANCE = Mappers.getMapper(WsDiJobLinkConvert2.class); | ||
|
||
@Override | ||
default DagLinkDTO toDo(WsDiJobLinkDTO dto) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
default WsDiJobLinkDTO toDto(DagLinkDTO entity) { | ||
WsDiJobLinkDTO dto = new WsDiJobLinkDTO(); | ||
BeanUtils.copyProperties(entity, dto); | ||
dto.setLinkCode(entity.getLinkId()); | ||
dto.setFromStepCode(entity.getFromStepId()); | ||
dto.setToStepCode(entity.getToStepId()); | ||
return dto; | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
.../src/main/java/cn/sliew/scaleph/engine/seatunnel/service/convert/WsDiJobStepConvert2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package cn.sliew.scaleph.engine.seatunnel.service.convert; | ||
|
||
import cn.sliew.milky.common.util.JacksonUtil; | ||
import cn.sliew.scaleph.common.convert.BaseConvert; | ||
import cn.sliew.scaleph.common.dict.seatunnel.SeaTunnelPluginName; | ||
import cn.sliew.scaleph.common.dict.seatunnel.SeaTunnelPluginType; | ||
import cn.sliew.scaleph.dag.service.dto.DagStepDTO; | ||
import cn.sliew.scaleph.engine.seatunnel.service.dto.WsDiJobStepDTO; | ||
import cn.sliew.scaleph.system.service.convert.DictVoConvert; | ||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import org.mapstruct.Mapper; | ||
import org.mapstruct.ReportingPolicy; | ||
import org.mapstruct.factory.Mappers; | ||
import org.springframework.beans.BeanUtils; | ||
|
||
import java.util.Map; | ||
|
||
@Mapper(uses = {DictVoConvert.class}, unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
public interface WsDiJobStepConvert2 extends BaseConvert<DagStepDTO, WsDiJobStepDTO> { | ||
WsDiJobStepConvert2 INSTANCE = Mappers.getMapper(WsDiJobStepConvert2.class); | ||
|
||
@Override | ||
default DagStepDTO toDo(WsDiJobStepDTO dto) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
default WsDiJobStepDTO toDto(DagStepDTO entity) { | ||
WsDiJobStepDTO dto = new WsDiJobStepDTO(); | ||
BeanUtils.copyProperties(entity, dto); | ||
dto.setStepCode(entity.getStepId()); | ||
dto.setStepTitle(entity.getStepName()); | ||
dto.setPositionX(entity.getPositionX()); | ||
dto.setPositionY(entity.getPositionY()); | ||
Map<String, Object> stepAttrs = JacksonUtil.toObject(entity.getStepAttrs(), new TypeReference<Map<String, Object>>() {}); | ||
dto.setStepAttrs(stepAttrs); | ||
dto.setStepType(SeaTunnelPluginType.of(stepAttrs.get("type").toString())); | ||
dto.setStepName(SeaTunnelPluginName.of(stepAttrs.get("name").toString())); | ||
return dto; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.