Commit 3e1637a4 by Shwetha GS

BUG-39239 Not storing arrays and maps in type system

parent 13aae4bf
...@@ -76,9 +76,7 @@ public class GraphBackedTypeStore implements ITypeStore { ...@@ -76,9 +76,7 @@ public class GraphBackedTypeStore implements ITypeStore {
@Override @Override
@GraphTransaction @GraphTransaction
public void store(TypeSystem typeSystem, ImmutableList<String> typeNames) throws AtlasException { public void store(TypeSystem typeSystem, ImmutableList<String> typeNames) throws AtlasException {
ImmutableList<String> coreTypes = typeSystem.getCoreTypes();
for (String typeName : typeNames) { for (String typeName : typeNames) {
if (!coreTypes.contains(typeName)) {
IDataType dataType = typeSystem.getDataType(IDataType.class, typeName); IDataType dataType = typeSystem.getDataType(IDataType.class, typeName);
LOG.debug("Processing {}.{} in type store", dataType.getTypeCategory(), dataType.getName()); LOG.debug("Processing {}.{} in type store", dataType.getTypeCategory(), dataType.getName());
switch (dataType.getTypeCategory()) { switch (dataType.getTypeCategory()) {
...@@ -104,7 +102,6 @@ public class GraphBackedTypeStore implements ITypeStore { ...@@ -104,7 +102,6 @@ public class GraphBackedTypeStore implements ITypeStore {
} }
} }
} }
}
private void addProperty(Vertex vertex, String propertyName, Object value) { private void addProperty(Vertex vertex, String propertyName, Object value) {
LOG.debug("Setting property {} = \"{}\" to vertex {}", propertyName, value, vertex); LOG.debug("Setting property {} = \"{}\" to vertex {}", propertyName, value, vertex);
...@@ -209,7 +206,7 @@ public class GraphBackedTypeStore implements ITypeStore { ...@@ -209,7 +206,7 @@ public class GraphBackedTypeStore implements ITypeStore {
} }
private void addEdge(Vertex fromVertex, Vertex toVertex, String label) { private void addEdge(Vertex fromVertex, Vertex toVertex, String label) {
LOG.debug("Adding edge from {} to {} with label {}" + toString(fromVertex), toString(toVertex), label); LOG.debug("Adding edge from {} to {} with label {}", toString(fromVertex), toString(toVertex), label);
titanGraph.addEdge(null, fromVertex, toVertex, label); titanGraph.addEdge(null, fromVertex, toVertex, label);
} }
...@@ -297,7 +294,7 @@ public class GraphBackedTypeStore implements ITypeStore { ...@@ -297,7 +294,7 @@ public class GraphBackedTypeStore implements ITypeStore {
} }
private String toString(Vertex vertex) { private String toString(Vertex vertex) {
return PROPERTY_PREFIX + "." + vertex.getProperty(Constants.TYPENAME_PROPERTY_KEY); return PROPERTY_PREFIX + vertex.getProperty(Constants.TYPENAME_PROPERTY_KEY);
} }
/** /**
......
...@@ -69,7 +69,7 @@ package object dsl { ...@@ -69,7 +69,7 @@ package object dsl {
new AttributeDefinition(name, dT.getName, m, isComposite, reverseAttributeName) new AttributeDefinition(name, dT.getName, m, isComposite, reverseAttributeName)
} }
def listTypes = (ts.getTypeNames -- ts.getCoreTypes).sorted.toList.mkString("[", ",", "]") def listTypes = ts.getTypeNames.sorted.toList.mkString("[", ",", "]")
def ts = TypeSystem.getInstance def ts = TypeSystem.getInstance
......
...@@ -85,7 +85,7 @@ class DSLTest { ...@@ -85,7 +85,7 @@ class DSLTest {
attrDef("o", mapType(STRING_TYPE, DOUBLE_TYPE))) attrDef("o", mapType(STRING_TYPE, DOUBLE_TYPE)))
// 2. 'mytype' available as a a Type // 2. 'mytype' available as a a Type
Assert.assertEquals(s"${listTypes}", "[array<bigdecimal>,array<int>,map<string,double>,mytype,t1,t2]") Assert.assertEquals(s"${listTypes}", "[mytype,t1,t2]")
// 3. Create a 'mytype' instance from Json // 3. Create a 'mytype' instance from Json
val i = createInstance("mytype", """ val i = createInstance("mytype", """
...@@ -125,7 +125,7 @@ class DSLTest { ...@@ -125,7 +125,7 @@ class DSLTest {
@Test def test2 { @Test def test2 {
// 1. Existing Types in System // 1. Existing Types in System
Assert.assertEquals(s"${listTypes}", "[array<bigdecimal>,array<int>,map<string,double>,t1,t2]") Assert.assertEquals(s"${listTypes}", "[t1,t2]")
val addrType = defineStructType("addressType", val addrType = defineStructType("addressType",
attrDef("houseNum", INT_TYPE, ATTR_REQUIRED), attrDef("houseNum", INT_TYPE, ATTR_REQUIRED),
...@@ -143,7 +143,7 @@ class DSLTest { ...@@ -143,7 +143,7 @@ class DSLTest {
) )
// 2. updated Types in System // 2. updated Types in System
Assert.assertEquals(s"${listTypes}", "[addressType,array<bigdecimal>,array<int>,map<string,double>,personType,t1,t2]") Assert.assertEquals(s"${listTypes}", "[addressType,personType,t1,t2]")
// 3. Construct a Person in Code // 3. Construct a Person in Code
......
...@@ -85,7 +85,9 @@ public class TypeSystem { ...@@ -85,7 +85,9 @@ public class TypeSystem {
} }
public ImmutableList<String> getTypeNames() { public ImmutableList<String> getTypeNames() {
return ImmutableList.copyOf(types.keySet()); List<String> typeNames = new ArrayList<>(types.keySet());
typeNames.removeAll(getCoreTypes());
return ImmutableList.copyOf(typeNames);
} }
public ImmutableList<String> getTypeNamesByCategory(DataTypes.TypeCategory typeCategory) { public ImmutableList<String> getTypeNamesByCategory(DataTypes.TypeCategory typeCategory) {
...@@ -259,8 +261,8 @@ public class TypeSystem { ...@@ -259,8 +261,8 @@ public class TypeSystem {
public DataTypes.ArrayType defineArrayType(IDataType elemType) throws AtlasException { public DataTypes.ArrayType defineArrayType(IDataType elemType) throws AtlasException {
assert elemType != null; assert elemType != null;
DataTypes.ArrayType dT = new DataTypes.ArrayType(elemType); DataTypes.ArrayType dT = new DataTypes.ArrayType(elemType);
types.put(dT.getName(), dT); // types.put(dT.getName(), dT);
typeCategoriesToTypeNamesMap.put(DataTypes.TypeCategory.ARRAY, dT.getName()); // typeCategoriesToTypeNamesMap.put(DataTypes.TypeCategory.ARRAY, dT.getName());
return dT; return dT;
} }
...@@ -269,8 +271,8 @@ public class TypeSystem { ...@@ -269,8 +271,8 @@ public class TypeSystem {
assert keyType != null; assert keyType != null;
assert valueType != null; assert valueType != null;
DataTypes.MapType dT = new DataTypes.MapType(keyType, valueType); DataTypes.MapType dT = new DataTypes.MapType(keyType, valueType);
types.put(dT.getName(), dT); // types.put(dT.getName(), dT);
typeCategoriesToTypeNamesMap.put(DataTypes.TypeCategory.MAP, dT.getName()); // typeCategoriesToTypeNamesMap.put(DataTypes.TypeCategory.MAP, dT.getName());
return dT; return dT;
} }
......
...@@ -157,6 +157,11 @@ public class TypesJerseyResourceIT extends BaseResourceIT { ...@@ -157,6 +157,11 @@ public class TypesJerseyResourceIT extends BaseResourceIT {
final JSONArray list = response.getJSONArray(AtlasClient.RESULTS); final JSONArray list = response.getJSONArray(AtlasClient.RESULTS);
Assert.assertNotNull(list); Assert.assertNotNull(list);
//Verify that primitive and core types are not returned
String typesString = list.join(" ");
Assert.assertFalse(typesString.contains(" \"__IdType\" "));
Assert.assertFalse(typesString.contains(" \"string\" "));
} }
@Test @Test
......
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