Commit 5b8b16eb by mayanknj Committed by nixonrodrigues

ATLAS-3206 - Additional attribute for AtlasGlossary, AtlasGlossaryTerm & AtlasGlossaryCategory.

parent 8127189c
......@@ -86,7 +86,7 @@
"__internal"
],
"serviceType": "atlas_core",
"typeVersion": "1.0",
"typeVersion": "1.1",
"attributeDefs": [
{
"name": "qualifiedName",
......@@ -135,8 +135,18 @@
"isIndexable": false,
"isOptional": true,
"isUnique": false
},
{
"name": "additionalAttributes",
"typeName": "map<string,string>",
"cardinality": "SINGLE",
"isIndexable": false,
"isOptional": true,
"isUnique": false
}
]
},
{
"name": "AtlasGlossaryTerm",
......@@ -144,7 +154,7 @@
"__internal"
],
"serviceType": "atlas_core",
"typeVersion": "1.0",
"typeVersion": "1.1",
"attributeDefs": [
{
"name": "qualifiedName",
......@@ -201,8 +211,18 @@
"isIndexable": false,
"isOptional": true,
"isUnique": false
},
{
"name": "additionalAttributes",
"typeName": "map<string,string>",
"cardinality": "SINGLE",
"isIndexable": false,
"isOptional": true,
"isUnique": false
}
]
},
{
"name": "AtlasGlossaryCategory",
......@@ -210,7 +230,7 @@
"__internal"
],
"serviceType": "atlas_core",
"typeVersion": "1.0",
"typeVersion": "1.1",
"attributeDefs": [
{
"name": "qualifiedName",
......@@ -243,6 +263,14 @@
"isIndexable": false,
"isOptional": true,
"isUnique": false
},
{
"name": "additionalAttributes",
"typeName": "map<string,string>",
"cardinality": "SINGLE",
"isIndexable": false,
"isOptional": true,
"isUnique": false
}
]
}
......@@ -895,4 +923,4 @@
]
}
]
}
}
\ No newline at end of file
{
"patches": [
{
"id": "TYPEDEF_PATCH_0001_004",
"description": "Add 'additionalAttributes' attribute to AtlasGlossary",
"action": "ADD_ATTRIBUTE",
"typeName": "AtlasGlossary",
"applyToVersion": "1.1",
"updateToVersion": "1.2",
"params": null,
"attributeDefs": [
{
"name": "additionalAttributes",
"typeName": "map<string,string>",
"cardinality": "SINGLE",
"isIndexable": false,
"isOptional": true,
"isUnique": false
}
]
},
{
"id": "TYPEDEF_PATCH_0002_004",
"description": "Add 'additionalAttributes' attribute to AtlasGlossaryTerm",
"action": "ADD_ATTRIBUTE",
"typeName": "AtlasGlossaryTerm",
"applyToVersion": "1.1",
"updateToVersion": "1.2",
"params": null,
"attributeDefs": [
{
"name": "additionalAttributes",
"typeName": "map<string,string>",
"cardinality": "SINGLE",
"isIndexable": false,
"isOptional": true,
"isUnique": false
}
]
},
{
"id": "TYPEDEF_PATCH_0003_004",
"description": "Add 'additionalAttributes' attribute to AtlasGlossaryCategory",
"action": "ADD_ATTRIBUTE",
"typeName": "AtlasGlossaryCategory",
"applyToVersion": "1.1",
"updateToVersion": "1.2",
"params": null,
"attributeDefs": [
{
"name": "additionalAttributes",
"typeName": "map<string,string>",
"cardinality": "SINGLE",
"isIndexable": false,
"isOptional": true,
"isUnique": false
}
]
}
]
}
......@@ -25,14 +25,17 @@ import org.apache.commons.collections.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Map;
public abstract class AtlasGlossaryBaseObject extends AtlasBaseModelObject {
// Core attributes
private String qualifiedName;
private String qualifiedName;
protected String name;
protected String shortDescription;
protected String longDescription;
private Map<String, Object> additionalAttributes;
// Classifications
protected List<AtlasClassification> classifications;
......@@ -47,6 +50,15 @@ public abstract class AtlasGlossaryBaseObject extends AtlasBaseModelObject {
this.longDescription = other.longDescription;
this.classifications = other.classifications;
this.qualifiedName = other.qualifiedName;
this.additionalAttributes = other.additionalAttributes;
}
public Map<String, Object> getAdditionalAttributes() {
return additionalAttributes;
}
public void setAdditionalAttributes(Map<String, Object> additionalAttributes) {
this.additionalAttributes = additionalAttributes;
}
public String getQualifiedName() {
......@@ -109,22 +121,22 @@ public abstract class AtlasGlossaryBaseObject extends AtlasBaseModelObject {
}
@Override
public boolean equals(final Object o) {
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof AtlasGlossaryBaseObject)) return false;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
final AtlasGlossaryBaseObject that = (AtlasGlossaryBaseObject) o;
return Objects.equals(name, that.name) &&
Objects.equals(shortDescription, that.shortDescription) &&
Objects.equals(longDescription, that.longDescription) &&
Objects.equals(classifications, that.classifications) &&
Objects.equals(qualifiedName, that.qualifiedName);
AtlasGlossaryBaseObject that = (AtlasGlossaryBaseObject) o;
return Objects.equals(qualifiedName, that.qualifiedName) &&
Objects.equals(name, that.name) &&
Objects.equals(shortDescription, that.shortDescription) &&
Objects.equals(longDescription, that.longDescription) &&
Objects.equals(additionalAttributes, that.additionalAttributes) &&
Objects.equals(classifications, that.classifications);
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), name, shortDescription, longDescription, classifications, qualifiedName);
return Objects.hash(super.hashCode(), qualifiedName, name, shortDescription, longDescription, additionalAttributes, classifications);
}
@Override
......@@ -133,7 +145,8 @@ public abstract class AtlasGlossaryBaseObject extends AtlasBaseModelObject {
sb.append(", name='").append(name).append('\'');
sb.append(", shortDescription='").append(shortDescription).append('\'');
sb.append(", longDescription='").append(longDescription).append('\'');
sb.append(", classifications=").append(classifications);
sb.append(", classifications=").append(classifications).append('\'');
sb.append(", additionalAttributes=").append(additionalAttributes);
return sb;
}
......
......@@ -29,10 +29,10 @@ import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Collection;
@Component
public class AtlasGlossaryCategoryDTO extends AbstractGlossaryDTO<AtlasGlossaryCategory> {
......@@ -57,6 +57,7 @@ public class AtlasGlossaryCategoryDTO extends AbstractGlossaryDTO<AtlasGlossaryC
ret.setName((String) entity.getAttribute("name"));
ret.setShortDescription((String) entity.getAttribute("shortDescription"));
ret.setLongDescription((String) entity.getAttribute("longDescription"));
ret.setAdditionalAttributes((Map) entity.getAttribute("additionalAttributes"));
Object anchor = entity.getRelationshipAttribute("anchor");
if (anchor instanceof AtlasRelatedObjectId) {
......@@ -125,6 +126,7 @@ public class AtlasGlossaryCategoryDTO extends AbstractGlossaryDTO<AtlasGlossaryC
ret.setAttribute("shortDescription", obj.getShortDescription());
ret.setAttribute("longDescription", obj.getLongDescription());
ret.setAttribute("anchor", new AtlasObjectId(obj.getAnchor().getGlossaryGuid()));
ret.setAttribute("additionalAttributes", obj.getAdditionalAttributes());
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasGlossaryCategoryDTO.toEntity() : {}", ret);
......
......@@ -58,9 +58,10 @@ public class AtlasGlossaryDTO extends AbstractGlossaryDTO<AtlasGlossary> {
ret.setLongDescription((String) entity.getAttribute("longDescription"));
ret.setLanguage((String) entity.getAttribute("language"));
ret.setUsage((String) entity.getAttribute("usage"));
ret.setAdditionalAttributes((Map) entity.getAttribute("additionalAttributes"));
Object categoriesAttr = entity.getRelationshipAttribute("categories");
Object termsAttr = entity.getRelationshipAttribute("terms");
Object termsAttr = entity.getRelationshipAttribute("terms");
// Populate categories
if (Objects.nonNull(categoriesAttr)) {
......@@ -92,7 +93,7 @@ public class AtlasGlossaryDTO extends AbstractGlossaryDTO<AtlasGlossary> {
@Override
public AtlasGlossary from(final AtlasEntity.AtlasEntityWithExtInfo entityWithExtInfo) {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasGlossaryDTO.from()",entityWithExtInfo);
LOG.debug("==> AtlasGlossaryDTO.from()", entityWithExtInfo);
}
Objects.requireNonNull(entityWithExtInfo, "entity");
AtlasGlossary ret = from(entityWithExtInfo.getEntity());
......@@ -119,6 +120,7 @@ public class AtlasGlossaryDTO extends AbstractGlossaryDTO<AtlasGlossary> {
ret.setAttribute("longDescription", obj.getLongDescription());
ret.setAttribute("language", obj.getLanguage());
ret.setAttribute("usage", obj.getUsage());
ret.setAttribute("additionalAttributes", obj.getAdditionalAttributes());
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasGlossaryDTO.toEntity() : {}", ret);
......
......@@ -63,6 +63,7 @@ public class AtlasGlossaryTermDTO extends AbstractGlossaryDTO<AtlasGlossaryTerm>
ret.setExamples((List<String>) entity.getAttribute("examples"));
ret.setAbbreviation((String) entity.getAttribute("abbreviation"));
ret.setUsage((String) entity.getAttribute("usage"));
ret.setAdditionalAttributes((Map) entity.getAttribute("additionalAttributes"));
Object anchor = entity.getRelationshipAttribute("anchor");
if (anchor instanceof AtlasRelatedObjectId) {
......@@ -220,6 +221,7 @@ public class AtlasGlossaryTermDTO extends AbstractGlossaryDTO<AtlasGlossaryTerm>
ret.setAttribute("abbreviation", obj.getAbbreviation());
ret.setAttribute("usage", obj.getUsage());
ret.setAttribute("anchor", new AtlasObjectId(obj.getAnchor().getGlossaryGuid()));
ret.setAttribute("additionalAttributes", obj.getAdditionalAttributes());
if (CollectionUtils.isNotEmpty(obj.getClassifications())) {
if (LOG.isDebugEnabled()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment