@Override public AtlasEntityType getEntityType() { AtlasEntityType ret = typeRegistry.getEntityTypeByName(entityTypeName); return ret; }
public Set<String> getEntityTypeAndAllSuperTypes(String entityType, AtlasTypeRegistry typeRegistry) { final Set<String> ret; if (entityType == null) { ret = Collections.emptySet(); } else if (typeRegistry == null) { ret = Collections.singleton(entityType); } else { AtlasEntityType entType = typeRegistry.getEntityTypeByName(entityType); ret = entType != null ? entType.getTypeAndAllSuperTypes() : Collections.singleton(entityType); } return ret; }
private AtlasEntityType getEntityType(String typeName) throws AtlasBaseException { AtlasEntityType ret = typeRegistry.getEntityTypeByName(typeName); if (ret == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, typeName); } return ret; }
@VisibleForTesting static String getTypeFilter(AtlasTypeRegistry typeRegistry, String typeName, int maxTypesLengthInIdxQuery) { AtlasEntityType type = typeRegistry.getEntityTypeByName(typeName); String typeAndSubTypesQryStr = type != null ? type.getTypeAndAllSubTypesQryStr() : null; if(StringUtils.isNotEmpty(typeAndSubTypesQryStr) && typeAndSubTypesQryStr.length() <= maxTypesLengthInIdxQuery) { return typeAndSubTypesQryStr; } return ""; }
private boolean isProcessEntity(AtlasEntity entity) throws AtlasBaseException { String typeName = entity.getTypeName(); AtlasEntityType entityType = typeRegistry.getEntityTypeByName(typeName); return entityType.isSubTypeOf(AtlasBaseTypeDef.ATLAS_TYPE_PROCESS); }
private boolean termExists(AtlasGlossaryTerm term) { AtlasVertex vertex = AtlasGraphUtilsV2.findByUniqueAttributes(atlasTypeRegistry.getEntityTypeByName(GlossaryUtils.ATLAS_GLOSSARY_TERM_TYPENAME), new HashMap<String, Object>() {{ put(QUALIFIED_NAME_ATTR, term.getQualifiedName()); }}); return Objects.nonNull(vertex); }
private boolean glossaryExists(AtlasGlossary atlasGlossary) { AtlasVertex vertex = AtlasGraphUtilsV2.findByUniqueAttributes(atlasTypeRegistry.getEntityTypeByName(GlossaryUtils.ATLAS_GLOSSARY_TYPENAME), new HashMap<String, Object>() {{ put(QUALIFIED_NAME_ATTR, atlasGlossary.getQualifiedName()); }}); return Objects.nonNull(vertex); }
private boolean termExists(AtlasGlossaryTerm term) { AtlasVertex vertex = AtlasGraphUtilsV2.findByUniqueAttributes(atlasTypeRegistry.getEntityTypeByName(GlossaryUtils.ATLAS_GLOSSARY_TERM_TYPENAME), new HashMap<String, Object>() {{ put(QUALIFIED_NAME_ATTR, term.getQualifiedName()); }}); return Objects.nonNull(vertex); }
public boolean isRelationshipEdge(AtlasEdge edge) { boolean ret = false; if (edge != null) { String outVertexType = getTypeName(edge.getOutVertex()); String inVertexType = getTypeName(edge.getInVertex()); ret = GraphHelper.isRelationshipEdge(edge) || edge.getPropertyKeys().contains(RELATIONSHIP_GUID_PROPERTY_KEY) || (typeRegistry.getEntityTypeByName(outVertexType) != null && typeRegistry.getEntityTypeByName(inVertexType) != null); } return ret; }
@Override void resolveReferencesPhase2(AtlasTypeRegistry typeRegistry) throws AtlasBaseException { super.resolveReferencesPhase2(typeRegistry); for (AtlasEntityType superType : superTypes) { superType.addSubType(this); } for (String superTypeName : allSuperTypes) { AtlasEntityType superType = typeRegistry.getEntityTypeByName(superTypeName); superType.addToAllSubTypes(this); } }
public AtlasVertex createVertexWithGuid(AtlasEntity entity, String guid) { if (LOG.isDebugEnabled()) { LOG.debug("==> createVertex({})", entity.getTypeName()); } AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entity.getTypeName()); AtlasVertex ret = createStructVertex(entity); for (String superTypeName : entityType.getAllSuperTypes()) { AtlasGraphUtilsV2.addEncodedProperty(ret, SUPER_TYPES_PROPERTY_KEY, superTypeName); } AtlasGraphUtilsV2.setEncodedProperty(ret, GUID_PROPERTY_KEY, guid); AtlasGraphUtilsV2.setEncodedProperty(ret, VERSION_PROPERTY_KEY, getEntityVersion(entity)); return ret; }
public AtlasVertex createVertexWithGuid(AtlasEntity entity, String guid) { if (LOG.isDebugEnabled()) { LOG.debug("==> createVertex({})", entity.getTypeName()); } AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entity.getTypeName()); AtlasVertex ret = createStructVertex(entity); for (String superTypeName : entityType.getAllSuperTypes()) { AtlasGraphUtilsV2.addEncodedProperty(ret, SUPER_TYPES_PROPERTY_KEY, superTypeName); } AtlasGraphUtilsV2.setEncodedProperty(ret, GUID_PROPERTY_KEY, guid); AtlasGraphUtilsV2.setEncodedProperty(ret, VERSION_PROPERTY_KEY, getEntityVersion(entity)); return ret; }
private AtlasVertex getVertexFromEndPoint(AtlasObjectId endPoint) { AtlasVertex ret = null; if (StringUtils.isNotEmpty(endPoint.getGuid())) { ret = AtlasGraphUtilsV2.findByGuid(endPoint.getGuid()); } else if (StringUtils.isNotEmpty(endPoint.getTypeName()) && MapUtils.isNotEmpty(endPoint.getUniqueAttributes())) { AtlasEntityType entityType = typeRegistry.getEntityTypeByName(endPoint.getTypeName()); ret = AtlasGraphUtilsV2.findByUniqueAttributes(entityType, endPoint.getUniqueAttributes()); } return ret; }
private void mapRelationshipAttributes(AtlasVertex entityVertex, AtlasEntity entity) throws AtlasBaseException { AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entity.getTypeName()); if (entityType == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, entity.getTypeName()); } for (AtlasAttribute attribute : entityType.getRelationshipAttributes().values()) { Object attrValue = mapVertexToRelationshipAttribute(entityVertex, entityType, attribute); entity.setRelationshipAttribute(attribute.getName(), attrValue); } }
private AtlasVertex getVertexFromEndPoint(AtlasObjectId endPoint) { AtlasVertex ret = null; if (StringUtils.isNotEmpty(endPoint.getGuid())) { ret = AtlasGraphUtilsV2.findByGuid(endPoint.getGuid()); } else if (StringUtils.isNotEmpty(endPoint.getTypeName()) && MapUtils.isNotEmpty(endPoint.getUniqueAttributes())) { AtlasEntityType entityType = typeRegistry.getEntityTypeByName(endPoint.getTypeName()); ret = AtlasGraphUtilsV2.findByUniqueAttributes(entityType, endPoint.getUniqueAttributes()); } return ret; }
public static AtlasEntity newEntity(AtlasEntityDef entityDef, AtlasTypeRegistry typesRegistry) { AtlasEntity ret = null; AtlasEntityType entityType = typesRegistry.getEntityTypeByName(entityDef.getName()); if (entityType != null) { ret = entityType.createDefaultValue(); } else { LOG.error("failed to get entity-type {}", entityDef.getName()); } return ret; }
void walkEntityGraph(AtlasEntity entity) throws AtlasBaseException { if (entity == null) { return; } AtlasEntityType type = typeRegistry.getEntityTypeByName(entity.getTypeName()); if (type == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.ENTITY.name(), entity.getTypeName()); } recordObjectReference(entity.getGuid()); visitEntity(type, entity); }
void walkEntityGraph(AtlasEntity entity) throws AtlasBaseException { if (entity == null) { return; } AtlasEntityType type = typeRegistry.getEntityTypeByName(entity.getTypeName()); if (type == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.ENTITY.name(), entity.getTypeName()); } recordObjectReference(entity.getGuid()); visitEntity(type, entity); }
@Test public void testEntitySerDe() throws AtlasBaseException { AtlasEntityDef entityDef = ModelTestUtil.getEntityDef(); AtlasTypeRegistry typeRegistry = ModelTestUtil.getTypesRegistry(); AtlasEntityType entityType = typeRegistry.getEntityTypeByName(entityDef.getName()); assertNotNull(entityType); AtlasEntity ent1 = entityType.createDefaultValue(); String jsonString = AtlasType.toJson(ent1); AtlasEntity ent2 = AtlasType.fromJson(jsonString, AtlasEntity.class); entityType.normalizeAttributeValues(ent2); assertEquals(ent2, ent1, "Incorrect serialization/deserialization of AtlasEntity"); }
public AtlasEntitiesWithExtInfo toAtlasEntity(Referenceable referenceable) throws AtlasBaseException { AtlasEntityFormatConverter converter = (AtlasEntityFormatConverter) instanceFormatters.getConverter(TypeCategory.ENTITY); AtlasEntityType entityType = typeRegistry.getEntityTypeByName(referenceable.getTypeName()); if (entityType == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID, TypeCategory.ENTITY.name(), referenceable.getTypeName()); } ConverterContext ctx = new ConverterContext(); AtlasEntity entity = converter.fromV1ToV2(referenceable, entityType, ctx); ctx.addEntity(entity); return ctx.getEntities(); }