use of org.apache.atlas.model.profile.AtlasUserSavedSearch in project atlas by apache.
the class UserProfileServiceTest method atteptsToAddAlreadyExistingQueryForAnExistingUser.
@Test(dependsOnMethods = { "createsNewProfile", "savesQueryForAnNonExistentUser" }, expectedExceptions = AtlasBaseException.class)
public void atteptsToAddAlreadyExistingQueryForAnExistingUser() throws AtlasBaseException {
SearchParameters expectedSearchParameter = getActualSearchParameters();
for (int i = 0; i < 2; i++) {
String userName = getIndexBasedUserName(i);
for (int j = 0; j < max_searches; j++) {
String queryName = getIndexBasedQueryName(j);
AtlasUserSavedSearch expected = getDefaultSavedSearch(userName, queryName, expectedSearchParameter);
AtlasUserSavedSearch actual = userProfileService.addSavedSearch(expected);
assertNotNull(actual);
assertNotNull(actual.getGuid());
assertEquals(actual.getOwnerName(), expected.getOwnerName());
assertEquals(actual.getName(), expected.getName());
assertEquals(actual.getSearchType(), expected.getSearchType());
assertEquals(actual.getSearchParameters(), expected.getSearchParameters());
}
}
}
use of org.apache.atlas.model.profile.AtlasUserSavedSearch in project atlas by apache.
the class UserProfileServiceTest method savesQueryForAnNonExistentUser.
@Test(dependsOnMethods = "createsNewProfile")
public void savesQueryForAnNonExistentUser() throws AtlasBaseException {
String expectedUserName = getIndexBasedUserName(0);
String expectedQueryName = "testQuery";
SearchParameters expectedSearchParam = getActualSearchParameters();
AtlasUserSavedSearch expectedSavedSearch = getDefaultSavedSearch(expectedUserName, expectedQueryName, expectedSearchParam);
AtlasUserSavedSearch actual = userProfileService.addSavedSearch(expectedSavedSearch);
assertEquals(actual.getOwnerName(), expectedUserName);
assertEquals(actual.getName(), expectedQueryName);
}
use of org.apache.atlas.model.profile.AtlasUserSavedSearch in project atlas by apache.
the class UserProfileServiceTest method savesExistingQueryForAnExistingUser.
@Test(dependsOnMethods = { "createsNewProfile", "savesQueryForAnNonExistentUser", "atteptsToAddAlreadyExistingQueryForAnExistingUser" })
public void savesExistingQueryForAnExistingUser() throws AtlasBaseException {
SearchParameters expectedSearchParameter = getActualSearchParameters();
for (int i = 0; i < 2; i++) {
String userName = getIndexBasedUserName(i);
for (int j = 4; j < max_searches + 6; j++) {
String queryName = getIndexBasedQueryName(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 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 AtlasUserProfileDTO method from.
public AtlasUserProfile from(AtlasEntityWithExtInfo entityWithExtInfo) {
AtlasUserProfile userProfile = from(entityWithExtInfo.getEntity());
Object savedSearches = entityWithExtInfo.getEntity().getAttribute(PROPERTY_SAVED_SEARCHES);
if (savedSearches instanceof Collection) {
for (Object o : (Collection) savedSearches) {
if (o instanceof AtlasObjectId) {
AtlasObjectId ssObjId = (AtlasObjectId) o;
AtlasEntity ssEntity = entityWithExtInfo.getReferredEntity(ssObjId.getGuid());
if (ssEntity != null && ssEntity.getStatus() == AtlasEntity.Status.ACTIVE) {
AtlasUserSavedSearch savedSearch = savedSearchDTO.from(ssEntity);
userProfile.getSavedSearches().add(savedSearch);
}
}
}
}
return userProfile;
}
Aggregations