Java Code Examples for org.apache.atlas.model.instance.AtlasClassification#AtlasClassifications

The following examples show how to use org.apache.atlas.model.instance.AtlasClassification#AtlasClassifications . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityREST.java    From atlas with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the list of classifications for a given entity represented by a guid.
 * @param guid globally unique identifier for the entity
 * @return a list of classifications for the given entity guid
 */
@GET
@Path("/guid/{guid}/classifications")
public AtlasClassification.AtlasClassifications getClassifications(@PathParam("guid") String guid) throws AtlasBaseException {
    Servlets.validateQueryParamLength("guid", guid);

    AtlasPerfTracer perf = null;

    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.getClassifications(" + guid + ")");
        }

        if (StringUtils.isEmpty(guid)) {
            throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
        }

        return new AtlasClassification.AtlasClassifications(entitiesStore.getClassifications(guid));
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
 
Example 2
Source File: TestEntityREST.java    From atlas with Apache License 2.0 6 votes vote down vote up
@Test(dependsOnMethods = "testGetEntityWithAssociations")
public void testDeleteClassification() throws Exception {

    deleteClassification(dbEntity.getGuid(), TestUtilsV2.CLASSIFICATION);
    final AtlasClassification.AtlasClassifications retrievedClassifications = entityREST.getClassifications(dbEntity.getGuid());

    String expectedClsNames    = "";
    AtlasVertex vertex         = AtlasGraphUtilsV2.findByGuid(dbEntity.getGuid());
    String classificationNames = vertex.getProperty(Constants.CLASSIFICATION_NAMES_KEY, String.class);

    Assert.assertNotNull(classificationNames);
    Assert.assertEquals(classificationNames, expectedClsNames);

    Assert.assertNotNull(retrievedClassifications);
    Assert.assertEquals(retrievedClassifications.getList().size(), 0);
}
 
Example 3
Source File: EntityREST.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the list of classifications for a given entity represented by a guid.
 * @param guid globally unique identifier for the entity
 * @return a list of classifications for the given entity guid
 */
@GET
@Path("/guid/{guid}/classifications")
@Produces(Servlets.JSON_MEDIA_TYPE)
public AtlasClassification.AtlasClassifications getClassifications(@PathParam("guid") String guid) throws AtlasBaseException {
    AtlasPerfTracer perf = null;

    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.getClassifications(" + guid + ")");
        }

        if (StringUtils.isEmpty(guid)) {
            throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
        }

        return new AtlasClassification.AtlasClassifications(entitiesStore.getClassifications(guid));
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
 
Example 4
Source File: TestEntityREST.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
@Test(dependsOnMethods = "testGetEntityById")
public void  testAddAndGetClassification() throws Exception {

    List<AtlasClassification> classifications = new ArrayList<>();
    testClassification = new AtlasClassification(TestUtilsV2.CLASSIFICATION, new HashMap<String, Object>() {{ put("tag", "tagName"); }});
    classifications.add(testClassification);
    entityREST.addClassifications(dbEntity.getGuid(), classifications);

    final AtlasClassification.AtlasClassifications retrievedClassifications = entityREST.getClassifications(dbEntity.getGuid());
    Assert.assertNotNull(retrievedClassifications);
    final List<AtlasClassification> retrievedClassificationsList = retrievedClassifications.getList();
    Assert.assertNotNull(retrievedClassificationsList);

    Assert.assertEquals(classifications, retrievedClassificationsList);

    final AtlasClassification retrievedClassification = entityREST.getClassification(dbEntity.getGuid(), TestUtilsV2.CLASSIFICATION);

    Assert.assertNotNull(retrievedClassification);
    Assert.assertEquals(retrievedClassification, testClassification);
}
 
Example 5
Source File: TestEntityREST.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Test(dependsOnMethods = "testGetEntityById")
public void testAddAndGetClassification() throws Exception {

    List<AtlasClassification> classifications = new ArrayList<>();
    testClassification = new AtlasClassification(TestUtilsV2.CLASSIFICATION, new HashMap<String, Object>() {{ put("tag", "tagName"); }});
    classifications.add(testClassification);
    entityREST.addClassifications(dbEntity.getGuid(), classifications);

    final AtlasClassification.AtlasClassifications retrievedClassifications = entityREST.getClassifications(dbEntity.getGuid());
    Assert.assertNotNull(retrievedClassifications);
    final List<AtlasClassification> retrievedClassificationsList = retrievedClassifications.getList();
    Assert.assertNotNull(retrievedClassificationsList);

    Assert.assertEquals(classifications, retrievedClassificationsList);

    final AtlasClassification retrievedClassification = entityREST.getClassification(dbEntity.getGuid(), TestUtilsV2.CLASSIFICATION);

    Assert.assertNotNull(retrievedClassification);
    Assert.assertEquals(retrievedClassification, testClassification);

    // For ATLAS-3327 to test internal properties are added properly.
    AtlasVertex vertex         = AtlasGraphUtilsV2.findByGuid(dbEntity.getGuid());
    String expectedClsName     = Constants.CLASSIFICATION_NAME_DELIMITER + TestUtilsV2.CLASSIFICATION + Constants.CLASSIFICATION_NAME_DELIMITER ;
    String classificationNames = vertex.getProperty(Constants.CLASSIFICATION_NAMES_KEY, String.class);

    Assert.assertNotNull(classificationNames);
    Assert.assertEquals(classificationNames, expectedClsName);
}
 
Example 6
Source File: TestEntityREST.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Test(dependsOnMethods = "testUpdateClassificationByUniqueAttribute" )
public void testDeleteClassificationByUniqueAttribute() throws Exception {
    entityREST.deleteClassificationByUniqueAttribute(TestUtilsV2.DATABASE_TYPE, toHttpServletRequest(TestUtilsV2.NAME, (String) dbEntity.getAttribute(TestUtilsV2.NAME)), TestUtilsV2.CLASSIFICATION);
    entityREST.deleteClassificationByUniqueAttribute(TestUtilsV2.DATABASE_TYPE, toHttpServletRequest(TestUtilsV2.NAME, (String) dbEntity.getAttribute(TestUtilsV2.NAME)), TestUtilsV2.PHI);

    final AtlasClassification.AtlasClassifications retrievedClassifications = entityREST.getClassifications(dbEntity.getGuid());

    Assert.assertNotNull(retrievedClassifications);
    Assert.assertEquals(retrievedClassifications.getList().size(), 0);
}
 
Example 7
Source File: TestEntityREST.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
@Test(dependsOnMethods = "testGetEntityWithAssociations")
public void  testDeleteClassification() throws Exception {

    entityREST.deleteClassification(dbEntity.getGuid(), TestUtilsV2.CLASSIFICATION);
    final AtlasClassification.AtlasClassifications retrievedClassifications = entityREST.getClassifications(dbEntity.getGuid());

    Assert.assertNotNull(retrievedClassifications);
    Assert.assertEquals(retrievedClassifications.getList().size(), 0);
}
 
Example 8
Source File: QuickStartV2IT.java    From incubator-atlas with Apache License 2.0 4 votes vote down vote up
private void verifyTrait(AtlasEntity table) throws AtlasServiceException {
    AtlasClassification.AtlasClassifications classfications = atlasClientV2.getClassifications(table.getGuid());
    List<AtlasClassification> traits = classfications.getList();
    assertNotNull(traits.get(0).getTypeName());
}
 
Example 9
Source File: TestEntityREST.java    From atlas with Apache License 2.0 3 votes vote down vote up
@Test(dependsOnMethods = "testDeleteClassification")
public void testAddClassificationByUniqueAttribute() throws Exception {
    testClassification = new AtlasClassification(TestUtilsV2.CLASSIFICATION, Collections.singletonMap("tag", "tagName"));

    List<AtlasClassification> classifications = Collections.singletonList(testClassification);

    entityREST.addClassificationsByUniqueAttribute(TestUtilsV2.DATABASE_TYPE, toHttpServletRequest(TestUtilsV2.NAME, (String) dbEntity.getAttribute(TestUtilsV2.NAME)), classifications);

    final AtlasClassification.AtlasClassifications retrievedClassifications = entityREST.getClassifications(dbEntity.getGuid());

    Assert.assertNotNull(retrievedClassifications);

    final List<AtlasClassification> retrievedClassificationsList = retrievedClassifications.getList();

    Assert.assertNotNull(retrievedClassificationsList);

    Assert.assertEquals(classifications, retrievedClassificationsList);

    String expectedClsNames    = Constants.CLASSIFICATION_NAME_DELIMITER + TestUtilsV2.CLASSIFICATION + Constants.CLASSIFICATION_NAME_DELIMITER;
    AtlasVertex vertex         = AtlasGraphUtilsV2.findByGuid(dbEntity.getGuid());
    String classificationNames = vertex.getProperty(Constants.CLASSIFICATION_NAMES_KEY, String.class);

    Assert.assertNotNull(classificationNames);
    Assert.assertEquals(classificationNames, expectedClsNames);

    final AtlasClassification retrievedClassification = entityREST.getClassification(dbEntity.getGuid(), TestUtilsV2.CLASSIFICATION);

    Assert.assertNotNull(retrievedClassification);
    Assert.assertEquals(retrievedClassification, testClassification);
}