Skip to content

Commit 5ebe0c3

Browse files
Merge pull request #5490 from atlanhq/mesh-645-repair
MESH-645 : Repair API for daapOutputPortGuids
2 parents 1e46b56 + 3a75a92 commit 5ebe0c3

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

repository/src/main/java/org/apache/atlas/repository/store/graph/v2/repair/RemoveInvalidGuidsRepairStrategy.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.apache.atlas.AtlasErrorCode;
44
import org.apache.atlas.exception.AtlasBaseException;
5+
import org.apache.atlas.repository.graphdb.AtlasGraph;
56
import org.apache.atlas.repository.graphdb.AtlasVertex;
67
import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2;
78
import org.apache.atlas.repository.store.graph.v2.EntityGraphRetriever;
@@ -22,11 +23,14 @@ public class RemoveInvalidGuidsRepairStrategy implements AtlasRepairAttributeStr
2223

2324
private final TransactionInterceptHelper transactionInterceptHelper;
2425

26+
2527
private static final String REPAIR_TYPE = "REMOVE_INVALID_OUTPUT_PORT_GUIDS";
28+
private AtlasGraph graph;
2629

27-
public RemoveInvalidGuidsRepairStrategy(EntityGraphRetriever entityRetriever, TransactionInterceptHelper transactionInterceptHelper) {
30+
public RemoveInvalidGuidsRepairStrategy(EntityGraphRetriever entityRetriever, TransactionInterceptHelper transactionInterceptHelper, AtlasGraph graph) {
2831
this.entityRetriever = entityRetriever;
2932
this.transactionInterceptHelper = transactionInterceptHelper;
33+
this.graph = graph;
3034
}
3135

3236
@Override
@@ -108,7 +112,7 @@ private boolean repairAttr(AtlasVertex vertex) throws AtlasBaseException {
108112
List<String> invalidGuids = new ArrayList<>();
109113

110114
for (String guid : outputPortGuids) {
111-
AtlasVertex portVertex = entityRetriever.getEntityVertex(guid);
115+
AtlasVertex portVertex = AtlasGraphUtilsV2.findByGuid(this.graph, guid);
112116
if (portVertex != null) {
113117
validGuids.add(guid);
114118
} else {

repository/src/main/java/org/apache/atlas/repository/store/graph/v2/repair/RepairAttributeFactory.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.apache.atlas.exception.AtlasBaseException;
44
import org.apache.atlas.AtlasErrorCode;
5+
import org.apache.atlas.repository.graphdb.AtlasGraph;
56
import org.apache.atlas.repository.store.graph.v2.EntityGraphRetriever;
67
import org.apache.atlas.repository.store.graph.v2.TransactionInterceptHelper;
78
import org.springframework.stereotype.Component;
@@ -14,18 +15,20 @@ public class RepairAttributeFactory {
1415

1516
private final EntityGraphRetriever entityRetriever;
1617
private final TransactionInterceptHelper transactionInterceptHelper;
18+
private final AtlasGraph graph;
1719

1820
@Inject
1921
public RepairAttributeFactory(EntityGraphRetriever entityRetriever,
20-
TransactionInterceptHelper transactionInterceptHelper) {
22+
TransactionInterceptHelper transactionInterceptHelper, AtlasGraph graph) {
2123
this.entityRetriever = entityRetriever;
2224
this.transactionInterceptHelper = transactionInterceptHelper;
25+
this.graph = graph;
2326
}
2427

2528
public AtlasRepairAttributeStrategy getStrategy(String repairType, Set<String> entityGuids) throws AtlasBaseException {
2629
switch (repairType) {
2730
case "REMOVE_INVALID_OUTPUT_PORT_GUIDS":
28-
return new RemoveInvalidGuidsRepairStrategy(entityRetriever, transactionInterceptHelper);
31+
return new RemoveInvalidGuidsRepairStrategy(entityRetriever, transactionInterceptHelper, graph);
2932
default:
3033
throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST,
3134
"Unsupported repair type: " + repairType + ". Supported types: [REMOVE_INVALID_OUTPUT_PORT_GUIDS]");

0 commit comments

Comments
 (0)