Search in sources :

Example 6 with AtlasUserSavedSearch

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

Example 7 with AtlasUserSavedSearch

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

Example 8 with AtlasUserSavedSearch

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

Example 9 with AtlasUserSavedSearch

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

Example 10 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