use of org.apache.atlas.model.profile.AtlasUserSavedSearch in project atlas by apache.
the class UserProfileServiceTest method addAdditionalSearchesForUser.
@Test(dependsOnMethods = "verifyQueryConversionFromJSON")
public void addAdditionalSearchesForUser() throws AtlasBaseException {
SearchParameters expectedSearchParameter = getActualSearchParameters();
for (int i = 0; i < NUM_USERS; i++) {
String userName = getIndexBasedUserName(i);
for (int j = 0; j < 6; j++) {
String queryName = getIndexBasedQueryName(NUM_SEARCHES + j);
AtlasUserSavedSearch actual = userProfileService.addSavedSearch(getDefaultSavedSearch(userName, queryName, expectedSearchParameter));
assertNotNull(actual);
AtlasUserSavedSearch savedSearch = userProfileService.getSavedSearch(userName, queryName);
assertNotNull(savedSearch);
assertEquals(savedSearch.getSearchParameters(), expectedSearchParameter);
}
}
}
use of org.apache.atlas.model.profile.AtlasUserSavedSearch in project atlas by apache.
the class UserProfileService method getSavedSearch.
public AtlasUserSavedSearch getSavedSearch(String guid) throws AtlasBaseException {
AtlasUserSavedSearch ss = new AtlasUserSavedSearch();
ss.setGuid(guid);
return dataAccess.load(ss);
}
use of org.apache.atlas.model.profile.AtlasUserSavedSearch in project atlas by apache.
the class UserProfileService method addSavedSearch.
public AtlasUserSavedSearch addSavedSearch(AtlasUserSavedSearch savedSearch) throws AtlasBaseException {
String userName = savedSearch.getOwnerName();
AtlasUserProfile userProfile = null;
try {
userProfile = getUserProfile(userName);
} catch (AtlasBaseException excp) {
// ignore
}
if (userProfile == null) {
userProfile = new AtlasUserProfile(userName);
}
checkIfQueryAlreadyExists(savedSearch, userProfile);
userProfile.getSavedSearches().add(savedSearch);
userProfile = dataAccess.save(userProfile);
for (AtlasUserSavedSearch s : userProfile.getSavedSearches()) {
if (s.getName().equals(savedSearch.getName())) {
return s;
}
}
return savedSearch;
}
use of org.apache.atlas.model.profile.AtlasUserSavedSearch in project atlas by apache.
the class DiscoveryREST method executeSavedSearchByGuid.
/**
* Attribute based search for entities satisfying the search parameters
*
* @param searchGuid Guid identifying saved search
* @return Atlas search result
* @throws AtlasBaseException
*/
@Path("saved/execute/guid/{guid}")
@GET
@Timed
public AtlasSearchResult executeSavedSearchByGuid(@PathParam("guid") String searchGuid) throws AtlasBaseException {
Servlets.validateQueryParamLength("guid", searchGuid);
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "DiscoveryREST.executeSavedSearchByGuid(" + searchGuid + ")");
}
AtlasUserSavedSearch savedSearch = discoveryService.getSavedSearchByGuid(AtlasAuthorizationUtils.getCurrentUserName(), searchGuid);
return executeSavedSearch(savedSearch);
} finally {
AtlasPerfTracer.log(perf);
}
}
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