use of org.apache.atlas.model.typedef.AtlasEntityDef in project incubator-atlas by apache.
the class AtlasEntityDefStoreV1 method getByName.
@Override
public AtlasEntityDef getByName(String name) throws AtlasBaseException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasEntityDefStoreV1.getByName({})", name);
}
AtlasVertex vertex = typeDefStore.findTypeVertexByNameAndCategory(name, TypeCategory.CLASS);
if (vertex == null) {
throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_NOT_FOUND, name);
}
vertex.getProperty(Constants.TYPE_CATEGORY_PROPERTY_KEY, TypeCategory.class);
AtlasEntityDef ret = toEntityDef(vertex);
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasEntityDefStoreV1.getByName({}): {}", name, ret);
}
return ret;
}
use of org.apache.atlas.model.typedef.AtlasEntityDef in project incubator-atlas by apache.
the class AtlasEntityDefStoreV1 method toEntityDef.
private AtlasEntityDef toEntityDef(AtlasVertex vertex) throws AtlasBaseException {
AtlasEntityDef ret = null;
if (vertex != null && typeDefStore.isTypeVertex(vertex, TypeCategory.CLASS)) {
ret = new AtlasEntityDef();
AtlasStructDefStoreV1.toStructDef(vertex, ret, typeDefStore);
ret.setSuperTypes(typeDefStore.getSuperTypeNames(vertex));
}
return ret;
}
use of org.apache.atlas.model.typedef.AtlasEntityDef in project incubator-atlas by apache.
the class EntityDiscoveryServiceTest method init.
@BeforeClass
public void init() throws AtlasBaseException {
typeTest = new AtlasEntityDef(TEST_TYPE);
typeTest1 = new AtlasEntityDef(TEST_TYPE1);
typeTest2 = new AtlasEntityDef(TEST_TYPE2);
typeTest3 = new AtlasEntityDef(TEST_TYPE3);
typeWithSubTypes = new AtlasEntityDef(TEST_TYPE_WITH_SUB_TYPES);
typeTest1.addSuperType(TEST_TYPE_WITH_SUB_TYPES);
typeTest2.addSuperType(TEST_TYPE_WITH_SUB_TYPES);
typeTest3.addSuperType(TEST_TYPE_WITH_SUB_TYPES);
AtlasTypeRegistry.AtlasTransientTypeRegistry ttr = typeRegistry.lockTypeRegistryForUpdate();
ttr.addType(typeTest);
ttr.addType(typeWithSubTypes);
ttr.addType(typeTest1);
ttr.addType(typeTest2);
ttr.addType(typeTest3);
typeRegistry.releaseTypeRegistryForUpdate(ttr, true);
}
use of org.apache.atlas.model.typedef.AtlasEntityDef in project incubator-atlas by apache.
the class AtlasTypeDefGraphStoreTest method testCreateWithInvalidSuperTypes.
@Test(dependsOnMethods = "testGet")
public void testCreateWithInvalidSuperTypes() {
AtlasTypesDef typesDef;
// Test Classification with supertype
AtlasClassificationDef classificationDef = TestUtilsV2.getClassificationWithInvalidSuperType();
typesDef = new AtlasTypesDef();
typesDef.getClassificationDefs().add(classificationDef);
try {
AtlasTypesDef created = typeDefStore.createTypesDef(typesDef);
fail("Classification creation with invalid supertype should've failed");
} catch (AtlasBaseException e) {
typesDef = null;
}
// Test Entity with supertype
AtlasEntityDef entityDef = TestUtilsV2.getEntityWithInvalidSuperType();
typesDef = new AtlasTypesDef();
typesDef.getEntityDefs().add(entityDef);
try {
AtlasTypesDef created = typeDefStore.createTypesDef(typesDef);
fail("Entity creation with invalid supertype should've failed");
} catch (AtlasBaseException e) {
}
}
use of org.apache.atlas.model.typedef.AtlasEntityDef 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) {
}
}
Aggregations