Search in sources :

Example 6 with AtlasEntityDef

use of org.apache.atlas.model.typedef.AtlasEntityDef in project incubator-atlas by apache.

the class TestUtilsV2 method getEntityWithInvalidSuperType.

public static AtlasEntityDef getEntityWithInvalidSuperType() {
    AtlasEntityDef entityDef = simpleType().getEntityDefs().get(0);
    entityDef.addSuperType("!@#$%");
    return entityDef;
}
Also used : AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef)

Example 7 with AtlasEntityDef

use of org.apache.atlas.model.typedef.AtlasEntityDef in project incubator-atlas by apache.

the class TestUtilsV2 method simpleTypeUpdated.

public static AtlasTypesDef simpleTypeUpdated() {
    AtlasEntityDef superTypeDefinition = AtlasTypeUtil.createClassTypeDef("h_type", ImmutableSet.<String>of(), AtlasTypeUtil.createOptionalAttrDef("attr", "string"));
    AtlasEntityDef newSuperTypeDefinition = AtlasTypeUtil.createClassTypeDef("new_h_type", ImmutableSet.<String>of(), AtlasTypeUtil.createOptionalAttrDef("attr", "string"));
    AtlasStructDef structTypeDefinition = new AtlasStructDef("s_type", "structType", "1.0", Arrays.asList(AtlasTypeUtil.createRequiredAttrDef("name", "string")));
    AtlasClassificationDef traitTypeDefinition = AtlasTypeUtil.createTraitTypeDef("t_type", "traitType", ImmutableSet.<String>of());
    AtlasEnumDef enumTypeDefinition = new AtlasEnumDef("e_type", "enumType", Arrays.asList(new AtlasEnumElementDef("ONE", "Element Description", 1)));
    return AtlasTypeUtil.getTypesDef(ImmutableList.of(enumTypeDefinition), ImmutableList.of(structTypeDefinition), ImmutableList.of(traitTypeDefinition), ImmutableList.of(superTypeDefinition, newSuperTypeDefinition));
}
Also used : AtlasStructDef(org.apache.atlas.model.typedef.AtlasStructDef) AtlasClassificationDef(org.apache.atlas.model.typedef.AtlasClassificationDef) AtlasEnumElementDef(org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumElementDef) AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) AtlasEnumDef(org.apache.atlas.model.typedef.AtlasEnumDef)

Example 8 with AtlasEntityDef

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);
}
Also used : AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) AtlasTypeRegistry(org.apache.atlas.type.AtlasTypeRegistry) BeforeClass(org.testng.annotations.BeforeClass)

Example 9 with AtlasEntityDef

use of org.apache.atlas.model.typedef.AtlasEntityDef in project incubator-atlas by apache.

the class EntityV2JerseyResourceIT method addNewType.

private String addNewType() throws Exception {
    String typeName = "test" + randomString();
    AtlasEntityDef classTypeDef = AtlasTypeUtil.createClassTypeDef(typeName, ImmutableSet.<String>of(), AtlasTypeUtil.createRequiredAttrDef("name", "string"), AtlasTypeUtil.createRequiredAttrDef("description", "string"));
    AtlasTypesDef typesDef = new AtlasTypesDef();
    typesDef.getEntityDefs().add(classTypeDef);
    createType(typesDef);
    return typeName;
}
Also used : AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef)

Example 10 with AtlasEntityDef

use of org.apache.atlas.model.typedef.AtlasEntityDef in project incubator-atlas by apache.

the class EntityV2JerseyResourceIT method testEntityDefinitionAcrossTypeUpdate.

@Test
public void testEntityDefinitionAcrossTypeUpdate() throws Exception {
    //create type
    AtlasEntityDef entityDef = AtlasTypeUtil.createClassTypeDef(randomString(), ImmutableSet.<String>of(), AtlasTypeUtil.createUniqueRequiredAttrDef("name", "string"));
    AtlasTypesDef typesDef = new AtlasTypesDef();
    typesDef.getEntityDefs().add(entityDef);
    AtlasTypesDef created = atlasClientV2.createAtlasTypeDefs(typesDef);
    assertNotNull(created);
    assertNotNull(created.getEntityDefs());
    assertEquals(created.getEntityDefs().size(), 1);
    //create entity for the type
    AtlasEntity instance = new AtlasEntity(entityDef.getName());
    instance.setAttribute("name", randomString());
    EntityMutationResponse mutationResponse = atlasClientV2.createEntity(new AtlasEntityWithExtInfo(instance));
    assertNotNull(mutationResponse);
    assertNotNull(mutationResponse.getEntitiesByOperation(EntityMutations.EntityOperation.CREATE));
    assertEquals(mutationResponse.getEntitiesByOperation(EntityMutations.EntityOperation.CREATE).size(), 1);
    String guid = mutationResponse.getEntitiesByOperation(EntityMutations.EntityOperation.CREATE).get(0).getGuid();
    //update type - add attribute
    entityDef = AtlasTypeUtil.createClassTypeDef(entityDef.getName(), ImmutableSet.<String>of(), AtlasTypeUtil.createUniqueRequiredAttrDef("name", "string"), AtlasTypeUtil.createOptionalAttrDef("description", "string"));
    typesDef = new AtlasTypesDef();
    typesDef.getEntityDefs().add(entityDef);
    AtlasTypesDef updated = atlasClientV2.updateAtlasTypeDefs(typesDef);
    assertNotNull(updated);
    assertNotNull(updated.getEntityDefs());
    assertEquals(updated.getEntityDefs().size(), 1);
    //Get definition after type update - new attributes should be null
    AtlasEntity entityByGuid = getEntityByGuid(guid);
    assertNull(entityByGuid.getAttribute("description"));
    assertEquals(entityByGuid.getAttribute("name"), instance.getAttribute("name"));
}
Also used : AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) AtlasEntityWithExtInfo(org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo) AtlasEntity(org.apache.atlas.model.instance.AtlasEntity) EntityMutationResponse(org.apache.atlas.model.instance.EntityMutationResponse) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef) Test(org.testng.annotations.Test)

Aggregations

AtlasEntityDef (org.apache.atlas.model.typedef.AtlasEntityDef)67 AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)30 Test (org.testng.annotations.Test)25 AtlasClassificationDef (org.apache.atlas.model.typedef.AtlasClassificationDef)24 AtlasStructDef (org.apache.atlas.model.typedef.AtlasStructDef)24 AtlasEnumDef (org.apache.atlas.model.typedef.AtlasEnumDef)19 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)18 ArrayList (java.util.ArrayList)17 AtlasAttributeDef (org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef)17 AtlasConstraintDef (org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef)14 HashMap (java.util.HashMap)12 AtlasTransientTypeRegistry (org.apache.atlas.type.AtlasTypeRegistry.AtlasTransientTypeRegistry)9 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)7 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)7 AtlasTypeRegistry (org.apache.atlas.type.AtlasTypeRegistry)7 AtlasEnumElementDef (org.apache.atlas.model.typedef.AtlasEnumDef.AtlasEnumElementDef)6 AtlasErrorCode (org.apache.atlas.AtlasErrorCode)5 AtlasEntityHeader (org.apache.atlas.model.instance.AtlasEntityHeader)5 EntityMutationResponse (org.apache.atlas.model.instance.EntityMutationResponse)5 AtlasEntityType (org.apache.atlas.type.AtlasEntityType)5