Skip to content

Commit 66db3aa

Browse files
committed
DG-1746 rename custom to user defined
1 parent b4d291f commit 66db3aa

File tree

7 files changed

+26
-19
lines changed

7 files changed

+26
-19
lines changed

common/src/main/java/org/apache/atlas/repository/Constants.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ public final class Constants {
156156
public static final String INPUT_PORT_PRODUCT_EDGE_LABEL = "__Asset.inputPortDataProducts";
157157
public static final String OUTPUT_PORT_PRODUCT_EDGE_LABEL = "__Asset.outputPortDataProducts";
158158

159-
public static final String CUSTOM_RELATIONSHIP_EDGE_LABEL = "__Referenceable.customRelationshipTo";
160-
public static final String CUSTOM_RELATIONSHIP_END_NAME_FROM = "customRelationshipFrom";
161-
public static final String CUSTOM_RELATIONSHIP_END_NAME_TO = "customRelationshipTo";
159+
public static final String UD_RELATIONSHIP_EDGE_LABEL = "__Referenceable.userDefRelationshipTo";
160+
public static final String UD_RELATIONSHIP_END_NAME_FROM = "userDefRelationshipFrom";
161+
public static final String UD_RELATIONSHIP_END_NAME_TO = "userDefRelationshipTo";
162162

163163
/**
164164
* SQL property keys.

intg/src/main/java/org/apache/atlas/AtlasConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public enum AtlasConfiguration {
115115

116116
ATLAS_MAINTENANCE_MODE("atlas.maintenance.mode", false),
117117

118-
ATLAS_CUSTOM_RELATIONSHIPS_MAX_COUNT("atlas.custom.relationships.max.count", 100);
118+
ATLAS_UD_RELATIONSHIPS_MAX_COUNT("atlas.ud.relationship.max.count", 100);
119119

120120

121121
private static final Configuration APPLICATION_PROPERTIES;

intg/src/main/java/org/apache/atlas/type/AtlasBuiltInTypes.java

+4
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,10 @@ public AtlasObjectId getNormalizedValue(Object obj) {
820820
private boolean isValidMap(Map map) {
821821
Object guid = map.get(AtlasObjectId.KEY_GUID);
822822

823+
if (map.containsKey(AtlasRelatedObjectId.KEY_RELATIONSHIP_ATTRIBUTES) && !map.containsKey(AtlasRelatedObjectId.KEY_RELATIONSHIP_TYPE)) {
824+
return false;
825+
}
826+
823827
if (guid != null && StringUtils.isNotEmpty(guid.toString())) {
824828
return true;
825829
} else {

repository/src/main/java/org/apache/atlas/repository/store/graph/v1/DeleteHandlerV1.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ private boolean isInternalType(final AtlasVertex instanceVertex) {
10611061
}
10621062

10631063
private boolean isCustomRelationship(final AtlasEdge edge) {
1064-
return edge.getLabel().equals(CUSTOM_RELATIONSHIP_EDGE_LABEL);
1064+
return edge.getLabel().equals(UD_RELATIONSHIP_EDGE_LABEL);
10651065
}
10661066

10671067
private void addToPropagatedClassificationNames(AtlasVertex entityVertex, String classificationName) {

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import org.apache.atlas.repository.graphdb.janus.JanusUtils;
4747
import org.apache.atlas.repository.store.graph.AtlasRelationshipStore;
4848
import org.apache.atlas.repository.store.graph.v1.DeleteHandlerDelegate;
49-
import org.apache.atlas.repository.store.graph.v1.SoftDeleteHandlerV1;
5049
import org.apache.atlas.type.AtlasEntityType;
5150
import org.apache.atlas.type.AtlasRelationshipType;
5251
import org.apache.atlas.type.AtlasStructType.AtlasAttribute;
@@ -100,7 +99,7 @@ public class AtlasRelationshipStoreV2 implements AtlasRelationshipStore {
10099
private static final String END_2_DOC_ID_KEY = "end2DocId";
101100
private static final String ES_DOC_ID_MAP_KEY = "esDocIdMap";
102101

103-
private static final String CUSTOM_RELATIONSHIP_TYPE_NAME = "CustomRelationship";
102+
private static final String UD_RELATIONSHIP_TYPE_NAME = "UserDefRelationship";
104103

105104
private static Set<String> EXCLUDE_MUTATION_REL_TYPE_NAMES = new HashSet<String>() {{
106105
add(REL_DOMAIN_TO_DOMAINS);
@@ -142,7 +141,7 @@ public AtlasRelationship create(AtlasRelationship relationship) throws AtlasBase
142141
AtlasVertex end1Vertex = getVertexFromEndPoint(relationship.getEnd1());
143142
AtlasVertex end2Vertex = getVertexFromEndPoint(relationship.getEnd2());
144143

145-
if (relationship.getTypeName().equals(CUSTOM_RELATIONSHIP_TYPE_NAME)) {
144+
if (relationship.getTypeName().equals(UD_RELATIONSHIP_TYPE_NAME)) {
146145
EntityGraphMapper.validateCustomRelationship(end1Vertex, end2Vertex);
147146
}
148147

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

+9-9
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public class EntityGraphMapper {
194194

195195
private static final int MAX_NUMBER_OF_RETRIES = AtlasConfiguration.MAX_NUMBER_OF_RETRIES.getInt();
196196
private static final int CHUNK_SIZE = AtlasConfiguration.TASKS_GRAPH_COMMIT_CHUNK_SIZE.getInt();
197-
private static final int CUSTOM_REL_THRESHOLD = AtlasConfiguration.ATLAS_CUSTOM_RELATIONSHIPS_MAX_COUNT.getInt();
197+
private static final int UD_REL_THRESHOLD = AtlasConfiguration.ATLAS_UD_RELATIONSHIPS_MAX_COUNT.getInt();
198198

199199
private final GraphHelper graphHelper;
200200
private final AtlasGraph graph;
@@ -2015,7 +2015,7 @@ public List mapArrayValue(AttributeMutationContext ctx, EntityMutationContext co
20152015
addInternalProductAttr(ctx, newElementsCreated, removedElements);
20162016
break;
20172017

2018-
case CUSTOM_RELATIONSHIP_EDGE_LABEL:
2018+
case UD_RELATIONSHIP_EDGE_LABEL:
20192019
validateCustomRelationship(ctx, newElementsCreated, false);
20202020
break;
20212021
}
@@ -2109,7 +2109,7 @@ public List appendArrayValue(AttributeMutationContext ctx, EntityMutationContext
21092109
addInternalProductAttr(ctx, newElementsCreated, null);
21102110
break;
21112111

2112-
case CUSTOM_RELATIONSHIP_EDGE_LABEL:
2112+
case UD_RELATIONSHIP_EDGE_LABEL:
21132113
validateCustomRelationship(ctx, newElementsCreated, true);
21142114
break;
21152115
}
@@ -2227,7 +2227,7 @@ public static void validateCustomRelationship(AttributeMutationContext ctx, List
22272227

22282228
if (isAppend) {
22292229
currentSize = ctx.getReferringVertex().getEdgesCount(isEdgeDirectionIn ? AtlasEdgeDirection.IN : AtlasEdgeDirection.OUT,
2230-
CUSTOM_RELATIONSHIP_EDGE_LABEL);
2230+
UD_RELATIONSHIP_EDGE_LABEL);
22312231
} else {
22322232
currentSize = newElements.size();
22332233
}
@@ -2253,23 +2253,23 @@ public static void validateCustomRelationship(AttributeMutationContext ctx, List
22532253
LOG.info("{}: {}", direction, "inVertex");
22542254
}
22552255

2256-
currentSize = targetVertex.getEdgesCount(direction, CUSTOM_RELATIONSHIP_EDGE_LABEL);
2256+
currentSize = targetVertex.getEdgesCount(direction, UD_RELATIONSHIP_EDGE_LABEL);
22572257
validateCustomRelationshipCount(currentSize, targetVertex);
22582258
}
22592259
}
22602260

22612261
public static void validateCustomRelationship(AtlasVertex end1Vertex, AtlasVertex end2Vertex) throws AtlasBaseException {
2262-
long currentSize = end1Vertex.getEdgesCount(AtlasEdgeDirection.OUT, CUSTOM_RELATIONSHIP_EDGE_LABEL) + 1;
2262+
long currentSize = end1Vertex.getEdgesCount(AtlasEdgeDirection.OUT, UD_RELATIONSHIP_EDGE_LABEL) + 1;
22632263
validateCustomRelationshipCount(currentSize, end1Vertex);
22642264

2265-
currentSize = end2Vertex.getEdgesCount(AtlasEdgeDirection.IN, CUSTOM_RELATIONSHIP_EDGE_LABEL) + 1;
2265+
currentSize = end2Vertex.getEdgesCount(AtlasEdgeDirection.IN, UD_RELATIONSHIP_EDGE_LABEL) + 1;
22662266
validateCustomRelationshipCount(currentSize, end2Vertex);
22672267
}
22682268

22692269
private static void validateCustomRelationshipCount(long size, AtlasVertex vertex) throws AtlasBaseException {
2270-
if (CUSTOM_REL_THRESHOLD < size) {
2270+
if (UD_REL_THRESHOLD < size) {
22712271
throw new AtlasBaseException(AtlasErrorCode.OPERATION_NOT_SUPPORTED,
2272-
"Custom relationships size is more than " + CUSTOM_REL_THRESHOLD + ", current is " + size + " for " + vertex.getProperty(NAME, String.class));
2272+
"Custom relationships size is more than " + UD_REL_THRESHOLD + ", current is " + size + " for " + vertex.getProperty(NAME, String.class));
22732273
}
22742274
}
22752275

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
import static org.apache.atlas.repository.graph.GraphHelper.*;
122122
import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.getIdFromVertex;
123123
import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.isReference;
124+
import static org.apache.atlas.repository.util.AtlasEntityUtils.mapOf;
124125
import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection;
125126
import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection.BOTH;
126127
import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection.IN;
@@ -1660,10 +1661,13 @@ private AtlasObjectId mapVertexToObjectId(AtlasVertex entityVertex, String edgeL
16601661
}
16611662

16621663
if (RequestContext.get().isRequestRelationshipAttrsForSearch()) {
1663-
boolean isRelationshipAttribute = typeRegistry.getRelationshipDefByName(GraphHelper.getTypeName(edge)) != null;
1664+
String relationshipTypeName = GraphHelper.getTypeName(edge);
1665+
boolean isRelationshipAttribute = typeRegistry.getRelationshipDefByName(relationshipTypeName) != null;
16641666
if (isRelationshipAttribute) {
16651667
AtlasRelationship relationship = mapEdgeToAtlasRelationship(edge);
1666-
ret.getAttributes().put("relationshipAttributes", relationship.getAttributes());
1668+
Map<String, Object> relationshipAttributes = mapOf("typeName", relationshipTypeName);
1669+
relationshipAttributes.put("attributes", relationship.getAttributes());
1670+
ret.getAttributes().put("relationshipAttributes", relationshipAttributes);
16671671
}
16681672
}
16691673
}

0 commit comments

Comments
 (0)