Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
383 changes: 383 additions & 0 deletions dspace-api/src/main/java/org/dspace/administer/ItemVersionLinker.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.administer;

import org.apache.commons.cli.Options;
import org.dspace.scripts.configuration.ScriptConfiguration;

/**
* The {@link ScriptConfiguration} for the {@link ItemVersionLinker} script.
*
* @author Milan Kuchtiak
*/
public class ItemVersionLinkerConfiguration extends ScriptConfiguration<ItemVersionLinker> {

private Class<ItemVersionLinker> dspaceRunnableClass;

/**
* Generic getter for the dspaceRunnableClass
*
* @return the dspaceRunnableClass value of this ScriptConfiguration
*/
@Override
public Class<ItemVersionLinker> getDspaceRunnableClass() {
return dspaceRunnableClass;
}

/**
* Generic setter for the dspaceRunnableClass
*
* @param dspaceRunnableClass The dspaceRunnableClass to be set for this ScriptConfiguration
*/
@Override
public void setDspaceRunnableClass(Class<ItemVersionLinker> dspaceRunnableClass) {
this.dspaceRunnableClass = dspaceRunnableClass;
}

/**
* The getter for the options of the Script
*
* @return the options value of this ScriptConfiguration
*/
@Override
public Options getOptions() {
if (options == null) {

Options options = new Options();

options.addOption("h", "help", false, "help");

options.addOption("l", "link", false, "link item with the previous item");

options.addOption("u", "unlink", false, "unlink item from the previous item in version history");

options.addOption("p", "previous", true,
"item handle, or UUID, of the previous(left) item that is intended to be linked with the (right)" +
" item (only required for link option)");

options.addOption("i", "item", true,
"item handle, or UUID, of the (right) item that is intended to be linked/unlinked with/from the " +
"previous item (required for both link and unlink options)");
options.getOption("i").setRequired(true);

options.addOption("e", "eperson", true, "ePerson email");
options.getOption("e").setRequired(false);

super.options = options;
}
return options;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void update(Context context, List<VersionHistory> versionHistories) throw

@Override
public void delete(Context context, VersionHistory versionHistory) throws SQLException, AuthorizeException {
versionHistoryDAO.delete(context, new VersionHistory());
versionHistoryDAO.delete(context, versionHistory);
}

// LIST order: descending
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,8 @@ public int countVersionsByHistoryWithItem(Context context, VersionHistory versio
return versionDAO.countVersionsByHistoryWithItem(context, versionHistory);
}

@Override
public void deleteVersion(Context c, Version version) throws SQLException {
versionDAO.delete(c, version);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public interface VersioningService {
* To keep version numbers stable we do not delete versions, we do only set
* the item, date, summary and eperson null. This methods returns only those
* versions that have an item assigned.
*
*
* @param c The relevant DSpace Context.
* @param vh Version history
* @param offset The position of the first result to return
Expand Down Expand Up @@ -79,6 +79,16 @@ List<Version> getVersionsByHistoryWithItems(Context c, VersionHistory vh, int of
Version createNewVersion(Context context, VersionHistory history, Item item, String summary, Date date,
int versionNumber);

/**
* This method deletes the version associated with the item from the versioning history,
* but unlike the {@link #delete} method this doesn't delete the entire item.
*
* @param c context
* @param version version
* @throws SQLException if database error
*/
void deleteVersion(Context c, Version version) throws SQLException;

/**
* Update the Version
*
Expand All @@ -94,7 +104,7 @@ Version createNewVersion(Context context, VersionHistory history, Item item, Str
* remove a version we set the item, date, summary and eperson null. This
* method returns only versions that aren't soft deleted and have items
* assigned.
*
*
* @param context The relevant DSpace Context.
* @param versionHistory Version history
* @return Total versions of an version history that have items assigned.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<property name="description" value="Retry all failed commits to the OpenURLTracker"/>
<property name="dspaceRunnableClass" value="org.dspace.statistics.export.RetryFailedOpenUrlTracker"/>
</bean>

<bean id="metadata-deletion" class="org.dspace.app.bulkedit.MetadataDeletionCliScriptConfiguration">
<property name="description" value="Delete all the values of the specified metadata field"/>
<property name="dspaceRunnableClass" value="org.dspace.app.bulkedit.MetadataDeletionCli"/>
Expand Down Expand Up @@ -106,6 +106,11 @@
<property name="dspaceRunnableClass" value="org.dspace.scripts.filepreview.FilePreview"/>
</bean>

<bean id="item-version-linker" class="org.dspace.administer.ItemVersionLinkerConfiguration" primary="true">
<property name="description" value="Link items into versioning relationship."/>
<property name="dspaceRunnableClass" value="org.dspace.administer.ItemVersionLinker"/>
</bean>

<bean id="report-diff" class="org.dspace.app.reportdiff.ReportDiffScriptConfiguration" primary="true">
<property name="description" value="Compares two health reports and shows the differences between them."/>
<property name="dspaceRunnableClass" value="org.dspace.app.reportdiff.ReportDiff"/>
Expand Down
Loading
Loading