use of org.apache.atlas.typesystem.TypesDef in project incubator-atlas by apache.
the class DefaultMetadataService method restoreTypeSystem.
private void restoreTypeSystem() throws AtlasException {
LOG.info("Restoring type system from the store");
TypesDef typesDef = typeStore.restore();
refreshCache(typesDef);
LOG.info("Restored type system from the store");
}
use of org.apache.atlas.typesystem.TypesDef in project incubator-atlas by apache.
the class ClassTest method testSerDeWithDescription.
@Test
public void testSerDeWithDescription() throws Exception {
HierarchicalTypeDefinition<ClassType> clsType = TypesUtil.createClassTypeDef("Random", "Random-description", ImmutableSet.<String>of(), TypesUtil.createRequiredAttrDef("name", DataTypes.STRING_TYPE));
TypesDef typesDef = getTypesDef(clsType);
String json = TypesSerialization.toJson(typesDef);
System.out.println("json " + json);
TypesSerialization.fromJson(json);
}
use of org.apache.atlas.typesystem.TypesDef in project incubator-atlas by apache.
the class TypesJerseyResourceIT method testGetDefinition.
@Test(dependsOnMethods = "testSubmit")
public void testGetDefinition() throws Exception {
for (HierarchicalTypeDefinition typeDefinition : typeDefinitions) {
System.out.println("typeName = " + typeDefinition.typeName);
JSONObject response = atlasClientV1.callAPIWithBodyAndParams(AtlasClient.API.LIST_TYPES, null, typeDefinition.typeName);
Assert.assertNotNull(response);
Assert.assertNotNull(response.get(AtlasClient.DEFINITION));
Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
String typesJson = response.getString(AtlasClient.DEFINITION);
final TypesDef typesDef = TypesSerialization.fromJson(typesJson);
List<HierarchicalTypeDefinition<ClassType>> hierarchicalTypeDefinitions = typesDef.classTypesAsJavaList();
for (HierarchicalTypeDefinition<ClassType> classType : hierarchicalTypeDefinitions) {
for (AttributeDefinition attrDef : classType.attributeDefinitions) {
if (NAME.equals(attrDef.name)) {
assertEquals(attrDef.isIndexable, true);
assertEquals(attrDef.isUnique, true);
}
}
}
}
}
use of org.apache.atlas.typesystem.TypesDef in project incubator-atlas by apache.
the class TypesJerseyResourceIT method testDuplicateSubmit.
@Test
public void testDuplicateSubmit() throws Exception {
HierarchicalTypeDefinition<ClassType> type = TypesUtil.createClassTypeDef(randomString(), ImmutableSet.<String>of(), TypesUtil.createUniqueRequiredAttrDef(NAME, DataTypes.STRING_TYPE));
TypesDef typesDef = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(), ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(), ImmutableList.of(type));
atlasClientV1.createType(typesDef);
try {
atlasClientV1.createType(typesDef);
fail("Expected 409");
} catch (AtlasServiceException e) {
assertEquals(e.getStatus().getStatusCode(), Response.Status.CONFLICT.getStatusCode());
}
}
use of org.apache.atlas.typesystem.TypesDef in project incubator-atlas by apache.
the class StoreBackedTypeCache method getTypeFromStore.
private TypesDef getTypeFromStore(String typeName, Context context) throws AtlasException {
TypesDef typesDef = typeStore.restoreType(typeName);
if (!typesDef.isEmpty()) {
// Type found in store, add it to lists.
context.addTypesDefToLists(typesDef);
// Check the attribute and super types that are
// used by the requested type, and restore them
// as needed.
checkAttributeAndSuperTypes(typesDef, context);
}
return typesDef;
}
Aggregations