Examples of ItemIterator


Examples of org.dspace.content.ItemIterator


    public void init(Context context, Item item) {
        ArrayList<Integer> itemList = new ArrayList<Integer>();
        itemList.add(item.getID());
        this.itemIterator = new ItemIterator(context, itemList);
        try {
            currentItem = this.itemIterator.next();
        } catch (SQLException e) {
            log.error("Error while retrieving an item in the metadata indexer");
        }
View Full Code Here

Examples of org.dspace.content.ItemIterator

           
            //next, we'll try to distribute to all child objects, based on container type
            int type = dso.getType();
            if (Constants.COLLECTION == type)
            {
                ItemIterator iter = ((Collection)dso).getItems();
                while (iter.hasNext())
                {
                    performObject(iter.next());
                }
            }
            else if (Constants.COMMUNITY == type)
            {
                Community comm = (Community)dso;
View Full Code Here

Examples of org.dspace.content.ItemIterator

        List<Integer> iids = new ArrayList<Integer>();
        for (Item item : items)
        {
            iids.add(item.getID());
        }
        ItemIterator ii = new ItemIterator(context, iids);
        MetadataExport exporter = new MetadataExport(context, ii, false);

        // Perform the export
        DSpaceCSV csv = exporter.export();
View Full Code Here

Examples of org.dspace.content.ItemIterator

        ArrayList iids = new ArrayList();
        for (Item item : items)
        {
            iids.add(item.getID());
        }
        ItemIterator ii = new ItemIterator(context, iids);
        MetadataExport exporter = new MetadataExport(context, ii, false);

        // Perform the export
        DSpaceCSV csv = exporter.export();
View Full Code Here

Examples of org.dspace.content.ItemIterator

        Map<Integer, Item> myItems = new HashMap<Integer, Item>(); // # for the browser
        Map<Integer, Collection> myCollections = new HashMap<Integer, Collection>(); // collections for list
        Map<Integer, Integer> myCounts = new HashMap<Integer, Integer>(); // counts for each collection
       
        // get all items from that collection, add them to a hash
        ItemIterator i = myCollection.getItems();
        try
            {
                // iterate through the items in this collection, and count how many
                // are native, and how many are imports, and which collections they
                // came from
                while (i.hasNext())
                {
                    Item myItem = i.next();

                    // get key for hash
                    Integer myKey = Integer.valueOf(myItem.getID());

                    if (myItem.isOwningCollection(myCollection))
                    {
                        count_native++;
                    }
                    else
                    {
                        count_import++;
                    }

                    // is the collection in the hash?
                    Collection owningCollection = myItem.getOwningCollection();
                    Integer cKey = Integer.valueOf(owningCollection.getID());

                    if (myCollections.containsKey(cKey))
                    {
                        Integer x = myCounts.get(cKey);
                        int myCount = x.intValue() + 1;

                        // increment count for that collection
                        myCounts.put(cKey, Integer.valueOf(myCount));
                    }
                    else
                    {
                        // store and initialize count
                        myCollections.put(cKey, owningCollection);
                        myCounts.put(cKey, Integer.valueOf(1));
                    }

                    // store the item
                    myItems.put(myKey, myItem);
                }
            }
            finally
            {
                if (i != null)
                {
                    i.close();
                }
            }
           
            // remove this collection's entry because we already have a native
        // count
        myCollections.remove(Integer.valueOf(myCollection.getID()));
       
        // sort items - later
        // show page
        request.setAttribute("collection", myCollection);
        request.setAttribute("count_native", Integer.valueOf(count_native));
        request.setAttribute("count_import", Integer.valueOf(count_import));
        request.setAttribute("items", myItems);
        request.setAttribute("collections", myCollections);
        request.setAttribute("collection_counts", myCounts);
        request
        .setAttribute("all_collections", Collection
            .findAll(context));
       
            request.setAttribute("searchIndices",
                    internalLogic.getSearchIndices());
            request.setAttribute("prefixKey", internalLogic.getI18NKeyPrefix());
        // show this page when we're done
        jspPage = "itemmap-main.jsp";
       
        // show the page
        JSPManager.showJSP(request, response, jspPage);
      }
      else if (action.equals("Remove"))
      {
        // get item IDs to remove
        String[] itemIDs = request.getParameterValues("item_ids");
        String message = "remove";
        LinkedList<String> removedItems = new LinkedList<String>();
       
                if (itemIDs == null)
                {
                        message = "none-removed";
                }
                else
                {
           for (int j = 0; j < itemIDs.length; j++)
          {
            int i = Integer.parseInt(itemIDs[j]);
            removedItems.add(itemIDs[j]);
         
            Item myItem = Item.find(context, i);
         
            // make sure item doesn't belong to this collection
            if (!myItem.isOwningCollection(myCollection))
            {
              myCollection.removeItem(myItem);
              try
              {
                IndexBrowse ib = new IndexBrowse(context);
                            ib.indexItem(myItem);
              }
              catch (BrowseException e)
              {
                log.error("caught exception: ", e);
                throw new ServletException(e);
              }
            }
          }
    }
       
        request.setAttribute("message", message);
        request.setAttribute("collection", myCollection);
        request.setAttribute("processedItems", removedItems);
       
        // show this page when we're done
        jspPage = "itemmap-info.jsp";
       
        // show the page
        JSPManager.showJSP(request, response, jspPage);
      }
      else if (action.equals("Add"))
      {
        // get item IDs to add
        String[] itemIDs = request.getParameterValues("item_ids");
        String message = "added";
        LinkedList<String> addedItems = new LinkedList<String>();
       
       
        if (itemIDs == null)
        {
          message = "none-selected";
        }
        else
        {
          for (int j = 0; j < itemIDs.length; j++)
          {
            int i = Integer.parseInt(itemIDs[j]);
           
            Item myItem = Item.find(context, i);
           
            if (AuthorizeManager.authorizeActionBoolean(context, myItem, Constants.READ))
            {
              // make sure item doesn't belong to this collection
              if (!myItem.isOwningCollection(myCollection))
              {
                myCollection.addItem(myItem);
                try
                  {
                    IndexBrowse ib = new IndexBrowse(context);
                    ib.indexItem(myItem);
                  }
                  catch (BrowseException e)
                  {
                    log.error("caught exception: ", e);
                    throw new ServletException(e);
                  }
                addedItems.add(itemIDs[j]);
              }
            }
          }
        }
       
        request.setAttribute("message", message);
        request.setAttribute("collection", myCollection);
        request.setAttribute("processedItems", addedItems);
       
        // show this page when we're done
        jspPage = "itemmap-info.jsp";
       
        // show the page
        JSPManager.showJSP(request, response, jspPage);
      }
      else if (action.equals("search"))
      {
            request.setAttribute("collection", myCollection);
            try
            {
                internalLogic.doItemMapSearch(context, request, response);
            }
            catch (SearchProcessorException e)
            {
                log.error(e.getMessage(), e);
                throw new ServletException(e.getMessage(), e);
            }
        }
      else if (action.equals("browse"))
      {
        // target collection to browse
        int t = UIUtil.getIntParameter(request, "t");
       
        Collection targetCollection = Collection.find(context, t);
       
        // now find all imported items from that collection
        // seemingly inefficient, but database should have this query cached
            Map<Integer, Item> items = new HashMap<Integer, Item>();
        ItemIterator i = myCollection.getItems();
            try
            {
                while (i.hasNext())
                {
                    Item myItem = i.next();

                    if (myItem.isOwningCollection(targetCollection))
                    {
                        Integer myKey = Integer.valueOf(myItem.getID());
                        items.put(myKey, myItem);
                    }
                }
            }
            finally
            {
                if (i != null)
                {
                    i.close();
                }
            }
       
            request.setAttribute("collection", myCollection);
        request.setAttribute("browsetext", targetCollection
View Full Code Here

Examples of org.dspace.content.ItemIterator

  public static FlowResult processReimportCollection(Context context, int collectionID, Request request) throws SQLException, IOException, AuthorizeException, CrosswalkException, ParserConfigurationException, SAXException, TransformerException, BrowseException
  {
    Collection collection = Collection.find(context, collectionID);
    HarvestedCollection hc = HarvestedCollection.find(context, collectionID);
   
    ItemIterator it = collection.getAllItems();
    //IndexBrowse ib = new IndexBrowse(context);
    while (it.hasNext()) {
      Item item = it.next();
      //System.out.println("Deleting: " + item.getHandle());
      //ib.itemRemoved(item);
      collection.removeItem(item);
    }
    hc.setHarvestResult(null,"");
View Full Code Here

Examples of org.dspace.content.ItemIterator

            limit = -1;
        } else {
            //Set a default limit of 50
            limit = 50;
        }
        ItemIterator subs = Item.findBySubmitterDateSorted(context, context.getCurrentUser(), limit);

        //NOTE: notice we are adding each item to this list in *reverse* order...
        // this is a very basic attempt at making more recent submissions float
        // up to the top of the list (findBySubmitter() doesn't guarrantee
        // chronological order, but tends to return older items near top of the list)
        try
        {
            while (subs.hasNext())
            {
                subList.add(subs.next());
            }
        }
        finally
        {
            if (subs != null)
                subs.close();
        }

        // No tasks, so don't show the table.
        if (!(subList.size() > 0))
            return;
View Full Code Here

Examples of org.dspace.content.ItemIterator

     * @param force
     */
    public static void updateIndex(Context context, boolean force) {
        try
        {
                ItemIterator items = null;
                try
                {
                    for(items = Item.findAll(context);items.hasNext();)
                    {
                        Item item = (Item) items.next();
                        indexContent(context, item);
                        item.decache();
                    }
                }
                finally
                {
                    if (items != null)
                    {
                        items.close();
                    }
                }

                for (Collection collection : Collection.findAll(context))
                {
View Full Code Here

Examples of org.dspace.content.ItemIterator

      {
        EPerson eperson = EPerson.findByEmail(context, email);
          context.setCurrentUser(eperson);
        context.turnOffAuthorisationSystem();
       
        ItemIterator it = collection.getAllItems();
        IndexBrowse ib = new IndexBrowse(context);
        int i=0;
        while (it.hasNext()) {
          i++;
          Item item = it.next();
          System.out.println("Deleting: " + item.getHandle());
          ib.itemRemoved(item);
          collection.removeItem(item);
          // commit every 50 items
          if (i%50 == 0) {
View Full Code Here

Examples of org.dspace.content.ItemIterator

     
      ItemUpdate.prv("Metadata field to match for item: " + dtom.toString());

      this.addUndoMetadataField(dtom)//seed the undo list with the identifier field
     
      ItemIterator itr = Item.findByMetadataField(context, dtom.schema, dtom.element, dtom.qualifier, dtom.value);
    int count = 0;
    while (itr.hasNext())
    {
      item = itr.next();
      count++;
    }
   
    itr.close();
   
    ItemUpdate.prv("items matching = " + count );
   
    if (count != 1)
    {
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.