private void populateTableRowFromItem(Item item, TableRow row) {
    EPerson submitter = item.getSubmitter();
    Collection owningCollection = item.getOwningCollection();

    row.setColumn("item_id", item.getID());
    row.setColumn("in_archive", item.isArchived());
    row.setColumn("withdrawn", item.isWithdrawn());
    row.setColumn("last_modified", item.getLastModified());

    if (submitter != null) {
      row.setColumn("submitter_id", submitter.getID());
    }

    if (owningCollection != null) {
      row.setColumn("owning_collection", owningCollection.getID());
    }
  }
 /**
  * Perform the curation task upon passed DSO
  *
  * @param dso the DSpace object
  * @throws IOException
  */
 @Override
 public int perform(DSpaceObject dso) throws IOException {
   if (dso.getType() == Constants.ITEM) {
     Item item = (Item) dso;
     int count = 0;
     try {
       StringBuilder sb = new StringBuilder();
       String handle = item.getHandle();
       if (handle == null) {
         // we are still in workflow - no handle assigned
         handle = "in workflow";
       }
       sb.append("Item: ").append(handle);
       for (String req : getReqList(item.getOwningCollection().getHandle())) {
         DCValue[] vals = item.getMetadata(req);
         if (vals.length == 0) {
           sb.append(" missing required field: ").append(req);
           count++;
         }
       }
       if (count == 0) {
         sb.append(" has all required fields");
       }
       report(sb.toString());
       setResult(sb.toString());
     } catch (DCInputsReaderException dcrE) {
       throw new IOException(dcrE.getMessage(), dcrE);
     } catch (SQLException sqlE) {
       throw new IOException(sqlE.getMessage(), sqlE);
     }
     return (count == 0) ? Curator.CURATE_SUCCESS : Curator.CURATE_FAIL;
   } else {
     setResult("Object skipped");
     return Curator.CURATE_SKIP;
   }
 }
  /**
   * Show an item page
   *
   * @param context Context object
   * @param request the HTTP request
   * @param response the HTTP response
   * @param item the item
   * @param identifier a persistent identifier that belongs to the item
   */
  private void displayItem(
      Context context, HttpServletRequest request, HttpServletResponse response, Item item)
      throws ServletException, IOException, SQLException, AuthorizeException {
    // Tombstone?
    if (item.isWithdrawn()) {
      JSPManager.showJSP(request, response, "/tombstone.jsp");

      return;
    }

    // Ensure the user has authorisation
    AuthorizeManager.authorizeAction(context, item, Constants.READ);

    log.info(
        LogManager.getHeader(
            context, "view_item", "uri=" + item.getIdentifier().getCanonicalForm()));

    // show edit link
    if (item.canEdit()) {
      // set a variable to create an edit button
      request.setAttribute("admin_button", new Boolean(true));
    }

    // Get the collections
    Collection[] collections = (Collection[]) item.getCollections().toArray();

    // For the breadcrumbs, get the first collection and the first community
    // that is in. FIXME: Not multiple-inclusion friendly--should be
    // smarter, context-sensitive
    request.setAttribute("dspace.collection", item.getOwningCollection());

    Collection collection = item.getOwningCollection();
    if (collection != null) {
      Community[] comms = (Community[]) collection.getCommunities().toArray();
      if (comms.length > 0) {
        request.setAttribute("dspace.community", comms[0]);

        /*
         * Find all the "parent" communities for the collection
         */
        request.setAttribute("dspace.communities", getParents(comms[0], true));
      }
    }

    // Full or simple display?
    boolean displayAll = false;
    String modeParam = request.getParameter("mode");

    if ((modeParam != null) && modeParam.equalsIgnoreCase("full")) {
      displayAll = true;
    }

    // Enable suggest link or not
    boolean suggestEnable = false;
    if (!ConfigurationManager.getBooleanProperty("webui.suggest.enable")) {
      // do nothing, the suggestLink is allready set to false
    } else {
      // it is in general enabled
      suggestEnable = true;

      // check for the enable only for logged in users option
      if (!ConfigurationManager.getBooleanProperty("webui.suggest.loggedinusers.only")) {
        // do nothing, the suggestLink stays as it is
      } else {
        // check whether there is a logged in user
        suggestEnable = (context.getCurrentUser() == null ? false : true);
      }
    }

    // Set attributes and display
    request.setAttribute("suggest.enable", new Boolean(suggestEnable));
    request.setAttribute("display.all", new Boolean(displayAll));
    request.setAttribute("item", item);
    request.setAttribute("collections", collections);
    JSPManager.showJSP(request, response, "/display-item.jsp");
  }
Example #4
0
  public void addBody(Body body) throws SAXException, WingException, SQLException {
    // Get our parameters and state;
    UUID collectionID = UUID.fromString(parameters.getParameter("collectionID", null));
    Collection collection = collectionService.find(context, collectionID);

    List<Item> items = getMappedItems(collection);

    // DIVISION: browse-items
    Division div =
        body.addInteractiveDivision(
            "browse-items",
            contextPath + "/admin/mapper",
            Division.METHOD_GET,
            "primary administrative mapper");
    div.setHead(T_head1);

    if (authorizeService.authorizeActionBoolean(context, collection, Constants.REMOVE)) {
      Para actions = div.addPara();
      actions.addButton("submit_unmap").setValue(T_submit_unmap);
      actions.addButton("submit_return").setValue(T_submit_return);
    } else {
      Para actions = div.addPara();
      Button button = actions.addButton("submit_unmap");
      button.setValue(T_submit_unmap);
      button.setDisabled();
      actions.addButton("submit_return").setValue(T_submit_return);

      div.addPara().addHighlight("fade").addContent(T_no_remove);
    }

    Table table = div.addTable("browse-items-table", 1, 1);

    Row header = table.addRow(Row.ROLE_HEADER);
    header.addCellContent(T_column1);
    header.addCellContent(T_column2);
    header.addCellContent(T_column3);
    header.addCellContent(T_column4);

    for (Item item : items) {
      String itemID = String.valueOf(item.getID());
      Collection owningCollection = item.getOwningCollection();
      String owning = owningCollection.getName();
      String author = "unknown";
      List<MetadataValue> dcAuthors =
          itemService.getMetadata(
              item, MetadataSchema.DC_SCHEMA, "contributor", Item.ANY, Item.ANY);
      if (dcAuthors != null && dcAuthors.size() >= 1) {
        author = dcAuthors.get(0).getValue();
      }

      String title = "untitled";
      List<MetadataValue> dcTitles =
          itemService.getMetadata(item, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY);
      if (dcTitles != null && dcTitles.size() >= 1) {
        title = dcTitles.get(0).getValue();
      }

      String url = contextPath + "/handle/" + item.getHandle();

      Row row = table.addRow();

      CheckBox select = row.addCell().addCheckBox("itemID");
      select.setLabel("Select");
      select.addOption(itemID);

      row.addCellContent(owning);
      row.addCell().addXref(url, author);
      row.addCell().addXref(url, title);
    }

    if (authorizeService.authorizeActionBoolean(context, collection, Constants.REMOVE)) {
      Para actions = div.addPara();
      actions.addButton("submit_unmap").setValue(T_submit_unmap);
      actions.addButton("submit_return").setValue(T_submit_return);
    } else {
      Para actions = div.addPara();
      Button button = actions.addButton("submit_unmap");
      button.setValue(T_submit_unmap);
      button.setDisabled();
      actions.addButton("submit_return").setValue(T_submit_return);

      div.addPara().addHighlight("fade").addContent(T_no_remove);
    }

    div.addHidden("administrative-continue").setValue(knot.getId());
  }