Examples of DSpaceObject


Examples of org.dspace.content.DSpaceObject

            int id = -1;
            try
            {
                context = new Context();
                DSpaceObject dso = HandleManager.resolveToObject(context, handle);
                id = dso.getID();
                dsoType = dso.getType();
                context.abort();

            }
            catch (SQLException e)
            {
View Full Code Here

Examples of org.dspace.content.DSpaceObject

     * Generate the unique caching key.
     * This key must be unique inside the space of this component.
     */
    public Serializable getKey() {
        try {
            DSpaceObject dso = HandleUtil.obtainHandle(objectModel);

            if (dso == null)
                return "0";

            return HashUtil.hash(dso.getHandle());
        }
        catch (SQLException sqle) {
            // Ignore all errors and just return that the component is not
            // cachable.
            return "0";
View Full Code Here

Examples of org.dspace.content.DSpaceObject

     */
    public SourceValidity getValidity() {
        if (this.validity == null) {

            try {
                DSpaceObject dso = HandleUtil.obtainHandle(objectModel);


                DSpaceValidity val = new DSpaceValidity();

                // add reciently submitted items, serialize solr query contents.
View Full Code Here

Examples of org.dspace.content.DSpaceObject

    @Override
    public void addOptions(Options options) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException {
        Request request = ObjectModelHelper.getRequest(objectModel);

        DSpaceObject dso = HandleUtil.obtainHandle(objectModel);

        java.util.List fqs = Arrays.asList(
                request.getParameterValues("fq") != null ? request.getParameterValues("fq") : new String[0]);

        if (this.queryResults != null) {
            java.util.List<FacetField> facetFields = this.queryResults.getFacetFields();
            if (facetFields == null)
                facetFields = new ArrayList<FacetField>();

            if(queryResults.getFacetDates() != null)
                facetFields.addAll(this.queryResults.getFacetDates());

            if (facetFields.size() > 0) {
                addDiscoveryLocation(options, request, fqs, dso);

                ////////////
                List browse = options.addList("discovery");
                boolean firstSubList = true;

                for (FacetField field : facetFields) {

                    // Skip location filter, since this is handled above.
                    if (field.getName().equals("location")) {
                        continue;
                    }

                    java.util.List<FacetField.Count> values = field.getValues();

                    //This is needed for a dirty hack to make sure that the date filters do not remain empty
                    boolean valueAdded = false;
                    if (values != null) {

                        if (firstSubList) {
                            browse.setHead(message("xmlui.ArtifactBrowser.AdvancedSearch.filter_by.head"));
                            firstSubList = false;
                        }
                        List facet = browse.addList(field.getName());

                        facet.setHead(message("xmlui.ArtifactBrowser.AdvancedSearch.type_" + field.getName().replace("_lc", "").replace("_dt", "")));

                        Iterator<FacetField.Count> iter = values.iterator();
                        for (int i = 0; i < this.queryArgs.getFacetLimit(); i++) {
                            if (!iter.hasNext())
                                break;
                            FacetField.Count value = iter.next();

                            if (i < this.queryArgs.getFacetLimit() - 1) {
                                String displayedValue = value.getName();
                                String filterQuery = value.getAsFilterQuery();
                                String itemName = null;
                                String itemRend = null;
                                if (field.getName().equals("location.comm") || field.getName().equals("location.coll")) {
                                    //We have a community/collection, resolve it to a dspaceObject
//                                    displayedValue = SolrServiceImpl.locationToName(context, field.getName(), displayedValue);
                                    int type = field.getName().equals("location.comm") ? Constants.COMMUNITY : Constants.COLLECTION;
                                    DSpaceObject commColl = DSpaceObject.find(context, type, Integer.parseInt(displayedValue));
                                    if (commColl != null) {
                                        displayedValue = commColl.getName();
                                        itemName = commColl.getHandle();
                                    }
                                }
                                if (field.getGap() != null) {
                                    //We have a date field
                                    //Since we currently only support years, get the year
View Full Code Here

Examples of org.dspace.content.DSpaceObject

                        if (fqs.contains(v.getAsFilterQuery())) {
                            curCommCollSelectedName = v.getName();
                            break;
                        }
                        int type = v.getName().startsWith("m") ? Constants.COMMUNITY : Constants.COLLECTION;
                        DSpaceObject commColl = DSpaceObject.find(context, type, Integer.parseInt(v.getName().substring(1)));
                        if (dso != null && commColl != null && dso.getHandle().equals(commColl.getHandle())) {
                            curCommCollSelectedName = v.getName();
                            break;
                        }
                    }
                    // UPDATE: see UPDATE above.
                    // Build list of locations (communities/collections) ordered by handle part after prefix.
                    Map<String, FacetField.Count> sortedSolrNameLocationWithValues = new TreeMap<String, FacetField.Count>();
                    for (FacetField.Count v : values) {
                        sortedSolrNameLocationWithValues.put(v.getName(), v);
                    }
                    // Default selection is "m1" (community with ID 1).
                    int curCommCollSelectedType = Constants.COMMUNITY;
                    int curCommCollSelectedID = 1;
                    if (curCommCollSelectedName != null) {
                        curCommCollSelectedType = curCommCollSelectedName.startsWith("m") ? Constants.COMMUNITY : Constants.COLLECTION;
                        curCommCollSelectedID = Integer.parseInt(curCommCollSelectedName.substring(1));
                    }
                    Map<Integer, String> sortedHandleWithSolrName = new TreeMap<Integer, String>();
                    Map<String, DSpaceObject> sortedSolrNameWithDSpaceObject = new TreeMap<String, DSpaceObject>();
                   
                    int topCommID = 1;
                    String topCommName = "m1";
                    boolean curSelectedIsTop = curCommCollSelectedName.equals(topCommName) ? true : false;
                   
                    Community mtop = Community.find(context, topCommID);
                    sortedHandleWithSolrName.put(Integer.parseInt(mtop.getHandle().split("/")[1]), topCommName);
                    sortedSolrNameWithDSpaceObject.put(topCommName, mtop);

                    Collection[] collections = mtop.getCollections();
                    for (Collection l : collections) {
                        String solrName = "l" + l.getID();
                        if (solrName.equals(curCommCollSelectedName))
                            curSelectedIsTop = true;
                        sortedHandleWithSolrName.put(Integer.parseInt(l.getHandle().split("/")[1]), solrName);
                        sortedSolrNameWithDSpaceObject.put(solrName, l);
                    }

                    Community[] communities = mtop.getSubcommunities();
                    for (Community mm : communities) {
                        String solrName = "m" + mm.getID();
                        if (solrName.equals(curCommCollSelectedName))
                            curSelectedIsTop = true;
                        sortedHandleWithSolrName.put(Integer.parseInt(mm.getHandle().split("/")[1]), solrName);
                        sortedSolrNameWithDSpaceObject.put(solrName, mm);
                    }
                    if (curSelectedIsTop == false) {
                        if (curCommCollSelectedType == Constants.COMMUNITY) {
                            Community msel = Community.find(context, curCommCollSelectedID);
                            Community[] parents = msel.getAllParents();
                            if (parents.length < 2) {
                                log.error("Something is wrong: this should not happen.");
                            }
                            Community topParent = parents[parents.length - 2];
                            curCommCollSelectedName = "m" + topParent.getID();
                        } else {
                            // Supposing Constants.COLLECTION
                            Collection lsel = Collection.find(context, curCommCollSelectedID);
                            Community firstParent = lsel.getCommunities()[0];
                            Community[] parents = firstParent.getAllParents();
                            if (parents.length == 0) {
                                //log.error("Something is wrong: this should not happen.");
                                //firstParent is a top community.
                                curCommCollSelectedName = "m" + firstParent.getID();
                            } else if (parents.length == 1) {
                                //firstParent is a second level community.
                                curCommCollSelectedName = "m" + firstParent.getID();
                            } else {
                                // get second level parent
                                Community topParent = parents[parents.length - 2];
                                curCommCollSelectedName = "m" + topParent.getID();
                            }
                        }
                    }
                    //                            Iterator<FacetField.Count> iter = sortedValues.values().iterator();
                    Iterator<String> iter = sortedHandleWithSolrName.values().iterator();
                    List facet = browseCommColl.addList(fieldLocation.getName());
                    //                            facet.setHead(message("xmlui.ArtifactBrowser.AdvancedSearch.type_" + fieldLocation.getName()));
                    facet.setHead(queryString);
                    for (int i = 0; i < this.queryArgs.getFacetLimit(); i++) {
                        if (!iter.hasNext()) {
                            break;
                        } //                                String displayedValue = value.getName();
                        String solrName = iter.next();
                        DSpaceObject commColl = sortedSolrNameWithDSpaceObject.get(solrName);
                        FacetField.Count value = sortedSolrNameLocationWithValues.get(solrName);
                        if (value == null) {
                            // This is probably due to an empty collection, which happens to not be indexed by Solr.
                            continue;
                        }
                        String displayedValue = commColl.getName();
                        String itemName = commColl.getHandle();
                        String itemRend = null;
                        //log.error("iter: solrName: " + solrName + "; " + value + "; handle: " + itemName + "; display: " + displayedValue);
                        //We have a community/collection, resolve it to a dspaceObject
                        //                                    displayedValue = SolrServiceImpl.locationToName(context, field.getName(), displayedValue);
                        //                                int type = fieldLocation.getName().equals("location.comm") ? Constants.COMMUNITY : Constants.COLLECTION;
                        if (curCommCollSelectedName != null && curCommCollSelectedName.equals(solrName)) {
                            //facet.addItem(itemName, "selected").addContent(displayedValue + " (" + value.getCount() + ")");
                            itemRend = "selected";
                        } else if (curCommCollSelectedName == null && value.getName().equals("m1")) {
                            //facet.addItem(itemName, "selected").addContent(displayedValue + " (" + value.getCount() + ")");
                            itemRend = "selected";
                        }
                        if (value.getCount() > 0) {
                            String URI = null;
                            try {
                                URI = request.getSitemapURI().split("/")[request.getSitemapURI().split("/").length - 1];
                                if (URI.matches("[0-9]+")) {
                                    URI = null;
                                }
                            } catch (Exception e) {
                                log.error(e.getMessage(), e);
                            }
                            facet.addItem(itemName, itemRend).addXref(contextPath + (commColl == null ? "" : "/handle/" + commColl.getHandle()) + "/" + (URI != null ? URI : "") + (queryString != null ? "?" + queryString : ""), displayedValue + " (" + "" + value.getCount() + ")");
                        } else {
                            facet.addItem(itemName, "disabled").addContent(displayedValue + " (" + value.getCount() + ")");
                        }
                    }
                }
View Full Code Here

Examples of org.dspace.content.DSpaceObject

     * Display a single collection
     */
    public void addBody(Body body) throws SAXException, WingException,
            SQLException, IOException, AuthorizeException {

        DSpaceObject dso = HandleUtil.obtainHandle(objectModel);

        // Set up the major variables
        Collection collection = (Collection) dso;

        performSearch(collection);
View Full Code Here

Examples of org.dspace.content.DSpaceObject

     */
    public Serializable getKey()
    {
        try
        {
            DSpaceObject dso = HandleUtil.obtainHandle(objectModel);

            if (dso == null)
                return "0";
               
            return HashUtil.hash(dso.getHandle());
        }
        catch (SQLException sqle)
        {
            // Ignore all errors and just return that the component is not
            // cachable.
View Full Code Here

Examples of org.dspace.content.DSpaceObject

      if (this.validity == null)
      {
            Collection collection = null;
          try
          {
              DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
 
              if (dso == null)
                  return null;
 
              if (!(dso instanceof Collection))
View Full Code Here

Examples of org.dspace.content.DSpaceObject

     */
    public void addPageMeta(PageMeta pageMeta) throws SAXException,
            WingException, UIException, SQLException, IOException,
            AuthorizeException
    {
        DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
        if (!(dso instanceof Collection))
            return;

        Collection collection = (Collection) dso;

View Full Code Here

Examples of org.dspace.content.DSpaceObject

     * Display a single collection
     */
    public void addBody(Body body) throws SAXException, WingException,
            UIException, SQLException, IOException, AuthorizeException
    {
        DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
        if (!(dso instanceof Collection))
            return;

        // Set up the major variables
        Collection collection = (Collection) dso;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.