Search in sources :

Example 21 with TypesDef

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");
}
Also used : TypesDef(org.apache.atlas.typesystem.TypesDef)

Example 22 with TypesDef

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);
}
Also used : TypesDef(org.apache.atlas.typesystem.TypesDef) Test(org.testng.annotations.Test)

Example 23 with TypesDef

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);
                }
            }
        }
    }
}
Also used : HierarchicalTypeDefinition(org.apache.atlas.typesystem.types.HierarchicalTypeDefinition) JSONObject(org.codehaus.jettison.json.JSONObject) TypesDef(org.apache.atlas.typesystem.TypesDef) AttributeDefinition(org.apache.atlas.typesystem.types.AttributeDefinition) ClassType(org.apache.atlas.typesystem.types.ClassType) Test(org.testng.annotations.Test)

Example 24 with TypesDef

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());
    }
}
Also used : TypesDef(org.apache.atlas.typesystem.TypesDef) AtlasServiceException(org.apache.atlas.AtlasServiceException) TraitType(org.apache.atlas.typesystem.types.TraitType) ClassType(org.apache.atlas.typesystem.types.ClassType) Test(org.testng.annotations.Test)

Example 25 with TypesDef

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;
}
Also used : TypesDef(org.apache.atlas.typesystem.TypesDef)

Aggregations

TypesDef (org.apache.atlas.typesystem.TypesDef)43 Test (org.testng.annotations.Test)20 ClassType (org.apache.atlas.typesystem.types.ClassType)15 TraitType (org.apache.atlas.typesystem.types.TraitType)13 AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)8 AttributeDefinition (org.apache.atlas.typesystem.types.AttributeDefinition)7 ITypedReferenceableInstance (org.apache.atlas.typesystem.ITypedReferenceableInstance)5 JSONObject (org.codehaus.jettison.json.JSONObject)5 BeforeTest (org.testng.annotations.BeforeTest)5 AtlasException (org.apache.atlas.AtlasException)4 HierarchicalTypeDefinition (org.apache.atlas.typesystem.types.HierarchicalTypeDefinition)4 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)3 Referenceable (org.apache.atlas.typesystem.Referenceable)3 Id (org.apache.atlas.typesystem.persistence.Id)3 StructTypeDefinition (org.apache.atlas.typesystem.types.StructTypeDefinition)3 BeforeClass (org.testng.annotations.BeforeClass)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2