public Set<String> getSuperTypes() { return entityDef.getSuperTypes(); }
public Set<String> getSuperTypes() { return entityDef.getSuperTypes(); }
public AtlasEntityDef(AtlasEntityDef other) { super(other); setSuperTypes(other != null ? other.getSuperTypes() : null); }
public AtlasEntityDef(AtlasEntityDef other) { super(other); setSuperTypes(other != null ? other.getSuperTypes() : null); }
private void updateVertexAddReferences(AtlasEntityDef entityDef, AtlasVertex vertex) throws AtlasBaseException { AtlasStructDefStoreV2.updateVertexAddReferences(entityDef, vertex, typeDefStore); typeDefStore.createSuperTypeEdges(vertex, entityDef.getSuperTypes(), TypeCategory.CLASS); }
private void updateVertexAddReferences(AtlasEntityDef entityDef, AtlasVertex vertex) throws AtlasBaseException { AtlasStructDefStoreV2.updateVertexAddReferences(entityDef, vertex, typeDefStore); typeDefStore.createSuperTypeEdges(vertex, entityDef.getSuperTypes(), TypeCategory.CLASS); }
public static List<AtlasEntityDef> getEntityWithValidAttribute() { List<AtlasEntityDef> entityDefs = getEntityWithValidSuperType(); entityDefs.get(1).getSuperTypes().clear(); return entityDefs; }
private void collectTypeHierarchyInfo(AtlasTypeRegistry typeRegistry, Set<String> allSuperTypeNames, Map<String, AtlasAttribute> allAttributes, List<String> visitedTypes) throws AtlasBaseException { if (visitedTypes.contains(entityDef.getName())) { throw new AtlasBaseException(AtlasErrorCode.CIRCULAR_REFERENCE, entityDef.getName(), visitedTypes.toString()); } if (CollectionUtils.isNotEmpty(entityDef.getSuperTypes())) { visitedTypes.add(entityDef.getName()); for (String superTypeName : entityDef.getSuperTypes()) { AtlasEntityType superType = typeRegistry.getEntityTypeByName(superTypeName); if (superType != null) { superType.collectTypeHierarchyInfo(typeRegistry, allSuperTypeNames, allAttributes, visitedTypes); } } visitedTypes.remove(entityDef.getName()); allSuperTypeNames.addAll(entityDef.getSuperTypes()); } if (CollectionUtils.isNotEmpty(entityDef.getAttributeDefs())) { for (AtlasAttributeDef attributeDef : entityDef.getAttributeDefs()) { AtlasType type = typeRegistry.getType(attributeDef.getTypeName()); allAttributes.put(attributeDef.getName(), new AtlasAttribute(this, attributeDef, type)); } } }
@Test public void filterInternalType() throws AtlasBaseException { SearchFilter searchFilter = new SearchFilter(); FilterUtil.addParamsToHideInternalType(searchFilter); AtlasTypesDef filteredTypeDefs = typeDefStore.searchTypesDef(searchFilter); assertNotNull(filteredTypeDefs); Optional<AtlasEntityDef> anyInternal = filteredTypeDefs.getEntityDefs().stream().filter(e -> e.getSuperTypes().contains("__internal")).findAny(); assertFalse(anyInternal.isPresent()); }
@Test public void filterInternalType() throws AtlasBaseException { SearchFilter searchFilter = new SearchFilter(); FilterUtil.addParamsToHideInternalType(searchFilter); AtlasTypesDef filteredTypeDefs = typeDefStore.searchTypesDef(searchFilter); assertNotNull(filteredTypeDefs); Optional<AtlasEntityDef> anyInternal = filteredTypeDefs.getEntityDefs().stream().filter(e -> e.getSuperTypes().contains("__internal")).findAny(); assertFalse(anyInternal.isPresent()); }
@Test public void testEntityDefHasSuperTypeWithNoSuperType() { AtlasEntityDef entityDef = ModelTestUtil.getEntityDef(); for (String superType : entityDef.getSuperTypes()) { assertTrue(entityDef.hasSuperType(superType)); } assertFalse(entityDef.hasSuperType("01234-xyzabc-;''-)(")); }
@Test public void testEntityDefHasSuperTypeWithNoSuperTypes() { AtlasEntityDef entityDef = ModelTestUtil.getEntityDefWithSuperTypes(); for (String superType : entityDef.getSuperTypes()) { assertTrue(entityDef.hasSuperType(superType)); } assertFalse(entityDef.hasSuperType("01234-xyzabc-;''-)(")); } }
@Test public void testEntityDefHasSuperTypeWithNoSuperType() { AtlasEntityDef entityDef = ModelTestUtil.getEntityDef(); for (String superType : entityDef.getSuperTypes()) { assertTrue(entityDef.hasSuperType(superType)); } assertFalse(entityDef.hasSuperType("01234-xyzabc-;''-)(")); }
@Test public void testEntityDefHasSuperTypeWithNoSuperTypes() { AtlasEntityDef entityDef = ModelTestUtil.getEntityDefWithSuperTypes(); for (String superType : entityDef.getSuperTypes()) { assertTrue(entityDef.hasSuperType(superType)); } assertFalse(entityDef.hasSuperType("01234-xyzabc-;''-)(")); } }
@Test public void testEntityDefRemoveElement() { AtlasEntityDef entityDef = ModelTestUtil.newEntityDefWithSuperTypes(); for (String superType : entityDef.getSuperTypes()) { entityDef.removeSuperType(superType); assertFalse(entityDef.hasSuperType(superType)); } }
@Test public void testEntityDefRemoveElement() { AtlasEntityDef entityDef = ModelTestUtil.newEntityDefWithSuperTypes(); for (String superType : entityDef.getSuperTypes()) { entityDef.removeSuperType(superType); assertFalse(entityDef.hasSuperType(superType)); } }
public static ClassTypeDefinition toClassTypeDefinition(final AtlasEntityType entityType) { ClassTypeDefinition ret = null; if (entityType != null) { AtlasEntityDef entityDef = entityType.getEntityDef(); ret = new ClassTypeDefinition(); ret.setTypeName(entityDef.getName()); ret.setTypeDescription(entityDef.getDescription()); ret.setTypeVersion(entityDef.getTypeVersion()); ret.setSuperTypes(entityDef.getSuperTypes()); if (MapUtils.isNotEmpty(entityType.getAllAttributes())) { List<AttributeDefinition> attributeDefinitions = entityType.getAllAttributes() .entrySet() .stream() .map(e -> toV1AttributeDefinition(e.getValue())) .collect(Collectors.toList()); ret.setAttributeDefinitions(attributeDefinitions); } } return ret; }
@Test public void testEntityDefSetSuperTypes() { AtlasEntityDef entityDef = ModelTestUtil.newEntityDefWithSuperTypes(); Set<String> oldSuperTypes = entityDef.getSuperTypes(); Set<String> newSuperTypes = new HashSet<>(); newSuperTypes.add("newType-abcd-1234"); entityDef.setSuperTypes(newSuperTypes); for (String superType : oldSuperTypes) { assertFalse(entityDef.hasSuperType(superType)); } for (String superType : newSuperTypes) { assertTrue(entityDef.hasSuperType(superType)); } // restore old sypertypes entityDef.setSuperTypes(oldSuperTypes); }
@Test public void testEntityDefSetSuperTypes() { AtlasEntityDef entityDef = ModelTestUtil.newEntityDefWithSuperTypes(); Set<String> oldSuperTypes = entityDef.getSuperTypes(); Set<String> newSuperTypes = new HashSet<>(); newSuperTypes.add("newType-abcd-1234"); entityDef.setSuperTypes(newSuperTypes); for (String superType : oldSuperTypes) { assertFalse(entityDef.hasSuperType(superType)); } for (String superType : newSuperTypes) { assertTrue(entityDef.hasSuperType(superType)); } // restore old sypertypes entityDef.setSuperTypes(oldSuperTypes); }
private static TypesDef entityToTypesDef(AtlasEntityType entityType, AtlasTypeRegistry registry) { String typeName = entityType.getEntityDef().getName(); String typeDesc = entityType.getEntityDef().getDescription(); String typeVersion = entityType.getEntityDef().getTypeVersion(); Set<String> superTypes = entityType.getEntityDef().getSuperTypes(); List<AttributeDefinition> attributes = getAttributes(entityType, registry); ClassTypeDefinition classTypeDef = new ClassTypeDefinition(typeName, typeDesc, typeVersion, attributes, superTypes); TypesDef ret = new TypesDef(null, null, null, Arrays.asList(classTypeDef)); return ret; }