mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Multiple updates.
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* http://www.dspace.org/license/
|
* http://www.dspace.org/license/
|
||||||
*/
|
*/
|
||||||
package org.dspace.app.canvasdimension;
|
package org.dspace.iiif.canvasdimension;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -17,18 +17,19 @@ import org.apache.commons.cli.HelpFormatter;
|
|||||||
import org.apache.commons.cli.MissingArgumentException;
|
import org.apache.commons.cli.MissingArgumentException;
|
||||||
import org.apache.commons.cli.Option;
|
import org.apache.commons.cli.Option;
|
||||||
import org.apache.commons.cli.Options;
|
import org.apache.commons.cli.Options;
|
||||||
import org.dspace.app.canvasdimension.factory.IIIFCanvasDimensionServiceFactory;
|
|
||||||
import org.dspace.app.canvasdimension.service.IIIFCanvasDimensionService;
|
|
||||||
import org.dspace.content.Collection;
|
import org.dspace.content.Collection;
|
||||||
import org.dspace.content.Community;
|
import org.dspace.content.Community;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
|
import org.dspace.content.factory.ContentServiceFactory;
|
||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.eperson.factory.EPersonServiceFactory;
|
import org.dspace.eperson.factory.EPersonServiceFactory;
|
||||||
import org.dspace.eperson.service.EPersonService;
|
import org.dspace.eperson.service.EPersonService;
|
||||||
import org.dspace.handle.factory.HandleServiceFactory;
|
import org.dspace.handle.factory.HandleServiceFactory;
|
||||||
|
import org.dspace.iiif.canvasdimension.factory.IIIFCanvasDimensionServiceFactory;
|
||||||
|
import org.dspace.iiif.canvasdimension.service.IIIFCanvasDimensionService;
|
||||||
import org.dspace.services.ConfigurationService;
|
import org.dspace.services.ConfigurationService;
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
|
|
||||||
@@ -61,7 +62,9 @@ public class CanvasDimensionCLI {
|
|||||||
int max2Process = Integer.MAX_VALUE;
|
int max2Process = Integer.MAX_VALUE;
|
||||||
|
|
||||||
String identifier = null;
|
String identifier = null;
|
||||||
|
String typeString = null;
|
||||||
String eperson = null;
|
String eperson = null;
|
||||||
|
int dsoType = -1;
|
||||||
|
|
||||||
Context context = new Context();
|
Context context = new Context();
|
||||||
IIIFCanvasDimensionService canvasProcessor = IIIFCanvasDimensionServiceFactory.getInstance()
|
IIIFCanvasDimensionService canvasProcessor = IIIFCanvasDimensionServiceFactory.getInstance()
|
||||||
@@ -72,14 +75,18 @@ public class CanvasDimensionCLI {
|
|||||||
Options options = new Options();
|
Options options = new Options();
|
||||||
options.addOption("i", "identifier", true,
|
options.addOption("i", "identifier", true,
|
||||||
"process IIIF canvas dimensions for images belonging to this identifier");
|
"process IIIF canvas dimensions for images belonging to this identifier");
|
||||||
|
options.addOption("t", "type", true,
|
||||||
|
"type: COMMUNITY, COLLECTION or ITEM\"");
|
||||||
options.addOption("e", "eperson", true,
|
options.addOption("e", "eperson", true,
|
||||||
"email of eperson setting the canvas dimensions");
|
"email of eperson setting the canvas dimensions");
|
||||||
options.addOption("f", "force", false,
|
options.addOption("f", "force", false,
|
||||||
"force update of all IIIF canvas height and width dimensions");
|
"force update of all IIIF canvas height and width dimensions");
|
||||||
options.addOption("q", "quiet", false,
|
options.addOption("q", "quiet", false,
|
||||||
"do not print anything except in the event of errors.");
|
"do not print anything except in the event of errors");
|
||||||
options.addOption("m", "maximum", true,
|
options.addOption("m", "maximum", true,
|
||||||
"process no more than maximum items");
|
"process no more than maximum items");
|
||||||
|
options.addOption("h", "help", false,
|
||||||
|
"display help");
|
||||||
|
|
||||||
Option skipOption = Option.builder("s")
|
Option skipOption = Option.builder("s")
|
||||||
.longOpt("skip")
|
.longOpt("skip")
|
||||||
@@ -104,6 +111,17 @@ public class CanvasDimensionCLI {
|
|||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (line.hasOption('h')) {
|
||||||
|
HelpFormatter help = new HelpFormatter();
|
||||||
|
help.printHelp("CanvasDimension processor\n", options);
|
||||||
|
System.out
|
||||||
|
.println("\nUUID example: iiif-canvas-dimensions -e user@email.org " +
|
||||||
|
"-i 1086306d-8a51-43c3-98b9-c3b00f49105f -t COLLECTION");
|
||||||
|
System.out
|
||||||
|
.println("\nHandle example: iiif-canvas-dimensions -e user@email.org -i 123456/21");
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
if (line.hasOption('f')) {
|
if (line.hasOption('f')) {
|
||||||
force = true;
|
force = true;
|
||||||
}
|
}
|
||||||
@@ -116,9 +134,29 @@ public class CanvasDimensionCLI {
|
|||||||
if (line.hasOption('i')) {
|
if (line.hasOption('i')) {
|
||||||
identifier = line.getOptionValue('i');
|
identifier = line.getOptionValue('i');
|
||||||
} else {
|
} else {
|
||||||
|
HelpFormatter help = new HelpFormatter();
|
||||||
|
help.printHelp("CanvasDimension processor\n", options);
|
||||||
System.out.println("An identifier for a Community, Collection, or Item must be provided.");
|
System.out.println("An identifier for a Community, Collection, or Item must be provided.");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
if (line.hasOption('t')) {
|
||||||
|
typeString = line.getOptionValue('t');
|
||||||
|
if ("ITEM".equalsIgnoreCase(typeString)) {
|
||||||
|
dsoType = Constants.ITEM;
|
||||||
|
} else if ("COLLECTION".equals(typeString)) {
|
||||||
|
dsoType = Constants.COLLECTION;
|
||||||
|
} else if ("COMMUNITY".equalsIgnoreCase(typeString)) {
|
||||||
|
dsoType = Constants.COMMUNITY;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// If the identifier is a handle dsoType is not required.
|
||||||
|
if (identifier.indexOf('/') == -1) {
|
||||||
|
HelpFormatter help = new HelpFormatter();
|
||||||
|
help.printHelp("CanvasDimension processor\n", options);
|
||||||
|
System.out.println("A DSpace type must be provided: COMMUNITY, COLLECTION or ITEM.");
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (line.hasOption('m')) {
|
if (line.hasOption('m')) {
|
||||||
max2Process = Integer.parseInt(line.getOptionValue('m'));
|
max2Process = Integer.parseInt(line.getOptionValue('m'));
|
||||||
if (max2Process <= 1) {
|
if (max2Process <= 1) {
|
||||||
@@ -144,11 +182,20 @@ public class CanvasDimensionCLI {
|
|||||||
canvasProcessor.setSkipList(Arrays.asList(skipIds));
|
canvasProcessor.setSkipList(Arrays.asList(skipIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DSpaceObject dso = null;
|
||||||
|
if (identifier.indexOf('/') != -1) {
|
||||||
|
dso = HandleServiceFactory.getInstance().getHandleService().resolveToObject(context, identifier);
|
||||||
|
} else if (dsoType == Constants.COMMUNITY) {
|
||||||
|
dso = ContentServiceFactory.getInstance().getCommunityService().find(context, UUID.fromString(identifier));
|
||||||
|
} else if (dsoType == Constants.COLLECTION) {
|
||||||
|
dso = ContentServiceFactory.getInstance().getCollectionService().find(context, UUID.fromString(identifier));
|
||||||
|
} else if (dsoType == Constants.ITEM) {
|
||||||
|
dso = ContentServiceFactory.getInstance().getItemService().find(context, UUID.fromString(identifier));
|
||||||
|
}
|
||||||
|
|
||||||
DSpaceObject dso = HandleServiceFactory.getInstance().getHandleService().resolveToObject(context, identifier);
|
|
||||||
if (dso == null) {
|
if (dso == null) {
|
||||||
throw new IllegalArgumentException("Cannot resolve "
|
throw new IllegalArgumentException("Cannot resolve "
|
||||||
+ identifier + " to a DSpace object");
|
+ identifier + " to a DSpace object using type: " + typeString);
|
||||||
}
|
}
|
||||||
|
|
||||||
EPerson user;
|
EPerson user;
|
||||||
@@ -189,10 +236,13 @@ public class CanvasDimensionCLI {
|
|||||||
processed = 1;
|
processed = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
System.out.println("Unsupported object type.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// commit changes
|
// commit changes
|
||||||
context.commit();
|
if (processed >= 1) {
|
||||||
|
context.commit();
|
||||||
|
}
|
||||||
|
|
||||||
// Always print summary to standard out.
|
// Always print summary to standard out.
|
||||||
System.out.println(processed + " IIIF items were processed.");
|
System.out.println(processed + " IIIF items were processed.");
|
@@ -5,9 +5,9 @@
|
|||||||
*
|
*
|
||||||
* http://www.dspace.org/license/
|
* http://www.dspace.org/license/
|
||||||
*/
|
*/
|
||||||
package org.dspace.app.canvasdimension;
|
package org.dspace.iiif.canvasdimension;
|
||||||
|
|
||||||
import static org.dspace.app.canvasdimension.Util.checkDimensions;
|
import static org.dspace.iiif.canvasdimension.Util.checkDimensions;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -18,10 +18,9 @@ import java.net.URL;
|
|||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.app.canvasdimension.service.IIIFApiQueryService;
|
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
|
import org.dspace.iiif.canvasdimension.service.IIIFApiQueryService;
|
||||||
import org.dspace.iiif.util.IIIFSharedUtils;
|
import org.dspace.iiif.util.IIIFSharedUtils;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,15 +29,10 @@ import org.springframework.beans.factory.InitializingBean;
|
|||||||
*
|
*
|
||||||
* @author Michael Spalti mspalti@willamette.edu
|
* @author Michael Spalti mspalti@willamette.edu
|
||||||
*/
|
*/
|
||||||
public class IIIFApiQueryServiceImpl implements IIIFApiQueryService, InitializingBean {
|
public class IIIFApiQueryServiceImpl implements IIIFApiQueryService {
|
||||||
|
|
||||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(IIIFApiQueryServiceImpl.class);
|
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(IIIFApiQueryServiceImpl.class);
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterPropertiesSet() throws Exception {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getImageDimensions(Bitstream bitstream) {
|
public int[] getImageDimensions(Bitstream bitstream) {
|
||||||
return getIiifImageDimensions(bitstream);
|
return getIiifImageDimensions(bitstream);
|
@@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* http://www.dspace.org/license/
|
* http://www.dspace.org/license/
|
||||||
*/
|
*/
|
||||||
package org.dspace.app.canvasdimension;
|
package org.dspace.iiif.canvasdimension;
|
||||||
|
|
||||||
import static org.dspace.iiif.util.IIIFSharedUtils.METADATA_IIIF_HEIGHT;
|
import static org.dspace.iiif.util.IIIFSharedUtils.METADATA_IIIF_HEIGHT;
|
||||||
import static org.dspace.iiif.util.IIIFSharedUtils.METADATA_IIIF_IMAGE;
|
import static org.dspace.iiif.util.IIIFSharedUtils.METADATA_IIIF_IMAGE;
|
||||||
@@ -19,8 +19,6 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.dspace.app.canvasdimension.service.IIIFApiQueryService;
|
|
||||||
import org.dspace.app.canvasdimension.service.IIIFCanvasDimensionService;
|
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
import org.dspace.content.Bundle;
|
import org.dspace.content.Bundle;
|
||||||
@@ -33,6 +31,8 @@ import org.dspace.content.service.CommunityService;
|
|||||||
import org.dspace.content.service.DSpaceObjectService;
|
import org.dspace.content.service.DSpaceObjectService;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.iiif.canvasdimension.service.IIIFApiQueryService;
|
||||||
|
import org.dspace.iiif.canvasdimension.service.IIIFCanvasDimensionService;
|
||||||
import org.dspace.iiif.util.IIIFSharedUtils;
|
import org.dspace.iiif.util.IIIFSharedUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
@@ -5,9 +5,9 @@
|
|||||||
*
|
*
|
||||||
* http://www.dspace.org/license/
|
* http://www.dspace.org/license/
|
||||||
*/
|
*/
|
||||||
package org.dspace.app.canvasdimension;
|
package org.dspace.iiif.canvasdimension;
|
||||||
|
|
||||||
import static org.dspace.app.canvasdimension.Util.checkDimensions;
|
import static org.dspace.iiif.canvasdimension.Util.checkDimensions;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
@@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* http://www.dspace.org/license/
|
* http://www.dspace.org/license/
|
||||||
*/
|
*/
|
||||||
package org.dspace.app.canvasdimension;
|
package org.dspace.iiif.canvasdimension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utilities for IIIF canvas dimension processing.
|
* Utilities for IIIF canvas dimension processing.
|
@@ -5,9 +5,9 @@
|
|||||||
*
|
*
|
||||||
* http://www.dspace.org/license/
|
* http://www.dspace.org/license/
|
||||||
*/
|
*/
|
||||||
package org.dspace.app.canvasdimension.factory;
|
package org.dspace.iiif.canvasdimension.factory;
|
||||||
|
|
||||||
import org.dspace.app.canvasdimension.service.IIIFCanvasDimensionService;
|
import org.dspace.iiif.canvasdimension.service.IIIFCanvasDimensionService;
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
|
|
||||||
/**
|
/**
|
@@ -5,9 +5,9 @@
|
|||||||
*
|
*
|
||||||
* http://www.dspace.org/license/
|
* http://www.dspace.org/license/
|
||||||
*/
|
*/
|
||||||
package org.dspace.app.canvasdimension.factory;
|
package org.dspace.iiif.canvasdimension.factory;
|
||||||
|
|
||||||
import org.dspace.app.canvasdimension.service.IIIFCanvasDimensionService;
|
import org.dspace.iiif.canvasdimension.service.IIIFCanvasDimensionService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
/**
|
/**
|
@@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* http://www.dspace.org/license/
|
* http://www.dspace.org/license/
|
||||||
*/
|
*/
|
||||||
package org.dspace.app.canvasdimension.service;
|
package org.dspace.iiif.canvasdimension.service;
|
||||||
|
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
|
|
@@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* http://www.dspace.org/license/
|
* http://www.dspace.org/license/
|
||||||
*/
|
*/
|
||||||
package org.dspace.app.canvasdimension.service;
|
package org.dspace.iiif.canvasdimension.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@@ -97,7 +97,7 @@ public class CanvasDimensionsIT extends AbstractIntegrationTestWithDatabase {
|
|||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
String handle = iiifItem.getHandle();
|
String handle = iiifItem.getHandle();
|
||||||
execCanvasScript(handle);
|
execCanvasScriptHandle(handle);
|
||||||
// The test image is small so the canvas dimension should be doubled, e.g. height 200 -> height 400
|
// The test image is small so the canvas dimension should be doubled, e.g. height 200 -> height 400
|
||||||
assertTrue(bitstream.getMetadata().stream()
|
assertTrue(bitstream.getMetadata().stream()
|
||||||
.filter(m -> m.getMetadataField().toString('.').contentEquals(METADATA_IIIF_HEIGHT))
|
.filter(m -> m.getMetadataField().toString('.').contentEquals(METADATA_IIIF_HEIGHT))
|
||||||
@@ -127,8 +127,8 @@ public class CanvasDimensionsIT extends AbstractIntegrationTestWithDatabase {
|
|||||||
.build();
|
.build();
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
String handle = col1.getHandle();
|
String id = col1.getID().toString();
|
||||||
execCanvasScript(handle);
|
execCanvasScript(id, "COLLECTION");
|
||||||
// The test image is small so the canvas dimension should be doubled, e.g. height 200 -> height 400
|
// The test image is small so the canvas dimension should be doubled, e.g. height 200 -> height 400
|
||||||
assertTrue(bitstream.getMetadata().stream()
|
assertTrue(bitstream.getMetadata().stream()
|
||||||
.filter(m -> m.getMetadataField().toString('.').contentEquals(METADATA_IIIF_HEIGHT))
|
.filter(m -> m.getMetadataField().toString('.').contentEquals(METADATA_IIIF_HEIGHT))
|
||||||
@@ -158,8 +158,9 @@ public class CanvasDimensionsIT extends AbstractIntegrationTestWithDatabase {
|
|||||||
.build();
|
.build();
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
String handle = child1.getHandle();
|
String id = child1.getID().toString();
|
||||||
execCanvasScript(handle);
|
execCanvasScript(id, "COMMUNITY");
|
||||||
|
|
||||||
// The test image is small so the canvas dimension should be doubled, e.g. height 200 -> height 400
|
// The test image is small so the canvas dimension should be doubled, e.g. height 200 -> height 400
|
||||||
assertTrue(bitstream.getMetadata().stream()
|
assertTrue(bitstream.getMetadata().stream()
|
||||||
.filter(m -> m.getMetadataField().toString('.').contentEquals(METADATA_IIIF_HEIGHT))
|
.filter(m -> m.getMetadataField().toString('.').contentEquals(METADATA_IIIF_HEIGHT))
|
||||||
@@ -190,7 +191,7 @@ public class CanvasDimensionsIT extends AbstractIntegrationTestWithDatabase {
|
|||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
String handle = parentCommunity.getHandle();
|
String handle = parentCommunity.getHandle();
|
||||||
execCanvasScript(handle);
|
execCanvasScriptHandle(handle);
|
||||||
// The test image is small so the canvas dimension should be doubled, e.g. height 200 -> height 400
|
// The test image is small so the canvas dimension should be doubled, e.g. height 200 -> height 400
|
||||||
assertTrue(bitstream.getMetadata().stream()
|
assertTrue(bitstream.getMetadata().stream()
|
||||||
.filter(m -> m.getMetadataField().toString('.').contentEquals(METADATA_IIIF_HEIGHT))
|
.filter(m -> m.getMetadataField().toString('.').contentEquals(METADATA_IIIF_HEIGHT))
|
||||||
@@ -233,8 +234,9 @@ public class CanvasDimensionsIT extends AbstractIntegrationTestWithDatabase {
|
|||||||
|
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
String handle = parentCommunity.getHandle();
|
String id = parentCommunity.getID().toString();
|
||||||
execCanvasScript(handle);
|
execCanvasScript(id, "COMMUNITY");
|
||||||
|
|
||||||
// All bitstreams should be updated with canvas metadata.
|
// All bitstreams should be updated with canvas metadata.
|
||||||
assertTrue(bitstream.getMetadata().stream()
|
assertTrue(bitstream.getMetadata().stream()
|
||||||
.filter(m -> m.getMetadataField().toString('.').contentEquals(METADATA_IIIF_HEIGHT))
|
.filter(m -> m.getMetadataField().toString('.').contentEquals(METADATA_IIIF_HEIGHT))
|
||||||
@@ -272,8 +274,43 @@ public class CanvasDimensionsIT extends AbstractIntegrationTestWithDatabase {
|
|||||||
.build();
|
.build();
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
String handle = iiifItem.getHandle();
|
String id = iiifItem.getID().toString();
|
||||||
execCanvasScriptForceOption(handle);
|
execCanvasScriptForceOption(id, "ITEM");
|
||||||
|
|
||||||
|
// The existing metadata should be updated
|
||||||
|
assertTrue(bitstream.getMetadata().stream()
|
||||||
|
.filter(m -> m.getMetadataField().toString('.').contentEquals(METADATA_IIIF_HEIGHT))
|
||||||
|
.anyMatch(m -> m.getValue().contentEquals("400")));
|
||||||
|
assertTrue(bitstream.getMetadata().stream()
|
||||||
|
.filter(m -> m.getMetadataField().toString('.').contentEquals(METADATA_IIIF_WIDTH))
|
||||||
|
.anyMatch(m -> m.getValue().contentEquals("600")));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void processCollectionWithForce() throws Exception {
|
||||||
|
context.turnOffAuthorisationSystem();
|
||||||
|
// Create a new Item
|
||||||
|
iiifItem = ItemBuilder.createItem(context, col1)
|
||||||
|
.withTitle("Test Item")
|
||||||
|
.withIssueDate("2017-10-17")
|
||||||
|
.enableIIIF()
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Add jpeg image bitstream (300 x 200)
|
||||||
|
InputStream input = this.getClass().getResourceAsStream("cat.jpg");
|
||||||
|
bitstream = BitstreamBuilder
|
||||||
|
.createBitstream(context, iiifItem, input)
|
||||||
|
.withName("Bitstream2.jpg")
|
||||||
|
.withMimeType("image/jpeg")
|
||||||
|
.withIIIFCanvasWidth(100)
|
||||||
|
.withIIIFCanvasHeight(100)
|
||||||
|
.build();
|
||||||
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
|
String id = col1.getID().toString();
|
||||||
|
execCanvasScriptForceOption(id, "COLLECTION");
|
||||||
|
|
||||||
// The existing metadata should be updated
|
// The existing metadata should be updated
|
||||||
assertTrue(bitstream.getMetadata().stream()
|
assertTrue(bitstream.getMetadata().stream()
|
||||||
.filter(m -> m.getMetadataField().toString('.').contentEquals(METADATA_IIIF_HEIGHT))
|
.filter(m -> m.getMetadataField().toString('.').contentEquals(METADATA_IIIF_HEIGHT))
|
||||||
@@ -306,7 +343,7 @@ public class CanvasDimensionsIT extends AbstractIntegrationTestWithDatabase {
|
|||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
String handle = iiifItem.getHandle();
|
String handle = iiifItem.getHandle();
|
||||||
execCanvasScript(handle);
|
execCanvasScriptHandle(handle);
|
||||||
// The existing canvas metadata should be unchanged
|
// The existing canvas metadata should be unchanged
|
||||||
assertTrue(bitstream.getMetadata().stream()
|
assertTrue(bitstream.getMetadata().stream()
|
||||||
.filter(m -> m.getMetadataField().toString('.').contentEquals(METADATA_IIIF_HEIGHT))
|
.filter(m -> m.getMetadataField().toString('.').contentEquals(METADATA_IIIF_HEIGHT))
|
||||||
@@ -367,9 +404,9 @@ public class CanvasDimensionsIT extends AbstractIntegrationTestWithDatabase {
|
|||||||
|
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
String handle = parentCommunity.getHandle();
|
String id = parentCommunity.getID().toString();
|
||||||
|
|
||||||
execCanvasScriptWithMaxRecs(handle);
|
execCanvasScriptWithMaxRecs(id, "COMMUNITY");
|
||||||
// check System.out for number of items processed.
|
// check System.out for number of items processed.
|
||||||
assertEquals("2 IIIF items were processed.\n", outContent.toString());
|
assertEquals("2 IIIF items were processed.\n", outContent.toString());
|
||||||
}
|
}
|
||||||
@@ -426,9 +463,9 @@ public class CanvasDimensionsIT extends AbstractIntegrationTestWithDatabase {
|
|||||||
|
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
String handle = parentCommunity.getHandle();
|
String id = parentCommunity.getID().toString();
|
||||||
|
|
||||||
execCanvasScriptWithSkipList(handle, col2.getHandle() + "," + col3.getHandle());
|
execCanvasScriptWithSkipList(id, "COMMUNITY", col2.getHandle() + "," + col3.getHandle());
|
||||||
// The test image is small so the canvas dimension should be doubled, e.g. height 200 -> height 400
|
// The test image is small so the canvas dimension should be doubled, e.g. height 200 -> height 400
|
||||||
assertTrue(bitstream.getMetadata().stream()
|
assertTrue(bitstream.getMetadata().stream()
|
||||||
.filter(m -> m.getMetadataField().toString('.').contentEquals(METADATA_IIIF_HEIGHT))
|
.filter(m -> m.getMetadataField().toString('.').contentEquals(METADATA_IIIF_HEIGHT))
|
||||||
@@ -489,9 +526,9 @@ public class CanvasDimensionsIT extends AbstractIntegrationTestWithDatabase {
|
|||||||
|
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
String handle = parentCommunity.getHandle();
|
String id = parentCommunity.getID().toString();
|
||||||
|
|
||||||
execCanvasScriptWithSkipList(handle, col2.getHandle());
|
execCanvasScriptWithSkipList(id, "COMMUNITY", col2.getHandle());
|
||||||
// The test image is small so the canvas dimension should be doubled, e.g. height 200 -> height 400
|
// The test image is small so the canvas dimension should be doubled, e.g. height 200 -> height 400
|
||||||
assertTrue(bitstream.getMetadata().stream()
|
assertTrue(bitstream.getMetadata().stream()
|
||||||
.filter(m -> m.getMetadataField().toString('.').contentEquals(METADATA_IIIF_HEIGHT))
|
.filter(m -> m.getMetadataField().toString('.').contentEquals(METADATA_IIIF_HEIGHT))
|
||||||
@@ -509,21 +546,26 @@ public class CanvasDimensionsIT extends AbstractIntegrationTestWithDatabase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void execCanvasScript(String handle) throws Exception {
|
private void execCanvasScriptHandle(String handle) throws Exception {
|
||||||
runDSpaceScript("canvas-dimensions", "-e", "admin@email.com", "-i", handle);
|
runDSpaceScript("iiif-canvas-dimensions", "-e", "admin@email.com", "-i", handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void execCanvasScriptForceOption(String handle) throws Exception {
|
private void execCanvasScript(String id, String type) throws Exception {
|
||||||
runDSpaceScript("canvas-dimensions", "-e", "admin@email.com", "-i", handle, "-f");
|
runDSpaceScript("iiif-canvas-dimensions", "-e", "admin@email.com", "-i", id, "-t", type);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void execCanvasScriptWithMaxRecs(String handle) throws Exception {
|
private void execCanvasScriptForceOption(String id, String type) throws Exception {
|
||||||
|
runDSpaceScript("iiif-canvas-dimensions", "-e", "admin@email.com", "-i", id, "-f", "-t", type);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void execCanvasScriptWithMaxRecs(String id, String type) throws Exception {
|
||||||
// maximum 2
|
// maximum 2
|
||||||
runDSpaceScript("canvas-dimensions", "-e", "admin@email.com", "-i", handle, "-m", "2", "-f", "-q");
|
runDSpaceScript("iiif-canvas-dimensions", "-e", "admin@email.com", "-i",
|
||||||
|
id, "-t", type, "-m", "2", "-f", "-q");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void execCanvasScriptWithSkipList(String handle, String skip) throws Exception {
|
private void execCanvasScriptWithSkipList(String id, String type, String skip) throws Exception {
|
||||||
runDSpaceScript("canvas-dimensions", "-e", "admin@email.com", "-i", handle, "-s", skip, "-f");
|
runDSpaceScript("iiif-canvas-dimensions", "-e", "admin@email.com", "-i", id, "-t", type, "-s", skip, "-f");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -367,10 +367,10 @@
|
|||||||
</step>
|
</step>
|
||||||
</command>
|
</command>
|
||||||
<command>
|
<command>
|
||||||
<name>canvas-dimensions</name>
|
<name>iiif-canvas-dimensions</name>
|
||||||
<description>Add canvas width and height metadata for IIIF enabled items.</description>
|
<description>Automatically add the IIIF canvas width/height metadata to Bitstreams of IIIF enabled Items.</description>
|
||||||
<step>
|
<step>
|
||||||
<class>org.dspace.app.canvasdimension.CanvasDimensionCLI</class>
|
<class>org.dspace.iiif.canvasdimension.CanvasDimensionCLI</class>
|
||||||
</step>
|
</step>
|
||||||
</command>
|
</command>
|
||||||
</commands>
|
</commands>
|
||||||
|
@@ -3,8 +3,8 @@
|
|||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"
|
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"
|
||||||
default-lazy-init="true">
|
default-lazy-init="true">
|
||||||
|
|
||||||
<bean id="iiifCanvasDimensionServiceFactory" class="org.dspace.app.canvasdimension.factory.IIIFCanvasDimensionServiceFactoryImpl"/>
|
<bean id="iiifCanvasDimensionServiceFactory" class="org.dspace.iiif.canvasdimension.factory.IIIFCanvasDimensionServiceFactoryImpl"/>
|
||||||
<bean class="org.dspace.app.canvasdimension.IIIFCanvasDimensionServiceImpl" scope="prototype"/>
|
<bean class="org.dspace.iiif.canvasdimension.IIIFCanvasDimensionServiceImpl" scope="prototype"/>
|
||||||
<bean class="org.dspace.app.canvasdimension.IIIFApiQueryServiceImpl" scope="prototype"/>
|
<bean class="org.dspace.iiif.canvasdimension.IIIFApiQueryServiceImpl" scope="prototype"/>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
Reference in New Issue
Block a user