Package org.dspace.discovery

Examples of org.dspace.discovery.DiscoverResult


        }
        request.setAttribute("scope", scope);
        request.setAttribute("scopes", scopes);

        // Perform the search
        DiscoverResult qResults = null;
        try
        {
            qResults = SearchUtils.getSearchService().search(context, scope,
                    queryArgs);
           
            List<Community> resultsListComm = new ArrayList<Community>();
            List<Collection> resultsListColl = new ArrayList<Collection>();
            List<Item> resultsListItem = new ArrayList<Item>();

            for (DSpaceObject dso : qResults.getDspaceObjects())
            {
                if (dso instanceof Item)
                {
                    resultsListItem.add((Item) dso);
                }
                else if (dso instanceof Collection)
                {
                    resultsListColl.add((Collection) dso);

                }
                else if (dso instanceof Community)
                {
                    resultsListComm.add((Community) dso);
                }
            }

            // Make objects from the handles - make arrays, fill them out
            resultsCommunities = new Community[resultsListComm.size()];
            resultsCollections = new Collection[resultsListColl.size()];
            resultsItems = new Item[resultsListItem.size()];

            resultsCommunities = resultsListComm.toArray(resultsCommunities);
            resultsCollections = resultsListColl.toArray(resultsCollections);
            resultsItems = resultsListItem.toArray(resultsItems);

            // Log
            log.info(LogManager.getHeader(context, "search", "scope=" + scope
                    + ",query=\"" + query + "\",results=("
                    + resultsCommunities.length + ","
                    + resultsCollections.length + "," + resultsItems.length
                    + ")"));

            // Pass in some page qualities
            // total number of pages
            long pageTotal = 1 + ((qResults.getTotalSearchResults() - 1) / qResults
                    .getMaxResults());

            // current page being displayed
            long pageCurrent = 1 + (qResults.getStart() / qResults
                    .getMaxResults());

            // pageLast = min(pageCurrent+3,pageTotal)
            long pageLast = ((pageCurrent + 3) > pageTotal) ? pageTotal
                    : (pageCurrent + 3);

            // pageFirst = max(1,pageCurrent-3)
            long pageFirst = ((pageCurrent - 3) > 1) ? (pageCurrent - 3) : 1;

            // Pass the results to the display JSP
            request.setAttribute("items", resultsItems);
            request.setAttribute("communities", resultsCommunities);
            request.setAttribute("collections", resultsCollections);

            request.setAttribute("pagetotal", new Long(pageTotal));
            request.setAttribute("pagecurrent", new Long(pageCurrent));
            request.setAttribute("pagelast", new Long(pageLast));
            request.setAttribute("pagefirst", new Long(pageFirst));
            request.setAttribute("spellcheck", qResults.getSpellCheckQuery());
           
            request.setAttribute("queryresults", qResults);

            try
            {
View Full Code Here


        query.setQuery(queryString);
        query.addFilterQueries("-location:l"+collection.getID());
        query.setMaxResults(ITEMMAP_RESULT_PAGE_SIZE);
        query.setStart(offset);

        DiscoverResult results = null;
        try
        {
            results = SearchUtils.getSearchService().search(context, query);
        }
        catch (SearchServiceException e)
        {
            throw new SearchProcessorException(e.getMessage(), e);
        }

        Map<Integer, Item> items = new HashMap<Integer, Item>();

        List<DSpaceObject> resultDSOs = results.getDspaceObjects();
        for (DSpaceObject dso : resultDSOs)
        {
            if (dso != null && dso.getType() == Constants.ITEM)
            {
                // no authorization check is required as discovery is right aware
                Item item = (Item) dso;
                items.put(Integer.valueOf(item.getID()), item);
            }
        }

        request.setAttribute("browsetext", queryString);
        request.setAttribute("items", items);
        request.setAttribute("more", results.getTotalSearchResults() > offset + ITEMMAP_RESULT_PAGE_SIZE);
        request.setAttribute("browsetype", "Add");
        request.setAttribute("page", page > 0 ? page + 1 : 1);
       
        JSPManager.showJSP(request, response, "itemmap-browse.jsp");
    }
View Full Code Here

        {
            DSpaceObject scope = DiscoverUtility.getSearchScope(context,
                    request);
            DiscoverQuery autocompleteQuery = DiscoverUtility
                    .getDiscoverAutocomplete(context, request, scope);
            DiscoverResult qResults = SearchUtils.getSearchService().search(
                    context, autocompleteQuery);
            // extract the only facet present in the result response
            Set<String> facets = qResults.getFacetResults().keySet();
            List<FacetResult> fResults = new ArrayList<DiscoverResult.FacetResult>();
            if (facets != null && facets.size() > 0)
            {
                String autocompleteField = (String) facets.toArray()[0];
                fResults = qResults
                        .getFacetResult(autocompleteField);               
            }
            Gson gson = new GsonBuilder().addSerializationExclusionStrategy(new ExclusionStrategy() {
       
        @Override
View Full Code Here

                            DiscoveryConfigurationParameters.SORT.COUNT));
        query.addFilterQueries("search.resourcetype:2");    // count only items
        query.addFilterQueries("NOT(discoverable:false)")// only discoverable
        query.setMaxResults(0);
       
        DiscoverResult sResponse = null;
        try
        {
            sResponse = searcher.search(context, query, false);
            List<FacetResult> commCount = sResponse.getFacetResult("location.comm");
            List<FacetResult> collCount = sResponse.getFacetResult("location.coll");
            for (FacetResult c : commCount)
            {
              communitiesCount.put(c.getAsFilterQuery(),(int) c.getCount());
            }
            for (FacetResult c : collCount)
View Full Code Here

        Division recentSubmissionDivision = mainDivision.addDivision("recent-submissions");
        if(isHomePage){
            recentSubmissionDivision.setHead(T_recent_submission_head);
        }

        DiscoverResult recentlySubmittedItems = RecentSubmissionUtils.getRecentlySubmittedItems(context, dso, getOffset(request));
        setPagination(request, dso, recentSubmissionDivision, recentlySubmittedItems);

        ReferenceSet lastSubmitted = recentSubmissionDivision.addReferenceSet(
                "last-submitted", ReferenceSet.TYPE_SUMMARY_LIST,
                null, "recent-submissions");

        for (DSpaceObject resultObject : recentlySubmittedItems.getDspaceObjects()) {
            if(resultObject != null){
                lastSubmitted.addReference(resultObject);
            }
        }
    }
View Full Code Here

    }

    @Override
    public int doCountQuery() throws BrowseException
    {
        DiscoverResult resp = getSolrResponse();
        int count = 0;
        if (distinct)
        {
            List<FacetResult> facetResults = resp.getFacetResult(facetField);
            count = facetResults.size();
        }
        else
        {
            // we need to cast to int to respect the BrowseDAO contract...
            count = (int) resp.getTotalSearchResults();
            // FIXME null the response cache
            // the BrowseEngine send fake argument to the BrowseDAO for the
            // count...
            sResponse = null;
        }
View Full Code Here

    }

    @Override
    public List doValueQuery() throws BrowseException
    {
        DiscoverResult resp = getSolrResponse();
        List<FacetResult> facet = resp.getFacetResult(facetField);
        int count = doCountQuery();
        int start = offset > 0 ? offset : 0;
        int max = limit > 0 ? limit : count; //if negative, return everything
        List<String[]> result = new ArrayList<String[]>();
        if (ascending)
View Full Code Here

    }

    @Override
    public List doQuery() throws BrowseException
    {
        DiscoverResult resp = getSolrResponse();

        List<BrowseItem> bitems = new ArrayList<BrowseItem>();
        for (DSpaceObject solrDoc : resp.getDspaceObjects())
        {
            // FIXME introduce project, don't retrieve Item immediately when
            // processing the query...
            Item item = (Item) solrDoc;
            BrowseItem bitem = new BrowseItem(context, item.getID(),
View Full Code Here

    {
        DiscoverQuery query = new DiscoverQuery();
        query.setQuery("search.resourceid:" + itemID
                + " AND search.resourcetype:" + Constants.ITEM);
        query.setMaxResults(1);
        DiscoverResult resp = null;
        try
        {
            resp = searcher.search(context, query);
        }
        catch (SearchServiceException e)
        {
            throw new BrowseException(e);
        }
        if (resp.getTotalSearchResults() > 0)
        {
            SearchDocument doc = resp.getSearchDocument(
                    resp.getDspaceObjects().get(0)).get(0);
            return (String) doc.getSearchFieldValues(column).get(0);
        }
        return null;
    }
View Full Code Here

        }
        else
        {
            query.setQuery("bi_" + column + "_sort" + ": {\"" + value + "\" TO *]");
        }
        DiscoverResult resp = null;
        try
        {
            resp = searcher.search(context, query);
        }
        catch (SearchServiceException e)
        {
            throw new BrowseException(e);
        }
        return (int) resp.getTotalSearchResults();
    }
View Full Code Here

TOP

Related Classes of org.dspace.discovery.DiscoverResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.