use of org.apache.atlas.model.profile.AtlasUserSavedSearch in project atlas by apache.
the class AtlasUserProfileDTO method toEntityWithExtInfo.
@Override
public AtlasEntityWithExtInfo toEntityWithExtInfo(AtlasUserProfile obj) throws AtlasBaseException {
AtlasEntity entity = toEntity(obj);
AtlasEntityWithExtInfo entityWithExtInfo = new AtlasEntityWithExtInfo(entity);
List<AtlasObjectId> objectIds = new ArrayList<>();
for (AtlasUserSavedSearch ss : obj.getSavedSearches()) {
AtlasEntity ssEntity = savedSearchDTO.toEntity(ss);
entityWithExtInfo.addReferredEntity(ssEntity);
objectIds.add(new AtlasObjectId(ssEntity.getGuid(), savedSearchDTO.getEntityType().getTypeName(), savedSearchDTO.getUniqueAttributes(ss)));
}
if (objectIds.size() > 0) {
entity.setAttribute(PROPERTY_SAVED_SEARCHES, objectIds);
}
return entityWithExtInfo;
}
use of org.apache.atlas.model.profile.AtlasUserSavedSearch in project atlas by apache.
the class AtlasSavedSearchDTO method from.
@Override
public AtlasUserSavedSearch from(AtlasEntity entity) {
AtlasUserSavedSearch savedSearch = new AtlasUserSavedSearch();
savedSearch.setGuid(entity.getGuid());
savedSearch.setName((String) entity.getAttribute(PROPERTY_NAME));
savedSearch.setOwnerName((String) entity.getAttribute(PROPERTY_OWNER_NAME));
savedSearch.setSearchType(AtlasUserSavedSearch.SavedSearchType.to((String) entity.getAttribute(PROPERTY_SEARCH_TYPE)));
String jsonSearchParams = (String) entity.getAttribute(PROPERTY_SEARCH_PARAMETERS);
if (StringUtils.isNotEmpty(jsonSearchParams)) {
savedSearch.setSearchParameters(AtlasType.fromJson(jsonSearchParams, SearchParameters.class));
}
savedSearch.setUiParameters((String) entity.getAttribute(PROPERTY_UI_PARAMETERS));
return savedSearch;
}
use of org.apache.atlas.model.profile.AtlasUserSavedSearch in project atlas by apache.
the class BasicSearchIT method testDeleteSavedSearch.
@Test(dependsOnMethods = "testExecuteSavedSearchByGuid")
public void testDeleteSavedSearch() {
AtlasUserSavedSearch searchAfterDelete = null;
try {
atlasClientV2.deleteSavedSearch(userSavedSearch.getGuid());
searchAfterDelete = atlasClientV2.getSavedSearch("admin", "basic_test");
} catch (AtlasServiceException e) {
assertNull(searchAfterDelete);
}
}
use of org.apache.atlas.model.profile.AtlasUserSavedSearch in project atlas by apache.
the class BasicSearchIT method testSavedSearch.
@Test(dataProvider = "attributeSearchJSONNames")
public void testSavedSearch(String jsonFile) {
try {
BasicSearchParametersWithExpectation[] testExpectations = TestResourceFileUtils.readObjectFromJson(jsonFile, BasicSearchParametersWithExpectation[].class);
assertNotNull(testExpectations);
for (BasicSearchParametersWithExpectation testExpectation : testExpectations) {
LOG.info("TestDescription :{}", testExpectation.testDescription);
LOG.info("SearchParameters :{}", testExpectation.searchParameters);
SearchParameters parameters = testExpectation.getSearchParameters();
AtlasUserSavedSearch savedSearch = new AtlasUserSavedSearch();
savedSearch.setSearchType(AtlasUserSavedSearch.SavedSearchType.BASIC);
savedSearch.setName("basic_test");
savedSearch.setGuid("");
savedSearch.setSearchParameters(parameters);
savedSearch.setOwnerName("admin");
userSavedSearch = atlasClientV2.addSavedSearch(savedSearch);
assertNotNull(userSavedSearch);
List<AtlasUserSavedSearch> list = atlasClientV2.getSavedSearches("admin");
assertNotNull(list);
}
} catch (IOException | AtlasServiceException e) {
fail(e.getMessage());
}
}
use of org.apache.atlas.model.profile.AtlasUserSavedSearch in project atlas by apache.
the class DiscoveryREST method executeSavedSearchByName.
/**
* Attribute based search for entities satisfying the search parameters
*
* @param searchName name of saved-search
* @param userName saved-search owner
* @return Atlas search result
* @throws AtlasBaseException
*/
@Path("saved/execute/{name}")
@GET
@Timed
public AtlasSearchResult executeSavedSearchByName(@PathParam("name") String searchName, @QueryParam("user") String userName) throws AtlasBaseException {
Servlets.validateQueryParamLength("name", searchName);
Servlets.validateQueryParamLength("user", userName);
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "DiscoveryREST.executeSavedSearchByName(userName=" + userName + ", " + "name=" + searchName + ")");
}
AtlasUserSavedSearch savedSearch = discoveryService.getSavedSearchByName(AtlasAuthorizationUtils.getCurrentUserName(), userName, searchName);
return executeSavedSearch(savedSearch);
} finally {
AtlasPerfTracer.log(perf);
}
}
Aggregations