use of org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumElementDef in project incubator-atlas by apache.
the class AtlasEnumDefStoreV1 method toEnumDef.
private static AtlasEnumDef toEnumDef(AtlasVertex vertex, AtlasEnumDef enumDef, AtlasTypeDefGraphStoreV1 typeDefStore) {
AtlasEnumDef ret = enumDef != null ? enumDef : new AtlasEnumDef();
typeDefStore.vertexToTypeDef(vertex, ret);
List<AtlasEnumElementDef> elements = new ArrayList<>();
List<String> elemValues = vertex.getProperty(AtlasGraphUtilsV1.getTypeDefPropertyKey(ret), List.class);
for (String elemValue : elemValues) {
String elemKey = AtlasGraphUtilsV1.getTypeDefPropertyKey(ret, elemValue);
String descKey = AtlasGraphUtilsV1.getTypeDefPropertyKey(elemKey, "description");
Integer ordinal = AtlasGraphUtilsV1.getProperty(vertex, elemKey, Integer.class);
String desc = AtlasGraphUtilsV1.getProperty(vertex, descKey, String.class);
elements.add(new AtlasEnumElementDef(elemValue, desc, ordinal));
}
ret.setElementDefs(elements);
return ret;
}
use of org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumElementDef in project incubator-atlas by apache.
the class TestAtlasEnumDef method testEnumDefAddElement.
@Test
public void testEnumDefAddElement() {
AtlasEnumDef enumDef = ModelTestUtil.newEnumDef();
String newElement = "newElement-abcd-1234";
enumDef.addElement(new AtlasEnumElementDef(newElement, "A new element", enumDef.getElementDefs().size()));
assertTrue(enumDef.hasElement(newElement));
}
use of org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumElementDef in project incubator-atlas by apache.
the class TestUtilsV2 method simpleTypeUpdated.
public static AtlasTypesDef simpleTypeUpdated() {
AtlasEntityDef superTypeDefinition = AtlasTypeUtil.createClassTypeDef("h_type", ImmutableSet.<String>of(), AtlasTypeUtil.createOptionalAttrDef("attr", "string"));
AtlasEntityDef newSuperTypeDefinition = AtlasTypeUtil.createClassTypeDef("new_h_type", ImmutableSet.<String>of(), AtlasTypeUtil.createOptionalAttrDef("attr", "string"));
AtlasStructDef structTypeDefinition = new AtlasStructDef("s_type", "structType", "1.0", Arrays.asList(AtlasTypeUtil.createRequiredAttrDef("name", "string")));
AtlasClassificationDef traitTypeDefinition = AtlasTypeUtil.createTraitTypeDef("t_type", "traitType", ImmutableSet.<String>of());
AtlasEnumDef enumTypeDefinition = new AtlasEnumDef("e_type", "enumType", Arrays.asList(new AtlasEnumElementDef("ONE", "Element Description", 1)));
return AtlasTypeUtil.getTypesDef(ImmutableList.of(enumTypeDefinition), ImmutableList.of(structTypeDefinition), ImmutableList.of(traitTypeDefinition), ImmutableList.of(superTypeDefinition, newSuperTypeDefinition));
}
use of org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumElementDef in project incubator-atlas by apache.
the class TestAtlasEnumDef method testEnumDefSetElementDefs.
@Test
public void testEnumDefSetElementDefs() {
AtlasEnumDef enumDef = ModelTestUtil.newEnumDef();
List<AtlasEnumElementDef> oldElements = enumDef.getElementDefs();
List<AtlasEnumElementDef> newElements = new ArrayList<>();
newElements.add(new AtlasEnumElementDef("newElement", "new Element", 100));
enumDef.setElementDefs(newElements);
for (AtlasEnumElementDef elementDef : oldElements) {
assertFalse(enumDef.hasElement(elementDef.getValue()));
}
for (AtlasEnumElementDef elementDef : newElements) {
assertTrue(enumDef.hasElement(elementDef.getValue()));
}
}
use of org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumElementDef in project incubator-atlas by apache.
the class TestAtlasEnumDef method testEnumDefHasElement.
@Test
public void testEnumDefHasElement() {
AtlasEnumDef enumDef = ModelTestUtil.getEnumDef();
for (AtlasEnumElementDef elementDef : enumDef.getElementDefs()) {
assertTrue(enumDef.hasElement(elementDef.getValue()));
}
assertFalse(enumDef.hasElement("01234-xyzabc-;''-)("));
}
Aggregations