use of org.apache.atlas.model.typedef.AtlasEnumDef in project incubator-atlas by apache.
the class TypeConverterUtil method toAtlasEnumDefs.
private static List<AtlasEnumDef> toAtlasEnumDefs(List<EnumTypeDefinition> enumTypeDefinitions) {
List<AtlasEnumDef> ret = new ArrayList<AtlasEnumDef>();
for (EnumTypeDefinition enumType : enumTypeDefinitions) {
AtlasEnumDef enumDef = new AtlasEnumDef();
enumDef.setName(enumType.name);
enumDef.setDescription(enumType.description);
enumDef.setTypeVersion(enumType.version);
enumDef.setElementDefs(getAtlasEnumElementDefs(enumType.enumValues));
ret.add(enumDef);
}
return ret;
}
use of org.apache.atlas.model.typedef.AtlasEnumDef in project incubator-atlas by apache.
the class TypedefsJerseyResourceIT method testCreate.
@Test
public void testCreate() throws Exception {
createType(typeDefinitions);
for (AtlasEnumDef enumDef : typeDefinitions.getEnumDefs()) {
AtlasEnumDef byName = atlasClientV2.getEnumDefByName(enumDef.getName());
assertNotNull(byName);
}
for (AtlasStructDef structDef : typeDefinitions.getStructDefs()) {
AtlasStructDef byName = atlasClientV2.getStructDefByName(structDef.getName());
assertNotNull(byName);
}
for (AtlasClassificationDef classificationDef : typeDefinitions.getClassificationDefs()) {
AtlasClassificationDef byName = atlasClientV2.getClassificationDefByName(classificationDef.getName());
assertNotNull(byName);
}
for (AtlasEntityDef entityDef : typeDefinitions.getEntityDefs()) {
AtlasEntityDef byName = atlasClientV2.getEntityDefByName(entityDef.getName());
assertNotNull(byName);
}
}
use of org.apache.atlas.model.typedef.AtlasEnumDef in project incubator-atlas by apache.
the class AtlasTypeDefGraphStore method addToGraphStore.
private AtlasTypesDef addToGraphStore(AtlasTypesDef typesDef, AtlasTransientTypeRegistry ttr) throws AtlasBaseException {
AtlasTypesDef ret = new AtlasTypesDef();
AtlasEnumDefStore enumDefStore = getEnumDefStore(ttr);
AtlasStructDefStore structDefStore = getStructDefStore(ttr);
AtlasClassificationDefStore classifiDefStore = getClassificationDefStore(ttr);
AtlasEntityDefStore entityDefStore = getEntityDefStore(ttr);
List<Object> preCreateStructDefs = new ArrayList<>();
List<Object> preCreateClassifiDefs = new ArrayList<>();
List<Object> preCreateEntityDefs = new ArrayList<>();
if (CollectionUtils.isNotEmpty(typesDef.getEnumDefs())) {
for (AtlasEnumDef enumDef : typesDef.getEnumDefs()) {
AtlasEnumDef createdDef = enumDefStore.create(enumDef);
ttr.updateGuid(createdDef.getName(), createdDef.getGuid());
ret.getEnumDefs().add(createdDef);
}
}
if (CollectionUtils.isNotEmpty(typesDef.getStructDefs())) {
for (AtlasStructDef structDef : typesDef.getStructDefs()) {
preCreateStructDefs.add(structDefStore.preCreate(structDef));
}
}
if (CollectionUtils.isNotEmpty(typesDef.getClassificationDefs())) {
for (AtlasClassificationDef classifiDef : typesDef.getClassificationDefs()) {
preCreateClassifiDefs.add(classifiDefStore.preCreate(classifiDef));
}
}
if (CollectionUtils.isNotEmpty(typesDef.getEntityDefs())) {
for (AtlasEntityDef entityDef : typesDef.getEntityDefs()) {
preCreateEntityDefs.add(entityDefStore.preCreate(entityDef));
}
}
if (CollectionUtils.isNotEmpty(typesDef.getStructDefs())) {
int i = 0;
for (AtlasStructDef structDef : typesDef.getStructDefs()) {
AtlasStructDef createdDef = structDefStore.create(structDef, preCreateStructDefs.get(i));
ttr.updateGuid(createdDef.getName(), createdDef.getGuid());
ret.getStructDefs().add(createdDef);
i++;
}
}
if (CollectionUtils.isNotEmpty(typesDef.getClassificationDefs())) {
int i = 0;
for (AtlasClassificationDef classifiDef : typesDef.getClassificationDefs()) {
AtlasClassificationDef createdDef = classifiDefStore.create(classifiDef, preCreateClassifiDefs.get(i));
ttr.updateGuid(createdDef.getName(), createdDef.getGuid());
ret.getClassificationDefs().add(createdDef);
i++;
}
}
if (CollectionUtils.isNotEmpty(typesDef.getEntityDefs())) {
int i = 0;
for (AtlasEntityDef entityDef : typesDef.getEntityDefs()) {
AtlasEntityDef createdDef = entityDefStore.create(entityDef, preCreateEntityDefs.get(i));
ttr.updateGuid(createdDef.getName(), createdDef.getGuid());
ret.getEntityDefs().add(createdDef);
i++;
}
}
return ret;
}
use of org.apache.atlas.model.typedef.AtlasEnumDef in project incubator-atlas by apache.
the class AtlasTypeDefGraphStoreTest method testUpdateWithMandatoryFields.
@Test(enabled = false, dependsOnMethods = { "testCreateDept" })
public void testUpdateWithMandatoryFields() {
AtlasTypesDef atlasTypesDef = TestUtilsV2.defineInvalidUpdatedDeptEmployeeTypes();
List<AtlasEnumDef> enumDefsToUpdate = atlasTypesDef.getEnumDefs();
List<AtlasClassificationDef> classificationDefsToUpdate = atlasTypesDef.getClassificationDefs();
List<AtlasStructDef> structDefsToUpdate = atlasTypesDef.getStructDefs();
List<AtlasEntityDef> entityDefsToUpdate = atlasTypesDef.getEntityDefs();
AtlasTypesDef onlyEnums = new AtlasTypesDef(enumDefsToUpdate, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
AtlasTypesDef onlyStructs = new AtlasTypesDef(Collections.EMPTY_LIST, structDefsToUpdate, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
AtlasTypesDef onlyClassification = new AtlasTypesDef(Collections.EMPTY_LIST, Collections.EMPTY_LIST, classificationDefsToUpdate, Collections.EMPTY_LIST);
AtlasTypesDef onlyEntities = new AtlasTypesDef(Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, entityDefsToUpdate);
try {
AtlasTypesDef updated = typeDefStore.updateTypesDef(onlyEnums);
assertNotNull(updated);
} catch (AtlasBaseException ignored) {
}
try {
AtlasTypesDef updated = typeDefStore.updateTypesDef(onlyClassification);
assertNotNull(updated);
assertEquals(updated.getClassificationDefs().size(), 0, "Updates should've failed");
} catch (AtlasBaseException ignored) {
}
try {
AtlasTypesDef updated = typeDefStore.updateTypesDef(onlyStructs);
assertNotNull(updated);
assertEquals(updated.getStructDefs().size(), 0, "Updates should've failed");
} catch (AtlasBaseException ignored) {
}
try {
AtlasTypesDef updated = typeDefStore.updateTypesDef(onlyEntities);
assertNotNull(updated);
assertEquals(updated.getEntityDefs().size(), 0, "Updates should've failed");
} catch (AtlasBaseException ignored) {
}
}
use of org.apache.atlas.model.typedef.AtlasEnumDef in project incubator-atlas by apache.
the class AtlasTypeDefGraphStoreTest method testUpdate.
@Test(dependsOnMethods = { "testCreateDept" }, dataProvider = "validUpdateDeptTypes")
public void testUpdate(AtlasTypesDef atlasTypesDef) {
try {
AtlasTypesDef updatedTypesDef = typeDefStore.updateTypesDef(atlasTypesDef);
assertNotNull(updatedTypesDef);
assertEquals(updatedTypesDef.getEnumDefs().size(), atlasTypesDef.getEnumDefs().size(), "EnumDefs update failed");
assertEquals(updatedTypesDef.getClassificationDefs().size(), atlasTypesDef.getClassificationDefs().size(), "ClassificationDef update failed");
assertEquals(updatedTypesDef.getStructDefs().size(), atlasTypesDef.getStructDefs().size(), "StructDef update failed");
assertEquals(updatedTypesDef.getEntityDefs().size(), atlasTypesDef.getEntityDefs().size(), "EntityDef update failed");
// Try another update round by name and GUID
for (AtlasEnumDef enumDef : updatedTypesDef.getEnumDefs()) {
AtlasEnumDef updated = typeDefStore.updateEnumDefByGuid(enumDef.getGuid(), enumDef);
assertNotNull(updated);
}
for (AtlasEnumDef enumDef : atlasTypesDef.getEnumDefs()) {
AtlasEnumDef updated = typeDefStore.updateEnumDefByName(enumDef.getName(), enumDef);
assertNotNull(updated);
}
// Try another update round by name and GUID
for (AtlasClassificationDef classificationDef : updatedTypesDef.getClassificationDefs()) {
AtlasClassificationDef updated = typeDefStore.updateClassificationDefByGuid(classificationDef.getGuid(), classificationDef);
assertNotNull(updated);
}
for (AtlasClassificationDef classificationDef : atlasTypesDef.getClassificationDefs()) {
AtlasClassificationDef updated = typeDefStore.updateClassificationDefByName(classificationDef.getName(), classificationDef);
assertNotNull(updated);
}
// Try another update round by name and GUID
for (AtlasStructDef structDef : updatedTypesDef.getStructDefs()) {
AtlasStructDef updated = typeDefStore.updateStructDefByGuid(structDef.getGuid(), structDef);
assertNotNull(updated);
}
for (AtlasStructDef structDef : atlasTypesDef.getStructDefs()) {
AtlasStructDef updated = typeDefStore.updateStructDefByName(structDef.getName(), structDef);
assertNotNull(updated);
}
// Try another update round by name and GUID
for (AtlasEntityDef entityDef : updatedTypesDef.getEntityDefs()) {
AtlasEntityDef updated = typeDefStore.updateEntityDefByGuid(entityDef.getGuid(), entityDef);
assertNotNull(updated);
}
for (AtlasEntityDef entityDef : atlasTypesDef.getEntityDefs()) {
AtlasEntityDef updated = typeDefStore.updateEntityDefByName(entityDef.getName(), entityDef);
assertNotNull(updated);
}
} catch (AtlasBaseException e) {
fail("TypeDef updates should've succeeded");
}
}
Aggregations