You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2017/11/05 20:32:00 UTC
[38/40] atlas git commit: ATLAS-2251: Remove TypeSystem and related
implementation, to avoid unncessary duplicate of type details in cache
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/intg/src/main/java/org/apache/atlas/model/v1/instance/Referenceable.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/model/v1/instance/Referenceable.java b/intg/src/main/java/org/apache/atlas/model/v1/instance/Referenceable.java
new file mode 100644
index 0000000..df541b7
--- /dev/null
+++ b/intg/src/main/java/org/apache/atlas/model/v1/instance/Referenceable.java
@@ -0,0 +1,201 @@
+/**
+ * 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.model.v1.instance;
+
+
+
+import org.codehaus.jackson.annotate.JsonAutoDetect;
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
+
+
+@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown=true)
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.PROPERTY)
+public class Referenceable extends Struct implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private Id id;
+ private Map<String, Struct> traits = new HashMap<>();
+ private List<String> traitNames = new ArrayList<>();
+ private AtlasSystemAttributes systemAttributes;
+
+
+ public Referenceable() {
+ super();
+ }
+
+ public Referenceable(Referenceable that) {
+ super(that);
+
+ if (that != null) {
+ this.id = new Id(that.id);
+
+ if (that.traits != null) {
+ this.traits.putAll(that.traits);
+ }
+
+ if (that.traitNames != null) {
+ this.traitNames.addAll(that.traitNames);
+ }
+
+ this.systemAttributes = new AtlasSystemAttributes(that.systemAttributes);
+ }
+ }
+
+ public Referenceable(String typeName, String... traitNames) {
+ super(typeName);
+
+ this.id = new Id(typeName);
+ this.systemAttributes = null;
+
+ if (traitNames != null) {
+ for (String traitName : traitNames) {
+ this.traitNames.add(traitName);
+ this.traits.put(traitName, new Struct(traitName));
+ }
+ }
+ }
+
+ public Referenceable(String typeName, Map<String, Object> values) {
+ this(new Id(typeName), typeName, values, null, null);
+ }
+
+ public Referenceable(String guid, String typeName, Map<String, Object> values) {
+ this(new Id(guid, 0, typeName), typeName, values, null, null, null);
+ }
+
+ public Referenceable(String guid, String typeName, Map<String, Object> values, AtlasSystemAttributes systemAttributes) {
+ this(new Id(guid, 0, typeName), typeName, values, systemAttributes, null, null);
+ }
+
+ public Referenceable(String guid, String typeName, Map<String, Object> values, AtlasSystemAttributes systemAttributes, List<String> traitNames, Map<String, Struct> traits) {
+ this(new Id(guid, 0, typeName), typeName, values, systemAttributes, traitNames, traits);
+ }
+
+ public Referenceable(String guid, String typeName, Map<String, Object> values, List<String> traitNames, Map<String, Struct> traits) {
+ this(new Id(guid, 0, typeName), typeName, values, null, traitNames, traits);
+ }
+
+ public Referenceable(Id id, String typeName, Map<String, Object> values, List<String> traitNames, Map<String, Struct> traits) {
+ this(id, typeName, values, null, traitNames, traits);
+ }
+
+ public Referenceable(Id id, String typeName, Map<String, Object> values, AtlasSystemAttributes systemAttributes, List<String> traitNames, Map<String, Struct> traits) {
+ super(typeName, values);
+
+ this.id = id;
+ this.systemAttributes = systemAttributes;
+
+ if (traitNames != null) {
+ this.traitNames = traitNames;
+ }
+
+ if (traits != null) {
+ this.traits = traits;
+ }
+ }
+
+
+ // for serialization backward compatibility
+ public String getJsonClass() {
+ return "org.apache.atlas.typesystem.json.InstanceSerialization$_Reference";
+ }
+
+ public Id getId() {
+ return id;
+ }
+
+ public void setId(Id id) {
+ this.id = id;
+ }
+
+ public Map<String, Struct> getTraits() {
+ return traits;
+ }
+
+ public void setTraits(Map<String, Struct> traits) {
+ this.traits = traits;
+ }
+
+ public List<String> getTraitNames() {
+ return traitNames;
+ }
+
+ public void setTraitNames(List<String> traitNames) {
+ this.traitNames = traitNames;
+ }
+
+ public AtlasSystemAttributes getSystemAttributes() {
+ return systemAttributes;
+ }
+
+ public void setSystemAttributes(AtlasSystemAttributes systemAttributes) {
+ this.systemAttributes = systemAttributes;
+ }
+
+ @JsonIgnore
+ public Struct getTrait(String name) {
+ return traits != null ? traits.get(name) : null;
+ }
+
+ @JsonIgnore
+ public String toShortString() {
+ return String.format("entity[type=%s guid=%s]", getTypeName(), id._getId());
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if (o == null || o.getClass() != getClass()) {
+ return false;
+ }
+
+ Referenceable obj = (Referenceable)o;
+
+ return Objects.equals(id, obj.id) &&
+ Objects.equals(traits, obj.traits) &&
+ Objects.equals(traitNames, obj.traitNames) &&
+ Objects.equals(systemAttributes, obj.systemAttributes);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, traits, traitNames, systemAttributes);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/intg/src/main/java/org/apache/atlas/model/v1/instance/Struct.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/model/v1/instance/Struct.java b/intg/src/main/java/org/apache/atlas/model/v1/instance/Struct.java
new file mode 100644
index 0000000..52bf98e
--- /dev/null
+++ b/intg/src/main/java/org/apache/atlas/model/v1/instance/Struct.java
@@ -0,0 +1,141 @@
+/**
+ * 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.model.v1.instance;
+
+
+import org.codehaus.jackson.annotate.JsonAutoDetect;
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
+
+
+@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown=true)
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.PROPERTY)
+public class Struct implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private String typeName;
+ private Map<String, Object> values;
+
+
+ public Struct() {
+ }
+
+ public Struct(Struct that) {
+ if (that != null) {
+ this.typeName = that.typeName;
+
+ if (that.values != null) {
+ this.values = new HashMap<>(that.values);
+ }
+ }
+ }
+
+ public Struct(String typeName) {
+ this(typeName, null);
+ }
+
+ public Struct(String typeName, Map<String, Object> values) {
+ this.typeName = typeName;
+ this.values = values;
+ }
+
+ // for serialization backward compatibility
+ public String getJsonClass() {
+ return "org.apache.atlas.typesystem.json.InstanceSerialization$_Struct";
+ }
+
+ public String getTypeName() {
+ return typeName;
+ }
+
+ public void setTypeName(String typeName) {
+ this.typeName = typeName;
+ }
+
+ public Map<String, Object> getValues() {
+ return values;
+ }
+
+ public void setValues(Map<String, Object> values) {
+ this.values = values;
+ }
+
+ @JsonIgnore
+ public Map<String, Object> getValuesMap() {
+ return values;
+ }
+
+ @JsonIgnore
+ public void set(String attrName, Object attrValue) {
+ if (values == null) {
+ values = new HashMap<>();
+ }
+
+ values.put(attrName, attrValue);
+ }
+
+ @JsonIgnore
+ public Object get(String attrName) {
+ return values != null ? values.get(attrName) : null;
+ }
+
+ @JsonIgnore
+ public void setNull(String attrName) {
+ if (values != null) {
+ values.remove(attrName);
+ }
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if (o == null || o.getClass() != getClass()) {
+ return false;
+ }
+
+ Struct obj = (Struct)o;
+
+ return Objects.equals(typeName, obj.typeName) &&
+ Objects.equals(values, obj.values);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(typeName, values);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/intg/src/main/java/org/apache/atlas/model/v1/typedef/AttributeDefinition.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/model/v1/typedef/AttributeDefinition.java b/intg/src/main/java/org/apache/atlas/model/v1/typedef/AttributeDefinition.java
new file mode 100644
index 0000000..c1369f7
--- /dev/null
+++ b/intg/src/main/java/org/apache/atlas/model/v1/typedef/AttributeDefinition.java
@@ -0,0 +1,159 @@
+/**
+ * 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.model.v1.typedef;
+
+import org.codehaus.jackson.annotate.JsonAutoDetect;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
+
+
+@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown=true)
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.PROPERTY)
+public class AttributeDefinition implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private String name;
+ private String dataTypeName;
+ private Multiplicity multiplicity;
+ private boolean isComposite; // A composite is the one whose lifecycle is dependent on the enclosing type and is not just a reference
+ private boolean isUnique;
+ private boolean isIndexable;
+ private String reverseAttributeName; // If this is a reference attribute, then the name of the attribute on the Class that this refers to.
+
+
+
+ public AttributeDefinition() {
+ }
+
+ public AttributeDefinition(String name, String dataTypeName, Multiplicity multiplicity) {
+ this(name, dataTypeName, multiplicity, false, false, true, null);
+ }
+
+ public AttributeDefinition(String name, String dataTypeName, Multiplicity multiplicity, boolean isComposite,
+ String reverseAttributeName) {
+ this(name, dataTypeName, multiplicity, isComposite, false, false, reverseAttributeName);
+ }
+
+ public AttributeDefinition(String name, String dataTypeName, Multiplicity multiplicity, boolean isComposite, boolean isUnique, boolean isIndexable, String reverseAttributeName) {
+ this.name = name;
+ this.dataTypeName = dataTypeName;
+ this.multiplicity = multiplicity;
+ this.isComposite = isComposite;
+ this.isUnique = isUnique;
+ this.isIndexable = isIndexable;
+ this.reverseAttributeName = reverseAttributeName;
+ }
+
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDataTypeName() {
+ return dataTypeName;
+ }
+
+ public void setDataTypeName(String dataTypeName) {
+ this.dataTypeName = dataTypeName;
+ }
+
+ public Multiplicity getMultiplicity() {
+ return multiplicity;
+ }
+
+ public void setMultiplicity(Multiplicity multiplicity) {
+ this.multiplicity = multiplicity;
+ }
+
+ public boolean getIsComposite() {
+ return isComposite;
+ }
+
+ public void setIsComposite(boolean isComposite) {
+ this.isComposite = isComposite;
+ }
+
+ public boolean getIsUnique() {
+ return isUnique;
+ }
+
+ public void setIsUnique(boolean isUnique) {
+ this.isUnique = isUnique;
+ }
+
+ public boolean getIsIndexable() {
+ return isIndexable;
+ }
+
+ public void setIsIndexable(boolean isIndexable) {
+ this.isIndexable = isIndexable;
+ }
+
+ public String getReverseAttributeName() {
+ return reverseAttributeName;
+ }
+
+ public void setReverseAttributeName(String reverseAttributeName) {
+ this.reverseAttributeName = reverseAttributeName;
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ AttributeDefinition that = (AttributeDefinition) o;
+
+ return isComposite == that.isComposite &&
+ isUnique == that.isUnique &&
+ isIndexable == that.isIndexable &&
+ Objects.equals(name, that.name) &&
+ Objects.equals(dataTypeName, that.dataTypeName) &&
+ Objects.equals(multiplicity, that.multiplicity) &&
+ Objects.equals(reverseAttributeName, that.reverseAttributeName);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(name, dataTypeName, multiplicity, isComposite, isUnique, isIndexable, reverseAttributeName);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/intg/src/main/java/org/apache/atlas/model/v1/typedef/ClassTypeDefinition.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/model/v1/typedef/ClassTypeDefinition.java b/intg/src/main/java/org/apache/atlas/model/v1/typedef/ClassTypeDefinition.java
new file mode 100644
index 0000000..54440e6
--- /dev/null
+++ b/intg/src/main/java/org/apache/atlas/model/v1/typedef/ClassTypeDefinition.java
@@ -0,0 +1,51 @@
+/**
+ * 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.model.v1.typedef;
+
+import org.codehaus.jackson.annotate.JsonAutoDetect;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Set;
+
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
+
+
+@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown=true)
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.PROPERTY)
+public class ClassTypeDefinition extends HierarchicalTypeDefinition implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+
+ public ClassTypeDefinition() {
+ }
+
+ public ClassTypeDefinition(String typeName, String typeDescription, String typeVersion, List<AttributeDefinition> attributeDefinitions, Set<String> superTypes) {
+ super(typeName, typeDescription, typeVersion, attributeDefinitions, "org.apache.atlas.typesystem.types.ClassType", superTypes);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/intg/src/main/java/org/apache/atlas/model/v1/typedef/EnumTypeDefinition.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/model/v1/typedef/EnumTypeDefinition.java b/intg/src/main/java/org/apache/atlas/model/v1/typedef/EnumTypeDefinition.java
new file mode 100644
index 0000000..45ffce5
--- /dev/null
+++ b/intg/src/main/java/org/apache/atlas/model/v1/typedef/EnumTypeDefinition.java
@@ -0,0 +1,174 @@
+/**
+ * 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.model.v1.typedef;
+
+import org.codehaus.jackson.annotate.JsonAutoDetect;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Objects;
+
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
+
+
+@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown=true)
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.PROPERTY)
+public class EnumTypeDefinition implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private String name;
+ private String description;
+ private String version;
+ private List<EnumValue> enumValues;
+
+
+ public EnumTypeDefinition() {
+ }
+
+ public EnumTypeDefinition(String name, String description, String version, List<EnumValue> enumValues) {
+ this.name = name;
+ this.description = description;
+ this.version = version;
+ this.enumValues = enumValues;
+ }
+
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public List<EnumValue> getEnumValues() {
+ return enumValues;
+ }
+
+ public void setEnumValues(List<EnumValue> enumValues) {
+ this.enumValues = enumValues;
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ EnumTypeDefinition that = (EnumTypeDefinition) o;
+
+ return Objects.equals(name, that.name) &&
+ Objects.equals(description, that.description) &&
+ Objects.equals(version, that.version) &&
+ Objects.equals(enumValues, that.enumValues);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(name, description, version, enumValues);
+ }
+
+
+ @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+ @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
+ @JsonIgnoreProperties(ignoreUnknown=true)
+ @XmlRootElement
+ @XmlAccessorType(XmlAccessType.PROPERTY)
+ public static class EnumValue implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private String value;
+ private int ordinal;
+
+ public EnumValue() {
+ }
+
+ public EnumValue(String value, int ordinal) {
+ this.value = value;
+ this.ordinal = ordinal;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public int getOrdinal() {
+ return ordinal;
+ }
+
+ public void setOrdinal(int ordinal) {
+ this.ordinal = ordinal;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ EnumValue that = (EnumValue) o;
+
+ return ordinal == that.ordinal &&
+ Objects.equals(value, that.value);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(value, ordinal);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/intg/src/main/java/org/apache/atlas/model/v1/typedef/HierarchicalTypeDefinition.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/model/v1/typedef/HierarchicalTypeDefinition.java b/intg/src/main/java/org/apache/atlas/model/v1/typedef/HierarchicalTypeDefinition.java
new file mode 100644
index 0000000..0a3daba
--- /dev/null
+++ b/intg/src/main/java/org/apache/atlas/model/v1/typedef/HierarchicalTypeDefinition.java
@@ -0,0 +1,96 @@
+/**
+ * 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.model.v1.typedef;
+
+import org.codehaus.jackson.annotate.JsonAutoDetect;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
+
+
+@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown=true)
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.PROPERTY)
+public class HierarchicalTypeDefinition extends StructTypeDefinition implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+
+ private String hierarchicalMetaTypeName = "org.apache.atlas.typesystem.types.TraitType";
+ private Set<String> superTypes;
+
+
+ public HierarchicalTypeDefinition() {
+ }
+
+ public HierarchicalTypeDefinition(String typeName, String typeDescription, String typeVersion, List<AttributeDefinition> attributeDefinitions, String hierarchicalMetaTypeName, Set<String> superTypes) {
+ super(typeName, typeDescription, typeVersion, attributeDefinitions);
+
+ this.hierarchicalMetaTypeName = hierarchicalMetaTypeName;
+ this.superTypes = superTypes;
+ }
+
+ public String getHierarchicalMetaTypeName() {
+ return hierarchicalMetaTypeName;
+ }
+
+ public void setHierarchicalMetaTypeName(String hierarchicalMetaTypeName) {
+ this.hierarchicalMetaTypeName = hierarchicalMetaTypeName;
+ }
+
+ public Set<String> getSuperTypes() {
+ return superTypes;
+ }
+
+ public void setSuperTypes(Set<String> superTypes) {
+ this.superTypes = superTypes;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if (o == null || getClass() != o.getClass() || !super.equals(o)) {
+ return false;
+ }
+
+ HierarchicalTypeDefinition that = (HierarchicalTypeDefinition) o;
+
+ return Objects.equals(superTypes, that.superTypes) &&
+ Objects.equals(hierarchicalMetaTypeName, that.hierarchicalMetaTypeName);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(super.hashCode(), superTypes, hierarchicalMetaTypeName);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/intg/src/main/java/org/apache/atlas/model/v1/typedef/Multiplicity.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/model/v1/typedef/Multiplicity.java b/intg/src/main/java/org/apache/atlas/model/v1/typedef/Multiplicity.java
new file mode 100644
index 0000000..b975834
--- /dev/null
+++ b/intg/src/main/java/org/apache/atlas/model/v1/typedef/Multiplicity.java
@@ -0,0 +1,113 @@
+/**
+ * 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.model.v1.typedef;
+
+import org.codehaus.jackson.annotate.JsonAutoDetect;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
+
+
+@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown=true)
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.PROPERTY)
+public class Multiplicity implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public static final Multiplicity OPTIONAL = new Multiplicity(0, 1, false);
+ public static final Multiplicity REQUIRED = new Multiplicity(1, 1, false);
+ public static final Multiplicity COLLECTION = new Multiplicity(1, Integer.MAX_VALUE, false);
+ public static final Multiplicity SET = new Multiplicity(1, Integer.MAX_VALUE, true);
+
+ private int lower;
+ private int upper;
+ private boolean isUnique;
+
+ public Multiplicity() {
+ this(Multiplicity.REQUIRED);
+ }
+
+ public Multiplicity(Multiplicity copyFrom) {
+ this(copyFrom.lower, copyFrom.upper, copyFrom.isUnique);
+ }
+
+ public Multiplicity(int lower, int upper, boolean isUnique) {
+ this.lower = lower;
+ this.upper = upper;
+ this.isUnique = isUnique;
+ }
+
+ public int getLower() {
+ return lower;
+ }
+
+ public void setLower(int lower) {
+ this.lower = lower;
+ }
+
+ public int getUpper() {
+ return upper;
+ }
+
+ public void setUpper(int upper) {
+ this.upper = upper;
+ }
+
+ public boolean getIsUnique() {
+ return isUnique;
+ }
+
+ public void setIsUnique(boolean isUnique) {
+ this.isUnique = isUnique;
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ Multiplicity that = (Multiplicity) o;
+
+ return lower == that.lower &&
+ upper == that.upper &&
+ isUnique == that.isUnique;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(lower, upper, isUnique);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/intg/src/main/java/org/apache/atlas/model/v1/typedef/StructTypeDefinition.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/model/v1/typedef/StructTypeDefinition.java b/intg/src/main/java/org/apache/atlas/model/v1/typedef/StructTypeDefinition.java
new file mode 100644
index 0000000..e030a8f
--- /dev/null
+++ b/intg/src/main/java/org/apache/atlas/model/v1/typedef/StructTypeDefinition.java
@@ -0,0 +1,119 @@
+/**
+ * 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.model.v1.typedef;
+
+import org.codehaus.jackson.annotate.JsonAutoDetect;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Objects;
+
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
+
+
+@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown=true)
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.PROPERTY)
+public class StructTypeDefinition implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private String typeName;
+ private String typeDescription;
+ private String typeVersion;
+ private List<AttributeDefinition> attributeDefinitions;
+
+
+ public StructTypeDefinition() {
+ }
+
+ public StructTypeDefinition(String typeName, String typeDescription, List<AttributeDefinition> attributeDefinitions) {
+ this(typeName, typeDescription, "1.0", attributeDefinitions);
+ }
+
+ public StructTypeDefinition(String typeName, String typeDescription, String typeVersion, List<AttributeDefinition> attributeDefinitions) {
+ this.typeName = typeName;
+ this.typeDescription = typeDescription;
+ this.typeVersion = typeVersion;
+ this.attributeDefinitions = attributeDefinitions;
+ }
+
+
+ public String getTypeName() {
+ return typeName;
+ }
+
+ public void setTypeName(String typeName) {
+ this.typeName = typeName;
+ }
+
+ public String getTypeDescription() {
+ return typeDescription;
+ }
+
+ public void setTypeDescription(String typeDescription) {
+ this.typeDescription = typeDescription;
+ }
+
+ public String getTypeVersion() {
+ return typeVersion;
+ }
+
+ public void setTypeVersion(String typeVersion) {
+ this.typeVersion = typeVersion;
+ }
+
+ public List<AttributeDefinition> getAttributeDefinitions() {
+ return attributeDefinitions;
+ }
+
+ public void setAttributeDefinitions(List<AttributeDefinition> attributeDefinitions) {
+ this.attributeDefinitions = attributeDefinitions;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ StructTypeDefinition that = (StructTypeDefinition) o;
+
+ return Objects.equals(typeName, that.typeName) &&
+ Objects.equals(typeDescription, that.typeDescription) &&
+ Objects.equals(typeVersion, that.typeVersion) &&
+ Objects.equals(attributeDefinitions, that.attributeDefinitions);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(typeName, typeDescription, typeVersion, attributeDefinitions);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/intg/src/main/java/org/apache/atlas/model/v1/typedef/TraitTypeDefinition.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/model/v1/typedef/TraitTypeDefinition.java b/intg/src/main/java/org/apache/atlas/model/v1/typedef/TraitTypeDefinition.java
new file mode 100644
index 0000000..0e99201
--- /dev/null
+++ b/intg/src/main/java/org/apache/atlas/model/v1/typedef/TraitTypeDefinition.java
@@ -0,0 +1,51 @@
+/**
+ * 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.model.v1.typedef;
+
+import org.codehaus.jackson.annotate.JsonAutoDetect;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Set;
+
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
+
+
+@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown=true)
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.PROPERTY)
+public class TraitTypeDefinition extends HierarchicalTypeDefinition implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+
+ public TraitTypeDefinition() {
+ }
+
+ public TraitTypeDefinition(String typeName, String typeDescription, String typeVersion, List<AttributeDefinition> attributeDefinitions, Set<String> superTypes) {
+ super(typeName, typeDescription, typeVersion, attributeDefinitions, "org.apache.atlas.typesystem.types.TraitType", superTypes);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/intg/src/main/java/org/apache/atlas/model/v1/typedef/TypesDef.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/model/v1/typedef/TypesDef.java b/intg/src/main/java/org/apache/atlas/model/v1/typedef/TypesDef.java
new file mode 100644
index 0000000..6e11841
--- /dev/null
+++ b/intg/src/main/java/org/apache/atlas/model/v1/typedef/TypesDef.java
@@ -0,0 +1,91 @@
+/**
+ * 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.model.v1.typedef;
+
+import org.codehaus.jackson.annotate.JsonAutoDetect;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.List;
+
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
+import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
+
+
+@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown=true)
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.PROPERTY)
+public class TypesDef implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private List<EnumTypeDefinition> enumTypes;
+ private List<StructTypeDefinition> structTypes;
+ private List<TraitTypeDefinition> traitTypes;
+ private List<ClassTypeDefinition> classTypes;
+
+
+ public TypesDef() {
+ }
+
+ public TypesDef(List<EnumTypeDefinition> enumTypes, List<StructTypeDefinition> structTypes, List<TraitTypeDefinition> traitTypes, List<ClassTypeDefinition> classTypes) {
+ this.enumTypes = enumTypes;
+ this.structTypes = structTypes;
+ this.traitTypes = traitTypes;
+ this.classTypes = classTypes;
+ }
+
+
+ public List<EnumTypeDefinition> getEnumTypes() {
+ return enumTypes;
+ }
+
+ public void setEnumTypes(List<EnumTypeDefinition> enumTypes) {
+ this.enumTypes = enumTypes;
+ }
+
+ public List<StructTypeDefinition> getStructTypes() {
+ return structTypes;
+ }
+
+ public void setStructTypes(List<StructTypeDefinition> structTypes) {
+ this.structTypes = structTypes;
+ }
+
+ public List<TraitTypeDefinition> getTraitTypes() {
+ return traitTypes;
+ }
+
+ public void setTraitTypes(List<TraitTypeDefinition> traitTypes) {
+ this.traitTypes = traitTypes;
+ }
+
+ public List<ClassTypeDefinition> getClassTypes() {
+ return classTypes;
+ }
+
+ public void setClassTypes(List<ClassTypeDefinition> classTypes) {
+ this.classTypes = classTypes;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/intg/src/main/java/org/apache/atlas/type/AtlasType.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasType.java b/intg/src/main/java/org/apache/atlas/type/AtlasType.java
index dc0d300..b5c89af 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasType.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasType.java
@@ -21,10 +21,14 @@ package org.apache.atlas.type;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.TypeCategory;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
-import org.codehaus.jackson.map.DeserializationConfig;
-import org.codehaus.jackson.map.ObjectMapper;
+import org.apache.atlas.model.v1.typedef.Multiplicity;
+import org.codehaus.jackson.*;
+import org.codehaus.jackson.map.*;
+import org.codehaus.jackson.map.module.SimpleModule;
import java.io.IOException;
+import java.text.ParseException;
+import java.util.Date;
import java.util.List;
@@ -39,6 +43,21 @@ public abstract class AtlasType {
private static final ObjectMapper mapper = new ObjectMapper()
.configure(DeserializationConfig.Feature.USE_BIG_DECIMAL_FOR_FLOATS, true);
+ private static final ObjectMapper mapperV1 = new ObjectMapper()
+ .configure(DeserializationConfig.Feature.USE_BIG_DECIMAL_FOR_FLOATS, true);
+
+ static {
+ SimpleModule atlasSerDeModule = new SimpleModule("AtlasSerDe", new Version(1, 0, 0, null));
+
+ atlasSerDeModule.addSerializer(Date.class, new DateSerializer());
+ atlasSerDeModule.addDeserializer(Date.class, new DateDeserializer());
+ atlasSerDeModule.addSerializer(Multiplicity.class, new MultiplicitySerializer());
+ atlasSerDeModule.addDeserializer(Multiplicity.class, new MultiplicityDeserializer());
+
+ mapperV1.registerModule(atlasSerDeModule);
+ }
+
+
private final String typeName;
private final TypeCategory typeCategory;
@@ -123,4 +142,95 @@ public abstract class AtlasType {
}
return ret;
}
+
+ public static String toV1Json(Object obj) {
+ String ret;
+ try {
+ ret = mapperV1.writeValueAsString(obj);
+ }catch (IOException e){
+ ret = null;
+ }
+ return ret;
+ }
+
+ public static <T> T fromV1Json(String jsonStr, Class<T> type) {
+ T ret;
+ try {
+ ret = mapperV1.readValue(jsonStr, type);
+ }catch (IOException e){
+ ret = null;
+ }
+ return ret;
+ }
+
+ static class DateSerializer extends JsonSerializer<Date> {
+ @Override
+ public void serialize(Date value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
+ if (value != null) {
+ jgen.writeString(AtlasBaseTypeDef.DATE_FORMATTER.format(value));
+ }
+ }
+ }
+
+ static class DateDeserializer extends JsonDeserializer<Date> {
+ @Override
+ public Date deserialize(JsonParser parser, DeserializationContext context) throws IOException {
+ Date ret = null;
+
+ String value = parser.readValueAs(String.class);
+
+ if (value != null) {
+ try {
+ ret = AtlasBaseTypeDef.DATE_FORMATTER.parse(value);
+ } catch (ParseException excp) {
+ }
+ }
+
+ return ret;
+ }
+ }
+
+ static class MultiplicitySerializer extends JsonSerializer<Multiplicity> {
+ @Override
+ public void serialize(Multiplicity value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
+ if (value != null) {
+ if (value.equals(Multiplicity.REQUIRED)) {
+ jgen.writeString("required");
+ } else if (value.equals(Multiplicity.OPTIONAL)) {
+ jgen.writeString("optional");
+ } else if (value.equals(Multiplicity.COLLECTION)) {
+ jgen.writeString("collection");
+ } else if (value.equals(Multiplicity.SET)) {
+ jgen.writeString("set");
+ }
+ }
+ }
+ }
+
+ static class MultiplicityDeserializer extends JsonDeserializer<Multiplicity> {
+ @Override
+ public Multiplicity deserialize(JsonParser parser, DeserializationContext context) throws IOException {
+ Multiplicity ret = null;
+
+ String value = parser.readValueAs(String.class);
+
+ if (value != null) {
+ if (value.equals("required")) {
+ ret = new Multiplicity(Multiplicity.REQUIRED);
+ } else if (value.equals("optional")) {
+ ret = new Multiplicity(Multiplicity.OPTIONAL);
+ } else if (value.equals("collection")) {
+ ret = new Multiplicity(Multiplicity.COLLECTION);
+ } else if (value.equals("set")) {
+ ret = new Multiplicity(Multiplicity.SET);
+ }
+ }
+
+ if (ret == null) {
+ ret = new Multiplicity();
+ }
+
+ return ret;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/intg/src/main/java/org/apache/atlas/typesystem/types/DataTypes.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/typesystem/types/DataTypes.java b/intg/src/main/java/org/apache/atlas/typesystem/types/DataTypes.java
new file mode 100644
index 0000000..804ad33
--- /dev/null
+++ b/intg/src/main/java/org/apache/atlas/typesystem/types/DataTypes.java
@@ -0,0 +1,33 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.typesystem.types;
+
+
+public class DataTypes {
+ public enum TypeCategory {
+ PRIMITIVE,
+ ENUM,
+ ARRAY,
+ MAP,
+ STRUCT,
+ TRAIT,
+ CLASS,
+ RELATIONSHIP
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/intg/src/main/java/org/apache/atlas/typesystem/types/utils/TypesUtil.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/typesystem/types/utils/TypesUtil.java b/intg/src/main/java/org/apache/atlas/typesystem/types/utils/TypesUtil.java
new file mode 100644
index 0000000..ed82e2a
--- /dev/null
+++ b/intg/src/main/java/org/apache/atlas/typesystem/types/utils/TypesUtil.java
@@ -0,0 +1,112 @@
+/**
+ * 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.typesystem.types.utils;
+
+
+import org.apache.atlas.model.v1.typedef.AttributeDefinition;
+import org.apache.atlas.model.v1.typedef.ClassTypeDefinition;
+import org.apache.atlas.model.v1.typedef.Multiplicity;
+import org.apache.atlas.model.v1.typedef.TraitTypeDefinition;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+
+public class TypesUtil {
+ public static ClassTypeDefinition createClassTypeDef(String name, String description, Set<String> superTypes, AttributeDefinition... attributes) {
+ ClassTypeDefinition ret = new ClassTypeDefinition(name, description, "1.0", Arrays.asList(attributes), superTypes);
+
+ return ret;
+ }
+
+ public static ClassTypeDefinition createClassTypeDef(String name, String description, String typeVersion, Set<String> superTypes, AttributeDefinition... attributes) {
+ ClassTypeDefinition ret = new ClassTypeDefinition(name, description, typeVersion, Arrays.asList(attributes), superTypes);
+
+ return ret;
+ }
+
+ public static TraitTypeDefinition createTraitTypeDef(String name, String description, Set<String> superTypes, AttributeDefinition... attributes) {
+ return createTraitTypeDef(name, description, superTypes, Arrays.asList(attributes));
+ }
+
+ public static TraitTypeDefinition createTraitTypeDef(String name, String description, String typeVersion, Set<String> superTypes, AttributeDefinition... attributes) {
+ return createTraitTypeDef(name, description, typeVersion, superTypes, Arrays.asList(attributes));
+ }
+
+ public static TraitTypeDefinition createTraitTypeDef(String name, String description, Set<String> superTypes, List<AttributeDefinition> attributes) {
+ TraitTypeDefinition ret = new TraitTypeDefinition(name, description, "1.0", attributes, superTypes);
+
+ return ret;
+ }
+
+ public static TraitTypeDefinition createTraitTypeDef(String name, String description, String typeVersion, Set<String> superTypes, List<AttributeDefinition> attributes) {
+ TraitTypeDefinition ret = new TraitTypeDefinition(name, description, typeVersion, attributes, superTypes);
+
+ return ret;
+ }
+
+ public static AttributeDefinition createUniqueRequiredAttrDef(String name, String dataTypeName) {
+ AttributeDefinition ret = new AttributeDefinition(name, dataTypeName, Multiplicity.REQUIRED, false, true, true, null);
+
+ return ret;
+ }
+
+ public static AttributeDefinition createRequiredAttrDef(String name, String dataTypeName) {
+ AttributeDefinition ret = new AttributeDefinition(name, dataTypeName, Multiplicity.REQUIRED, false, false, true, null);
+
+ return ret;
+ }
+
+ public static AttributeDefinition createOptionalAttrDef(String name, String dataTypeName) {
+ AttributeDefinition ret = new AttributeDefinition(name, dataTypeName, Multiplicity.OPTIONAL, false, false, true, null);
+
+ return ret;
+ }
+
+ public static class Pair<L, R> {
+ public L left;
+ public R right;
+
+ public Pair(L left, R right) {
+ this.left = left;
+ this.right = right;
+ }
+
+ public static <L, R> Pair<L, R> of(L left, R right) {
+ return new Pair<>(left, right);
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ Pair p = (Pair)o;
+
+ return Objects.equals(left, p.left) && Objects.equals(right, p.right);
+ }
+
+ public int hashCode() { return Objects.hash(left, right); }
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/notification/src/main/java/org/apache/atlas/hook/AtlasHook.java
----------------------------------------------------------------------
diff --git a/notification/src/main/java/org/apache/atlas/hook/AtlasHook.java b/notification/src/main/java/org/apache/atlas/hook/AtlasHook.java
index 38f3208..efe0b88 100644
--- a/notification/src/main/java/org/apache/atlas/hook/AtlasHook.java
+++ b/notification/src/main/java/org/apache/atlas/hook/AtlasHook.java
@@ -21,12 +21,12 @@ package org.apache.atlas.hook;
import com.google.common.annotations.VisibleForTesting;
import org.apache.atlas.ApplicationProperties;
import org.apache.atlas.kafka.NotificationProvider;
+import org.apache.atlas.model.v1.instance.Referenceable;
import org.apache.atlas.notification.NotificationException;
import org.apache.atlas.notification.NotificationInterface;
import org.apache.atlas.notification.hook.HookNotification;
import org.apache.atlas.security.InMemoryJAASConfiguration;
-import org.apache.atlas.typesystem.Referenceable;
-import org.apache.atlas.typesystem.json.InstanceSerialization;
+import org.apache.atlas.type.AtlasType;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.security.UserGroupInformation;
@@ -106,7 +106,7 @@ public abstract class AtlasHook {
for (Referenceable entity : entities) {
LOG.info("Adding entity for type: {}", entity.getTypeName());
- final String entityJson = InstanceSerialization.toJson(entity, true);
+ final String entityJson = AtlasType.toV1Json(entity);
entitiesArray.put(entityJson);
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/notification/src/main/java/org/apache/atlas/notification/AbstractMessageDeserializer.java
----------------------------------------------------------------------
diff --git a/notification/src/main/java/org/apache/atlas/notification/AbstractMessageDeserializer.java b/notification/src/main/java/org/apache/atlas/notification/AbstractMessageDeserializer.java
index 37a57d1..67bbb22 100644
--- a/notification/src/main/java/org/apache/atlas/notification/AbstractMessageDeserializer.java
+++ b/notification/src/main/java/org/apache/atlas/notification/AbstractMessageDeserializer.java
@@ -27,11 +27,9 @@ import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.reflect.TypeToken;
-import org.apache.atlas.typesystem.IReferenceableInstance;
-import org.apache.atlas.typesystem.IStruct;
-import org.apache.atlas.typesystem.Referenceable;
-import org.apache.atlas.typesystem.Struct;
-import org.apache.atlas.typesystem.json.InstanceSerialization;
+import org.apache.atlas.model.v1.instance.Referenceable;
+import org.apache.atlas.model.v1.instance.Struct;
+import org.apache.atlas.type.AtlasType;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.slf4j.Logger;
@@ -52,8 +50,7 @@ public abstract class AbstractMessageDeserializer<T> extends AtlasNotificationMe
DESERIALIZER_MAP.put(ImmutableList.class, new ImmutableListDeserializer());
DESERIALIZER_MAP.put(ImmutableMap.class, new ImmutableMapDeserializer());
DESERIALIZER_MAP.put(JSONArray.class, new JSONArrayDeserializer());
- DESERIALIZER_MAP.put(IStruct.class, new StructDeserializer());
- DESERIALIZER_MAP.put(IReferenceableInstance.class, new ReferenceableDeserializer());
+ DESERIALIZER_MAP.put(Struct.class, new StructDeserializer());
DESERIALIZER_MAP.put(Referenceable.class, new ReferenceableDeserializer());
}
@@ -143,9 +140,9 @@ public abstract class AbstractMessageDeserializer<T> extends AtlasNotificationMe
/**
* Deserializer for Struct.
*/
- protected static final class StructDeserializer implements JsonDeserializer<IStruct> {
+ protected static final class StructDeserializer implements JsonDeserializer<Struct> {
@Override
- public IStruct deserialize(final JsonElement json, final Type type,
+ public Struct deserialize(final JsonElement json, final Type type,
final JsonDeserializationContext context) {
return context.deserialize(json, Struct.class);
}
@@ -154,12 +151,12 @@ public abstract class AbstractMessageDeserializer<T> extends AtlasNotificationMe
/**
* Deserializer for Referenceable.
*/
- protected static final class ReferenceableDeserializer implements JsonDeserializer<IReferenceableInstance> {
+ protected static final class ReferenceableDeserializer implements JsonDeserializer<Referenceable> {
@Override
- public IReferenceableInstance deserialize(final JsonElement json, final Type type,
+ public Referenceable deserialize(final JsonElement json, final Type type,
final JsonDeserializationContext context) {
- return InstanceSerialization.fromJsonReferenceable(json.toString(), true);
+ return AtlasType.fromV1Json(json.toString(), Referenceable.class);
}
}
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/notification/src/main/java/org/apache/atlas/notification/AbstractNotification.java
----------------------------------------------------------------------
diff --git a/notification/src/main/java/org/apache/atlas/notification/AbstractNotification.java b/notification/src/main/java/org/apache/atlas/notification/AbstractNotification.java
index 4f56bd8..9dcda57 100644
--- a/notification/src/main/java/org/apache/atlas/notification/AbstractNotification.java
+++ b/notification/src/main/java/org/apache/atlas/notification/AbstractNotification.java
@@ -26,10 +26,9 @@ import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import org.apache.atlas.AtlasException;
import org.apache.atlas.ha.HAConfiguration;
+import org.apache.atlas.model.v1.instance.Referenceable;
import org.apache.atlas.notification.AtlasNotificationBaseMessage.CompressionKind;
-import org.apache.atlas.typesystem.IReferenceableInstance;
-import org.apache.atlas.typesystem.Referenceable;
-import org.apache.atlas.typesystem.json.InstanceSerialization;
+import org.apache.atlas.type.AtlasType;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang.StringUtils;
import org.codehaus.jettison.json.JSONArray;
@@ -83,7 +82,6 @@ public abstract class AbstractNotification implements NotificationInterface {
* Used for message serialization.
*/
public static final Gson GSON = new GsonBuilder().
- registerTypeAdapter(IReferenceableInstance.class, new ReferenceableSerializer()).
registerTypeAdapter(Referenceable.class, new ReferenceableSerializer()).
registerTypeAdapter(JSONArray.class, new JSONArraySerializer()).
create();
@@ -264,10 +262,10 @@ public abstract class AbstractNotification implements NotificationInterface {
/**
* Serializer for Referenceable.
*/
- public static final class ReferenceableSerializer implements JsonSerializer<IReferenceableInstance> {
+ public static final class ReferenceableSerializer implements JsonSerializer<Referenceable> {
@Override
- public JsonElement serialize(IReferenceableInstance src, Type typeOfSrc, JsonSerializationContext context) {
- String instanceJson = InstanceSerialization.toJson(src, true);
+ public JsonElement serialize(Referenceable src, Type typeOfSrc, JsonSerializationContext context) {
+ String instanceJson = AtlasType.toV1Json(src);
return new JsonParser().parse(instanceJson).getAsJsonObject();
}
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/notification/src/main/java/org/apache/atlas/notification/entity/EntityNotification.java
----------------------------------------------------------------------
diff --git a/notification/src/main/java/org/apache/atlas/notification/entity/EntityNotification.java b/notification/src/main/java/org/apache/atlas/notification/entity/EntityNotification.java
index 379e815..9ccb699 100644
--- a/notification/src/main/java/org/apache/atlas/notification/entity/EntityNotification.java
+++ b/notification/src/main/java/org/apache/atlas/notification/entity/EntityNotification.java
@@ -17,8 +17,9 @@
*/
package org.apache.atlas.notification.entity;
-import org.apache.atlas.typesystem.IReferenceableInstance;
-import org.apache.atlas.typesystem.IStruct;
+
+import org.apache.atlas.model.v1.instance.Referenceable;
+import org.apache.atlas.model.v1.instance.Struct;
import java.util.List;
@@ -47,14 +48,14 @@ public interface EntityNotification {
*
* @return the associated entity
*/
- IReferenceableInstance getEntity();
+ Referenceable getEntity();
/**
* Get flattened list of traits that are associated with this entity (includes super traits).
*
* @return the list of all traits
*/
- List<IStruct> getAllTraits();
+ List<Struct> getAllTraits();
/**
* Get the type of operation that triggered this notification.
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/notification/src/main/java/org/apache/atlas/notification/entity/EntityNotificationImpl.java
----------------------------------------------------------------------
diff --git a/notification/src/main/java/org/apache/atlas/notification/entity/EntityNotificationImpl.java b/notification/src/main/java/org/apache/atlas/notification/entity/EntityNotificationImpl.java
index 6a9b362..ce3cde6 100644
--- a/notification/src/main/java/org/apache/atlas/notification/entity/EntityNotificationImpl.java
+++ b/notification/src/main/java/org/apache/atlas/notification/entity/EntityNotificationImpl.java
@@ -18,13 +18,12 @@
package org.apache.atlas.notification.entity;
import org.apache.atlas.AtlasException;
-import org.apache.atlas.typesystem.IReferenceableInstance;
-import org.apache.atlas.typesystem.IStruct;
-import org.apache.atlas.typesystem.Referenceable;
-import org.apache.atlas.typesystem.Struct;
-import org.apache.atlas.typesystem.types.FieldMapping;
-import org.apache.atlas.typesystem.types.TraitType;
-import org.apache.atlas.typesystem.types.TypeSystem;
+import org.apache.atlas.model.v1.instance.Referenceable;
+import org.apache.atlas.model.v1.instance.Struct;
+import org.apache.atlas.type.AtlasClassificationType;
+import org.apache.atlas.type.AtlasTypeRegistry;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.MapUtils;
import java.util.Collections;
import java.util.HashMap;
@@ -41,7 +40,7 @@ public class EntityNotificationImpl implements EntityNotification {
private final Referenceable entity;
private final OperationType operationType;
- private final List<IStruct> traits;
+ private final List<Struct> traits;
// ----- Constructors ------------------------------------------------------
@@ -51,7 +50,7 @@ public class EntityNotificationImpl implements EntityNotification {
*/
@SuppressWarnings("unused")
private EntityNotificationImpl() throws AtlasException {
- this(null, OperationType.ENTITY_CREATE, Collections.<IStruct>emptyList());
+ this(null, OperationType.ENTITY_CREATE, Collections.<Struct>emptyList());
}
/**
@@ -63,7 +62,7 @@ public class EntityNotificationImpl implements EntityNotification {
*
* @throws AtlasException if the entity notification can not be created
*/
- public EntityNotificationImpl(Referenceable entity, OperationType operationType, List<IStruct> traits)
+ public EntityNotificationImpl(Referenceable entity, OperationType operationType, List<Struct> traits)
throws AtlasException {
this.entity = entity;
this.operationType = operationType;
@@ -75,25 +74,25 @@ public class EntityNotificationImpl implements EntityNotification {
*
* @param entity the entity subject of the notification
* @param operationType the type of operation that caused the notification
- * @param typeSystem the Atlas type system
+ * @param typeRegistry the Atlas type system
*
* @throws AtlasException if the entity notification can not be created
*/
- public EntityNotificationImpl(Referenceable entity, OperationType operationType, TypeSystem typeSystem)
+ public EntityNotificationImpl(Referenceable entity, OperationType operationType, AtlasTypeRegistry typeRegistry)
throws AtlasException {
- this(entity, operationType, getAllTraits(entity, typeSystem));
+ this(entity, operationType, getAllTraits(entity, typeRegistry));
}
// ----- EntityNotification ------------------------------------------------
@Override
- public IReferenceableInstance getEntity() {
+ public Referenceable getEntity() {
return entity;
}
@Override
- public List<IStruct> getAllTraits() {
+ public List<Struct> getAllTraits() {
return traits;
}
@@ -123,48 +122,36 @@ public class EntityNotificationImpl implements EntityNotification {
// ----- helper methods ----------------------------------------------------
- private static List<IStruct> getAllTraits(IReferenceableInstance entityDefinition,
- TypeSystem typeSystem) throws AtlasException {
- List<IStruct> traitInfo = new LinkedList<>();
- for (String traitName : entityDefinition.getTraits()) {
- IStruct trait = entityDefinition.getTrait(traitName);
- String typeName = trait.getTypeName();
- Map<String, Object> valuesMap = trait.getValuesMap();
- traitInfo.add(new Struct(typeName, valuesMap));
- traitInfo.addAll(getSuperTraits(typeName, valuesMap, typeSystem));
- }
- return traitInfo;
- }
-
- private static List<IStruct> getSuperTraits(
- String typeName, Map<String, Object> values, TypeSystem typeSystem) throws AtlasException {
+ private static List<Struct> getAllTraits(Referenceable entityDefinition, AtlasTypeRegistry typeRegistry) throws AtlasException {
+ List<Struct> ret = new LinkedList<>();
- List<IStruct> superTypes = new LinkedList<>();
+ for (String traitName : entityDefinition.getTraitNames()) {
+ Struct trait = entityDefinition.getTrait(traitName);
+ AtlasClassificationType traitType = typeRegistry.getClassificationTypeByName(traitName);
+ Set<String> superTypeNames = traitType != null ? traitType.getAllSuperTypes() : null;
- TraitType traitDef = typeSystem.getDataType(TraitType.class, typeName);
- Set<String> superTypeNames = traitDef.getAllSuperTypeNames();
+ ret.add(trait);
- for (String superTypeName : superTypeNames) {
- TraitType superTraitDef = typeSystem.getDataType(TraitType.class, superTypeName);
+ if (CollectionUtils.isNotEmpty(superTypeNames)) {
+ for (String superTypeName : superTypeNames) {
+ Struct superTypeTrait = new Struct(superTypeName);
- Map<String, Object> superTypeValues = new HashMap<>();
+ if (MapUtils.isNotEmpty(trait.getValues())) {
+ AtlasClassificationType superType = typeRegistry.getClassificationTypeByName(superTypeName);
- FieldMapping fieldMapping = superTraitDef.fieldMapping();
+ if (superType != null && MapUtils.isNotEmpty(superType.getAllAttributes())) {
+ Map<String, Object> attributes = new HashMap<>();
- if (fieldMapping != null) {
- Set<String> superTypeAttributeNames = fieldMapping.fields.keySet();
+ // TODO: add superTypeTrait attributess
- for (String superTypeAttributeName : superTypeAttributeNames) {
- if (values.containsKey(superTypeAttributeName)) {
- superTypeValues.put(superTypeAttributeName, values.get(superTypeAttributeName));
+ superTypeTrait.setValues(attributes);
+ }
}
+
+ ret.add(superTypeTrait);
}
}
- IStruct superTrait = new Struct(superTypeName, superTypeValues);
- superTypes.add(superTrait);
- superTypes.addAll(getSuperTraits(superTypeName, values, typeSystem));
}
- return superTypes;
- }
-}
+ return ret;
+ }}
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/notification/src/main/java/org/apache/atlas/notification/hook/HookNotification.java
----------------------------------------------------------------------
diff --git a/notification/src/main/java/org/apache/atlas/notification/hook/HookNotification.java b/notification/src/main/java/org/apache/atlas/notification/hook/HookNotification.java
index a25aa52..d80c466 100644
--- a/notification/src/main/java/org/apache/atlas/notification/hook/HookNotification.java
+++ b/notification/src/main/java/org/apache/atlas/notification/hook/HookNotification.java
@@ -22,9 +22,9 @@ import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
-import org.apache.atlas.typesystem.Referenceable;
-import org.apache.atlas.typesystem.TypesDef;
-import org.apache.atlas.typesystem.json.InstanceSerialization;
+import org.apache.atlas.model.v1.instance.Referenceable;
+import org.apache.atlas.model.v1.typedef.TypesDef;
+import org.apache.atlas.type.AtlasType;
import org.apache.commons.lang.StringUtils;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
@@ -149,7 +149,7 @@ public class HookNotification implements JsonDeserializer<HookNotification.HookN
entities = new ArrayList<>();
for (int index = 0; index < jsonArray.length(); index++) {
try {
- entities.add(InstanceSerialization.fromJsonReferenceable(jsonArray.getString(index), true));
+ entities.add(AtlasType.fromV1Json(jsonArray.getString(index), Referenceable.class));
} catch (JSONException e) {
throw new JsonParseException(e);
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/notification/src/test/java/org/apache/atlas/kafka/KafkaConsumerTest.java
----------------------------------------------------------------------
diff --git a/notification/src/test/java/org/apache/atlas/kafka/KafkaConsumerTest.java b/notification/src/test/java/org/apache/atlas/kafka/KafkaConsumerTest.java
index 08a20bd..2b9a96d 100644
--- a/notification/src/test/java/org/apache/atlas/kafka/KafkaConsumerTest.java
+++ b/notification/src/test/java/org/apache/atlas/kafka/KafkaConsumerTest.java
@@ -19,13 +19,13 @@
package org.apache.atlas.kafka;
import kafka.message.MessageAndMetadata;
+import org.apache.atlas.model.v1.instance.Referenceable;
+import org.apache.atlas.model.v1.instance.Struct;
import org.apache.atlas.notification.*;
import org.apache.atlas.notification.AtlasNotificationMessage;
import org.apache.atlas.notification.entity.EntityNotificationImplTest;
import org.apache.atlas.notification.hook.HookNotification;
-import org.apache.atlas.typesystem.IStruct;
-import org.apache.atlas.typesystem.Referenceable;
-import org.apache.atlas.typesystem.Struct;
+import org.apache.atlas.type.AtlasType;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
@@ -79,7 +79,7 @@ public class KafkaConsumerTest {
HookNotification.EntityUpdateRequest message =
new HookNotification.EntityUpdateRequest("user1", entity);
- String json = AbstractNotification.GSON.toJson(new AtlasNotificationMessage<>(new MessageVersion("1.0.0"), message));
+ String json = AtlasType.toV1Json(new AtlasNotificationMessage<>(new MessageVersion("1.0.0"), message));
kafkaConsumer.assign(Arrays.asList(new TopicPartition("ATLAS_HOOK", 0)));
List<ConsumerRecord> klist = new ArrayList<>();
@@ -116,7 +116,7 @@ public class KafkaConsumerTest {
HookNotification.EntityUpdateRequest message =
new HookNotification.EntityUpdateRequest("user1", entity);
- String json = AbstractNotification.GSON.toJson(new AtlasNotificationMessage<>(new MessageVersion("2.0.0"), message));
+ String json = AtlasType.toV1Json(new AtlasNotificationMessage<>(new MessageVersion("2.0.0"), message));
kafkaConsumer.assign(Arrays.asList(new TopicPartition("ATLAS_HOOK", 0)));
List<ConsumerRecord> klist = new ArrayList<>();
@@ -172,8 +172,8 @@ public class KafkaConsumerTest {
private Referenceable getEntity(String traitName) {
Referenceable entity = EntityNotificationImplTest.getEntity("id");
- List<IStruct> traitInfo = new LinkedList<>();
- IStruct trait = new Struct(traitName, Collections.<String, Object>emptyMap());
+ List<Struct> traitInfo = new LinkedList<>();
+ Struct trait = new Struct(traitName, Collections.<String, Object>emptyMap());
traitInfo.add(trait);
return entity;
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/notification/src/test/java/org/apache/atlas/kafka/KafkaNotificationTest.java
----------------------------------------------------------------------
diff --git a/notification/src/test/java/org/apache/atlas/kafka/KafkaNotificationTest.java b/notification/src/test/java/org/apache/atlas/kafka/KafkaNotificationTest.java
index a1e13b9..e300d8b 100644
--- a/notification/src/test/java/org/apache/atlas/kafka/KafkaNotificationTest.java
+++ b/notification/src/test/java/org/apache/atlas/kafka/KafkaNotificationTest.java
@@ -19,10 +19,10 @@
package org.apache.atlas.kafka;
import org.apache.atlas.ApplicationProperties;
+import org.apache.atlas.model.v1.instance.Referenceable;
import org.apache.atlas.notification.NotificationConsumer;
import org.apache.atlas.notification.NotificationInterface;
import org.apache.atlas.notification.hook.HookNotification;
-import org.apache.atlas.typesystem.Referenceable;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang.RandomStringUtils;
import org.testng.annotations.AfterClass;
@@ -33,7 +33,6 @@ import static org.apache.atlas.notification.hook.HookNotification.HookNotificati
import java.util.List;
import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
public class KafkaNotificationTest {
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/notification/src/test/java/org/apache/atlas/notification/entity/EntityMessageDeserializerTest.java
----------------------------------------------------------------------
diff --git a/notification/src/test/java/org/apache/atlas/notification/entity/EntityMessageDeserializerTest.java b/notification/src/test/java/org/apache/atlas/notification/entity/EntityMessageDeserializerTest.java
index 7b513da..4d8d991 100644
--- a/notification/src/test/java/org/apache/atlas/notification/entity/EntityMessageDeserializerTest.java
+++ b/notification/src/test/java/org/apache/atlas/notification/entity/EntityMessageDeserializerTest.java
@@ -18,10 +18,9 @@
package org.apache.atlas.notification.entity;
+import org.apache.atlas.model.v1.instance.Referenceable;
+import org.apache.atlas.model.v1.instance.Struct;
import org.apache.atlas.notification.AbstractNotification;
-import org.apache.atlas.typesystem.IStruct;
-import org.apache.atlas.typesystem.Referenceable;
-import org.apache.atlas.typesystem.Struct;
import org.testng.annotations.Test;
import java.util.ArrayList;
@@ -42,8 +41,8 @@ public class EntityMessageDeserializerTest {
Referenceable entity = EntityNotificationImplTest.getEntity("id");
String traitName = "MyTrait";
- List<IStruct> traitInfo = new LinkedList<>();
- IStruct trait = new Struct(traitName, Collections.<String, Object>emptyMap());
+ List<Struct> traitInfo = new LinkedList<>();
+ Struct trait = new Struct(traitName, Collections.<String, Object>emptyMap());
traitInfo.add(trait);
EntityNotificationImpl notification =
http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/notification/src/test/java/org/apache/atlas/notification/entity/EntityNotificationImplTest.java
----------------------------------------------------------------------
diff --git a/notification/src/test/java/org/apache/atlas/notification/entity/EntityNotificationImplTest.java b/notification/src/test/java/org/apache/atlas/notification/entity/EntityNotificationImplTest.java
index c3a2db8..7530431 100644
--- a/notification/src/test/java/org/apache/atlas/notification/entity/EntityNotificationImplTest.java
+++ b/notification/src/test/java/org/apache/atlas/notification/entity/EntityNotificationImplTest.java
@@ -18,11 +18,10 @@
package org.apache.atlas.notification.entity;
-import org.apache.atlas.typesystem.IStruct;
-import org.apache.atlas.typesystem.Referenceable;
-import org.apache.atlas.typesystem.Struct;
-import org.apache.atlas.typesystem.types.TraitType;
-import org.apache.atlas.typesystem.types.TypeSystem;
+import org.apache.atlas.model.v1.instance.Referenceable;
+import org.apache.atlas.model.v1.instance.Struct;
+import org.apache.atlas.type.AtlasClassificationType;
+import org.apache.atlas.type.AtlasTypeRegistry;
import org.testng.annotations.Test;
import java.util.Collections;
@@ -48,7 +47,7 @@ public class EntityNotificationImplTest {
EntityNotificationImpl entityNotification =
new EntityNotificationImpl(entity, EntityNotification.OperationType.ENTITY_CREATE,
- Collections.<IStruct>emptyList());
+ Collections.<Struct>emptyList());
assertEquals(entity, entityNotification.getEntity());
}
@@ -59,7 +58,7 @@ public class EntityNotificationImplTest {
EntityNotificationImpl entityNotification =
new EntityNotificationImpl(entity, EntityNotification.OperationType.ENTITY_CREATE,
- Collections.<IStruct>emptyList());
+ Collections.<Struct>emptyList());
assertEquals(EntityNotification.OperationType.ENTITY_CREATE, entityNotification.getOperationType());
}
@@ -68,8 +67,8 @@ public class EntityNotificationImplTest {
public void testGetAllTraits() throws Exception {
Referenceable entity = getEntity("id");
String traitName = "MyTrait";
- List<IStruct> traitInfo = new LinkedList<>();
- IStruct trait = new Struct(traitName, Collections.<String, Object>emptyMap());
+ List<Struct> traitInfo = new LinkedList<>();
+ Struct trait = new Struct(traitName, Collections.<String, Object>emptyMap());
traitInfo.add(trait);
EntityNotificationImpl entityNotification =
@@ -80,36 +79,35 @@ public class EntityNotificationImplTest {
@Test
public void testGetAllTraitsSuperTraits() throws Exception {
-
- TypeSystem typeSystem = mock(TypeSystem.class);
+ AtlasTypeRegistry typeRegistry = mock(AtlasTypeRegistry.class);
String traitName = "MyTrait";
- IStruct myTrait = new Struct(traitName);
+ Struct myTrait = new Struct(traitName);
String superTraitName = "MySuperTrait";
- TraitType traitDef = mock(TraitType.class);
+ AtlasClassificationType traitType = mock(AtlasClassificationType.class);
Set<String> superTypeNames = Collections.singleton(superTraitName);
- TraitType superTraitDef = mock(TraitType.class);
+ AtlasClassificationType superTraitType = mock(AtlasClassificationType.class);
Set<String> superSuperTypeNames = Collections.emptySet();
Referenceable entity = getEntity("id", myTrait);
- when(typeSystem.getDataType(TraitType.class, traitName)).thenReturn(traitDef);
- when(typeSystem.getDataType(TraitType.class, superTraitName)).thenReturn(superTraitDef);
+ when(typeRegistry.getClassificationTypeByName(traitName)).thenReturn(traitType);
+ when(typeRegistry.getClassificationTypeByName(superTraitName)).thenReturn(superTraitType);
- when(traitDef.getAllSuperTypeNames()).thenReturn(superTypeNames);
- when(superTraitDef.getAllSuperTypeNames()).thenReturn(superSuperTypeNames);
+ when(traitType.getAllSuperTypes()).thenReturn(superTypeNames);
+ when(superTraitType.getAllSuperTypes()).thenReturn(superSuperTypeNames);
EntityNotificationImpl entityNotification =
- new EntityNotificationImpl(entity, EntityNotification.OperationType.TRAIT_ADD, typeSystem);
+ new EntityNotificationImpl(entity, EntityNotification.OperationType.TRAIT_ADD, typeRegistry);
- List<IStruct> allTraits = entityNotification.getAllTraits();
+ List<Struct> allTraits = entityNotification.getAllTraits();
assertEquals(2, allTraits.size());
- for (IStruct trait : allTraits) {
+ for (Struct trait : allTraits) {
String typeName = trait.getTypeName();
assertTrue(typeName.equals(traitName) || typeName.equals(superTraitName));
}
@@ -121,24 +119,24 @@ public class EntityNotificationImplTest {
EntityNotificationImpl entityNotification2 =
new EntityNotificationImpl(entity, EntityNotification.OperationType.ENTITY_CREATE,
- Collections.<IStruct>emptyList());
+ Collections.<Struct>emptyList());
EntityNotificationImpl entityNotification =
new EntityNotificationImpl(entity, EntityNotification.OperationType.ENTITY_CREATE,
- Collections.<IStruct>emptyList());
+ Collections.<Struct>emptyList());
assertTrue(entityNotification.equals(entityNotification2));
assertTrue(entityNotification2.equals(entityNotification));
}
- public static Referenceable getEntity(String id, IStruct... traits) {
+ public static Referenceable getEntity(String id, Struct... traits) {
String typeName = "typeName";
Map<String, Object> values = new HashMap<>();
List<String> traitNames = new LinkedList<>();
- Map<String, IStruct> traitMap = new HashMap<>();
+ Map<String, Struct> traitMap = new HashMap<>();
- for (IStruct trait : traits) {
+ for (Struct trait : traits) {
String traitName = trait.getTypeName();
traitNames.add(traitName);