@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); } }
/** * Check if the item is an inprogress submission * * @param context The relevant DSpace Context. * @param item item to check * @return <code>true</code> if the item is an inprogress submission, i.e. a WorkspaceItem or WorkflowItem * @throws SQLException An exception that provides information on a database access error or other errors. */ public boolean isInProgressSubmission(Context context, Item item) throws SQLException { return workspaceItemService.findByItem(context, item) != null || workflowItemService.findByItem(context, item) != null; }
public String getObjectSizesInfo(Context context) throws SQLException { StringBuilder sb = new StringBuilder(); sb.append(String.format("Count %-14s: %s\n", "Bitstream", String.valueOf(bitstreamService.countTotal(context)))); sb.append(String.format("Count %-14s: %s\n", "Bundle", String.valueOf(bundleService.countTotal(context)))); sb.append(String.format("Count %-14s: %s\n", "Collection", String.valueOf(collectionService.countTotal(context)))); sb.append(String.format("Count %-14s: %s\n", "Community", String.valueOf(communityService.countTotal(context)))); sb.append(String.format("Count %-14s: %s\n", "MetadataValue", String.valueOf(metadataValueService.countTotal(context)))); sb.append(String.format("Count %-14s: %s\n", "EPerson", String.valueOf(ePersonService.countTotal(context)))); sb.append(String.format("Count %-14s: %s\n", "Item", String.valueOf(itemService.countTotal(context)))); sb.append(String.format("Count %-14s: %s\n", "Handle", String.valueOf(handleService.countTotal(context)))); sb.append(String.format("Count %-14s: %s\n", "Group", String.valueOf(groupService.countTotal(context)))); sb.append(String.format("Count %-14s: %s\n", "BasicWorkflowItem", String.valueOf(basicWorkflowItemService.countTotal(context)))); sb.append(String.format("Count %-14s: %s\n", "WorkspaceItem", String.valueOf(workspaceItemService.countTotal(context)))); return sb.toString(); }
wi = workspaceItemService.create(context, (Collection) parent, false); Item myitem = wi.getItem(); original = bundleService.create(context, myitem, "ORIGINAL"); workspaceItemService.update(context, wi); success = true; log.info(LogManager.getHeader(context, "ingest", workspaceItemService.deleteAll(context, wi);
WorkspaceItem wsi = workspaceItemService.findByItem(c, item); if (wsi != null) { workspaceItemService.deleteAll(c, wsi); } else { WorkflowItem wfi = workflowItemService.findByItem(c, item);
wi = workspaceItemService.create(ourContext, targetCollection, false); item = wi.getItem(); workspaceItemService.deleteWrapper(ourContext, wi); throw se;
Iterator<WorkspaceItem> workspaceItems = workspaceItemService.findByCollection(context, collection).iterator(); while (workspaceItems.hasNext()) { WorkspaceItem workspaceItem = workspaceItems.next(); workspaceItems.remove(); workspaceItemService.deleteAll(context, workspaceItem);
protected void doContainerDelete(SwordContext swordContext, Item item, AuthCredentials authCredentials, SwordConfigurationDSpace swordConfig) throws DSpaceSwordException, SwordAuthException { try { Context context = swordContext.getContext(); // first figure out if there's anything we need to do about the workflow/workspace state WorkflowTools wft = new WorkflowTools(); if (wft.isItemInWorkspace(swordContext.getContext(), item)) { WorkspaceItem wsi = wft.getWorkspaceItem(context, item); workspaceItemService.deleteAll(context, wsi); } else if (wft.isItemInWorkflow(context, item)) { WorkflowItem wfi = wft.getWorkflowItem(context, item); workflowItemService.deleteWrapper(context, wfi); } // then delete the item itemService.delete(context, item); } catch (SQLException | IOException e) { throw new DSpaceSwordException(e); } catch (AuthorizeException e) { throw new SwordAuthException(e); } }
@Override public BasicWorkflowItem start(Context context, WorkspaceItem wsi) throws SQLException, AuthorizeException, IOException { Item myitem = wsi.getItem(); Collection collection = wsi.getCollection(); log.info(LogManager.getHeader(context, "start_workflow", "workspace_item_id=" + wsi.getID() + "item_id=" + myitem.getID() + "collection_id=" + collection.getID())); // record the start of the workflow w/provenance message recordStart(context, myitem); // create the WorkflowItem BasicWorkflowItem wfi = workflowItemService.create(context, myitem, collection); wfi.setMultipleFiles(wsi.hasMultipleFiles()); wfi.setMultipleTitles(wsi.hasMultipleTitles()); wfi.setPublishedBefore(wsi.isPublishedBefore()); // remove the WorkspaceItem workspaceItemService.deleteWrapper(context, wsi); // now get the workflow started wfi.setState(WFSTATE_SUBMIT); advance(context, wfi, null); // Return the workflow item return wfi; }
@Override public List<WorkspaceItem> getAll(Context context) throws SQLException { return workspaceItemService.findAllSupervisedItems(context); }
.findByEPerson(sc.getContext(), person); for (WorkspaceItem wsi : wsis) { Item item = wsi.getItem();
workspaceItemService.deleteWrapper(context, wsi); context.restoreAuthSystemState(); return wfi;
/** * Is the given item in a DSpace workspace? * <p> * This method queries the database directly to determine if this is the * case rather than using the DSpace API (which is very slow). * * @param context The relevant DSpace Context. * @param item item to check * @return true if item is in workspace * @throws DSpaceSwordException can be thrown by the internals of the DSpace SWORD implementation */ public boolean isItemInWorkspace(Context context, Item item) throws DSpaceSwordException { try { return workspaceItemService.findByItem(context, item) != null; } catch (SQLException e) { throw new DSpaceSwordException(e); } }
@Override public List<String> generateOutput(RecordSet recordSet) { log.info("BTE OutputGenerator started. Records to output: " + recordSet.getRecords().size()); // Printing debug message String totalString = ""; for (Record record : recordSet.getRecords()) { totalString += SubmissionLookupUtils.getPrintableString(record) + "\n"; } log.debug("Records to output:\n" + totalString); witems = new ArrayList<WorkspaceItem>(); for (Record rec : recordSet.getRecords()) { try { WorkspaceItem wi = workspaceItemService.create(context, collection, true); merge(formName, wi.getItem(), rec); witems.add(wi); } catch (AuthorizeException e) { log.error(e.getMessage(), e); } catch (SQLException e) { log.error(e.getMessage(), e); } } return new ArrayList<String>(); }
/** * Obtain the WorkspaceItem object which wraps the given Item. * <p> * This method queries the database directly to determine if this is the * case rather than using the DSpace API (which is very slow). * * @param context The relevant DSpace Context. * @param item item to check * @return workspace item * @throws DSpaceSwordException can be thrown by the internals of the DSpace SWORD implementation */ public WorkspaceItem getWorkspaceItem(Context context, Item item) throws DSpaceSwordException { try { return workspaceItemService.findByItem(context, item); } catch (SQLException e) { throw new DSpaceSwordException(e); } }
.create(context, (Collection) parent, params.useCollectionTemplate());