@Override public AtlasStructDef getStructDefByName(String name) throws AtlasBaseException { AtlasStructDef ret = typeRegistry.getStructDefByName(name); if (ret == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name); } return ret; }
@Override public AtlasStructDef getStructDefByName(String name) throws AtlasBaseException { AtlasStructDef ret = typeRegistry.getStructDefByName(name); if (ret == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name); } return ret; }
private void createLabelIfNeeded(final AtlasGraphManagement management, final String propertyName, final String attribTypeName) { // If any of the referenced typename is of type Entity or Struct then the edge label needs to be created for (String typeName : AtlasTypeUtil.getReferencedTypeNames(attribTypeName)) { if (typeRegistry.getEntityDefByName(typeName) != null || typeRegistry.getStructDefByName(typeName) != null) { // Create the edge label upfront to avoid running into concurrent call issue (ATLAS-2092) createEdgeLabel(management, propertyName); } } }
@Override public AtlasVertex preDeleteByName(String name) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> AtlasStructDefStoreV1.preDeleteByName({})", name); } AtlasStructDef existingDef = typeRegistry.getStructDefByName(name); AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_DELETE, existingDef), "delete struct-def ", name); AtlasVertex ret = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.STRUCT); if (AtlasGraphUtilsV2.typeHasInstanceVertex(name)) { throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, name); } if (ret == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name); } typeDefStore.deleteTypeVertexOutEdges(ret); if (LOG.isDebugEnabled()) { LOG.debug("<== AtlasStructDefStoreV1.preDeleteByName({}): {}", name, ret); } return ret; }
@Override public AtlasVertex preDeleteByName(String name) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> AtlasStructDefStoreV1.preDeleteByName({})", name); } AtlasStructDef existingDef = typeRegistry.getStructDefByName(name); AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_DELETE, existingDef), "delete struct-def ", name); AtlasVertex ret = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.STRUCT); if (AtlasGraphUtilsV2.typeHasInstanceVertex(name)) { throw new AtlasBaseException(AtlasErrorCode.TYPE_HAS_REFERENCES, name); } if (ret == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name); } typeDefStore.deleteTypeVertexOutEdges(ret); if (LOG.isDebugEnabled()) { LOG.debug("<== AtlasStructDefStoreV1.preDeleteByName({}): {}", name, ret); } return ret; }
private void processTypesDef(ExportContext context) { AtlasTypesDef typesDef = context.result.getData().getTypesDef(); for (String entityType : context.entityTypes) { AtlasEntityDef entityDef = typeRegistry.getEntityDefByName(entityType); typesDef.getEntityDefs().add(entityDef); } for (String classificationType : context.classificationTypes) { AtlasClassificationDef classificationDef = typeRegistry.getClassificationDefByName(classificationType); typesDef.getClassificationDefs().add(classificationDef); } for (String structType : context.structTypes) { AtlasStructDef structDef = typeRegistry.getStructDefByName(structType); typesDef.getStructDefs().add(structDef); } for (String enumType : context.enumTypes) { AtlasEnumDef enumDef = typeRegistry.getEnumDefByName(enumType); typesDef.getEnumDefs().add(enumDef); } }
private void updateStructDef(AtlasTypesDef typeDefinitionMap, AtlasImportResult result) throws AtlasBaseException { for (AtlasStructDef def: typeDefinitionMap.getStructDefs()) { AtlasStructDef existing = typeRegistry.getStructDefByName(def.getName()); if(existing != null && addAttributes(existing, def)) { typeDefStore.updateStructDefByName(existing.getName(), existing); result.incrementMeticsCounter("typedef:struct:update"); } } }
private void updateStructDef(AtlasTypesDef typeDefinitionMap, AtlasImportResult result) throws AtlasBaseException { for (AtlasStructDef def : typeDefinitionMap.getStructDefs()) { AtlasStructDef existing = typeRegistry.getStructDefByName(def.getName()); if (existing != null && addAttributes(existing, def)) { typeDefStore.updateStructDefByName(existing.getName(), existing); result.incrementMeticsCounter("typedef:struct:update"); } } }
assertNotNull(typeRegistry.getStructDefByName(structType), structType + ": struct not found"); assertNotNull(typeRegistry.getClassificationDefByName(classificationType), classificationType + ": classification not found"); assertNotNull(typeRegistry.getEntityDefByName(entityType), entityType + ": entity not found");
AtlasStructDef oldStructDef = typeRegistry.getStructDefByName(newStructDef.getName());
@Override public AtlasStructDef updateByName(String name, AtlasStructDef structDef) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> AtlasStructDefStoreV1.updateByName({}, {})", name, structDef); } AtlasStructDef existingDef = typeRegistry.getStructDefByName(name); AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_UPDATE, existingDef), "update struct-def ", name); validateType(structDef); AtlasType type = typeRegistry.getType(structDef.getName()); if (type.getTypeCategory() != org.apache.atlas.model.TypeCategory.STRUCT) { throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, structDef.getName(), TypeCategory.STRUCT.name()); } AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.STRUCT); if (vertex == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name); } AtlasStructDefStoreV2.updateVertexPreUpdate(structDef, (AtlasStructType)type, vertex, typeDefStore); AtlasStructDefStoreV2.updateVertexAddReferences(structDef, vertex, typeDefStore); AtlasStructDef ret = toStructDef(vertex); if (LOG.isDebugEnabled()) { LOG.debug("<== AtlasStructDefStoreV1.updateByName({}, {}): {}", name, structDef, ret); } return ret; }
@Override public AtlasStructDef updateByName(String name, AtlasStructDef structDef) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> AtlasStructDefStoreV1.updateByName({}, {})", name, structDef); } AtlasStructDef existingDef = typeRegistry.getStructDefByName(name); AtlasAuthorizationUtils.verifyAccess(new AtlasTypeAccessRequest(AtlasPrivilege.TYPE_UPDATE, existingDef), "update struct-def ", name); validateType(structDef); AtlasType type = typeRegistry.getType(structDef.getName()); if (type.getTypeCategory() != org.apache.atlas.model.TypeCategory.STRUCT) { throw new AtlasBaseException(AtlasErrorCode.TYPE_MATCH_FAILED, structDef.getName(), TypeCategory.STRUCT.name()); } AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.STRUCT); if (vertex == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name); } AtlasStructDefStoreV2.updateVertexPreUpdate(structDef, (AtlasStructType)type, vertex, typeDefStore); AtlasStructDefStoreV2.updateVertexAddReferences(structDef, vertex, typeDefStore); AtlasStructDef ret = toStructDef(vertex); if (LOG.isDebugEnabled()) { LOG.debug("<== AtlasStructDefStoreV1.updateByName({}, {}): {}", name, structDef, ret); } return ret; }
assertNotNull(typeRegistry.getStructDefByName(structType), structType + ": struct not found"); assertNotNull(typeRegistry.getClassificationDefByName(classificationType), classificationType + ": classification not found"); assertNotNull(typeRegistry.getEntityDefByName(entityType), entityType + ": entity not found");
private void processTypesDef(ExportContext context) { AtlasTypesDef typesDef = context.result.getData().getTypesDef(); for (String entityType : context.entityTypes) { AtlasEntityDef entityDef = typeRegistry.getEntityDefByName(entityType); typesDef.getEntityDefs().add(entityDef); } for (String classificationType : context.classificationTypes) { AtlasClassificationDef classificationDef = typeRegistry.getClassificationDefByName(classificationType); typesDef.getClassificationDefs().add(classificationDef); } for (String structType : context.structTypes) { AtlasStructDef structDef = typeRegistry.getStructDefByName(structType); typesDef.getStructDefs().add(structDef); } for (String enumType : context.enumTypes) { AtlasEnumDef enumDef = typeRegistry.getEnumDefByName(enumType); typesDef.getEnumDefs().add(enumDef); } }
private void cleanupIndexForAttribute(AtlasGraphManagement management, String typeName, AtlasAttributeDef attributeDef) { final String propertyName = AtlasGraphUtilsV2.encodePropertyKey(typeName + "." + attributeDef.getName()); String attribTypeName = attributeDef.getTypeName(); boolean isBuiltInType = AtlasTypeUtil.isBuiltInType(attribTypeName); boolean isArrayType = isArrayType(attribTypeName); boolean isMapType = isMapType(attribTypeName); try { AtlasType atlasType = typeRegistry.getType(attribTypeName); if (isClassificationType(atlasType) || isEntityType(atlasType)) { LOG.warn("Ignoring non-indexable attribute {}", attribTypeName); } else if (isBuiltInType || isEnumType(atlasType) || isArrayType || isMapType) { cleanupIndex(management, propertyName); } else if (isStructType(atlasType)) { AtlasStructDef structDef = typeRegistry.getStructDefByName(attribTypeName); cleanupIndices(management, structDef); } } catch (AtlasBaseException e) { LOG.error("No type exists for {}", attribTypeName, e); } }
AtlasStructDef oldStructDef = typeRegistry.getStructDefByName(newStructDef.getName());
AtlasStructDef structDef = typeRegistry.getStructDefByName(attribTypeName); updateIndexForTypeDef(management, structDef);