Search in sources :

Example 11 with AtlasEntityWithExtInfo

use of org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo in project incubator-atlas by apache.

the class AtlasEntityStoreV1 method getById.

@Override
@GraphTransaction
public AtlasEntityWithExtInfo getById(String guid) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> getById({})", guid);
    }
    EntityGraphRetriever entityRetriever = new EntityGraphRetriever(typeRegistry);
    AtlasEntityWithExtInfo ret = entityRetriever.toAtlasEntityWithExtInfo(guid);
    if (ret == null) {
        throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("<== getById({}): {}", guid, ret);
    }
    return ret;
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasEntityWithExtInfo(org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo) GraphTransaction(org.apache.atlas.annotation.GraphTransaction)

Example 12 with AtlasEntityWithExtInfo

use of org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo in project incubator-atlas by apache.

the class ImportTransformsTest method transformEntityWithExtInfo.

@Test
public void transformEntityWithExtInfo() throws AtlasBaseException {
    addColumnTransform(transform);
    AtlasEntityWithExtInfo entityWithExtInfo = getAtlasEntityWithExtInfo();
    AtlasEntity entity = entityWithExtInfo.getEntity();
    String attrValue = (String) entity.getAttribute(qualifiedName);
    String[] expectedValues = getExtEntityExpectedValues(entityWithExtInfo);
    transform.apply(entityWithExtInfo);
    assertEquals(entityWithExtInfo.getEntity().getAttribute(qualifiedName), applyDefaultTransform(attrValue));
    for (int i = 0; i < expectedValues.length; i++) {
        assertEquals(entityWithExtInfo.getReferredEntities().get(Integer.toString(i)).getAttribute(qualifiedName), expectedValues[i]);
    }
}
Also used : AtlasEntityWithExtInfo(org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo) AtlasEntity(org.apache.atlas.model.instance.AtlasEntity) BeforeTest(org.testng.annotations.BeforeTest) Test(org.testng.annotations.Test)

Example 13 with AtlasEntityWithExtInfo

use of org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo in project incubator-atlas by apache.

the class ImportTransformsTest method transformEntityWithExtInfoNullCheck.

@Test
public void transformEntityWithExtInfoNullCheck() throws AtlasBaseException {
    addColumnTransform(transform);
    AtlasEntityWithExtInfo entityWithExtInfo = getAtlasEntityWithExtInfo();
    entityWithExtInfo.setReferredEntities(null);
    AtlasEntityWithExtInfo transformedEntityWithExtInfo = transform.apply(entityWithExtInfo);
    assertNotNull(transformedEntityWithExtInfo);
    assertEquals(entityWithExtInfo.getEntity().getGuid(), transformedEntityWithExtInfo.getEntity().getGuid());
}
Also used : AtlasEntityWithExtInfo(org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo) BeforeTest(org.testng.annotations.BeforeTest) Test(org.testng.annotations.Test)

Example 14 with AtlasEntityWithExtInfo

use of org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo in project incubator-atlas by apache.

the class TestEntityREST method testGetEntityWithAssociations.

@Test(dependsOnMethods = "testAddAndGetClassification")
public void testGetEntityWithAssociations() throws Exception {
    AtlasEntityWithExtInfo entity = entityREST.getById(dbEntity.getGuid());
    final List<AtlasClassification> retrievedClassifications = entity.getEntity().getClassifications();
    Assert.assertNotNull(retrievedClassifications);
    Assert.assertEquals(new ArrayList<AtlasClassification>() {

        {
            add(testClassification);
        }
    }, retrievedClassifications);
}
Also used : AtlasEntityWithExtInfo(org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo) AtlasClassification(org.apache.atlas.model.instance.AtlasClassification) Test(org.testng.annotations.Test)

Example 15 with AtlasEntityWithExtInfo

use of org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo in project incubator-atlas by apache.

the class EntityGraphRetriever method toAtlasEntityWithExtInfo.

public AtlasEntityWithExtInfo toAtlasEntityWithExtInfo(AtlasVertex entityVertex) throws AtlasBaseException {
    AtlasEntityExtInfo entityExtInfo = new AtlasEntityExtInfo();
    AtlasEntity entity = mapVertexToAtlasEntity(entityVertex, entityExtInfo);
    AtlasEntityWithExtInfo ret = new AtlasEntityWithExtInfo(entity, entityExtInfo);
    ret.compact();
    return ret;
}
Also used : AtlasEntityExtInfo(org.apache.atlas.model.instance.AtlasEntity.AtlasEntityExtInfo) AtlasEntityWithExtInfo(org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo) AtlasEntity(org.apache.atlas.model.instance.AtlasEntity)

Aggregations

AtlasEntityWithExtInfo (org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo)34 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)24 EntityMutationResponse (org.apache.atlas.model.instance.EntityMutationResponse)18 Test (org.testng.annotations.Test)17 AtlasEntitiesWithExtInfo (org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo)8 AtlasEntityHeader (org.apache.atlas.model.instance.AtlasEntityHeader)8 HashMap (java.util.HashMap)6 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)6 AtlasEntityType (org.apache.atlas.type.AtlasEntityType)6 AtlasObjectId (org.apache.atlas.model.instance.AtlasObjectId)5 GraphTransaction (org.apache.atlas.annotation.GraphTransaction)4 BeforeTest (org.testng.annotations.BeforeTest)4 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 AtlasServiceException (org.apache.atlas.AtlasServiceException)2 TestUtils.randomString (org.apache.atlas.TestUtils.randomString)2 AtlasClassification (org.apache.atlas.model.instance.AtlasClassification)2 AtlasStruct (org.apache.atlas.model.instance.AtlasStruct)2 AtlasEntityDef (org.apache.atlas.model.typedef.AtlasEntityDef)2 AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)2