Commit 7ebb2013 by Suma Shivaprasad

ATLAS-463 Disconnect inverse references ( dkantor via sumasai)

parent a77d1ab5
...@@ -10,6 +10,7 @@ ATLAS-409 Atlas will not import avro tables with schema read from a file (dosset ...@@ -10,6 +10,7 @@ ATLAS-409 Atlas will not import avro tables with schema read from a file (dosset
ATLAS-379 Create sqoop and falcon metadata addons (venkatnrangan,bvellanki,sowmyaramesh via shwethags) ATLAS-379 Create sqoop and falcon metadata addons (venkatnrangan,bvellanki,sowmyaramesh via shwethags)
ALL CHANGES: ALL CHANGES:
ATLAS-463 Disconnect inverse references ( dkantor via sumasai)
ATLAS-479 Add description for different types during create time (guptaneeru via shwethags) ATLAS-479 Add description for different types during create time (guptaneeru via shwethags)
ATLAS-508 Apache nightly build failure - UnsupportedOperationException: Not a single key: __traitNames (shwethags) ATLAS-508 Apache nightly build failure - UnsupportedOperationException: Not a single key: __traitNames (shwethags)
ATLAS-422 JavaDoc NotificationConsumer and NotificationInterface.(tbeerbower via sumasai) ATLAS-422 JavaDoc NotificationConsumer and NotificationInterface.(tbeerbower via sumasai)
......
/**
* 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 org.apache.atlas.repository.graph;
/**
* Represents an edge label used in Atlas.
* The format of an Atlas edge label is EDGE_LABEL_PREFIX<<typeName>>.<<attributeName>>[.mapKey]
*
*/
public class AtlasEdgeLabel {
private final String typeName_;
private final String attributeName_;
private final String mapKey_;
private final String edgeLabel_;
private final String qualifiedMapKey_;
private final String qualifiedAttributeName_;
public AtlasEdgeLabel(String edgeLabel) {
if (!edgeLabel.startsWith(GraphHelper.EDGE_LABEL_PREFIX)) {
throw new IllegalArgumentException("Invalid edge label " + edgeLabel + ": missing required prefix " + GraphHelper.EDGE_LABEL_PREFIX);
}
String labelWithoutPrefix = edgeLabel.substring(GraphHelper.EDGE_LABEL_PREFIX.length());
String[] fields = labelWithoutPrefix.split("\\.", 3);
if (fields.length < 2 || fields.length > 3) {
throw new IllegalArgumentException("Invalid edge label " + edgeLabel +
": expected 2 or 3 label components but found " + fields.length);
}
typeName_ = fields[0];
attributeName_ = fields[1];
if (fields.length == 3) {
mapKey_ = fields[2];
qualifiedMapKey_ = labelWithoutPrefix;
qualifiedAttributeName_ = typeName_ + '.' + attributeName_;
}
else {
mapKey_ = null;
qualifiedMapKey_ = null;
qualifiedAttributeName_ = labelWithoutPrefix;
}
edgeLabel_ = edgeLabel;
}
public String getTypeName() {
return typeName_;
}
public String getAttributeName() {
return attributeName_;
}
public String getMapKey() {
return mapKey_;
}
public String getEdgeLabel() {
return edgeLabel_;
}
public String getQualifiedMapKey() {
return qualifiedMapKey_;
}
public String getQualifiedAttributeName() {
return qualifiedAttributeName_;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append('(').append("typeName: ").append(typeName_);
sb.append(", attributeName: ").append(attributeName_);
if (mapKey_ != null) {
sb.append(", mapKey: ").append(mapKey_);
sb.append(", qualifiedMapKey: ").append(qualifiedMapKey_);
}
sb.append(", edgeLabel: ").append(edgeLabel_).append(')');
return sb.toString();
}
}
\ No newline at end of file
...@@ -170,7 +170,7 @@ public final class TestUtils { ...@@ -170,7 +170,7 @@ public final class TestUtils {
max.set("mentor", julius); max.set("mentor", julius);
john.set("manager", jane); john.set("manager", jane);
john.set("mentor", max);
hrDept.set("employees", ImmutableList.of(john, jane, julius, max)); hrDept.set("employees", ImmutableList.of(john, jane, julius, max));
jane.set("subordinates", ImmutableList.of(john, max)); jane.set("subordinates", ImmutableList.of(john, max));
......
...@@ -534,7 +534,6 @@ public class GraphBackedMetadataRepositoryTest { ...@@ -534,7 +534,6 @@ public class GraphBackedMetadataRepositoryTest {
Assert.assertTrue(creationTimestamp < modificationTimestampPostUpdate); Assert.assertTrue(creationTimestamp < modificationTimestampPostUpdate);
// Update max's mentor reference to jane. // Update max's mentor reference to jane.
instance = personType.createInstance(max.getId());
instance.set("mentor", janeGuid); instance.set("mentor", janeGuid);
repositoryService.updatePartial(instance); repositoryService.updatePartial(instance);
...@@ -550,6 +549,30 @@ public class GraphBackedMetadataRepositoryTest { ...@@ -550,6 +549,30 @@ public class GraphBackedMetadataRepositoryTest {
Long modificationTimestampPost2ndUpdate = vertex.getProperty(Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY); Long modificationTimestampPost2ndUpdate = vertex.getProperty(Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY);
Assert.assertNotNull(modificationTimestampPost2ndUpdate); Assert.assertNotNull(modificationTimestampPost2ndUpdate);
Assert.assertTrue(modificationTimestampPostUpdate < modificationTimestampPost2ndUpdate); Assert.assertTrue(modificationTimestampPostUpdate < modificationTimestampPost2ndUpdate);
ITypedReferenceableInstance julius = repositoryService.getEntityDefinition("Person", "name", "Julius");
Id juliusGuid = julius.getId();
instance = personType.createInstance(max.getId());
instance.set("manager", juliusGuid);
repositoryService.updatePartial(instance);
// Verify the update was applied correctly - julius should now be max's manager.
max = repositoryService.getEntityDefinition(maxGuid);
object = max.get("manager");
Assert.assertTrue(object instanceof ITypedReferenceableInstance);
refTarget = (ITypedReferenceableInstance) object;
Assert.assertEquals(refTarget.getId()._getId(), juliusGuid._getId());
// Verify that max is no longer a subordinate of jane.
jane = repositoryService.getEntityDefinition(janeGuid._getId());
Object refValue = jane.get("subordinates");
Assert.assertTrue(refValue instanceof List);
List<Object> subordinates = (List<Object>)refValue;
Assert.assertEquals(subordinates.size(), 1);
Object listValue = subordinates.get(0);
Assert.assertTrue(listValue instanceof ITypedReferenceableInstance);
ITypedReferenceableInstance subordinate = (ITypedReferenceableInstance) listValue;
Assert.assertNotEquals(subordinate.getId()._getId(), maxGuid);
} }
private ITypedReferenceableInstance createHiveTableInstance(Referenceable databaseInstance) throws Exception { private ITypedReferenceableInstance createHiveTableInstance(Referenceable databaseInstance) throws Exception {
......
...@@ -389,7 +389,7 @@ public class DefaultMetadataServiceTest { ...@@ -389,7 +389,7 @@ public class DefaultMetadataServiceTest {
Assert.assertEquals(arrColumnsList.size(), columns.size()); Assert.assertEquals(arrColumnsList.size(), columns.size());
assertReferenceables(arrColumnsList.get(1), columns.get(1)); assertReferenceables(arrColumnsList.get(1), columns.get(1));
assertReferenceables(arrColumnsList.get(2), columns.get(2)); assertReferenceables(arrColumnsList.get(2), columns.get(2));
//Remove a class reference/Id and insert another reference //Remove a class reference/Id and insert another reference
//Also covers isComposite case since columns is a composite //Also covers isComposite case since columns is a composite
values.clear(); values.clear();
...@@ -788,7 +788,8 @@ public class DefaultMetadataServiceTest { ...@@ -788,7 +788,8 @@ public class DefaultMetadataServiceTest {
for (ITypedReferenceableInstance deletedEntity : deletedEntitiesFromListener) { for (ITypedReferenceableInstance deletedEntity : deletedEntitiesFromListener) {
deletedGuidsFromListener.add(deletedEntity.getId()._getId()); deletedGuidsFromListener.add(deletedEntity.getId()._getId());
} }
Assert.assertEquals(deletedGuidsFromListener, deletedGuids); Assert.assertEquals(deletedGuidsFromListener.size(), deletedGuids.size());
Assert.assertTrue(deletedGuidsFromListener.containsAll(deletedGuids));
} }
private static class DeleteEntitiesChangeListener implements EntityChangeListener { private static class DeleteEntitiesChangeListener implements EntityChangeListener {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment