Skip to content

Commit

Permalink
Merged in DSC-1201 (pull request DSpace#1010)
Browse files Browse the repository at this point in the history
[DSC-1201] Make it possible to create related item using templates

Approved-by: Francesco Pio Scognamiglio
  • Loading branch information
NikitaKr1vonosov authored and francescopioscognamiglio committed Oct 13, 2023
2 parents 7294b69 + e9576e6 commit a820789
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
13 changes: 12 additions & 1 deletion dspace-api/src/main/java/org/dspace/authority/CrisConsumer.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ private String getFieldKey(MetadataValue metadata) {
private Item buildRelatedItem(Context context, Item item, Collection collection, MetadataValue metadata,
String entityType, String crisSourceId) throws Exception {

WorkspaceItem workspaceItem = workspaceItemService.create(context, collection, false);
WorkspaceItem workspaceItem = workspaceItemService.create(context, collection, useOfTemplate(metadata));
Item relatedItem = workspaceItem.getItem();
itemService.addMetadata(context, relatedItem, CRIS.getName(), "sourceId", null, null, crisSourceId);
if (!hasEntityType(relatedItem, entityType)) {
Expand Down Expand Up @@ -299,6 +299,17 @@ private boolean isSubmissionEnabled(MetadataValue value) {
}
}

private boolean useOfTemplate(MetadataValue value) {

String useOfTemplateByMetadata = "cris.import.submission.enabled.entity."
+ getFieldKey(value) + ".use-template";
if (configurationService.hasProperty(useOfTemplateByMetadata)) {
return configurationService.getBooleanProperty(useOfTemplateByMetadata);
}

return configurationService.getBooleanProperty("cris.import.submission.enabled.entity.use-template");
}

private void fillRelatedItem(Context context, MetadataValue metadata, Item relatedItem, boolean alreadyPresent)
throws SQLException {

Expand Down
7 changes: 7 additions & 0 deletions dspace/config/modules/cris.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ cris.entity-type = Equipment
cris-consumer.skip-empty-authority = true
cris.item-reference-resolution.override-metadata-value = false

# It specifies whether CrisConsumer should use template while creating related items.
# By default it is false and so no template is used.
# cris.import.submission.enabled.entity.use-template = true

# It specifies whether CrisConsumer should use template while creating
# related item linked via specified authority field.
# cris.import.submission.enabled.entity.{authority_field_separated_by_underscores}.use-template = true

# Max size, in bytes of bitstreams without a custom thumbnail
# to be rendered directly as thumbnail
Expand Down

0 comments on commit a820789

Please sign in to comment.