Commit 9044e037 by apoorvnaik

ATLAS-2700: Error message fix

ATLAS-2701: Usage attribute not getting persisted for term ATLAS-2702: Term qualifiedName not persisting after anchor change Change-Id: I23b53086b2bb2380f451e7d85b59096edc610181
parent 6bacbe94
...@@ -143,11 +143,11 @@ public enum AtlasErrorCode { ...@@ -143,11 +143,11 @@ public enum AtlasErrorCode {
RELATIONSHIP_END_IS_NULL(400, "ATLAS-400-00-07D", "Relationship end is invalid. Expected {0} but is NULL"), RELATIONSHIP_END_IS_NULL(400, "ATLAS-400-00-07D", "Relationship end is invalid. Expected {0} but is NULL"),
INVALID_TERM_RELATION_TO_SELF(400, "ATLAS-400-00-07E", "Invalid Term relationship: Term can't have a relationship with self"), INVALID_TERM_RELATION_TO_SELF(400, "ATLAS-400-00-07E", "Invalid Term relationship: Term can't have a relationship with self"),
INVALID_CHILD_CATEGORY_DIFFERENT_GLOSSARY(400, "ATLAS-400-00-07F", "Invalid child category relationship: Child category (guid = {0}) belongs to different glossary"), INVALID_CHILD_CATEGORY_DIFFERENT_GLOSSARY(400, "ATLAS-400-00-07F", "Invalid child category relationship: Child category (guid = {0}) belongs to different glossary"),
INVALID_TERM_DISSOCIATION(400, "ATLAS-400-00-080", "Given term (guid={0}) is not associated to entity(guid={1})"), INVALID_TERM_DISSOCIATION(400, "ATLAS-400-00-080", "Given relationshipGuid({0}) is invalid for term (guid={1}) and entity(guid={2})"),
ATTRIBUTE_TYPE_INVALID(400, "ATLAS-400-00-081", "{0}.{1}: invalid attribute type. Attribute cannot be of type classification"), ATTRIBUTE_TYPE_INVALID(400, "ATLAS-400-00-081", "{0}.{1}: invalid attribute type. Attribute cannot be of type classification"),
MISSING_CATEGORY_DISPLAY_NAME(400, "ATLAS-400-00-082", "Category displayName is empty/null"), MISSING_CATEGORY_DISPLAY_NAME(400, "ATLAS-400-00-082", "Category displayName is empty/null"),
INVALID_DISPLAY_NAME(400, "ATLAS-400-00-083", "displayName cannot contain following special chars ('@', '.')"), INVALID_DISPLAY_NAME(400, "ATLAS-400-00-083", "displayName cannot contain following special chars ('@', '.')"),
TERM_HAS_ENTITY_ASSOCIATION(400, "ATLAS-400-00-086", "Term (guid={}) can't be deleted as it has been assigned to {} entities."), TERM_HAS_ENTITY_ASSOCIATION(400, "ATLAS-400-00-086", "Term (guid={0}) can't be deleted as it has been assigned to {1} entities."),
UNAUTHORIZED_ACCESS(403, "ATLAS-403-00-001", "{0} is not authorized to perform {1}"), UNAUTHORIZED_ACCESS(403, "ATLAS-403-00-001", "{0} is not authorized to perform {1}"),
......
...@@ -348,7 +348,12 @@ public class GlossaryService { ...@@ -348,7 +348,12 @@ public class GlossaryService {
glossaryTermUtils.processTermRelations(storeObject, glossaryTerm, GlossaryUtils.RelationshipOperation.CREATE); glossaryTermUtils.processTermRelations(storeObject, glossaryTerm, GlossaryUtils.RelationshipOperation.CREATE);
// Re-load term after handling relations // Re-load term after handling relations
storeObject = dataAccess.load(glossaryTerm); if (StringUtils.equals(storeObject.getQualifiedName(), glossaryTerm.getQualifiedName())) {
storeObject = dataAccess.load(glossaryTerm);
} else {
glossaryTerm.setQualifiedName(storeObject.getQualifiedName());
storeObject = dataAccess.save(glossaryTerm);
}
setInfoForRelations(storeObject); setInfoForRelations(storeObject);
if (DEBUG_ENABLED) { if (DEBUG_ENABLED) {
...@@ -409,11 +414,17 @@ public class GlossaryService { ...@@ -409,11 +414,17 @@ public class GlossaryService {
LOG.debug("Glossary term had no immediate attr updates. Exception: {}", e.getMessage()); LOG.debug("Glossary term had no immediate attr updates. Exception: {}", e.getMessage());
} finally { } finally {
glossaryTermUtils.processTermRelations(storeObject, atlasGlossaryTerm, GlossaryUtils.RelationshipOperation.UPDATE); glossaryTermUtils.processTermRelations(storeObject, atlasGlossaryTerm, GlossaryUtils.RelationshipOperation.UPDATE);
}
// If qualifiedName changes due to anchor change, we need to persist the term again with updated qualifiedName
if (StringUtils.equals(storeObject.getQualifiedName(), atlasGlossaryTerm.getQualifiedName())) {
storeObject = dataAccess.load(atlasGlossaryTerm);
} else {
atlasGlossaryTerm.setQualifiedName(storeObject.getQualifiedName());
storeObject = dataAccess.save(atlasGlossaryTerm);
}
}
} }
storeObject = dataAccess.load(atlasGlossaryTerm);
setInfoForRelations(storeObject); setInfoForRelations(storeObject);
if (DEBUG_ENABLED) { if (DEBUG_ENABLED) {
...@@ -539,11 +550,11 @@ public class GlossaryService { ...@@ -539,11 +550,11 @@ public class GlossaryService {
dataAccess.save(impactedCategories.values()); dataAccess.save(impactedCategories.values());
// Since the current category is also affected, we need to update qualifiedName and save again // Since the current category is also affected, we need to update qualifiedName and save again
if (!StringUtils.equals(glossaryCategory.getQualifiedName(), storeObject.getQualifiedName())) { if (StringUtils.equals(glossaryCategory.getQualifiedName(), storeObject.getQualifiedName())) {
storeObject = dataAccess.load(glossaryCategory);
} else {
glossaryCategory.setQualifiedName(storeObject.getQualifiedName()); glossaryCategory.setQualifiedName(storeObject.getQualifiedName());
storeObject = dataAccess.save(glossaryCategory); storeObject = dataAccess.save(glossaryCategory);
} else {
storeObject = dataAccess.load(glossaryCategory);
} }
setInfoForRelations(storeObject); setInfoForRelations(storeObject);
......
...@@ -121,7 +121,7 @@ public class GlossaryTermUtils extends GlossaryUtils { ...@@ -121,7 +121,7 @@ public class GlossaryTermUtils extends GlossaryUtils {
if (CollectionUtils.isNotEmpty(assignedEntities) && isRelationshipGuidSame(existingTermRelation, relatedObjectId)) { if (CollectionUtils.isNotEmpty(assignedEntities) && isRelationshipGuidSame(existingTermRelation, relatedObjectId)) {
relationshipStore.deleteById(relatedObjectId.getRelationshipGuid()); relationshipStore.deleteById(relatedObjectId.getRelationshipGuid());
} else { } else {
throw new AtlasBaseException(AtlasErrorCode.INVALID_TERM_DISSOCIATION, glossaryTerm.getGuid(), relatedObjectId.getGuid()); throw new AtlasBaseException(AtlasErrorCode.INVALID_TERM_DISSOCIATION, relatedObjectId.getRelationshipGuid(), glossaryTerm.getGuid(), relatedObjectId.getGuid());
} }
} }
} }
......
...@@ -60,6 +60,7 @@ public class AtlasGlossaryTermDTO extends AbstractGlossaryDTO<AtlasGlossaryTerm> ...@@ -60,6 +60,7 @@ public class AtlasGlossaryTermDTO extends AbstractGlossaryDTO<AtlasGlossaryTerm>
ret.setLongDescription((String) entity.getAttribute("longDescription")); ret.setLongDescription((String) entity.getAttribute("longDescription"));
ret.setExamples((List<String>) entity.getAttribute("examples")); ret.setExamples((List<String>) entity.getAttribute("examples"));
ret.setAbbreviation((String) entity.getAttribute("abbreviation")); ret.setAbbreviation((String) entity.getAttribute("abbreviation"));
ret.setUsage((String) entity.getAttribute("usage"));
Object anchor = entity.getRelationshipAttribute("anchor"); Object anchor = entity.getRelationshipAttribute("anchor");
if (anchor instanceof AtlasRelatedObjectId) { if (anchor instanceof AtlasRelatedObjectId) {
...@@ -212,6 +213,7 @@ public class AtlasGlossaryTermDTO extends AbstractGlossaryDTO<AtlasGlossaryTerm> ...@@ -212,6 +213,7 @@ public class AtlasGlossaryTermDTO extends AbstractGlossaryDTO<AtlasGlossaryTerm>
ret.setAttribute("longDescription", obj.getLongDescription()); ret.setAttribute("longDescription", obj.getLongDescription());
ret.setAttribute("examples", obj.getExamples()); ret.setAttribute("examples", obj.getExamples());
ret.setAttribute("abbreviation", obj.getAbbreviation()); ret.setAttribute("abbreviation", obj.getAbbreviation());
ret.setAttribute("usage", obj.getUsage());
if (CollectionUtils.isNotEmpty(obj.getClassifications())) { if (CollectionUtils.isNotEmpty(obj.getClassifications())) {
if (LOG.isDebugEnabled()) { 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