use of org.apache.atlas.model.glossary.AtlasGlossaryCategory in project atlas by apache.
the class GlossaryREST method partialUpdateGlossaryCategory.
/**
* Partially update the glossary category
* @param categoryGuid unique identifier for glossary term
* @param partialUpdates Map containing keys as attribute names and values as corresponding attribute values
* @return Updated glossary category
* @throws AtlasBaseException
* @HTTP 200 If glossary category partial update was successful
* @HTTP 404 If glossary category guid in invalid
* @HTTP 400 If category attributes are invalid
*/
@PUT
@Path("/category/{categoryGuid}/partial")
@Timed
public AtlasGlossaryCategory partialUpdateGlossaryCategory(@PathParam("categoryGuid") String categoryGuid, Map<String, String> partialUpdates) throws AtlasBaseException {
Servlets.validateQueryParamLength("categoryGuid", categoryGuid);
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "GlossaryREST.partialUpdateGlossaryCategory()");
}
if (MapUtils.isEmpty(partialUpdates)) {
throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "PartialUpdates missing or empty");
}
AtlasGlossaryCategory glossaryCategory = glossaryService.getCategory(categoryGuid);
for (Map.Entry<String, String> entry : partialUpdates.entrySet()) {
try {
glossaryCategory.setAttribute(entry.getKey(), entry.getValue());
} catch (IllegalArgumentException e) {
throw new AtlasBaseException(AtlasErrorCode.INVALID_PARTIAL_UPDATE_ATTR, "Glossary Category", entry.getKey());
}
}
return glossaryService.updateCategory(glossaryCategory);
} finally {
AtlasPerfTracer.log(perf);
}
}
use of org.apache.atlas.model.glossary.AtlasGlossaryCategory in project atlas by apache.
the class GlossaryREST method getGlossaryCategory.
/**
* Get specific glossary category
* @param categoryGuid unique identifier for glossary category
* @return Glossary category
* @throws AtlasBaseException
* @HTTP 200 If glossary category exists for given GUID
* @HTTP 404 If glossary category GUID is invalid
*/
@GET
@Path("/category/{categoryGuid}")
@Timed
public AtlasGlossaryCategory getGlossaryCategory(@PathParam("categoryGuid") String categoryGuid) throws AtlasBaseException {
Servlets.validateQueryParamLength("categoryGuid", categoryGuid);
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "GlossaryREST.getGlossaryCategory(" + categoryGuid + ")");
}
AtlasGlossaryCategory ret = glossaryService.getCategory(categoryGuid);
if (ret == null) {
throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND);
}
return ret;
} finally {
AtlasPerfTracer.log(perf);
}
}
use of org.apache.atlas.model.glossary.AtlasGlossaryCategory in project atlas by apache.
the class GlossaryClientV2IT method testCreateGlossaryCategories.
@Test(dependsOnMethods = "testCreateGlossaryCategory")
public void testCreateGlossaryCategories() throws Exception {
List<AtlasGlossaryCategory> glossaryCategories = new ArrayList<>();
AtlasGlossaryCategory category1 = new AtlasGlossaryCategory();
AtlasGlossaryHeader header1 = new AtlasGlossaryHeader();
header1.setGlossaryGuid(healthCareGlossary.getGuid());
header1.setDisplayText(healthCareGlossary.getName());
category1.setAnchor(header1);
category1.setName("category1ForEducation");
glossaryCategories.add(category1);
// Setting different category
AtlasGlossaryCategory category2 = new AtlasGlossaryCategory();
category2.setAnchor(header1);
category2.setName("category2ForEducation");
glossaryCategories.add(category2);
List<AtlasGlossaryCategory> list = atlasClientV2.createGlossaryCategories(glossaryCategories);
assertNotNull(list);
assertEquals(list.size(), 2);
}
use of org.apache.atlas.model.glossary.AtlasGlossaryCategory in project atlas by apache.
the class GlossaryClientV2IT method testPartialUpdateCategoryByGuid.
@Test(dependsOnMethods = "testCreateGlossary")
public void testPartialUpdateCategoryByGuid() throws Exception {
Map<String, String> partialUpdates = new HashMap<>();
partialUpdates.put("shortDescription", "shortDescriptionCategory");
partialUpdates.put("longDescription", "longDescriptionCategory");
AtlasGlossaryCategory category = atlasClientV2.partialUpdateCategoryByGuid(educationCategory.getGuid(), partialUpdates);
assertNotNull(category);
assertEquals(category.getShortDescription(), "shortDescriptionCategory");
assertEquals(category.getLongDescription(), "longDescriptionCategory");
}
use of org.apache.atlas.model.glossary.AtlasGlossaryCategory in project atlas by apache.
the class GlossaryServiceTest method testCategoryCreation.
@Test(groups = "Glossary.CREATE", dependsOnMethods = "testCreateGlossary")
public void testCategoryCreation() {
try {
customerCategory = glossaryService.createCategory(customerCategory);
AtlasRelatedCategoryHeader parentHeader = new AtlasRelatedCategoryHeader();
parentHeader.setCategoryGuid(customerCategory.getGuid());
// Test parent relation
accountCategory.setParentCategory(parentHeader);
List<AtlasGlossaryCategory> categories = glossaryService.createCategories(Arrays.asList(accountCategory, mortgageCategory));
accountCategory.setGuid(categories.get(0).getGuid());
assertNotNull(accountCategory.getParentCategory());
assertEquals(accountCategory.getParentCategory().getCategoryGuid(), customerCategory.getGuid());
assertTrue(accountCategory.getQualifiedName().endsWith(customerCategory.getQualifiedName()));
mortgageCategory.setGuid(categories.get(1).getGuid());
assertNull(mortgageCategory.getParentCategory());
} catch (AtlasBaseException e) {
fail("Category creation should've succeeded", e);
}
}
Aggregations