@Override public boolean evaluate(Object o) { return (isClassificationType(o) && ((AtlasClassificationType) o).getAllSuperTypes().contains(supertype))|| (isEntityType(o) && ((AtlasEntityType)o).getAllSuperTypes().contains(supertype)); } };
private void addClassificationType(AtlasClassificationType classificationType, ExportContext context) { if (!context.classificationTypes.contains(classificationType.getTypeName())) { context.classificationTypes.add(classificationType.getTypeName()); addAttributeTypes(classificationType, context); if (CollectionUtils.isNotEmpty(classificationType.getAllSuperTypes())) { for (String superType : classificationType.getAllSuperTypes()) { addClassificationType(superType, context); } } } }
private void addClassificationType(AtlasClassificationType classificationType, ExportService.ExportContext context) { if (!context.classificationTypes.contains(classificationType.getTypeName())) { context.classificationTypes.add(classificationType.getTypeName()); addAttributeTypes(classificationType, context); if (CollectionUtils.isNotEmpty(classificationType.getAllSuperTypes())) { for (String superType : classificationType.getAllSuperTypes()) { addClassificationType(superType, context); } } } }
@Override public boolean evaluate(Object o) { return (isClassificationType(o) && ((AtlasClassificationType) o).getAllSuperTypes().contains(supertype)) || (isEntityType(o) && ((AtlasEntityType) o).getAllSuperTypes().contains(supertype)); } };
@VisibleForTesting public static List<Struct> getAllTraits(Referenceable entityDefinition, AtlasTypeRegistry typeRegistry) throws AtlasException { List<Struct> ret = new ArrayList<>(); for (String traitName : entityDefinition.getTraitNames()) { Struct trait = entityDefinition.getTrait(traitName); AtlasClassificationType traitType = typeRegistry.getClassificationTypeByName(traitName); Set<String> superTypeNames = traitType != null ? traitType.getAllSuperTypes() : null; ret.add(trait); if (CollectionUtils.isNotEmpty(superTypeNames)) { for (String superTypeName : superTypeNames) { Struct superTypeTrait = new Struct(superTypeName); if (MapUtils.isNotEmpty(trait.getValues())) { AtlasClassificationType superType = typeRegistry.getClassificationTypeByName(superTypeName); if (superType != null && MapUtils.isNotEmpty(superType.getAllAttributes())) { Map<String, Object> superTypeTraitAttributes = new HashMap<>(); for (Map.Entry<String, Object> attrEntry : trait.getValues().entrySet()) { String attrName = attrEntry.getKey(); if (superType.getAllAttributes().containsKey(attrName)) { superTypeTraitAttributes.put(attrName, attrEntry.getValue()); } } superTypeTrait.setValues(superTypeTraitAttributes); } } ret.add(superTypeTrait); } } } return ret; }
Struct trait = entityDefinition.getTrait(traitName); AtlasClassificationType traitType = typeRegistry.getClassificationTypeByName(traitName); Set<String> superTypeNames = traitType != null ? traitType.getAllSuperTypes() : null;
Struct trait = entityDefinition.getTrait(traitName); AtlasClassificationType traitType = typeRegistry.getClassificationTypeByName(traitName); Set<String> superTypeNames = traitType != null ? traitType.getAllSuperTypes() : null;
private void validateAllSuperTypes(AtlasTypeRegistry typeRegistry, String typeName, Set<String> expectedSuperTypes) { AtlasType type = null; try { type = typeRegistry.getType(typeName); } catch (AtlasBaseException excp) { } Set<String> superTypes = null; if (type != null) { if (type instanceof AtlasEntityType) { superTypes = ((AtlasEntityType) type).getAllSuperTypes(); } else if (type instanceof AtlasClassificationType) { superTypes = ((AtlasClassificationType) type).getAllSuperTypes(); } } assertEquals(superTypes, expectedSuperTypes); }
for (AtlasClassification classification : classifications) { AtlasClassificationType classificationType = typeRegistry.getClassificationTypeByName(classification.getTypeName()); Set<String> superTypeNames = classificationType != null ? classificationType.getAllSuperTypes() : null;
private AtlasVertex createClassificationVertex(AtlasClassification classification) { if (LOG.isDebugEnabled()) { LOG.debug("==> createVertex({})", classification.getTypeName()); } AtlasClassificationType classificationType = typeRegistry.getClassificationTypeByName(classification.getTypeName()); AtlasVertex ret = createStructVertex(classification); AtlasGraphUtilsV2.addEncodedProperty(ret, SUPER_TYPES_PROPERTY_KEY, classificationType.getAllSuperTypes()); AtlasGraphUtilsV2.setEncodedProperty(ret, CLASSIFICATION_ENTITY_GUID, classification.getEntityGuid()); AtlasGraphUtilsV2.setEncodedProperty(ret, CLASSIFICATION_ENTITY_STATUS, classification.getEntityStatus().name()); return ret; }
private AtlasVertex createClassificationVertex(AtlasClassification classification) { if (LOG.isDebugEnabled()) { LOG.debug("==> createVertex({})", classification.getTypeName()); } AtlasClassificationType classificationType = typeRegistry.getClassificationTypeByName(classification.getTypeName()); AtlasVertex ret = createStructVertex(classification); AtlasGraphUtilsV2.addEncodedProperty(ret, SUPER_TYPES_PROPERTY_KEY, classificationType.getAllSuperTypes()); AtlasGraphUtilsV2.setEncodedProperty(ret, CLASSIFICATION_ENTITY_GUID, classification.getEntityGuid()); AtlasGraphUtilsV2.setEncodedProperty(ret, CLASSIFICATION_ENTITY_STATUS, classification.getEntityStatus().name()); return ret; }