List<MetadataValue> metadata = itemService.getMetadata(item, MD_SCHEMA, DOI_ELEMENT, DOI_QUALIFIER, null); List<String> remainder = new ArrayList<String>(); itemService.clearMetadata(context, item, MD_SCHEMA, DOI_ELEMENT, DOI_QUALIFIER, null); itemService.addMetadata(context, item, MD_SCHEMA, DOI_ELEMENT, DOI_QUALIFIER, null, remainder); itemService.update(context, item);
public boolean testItem(Context context, Item item) { return itemService.getMetadataByMetadataString(item, "dc.identifier.uri").size() > 1; } },
@Override public void delete(Context context, XmlWorkflowItem workflowItem) throws SQLException, AuthorizeException, IOException { Item item = workflowItem.getItem(); // Need to delete the workspaceitem row first since it refers // to item ID deleteWrapper(context, workflowItem); // Delete item itemService.delete(context, item); }
@Override public void removeLicense(Context context, Item item) throws SQLException, IOException, AuthorizeException { // remove CC license bundle if one exists List<Bundle> bundles = itemService.getBundles(item, CC_BUNDLE_NAME); if ((bundles.size() > 0) && (bundles.get(0) != null)) { itemService.removeBundle(context, item, bundles.get(0)); } }
@Override public void liftEmbargo(Context context, Item item) throws SQLException, AuthorizeException, IOException { // Since 3.0 the lift process for all embargoes is performed through the dates // on the authorization process (see DS-2588) // lifter.liftEmbargo(context, item); itemService.clearMetadata(context, item, lift_schema, lift_element, lift_qualifier, Item.ANY); // set the dc.date.available value to right now itemService.clearMetadata(context, item, MetadataSchema.DC_SCHEMA, "date", "available", Item.ANY); itemService.addMetadata(context, item, MetadataSchema.DC_SCHEMA, "date", "available", null, DCDate.getCurrent().toString()); log.info("Lifting embargo on Item " + item.getHandle()); itemService.update(context, item); }
/** * Removes the passed value from the set of values for the field in passed item. * * @param context The relevant DSpace Context. * @param item - the item to update * @param value - the value to remove * @throws IOException A general class of exceptions produced by failed or interrupted I/O operations. * @throws SQLException An exception that provides information on a database access error or other errors. * @throws AuthorizeException Exception indicating the current user of the context does not have permission * to perform a particular action. */ public void removeItemValue(Context context, Item item, String value) throws AuthorizeException, IOException, SQLException { if (value != null) { List<MetadataValue> dcvalues = itemService.getMetadata(item, params[0], params[1], params[2], params[3]); ArrayList<String> arrayList = new ArrayList<String>(); for (MetadataValue dcvalue : dcvalues) { if (!dcvalue.getValue().equals(value)) { arrayList.add(dcvalue.getValue()); } } itemService.clearMetadata(context, item, params[0], params[1], params[2], params[3]); itemService.addMetadata(context, item, params[0], params[1], params[2], params[3], arrayList); } }
@Override public ActionResult execute(Context c, XmlWorkflowItem wfi, Step step, HttpServletRequest request) throws SQLException, AuthorizeException, IOException, WorkflowException { if (request.getParameter("submit_score") != null) { int score = Util.getIntParameter(request, "score"); //Add our score to the metadata itemService.addMetadata(c, wfi.getItem(), WorkflowRequirementsService.WORKFLOW_SCHEMA, "score", null, null, String.valueOf(score)); itemService.update(c, wfi.getItem()); return new ActionResult(ActionResult.TYPE.TYPE_OUTCOME, ActionResult.OUTCOME_COMPLETE); } else { //We have pressed the leave button so return to our submission page return new ActionResult(ActionResult.TYPE.TYPE_SUBMISSION_PAGE); } } }
itemService.clearMetadata(context, item, dc.schema, dc.element, dc.qualifier, Item.ANY); DCDate date = new DCDate(new Date()); itemService.addMetadata(context, item, dc.schema, dc.element, dc.qualifier, null, date.toString()); } catch (SQLException e) {
@Override public List<MetadataValue> getLiftMetadata(Context context, Item item) { return itemService.getMetadata(item, lift_schema, lift_element, lift_qualifier, Item.ANY); }
Bitstream bs = itemService.createSingleBitstream( context, deposit.getInputStream(), item); BitstreamFormat format = this.getFormat( itemService.addMetadata(context, item, "dc", "title", null, null, "Untitled: " + deposit.getFilename()); itemService.addMetadata( context, item, "dc", "description", null, null, "Zip file deposted by SWORD without accompanying metadata"); itemService.update(context, item); context.restoreAuthSystemState();
protected void populateHandleMetadata(Context context, Item item, String handle) throws SQLException, IOException, AuthorizeException { String handleref = handleService.getCanonicalForm(handle); // Add handle as identifier.uri DC value. // First check that identifier doesn't already exist. boolean identifierExists = false; List<MetadataValue> identifiers = itemService .getMetadata(item, MetadataSchema.DC_SCHEMA, "identifier", "uri", Item.ANY); for (MetadataValue identifier : identifiers) { if (handleref.equals(identifier.getValue())) { identifierExists = true; } } if (!identifierExists) { itemService.addMetadata(context, item, MetadataSchema.DC_SCHEMA, "identifier", "uri", null, handleref); } } }
item = itemService.find(c, id); if (item == null) { throw new MetadataImportException("Unknown item ID " + id); itemService.delete(c, item); itemService.withdraw(c, item); itemService.reinstate(c, item); itemService.addMetadata(c, item, dcv.getSchema(), dcv.getElement(), dcv.getQualifier(),
/** * Run task for Collection along with all Items in that collection. * * @param tr TaskRunner * @param coll Collection * @return true if successful, false otherwise * @throws IOException if IO error */ protected boolean doCollection(TaskRunner tr, Collection coll) throws IOException { try { if (!tr.run(coll)) { return false; } Context context = curationContext(); Iterator<Item> iter = itemService.findByCollection(context, coll); while (iter.hasNext()) { Item item = iter.next(); boolean shouldContinue = tr.run(item); context.uncacheEntity(item); if (!shouldContinue) { return false; } } } catch (SQLException sqlE) { throw new IOException(sqlE.getMessage(), sqlE); } return true; }
.clearMetadata(context, item, WorkflowRequirementsService.WORKFLOW_SCHEMA, Item.ANY, Item.ANY, Item.ANY); itemService.update(context, item);
@Override public Item createNewItemAndAddItInWorkspace(Context context, Item nativeItem) { try { WorkspaceItem workspaceItem = workspaceItemService.create(context, nativeItem.getOwningCollection(), false); Item itemNew = workspaceItem.getItem(); itemService.update(context, itemNew); return itemNew; } catch (SQLException | AuthorizeException e) { throw new RuntimeException(e.getMessage(), e); } }
@Override public Bitstream getFirstBitstream(Item item, String bundleName) throws SQLException { List<Bundle> bundles = itemService.getBundles(item, bundleName); if (CollectionUtils.isNotEmpty(bundles)) { List<Bitstream> bitstreams = bundles.get(0).getBitstreams(); if (CollectionUtils.isNotEmpty(bitstreams)) { return bitstreams.get(0); } } return null; }
org.dspace.content.Item item = itemService.findByIdOrLegacyId(context, itemId); itemService.update(context, item);
Item item = itemService.findByIdOrLegacyId(context, dsoId); if (item == null) { break; List<MetadataValue> vals = itemService.getMetadata(item, "dc", "title", null, Item.ANY); if (vals != null && 0 < vals.size()) { name = vals.get(0).getValue();
itemService.findByCollection(context, collection, limit, offset); org.dspace.content.Item item = childItems.next(); if (itemService.isItemListedForUser(context, item)) { items.add(new Item(item, servletContext, null, context)); this.setNumberItems(itemService.countItems(context, collection));
protected void updateItems(AuthorityValue authority) { try { Iterator<Item> itemIterator = itemService .findByMetadataFieldAuthority(context, authority.getField(), authority.getId()); while (itemIterator.hasNext()) { Item next = itemIterator.next(); List<MetadataValue> metadata = itemService.getMetadata(next, authority.getField(), authority.getId()); authority.updateItem(context, next, metadata.get(0)); //should be only one List<MetadataValue> metadataAfter = itemService .getMetadata(next, authority.getField(), authority.getId()); if (!metadata.get(0).getValue().equals(metadataAfter.get(0).getValue())) { print.println("Updated item with handle " + next.getHandle()); } } } catch (Exception e) { log.error("Error updating item", e); print.println("Error updating item. " + Arrays.toString(e.getStackTrace())); } }