atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shweth...@apache.org
Subject [1/2] incubator-atlas git commit: ATLAS-479 Add description for different types during create time (guptaneeru via shwethags)
Date Mon, 07 Mar 2016 06:43:59 GMT
Repository: incubator-atlas
Updated Branches:
  refs/heads/master b9575f29d -> b6fb1f1ac


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/b6fb1f1a/typesystem/src/test/java/org/apache/atlas/typesystem/types/TraitTest.java
----------------------------------------------------------------------
diff --git a/typesystem/src/test/java/org/apache/atlas/typesystem/types/TraitTest.java b/typesystem/src/test/java/org/apache/atlas/typesystem/types/TraitTest.java
index 4482816..b7ac8f8 100755
--- a/typesystem/src/test/java/org/apache/atlas/typesystem/types/TraitTest.java
+++ b/typesystem/src/test/java/org/apache/atlas/typesystem/types/TraitTest.java
@@ -220,13 +220,13 @@ public class TraitTest extends HierarchicalTypeTest<TraitType>
{
 
     @Override
     protected HierarchicalTypeDefinition<TraitType> getTypeDefinition(String name,
AttributeDefinition... attributes) {
-        return new HierarchicalTypeDefinition(TraitType.class, name, null, attributes);
+        return new HierarchicalTypeDefinition(TraitType.class, name, null, null, attributes);
     }
 
     @Override
     protected HierarchicalTypeDefinition<TraitType> getTypeDefinition(String name,
ImmutableList<String> superTypes,
                                                                       AttributeDefinition...
attributes) {
-        return new HierarchicalTypeDefinition(TraitType.class, name, superTypes, attributes);
+        return new HierarchicalTypeDefinition(TraitType.class, name, null, superTypes, attributes);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/b6fb1f1a/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeSystemTest.java
----------------------------------------------------------------------
diff --git a/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeSystemTest.java
b/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeSystemTest.java
index eb472e9..4ee9f9c 100755
--- a/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeSystemTest.java
+++ b/typesystem/src/test/java/org/apache/atlas/typesystem/types/TypeSystemTest.java
@@ -27,10 +27,8 @@ import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 import scala.actors.threadpool.Arrays;
-
 import java.util.Collections;
 import java.util.List;
-
 import static org.apache.atlas.typesystem.types.utils.TypesUtil.createClassTypeDef;
 import static org.apache.atlas.typesystem.types.utils.TypesUtil.createRequiredAttrDef;
 import static org.apache.atlas.typesystem.types.utils.TypesUtil.createStructTypeDef;
@@ -56,6 +54,50 @@ public class TypeSystemTest extends BaseTest {
     }
 
     @Test
+    public void testGetTypeDescription() throws Exception {
+        String typeName = "enum_type";
+        String description = "_description";
+        String typeDescription = typeName + description;
+        getTypeSystem().defineEnumType(typeName, typeDescription, new EnumValue("0", 0),
new EnumValue("1", 1), new EnumValue("2", 2),
+                new EnumValue("3", 3));
+        Assert.assertTrue(getTypeSystem().getTypeNames().contains(typeName));
+        IDataType type = getTypeSystem().getDataType(EnumType.class, typeName);
+        Assert.assertNotNull(type);
+        Assert.assertEquals(type.getDescription(), typeDescription);
+
+        typeName = "trait_type";
+        typeDescription = typeName + description;
+        HierarchicalTypeDefinition<TraitType> trait = TypesUtil
+            .createTraitTypeDef(typeName, typeDescription, ImmutableList.<String>of(),
+                TypesUtil.createRequiredAttrDef("type", DataTypes.STRING_TYPE));
+        getTypeSystem().defineTraitType(trait);
+        Assert.assertTrue(getTypeSystem().getTypeNames().contains(typeName));
+        type = getTypeSystem().getDataType(TraitType.class, typeName);
+        Assert.assertNotNull(type);
+        Assert.assertEquals(type.getDescription(), typeDescription);
+
+        typeName = "class_type";
+        typeDescription = typeName + description;
+        HierarchicalTypeDefinition<ClassType> classType = TypesUtil
+            .createClassTypeDef(typeName, typeDescription, ImmutableList.<String>of(),
+                TypesUtil.createRequiredAttrDef("type", DataTypes.STRING_TYPE));
+        getTypeSystem().defineClassType(classType);
+        Assert.assertTrue(getTypeSystem().getTypeNames().contains(typeName));
+        type = getTypeSystem().getDataType(ClassType.class, typeName);
+        Assert.assertNotNull(type);
+        Assert.assertEquals(type.getDescription(), typeDescription);
+
+        typeName = "struct_type";
+        typeDescription = typeName + description;
+        getTypeSystem().defineStructType(typeName, typeDescription, true, createRequiredAttrDef("a",
DataTypes.INT_TYPE));
+        Assert.assertTrue(getTypeSystem().getTypeNames().contains(typeName));
+        type = getTypeSystem().getDataType(StructType.class, typeName);
+        Assert.assertNotNull(type);
+        Assert.assertEquals(type.getDescription(), typeDescription);
+        
+    }
+
+    @Test
     public void testIsRegistered() throws Exception {
         getTypeSystem().defineEnumType("enum_test", new EnumValue("0", 0), new EnumValue("1",
1), new EnumValue("2", 2),
                 new EnumValue("3", 3));

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/b6fb1f1a/typesystem/src/test/scala/org/apache/atlas/typesystem/json/TypesSerializationTest.scala
----------------------------------------------------------------------
diff --git a/typesystem/src/test/scala/org/apache/atlas/typesystem/json/TypesSerializationTest.scala
b/typesystem/src/test/scala/org/apache/atlas/typesystem/json/TypesSerializationTest.scala
index 07ffa96..cfd4bdb 100755
--- a/typesystem/src/test/scala/org/apache/atlas/typesystem/json/TypesSerializationTest.scala
+++ b/typesystem/src/test/scala/org/apache/atlas/typesystem/json/TypesSerializationTest.scala
@@ -86,6 +86,11 @@ class TypesSerializationTest extends BaseTest with TypeHelpers {
             new EnumValue("DB", 1),
             new EnumValue("TABLE", 2),
             new EnumValue("PARTITION", 3))
+            
+         ts.defineEnumType("TestType", "TestType-description",
+            new EnumValue("A", 1),
+            new EnumValue("B", 2),
+            new EnumValue("C", 3))
 
         defineClassType(ts, createClassTypeDef("t4", List(),
             requiredAttr("a", DataTypes.INT_TYPE),
@@ -124,8 +129,12 @@ class TypesSerializationTest extends BaseTest with TypeHelpers {
         val securityClearanceTypeDef: HierarchicalTypeDefinition[TraitType] = createTraitTypeDef("SecurityClearance",
List(),
             requiredAttr("level", DataTypes.INT_TYPE)
         )
+        
+        val securityClearanceTypeDefWithDesc: HierarchicalTypeDefinition[TraitType] = createTraitTypeDef("SecurityClearance2",
Some("SecurityClearance-Description"), List(),
+            requiredAttr("level", DataTypes.INT_TYPE)
+        )
         ts.defineTypes(ImmutableList.of[EnumTypeDefinition], ImmutableList.of[StructTypeDefinition],
-            ImmutableList.of[HierarchicalTypeDefinition[TraitType]](securityClearanceTypeDef),
+            ImmutableList.of[HierarchicalTypeDefinition[TraitType]](securityClearanceTypeDef,
securityClearanceTypeDefWithDesc),
             ImmutableList.of[HierarchicalTypeDefinition[ClassType]](deptTypeDef, personTypeDef,
managerTypeDef))
 
         val ser = TypesSerialization.toJson(ts, _ => true)
@@ -191,12 +200,32 @@ class TypesSerializationTest extends BaseTest with TypeHelpers {
       optionalAttr("n", DataTypes.arrayTypeName(DataTypes.BIGDECIMAL_TYPE)),
       optionalAttr("o", DataTypes.mapTypeName(DataTypes.STRING_TYPE, DataTypes.DOUBLE_TYPE)))
 
+      val ser = TypesSerialization.toJson(sDef)
+      val typesDef2 = TypesSerialization.fromJson(ser)
 
+      Assert.assertEquals(sDef, typesDef2.structTypes(0))
+    
+      //Now with description
+      val sDef2 = structDef("ts1", Some("ts1-description"), requiredAttr("a", DataTypes.INT_TYPE),
+      optionalAttr("b", DataTypes.BOOLEAN_TYPE),
+      optionalAttr("c", DataTypes.BYTE_TYPE),
+      optionalAttr("d", DataTypes.SHORT_TYPE),
+      optionalAttr("e", DataTypes.INT_TYPE),
+      optionalAttr("f", DataTypes.INT_TYPE),
+      optionalAttr("g", DataTypes.LONG_TYPE),
+      optionalAttr("h", DataTypes.FLOAT_TYPE),
+      optionalAttr("i", DataTypes.DOUBLE_TYPE),
+      optionalAttr("j", DataTypes.BIGINTEGER_TYPE),
+      optionalAttr("k", DataTypes.BIGDECIMAL_TYPE),
+      optionalAttr("l", DataTypes.DATE_TYPE),
+      optionalAttr("m", DataTypes.arrayTypeName(DataTypes.INT_TYPE)),
+      optionalAttr("n", DataTypes.arrayTypeName(DataTypes.BIGDECIMAL_TYPE)),
+      optionalAttr("o", DataTypes.mapTypeName(DataTypes.STRING_TYPE, DataTypes.DOUBLE_TYPE)))
 
-    val ser2 = TypesSerialization.toJson(sDef)
-    val typesDef2 = TypesSerialization.fromJson(ser2)
+      val ser2 = TypesSerialization.toJson(sDef)
+      val typesDef3 = TypesSerialization.fromJson(ser2)
+      Assert.assertEquals(sDef, typesDef3.structTypes(0))
 
-    Assert.assertEquals(sDef, typesDef2.structTypes(0))
   }
 
   @Test def test4 : Unit = {
@@ -212,8 +241,9 @@ class TypesSerializationTest extends BaseTest with TypeHelpers {
       createTraitTypeDef("C", Seq("A"), optionalAttr("c", DataTypes.BYTE_TYPE))
     val D: HierarchicalTypeDefinition[TraitType] =
       createTraitTypeDef("D", Seq("B", "C"), optionalAttr("d", DataTypes.SHORT_TYPE))
-
-    val typDefs = Seq(A,B,C,D)
+    val E: HierarchicalTypeDefinition[TraitType] =
+      createTraitTypeDef("E", Some("E-description"), Seq("B", "C"), optionalAttr("d", DataTypes.SHORT_TYPE))
+    val typDefs = Seq(A,B,C,D,E)
     typDefs.foreach { tDef =>
       val ser2 = TypesSerialization.toJson(tDef, true)
       val typesDef2 = TypesSerialization.fromJson(ser2)
@@ -245,7 +275,12 @@ class TypesSerializationTest extends BaseTest with TypeHelpers {
       new EnumValue("TABLE", 2),
       new EnumValue("PARTITION", 3))
 
-    val typDefs = Seq(e1,e2,e3,e4)
+    val e5 = new EnumTypeDefinition("LockLevel", "LockLevel-description",
+      new EnumValue("DB", 1),
+      new EnumValue("TABLE", 2),
+      new EnumValue("PARTITION", 3))
+    
+    val typDefs = Seq(e1,e2,e3,e4,e5)
     typDefs.foreach { tDef =>
       val ser2 = TypesSerialization.toJson(tDef)
       val typesDef2 = TypesSerialization.fromJson(ser2)
@@ -290,12 +325,18 @@ class TypesSerializationTest extends BaseTest with TypeHelpers {
         Multiplicity.COLLECTION, false, "manager")
     )
 
-    val typDefs = Seq(typDef, deptTypeDef, personTypeDef, managerTypeDef)
+    val managerTypeDefWithDesc: HierarchicalTypeDefinition[ClassType] = createClassTypeDef("Manager",
Some("Manager-description"), List("Person"),
+      new AttributeDefinition("subordinates", String.format("array<%s>", "Person"),
+        Multiplicity.COLLECTION, false, "manager")
+    )
+
+    val typDefs = Seq(typDef, deptTypeDef, personTypeDef, managerTypeDef, managerTypeDefWithDesc)
     typDefs.foreach { tDef =>
       val ser2 = TypesSerialization.toJson(tDef, false)
       val typesDef2 = TypesSerialization.fromJson(ser2)
       Assert.assertEquals(tDef, typesDef2.classTypes(0))
 
     }
+
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/b6fb1f1a/webapp/src/main/java/org/apache/atlas/examples/QuickStart.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/examples/QuickStart.java b/webapp/src/main/java/org/apache/atlas/examples/QuickStart.java
index 0a6b7b9..dc5eaae 100755
--- a/webapp/src/main/java/org/apache/atlas/examples/QuickStart.java
+++ b/webapp/src/main/java/org/apache/atlas/examples/QuickStart.java
@@ -128,22 +128,22 @@ public class QuickStart {
 
     TypesDef createTypeDefinitions() throws Exception {
         HierarchicalTypeDefinition<ClassType> dbClsDef = TypesUtil
-                .createClassTypeDef(DATABASE_TYPE, null,
+                .createClassTypeDef(DATABASE_TYPE, DATABASE_TYPE, null,
                         TypesUtil.createUniqueRequiredAttrDef("name", DataTypes.STRING_TYPE),
                         attrDef("description", DataTypes.STRING_TYPE), attrDef("locationUri",
DataTypes.STRING_TYPE),
                         attrDef("owner", DataTypes.STRING_TYPE), attrDef("createTime", DataTypes.LONG_TYPE));
 
         HierarchicalTypeDefinition<ClassType> storageDescClsDef = TypesUtil
-                .createClassTypeDef(STORAGE_DESC_TYPE, null, attrDef("location", DataTypes.STRING_TYPE),
+                .createClassTypeDef(STORAGE_DESC_TYPE, STORAGE_DESC_TYPE, null, attrDef("location",
DataTypes.STRING_TYPE),
                         attrDef("inputFormat", DataTypes.STRING_TYPE), attrDef("outputFormat",
DataTypes.STRING_TYPE),
                         attrDef("compressed", DataTypes.STRING_TYPE, Multiplicity.REQUIRED,
false, null));
 
         HierarchicalTypeDefinition<ClassType> columnClsDef = TypesUtil
-                .createClassTypeDef(COLUMN_TYPE, null, attrDef("name", DataTypes.STRING_TYPE),
+                .createClassTypeDef(COLUMN_TYPE, COLUMN_TYPE, null, attrDef("name", DataTypes.STRING_TYPE),
                         attrDef("dataType", DataTypes.STRING_TYPE), attrDef("comment", DataTypes.STRING_TYPE));
 
         HierarchicalTypeDefinition<ClassType> tblClsDef = TypesUtil
-                .createClassTypeDef(TABLE_TYPE, ImmutableList.of("DataSet"),
+                .createClassTypeDef(TABLE_TYPE, TABLE_TYPE, ImmutableList.of("DataSet"),
                         new AttributeDefinition(DB_ATTRIBUTE, DATABASE_TYPE, Multiplicity.REQUIRED,
false, null),
                         new AttributeDefinition("sd", STORAGE_DESC_TYPE, Multiplicity.REQUIRED,
true, null),
                         attrDef("owner", DataTypes.STRING_TYPE), attrDef("createTime", DataTypes.LONG_TYPE),
@@ -155,7 +155,7 @@ public class QuickStart {
                                 Multiplicity.COLLECTION, true, null));
 
         HierarchicalTypeDefinition<ClassType> loadProcessClsDef = TypesUtil
-                .createClassTypeDef(LOAD_PROCESS_TYPE, ImmutableList.of("Process"),
+                .createClassTypeDef(LOAD_PROCESS_TYPE, LOAD_PROCESS_TYPE, ImmutableList.of("Process"),
                         attrDef("userName", DataTypes.STRING_TYPE), attrDef("startTime",
DataTypes.LONG_TYPE),
                         attrDef("endTime", DataTypes.LONG_TYPE),
                         attrDef("queryText", DataTypes.STRING_TYPE, Multiplicity.REQUIRED),
@@ -164,25 +164,25 @@ public class QuickStart {
                         attrDef("queryGraph", DataTypes.STRING_TYPE, Multiplicity.REQUIRED));
 
         HierarchicalTypeDefinition<ClassType> viewClsDef = TypesUtil
-                .createClassTypeDef(VIEW_TYPE, null,
+                .createClassTypeDef(VIEW_TYPE, VIEW_TYPE, null,
                         TypesUtil.createUniqueRequiredAttrDef("name", DataTypes.STRING_TYPE),
                         new AttributeDefinition("db", DATABASE_TYPE, Multiplicity.REQUIRED,
false, null),
                         new AttributeDefinition("inputTables", DataTypes.arrayTypeName(TABLE_TYPE),
                                 Multiplicity.COLLECTION, false, null));
 
-        HierarchicalTypeDefinition<TraitType> dimTraitDef = TypesUtil.createTraitTypeDef("Dimension",
null);
+        HierarchicalTypeDefinition<TraitType> dimTraitDef = TypesUtil.createTraitTypeDef("Dimension",
 "Dimension Trait", null);
 
-        HierarchicalTypeDefinition<TraitType> factTraitDef = TypesUtil.createTraitTypeDef("Fact",
null);
+        HierarchicalTypeDefinition<TraitType> factTraitDef = TypesUtil.createTraitTypeDef("Fact",
"Fact Trait", null);
 
-        HierarchicalTypeDefinition<TraitType> piiTraitDef = TypesUtil.createTraitTypeDef("PII",
null);
+        HierarchicalTypeDefinition<TraitType> piiTraitDef = TypesUtil.createTraitTypeDef("PII",
"PII Trait", null);
 
-        HierarchicalTypeDefinition<TraitType> metricTraitDef = TypesUtil.createTraitTypeDef("Metric",
null);
+        HierarchicalTypeDefinition<TraitType> metricTraitDef = TypesUtil.createTraitTypeDef("Metric",
"Metric Trait", null);
 
-        HierarchicalTypeDefinition<TraitType> etlTraitDef = TypesUtil.createTraitTypeDef("ETL",
null);
+        HierarchicalTypeDefinition<TraitType> etlTraitDef = TypesUtil.createTraitTypeDef("ETL",
"ETL Trait", null);
 
-        HierarchicalTypeDefinition<TraitType> jdbcTraitDef = TypesUtil.createTraitTypeDef("JdbcAccess",
null);
+        HierarchicalTypeDefinition<TraitType> jdbcTraitDef = TypesUtil.createTraitTypeDef("JdbcAccess",
"JdbcAccess Trait", null);
 
-        HierarchicalTypeDefinition<TraitType> logTraitDef = TypesUtil.createTraitTypeDef("Log
Data", null);
+        HierarchicalTypeDefinition<TraitType> logTraitDef = TypesUtil.createTraitTypeDef("Log
Data", "LogData Trait",  null);
 
         return TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(),
                 ImmutableList.of(dimTraitDef, factTraitDef, piiTraitDef, metricTraitDef,
etlTraitDef, jdbcTraitDef, logTraitDef),


Mime
View raw message