in repository/src/main/java/org/apache/atlas/repository/ogm/glossary/AtlasGlossaryTermDTO.java [51:220]
public AtlasGlossaryTerm from(final AtlasEntity entity) {
LOG.debug("==> AtlasGlossaryTermDTO.from({})", entity);
requireNonNull(entity, "entity");
AtlasGlossaryTerm ret = new AtlasGlossaryTerm();
ret.setGuid(entity.getGuid());
ret.setQualifiedName((String) entity.getAttribute("qualifiedName"));
ret.setName((String) entity.getAttribute("name"));
ret.setShortDescription((String) entity.getAttribute("shortDescription"));
ret.setLongDescription((String) entity.getAttribute("longDescription"));
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) {
LOG.debug("Processing anchor");
ret.setAnchor(constructGlossaryId((AtlasRelatedObjectId) anchor));
}
Object categories = entity.getRelationshipAttribute("categories");
if (categories instanceof Collection) {
LOG.debug("Processing categories");
for (Object category : (Collection<?>) categories) {
if (category instanceof AtlasRelatedObjectId) {
ret.addCategory(constructTermCategorizationId((AtlasRelatedObjectId) category));
}
}
}
// ret.setContextRelevantTerms(toRelatedObjectIdsSet(entity.getRelationshipAttribute("contextRelevantTerms")));
// ret.setUsedInContexts(toRelatedObjectIdsSet(entity.getRelationshipAttribute("usedInContexts")));
Object assignedEntities = entity.getRelationshipAttribute("assignedEntities");
if (assignedEntities instanceof Collection) {
LOG.debug("Processing assigned entities");
for (Object assignedEntity : (Collection<?>) assignedEntities) {
if (assignedEntity instanceof AtlasRelatedObjectId) {
AtlasRelatedObjectId id = (AtlasRelatedObjectId) assignedEntity;
// Since the edges are not a hard delete we need to filter the DELETED ones
if (id.getRelationshipStatus() == AtlasRelationship.Status.ACTIVE) {
ret.addAssignedEntity(id);
}
}
}
}
Object seeAlso = entity.getRelationshipAttribute("seeAlso");
if (seeAlso instanceof Collection && CollectionUtils.isNotEmpty((Collection<?>) seeAlso)) {
LOG.debug("Processing RelatedTerm(seeAlso)");
ret.setSeeAlso(toRelatedTermIdsSet(seeAlso));
}
Object synonyms = entity.getRelationshipAttribute("synonyms");
if (synonyms instanceof Collection && CollectionUtils.isNotEmpty((Collection<?>) synonyms)) {
LOG.debug("Processing Synonym(synonyms)");
ret.setSynonyms(toRelatedTermIdsSet(synonyms));
}
Object antonyms = entity.getRelationshipAttribute("antonyms");
if (antonyms instanceof Collection && CollectionUtils.isNotEmpty((Collection<?>) antonyms)) {
LOG.debug("Processing Antonym(antonyms)");
ret.setAntonyms(toRelatedTermIdsSet(antonyms));
}
Object preferredTerms = entity.getRelationshipAttribute("preferredTerms");
if (preferredTerms instanceof Collection && CollectionUtils.isNotEmpty((Collection<?>) preferredTerms)) {
LOG.debug("Processing preferredTerm(preferredTerms)");
ret.setPreferredTerms(toRelatedTermIdsSet(preferredTerms));
}
Object preferredToTerms = entity.getRelationshipAttribute("preferredToTerms");
if (preferredToTerms instanceof Collection && CollectionUtils.isNotEmpty((Collection<?>) preferredToTerms)) {
LOG.debug("Processing preferredTerm(preferredToTerms)");
ret.setPreferredToTerms(toRelatedTermIdsSet(preferredToTerms));
}
Object replacementTerms = entity.getRelationshipAttribute("replacementTerms");
if (replacementTerms instanceof Collection && CollectionUtils.isNotEmpty((Collection<?>) replacementTerms)) {
LOG.debug("Processing ReplacementTerm(replacementTerms)");
ret.setReplacementTerms(toRelatedTermIdsSet(replacementTerms));
}
Object replacedBy = entity.getRelationshipAttribute("replacedBy");
if (replacedBy instanceof Collection && CollectionUtils.isNotEmpty((Collection<?>) replacedBy)) {
LOG.debug("Processing ReplacementTerm(replacedBy)");
ret.setReplacedBy(toRelatedTermIdsSet(replacedBy));
}
Object translationTerms = entity.getRelationshipAttribute("translationTerms");
if (translationTerms instanceof Collection && CollectionUtils.isNotEmpty((Collection<?>) translationTerms)) {
LOG.debug("Processing Translation(translationTerms)");
ret.setTranslationTerms(toRelatedTermIdsSet(translationTerms));
}
Object translatedTerms = entity.getRelationshipAttribute("translatedTerms");
if (translatedTerms instanceof Collection && CollectionUtils.isNotEmpty((Collection<?>) translatedTerms)) {
LOG.debug("Processing Translation(translatedTerms)");
ret.setTranslatedTerms(toRelatedTermIdsSet(translatedTerms));
}
Object isA = entity.getRelationshipAttribute("isA");
if (isA instanceof Collection && CollectionUtils.isNotEmpty((Collection<?>) isA)) {
LOG.debug("Processing Classifies(isA)");
ret.setIsA(toRelatedTermIdsSet(isA));
}
Object classifies = entity.getRelationshipAttribute("classifies");
if (classifies instanceof Collection && CollectionUtils.isNotEmpty((Collection<?>) classifies)) {
LOG.debug("Processing Classifies(classifies)");
ret.setClassifies(toRelatedTermIdsSet(classifies));
}
Object validValues = entity.getRelationshipAttribute("validValues");
if (validValues instanceof Collection && CollectionUtils.isNotEmpty((Collection<?>) validValues)) {
LOG.debug("Processing validValue(validValues)");
ret.setValidValues(toRelatedTermIdsSet(validValues));
}
Object validValuesFor = entity.getRelationshipAttribute("validValuesFor");
if (validValuesFor instanceof Collection && CollectionUtils.isNotEmpty((Collection<?>) validValuesFor)) {
LOG.debug("Processing validValue(validValuesFor)");
ret.setValidValuesFor(toRelatedTermIdsSet(validValuesFor));
}
if (CollectionUtils.isNotEmpty(entity.getClassifications())) {
LOG.debug("Processing term classifications");
ret.setClassifications(entity.getClassifications());
}
LOG.debug("<== AtlasGlossaryTermDTO.from() : {}", ret);
return ret;
}