You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by su...@apache.org on 2015/11/25 11:39:28 UTC
incubator-atlas git commit: ATLAS-220 Gets on Enum attribute should
return EnumValue(yhemanth via sumasai)
Repository: incubator-atlas
Updated Branches:
refs/heads/master f671d3ad7 -> 4f3512192
ATLAS-220 Gets on Enum attribute should return EnumValue(yhemanth via sumasai)
Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/4f351219
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/4f351219
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/4f351219
Branch: refs/heads/master
Commit: 4f3512192d35b0209f00a2389074d399e34b920c
Parents: f671d3a
Author: Suma Shivaprasad <su...@gmail.com>
Authored: Wed Nov 25 16:09:16 2015 +0530
Committer: Suma Shivaprasad <su...@gmail.com>
Committed: Wed Nov 25 16:09:16 2015 +0530
----------------------------------------------------------------------
release-log.txt | 1 +
.../service/DefaultMetadataServiceTest.java | 23 ++++++++++++++++++++
.../typesystem/json/InstanceSerialization.scala | 10 +++++++--
3 files changed, 32 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4f351219/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index 401440c..c8faac2 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -9,6 +9,7 @@ ATLAS-54 Rename configs in hive hook (shwethags)
ATLAS-3 Mixed Index creation fails with Date types (sumasai via shwethags)
ALL CHANGES:
+ATLAS-220 Gets on Enum attribute should return EnumValue(yhemanth via sumasai)
ATLAS-334 Update documentation to reflect copying required atlas file on solr installation (sumasai via shwethags)
ATLAS-294 Select queries(ex: from DB select DB.name) response contains column names as "_col_x" instead of the actual names requested in the query.(thiyag via sumasai)
ATLAS-297 KafkaNotificationTest.testSendReceiveMessage fails when atlas-server is running on the same machine (yhemanth via shwethags)
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4f351219/repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java
----------------------------------------------------------------------
diff --git a/repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java b/repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java
index 3c22815..9d32332 100644
--- a/repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java
+++ b/repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java
@@ -31,6 +31,8 @@ import org.apache.atlas.typesystem.Referenceable;
import org.apache.atlas.typesystem.TypesDef;
import org.apache.atlas.typesystem.json.InstanceSerialization;
import org.apache.atlas.typesystem.json.TypesSerialization;
+import org.apache.atlas.typesystem.types.EnumType;
+import org.apache.atlas.typesystem.types.EnumValue;
import org.apache.commons.lang.RandomStringUtils;
import org.codehaus.jettison.json.JSONArray;
import org.testng.Assert;
@@ -126,6 +128,27 @@ public class DefaultMetadataServiceTest {
}
@Test
+ public void testCreateEntityWithEnum() throws Exception {
+ Referenceable dbEntity = createDBEntity();
+ String db = createInstance(dbEntity);
+
+ Referenceable table = new Referenceable(TestUtils.TABLE_TYPE);
+ table.set("name", TestUtils.randomString());
+ table.set("description", "random table");
+ table.set("type", "type");
+ table.set("tableType", "MANAGED");
+ table.set("database", dbEntity);
+ createInstance(table);
+
+ String tableDefinitionJson =
+ metadataService.getEntityDefinition(TestUtils.TABLE_TYPE, "name", (String) table.get("name"));
+ Referenceable tableDefinition = InstanceSerialization.fromJsonReferenceable(tableDefinitionJson, true);
+ EnumValue tableType = (EnumValue) tableDefinition.get("tableType");
+
+ Assert.assertEquals(tableType, new EnumValue("MANAGED", 1));
+ }
+
+ @Test
public void testGetEntityByUniqueAttribute() throws Exception {
Referenceable entity = createDBEntity();
createInstance(entity);
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/4f351219/typesystem/src/main/scala/org/apache/atlas/typesystem/json/InstanceSerialization.scala
----------------------------------------------------------------------
diff --git a/typesystem/src/main/scala/org/apache/atlas/typesystem/json/InstanceSerialization.scala b/typesystem/src/main/scala/org/apache/atlas/typesystem/json/InstanceSerialization.scala
index f792858..b8fa4ea 100755
--- a/typesystem/src/main/scala/org/apache/atlas/typesystem/json/InstanceSerialization.scala
+++ b/typesystem/src/main/scala/org/apache/atlas/typesystem/json/InstanceSerialization.scala
@@ -259,8 +259,14 @@ object InstanceSerialization {
asJava(r.traits).asInstanceOf[java.util.Map[String, IStruct]])
}
case l : List[_] => l.map(e => asJava(e)).toList.asJava
- case m : Map[_, _] if Try{m.asInstanceOf[Map[String,_]]}.isDefined =>
- new InstanceJavaConversion(m.asInstanceOf[Map[String,_]], format).convert
+ case m : Map[_, _] if Try{m.asInstanceOf[Map[String,_]]}.isDefined => {
+ if (m.keys.size == 2 && m.keys.contains("value") && m.keys.contains("ordinal")) {
+ new EnumValue(m.get("value").toString, m.get("ordinal").asInstanceOf[BigInt].intValue())
+ } else {
+ new InstanceJavaConversion(m.asInstanceOf[Map[String,_]], format).convert
+ }
+ }
+
case _ => v
}