@Override public AtlasVertex preCreate(AtlasStructDef structDef) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> AtlasStructDefStoreV1.preCreate({})", structDef); } AtlasType type = typeRegistry.getType(structDef.getName()); if (type.getTypeCategory() != AtlasType.TypeCategory.STRUCT) { throw new AtlasBaseException( AtlasErrorCode.TYPE_MATCH_FAILED, structDef.getName(), TypeCategory.STRUCT.name()); } AtlasVertex ret = typeDefStore.findTypeVertexByName(structDef.getName()); if (ret != null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_ALREADY_EXISTS, structDef.getName()); } ret = typeDefStore.createTypeVertex(structDef); AtlasStructDefStoreV1.updateVertexPreCreate( structDef, (AtlasStructType) type, ret, typeDefStore); if (LOG.isDebugEnabled()) { LOG.debug("<== AtlasStructDefStoreV1.preCreate({}): {}", structDef, ret); } return ret; }
@Override public AtlasStructDef updateByGuid(String guid, AtlasStructDef structDef) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> AtlasStructDefStoreV1.updateByGuid({})", guid); } AtlasType type = typeRegistry.getTypeByGuid(guid); if (type.getTypeCategory() != AtlasType.TypeCategory.STRUCT) { throw new AtlasBaseException( AtlasErrorCode.TYPE_MATCH_FAILED, structDef.getName(), TypeCategory.STRUCT.name()); } AtlasVertex vertex = typeDefStore.findTypeVertexByGuidAndCategory(guid, TypeCategory.STRUCT); if (vertex == null) { throw new AtlasBaseException(AtlasErrorCode.TYPE_GUID_NOT_FOUND, guid); } AtlasStructDefStoreV1.updateVertexPreUpdate( structDef, (AtlasStructType) type, vertex, typeDefStore); AtlasStructDefStoreV1.updateVertexAddReferences(structDef, vertex, typeDefStore); AtlasStructDef ret = toStructDef(vertex); if (LOG.isDebugEnabled()) { LOG.debug("<== AtlasStructDefStoreV1.updateByGuid({}): {}", guid, ret); } return ret; }