public Set<String> getSuperTypes() { return classificationDef.getSuperTypes(); }
public Set<String> getSuperTypes() { return classificationDef.getSuperTypes(); }
public AtlasClassificationDef(AtlasClassificationDef other) { super(other); setSuperTypes(other != null ? other.getSuperTypes() : null); }
public AtlasClassificationDef(AtlasClassificationDef other) { super(other); setSuperTypes(other != null ? other.getSuperTypes() : null); }
@Override public void resolveReferences(AtlasTypeRegistry typeRegistry) throws AtlasBaseException { super.resolveReferences(typeRegistry); List<AtlasClassificationType> s = new ArrayList<>(); Set<String> allS = new HashSet<>(); Map<String, AtlasAttribute> allA = new HashMap<>(); getTypeHierarchyInfo(typeRegistry, allS, allA); for (String superTypeName : classificationDef.getSuperTypes()) { AtlasType superType = typeRegistry.getType(superTypeName); if (superType instanceof AtlasClassificationType) { s.add((AtlasClassificationType)superType); } else { throw new AtlasBaseException(AtlasErrorCode.INCOMPATIBLE_SUPERTYPE, superTypeName, classificationDef.getName()); } } this.superTypes = Collections.unmodifiableList(s); this.allSuperTypes = Collections.unmodifiableSet(allS); this.allAttributes = Collections.unmodifiableMap(allA); this.uniqAttributes = getUniqueAttributes(this.allAttributes); this.allSubTypes = new HashSet<>(); // this will be populated in resolveReferencesPhase2() this.typeAndAllSubTypes = new HashSet<>(); // this will be populated in resolveReferencesPhase2() this.typeAndAllSubTypes.add(this.getTypeName()); }
@Override void resolveReferences(AtlasTypeRegistry typeRegistry) throws AtlasBaseException { super.resolveReferences(typeRegistry); List<AtlasClassificationType> s = new ArrayList<>(); Set<String> allS = new HashSet<>(); Map<String, AtlasAttribute> allA = new HashMap<>(); getTypeHierarchyInfo(typeRegistry, allS, allA); for (String superTypeName : classificationDef.getSuperTypes()) { AtlasType superType = typeRegistry.getType(superTypeName); if (superType instanceof AtlasClassificationType) { s.add((AtlasClassificationType)superType); } else { throw new AtlasBaseException(AtlasErrorCode.INCOMPATIBLE_SUPERTYPE, superTypeName, classificationDef.getName()); } } this.superTypes = Collections.unmodifiableList(s); this.allSuperTypes = Collections.unmodifiableSet(allS); this.allAttributes = Collections.unmodifiableMap(allA); this.uniqAttributes = getUniqueAttributes(this.allAttributes); this.subTypes = new HashSet<>(); // this will be populated in resolveReferencesPhase2() this.allSubTypes = new HashSet<>(); // this will be populated in resolveReferencesPhase2() this.typeAndAllSubTypes = new HashSet<>(); // this will be populated in resolveReferencesPhase2() this.entityTypes = new HashSet<>(); // this will be populated in resolveReferencesPhase3() this.typeAndAllSubTypes.add(this.getTypeName()); this.typeAndAllSuperTypes = new HashSet<>(this.allSuperTypes); this.typeAndAllSuperTypes.add(this.getTypeName()); this.typeAndAllSuperTypes = Collections.unmodifiableSet(this.typeAndAllSuperTypes); }
private void collectTypeHierarchyInfo(AtlasTypeRegistry typeRegistry, Set<String> allSuperTypeNames, Map<String, AtlasAttribute> allAttributes, List<String> visitedTypes) throws AtlasBaseException { if (visitedTypes.contains(classificationDef.getName())) { throw new AtlasBaseException(AtlasErrorCode.CIRCULAR_REFERENCE, classificationDef.getName(), visitedTypes.toString()); } if (CollectionUtils.isNotEmpty(classificationDef.getSuperTypes())) { visitedTypes.add(classificationDef.getName()); for (String superTypeName : classificationDef.getSuperTypes()) { AtlasClassificationType superType = typeRegistry.getClassificationTypeByName(superTypeName); if (superType != null) { superType.collectTypeHierarchyInfo(typeRegistry, allSuperTypeNames, allAttributes, visitedTypes); } } visitedTypes.remove(classificationDef.getName()); allSuperTypeNames.addAll(classificationDef.getSuperTypes()); } if (CollectionUtils.isNotEmpty(classificationDef.getAttributeDefs())) { for (AtlasAttributeDef attributeDef : classificationDef.getAttributeDefs()) { AtlasType type = typeRegistry.getType(attributeDef.getTypeName()); allAttributes.put(attributeDef.getName(), new AtlasAttribute(this, attributeDef, type)); } } }
if (CollectionUtils.isNotEmpty(classificationDef.getSuperTypes())) { visitedTypes.add(classificationDef.getName()); for (String superTypeName : classificationDef.getSuperTypes()) { AtlasClassificationType superType = typeRegistry.getClassificationTypeByName(superTypeName); allSuperTypeNames.addAll(classificationDef.getSuperTypes());
public static AtlasClassificationDef getClassificationWithInvalidSuperType() { AtlasClassificationDef classificationDef = simpleType().getClassificationDefs().get(0); classificationDef.getSuperTypes().add("!@#$%"); return classificationDef; }
private void updateVertexAddReferences(AtlasClassificationDef classificationDef, AtlasVertex vertex) throws AtlasBaseException { AtlasStructDefStoreV2.updateVertexAddReferences(classificationDef, vertex, typeDefStore); typeDefStore.createSuperTypeEdges(vertex, classificationDef.getSuperTypes(), TypeCategory.TRAIT); // create edges from this vertex to entity Type vertices with the supplied entity type names typeDefStore.createEntityTypeEdges(vertex, classificationDef.getEntityTypes()); }
private void updateVertexAddReferences(AtlasClassificationDef classificationDef, AtlasVertex vertex) throws AtlasBaseException { AtlasStructDefStoreV2.updateVertexAddReferences(classificationDef, vertex, typeDefStore); typeDefStore.createSuperTypeEdges(vertex, classificationDef.getSuperTypes(), TypeCategory.TRAIT); // create edges from this vertex to entity Type vertices with the supplied entity type names typeDefStore.createEntityTypeEdges(vertex, classificationDef.getEntityTypes()); }
@Test public void testClassificationDefHasSuperTypeWithNoSuperType() { AtlasClassificationDef classificationDef = ModelTestUtil.getClassificationDef(); for (String superType : classificationDef.getSuperTypes()) { assertTrue(classificationDef.hasSuperType(superType)); } assertFalse(classificationDef.hasSuperType("01234-xyzabc-;''-)(")); }
@Test public void testClassificationDefHasSuperTypeWithSuperType() { AtlasClassificationDef classificationDef = ModelTestUtil.getClassificationDefWithSuperTypes(); for (String superType : classificationDef.getSuperTypes()) { assertTrue(classificationDef.hasSuperType(superType)); } assertFalse(classificationDef.hasSuperType("01234-xyzabc-;''-)(")); } }
@Test public void testClassificationDefHasSuperTypeWithNoSuperType() { AtlasClassificationDef classificationDef = ModelTestUtil.getClassificationDef(); for (String superType : classificationDef.getSuperTypes()) { assertTrue(classificationDef.hasSuperType(superType)); } assertFalse(classificationDef.hasSuperType("01234-xyzabc-;''-)(")); }
@Test public void testClassificationDefHasSuperTypeWithSuperType() { AtlasClassificationDef classificationDef = ModelTestUtil.getClassificationDefWithSuperTypes(); for (String superType : classificationDef.getSuperTypes()) { assertTrue(classificationDef.hasSuperType(superType)); } assertFalse(classificationDef.hasSuperType("01234-xyzabc-;''-)(")); } }
private static TypesDef entityToTypesDef(AtlasEntityType entityType, AtlasTypeRegistry registry) throws AtlasBaseException { String typeName = entityType.getEntityDef().getName(); String typeDesc = entityType.getEntityDef().getDescription(); String typeVersion = entityType.getEntityDef().getTypeVersion(); ImmutableSet superTypes = ImmutableSet.copyOf(entityType.getEntityDef().getSuperTypes()); AttributeDefinition[] attributes = getAttributes(entityType, registry); HierarchicalTypeDefinition<ClassType> classType = TypesUtil.createClassTypeDef(typeName, typeDesc, typeVersion, superTypes, attributes); TypesDef ret = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(), ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(), ImmutableList.of(classType)); return ret; }
private static TypesDef classificationToTypesDef(AtlasClassificationType classificationType, AtlasTypeRegistry registry) { String typeName = classificationType.getClassificationDef().getName(); String typeDesc = classificationType.getClassificationDef().getDescription(); String typeVersion = classificationType.getClassificationDef().getTypeVersion(); Set<String> superTypes = new HashSet<>(classificationType.getClassificationDef().getSuperTypes()); List<AttributeDefinition> attributes = getAttributes(classificationType, registry); TraitTypeDefinition traitTypeDef = new TraitTypeDefinition(typeName, typeDesc, typeVersion, attributes, superTypes); TypesDef ret = new TypesDef(null, null, Arrays.asList(traitTypeDef), null); return ret; }