http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/intg/src/main/java/org/apache/atlas/v1/model/notification/HookNotificationV1.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/v1/model/notification/HookNotificationV1.java b/intg/src/main/java/org/apache/atlas/v1/model/notification/HookNotificationV1.java new file mode 100644 index 0000000..c70e7d0 --- /dev/null +++ b/intg/src/main/java/org/apache/atlas/v1/model/notification/HookNotificationV1.java @@ -0,0 +1,357 @@ +/** + * 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.v1.model.notification; + +import org.apache.atlas.model.notification.HookNotification; +import org.apache.atlas.model.typedef.AtlasBaseTypeDef; +import org.apache.atlas.v1.model.instance.Referenceable; +import org.apache.atlas.v1.model.typedef.TypesDef; +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.Arrays; +import java.util.List; + +import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE; +import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY; + +/** + * Contains the structure of messages transferred from hooks to atlas. + */ +public class HookNotificationV1 { + + /** + * Hook message for create type definitions. + */ + @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) + @JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS) + @JsonIgnoreProperties(ignoreUnknown=true) + @XmlRootElement + @XmlAccessorType(XmlAccessType.PROPERTY) + public static class TypeRequest extends HookNotification implements Serializable { + private static final long serialVersionUID = 1L; + + private TypesDef typesDef; + + public TypeRequest() { + } + + public TypeRequest(HookNotificationType type, TypesDef typesDef, String user) { + super(type, user); + this.typesDef = typesDef; + } + + public TypesDef getTypesDef() { + return typesDef; + } + + public void setTypesDef(TypesDef typesDef) { + this.typesDef = typesDef; + } + + @Override + public StringBuilder toString(StringBuilder sb) { + if (sb == null) { + sb = new StringBuilder(); + } + + sb.append("TypeRequest{"); + super.toString(sb); + sb.append("typesDef="); + if (typesDef != null) { + typesDef.toString(sb); + } + sb.append("}"); + + return sb; + } + } + + /** + * Hook message for creating new entities. + */ + @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) + @JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS) + @JsonIgnoreProperties(ignoreUnknown=true) + @XmlRootElement + @XmlAccessorType(XmlAccessType.PROPERTY) + public static class EntityCreateRequest extends HookNotification implements Serializable { + private static final long serialVersionUID = 1L; + + private List<Referenceable> entities; + + public EntityCreateRequest() { + } + + public EntityCreateRequest(String user, Referenceable... entities) { + this(HookNotificationType.ENTITY_CREATE, Arrays.asList(entities), user); + } + + public EntityCreateRequest(String user, List<Referenceable> entities) { + this(HookNotificationType.ENTITY_CREATE, entities, user); + } + + protected EntityCreateRequest(HookNotificationType type, List<Referenceable> entities, String user) { + super(type, user); + + this.entities = entities; + } + + public List<Referenceable> getEntities() { + return entities; + } + + public void setEntities(List<Referenceable> entities) { + this.entities = entities; + } + + @Override + public void normalize() { + super.normalize(); + + if (entities != null) { + for (Referenceable entity : entities) { + if (entity != null) { + entity.normailze(); + } + } + } + } + + @Override + public StringBuilder toString(StringBuilder sb) { + if (sb == null) { + sb = new StringBuilder(); + } + + sb.append("EntityCreateRequest{"); + super.toString(sb); + sb.append("entities=["); + AtlasBaseTypeDef.dumpObjects(getEntities(), sb); + sb.append("]"); + sb.append("}"); + + return sb; + } + } + + /** + * Hook message for updating entities(full update). + */ + @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) + @JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS) + @JsonIgnoreProperties(ignoreUnknown=true) + @XmlRootElement + @XmlAccessorType(XmlAccessType.PROPERTY) + public static class EntityUpdateRequest extends EntityCreateRequest implements Serializable { + private static final long serialVersionUID = 1L; + + public EntityUpdateRequest() { + } + + public EntityUpdateRequest(String user, Referenceable... entities) { + this(user, Arrays.asList(entities)); + } + + public EntityUpdateRequest(String user, List<Referenceable> entities) { + super(HookNotificationType.ENTITY_FULL_UPDATE, entities, user); + } + + @Override + public StringBuilder toString(StringBuilder sb) { + if (sb == null) { + sb = new StringBuilder(); + } + + sb.append("EntityUpdateRequest{"); + super.toString(sb); + sb.append("entities=["); + AtlasBaseTypeDef.dumpObjects(getEntities(), sb); + sb.append("]"); + sb.append("}"); + + return sb; + } + } + + /** + * Hook message for updating entities(partial update). + */ + @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) + @JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS) + @JsonIgnoreProperties(ignoreUnknown=true) + @XmlRootElement + @XmlAccessorType(XmlAccessType.PROPERTY) + public static class EntityPartialUpdateRequest extends HookNotification { + private static final long serialVersionUID = 1L; + + private String typeName; + private String attribute; + private String attributeValue; + private Referenceable entity; + + public EntityPartialUpdateRequest() { + } + + public EntityPartialUpdateRequest(String user, String typeName, String attribute, String attributeValue, Referenceable entity) { + super(HookNotificationType.ENTITY_PARTIAL_UPDATE, user); + + this.typeName = typeName; + this.attribute = attribute; + this.attributeValue = attributeValue; + this.entity = entity; + } + + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + public String getAttribute() { + return attribute; + } + + public void setAttribute(String attribute) { + this.attribute = attribute; + } + + public String getAttributeValue() { + return attributeValue; + } + + public void setAttributeValue(String attributeValue) { + this.attributeValue = attributeValue; + } + + public Referenceable getEntity() { + return entity; + } + + public void setEntity(Referenceable entity) { + this.entity = entity; + } + + @Override + public void normalize() { + super.normalize(); + + if (entity != null) { + entity.normailze(); + } + } + + @Override + public StringBuilder toString(StringBuilder sb) { + if (sb == null) { + sb = new StringBuilder(); + } + + sb.append("EntityPartialUpdateRequest{"); + super.toString(sb); + sb.append("typeName=").append(typeName); + sb.append("attribute=").append(attribute); + sb.append("attributeValue=").append(attributeValue); + sb.append("entity="); + if (entity != null) { + entity.toString(sb); + } + sb.append("}"); + + return sb; + } + } + + /** + * Hook message for entity delete. + */ + @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) + @JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS) + @JsonIgnoreProperties(ignoreUnknown=true) + @XmlRootElement + @XmlAccessorType(XmlAccessType.PROPERTY) + public static class EntityDeleteRequest extends HookNotification implements Serializable { + private static final long serialVersionUID = 1L; + + private String typeName; + private String attribute; + private String attributeValue; + + public EntityDeleteRequest() { + } + + public EntityDeleteRequest(String user, String typeName, String attribute, String attributeValue) { + this(HookNotificationType.ENTITY_DELETE, user, typeName, attribute, attributeValue); + } + + protected EntityDeleteRequest(HookNotificationType type, String user, String typeName, String attribute, String attributeValue) { + super(type, user); + + this.typeName = typeName; + this.attribute = attribute; + this.attributeValue = attributeValue; + } + + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + public String getAttribute() { + return attribute; + } + + public void setAttribute(String attribute) { + this.attribute = attribute; + } + + public String getAttributeValue() { + return attributeValue; + } + + public void setAttributeValue(String attributeValue) { + this.attributeValue = attributeValue; + } + + @Override + public StringBuilder toString(StringBuilder sb) { + if (sb == null) { + sb = new StringBuilder(); + } + + sb.append("EntityDeleteRequest{"); + super.toString(sb); + sb.append("typeName=").append(typeName); + sb.append("attribute=").append(attribute); + sb.append("attributeValue=").append(attributeValue); + sb.append("}"); + + return sb; + } + } +}
http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/intg/src/main/java/org/apache/atlas/v1/model/typedef/AttributeDefinition.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/v1/model/typedef/AttributeDefinition.java b/intg/src/main/java/org/apache/atlas/v1/model/typedef/AttributeDefinition.java new file mode 100644 index 0000000..a64425c --- /dev/null +++ b/intg/src/main/java/org/apache/atlas/v1/model/typedef/AttributeDefinition.java @@ -0,0 +1,179 @@ +/** + * 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.v1.model.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. + private String defaultValue; + private String description; + + + + 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; + } + + public String getDefaultValue() { + return defaultValue; + } + + public void setDefaultValue(final String defaultValue) { + this.defaultValue = defaultValue; + } + + public String getDescription() { + return description; + } + + public void setDescription(final String description) { + this.description = description; + } + + @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(defaultValue, that.defaultValue) && + Objects.equals(description, that.description) && + Objects.equals(reverseAttributeName, that.reverseAttributeName); + } + + @Override + public int hashCode() { + return Objects.hash(name, dataTypeName, multiplicity, isComposite, isUnique, isIndexable, + reverseAttributeName, defaultValue, description); + } +} http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/intg/src/main/java/org/apache/atlas/v1/model/typedef/ClassTypeDefinition.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/v1/model/typedef/ClassTypeDefinition.java b/intg/src/main/java/org/apache/atlas/v1/model/typedef/ClassTypeDefinition.java new file mode 100644 index 0000000..9e7e03c --- /dev/null +++ b/intg/src/main/java/org/apache/atlas/v1/model/typedef/ClassTypeDefinition.java @@ -0,0 +1,57 @@ +/** + * 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.v1.model.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; + private static final String META_TYPE_NAME = "org.apache.atlas.typesystem.types.ClassType"; + + + public ClassTypeDefinition() { + } + + public ClassTypeDefinition(String typeName, String typeDescription, String typeVersion, List<AttributeDefinition> attributeDefinitions, Set<String> superTypes) { + super(typeName, typeDescription, typeVersion, attributeDefinitions, META_TYPE_NAME, superTypes); + } + + @Override + public String getHierarchicalMetaTypeName() { + return META_TYPE_NAME; + } +} http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/intg/src/main/java/org/apache/atlas/v1/model/typedef/EnumTypeDefinition.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/v1/model/typedef/EnumTypeDefinition.java b/intg/src/main/java/org/apache/atlas/v1/model/typedef/EnumTypeDefinition.java new file mode 100644 index 0000000..d2fdaf8 --- /dev/null +++ b/intg/src/main/java/org/apache/atlas/v1/model/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.v1.model.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/435fe3fb/intg/src/main/java/org/apache/atlas/v1/model/typedef/HierarchicalTypeDefinition.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/v1/model/typedef/HierarchicalTypeDefinition.java b/intg/src/main/java/org/apache/atlas/v1/model/typedef/HierarchicalTypeDefinition.java new file mode 100644 index 0000000..65d63a7 --- /dev/null +++ b/intg/src/main/java/org/apache/atlas/v1/model/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.v1.model.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/435fe3fb/intg/src/main/java/org/apache/atlas/v1/model/typedef/Multiplicity.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/v1/model/typedef/Multiplicity.java b/intg/src/main/java/org/apache/atlas/v1/model/typedef/Multiplicity.java new file mode 100644 index 0000000..653151b --- /dev/null +++ b/intg/src/main/java/org/apache/atlas/v1/model/typedef/Multiplicity.java @@ -0,0 +1,167 @@ +/** + * 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.v1.model.typedef; + +import org.codehaus.jackson.JsonGenerator; +import org.codehaus.jackson.JsonParser; +import org.codehaus.jackson.annotate.JsonAutoDetect; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; +import org.codehaus.jackson.map.DeserializationContext; +import org.codehaus.jackson.map.JsonDeserializer; +import org.codehaus.jackson.map.JsonSerializer; +import org.codehaus.jackson.map.SerializerProvider; +import org.codehaus.jackson.map.annotate.JsonDeserialize; +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.IOException; +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(using = Multiplicity.MultiplicitySerializer.class, include=JsonSerialize.Inclusion.NON_NULL) +@JsonDeserialize(using = Multiplicity.MultiplicityDeserializer.class) +@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); + } + + + 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/435fe3fb/intg/src/main/java/org/apache/atlas/v1/model/typedef/StructTypeDefinition.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/v1/model/typedef/StructTypeDefinition.java b/intg/src/main/java/org/apache/atlas/v1/model/typedef/StructTypeDefinition.java new file mode 100644 index 0000000..842439d --- /dev/null +++ b/intg/src/main/java/org/apache/atlas/v1/model/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.v1.model.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/435fe3fb/intg/src/main/java/org/apache/atlas/v1/model/typedef/TraitTypeDefinition.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/v1/model/typedef/TraitTypeDefinition.java b/intg/src/main/java/org/apache/atlas/v1/model/typedef/TraitTypeDefinition.java new file mode 100644 index 0000000..9caf62a --- /dev/null +++ b/intg/src/main/java/org/apache/atlas/v1/model/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.v1.model.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/435fe3fb/intg/src/main/java/org/apache/atlas/v1/model/typedef/TypesDef.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/v1/model/typedef/TypesDef.java b/intg/src/main/java/org/apache/atlas/v1/model/typedef/TypesDef.java new file mode 100644 index 0000000..6a8bcb4 --- /dev/null +++ b/intg/src/main/java/org/apache/atlas/v1/model/typedef/TypesDef.java @@ -0,0 +1,118 @@ +/** + * 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.v1.model.typedef; + +import org.apache.atlas.model.typedef.AtlasBaseTypeDef; +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.ALWAYS) +@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; + } + + + @Override + public String toString() { + return toString(new StringBuilder()).toString(); + } + + public StringBuilder toString(StringBuilder sb) { + if (sb == null) { + sb = new StringBuilder(); + } + + sb.append("TypesDef{"); + sb.append("enumTypes=["); + AtlasBaseTypeDef.dumpObjects(enumTypes, sb); + sb.append("], structTypes=["); + AtlasBaseTypeDef.dumpObjects(structTypes, sb); + sb.append("], traitTypes=["); + AtlasBaseTypeDef.dumpObjects(traitTypes, sb); + sb.append("], classTypes=["); + AtlasBaseTypeDef.dumpObjects(classTypes, sb); + sb.append("]"); + sb.append("}"); + + return sb; + } +} http://git-wip-us.apache.org/repos/asf/atlas/blob/435fe3fb/intg/src/main/java/org/apache/atlas/v1/typesystem/types/utils/TypesUtil.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/v1/typesystem/types/utils/TypesUtil.java b/intg/src/main/java/org/apache/atlas/v1/typesystem/types/utils/TypesUtil.java new file mode 100644 index 0000000..864623a --- /dev/null +++ b/intg/src/main/java/org/apache/atlas/v1/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.v1.typesystem.types.utils; + + +import org.apache.atlas.v1.model.typedef.AttributeDefinition; +import org.apache.atlas.v1.model.typedef.ClassTypeDefinition; +import org.apache.atlas.v1.model.typedef.Multiplicity; +import org.apache.atlas.v1.model.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/435fe3fb/intg/src/test/java/org/apache/atlas/TestRelationshipUtilsV2.java ---------------------------------------------------------------------- diff --git a/intg/src/test/java/org/apache/atlas/TestRelationshipUtilsV2.java b/intg/src/test/java/org/apache/atlas/TestRelationshipUtilsV2.java index d0effd6..02613b5 100755 --- a/intg/src/test/java/org/apache/atlas/TestRelationshipUtilsV2.java +++ b/intg/src/test/java/org/apache/atlas/TestRelationshipUtilsV2.java @@ -18,8 +18,6 @@ package org.apache.atlas; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo; @@ -38,10 +36,7 @@ import org.apache.commons.lang.StringUtils; import java.math.BigDecimal; import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.List; +import java.util.*; import static org.apache.atlas.model.typedef.AtlasRelationshipDef.PropagateTags.BOTH; import static org.apache.atlas.model.typedef.AtlasRelationshipDef.PropagateTags.ONE_TO_TWO; @@ -146,11 +141,11 @@ public final class TestRelationshipUtilsV2 { new AtlasRelationshipEndDef(PERSON_TYPE, "sibling", SINGLE), new AtlasRelationshipEndDef(PERSON_TYPE, "sibling", SINGLE)); - return new AtlasTypesDef(ImmutableList.of(orgLevelType), - ImmutableList.of(addressType), - ImmutableList.of(securityClearanceType), - ImmutableList.of(personType, employeeType, departmentType, managerType), - ImmutableList.of(employeeDepartmentType, employeeManagerType, employeeMentorsType, employeeFriendsType, personSiblingType)); + return new AtlasTypesDef(Collections.singletonList(orgLevelType), + Collections.singletonList(addressType), + Collections.singletonList(securityClearanceType), + Arrays.asList(personType, employeeType, departmentType, managerType), + Arrays.asList(employeeDepartmentType, employeeManagerType, employeeMentorsType, employeeFriendsType, personSiblingType)); } public static AtlasEntitiesWithExtInfo getDepartmentEmployeeInstances() { @@ -282,9 +277,8 @@ public final class TestRelationshipUtilsV2 { new AtlasRelationshipEndDef(TYPE_B, "mappedFromA", SINGLE), new AtlasRelationshipEndDef(TYPE_A, "mapToB", SET)); - return new AtlasTypesDef(ImmutableList.<AtlasEnumDef>of(), ImmutableList.<AtlasStructDef>of(), - ImmutableList.<AtlasClassificationDef>of(), ImmutableList.of(aType, bType), - ImmutableList.of(relationshipType1, relationshipType2, relationshipType3, relationshipType4)); + return new AtlasTypesDef(Collections.<AtlasEnumDef>emptyList(), Collections.<AtlasStructDef>emptyList(), Collections.<AtlasClassificationDef>emptyList(), Arrays.asList(aType, bType), + Arrays.asList(relationshipType1, relationshipType2, relationshipType3, relationshipType4)); } private static List<AtlasEnumElementDef> getOrgLevelElements() { @@ -299,8 +293,8 @@ public final class TestRelationshipUtilsV2 { return typeName + " description"; } - private static ImmutableSet<String> superType(String superTypeName) { - return StringUtils.isNotEmpty(superTypeName) ? ImmutableSet.of(superTypeName) : ImmutableSet.<String>of(); + private static Set<String> superType(String superTypeName) { + return StringUtils.isNotEmpty(superTypeName) ? Collections.singleton(superTypeName) : Collections.<String>emptySet(); } private static List<AtlasObjectId> getAtlasObjectIds(AtlasEntity... entities) {