AtlasClassificationDef classifiL2_4 = new AtlasClassificationDef("L2-4"); classifiL1_1.addSuperType(classifiL0.getName()); classifiL1_2.addSuperType(classifiL0.getName()); classifiL2_1.addSuperType(classifiL1_1.getName()); classifiL2_2.addSuperType(classifiL1_1.getName()); classifiL2_3.addSuperType(classifiL1_1.getName()); classifiL2_3.addSuperType(classifiL1_2.getName()); classifiL2_4.addSuperType(classifiL1_2.getName()); classifiL0.addSuperType(classifiL2_3.getName()); // circular-ref
@Test public void testClassificationDefInvalidHierarchy_Self() { AtlasClassificationDef classifiDef1 = new AtlasClassificationDef("classifiDef-1"); classifiDef1.addSuperType(classifiDef1.getName()); AtlasTypeRegistry typeRegistry = new AtlasTypeRegistry(); AtlasTransientTypeRegistry ttr = null; boolean commit = false; String failureMsg = null; try { ttr = typeRegistry.lockTypeRegistryForUpdate(); ttr.addType(classifiDef1); commit = true; } catch (AtlasBaseException excp) { failureMsg = excp.getMessage(); } finally { typeRegistry.releaseTypeRegistryForUpdate(ttr, commit); } assertNotNull(failureMsg, "expected invalid supertype failure"); }
AtlasClassificationDef classifiL2_4 = new AtlasClassificationDef("L2-4"); classifiL1_1.addSuperType(classifiL0.getName()); classifiL1_2.addSuperType(classifiL0.getName()); classifiL2_1.addSuperType(classifiL1_1.getName()); classifiL2_2.addSuperType(classifiL1_1.getName()); classifiL2_3.addSuperType(classifiL1_1.getName()); classifiL2_3.addSuperType(classifiL1_2.getName()); classifiL2_4.addSuperType(classifiL1_2.getName()); classifiL0.addSuperType(classifiL2_3.getName()); // circular-ref
@Test public void testClassificationDefInvalidHierarchy_Self() { AtlasClassificationDef classifiDef1 = new AtlasClassificationDef("classifiDef-1"); classifiDef1.addSuperType(classifiDef1.getName()); AtlasTypeRegistry typeRegistry = new AtlasTypeRegistry(); AtlasTransientTypeRegistry ttr = null; boolean commit = false; String failureMsg = null; try { ttr = typeRegistry.lockTypeRegistryForUpdate(); ttr.addType(classifiDef1); commit = true; } catch (AtlasBaseException excp) { failureMsg = excp.getMessage(); } finally { typeRegistry.releaseTypeRegistryForUpdate(ttr, commit); } assertNotNull(failureMsg, "expected invalid supertype failure"); }
AtlasClassificationDef classifiL2_4 = new AtlasClassificationDef("L2-4"); classifiL1_1.addSuperType(classifiL0.getName()); classifiL1_2.addSuperType(classifiL0.getName()); classifiL2_1.addSuperType(classifiL1_1.getName()); classifiL2_2.addSuperType(classifiL1_1.getName()); classifiL2_3.addSuperType(classifiL1_1.getName()); classifiL2_3.addSuperType(classifiL1_2.getName()); classifiL2_4.addSuperType(classifiL1_2.getName());
AtlasClassificationDef classifiL2_4 = new AtlasClassificationDef("L2-4"); classifiL1_1.addSuperType(classifiL0.getName()); classifiL1_2.addSuperType(classifiL0.getName()); classifiL2_1.addSuperType(classifiL1_1.getName()); classifiL2_2.addSuperType(classifiL1_1.getName()); classifiL2_3.addSuperType(classifiL1_1.getName()); classifiL2_3.addSuperType(classifiL1_2.getName()); classifiL2_4.addSuperType(classifiL1_2.getName());
public static AtlasClassificationDef newClassificationDef(AtlasTypeRegistry typesRegistry, AtlasClassificationDef[] superTypes) { int classificationDefIdx = IDX_CLASSIFICATION_DEF.getAndIncrement(); AtlasClassificationDef ret = new AtlasClassificationDef(); ret.setName(PREFIX_CLASSIFICATION_DEF + classificationDefIdx); ret.setDescription(ret.getName()); ret.setAttributeDefs(newAttributeDefsWithAllBuiltInTypes(PREFIX_ATTRIBUTE_NAME)); if (superTypes != null) { for (AtlasClassificationDef superType : superTypes) { ret.addSuperType(superType.getName()); } } AtlasTransientTypeRegistry ttr = null; boolean commit = false; try { ttr = typesRegistry.lockTypeRegistryForUpdate(); ttr.addType(ret); commit = true; } catch (AtlasBaseException excp) { LOG.error("failed to create classification-def", excp); ret = null; } finally { typesRegistry.releaseTypeRegistryForUpdate(ttr, commit); } return ret; }
public static AtlasClassificationDef newClassificationDef(AtlasTypeRegistry typesRegistry, AtlasClassificationDef[] superTypes) { int classificationDefIdx = IDX_CLASSIFICATION_DEF.getAndIncrement(); AtlasClassificationDef ret = new AtlasClassificationDef(); ret.setName(PREFIX_CLASSIFICATION_DEF + classificationDefIdx); ret.setDescription(ret.getName()); ret.setAttributeDefs(newAttributeDefsWithAllBuiltInTypes(PREFIX_ATTRIBUTE_NAME)); if (superTypes != null) { for (AtlasClassificationDef superType : superTypes) { ret.addSuperType(superType.getName()); } } AtlasTransientTypeRegistry ttr = null; boolean commit = false; try { ttr = typesRegistry.lockTypeRegistryForUpdate(); ttr.addType(ret); commit = true; } catch (AtlasBaseException excp) { LOG.error("failed to create classification-def", excp); ret = null; } finally { typesRegistry.releaseTypeRegistryForUpdate(ttr, commit); } return ret; }