Search in sources :

Example 36 with Referenceable

use of org.apache.atlas.v1.model.instance.Referenceable in project atlas by apache.

the class QuickStartIT method testProcessIsAdded.

@Test
public void testProcessIsAdded() throws AtlasServiceException {
    Referenceable loadProcess = atlasClientV1.getEntity(QuickStart.LOAD_PROCESS_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, QuickStart.LOAD_SALES_DAILY_PROCESS);
    assertEquals(QuickStart.LOAD_SALES_DAILY_PROCESS, loadProcess.get(AtlasClient.NAME));
    assertEquals(QuickStart.LOAD_SALES_DAILY_PROCESS_DESCRIPTION, loadProcess.get("description"));
    List<Id> inputs = (List<Id>) loadProcess.get(QuickStart.INPUTS_ATTRIBUTE);
    List<Id> outputs = (List<Id>) loadProcess.get(QuickStart.OUTPUTS_ATTRIBUTE);
    assertEquals(2, inputs.size());
    String salesFactTableId = getTableId(QuickStart.SALES_FACT_TABLE);
    String timeDimTableId = getTableId(QuickStart.TIME_DIM_TABLE);
    String salesFactDailyMVId = getTableId(QuickStart.SALES_FACT_DAILY_MV_TABLE);
    assertEquals(salesFactTableId, inputs.get(0)._getId());
    assertEquals(timeDimTableId, inputs.get(1)._getId());
    assertEquals(salesFactDailyMVId, outputs.get(0)._getId());
}
Also used : Referenceable(org.apache.atlas.v1.model.instance.Referenceable) List(java.util.List) Id(org.apache.atlas.v1.model.instance.Id) Test(org.testng.annotations.Test)

Example 37 with Referenceable

use of org.apache.atlas.v1.model.instance.Referenceable in project atlas by apache.

the class QuickStart method database.

Id database(String name, String description, String owner, String locationUri, String... traitNames) throws AtlasBaseException {
    try {
        Referenceable referenceable = new Referenceable(DATABASE_TYPE, traitNames);
        referenceable.set("name", name);
        referenceable.set("description", description);
        referenceable.set("owner", owner);
        referenceable.set("locationUri", locationUri);
        referenceable.set("createTime", System.currentTimeMillis());
        return createInstance(referenceable);
    } catch (Exception e) {
        throw new AtlasBaseException(AtlasErrorCode.QUICK_START, e, String.format("%s database entity creation failed", name));
    }
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) Referenceable(org.apache.atlas.v1.model.instance.Referenceable) AtlasException(org.apache.atlas.AtlasException) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException)

Example 38 with Referenceable

use of org.apache.atlas.v1.model.instance.Referenceable in project atlas by apache.

the class QuickStart method rawStorageDescriptor.

Referenceable rawStorageDescriptor(String location, String inputFormat, String outputFormat, boolean compressed) {
    Referenceable referenceable = new Referenceable(STORAGE_DESC_TYPE);
    referenceable.set("location", location);
    referenceable.set("inputFormat", inputFormat);
    referenceable.set("outputFormat", outputFormat);
    referenceable.set("compressed", compressed);
    return referenceable;
}
Also used : Referenceable(org.apache.atlas.v1.model.instance.Referenceable)

Example 39 with Referenceable

use of org.apache.atlas.v1.model.instance.Referenceable in project atlas by apache.

the class ColumnLineageUtils method populateColumnReferenceableMap.

static void populateColumnReferenceableMap(Map<String, Referenceable> m, Referenceable r) {
    if (r.getTypeName().equals(HiveDataTypes.HIVE_TABLE.getName())) {
        String qName = (String) r.get(ATTRIBUTE_QUALIFIED_NAME);
        String[] qNameComps = extractComponents(qName);
        for (Referenceable col : (List<Referenceable>) r.get(ATTRIBUTE_COLUMNS)) {
            String cName = (String) col.get(ATTRIBUTE_QUALIFIED_NAME);
            String[] colQNameComps = extractComponents(cName);
            String colQName = colQNameComps[0] + "." + colQNameComps[1] + "." + colQNameComps[2];
            m.put(colQName, col);
        }
        String tableQName = qNameComps[0] + "." + qNameComps[1];
        m.put(tableQName, r);
    }
}
Also used : Referenceable(org.apache.atlas.v1.model.instance.Referenceable) ArrayList(java.util.ArrayList) List(java.util.List)

Example 40 with Referenceable

use of org.apache.atlas.v1.model.instance.Referenceable in project atlas by apache.

the class SqoopHookIT method assertEntityIsRegistered.

protected String assertEntityIsRegistered(final String typeName, final String property, final String value, final AssertPredicate assertPredicate) throws Exception {
    waitFor(80000, new Predicate() {

        @Override
        public void evaluate() throws Exception {
            Referenceable entity = atlasClient.getEntity(typeName, property, value);
            assertNotNull(entity);
            if (assertPredicate != null) {
                assertPredicate.assertOnEntity(entity);
            }
        }
    });
    Referenceable entity = atlasClient.getEntity(typeName, property, value);
    return entity.getId()._getId();
}
Also used : Referenceable(org.apache.atlas.v1.model.instance.Referenceable)

Aggregations

Referenceable (org.apache.atlas.v1.model.instance.Referenceable)143 Test (org.testng.annotations.Test)64 Id (org.apache.atlas.v1.model.instance.Id)37 Struct (org.apache.atlas.v1.model.instance.Struct)23 ArrayList (java.util.ArrayList)20 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)15 HashMap (java.util.HashMap)12 List (java.util.List)10 AtlasException (org.apache.atlas.AtlasException)10 HookNotification (org.apache.atlas.model.notification.HookNotification)10 Map (java.util.Map)9 EntityUpdateRequest (org.apache.atlas.v1.model.notification.HookNotificationV1.EntityUpdateRequest)9 AtlasServiceException (org.apache.atlas.AtlasServiceException)8 EntityAuditEvent (org.apache.atlas.EntityAuditEvent)8 EntityNotificationV1 (org.apache.atlas.v1.model.notification.EntityNotificationV1)7 EntityCreateRequest (org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateRequest)7 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)6 EntityResult (org.apache.atlas.model.legacy.EntityResult)6 AtlasEntityType (org.apache.atlas.type.AtlasEntityType)6 EntityNotificationTest (org.apache.atlas.notification.entity.EntityNotificationTest)5