Commit 883251c0 by Shwetha GS

ATLAS-33 Atlas restart fails (shwethags)

parent 155554e6
...@@ -6,13 +6,13 @@ Apache Atlas Release Notes ...@@ -6,13 +6,13 @@ Apache Atlas Release Notes
INCOMPATIBLE CHANGES: INCOMPATIBLE CHANGES:
ALL CHANGES: ALL CHANGES:
ATLAS-33 Atlas restart fails (shwethags)
ATLAS-10 Update trunk version to 0.6-incubating-SNAPSHOT (shwethags) ATLAS-10 Update trunk version to 0.6-incubating-SNAPSHOT (shwethags)
--Release 0.5-incubating --Release 0.5-incubating
ALL CHANGES: ALL CHANGES:
ATLAS-26 Minor issues with release prep (Venkatesh Seetharam) ATLAS-26 Minor issues with release prep (Venkatesh Seetharam)
ATLAS-17 Parameterize schema API query per typeName (shwethags) ATLAS-17 Parameterize schema API query per typeName (shwethags)
ATLAS-13 Add project website (Venkatesh Seetharam) ATLAS-13 Add project website (Venkatesh Seetharam)
......
...@@ -340,12 +340,16 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A ...@@ -340,12 +340,16 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A
@Override @Override
public int compareTo(ST o) { public int compareTo(ST o) {
String oName = o.getName(); String oName = o.getName();
if (superTypes.contains(oName)) { try {
return 1; if (o.isSubType(getName())) {
} else if (o.superTypes.contains(getName())) { return 1;
return -1; } else if (isSubType(oName)) {
} else { return -1;
return getName().compareTo(oName); } else {
return getName().compareTo(oName);
}
} catch(AtlasException e) {
throw new RuntimeException(e);
} }
} }
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
package org.apache.atlas.typesystem.types; package org.apache.atlas.typesystem.types;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.apache.atlas.AtlasException;
import org.apache.atlas.typesystem.types.utils.TypesUtil; import org.apache.atlas.typesystem.types.utils.TypesUtil;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.testng.Assert; import org.testng.Assert;
...@@ -118,4 +119,23 @@ public class TypeSystemTest extends BaseTest { ...@@ -118,4 +119,23 @@ public class TypeSystemTest extends BaseTest {
ts.defineTypes(ImmutableList.of(structType), ImmutableList.of(traitType), ImmutableList.of(classType)); ts.defineTypes(ImmutableList.of(structType), ImmutableList.of(traitType), ImmutableList.of(classType));
} }
@Test
public void testHierarchy() throws AtlasException {
HierarchicalTypeDefinition<ClassType> a = TypesUtil.createClassTypeDef("a", ImmutableList.<String>of());
HierarchicalTypeDefinition<ClassType> b = TypesUtil.createClassTypeDef("B", ImmutableList.of("a"));
HierarchicalTypeDefinition<ClassType> c = TypesUtil.createClassTypeDef("C", ImmutableList.of("B"));
TypeSystem ts = getTypeSystem();
ts.defineTypes(ImmutableList.<StructTypeDefinition>of(),
ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(),
ImmutableList.of(a, b, c));
ClassType ac = ts.getDataType(ClassType.class, "a");
ClassType bc = ts.getDataType(ClassType.class, "B");
ClassType cc = ts.getDataType(ClassType.class, "C");
Assert.assertTrue(ac.compareTo(bc) < 0);
Assert.assertTrue(bc.compareTo(cc) < 0);
Assert.assertTrue(ac.compareTo(cc) < 0);
}
} }
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