Search in sources :

Example 11 with AtlasUserSavedSearch

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);
        }
    }
}
Also used : SearchParameters(org.apache.atlas.model.discovery.SearchParameters) AtlasUserSavedSearch(org.apache.atlas.model.profile.AtlasUserSavedSearch) Test(org.testng.annotations.Test)

Example 12 with AtlasUserSavedSearch

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);
}
Also used : AtlasUserSavedSearch(org.apache.atlas.model.profile.AtlasUserSavedSearch)

Example 13 with AtlasUserSavedSearch

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;
}
Also used : AtlasUserProfile(org.apache.atlas.model.profile.AtlasUserProfile) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasUserSavedSearch(org.apache.atlas.model.profile.AtlasUserSavedSearch)

Example 14 with AtlasUserSavedSearch

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);
    }
}
Also used : AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) AtlasUserSavedSearch(org.apache.atlas.model.profile.AtlasUserSavedSearch) Path(javax.ws.rs.Path) Timed(org.apache.atlas.annotation.Timed) GET(javax.ws.rs.GET)

Example 15 with AtlasUserSavedSearch

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);
    }
}
Also used : AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) AtlasUserSavedSearch(org.apache.atlas.model.profile.AtlasUserSavedSearch) Path(javax.ws.rs.Path) Timed(org.apache.atlas.annotation.Timed) GET(javax.ws.rs.GET)

Aggregations

AtlasUserSavedSearch (org.apache.atlas.model.profile.AtlasUserSavedSearch)26 Test (org.testng.annotations.Test)13 SearchParameters (org.apache.atlas.model.discovery.SearchParameters)12 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)5 AtlasUserProfile (org.apache.atlas.model.profile.AtlasUserProfile)5 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)4 AtlasObjectId (org.apache.atlas.model.instance.AtlasObjectId)4 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 AtlasServiceException (org.apache.atlas.AtlasServiceException)2 Timed (org.apache.atlas.annotation.Timed)2 AtlasEntityWithExtInfo (org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo)2 AtlasPerfTracer (org.apache.atlas.utils.AtlasPerfTracer)2 IOException (java.io.IOException)1 QuickSearchParameters (org.apache.atlas.model.discovery.QuickSearchParameters)1 AbstractDataTransferObject (org.apache.atlas.repository.ogm.AbstractDataTransferObject)1