Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate legacy uuid identifier #274

Open
wants to merge 13 commits into
base: dspace-cris-2023_02_x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
14 changes: 10 additions & 4 deletions dspace-api/src/main/java/org/dspace/app/batch/ItemImportOA.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.StringTokenizer;
import java.util.UUID;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -85,6 +86,7 @@
import org.dspace.services.ConfigurationService;
import org.dspace.services.factory.DSpaceServicesFactory;
import org.dspace.util.ItemUtils;
import org.dspace.util.UUIDUtils;
import org.dspace.utils.DSpace;
import org.dspace.workflow.WorkflowException;
import org.dspace.xmlworkflow.WorkflowConfigurationException;
Expand Down Expand Up @@ -547,11 +549,15 @@ private UUID addItem(Context c, Collection[] mycollections, ImpRecord impRecord,
Item myitem = null;
WorkspaceItem wsi = null;
c.setCurrentUser(myEPerson);

wsi = workspaceItemService.create(c, mycollections[0], false);
UUID predefineduuid = UUIDUtils.fromString(handle);
floriangantner marked this conversation as resolved.
Show resolved Hide resolved
if (Objects.nonNull(predefineduuid)) {
wsi = workspaceItemService.create(c, mycollections[0], predefineduuid,false);
} else {
wsi = workspaceItemService.create(c, mycollections[0], false);
}
myitem = wsi.getItem();

if (StringUtils.isNotEmpty(handle)) {
if (Objects.isNull(predefineduuid) && StringUtils.isNotEmpty(handle)) {
identifierService.register(c, myitem, handle);
}

Expand Down Expand Up @@ -1017,4 +1023,4 @@ public void setSourceRef(String sourceRef) {
this.sourceRef = sourceRef.trim();
}

}
}
9 changes: 8 additions & 1 deletion dspace/etc/migration/entity_migration.ktr
Original file line number Diff line number Diff line change
Expand Up @@ -2407,6 +2407,9 @@ WHERE property_def.id = properties.typo_id
<remove>
<name>entity_type_var</name>
</remove>
<remove>
<name>uuid</name>
</remove>
</fields>
<attributes/>
<cluster_schema/>
Expand Down Expand Up @@ -3769,7 +3772,7 @@ and parent_id = ?</sql>
<schema_name/>
</partitioning>
<connection>dspace</connection>
<sql>SELECT id, crisid, sourceref, row_number() OVER () as row_number
<sql>SELECT id, crisid, uuid, sourceref, row_number() OVER () as row_number
FROM "public".${ENTITY_TABLE}
WHERE ${ENTITY_FILTER}
</sql>
Expand Down Expand Up @@ -5479,6 +5482,10 @@ WHERE property_def.id = properties.typo_id
<column_name>status</column_name>
<stream_name>status</stream_name>
</field>
<field>
<column_name>handle</column_name>
<stream_name>uuid</stream_name>
</field>
</fields>
<attributes/>
<cluster_schema/>
Expand Down