AtlasTypeDefGraphStore implements AtlasTypeDefStore, ActiveStateChangeHandler { @Override @GraphTransaction public void deleteTypesDef(AtlasTypesDef typesDef) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> AtlasTypeDefGraphStore.deleteTypesDef(enums={}, structs={}, classfications={}, entities={}, relationships={})", CollectionUtils.size(typesDef.getEnumDefs()), CollectionUtils.size(typesDef.getStructDefs()), CollectionUtils.size(typesDef.getClassificationDefs()), CollectionUtils.size(typesDef.getEntityDefs()), CollectionUtils.size(typesDef.getRelationshipDefs())); } AtlasTransientTypeRegistry ttr = lockTypeRegistryAndReleasePostCommit(); AtlasEnumDefStore enumDefStore = getEnumDefStore(ttr); AtlasStructDefStore structDefStore = getStructDefStore(ttr); AtlasClassificationDefStore classifiDefStore = getClassificationDefStore(ttr); AtlasEntityDefStore entityDefStore = getEntityDefStore(ttr); AtlasRelationshipDefStore relationshipDefStore = getRelationshipDefStore(ttr); List<Object> preDeleteStructDefs = new ArrayList<>(); List<Object> preDeleteClassifiDefs = new ArrayList<>(); List<Object> preDeleteEntityDefs = new ArrayList<>(); List<Object> preDeleteRelationshipDefs = new ArrayList<>(); if (CollectionUtils.isNotEmpty(typesDef.getRelationshipDefs())) { for (AtlasRelationshipDef relationshipDef : typesDef.getRelationshipDefs()) { if (StringUtils.isNotBlank(relationshipDef.getGuid())) { preDeleteRelationshipDefs.add(relationshipDefStore.preDeleteByGuid(relationshipDef.getGuid())); } else { preDeleteRelationshipDefs.add(relationshipDefStore.preDeleteByName(relationshipDef.getName())); } } } if (CollectionUtils.isNotEmpty(typesDef.getStructDefs())) { for (AtlasStructDef structDef : typesDef.getStructDefs()) { if (StringUtils.isNotBlank(structDef.getGuid())) { preDeleteStructDefs.add(structDefStore.preDeleteByGuid(structDef.getGuid())); } else { preDeleteStructDefs.add(structDefStore.preDeleteByName(structDef.getName())); } } } if (CollectionUtils.isNotEmpty(typesDef.getClassificationDefs())) { for (AtlasClassificationDef classifiDef : typesDef.getClassificationDefs()) { if (StringUtils.isNotBlank(classifiDef.getGuid())) { preDeleteClassifiDefs.add(classifiDefStore.preDeleteByGuid(classifiDef.getGuid())); } else { preDeleteClassifiDefs.add(classifiDefStore.preDeleteByName(classifiDef.getName())); } } } if (CollectionUtils.isNotEmpty(typesDef.getEntityDefs())) { for (AtlasEntityDef entityDef : typesDef.getEntityDefs()) { if (StringUtils.isNotBlank(entityDef.getGuid())) { preDeleteEntityDefs.add(entityDefStore.preDeleteByGuid(entityDef.getGuid())); } else { preDeleteEntityDefs.add(entityDefStore.preDeleteByName(entityDef.getName())); } } } if (CollectionUtils.isNotEmpty(typesDef.getRelationshipDefs())) { int i = 0; for (AtlasRelationshipDef relationshipDef : typesDef.getRelationshipDefs()) { if (StringUtils.isNotBlank(relationshipDef.getGuid())) { relationshipDefStore.deleteByGuid(relationshipDef.getGuid(), preDeleteRelationshipDefs.get(i)); } else { relationshipDefStore.deleteByName(relationshipDef.getName(), preDeleteRelationshipDefs.get(i)); } i++; } } if (CollectionUtils.isNotEmpty(typesDef.getStructDefs())) { int i = 0; for (AtlasStructDef structDef : typesDef.getStructDefs()) { if (StringUtils.isNotBlank(structDef.getGuid())) { structDefStore.deleteByGuid(structDef.getGuid(), preDeleteStructDefs.get(i)); } else { structDefStore.deleteByName(structDef.getName(), preDeleteStructDefs.get(i)); } i++; } } if (CollectionUtils.isNotEmpty(typesDef.getClassificationDefs())) { int i = 0; for (AtlasClassificationDef classifiDef : typesDef.getClassificationDefs()) { if (StringUtils.isNotBlank(classifiDef.getGuid())) { classifiDefStore.deleteByGuid(classifiDef.getGuid(), preDeleteClassifiDefs.get(i)); } else { classifiDefStore.deleteByName(classifiDef.getName(), preDeleteClassifiDefs.get(i)); } i++; } } if (CollectionUtils.isNotEmpty(typesDef.getEntityDefs())) { int i = 0; for (AtlasEntityDef entityDef : typesDef.getEntityDefs()) { if (StringUtils.isNotBlank(entityDef.getGuid())) { entityDefStore.deleteByGuid(entityDef.getGuid(), preDeleteEntityDefs.get(i)); } else { entityDefStore.deleteByName(entityDef.getName(), preDeleteEntityDefs.get(i)); } i++; } } if (CollectionUtils.isNotEmpty(typesDef.getEnumDefs())) { for (AtlasEnumDef enumDef : typesDef.getEnumDefs()) { if (StringUtils.isNotBlank(enumDef.getGuid())) { enumDefStore.deleteByGuid(enumDef.getGuid()); } else { enumDefStore.deleteByName(enumDef.getName()); } } } ttr.removeTypesDef(typesDef); if (LOG.isDebugEnabled()) { LOG.debug("<== AtlasTypeDefGraphStore.deleteTypesDef(enums={}, structs={}, classfications={}, entities={})", CollectionUtils.size(typesDef.getEnumDefs()), CollectionUtils.size(typesDef.getStructDefs()), CollectionUtils.size(typesDef.getClassificationDefs()), CollectionUtils.size(typesDef.getEntityDefs())); } } protected  AtlasTypeDefGraphStore(AtlasTypeRegistry typeRegistry,
                                     Set<TypeDefChangeListener> typeDefChangeListeners); @Override void init(); @Override AtlasEnumDef getEnumDefByName(String name); @Override AtlasEnumDef getEnumDefByGuid(String guid); @Override @GraphTransaction AtlasEnumDef updateEnumDefByName(String name, AtlasEnumDef enumDef); @Override @GraphTransaction AtlasEnumDef updateEnumDefByGuid(String guid, AtlasEnumDef enumDef); @Override AtlasStructDef getStructDefByName(String name); @Override AtlasStructDef getStructDefByGuid(String guid); @Override AtlasRelationshipDef getRelationshipDefByName(String name); @Override AtlasRelationshipDef getRelationshipDefByGuid(String guid); @Override @GraphTransaction AtlasStructDef updateStructDefByName(String name, AtlasStructDef structDef); @Override @GraphTransaction AtlasStructDef updateStructDefByGuid(String guid, AtlasStructDef structDef); @Override AtlasClassificationDef getClassificationDefByName(String name); @Override AtlasClassificationDef getClassificationDefByGuid(String guid); @Override @GraphTransaction AtlasClassificationDef updateClassificationDefByName(String name, AtlasClassificationDef classificationDef); @Override @GraphTransaction AtlasClassificationDef updateClassificationDefByGuid(String guid, AtlasClassificationDef classificationDef); @Override AtlasEntityDef getEntityDefByName(String name); @Override AtlasEntityDef getEntityDefByGuid(String guid); @Override @GraphTransaction AtlasEntityDef updateEntityDefByName(String name, AtlasEntityDef entityDef); @Override @GraphTransaction AtlasEntityDef updateEntityDefByGuid(String guid, AtlasEntityDef entityDef); @Override @GraphTransaction AtlasRelationshipDef updateRelationshipDefByName(String name, AtlasRelationshipDef relationshipDef); @Override @GraphTransaction AtlasRelationshipDef updateRelationshipDefByGuid(String guid, AtlasRelationshipDef relationshipDef); @Override @GraphTransaction AtlasTypesDef createTypesDef(AtlasTypesDef typesDef); @Override @GraphTransaction AtlasTypesDef createUpdateTypesDef(AtlasTypesDef typesToCreate, AtlasTypesDef typesToUpdate); @Override @GraphTransaction AtlasTypesDef updateTypesDef(AtlasTypesDef typesDef); @Override @GraphTransaction void deleteTypesDef(AtlasTypesDef typesDef); @Override AtlasTypesDef searchTypesDef(SearchFilter searchFilter); @Override AtlasBaseTypeDef getByName(String name); @Override AtlasBaseTypeDef getByGuid(String guid); @Override void instanceIsActive(); @Override void instanceIsPassive();  }
@Test(dependsOnMethods = {"testUpdate"}, dataProvider = "allCreatedTypes") public void testDelete(AtlasTypesDef atlasTypesDef){ try { typeDefStore.deleteTypesDef(atlasTypesDef); } catch (AtlasBaseException e) { fail("Deletion should've succeeded"); } }