Search in sources :

Example 36 with ClassType

use of org.apache.atlas.typesystem.types.ClassType in project incubator-atlas by apache.

the class QueryProcessorTest method findTypeLookupsDuringQueryParsing.

private ValidatingTypeCache findTypeLookupsDuringQueryParsing(String query) throws AtlasException {
    TypeSystem typeSystem = TypeSystem.getInstance();
    ValidatingTypeCache result = new ValidatingTypeCache();
    typeSystem.setTypeCache(result);
    typeSystem.reset();
    HierarchicalTypeDefinition<ClassType> hiveTypeDef = createClassTypeDef("hive_db", "", ImmutableSet.<String>of(), createRequiredAttrDef("name", DataTypes.STRING_TYPE), createRequiredAttrDef("tableCount", DataTypes.INT_TYPE));
    typeSystem.defineClassType(hiveTypeDef);
    Either<Parsers.NoSuccess, Expressions.Expression> either = QueryParser.apply(query, null);
    Expressions.Expression expression = either.right().get();
    QueryProcessor.validate(expression);
    return result;
}
Also used : TypeSystem(org.apache.atlas.typesystem.types.TypeSystem) ClassType(org.apache.atlas.typesystem.types.ClassType)

Example 37 with ClassType

use of org.apache.atlas.typesystem.types.ClassType in project incubator-atlas by apache.

the class GraphBackedDiscoveryServiceTest method setUp.

@Override
@BeforeClass
public void setUp() throws Exception {
    super.setUp();
    repositoryService = TestUtils.addTransactionWrapper(repositoryService);
    final TypeSystem typeSystem = TypeSystem.getInstance();
    Collection<String> oldTypeNames = new HashSet<>();
    oldTypeNames.addAll(typeSystem.getTypeNames());
    TestUtils.defineDeptEmployeeTypes(typeSystem);
    addIndexesForNewTypes(oldTypeNames, typeSystem);
    ITypedReferenceableInstance hrDept = TestUtils.createDeptEg1(typeSystem);
    repositoryService.createEntities(hrDept);
    ITypedReferenceableInstance jane = repositoryService.getEntityDefinition("Manager", "name", "Jane");
    Id janeGuid = jane.getId();
    ClassType personType = typeSystem.getDataType(ClassType.class, "Person");
    ITypedReferenceableInstance instance = personType.createInstance(janeGuid);
    instance.set("orgLevel", "L1");
    repositoryService.updatePartial(instance);
}
Also used : TypeSystem(org.apache.atlas.typesystem.types.TypeSystem) ITypedReferenceableInstance(org.apache.atlas.typesystem.ITypedReferenceableInstance) Id(org.apache.atlas.typesystem.persistence.Id) ClassType(org.apache.atlas.typesystem.types.ClassType) BeforeClass(org.testng.annotations.BeforeClass)

Example 38 with ClassType

use of org.apache.atlas.typesystem.types.ClassType in project incubator-atlas by apache.

the class StoreBackedTypeCacheTest method setUp.

@BeforeClass
public void setUp() throws Exception {
    //force graph to be initialized up front
    TestUtils.getGraph();
    ts = TypeSystem.getInstance();
    ts.reset();
    ts.setTypeCache(typeCache);
    // Populate the type store for testing.
    TestUtils.defineDeptEmployeeTypes(ts);
    TestUtils.createHiveTypes(ts);
    ImmutableList<String> typeNames = ts.getTypeNames();
    typeStore.store(ts, typeNames);
    ClassType type = ts.getDataType(ClassType.class, "Manager");
    classTypesToTest.put("Manager", type);
    type = ts.getDataType(ClassType.class, TestUtils.TABLE_TYPE);
    classTypesToTest.put(TestUtils.TABLE_TYPE, type);
}
Also used : ClassType(org.apache.atlas.typesystem.types.ClassType) BeforeClass(org.testng.annotations.BeforeClass)

Example 39 with ClassType

use of org.apache.atlas.typesystem.types.ClassType in project incubator-atlas by apache.

the class MetadataDiscoveryJerseyResourceIT method createTypes.

private void createTypes() throws Exception {
    createTypeDefinitionsV1();
    HierarchicalTypeDefinition<ClassType> dslTestTypeDefinition = TypesUtil.createClassTypeDef("dsl_test_type", ImmutableSet.<String>of(), TypesUtil.createUniqueRequiredAttrDef("name", DataTypes.STRING_TYPE), TypesUtil.createRequiredAttrDef("description", DataTypes.STRING_TYPE));
    HierarchicalTypeDefinition<TraitType> classificationTraitDefinition = TypesUtil.createTraitTypeDef("Classification", ImmutableSet.<String>of(), TypesUtil.createRequiredAttrDef("tag", DataTypes.STRING_TYPE));
    TypesDef typesDef = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(), ImmutableList.of(classificationTraitDefinition), ImmutableList.of(dslTestTypeDefinition));
    createType(typesDef);
}
Also used : TypesDef(org.apache.atlas.typesystem.TypesDef) TraitType(org.apache.atlas.typesystem.types.TraitType) ClassType(org.apache.atlas.typesystem.types.ClassType)

Example 40 with ClassType

use of org.apache.atlas.typesystem.types.ClassType in project incubator-atlas by apache.

the class TypesJerseyResourceIT method testUpdate.

@Test
public void testUpdate() throws Exception {
    HierarchicalTypeDefinition<ClassType> typeDefinition = TypesUtil.createClassTypeDef(randomString(), ImmutableSet.<String>of(), TypesUtil.createUniqueRequiredAttrDef(NAME, DataTypes.STRING_TYPE));
    List<String> typesCreated = atlasClientV1.createType(TypesSerialization.toJson(typeDefinition, false));
    assertEquals(typesCreated.size(), 1);
    assertEquals(typesCreated.get(0), typeDefinition.typeName);
    //Add attribute description
    typeDefinition = TypesUtil.createClassTypeDef(typeDefinition.typeName, ImmutableSet.<String>of(), TypesUtil.createUniqueRequiredAttrDef(NAME, DataTypes.STRING_TYPE), createOptionalAttrDef(DESCRIPTION, DataTypes.STRING_TYPE));
    TypesDef typeDef = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(), ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(), ImmutableList.of(typeDefinition));
    List<String> typesUpdated = atlasClientV1.updateType(typeDef);
    assertEquals(typesUpdated.size(), 1);
    Assert.assertTrue(typesUpdated.contains(typeDefinition.typeName));
    TypesDef updatedTypeDef = atlasClientV1.getType(typeDefinition.typeName);
    assertNotNull(updatedTypeDef);
    HierarchicalTypeDefinition<ClassType> updatedType = updatedTypeDef.classTypesAsJavaList().get(0);
    assertEquals(updatedType.attributeDefinitions.length, 2);
}
Also used : TypesDef(org.apache.atlas.typesystem.TypesDef) TraitType(org.apache.atlas.typesystem.types.TraitType) ClassType(org.apache.atlas.typesystem.types.ClassType) Test(org.testng.annotations.Test)

Aggregations

ClassType (org.apache.atlas.typesystem.types.ClassType)54 Test (org.testng.annotations.Test)26 ITypedReferenceableInstance (org.apache.atlas.typesystem.ITypedReferenceableInstance)19 TraitType (org.apache.atlas.typesystem.types.TraitType)19 AttributeDefinition (org.apache.atlas.typesystem.types.AttributeDefinition)17 Referenceable (org.apache.atlas.typesystem.Referenceable)16 TypesDef (org.apache.atlas.typesystem.TypesDef)15 ArrayList (java.util.ArrayList)12 Id (org.apache.atlas.typesystem.persistence.Id)8 TypeSystem (org.apache.atlas.typesystem.types.TypeSystem)8 Date (java.util.Date)5 HashMap (java.util.HashMap)5 HierarchicalTypeDefinition (org.apache.atlas.typesystem.types.HierarchicalTypeDefinition)5 BeforeTest (org.testng.annotations.BeforeTest)5 AtlasException (org.apache.atlas.AtlasException)4 JSONObject (org.codehaus.jettison.json.JSONObject)4 CreateUpdateEntitiesResult (org.apache.atlas.CreateUpdateEntitiesResult)3 AtlasEntityDef (org.apache.atlas.model.typedef.AtlasEntityDef)3 AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)3 IReferenceableInstance (org.apache.atlas.typesystem.IReferenceableInstance)3