diff --git a/src/main/java/edu/tamu/iiif/config/AbstractIiifConfig.java b/src/main/java/edu/tamu/iiif/config/AbstractIiifConfig.java new file mode 100644 index 0000000..3af0eed --- /dev/null +++ b/src/main/java/edu/tamu/iiif/config/AbstractIiifConfig.java @@ -0,0 +1,62 @@ +package edu.tamu.iiif.config; + +import java.util.ArrayList; +import java.util.List; + +public abstract class AbstractIiifConfig { + + private List labelPrecedence = new ArrayList(); + + private List descriptionPrecedence = new ArrayList(); + + private List metadataPrefixes = new ArrayList(); + + private String url; + + private String identifier; + + public AbstractIiifConfig() { + + } + + public List getLabelPrecedence() { + return labelPrecedence; + } + + public void setLabelPrecedence(List labelPrecedence) { + this.labelPrecedence = labelPrecedence; + } + + public List getDescriptionPrecedence() { + return descriptionPrecedence; + } + + public void setDescriptionPrecedence(List descriptionPrecedence) { + this.descriptionPrecedence = descriptionPrecedence; + } + + public List getMetadataPrefixes() { + return metadataPrefixes; + } + + public void setMetadataPrefixes(List metadataPrefixes) { + this.metadataPrefixes = metadataPrefixes; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getIdentifier() { + return identifier; + } + + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + +} diff --git a/src/main/java/edu/tamu/iiif/config/DSpaceRdfIiifConfig.java b/src/main/java/edu/tamu/iiif/config/DSpaceRdfIiifConfig.java new file mode 100644 index 0000000..4c848b4 --- /dev/null +++ b/src/main/java/edu/tamu/iiif/config/DSpaceRdfIiifConfig.java @@ -0,0 +1,27 @@ +package edu.tamu.iiif.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +@Component +@ConfigurationProperties(prefix = "iiif.dspace") +public class DSpaceRdfIiifConfig extends AbstractIiifConfig { + + private String webapp; + + public DSpaceRdfIiifConfig() { + super(); + setUrl("http://localhost:8080"); + setIdentifier("dspace"); + setWebapp("xmlui"); + } + + public String getWebapp() { + return webapp; + } + + public void setWebapp(String webapp) { + this.webapp = webapp; + } + +} diff --git a/src/main/java/edu/tamu/iiif/config/FedoraPcdmIiifConfig.java b/src/main/java/edu/tamu/iiif/config/FedoraPcdmIiifConfig.java new file mode 100644 index 0000000..d3b3c2d --- /dev/null +++ b/src/main/java/edu/tamu/iiif/config/FedoraPcdmIiifConfig.java @@ -0,0 +1,16 @@ +package edu.tamu.iiif.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +@Component +@ConfigurationProperties(prefix = "iiif.fedora") +public class FedoraPcdmIiifConfig extends AbstractIiifConfig { + + public FedoraPcdmIiifConfig() { + super(); + setUrl("http://localhost:9000/fcrepo/rest"); + setIdentifier("fedora"); + } + +} diff --git a/src/main/java/edu/tamu/iiif/constants/Constants.java b/src/main/java/edu/tamu/iiif/constants/Constants.java index 3474bf4..f55c1af 100644 --- a/src/main/java/edu/tamu/iiif/constants/Constants.java +++ b/src/main/java/edu/tamu/iiif/constants/Constants.java @@ -3,8 +3,8 @@ public class Constants { // Repository Identifiers - public final static String DSPACE_RDF_IDENTIFIER = "${iiif.dspace.identifier.dspace-rdf}"; - public final static String FEDORA_PCDM_IDENTIFIER = "${iiif.fedora.identifier.fedora-pcdm}"; + public final static String DSPACE_RDF_IDENTIFIER = "${iiif.dspace.identifier}"; + public final static String FEDORA_PCDM_IDENTIFIER = "${iiif.fedora.identifier}"; // Repository Conditions public final static String DSPACE_RDF_CONDITION = "'${spring.profiles.include}'.contains('" + DSPACE_RDF_IDENTIFIER + "')"; @@ -56,6 +56,7 @@ public class Constants { public final static String DUBLIN_CORE_TITLE_PREDICATE = DUBLIN_CORE_PREFIX + "title"; public final static String DUBLIN_CORE_IDENTIFIER_PREDICATE = DUBLIN_CORE_PREFIX + "identifier"; public final static String DUBLIN_CORE_DESCRIPTION_PREDICATE = DUBLIN_CORE_PREFIX + "description"; + public final static String DUBLIN_CORE_DESCRIPTION_ABSTRACT_PREDICATE = DUBLIN_CORE_PREFIX + "description.abstract"; // Dublin Core Terms public final static String DUBLIN_CORE_TERMS_PREFIX = "http://purl.org/dc/terms/"; diff --git a/src/main/java/edu/tamu/iiif/model/rdf/RdfResource.java b/src/main/java/edu/tamu/iiif/model/rdf/RdfResource.java index 26fbd8e..98f2fa6 100644 --- a/src/main/java/edu/tamu/iiif/model/rdf/RdfResource.java +++ b/src/main/java/edu/tamu/iiif/model/rdf/RdfResource.java @@ -65,10 +65,6 @@ public Statement getStatementOfPropertyWithId(String id) { return resource.getProperty(getProperty(id)); } - public StmtIterator getStatementsOfPropertyWithId(String id) { - return resource.listProperties(getProperty(id)); - } - public NodeIterator getAllNodesOfPropertyWithId(String id) { return model.listObjectsOfProperty(getProperty(id)); } @@ -81,8 +77,8 @@ public ResIterator listResourcesWithPropertyWithId(String id) { return model.listResourcesWithProperty(getProperty(id)); } - public boolean containsStatement(String propertyId, String value) { - StmtIterator stmtItr = getStatementsOfPropertyWithId(propertyId); + public boolean containsStatement(String uri, String value) { + StmtIterator stmtItr = resource.listProperties(getProperty(uri)); while (stmtItr.hasNext()) { Statement stmnt = stmtItr.next(); if (stmnt.getResource().toString().equals(value)) { diff --git a/src/main/java/edu/tamu/iiif/service/AbstractManifestService.java b/src/main/java/edu/tamu/iiif/service/AbstractManifestService.java index ab12bea..7fb2b9d 100644 --- a/src/main/java/edu/tamu/iiif/service/AbstractManifestService.java +++ b/src/main/java/edu/tamu/iiif/service/AbstractManifestService.java @@ -1,10 +1,9 @@ package edu.tamu.iiif.service; -import static edu.tamu.iiif.constants.Constants.DUBLIN_CORE_PREFIX; -import static edu.tamu.iiif.constants.Constants.DUBLIN_CORE_TERMS_PREFIX; import static edu.tamu.iiif.constants.Constants.IIIF_IMAGE_API_CONTEXT; import static edu.tamu.iiif.constants.Constants.IIIF_IMAGE_API_LEVEL_ZERO_PROFILE; import static edu.tamu.iiif.utility.RdfModelUtility.createRdfModel; +import static edu.tamu.iiif.utility.RdfModelUtility.getObject; import static edu.tamu.iiif.utility.StringUtility.encode; import static edu.tamu.iiif.utility.StringUtility.encodeSpaces; import static edu.tamu.iiif.utility.StringUtility.joinPath; @@ -304,10 +303,34 @@ private String getResourceId(String url) throws InvalidUrlException { return redisResourceRepo.getOrCreate(url).getId(); } + protected Optional getDescription(RdfResource rdfResource) { + Optional description = Optional.empty(); + for (String descriptionPredicate : getDescriptionPrecedence()) { + description = getObject(rdfResource, descriptionPredicate); + if (description.isPresent()) { + return Optional.of(new PropertyValueSimpleImpl(description.get())); + } + } + return Optional.empty(); + } + + protected PropertyValueSimpleImpl getLabel(RdfResource rdfResource) { + Optional title = Optional.empty(); + for (String labelPredicate : getLabelPrecedence()) { + title = getObject(rdfResource, labelPredicate); + if (title.isPresent()) { + return new PropertyValueSimpleImpl(title.get()); + } + } + String id = rdfResource.getResource().getURI(); + return new PropertyValueSimpleImpl(getRepositoryContextIdentifier(id)); + } + protected List getMetadata(RdfResource rdfResource) { List metadata = new ArrayList(); - metadata.addAll(getMetadata(rdfResource, DUBLIN_CORE_PREFIX)); - metadata.addAll(getMetadata(rdfResource, DUBLIN_CORE_TERMS_PREFIX)); + for (String metadataPrefix : getMetadataPrefixes()) { + metadata.addAll(getMetadata(rdfResource, metadataPrefix)); + } return metadata; } @@ -331,6 +354,12 @@ protected List getMetadata(RdfResource rdfResource) { protected abstract String getRepositoryPath(String url); + protected abstract List getLabelPrecedence(); + + protected abstract List getDescriptionPrecedence(); + + protected abstract List getMetadataPrefixes(); + private Service getService(RdfResource rdfResource, String name) throws InvalidUrlException { Service service = new ServiceImpl(getImageUri(rdfResource.getResource().getURI())); service.setLabel(new PropertyValueSimpleImpl(name)); diff --git a/src/main/java/edu/tamu/iiif/service/dspace/rdf/AbstractDSpaceRdfManifestService.java b/src/main/java/edu/tamu/iiif/service/dspace/rdf/AbstractDSpaceRdfManifestService.java index bca7e96..43050df 100644 --- a/src/main/java/edu/tamu/iiif/service/dspace/rdf/AbstractDSpaceRdfManifestService.java +++ b/src/main/java/edu/tamu/iiif/service/dspace/rdf/AbstractDSpaceRdfManifestService.java @@ -8,12 +8,8 @@ import static edu.tamu.iiif.constants.Constants.DSPACE_IS_PART_OF_REPOSITORY_PREDICATE; import static edu.tamu.iiif.constants.Constants.DSPACE_IS_SUB_COMMUNITY_OF_PREDICATE; import static edu.tamu.iiif.constants.Constants.DSPACE_RDF_CONDITION; -import static edu.tamu.iiif.constants.Constants.DUBLIN_CORE_TERMS_ABSTRACT; -import static edu.tamu.iiif.constants.Constants.DUBLIN_CORE_TERMS_DESCRIPTION; -import static edu.tamu.iiif.constants.Constants.DUBLIN_CORE_TERMS_TITLE; import static edu.tamu.iiif.constants.Constants.PRESENTATION_IDENTIFIER; import static edu.tamu.iiif.constants.Constants.SEQUENCE_IDENTIFIER; -import static edu.tamu.iiif.utility.RdfModelUtility.getIdByPredicate; import static edu.tamu.iiif.utility.RdfModelUtility.getObject; import static edu.tamu.iiif.utility.StringUtility.encodeSpaces; import static edu.tamu.iiif.utility.StringUtility.joinPath; @@ -29,7 +25,7 @@ import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.NodeIterator; -import org.springframework.beans.factory.annotation.Value; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import de.digitalcollections.iiif.presentation.model.api.v2.Canvas; @@ -39,6 +35,7 @@ import de.digitalcollections.iiif.presentation.model.impl.v2.CanvasImpl; import de.digitalcollections.iiif.presentation.model.impl.v2.PropertyValueSimpleImpl; import de.digitalcollections.iiif.presentation.model.impl.v2.SequenceImpl; +import edu.tamu.iiif.config.DSpaceRdfIiifConfig; import edu.tamu.iiif.controller.ManifestRequest; import edu.tamu.iiif.exception.InvalidUrlException; import edu.tamu.iiif.model.rdf.RdfCanvas; @@ -49,14 +46,8 @@ @ConditionalOnExpression(DSPACE_RDF_CONDITION) public abstract class AbstractDSpaceRdfManifestService extends AbstractManifestService { - @Value("${iiif.dspace.url}") - protected String dspaceUrl; - - @Value("${iiif.dspace.webapp}") - protected String dspaceWebapp; - - @Value("${iiif.dspace.identifier.dspace-rdf}") - protected String dspaceRdfIdentifier; + @Autowired + protected DSpaceRdfIiifConfig config; protected Sequence generateSequence(ManifestRequest request, RdfResource rdfResource) throws IOException, URISyntaxException { String uri = rdfResource.getResource().getURI(); @@ -72,50 +63,26 @@ protected Canvas generateCanvas(ManifestRequest request, RdfResource rdfResource String uri = rdfResource.getResource().getURI(); PropertyValueSimpleImpl label = new PropertyValueSimpleImpl(getBitstreamPath(uri)); String parameterizedUri = RdfModelUtility.getParameterizedId(uri, request); - RdfCanvas rdfCanvas = getDSpaceRdfCanvas(request, rdfResource); - Canvas canvas = new CanvasImpl(getDSpaceIiifCanvasUri(getHandlePath(parameterizedUri)), label, rdfCanvas.getHeight(), rdfCanvas.getWidth()); - canvas.setImages(rdfCanvas.getImages()); - return canvas; } - protected PropertyValueSimpleImpl getTitle(RdfResource rdfResource) { - Optional title = getObject(rdfResource, DUBLIN_CORE_TERMS_TITLE); - if (!title.isPresent()) { - String id = rdfResource.getResource().getURI(); - title = Optional.of(getRepositoryContextIdentifier(id)); - } - return new PropertyValueSimpleImpl(title.get()); - } - - protected PropertyValueSimpleImpl getDescription(RdfResource rdfResource) { - Optional description = getObject(rdfResource, DUBLIN_CORE_TERMS_ABSTRACT); - if (!description.isPresent()) { - description = getObject(rdfResource, DUBLIN_CORE_TERMS_DESCRIPTION); - } - if (!description.isPresent()) { - description = Optional.of("No description available!"); - } - return new PropertyValueSimpleImpl(description.get()); - } - protected boolean isTopLevelCommunity(Model model) { - return getIdByPredicate(model, DSPACE_IS_PART_OF_REPOSITORY_PREDICATE).isPresent(); + return getObject(model, DSPACE_IS_PART_OF_REPOSITORY_PREDICATE).isPresent(); } protected boolean isSubcommunity(Model model) { - return getIdByPredicate(model, DSPACE_IS_SUB_COMMUNITY_OF_PREDICATE).isPresent(); + return getObject(model, DSPACE_IS_SUB_COMMUNITY_OF_PREDICATE).isPresent(); } protected boolean isCollection(Model model) { - return getIdByPredicate(model, DSPACE_IS_PART_OF_COMMUNITY_PREDICATE).isPresent(); + return getObject(model, DSPACE_IS_PART_OF_COMMUNITY_PREDICATE).isPresent(); } protected boolean isItem(Model model) { - return getIdByPredicate(model, DSPACE_IS_PART_OF_COLLECTION_PREDICATE).isPresent(); + return getObject(model, DSPACE_IS_PART_OF_COLLECTION_PREDICATE).isPresent(); } protected URI getDSpaceIiifCollectionUri(String handle) throws URISyntaxException { @@ -175,27 +142,42 @@ protected String getMatcherHandle(String uri) { @Override protected String getIiifServiceUrl() { - return iiifServiceUrl + "/" + dspaceRdfIdentifier; + return iiifServiceUrl + "/" + config.getIdentifier(); } @Override protected String getRepositoryContextIdentifier(String url) { - return dspaceRdfIdentifier + ":" + getRepositoryPath(url); + return config.getIdentifier() + ":" + getRepositoryPath(url); } @Override protected String getRepositoryPath(String url) { - return url.substring(dspaceUrl.length() + 1); + return url.substring(config.getUrl().length() + 1); } @Override protected String getRepositoryType() { - return dspaceRdfIdentifier; + return config.getIdentifier(); } @Override protected String getRdfUrl(String handle) { - return joinPath(dspaceUrl, "rdf", "handle", handle); + return joinPath(config.getUrl(), "rdf", "handle", handle); + } + + @Override + protected List getLabelPrecedence() { + return config.getLabelPrecedence(); + } + + @Override + protected List getDescriptionPrecedence() { + return config.getDescriptionPrecedence(); + } + + @Override + protected List getMetadataPrefixes() { + return config.getMetadataPrefixes(); } private URI getDSpaceIiifUri(String handle, String type) throws URISyntaxException { diff --git a/src/main/java/edu/tamu/iiif/service/dspace/rdf/DSpaceRdfCanvasManifestService.java b/src/main/java/edu/tamu/iiif/service/dspace/rdf/DSpaceRdfCanvasManifestService.java index 4b5bae1..b7be084 100644 --- a/src/main/java/edu/tamu/iiif/service/dspace/rdf/DSpaceRdfCanvasManifestService.java +++ b/src/main/java/edu/tamu/iiif/service/dspace/rdf/DSpaceRdfCanvasManifestService.java @@ -20,7 +20,7 @@ public String generateManifest(ManifestRequest request) throws IOException, URIS String handle = extractHandle(context); RdfResource rdfResource = getRdfResource(handle); String url = rdfResource.getResource().getURI(); - Canvas canvas = generateCanvas(request, new RdfResource(rdfResource, url.replace("rdf/handle", dspaceWebapp != null && dspaceWebapp.length() > 0 ? dspaceWebapp + "/bitstream" : "bitstream").replaceAll(handle, context))); + Canvas canvas = generateCanvas(request, new RdfResource(rdfResource, url.replace("rdf/handle", config.getWebapp() != null && config.getWebapp().length() > 0 ? config.getWebapp() + "/bitstream" : "bitstream").replaceAll(handle, context))); return mapper.writeValueAsString(canvas); } diff --git a/src/main/java/edu/tamu/iiif/service/dspace/rdf/DSpaceRdfCollectionManifestService.java b/src/main/java/edu/tamu/iiif/service/dspace/rdf/DSpaceRdfCollectionManifestService.java index d65eb4c..625eb73 100644 --- a/src/main/java/edu/tamu/iiif/service/dspace/rdf/DSpaceRdfCollectionManifestService.java +++ b/src/main/java/edu/tamu/iiif/service/dspace/rdf/DSpaceRdfCollectionManifestService.java @@ -11,6 +11,7 @@ import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import org.apache.jena.rdf.model.NodeIterator; import org.springframework.stereotype.Service; @@ -46,20 +47,21 @@ private Collection generateCollection(ManifestRequest request) throws URISyntaxE URI id = buildId(parameterizedContext); - PropertyValueSimpleImpl label = getTitle(rdfResource); - List metadata = getMetadata(rdfResource); - Collection collection = new CollectionImpl(id, label, metadata); + Collection collection = new CollectionImpl(id, getLabel(rdfResource), metadata); + + collection.setManifests(getResourceManifests(request, rdfResource)); List collections = getSubcollections(request, rdfResource); if (!collections.isEmpty()) { collection.setSubCollections(collections); } - collection.setManifests(getResourceManifests(request, rdfResource)); - - collection.setDescription(getDescription(rdfResource)); + Optional description = getDescription(rdfResource); + if (description.isPresent()) { + collection.setDescription(description.get()); + } collection.setLogo(getLogo(rdfResource)); @@ -68,13 +70,32 @@ private Collection generateCollection(ManifestRequest request) throws URISyntaxE return collection; } - private List getSubcollections(ManifestRequest request, RdfResource rdfResource) throws URISyntaxException, NotFoundException { - List subcollections = getSubcommunities(rdfResource); + private List getResourceManifests(ManifestRequest request, RdfResource rdfResource) throws URISyntaxException, NotFoundException { + List manifests = new ArrayList(); + if (isItem(rdfResource.getModel())) { + NodeIterator hasBitstreamIterator = rdfResource.getAllNodesOfPropertyWithId(DSPACE_HAS_BITSTREAM_PREDICATE); + while (hasBitstreamIterator.hasNext()) { + String hasBitstreamHandlePath = getHandlePath(hasBitstreamIterator.next().toString()); + String parameterizedHasBitstreamHandlePath = RdfModelUtility.getParameterizedId(hasBitstreamHandlePath, request); + RdfResource hasBitstreamRdfResource = getRdfResource(hasBitstreamHandlePath); + manifests.add(new ManifestReferenceImpl(getDSpaceIiifPresentationUri(parameterizedHasBitstreamHandlePath), getLabel(hasBitstreamRdfResource))); + } + } else { + NodeIterator hasItemIterator = rdfResource.getAllNodesOfPropertyWithId(DSPACE_HAS_ITEM_PREDICATE); + while (hasItemIterator.hasNext()) { + String hasItemHandle = getHandle(hasItemIterator.next().toString()); + String parameterizedHasItemHandle = RdfModelUtility.getParameterizedId(hasItemHandle, request); + RdfResource hasItemRdfResource = getRdfResource(hasItemHandle); + manifests.add(new ManifestReferenceImpl(getDSpaceIiifPresentationUri(parameterizedHasItemHandle), getLabel(hasItemRdfResource))); + } + } + return manifests; + } + private List getSubcollections(ManifestRequest request, RdfResource rdfResource) throws URISyntaxException, NotFoundException { + List collectionsToElide = new ArrayList(); + List subcollections = getSubcommunities(rdfResource, collectionsToElide); List collections = getCollections(rdfResource); - - List collectionsToElide = getCollectionsToElide(rdfResource); - collections.forEach(c -> { boolean include = true; for (CollectionReference ce : collectionsToElide) { @@ -87,65 +108,32 @@ private List getSubcollections(ManifestRequest request, Rdf subcollections.add(c); } }); - return subcollections; } - private List getSubcommunities(RdfResource rdfResource) throws URISyntaxException { + private List getSubcommunities(RdfResource rdfResource, List collectionsToElide) throws URISyntaxException, NotFoundException { List subcommunities = new ArrayList(); NodeIterator subcommunityIterator = rdfResource.getAllNodesOfPropertyWithId(DSPACE_HAS_SUB_COMMUNITY_PREDICATE); while (subcommunityIterator.hasNext()) { - String uri = subcommunityIterator.next().toString(); - String handle = getHandle(uri); - subcommunities.add(new CollectionReferenceImpl(getDSpaceIiifCollectionUri(handle), new PropertyValueSimpleImpl(handle))); + String subcommunityHandle = getHandle(subcommunityIterator.next().toString()); + RdfResource subcommunityRdfResource = getRdfResource(subcommunityHandle); + collectionsToElide.addAll(getCollections(subcommunityRdfResource)); + subcommunities.add(new CollectionReferenceImpl(getDSpaceIiifCollectionUri(subcommunityHandle), getLabel(subcommunityRdfResource))); } return subcommunities; } - private List getCollections(RdfResource rdfResource) throws URISyntaxException { + private List getCollections(RdfResource rdfResource) throws URISyntaxException, NotFoundException { List collections = new ArrayList(); NodeIterator collectionIterator = rdfResource.getAllNodesOfPropertyWithId(DSPACE_HAS_COLLECTION_PREDICATE); while (collectionIterator.hasNext()) { - String uri = collectionIterator.next().toString(); - String handle = getHandle(uri); - collections.add(new CollectionReferenceImpl(getDSpaceIiifCollectionUri(handle), new PropertyValueSimpleImpl(handle))); + String collectionHandle = getHandle(collectionIterator.next().toString()); + RdfResource collectionRdfResource = getRdfResource(collectionHandle); + collections.add(new CollectionReferenceImpl(getDSpaceIiifCollectionUri(collectionHandle), getLabel(collectionRdfResource))); } return collections; } - private List getCollectionsToElide(RdfResource rdfResource) throws URISyntaxException, NotFoundException { - List collectionsToElide = new ArrayList(); - for (CollectionReference subcommunity : getSubcommunities(rdfResource)) { - String handle = subcommunity.getLabel().getFirstValue(); - RdfResource subcommunityRdfResource = getRdfResource(handle); - collectionsToElide.addAll(getCollections(subcommunityRdfResource)); - } - return collectionsToElide; - } - - private List getResourceManifests(ManifestRequest request, RdfResource rdfResource) throws URISyntaxException { - List manifests = new ArrayList(); - if (isItem(rdfResource.getModel())) { - String uri = rdfResource.getResource().getURI(); - String handle = getHandle(uri); - NodeIterator bitstreamIterator = rdfResource.getAllNodesOfPropertyWithId(DSPACE_HAS_BITSTREAM_PREDICATE); - while (bitstreamIterator.hasNext()) { - String bitstreamHandlePath = getHandlePath(bitstreamIterator.next().toString()); - String parameterizedBitstreamHandlePath = RdfModelUtility.getParameterizedId(bitstreamHandlePath, request); - manifests.add(new ManifestReferenceImpl(getDSpaceIiifPresentationUri(parameterizedBitstreamHandlePath), new PropertyValueSimpleImpl(handle))); - } - } else { - NodeIterator collectionIterator = rdfResource.getAllNodesOfPropertyWithId(DSPACE_HAS_ITEM_PREDICATE); - while (collectionIterator.hasNext()) { - String uri = collectionIterator.next().toString(); - String handle = getHandle(uri); - String parameterizedHandle = RdfModelUtility.getParameterizedId(handle, request); - manifests.add(new ManifestReferenceImpl(getDSpaceIiifPresentationUri(parameterizedHandle), new PropertyValueSimpleImpl(handle))); - } - } - return manifests; - } - @Override protected ManifestType getManifestType() { return COLLECTION; diff --git a/src/main/java/edu/tamu/iiif/service/dspace/rdf/DSpaceRdfImageManifestService.java b/src/main/java/edu/tamu/iiif/service/dspace/rdf/DSpaceRdfImageManifestService.java index 4e8d04f..8a23a58 100644 --- a/src/main/java/edu/tamu/iiif/service/dspace/rdf/DSpaceRdfImageManifestService.java +++ b/src/main/java/edu/tamu/iiif/service/dspace/rdf/DSpaceRdfImageManifestService.java @@ -17,7 +17,7 @@ public class DSpaceRdfImageManifestService extends AbstractDSpaceRdfManifestServ public String generateManifest(ManifestRequest request) throws IOException, URISyntaxException { String context = request.getContext(); - String dspacePath = dspaceWebapp != null && dspaceWebapp.length() > 0 ? joinPath(dspaceUrl, dspaceWebapp, "bitstream", context) : joinPath(dspaceUrl, "bitstream", context); + String dspacePath = config.getWebapp() != null && config.getWebapp().length() > 0 ? joinPath(config.getUrl(), config.getWebapp(), "bitstream", context) : joinPath(config.getUrl(), "bitstream", context); URI uri = getImageUri(dspacePath); return fetchImageInfo(uri.toString()); } diff --git a/src/main/java/edu/tamu/iiif/service/dspace/rdf/DSpaceRdfPresentationManifestService.java b/src/main/java/edu/tamu/iiif/service/dspace/rdf/DSpaceRdfPresentationManifestService.java index b5bfc6a..5c9aff0 100644 --- a/src/main/java/edu/tamu/iiif/service/dspace/rdf/DSpaceRdfPresentationManifestService.java +++ b/src/main/java/edu/tamu/iiif/service/dspace/rdf/DSpaceRdfPresentationManifestService.java @@ -16,6 +16,7 @@ import de.digitalcollections.iiif.presentation.model.api.v2.Canvas; import de.digitalcollections.iiif.presentation.model.api.v2.Manifest; +import de.digitalcollections.iiif.presentation.model.api.v2.Metadata; import de.digitalcollections.iiif.presentation.model.api.v2.Sequence; import de.digitalcollections.iiif.presentation.model.api.v2.Thumbnail; import de.digitalcollections.iiif.presentation.model.impl.v2.ManifestImpl; @@ -38,11 +39,7 @@ public String generateManifest(ManifestRequest request) throws IOException, URIS URI id = buildId(parameterizedContext); - PropertyValueSimpleImpl label = getTitle(rdfResource); - - Manifest manifest = new ManifestImpl(id, label); - - manifest.setDescription(getDescription(rdfResource)); + Manifest manifest = new ManifestImpl(id, getLabel(rdfResource)); List sequences = getSequences(request, rdfResource); @@ -50,7 +47,15 @@ public String generateManifest(ManifestRequest request) throws IOException, URIS manifest.setLogo(getLogo(rdfResource)); - manifest.setMetadata(getMetadata(rdfResource)); + List metadata = getMetadata(rdfResource); + if (!metadata.isEmpty()) { + manifest.setMetadata(metadata); + } + + Optional description = getDescription(rdfResource); + if (description.isPresent()) { + manifest.setDescription(description.get()); + } Optional thumbnail = getThumbnail(sequences); if (thumbnail.isPresent()) { @@ -74,6 +79,8 @@ private List getSequences(ManifestRequest request, RdfResource rdfReso if (broadSequences.size() > 0) { Sequence sequence = broadSequences.get(0); + sequence.setLabel(getLabel(rdfResource)); + List canvases = sequence.getCanvases(); broadSequences.remove(0); diff --git a/src/main/java/edu/tamu/iiif/service/dspace/rdf/DSpaceRdfSequenceManifestService.java b/src/main/java/edu/tamu/iiif/service/dspace/rdf/DSpaceRdfSequenceManifestService.java index 8d4652e..a5f29ad 100644 --- a/src/main/java/edu/tamu/iiif/service/dspace/rdf/DSpaceRdfSequenceManifestService.java +++ b/src/main/java/edu/tamu/iiif/service/dspace/rdf/DSpaceRdfSequenceManifestService.java @@ -19,7 +19,6 @@ public String generateManifest(ManifestRequest request) throws IOException, URIS String context = request.getContext(); RdfResource rdfResource = getRdfResource(context); Sequence sequence = generateSequence(request, rdfResource); - sequence.setDescription(getDescription(rdfResource)); return mapper.writeValueAsString(sequence); } diff --git a/src/main/java/edu/tamu/iiif/service/fedora/pcdm/AbstractFedoraPcdmManifestService.java b/src/main/java/edu/tamu/iiif/service/fedora/pcdm/AbstractFedoraPcdmManifestService.java index 9ff0edd..5b1b6ee 100644 --- a/src/main/java/edu/tamu/iiif/service/fedora/pcdm/AbstractFedoraPcdmManifestService.java +++ b/src/main/java/edu/tamu/iiif/service/fedora/pcdm/AbstractFedoraPcdmManifestService.java @@ -2,9 +2,6 @@ import static edu.tamu.iiif.constants.Constants.CANVAS_IDENTIFIER; import static edu.tamu.iiif.constants.Constants.COLLECTION_IDENTIFIER; -import static edu.tamu.iiif.constants.Constants.DUBLIN_CORE_DESCRIPTION_PREDICATE; -import static edu.tamu.iiif.constants.Constants.DUBLIN_CORE_IDENTIFIER_PREDICATE; -import static edu.tamu.iiif.constants.Constants.DUBLIN_CORE_TITLE_PREDICATE; import static edu.tamu.iiif.constants.Constants.FEDORA_FCR_METADATA; import static edu.tamu.iiif.constants.Constants.FEDORA_PCDM_CONDITION; import static edu.tamu.iiif.constants.Constants.IANA_FIRST_PREDICATE; @@ -18,10 +15,8 @@ import static edu.tamu.iiif.constants.Constants.PCDM_HAS_FILE_PREDICATE; import static edu.tamu.iiif.constants.Constants.PCDM_HAS_MEMBER_PREDICATE; import static edu.tamu.iiif.constants.Constants.PRESENTATION_IDENTIFIER; -import static edu.tamu.iiif.constants.Constants.RDFS_LABEL_PREDICATE; import static edu.tamu.iiif.constants.Constants.RDF_TYPE_PREDICATE; import static edu.tamu.iiif.constants.Constants.SEQUENCE_IDENTIFIER; -import static edu.tamu.iiif.utility.RdfModelUtility.getIdByPredicate; import static edu.tamu.iiif.utility.RdfModelUtility.getObject; import static edu.tamu.iiif.utility.StringUtility.joinPath; @@ -39,7 +34,7 @@ import org.apache.jena.rdf.model.ResIterator; import org.apache.jena.rdf.model.Resource; import org.apache.jena.rdf.model.Statement; -import org.springframework.beans.factory.annotation.Value; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import com.fasterxml.jackson.core.JsonProcessingException; @@ -47,10 +42,12 @@ import de.digitalcollections.iiif.presentation.model.api.v2.Canvas; import de.digitalcollections.iiif.presentation.model.api.v2.Image; import de.digitalcollections.iiif.presentation.model.api.v2.ImageResource; +import de.digitalcollections.iiif.presentation.model.api.v2.Metadata; import de.digitalcollections.iiif.presentation.model.api.v2.Sequence; import de.digitalcollections.iiif.presentation.model.impl.v2.CanvasImpl; import de.digitalcollections.iiif.presentation.model.impl.v2.PropertyValueSimpleImpl; import de.digitalcollections.iiif.presentation.model.impl.v2.SequenceImpl; +import edu.tamu.iiif.config.FedoraPcdmIiifConfig; import edu.tamu.iiif.controller.ManifestRequest; import edu.tamu.iiif.exception.NotFoundException; import edu.tamu.iiif.model.rdf.RdfCanvas; @@ -62,11 +59,8 @@ @ConditionalOnExpression(FEDORA_PCDM_CONDITION) public abstract class AbstractFedoraPcdmManifestService extends AbstractManifestService { - @Value("${iiif.fedora.url}") - protected String fedoraUrl; - - @Value("${iiif.fedora.identifier.fedora-pcdm}") - protected String fedoraPcdmIdentifier; + @Autowired + protected FedoraPcdmIiifConfig config; protected Sequence generateSequence(ManifestRequest request, RdfResource rdfResource) throws IOException, URISyntaxException { String parameterizedId = RdfModelUtility.getParameterizedId(rdfResource.getResource().getURI(), request); @@ -86,32 +80,13 @@ protected Canvas generateCanvas(ManifestRequest request, RdfResource rdfResource canvas.setImages(rdfCanvas.getImages()); - canvas.setMetadata(getMetadata(rdfResource)); + List metadata = getMetadata(rdfResource); - return canvas; - } - - protected PropertyValueSimpleImpl getLabel(RdfResource rdfResource) { - Optional title = getObject(rdfResource, RDFS_LABEL_PREDICATE); - if (!title.isPresent()) { - title = getObject(rdfResource, DUBLIN_CORE_TITLE_PREDICATE); - } - if (!title.isPresent()) { - title = getObject(rdfResource, DUBLIN_CORE_IDENTIFIER_PREDICATE); + if (!metadata.isEmpty()) { + canvas.setMetadata(metadata); } - if (!title.isPresent()) { - String id = rdfResource.getResource().getURI(); - title = Optional.of(getRepositoryContextIdentifier(id)); - } - return new PropertyValueSimpleImpl(title.get()); - } - protected PropertyValueSimpleImpl getDescription(RdfResource rdfResource) { - Optional description = getObject(rdfResource, DUBLIN_CORE_DESCRIPTION_PREDICATE); - if (!description.isPresent()) { - description = Optional.of("No description available!"); - } - return new PropertyValueSimpleImpl(description.get()); + return canvas; } protected URI getFedoraIiifCollectionUri(String url) throws URISyntaxException { @@ -180,41 +155,56 @@ protected String getMatcherHandle(String uri) { @Override protected String getIiifServiceUrl() { - return iiifServiceUrl + "/" + fedoraPcdmIdentifier; + return iiifServiceUrl + "/" + config.getIdentifier(); } @Override protected String getRepositoryContextIdentifier(String url) { - return fedoraPcdmIdentifier + ":" + getRepositoryPath(url); + return config.getIdentifier() + ":" + getRepositoryPath(url); } @Override protected String getRepositoryPath(String url) { - return url.substring(fedoraUrl.length() + 1); + return url.substring(config.getUrl().length() + 1); } @Override protected String getRepositoryType() { - return fedoraPcdmIdentifier; + return config.getIdentifier(); } @Override protected String getRdfUrl(String path) { - return joinPath(fedoraUrl, path); + return joinPath(config.getUrl(), path); + } + + @Override + protected List getLabelPrecedence() { + return config.getLabelPrecedence(); + } + + @Override + protected List getDescriptionPrecedence() { + return config.getDescriptionPrecedence(); + } + + @Override + protected List getMetadataPrefixes() { + return config.getMetadataPrefixes(); } // TODO: update to match getDSpaceIiifUrl private URI getFedoraIiifUri(String url, String type) throws URISyntaxException { - return URI.create(url.replace(fedoraUrl + "/", getIiifServiceUrl() + "/" + type + "/")); + return URI.create(url.replace(config.getUrl() + "/", getIiifServiceUrl() + "/" + type + "/")); } private List getCanvases(ManifestRequest request, RdfResource rdfResource) throws IOException, URISyntaxException { List canvases = new ArrayList(); - Optional firstId = getIdByPredicate(rdfResource.getModel(), IANA_FIRST_PREDICATE); + Optional firstId = getObject(rdfResource.getModel(), IANA_FIRST_PREDICATE); if (firstId.isPresent()) { - Optional lastId = getIdByPredicate(rdfResource.getModel(), IANA_LAST_PREDICATE); + Optional lastId = getObject(rdfResource.getModel(), IANA_LAST_PREDICATE); if (lastId.isPresent()) { Resource firstResource = rdfResource.getModel().getResource(firstId.get()); @@ -244,10 +234,10 @@ private void generateOrderedCanvases(ManifestRequest request, RdfOrderedResource Model model = getFedoraRdfModel(rdfOrderedSequence.getResource().getURI()); - Optional id = getIdByPredicate(model, ORE_PROXY_FOR_PREDICATE); + Optional id = getObject(model, ORE_PROXY_FOR_PREDICATE); if (!id.isPresent()) { - id = getIdByPredicate(model, ORE_PROXY_FOR_PREDICATE.replace("#", "/")); + id = getObject(model, ORE_PROXY_FOR_PREDICATE.replace("#", "/")); } if (id.isPresent()) { @@ -259,7 +249,7 @@ private void generateOrderedCanvases(ManifestRequest request, RdfOrderedResource canvases.add(canvas); } - Optional nextId = getIdByPredicate(model, IANA_NEXT_PREDICATE); + Optional nextId = getObject(model, IANA_NEXT_PREDICATE); if (nextId.isPresent()) { Resource resource = rdfOrderedSequence.getModel().getResource(nextId.get()); diff --git a/src/main/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmCollectionManifestService.java b/src/main/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmCollectionManifestService.java index 7c4cb7d..bda1888 100644 --- a/src/main/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmCollectionManifestService.java +++ b/src/main/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmCollectionManifestService.java @@ -7,7 +7,7 @@ import static edu.tamu.iiif.constants.Constants.PCDM_HAS_FILE_PREDICATE; import static edu.tamu.iiif.constants.Constants.PCDM_HAS_MEMBER_PREDICATE; import static edu.tamu.iiif.model.ManifestType.COLLECTION; -import static edu.tamu.iiif.utility.RdfModelUtility.getIdByPredicate; +import static edu.tamu.iiif.utility.RdfModelUtility.getObject; import java.io.IOException; import java.net.URI; @@ -55,7 +55,9 @@ private Collection generateCollection(ManifestRequest request) throws URISyntaxE URI id = buildId(parameterizedContext); - PropertyValueSimpleImpl label = getLabel(rdfResource); + List metadata = getMetadata(rdfResource); + + Collection collection = new CollectionImpl(id, getLabel(rdfResource), metadata); boolean isCollection = isCollection(rdfResource); @@ -72,17 +74,16 @@ private Collection generateCollection(ManifestRequest request) throws URISyntaxE rdfResource = new RdfResource(collectionObjectMemberModel, collectionObjectMemberId); } - List metadata = getMetadata(rdfResource); - - Collection collection = new CollectionImpl(id, label, metadata); + collection.setManifests(getResourceManifests(request, rdfResource, isCollection)); if (!collections.isEmpty()) { collection.setSubCollections(collections); } - collection.setManifests(getResourceManifests(request, rdfResource, isCollection)); - - collection.setDescription(getDescription(rdfResource)); + Optional description = getDescription(rdfResource); + if (description.isPresent()) { + collection.setDescription(description.get()); + } collection.setLogo(getLogo(rdfResource)); @@ -91,25 +92,8 @@ private Collection generateCollection(ManifestRequest request) throws URISyntaxE return collection; } - private List getSubcollections(RdfResource rdfResource) throws URISyntaxException, NotFoundException { - List subcollections = new ArrayList(); - // TODO: follow order proxy if iana available - NodeIterator nodes = rdfResource.getNodesOfPropertyWithId(PCDM_HAS_MEMBER_PREDICATE); - while (nodes.hasNext()) { - RDFNode node = nodes.next(); - String id = node.toString(); - Model member = getFedoraRdfModel(id); - if (isCollection(member)) { - PropertyValueSimpleImpl label = getLabel(new RdfResource(member, id)); - subcollections.add(new CollectionReferenceImpl(getFedoraIiifCollectionUri(id), label)); - } - } - return subcollections; - } - private List getResourceManifests(ManifestRequest request, RdfResource rdfResource, boolean isCollection) throws URISyntaxException, IOException { List manifests = new ArrayList(); - if (isCollection) { manifests.addAll(gatherResourceManifests(request, rdfResource)); } else { @@ -121,7 +105,6 @@ private List getResourceManifests(ManifestRequest request, Rd manifests.add(new ManifestReferenceImpl(getFedoraIiifPresentationUri(parameterizedId), label)); } } - if (manifests.isEmpty()) { ResIterator resources = rdfResource.listResourcesWithPropertyWithId(PCDM_HAS_FILE_PREDICATE); while (resources.hasNext()) { @@ -131,17 +114,16 @@ private List getResourceManifests(ManifestRequest request, Rd manifests.add(new ManifestReferenceImpl(getFedoraIiifPresentationUri(parameterizedId), label)); } } - return manifests; } private List gatherResourceManifests(ManifestRequest request, RdfResource rdfResource) throws URISyntaxException, IOException { List manifests = new ArrayList(); - Optional firstId = getIdByPredicate(rdfResource.getModel(), IANA_FIRST_PREDICATE); + Optional firstId = getObject(rdfResource.getModel(), IANA_FIRST_PREDICATE); if (firstId.isPresent()) { - Optional lastId = getIdByPredicate(rdfResource.getModel(), IANA_LAST_PREDICATE); + Optional lastId = getObject(rdfResource.getModel(), IANA_LAST_PREDICATE); if (lastId.isPresent()) { Resource firstResource = rdfResource.getModel().getResource(firstId.get()); @@ -156,10 +138,10 @@ private void gatherResourceManifests(ManifestRequest request, RdfOrderedResource Model model = getFedoraRdfModel(rdfOrderedResource.getResource().getURI()); - Optional id = getIdByPredicate(model, ORE_PROXY_FOR_PREDICATE); + Optional id = getObject(model, ORE_PROXY_FOR_PREDICATE); if (!id.isPresent()) { - id = getIdByPredicate(model, ORE_PROXY_FOR_PREDICATE.replace("#", "/")); + id = getObject(model, ORE_PROXY_FOR_PREDICATE.replace("#", "/")); } if (id.isPresent()) { @@ -169,7 +151,7 @@ private void gatherResourceManifests(ManifestRequest request, RdfOrderedResource PropertyValueSimpleImpl label = getLabel(rdfOrderedResource); manifests.add(new ManifestReferenceImpl(getFedoraIiifPresentationUri(parameterizedActualId), label)); - Optional nextId = getIdByPredicate(model, IANA_NEXT_PREDICATE); + Optional nextId = getObject(model, IANA_NEXT_PREDICATE); if (nextId.isPresent()) { Resource resource = rdfOrderedResource.getModel().getResource(nextId.get()); @@ -181,6 +163,22 @@ private void gatherResourceManifests(ManifestRequest request, RdfOrderedResource } + private List getSubcollections(RdfResource rdfResource) throws URISyntaxException, NotFoundException { + List subcollections = new ArrayList(); + // TODO: follow order proxy if iana available + NodeIterator nodes = rdfResource.getNodesOfPropertyWithId(PCDM_HAS_MEMBER_PREDICATE); + while (nodes.hasNext()) { + RDFNode node = nodes.next(); + String id = node.toString(); + Model member = getFedoraRdfModel(id); + if (isCollection(member)) { + PropertyValueSimpleImpl label = getLabel(new RdfResource(member, id)); + subcollections.add(new CollectionReferenceImpl(getFedoraIiifCollectionUri(id), label)); + } + } + return subcollections; + } + @Override protected ManifestType getManifestType() { return COLLECTION; diff --git a/src/main/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmImageManifestService.java b/src/main/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmImageManifestService.java index 8d2cde8..e6e31a2 100644 --- a/src/main/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmImageManifestService.java +++ b/src/main/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmImageManifestService.java @@ -17,7 +17,7 @@ public class FedoraPcdmImageManifestService extends AbstractFedoraPcdmManifestSe public String generateManifest(ManifestRequest request) throws IOException, URISyntaxException { String context = request.getContext(); - String fedoraPath = joinPath(fedoraUrl, context); + String fedoraPath = joinPath(config.getUrl(), context); URI uri = getImageUri(fedoraPath); return fetchImageInfo(uri.toString()); } diff --git a/src/main/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmPresentationManifestService.java b/src/main/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmPresentationManifestService.java index d95248a..9a91774 100644 --- a/src/main/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmPresentationManifestService.java +++ b/src/main/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmPresentationManifestService.java @@ -13,6 +13,7 @@ import org.springframework.stereotype.Service; import de.digitalcollections.iiif.presentation.model.api.v2.Manifest; +import de.digitalcollections.iiif.presentation.model.api.v2.Metadata; import de.digitalcollections.iiif.presentation.model.api.v2.Sequence; import de.digitalcollections.iiif.presentation.model.api.v2.Thumbnail; import de.digitalcollections.iiif.presentation.model.impl.v2.ManifestImpl; @@ -34,8 +35,6 @@ public String generateManifest(ManifestRequest request) throws IOException, URIS URI id = buildId(parameterizedContext); - PropertyValueSimpleImpl label = getLabel(rdfResource); - boolean isCollection = isCollection(rdfResource); if (isCollection) { @@ -46,11 +45,13 @@ public String generateManifest(ManifestRequest request) throws IOException, URIS rdfResource = new RdfResource(collectionObjectMemberModel, collectionObjectMemberId); } - Manifest manifest = new ManifestImpl(id, label); + Manifest manifest = new ManifestImpl(id, getLabel(rdfResource)); - manifest.setDescription(getDescription(rdfResource)); + List metadata = getMetadata(rdfResource); - manifest.setMetadata(getMetadata(rdfResource)); + if (!metadata.isEmpty()) { + manifest.setMetadata(metadata); + } List sequences = getSequences(request, rdfResource); @@ -58,6 +59,11 @@ public String generateManifest(ManifestRequest request) throws IOException, URIS manifest.setLogo(getLogo(rdfResource)); + Optional description = getDescription(rdfResource); + if (description.isPresent()) { + manifest.setDescription(description.get()); + } + Optional thumbnail = getThumbnail(sequences); if (thumbnail.isPresent()) { manifest.setThumbnail(thumbnail.get()); diff --git a/src/main/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmSequenceManifestService.java b/src/main/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmSequenceManifestService.java index b9de020..d447d17 100644 --- a/src/main/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmSequenceManifestService.java +++ b/src/main/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmSequenceManifestService.java @@ -19,7 +19,6 @@ public String generateManifest(ManifestRequest request) throws IOException, URIS String context = request.getContext(); RdfResource rdfResource = getRdfResource(context); Sequence sequence = generateSequence(request, rdfResource); - sequence.setDescription(getDescription(rdfResource)); return mapper.writeValueAsString(sequence); } diff --git a/src/main/java/edu/tamu/iiif/utility/RdfModelUtility.java b/src/main/java/edu/tamu/iiif/utility/RdfModelUtility.java index 9f6b711..6251655 100644 --- a/src/main/java/edu/tamu/iiif/utility/RdfModelUtility.java +++ b/src/main/java/edu/tamu/iiif/utility/RdfModelUtility.java @@ -8,8 +8,6 @@ import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.NodeIterator; -import org.apache.jena.rdf.model.RDFNode; -import org.apache.jena.rdf.model.Statement; import edu.tamu.iiif.controller.ManifestRequest; import edu.tamu.iiif.model.rdf.RdfResource; @@ -23,25 +21,17 @@ public static Model createRdfModel(String rdf) { return model; } - public static Optional getIdByPredicate(Model model, String predicate) { + public static Optional getObject(Model model, String uri) { Optional id = Optional.empty(); - NodeIterator firstNodeItr = model.listObjectsOfProperty(model.getProperty(predicate)); - while (firstNodeItr.hasNext()) { + NodeIterator firstNodeItr = model.listObjectsOfProperty(model.getProperty(uri)); + if (firstNodeItr.hasNext()) { id = Optional.of(firstNodeItr.next().toString()); } return id; } public static Optional getObject(RdfResource rdfResource, String uri) { - Optional metadatum = Optional.empty(); - Optional statement = Optional.ofNullable(rdfResource.getStatementOfPropertyWithId(uri)); - if (statement.isPresent()) { - RDFNode object = statement.get().getObject(); - if (!object.toString().isEmpty()) { - metadatum = Optional.of(object.toString()); - } - } - return metadatum; + return getObject(rdfResource.getModel(), uri); } public static String getParameterizedId(String id, ManifestRequest request) { diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index fa0249b..7a0cae5 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -32,11 +32,33 @@ iiif: image.server.url: http://localhost:8182/iiif/2 logo.url: https://brandguide.tamu.edu/assets/downloads/logos/TAM-Logo.png dspace: + label-precedence: + - "http://purl.org/dc/elements/1.1/title" + - "http://purl.org/dc/terms/title" + - "http://www.w3.org/2000/01/rdf-schema#label" + - "http://purl.org/dc/elements/1.1/identifier" + description-precedence: + - "http://purl.org/dc/terms/abstract" + - "http://purl.org/dc/terms/description" + - "http://purl.org/dc/elements/1.1/description" + metadata-prefixes: + - "http://purl.org/dc/elements/1.1/" + - "http://purl.org/dc/terms/" url: http://localhost:8080 + identifier: dspace webapp: xmlui - identifier: - dspace-rdf: dspace fedora: + label-precedence: + - "http://purl.org/dc/elements/1.1/title" + - "http://purl.org/dc/terms/title" + - "http://www.w3.org/2000/01/rdf-schema#label" + - "http://purl.org/dc/elements/1.1/identifier" + description-precedence: + - "http://purl.org/dc/terms/abstract" + - "http://purl.org/dc/terms/description" + - "http://purl.org/dc/elements/1.1/description" + metadata-prefixes: + - "http://purl.org/dc/elements/1.1/" + - "http://purl.org/dc/terms/" url: http://localhost:9000/fcrepo/rest - identifier: - fedora-pcdm: fedora \ No newline at end of file + identifier: fedora diff --git a/src/test/java/edu/tamu/iiif/config/DSpaceRdfIiiifConfigTest.java b/src/test/java/edu/tamu/iiif/config/DSpaceRdfIiiifConfigTest.java new file mode 100644 index 0000000..25c7877 --- /dev/null +++ b/src/test/java/edu/tamu/iiif/config/DSpaceRdfIiiifConfigTest.java @@ -0,0 +1,57 @@ +package edu.tamu.iiif.config; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +public class DSpaceRdfIiiifConfigTest { + + @Test + public void testDSpaceRdfIiifConfig() { + DSpaceRdfIiifConfig config = new DSpaceRdfIiifConfig(); + + List labelPrecedence = new ArrayList(); + labelPrecedence.add("http://purl.org/dc/elements/1.1/title"); + labelPrecedence.add("http://purl.org/dc/terms/title"); + labelPrecedence.add("http://www.w3.org/2000/01/rdf-schema#label"); + labelPrecedence.add("http://purl.org/dc/elements/1.1/identifier"); + List descriptionPrecedence = new ArrayList(); + descriptionPrecedence.add("http://purl.org/dc/terms/abstract"); + descriptionPrecedence.add("http://purl.org/dc/terms/description"); + descriptionPrecedence.add("http://purl.org/dc/elements/1.1/description"); + List metadataPrefixes = new ArrayList(); + metadataPrefixes.add("http://purl.org/dc/elements/1.1/"); + metadataPrefixes.add("http://purl.org/dc/terms/"); + + config.setLabelPrecedence(labelPrecedence); + config.setDescriptionPrecedence(descriptionPrecedence); + config.setMetadataPrefixes(metadataPrefixes); + config.setUrl("http://localhost:8080"); + config.setIdentifier("dspace-rdf"); + config.setWebapp("xmlui"); + + assertEquals(4, config.getLabelPrecedence().size()); + assertEquals("http://purl.org/dc/elements/1.1/title", config.getLabelPrecedence().get(0)); + assertEquals("http://purl.org/dc/terms/title", config.getLabelPrecedence().get(1)); + assertEquals("http://www.w3.org/2000/01/rdf-schema#label", config.getLabelPrecedence().get(2)); + assertEquals("http://purl.org/dc/elements/1.1/identifier", config.getLabelPrecedence().get(3)); + assertEquals(3, config.getDescriptionPrecedence().size()); + assertEquals("http://purl.org/dc/terms/abstract", config.getDescriptionPrecedence().get(0)); + assertEquals("http://purl.org/dc/terms/description", config.getDescriptionPrecedence().get(1)); + assertEquals("http://purl.org/dc/elements/1.1/description", config.getDescriptionPrecedence().get(2)); + assertEquals(2, config.getMetadataPrefixes().size()); + assertEquals("http://purl.org/dc/elements/1.1/", config.getMetadataPrefixes().get(0)); + assertEquals("http://purl.org/dc/terms/", config.getMetadataPrefixes().get(1)); + + assertEquals("http://localhost:8080", config.getUrl()); + assertEquals("dspace-rdf", config.getIdentifier()); + assertEquals("xmlui", config.getWebapp()); + } + +} diff --git a/src/test/java/edu/tamu/iiif/config/FedoraPcdmIiiifConfigTest.java b/src/test/java/edu/tamu/iiif/config/FedoraPcdmIiiifConfigTest.java new file mode 100644 index 0000000..10f997a --- /dev/null +++ b/src/test/java/edu/tamu/iiif/config/FedoraPcdmIiiifConfigTest.java @@ -0,0 +1,55 @@ +package edu.tamu.iiif.config; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +public class FedoraPcdmIiiifConfigTest { + + @Test + public void testFedoraPcdmIiifConfig() { + FedoraPcdmIiifConfig config = new FedoraPcdmIiifConfig(); + + List labelPrecedence = new ArrayList(); + labelPrecedence.add("http://purl.org/dc/elements/1.1/title"); + labelPrecedence.add("http://purl.org/dc/terms/title"); + labelPrecedence.add("http://www.w3.org/2000/01/rdf-schema#label"); + labelPrecedence.add("http://purl.org/dc/elements/1.1/identifier"); + List descriptionPrecedence = new ArrayList(); + descriptionPrecedence.add("http://purl.org/dc/terms/abstract"); + descriptionPrecedence.add("http://purl.org/dc/terms/description"); + descriptionPrecedence.add("http://purl.org/dc/elements/1.1/description"); + List metadataPrefixes = new ArrayList(); + metadataPrefixes.add("http://purl.org/dc/elements/1.1/"); + metadataPrefixes.add("http://purl.org/dc/terms/"); + + config.setLabelPrecedence(labelPrecedence); + config.setDescriptionPrecedence(descriptionPrecedence); + config.setMetadataPrefixes(metadataPrefixes); + config.setUrl("http://localhost:9000/fcrepo/rest"); + config.setIdentifier("fedora-pcdm"); + + assertEquals(4, config.getLabelPrecedence().size()); + assertEquals("http://purl.org/dc/elements/1.1/title", config.getLabelPrecedence().get(0)); + assertEquals("http://purl.org/dc/terms/title", config.getLabelPrecedence().get(1)); + assertEquals("http://www.w3.org/2000/01/rdf-schema#label", config.getLabelPrecedence().get(2)); + assertEquals("http://purl.org/dc/elements/1.1/identifier", config.getLabelPrecedence().get(3)); + assertEquals(3, config.getDescriptionPrecedence().size()); + assertEquals("http://purl.org/dc/terms/abstract", config.getDescriptionPrecedence().get(0)); + assertEquals("http://purl.org/dc/terms/description", config.getDescriptionPrecedence().get(1)); + assertEquals("http://purl.org/dc/elements/1.1/description", config.getDescriptionPrecedence().get(2)); + assertEquals(2, config.getMetadataPrefixes().size()); + assertEquals("http://purl.org/dc/elements/1.1/", config.getMetadataPrefixes().get(0)); + assertEquals("http://purl.org/dc/terms/", config.getMetadataPrefixes().get(1)); + + assertEquals("http://localhost:9000/fcrepo/rest", config.getUrl()); + assertEquals("fedora-pcdm", config.getIdentifier()); + } + +} diff --git a/src/test/java/edu/tamu/iiif/controller/AbstractManifestControllerTest.java b/src/test/java/edu/tamu/iiif/controller/AbstractManifestControllerTest.java index 8fbbdf0..18fe9de 100644 --- a/src/test/java/edu/tamu/iiif/controller/AbstractManifestControllerTest.java +++ b/src/test/java/edu/tamu/iiif/controller/AbstractManifestControllerTest.java @@ -2,7 +2,6 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; @@ -12,10 +11,4 @@ public abstract class AbstractManifestControllerTest implements ManifestControll @Autowired protected MockMvc mockMvc; - @Value("${iiif.dspace.identifier.dspace-rdf}") - protected String dspaceRdfIdentifier; - - @Value("${iiif.fedora.identifier.fedora-pcdm}") - protected String fedoraPcdmIdentifier; - } diff --git a/src/test/java/edu/tamu/iiif/controller/dspace/rdf/DSpaceRdfCanvasManifestControllerTest.java b/src/test/java/edu/tamu/iiif/controller/dspace/rdf/DSpaceRdfCanvasManifestControllerTest.java index c54c870..5f43cd8 100644 --- a/src/test/java/edu/tamu/iiif/controller/dspace/rdf/DSpaceRdfCanvasManifestControllerTest.java +++ b/src/test/java/edu/tamu/iiif/controller/dspace/rdf/DSpaceRdfCanvasManifestControllerTest.java @@ -17,7 +17,6 @@ import edu.tamu.iiif.controller.AbstractManifestControllerTest; import edu.tamu.iiif.controller.ManifestRequest; -import edu.tamu.iiif.controller.dspace.rdf.DSpaceRdfCanvasManifestController; import edu.tamu.iiif.service.dspace.rdf.DSpaceRdfCanvasManifestService; @WebMvcTest(value = DSpaceRdfCanvasManifestController.class, secure = false) @@ -33,7 +32,7 @@ public class DSpaceRdfCanvasManifestControllerTest extends AbstractManifestContr public void testGetManifest() throws Exception { String expected = readFileToString(json.getFile(), "UTF-8"); when(dspaceRdfCanvasManifestService.getManifest(any(ManifestRequest.class))).thenReturn(expected); - RequestBuilder requestBuilder = get("/" + dspaceRdfIdentifier + "/canvas/123456789/158308/1/sports-car-146873_960_720.png").accept(APPLICATION_JSON); + RequestBuilder requestBuilder = get("/dspace/canvas/123456789/158308/1/sports-car-146873_960_720.png").accept(APPLICATION_JSON); MvcResult result = mockMvc.perform(requestBuilder).andReturn(); assertEquals(expected, result.getResponse().getContentAsString()); } diff --git a/src/test/java/edu/tamu/iiif/controller/dspace/rdf/DSpaceRdfCollectionManifestControllerTest.java b/src/test/java/edu/tamu/iiif/controller/dspace/rdf/DSpaceRdfCollectionManifestControllerTest.java index 6db45ec..91b05f7 100644 --- a/src/test/java/edu/tamu/iiif/controller/dspace/rdf/DSpaceRdfCollectionManifestControllerTest.java +++ b/src/test/java/edu/tamu/iiif/controller/dspace/rdf/DSpaceRdfCollectionManifestControllerTest.java @@ -17,7 +17,6 @@ import edu.tamu.iiif.controller.AbstractManifestControllerTest; import edu.tamu.iiif.controller.ManifestRequest; -import edu.tamu.iiif.controller.dspace.rdf.DSpaceRdfCollectionManifestController; import edu.tamu.iiif.service.dspace.rdf.DSpaceRdfCollectionManifestService; @WebMvcTest(value = DSpaceRdfCollectionManifestController.class, secure = false) @@ -33,7 +32,7 @@ public class DSpaceRdfCollectionManifestControllerTest extends AbstractManifestC public void testGetManifest() throws Exception { String expected = readFileToString(json.getFile(), "UTF-8"); when(dspaceRdfCollectionManifestService.getManifest(any(ManifestRequest.class))).thenReturn(expected); - RequestBuilder requestBuilder = get("/" + dspaceRdfIdentifier + "/collection/123456789/158298").accept(APPLICATION_JSON); + RequestBuilder requestBuilder = get("/dspace/collection/123456789/158298").accept(APPLICATION_JSON); MvcResult result = mockMvc.perform(requestBuilder).andReturn(); assertEquals(expected, result.getResponse().getContentAsString()); } diff --git a/src/test/java/edu/tamu/iiif/controller/dspace/rdf/DSpaceRdfImageManifestControllerTest.java b/src/test/java/edu/tamu/iiif/controller/dspace/rdf/DSpaceRdfImageManifestControllerTest.java index 3cb6b39..9439736 100644 --- a/src/test/java/edu/tamu/iiif/controller/dspace/rdf/DSpaceRdfImageManifestControllerTest.java +++ b/src/test/java/edu/tamu/iiif/controller/dspace/rdf/DSpaceRdfImageManifestControllerTest.java @@ -17,7 +17,6 @@ import edu.tamu.iiif.controller.AbstractManifestControllerTest; import edu.tamu.iiif.controller.ManifestRequest; -import edu.tamu.iiif.controller.dspace.rdf.DSpaceRdfImageManifestController; import edu.tamu.iiif.service.dspace.rdf.DSpaceRdfImageManifestService; @WebMvcTest(value = DSpaceRdfImageManifestController.class, secure = false) @@ -33,7 +32,7 @@ public class DSpaceRdfImageManifestControllerTest extends AbstractManifestContro public void testGetManifest() throws Exception { String expected = readFileToString(json.getFile(), "UTF-8"); when(dspaceRdfImageManifestService.getManifest(any(ManifestRequest.class))).thenReturn(expected); - RequestBuilder requestBuilder = get("/" + dspaceRdfIdentifier + "/image/123456789/158308/1/sports-car-146873_960_20.png").accept(APPLICATION_JSON); + RequestBuilder requestBuilder = get("/dspace/image/123456789/158308/1/sports-car-146873_960_20.png").accept(APPLICATION_JSON); MvcResult result = mockMvc.perform(requestBuilder).andReturn(); assertEquals(expected, result.getResponse().getContentAsString()); } diff --git a/src/test/java/edu/tamu/iiif/controller/dspace/rdf/DSpaceRdfPresentationManifestControllerTest.java b/src/test/java/edu/tamu/iiif/controller/dspace/rdf/DSpaceRdfPresentationManifestControllerTest.java index 06e1b67..feaf95d 100644 --- a/src/test/java/edu/tamu/iiif/controller/dspace/rdf/DSpaceRdfPresentationManifestControllerTest.java +++ b/src/test/java/edu/tamu/iiif/controller/dspace/rdf/DSpaceRdfPresentationManifestControllerTest.java @@ -17,7 +17,6 @@ import edu.tamu.iiif.controller.AbstractManifestControllerTest; import edu.tamu.iiif.controller.ManifestRequest; -import edu.tamu.iiif.controller.dspace.rdf.DSpaceRdfPresentationManifestController; import edu.tamu.iiif.service.dspace.rdf.DSpaceRdfPresentationManifestService; @WebMvcTest(value = DSpaceRdfPresentationManifestController.class, secure = false) @@ -33,7 +32,7 @@ public class DSpaceRdfPresentationManifestControllerTest extends AbstractManifes public void testGetManifest() throws Exception { String expected = readFileToString(json.getFile(), "UTF-8"); when(dspaceRdfPresentationManifestService.getManifest(any(ManifestRequest.class))).thenReturn(expected); - RequestBuilder requestBuilder = get("/" + dspaceRdfIdentifier + "/presentation/123456789/158308").accept(APPLICATION_JSON); + RequestBuilder requestBuilder = get("/dspace/presentation/123456789/158308").accept(APPLICATION_JSON); MvcResult result = mockMvc.perform(requestBuilder).andReturn(); assertEquals(expected, result.getResponse().getContentAsString()); } diff --git a/src/test/java/edu/tamu/iiif/controller/dspace/rdf/DSpaceRdfSequenceManifestControllerTest.java b/src/test/java/edu/tamu/iiif/controller/dspace/rdf/DSpaceRdfSequenceManifestControllerTest.java index baa01fa..323f85a 100644 --- a/src/test/java/edu/tamu/iiif/controller/dspace/rdf/DSpaceRdfSequenceManifestControllerTest.java +++ b/src/test/java/edu/tamu/iiif/controller/dspace/rdf/DSpaceRdfSequenceManifestControllerTest.java @@ -17,7 +17,6 @@ import edu.tamu.iiif.controller.AbstractManifestControllerTest; import edu.tamu.iiif.controller.ManifestRequest; -import edu.tamu.iiif.controller.dspace.rdf.DSpaceRdfSequenceManifestController; import edu.tamu.iiif.service.dspace.rdf.DSpaceRdfSequenceManifestService; @WebMvcTest(value = DSpaceRdfSequenceManifestController.class, secure = false) @@ -33,7 +32,7 @@ public class DSpaceRdfSequenceManifestControllerTest extends AbstractManifestCon public void testGetManifest() throws Exception { String expected = readFileToString(json.getFile(), "UTF-8"); when(dspaceRdfSequenceManifestService.getManifest(any(ManifestRequest.class))).thenReturn(expected); - RequestBuilder requestBuilder = get("/" + dspaceRdfIdentifier + "/sequence/123456789/158308").accept(APPLICATION_JSON); + RequestBuilder requestBuilder = get("/dspace/sequence/123456789/158308").accept(APPLICATION_JSON); MvcResult result = mockMvc.perform(requestBuilder).andReturn(); assertEquals(expected, result.getResponse().getContentAsString()); } diff --git a/src/test/java/edu/tamu/iiif/controller/fedora/pcdm/FedoraPcdmCanvasManifestControllerTest.java b/src/test/java/edu/tamu/iiif/controller/fedora/pcdm/FedoraPcdmCanvasManifestControllerTest.java index f103123..e9443a0 100644 --- a/src/test/java/edu/tamu/iiif/controller/fedora/pcdm/FedoraPcdmCanvasManifestControllerTest.java +++ b/src/test/java/edu/tamu/iiif/controller/fedora/pcdm/FedoraPcdmCanvasManifestControllerTest.java @@ -17,7 +17,6 @@ import edu.tamu.iiif.controller.AbstractManifestControllerTest; import edu.tamu.iiif.controller.ManifestRequest; -import edu.tamu.iiif.controller.fedora.pcdm.FedoraPcdmCanvasManifestController; import edu.tamu.iiif.service.fedora.pcdm.FedoraPcdmCanvasManifestService; @WebMvcTest(value = FedoraPcdmCanvasManifestController.class, secure = false) @@ -33,7 +32,7 @@ public class FedoraPcdmCanvasManifestControllerTest extends AbstractManifestCont public void testGetManifest() throws Exception { String expected = readFileToString(json.getFile(), "UTF-8"); when(fedoraPcdmCanvasManifestService.getManifest(any(ManifestRequest.class))).thenReturn(expected); - RequestBuilder requestBuilder = get("/" + fedoraPcdmIdentifier + "/canvas/cars_pcdm_objects/chevy/pages/page_0").accept(APPLICATION_JSON); + RequestBuilder requestBuilder = get("/fedora/canvas/cars_pcdm_objects/chevy/pages/page_0").accept(APPLICATION_JSON); MvcResult result = mockMvc.perform(requestBuilder).andReturn(); assertEquals(expected, result.getResponse().getContentAsString()); } diff --git a/src/test/java/edu/tamu/iiif/controller/fedora/pcdm/FedoraPcdmCollectionManifestControllerTest.java b/src/test/java/edu/tamu/iiif/controller/fedora/pcdm/FedoraPcdmCollectionManifestControllerTest.java index db6a7e6..1ca899c 100644 --- a/src/test/java/edu/tamu/iiif/controller/fedora/pcdm/FedoraPcdmCollectionManifestControllerTest.java +++ b/src/test/java/edu/tamu/iiif/controller/fedora/pcdm/FedoraPcdmCollectionManifestControllerTest.java @@ -17,7 +17,6 @@ import edu.tamu.iiif.controller.AbstractManifestControllerTest; import edu.tamu.iiif.controller.ManifestRequest; -import edu.tamu.iiif.controller.fedora.pcdm.FedoraPcdmCollectionManifestController; import edu.tamu.iiif.service.fedora.pcdm.FedoraPcdmCollectionManifestService; @WebMvcTest(value = FedoraPcdmCollectionManifestController.class, secure = false) @@ -33,7 +32,7 @@ public class FedoraPcdmCollectionManifestControllerTest extends AbstractManifest public void testGetManifest() throws Exception { String expected = readFileToString(json.getFile(), "UTF-8"); when(fedoraPcdmCollectionManifestService.getManifest(any(ManifestRequest.class))).thenReturn(expected); - RequestBuilder requestBuilder = get("/" + fedoraPcdmIdentifier + "/collection/cars_pcdm").accept(APPLICATION_JSON); + RequestBuilder requestBuilder = get("/fedora/collection/cars_pcdm").accept(APPLICATION_JSON); MvcResult result = mockMvc.perform(requestBuilder).andReturn(); assertEquals(expected, result.getResponse().getContentAsString()); } diff --git a/src/test/java/edu/tamu/iiif/controller/fedora/pcdm/FedoraPcdmImageManifestControllerTest.java b/src/test/java/edu/tamu/iiif/controller/fedora/pcdm/FedoraPcdmImageManifestControllerTest.java index 1ab85d0..40af034 100644 --- a/src/test/java/edu/tamu/iiif/controller/fedora/pcdm/FedoraPcdmImageManifestControllerTest.java +++ b/src/test/java/edu/tamu/iiif/controller/fedora/pcdm/FedoraPcdmImageManifestControllerTest.java @@ -17,7 +17,6 @@ import edu.tamu.iiif.controller.AbstractManifestControllerTest; import edu.tamu.iiif.controller.ManifestRequest; -import edu.tamu.iiif.controller.fedora.pcdm.FedoraPcdmImageManifestController; import edu.tamu.iiif.service.fedora.pcdm.FedoraPcdmImageManifestService; @WebMvcTest(value = FedoraPcdmImageManifestController.class, secure = false) @@ -26,14 +25,14 @@ public class FedoraPcdmImageManifestControllerTest extends AbstractManifestContr @MockBean private FedoraPcdmImageManifestService fedoraPcdmImageManifestService; - @Value("classpath:mock/fedora/json/image0.json") + @Value("classpath:mock/fedora/json/image.json") private Resource image0; @Test public void testGetManifest() throws Exception { String expected = readFileToString(image0.getFile(), "UTF-8"); when(fedoraPcdmImageManifestService.getManifest(any(ManifestRequest.class))).thenReturn(expected); - RequestBuilder requestBuilder = get("/" + fedoraPcdmIdentifier + "/image/cars_pcdm_objects/chevy/pages/page_0/files/PTAR_800x400.png").accept(APPLICATION_JSON); + RequestBuilder requestBuilder = get("/fedora/image/cars_pcdm_objects/chevy/pages/page_0/files/PTAR_800x400.png").accept(APPLICATION_JSON); MvcResult result = mockMvc.perform(requestBuilder).andReturn(); assertEquals(expected, result.getResponse().getContentAsString()); } diff --git a/src/test/java/edu/tamu/iiif/controller/fedora/pcdm/FedoraPcdmPresentationManifestControllerTest.java b/src/test/java/edu/tamu/iiif/controller/fedora/pcdm/FedoraPcdmPresentationManifestControllerTest.java index 6a336a6..c6a6d12 100644 --- a/src/test/java/edu/tamu/iiif/controller/fedora/pcdm/FedoraPcdmPresentationManifestControllerTest.java +++ b/src/test/java/edu/tamu/iiif/controller/fedora/pcdm/FedoraPcdmPresentationManifestControllerTest.java @@ -17,7 +17,6 @@ import edu.tamu.iiif.controller.AbstractManifestControllerTest; import edu.tamu.iiif.controller.ManifestRequest; -import edu.tamu.iiif.controller.fedora.pcdm.FedoraPcdmPresentationManifestController; import edu.tamu.iiif.service.fedora.pcdm.FedoraPcdmPresentationManifestService; @WebMvcTest(value = FedoraPcdmPresentationManifestController.class, secure = false) @@ -33,7 +32,7 @@ public class FedoraPcdmPresentationManifestControllerTest extends AbstractManife public void testGetManifest() throws Exception { String expected = readFileToString(json.getFile(), "UTF-8"); when(fedoraPcdmPresentationManifestService.getManifest(any(ManifestRequest.class))).thenReturn(expected); - RequestBuilder requestBuilder = get("/" + fedoraPcdmIdentifier + "/presentation/cars_pcdm_objects/chevy").accept(APPLICATION_JSON); + RequestBuilder requestBuilder = get("/fedora/presentation/cars_pcdm_objects/chevy").accept(APPLICATION_JSON); MvcResult result = mockMvc.perform(requestBuilder).andReturn(); assertEquals(expected, result.getResponse().getContentAsString()); } diff --git a/src/test/java/edu/tamu/iiif/controller/fedora/pcdm/FedoraPcdmSequenceManifestControllerTest.java b/src/test/java/edu/tamu/iiif/controller/fedora/pcdm/FedoraPcdmSequenceManifestControllerTest.java index ce4d74a..ac783df 100644 --- a/src/test/java/edu/tamu/iiif/controller/fedora/pcdm/FedoraPcdmSequenceManifestControllerTest.java +++ b/src/test/java/edu/tamu/iiif/controller/fedora/pcdm/FedoraPcdmSequenceManifestControllerTest.java @@ -17,7 +17,6 @@ import edu.tamu.iiif.controller.AbstractManifestControllerTest; import edu.tamu.iiif.controller.ManifestRequest; -import edu.tamu.iiif.controller.fedora.pcdm.FedoraPcdmSequenceManifestController; import edu.tamu.iiif.service.fedora.pcdm.FedoraPcdmSequenceManifestService; @WebMvcTest(value = FedoraPcdmSequenceManifestController.class, secure = false) @@ -33,7 +32,7 @@ public class FedoraPcdmSequenceManifestControllerTest extends AbstractManifestCo public void testGetManifest() throws Exception { String expected = readFileToString(json.getFile(), "UTF-8"); when(fedoraPcdmSequenceManifestService.getManifest(any(ManifestRequest.class))).thenReturn(expected); - RequestBuilder requestBuilder = get("/" + fedoraPcdmIdentifier + "/sequence/cars_pcdm_objects/chevy").accept(APPLICATION_JSON); + RequestBuilder requestBuilder = get("/fedora/sequence/cars_pcdm_objects/chevy").accept(APPLICATION_JSON); MvcResult result = mockMvc.perform(requestBuilder).andReturn(); assertEquals(expected, result.getResponse().getContentAsString()); } diff --git a/src/test/java/edu/tamu/iiif/model/rdf/RdfOrderedSequenceTest.java b/src/test/java/edu/tamu/iiif/model/rdf/RdfOrderedSequenceTest.java index cb156c2..aa15961 100644 --- a/src/test/java/edu/tamu/iiif/model/rdf/RdfOrderedSequenceTest.java +++ b/src/test/java/edu/tamu/iiif/model/rdf/RdfOrderedSequenceTest.java @@ -26,8 +26,8 @@ public void testRdfOrderedSequence() { System.out.println(model); Resource resource = model.getResource("http://localhost:9000/fcrepo/rest/mwbObjects/TGWCatalog"); RdfResource rdfResource = new RdfResource(model, resource); - Optional firstId = RdfModelUtility.getIdByPredicate(rdfResource.getModel(), IANA_FIRST_PREDICATE); - Optional lastId = RdfModelUtility.getIdByPredicate(rdfResource.getModel(), IANA_LAST_PREDICATE); + Optional firstId = RdfModelUtility.getObject(rdfResource.getModel(), IANA_FIRST_PREDICATE); + Optional lastId = RdfModelUtility.getObject(rdfResource.getModel(), IANA_LAST_PREDICATE); System.out.println(firstId.get()); System.out.println(lastId.get()); diff --git a/src/test/java/edu/tamu/iiif/service/HttpServiceTest.java b/src/test/java/edu/tamu/iiif/service/HttpServiceTest.java index 5fc1e25..963c03b 100644 --- a/src/test/java/edu/tamu/iiif/service/HttpServiceTest.java +++ b/src/test/java/edu/tamu/iiif/service/HttpServiceTest.java @@ -49,7 +49,7 @@ public class HttpServiceTest { @InjectMocks private HttpService httpService; - @Value("classpath:mock/fedora/json/image0.json") + @Value("classpath:mock/fedora/json/image.json") private Resource image0; @Value("classpath:mock/fedora/rdf/pcdm_collection_container.rdf") diff --git a/src/test/java/edu/tamu/iiif/service/dspace/rdf/AbstractDSpaceRdfManifestServiceTest.java b/src/test/java/edu/tamu/iiif/service/dspace/rdf/AbstractDSpaceRdfManifestServiceTest.java index 3a636fc..e55c8da 100644 --- a/src/test/java/edu/tamu/iiif/service/dspace/rdf/AbstractDSpaceRdfManifestServiceTest.java +++ b/src/test/java/edu/tamu/iiif/service/dspace/rdf/AbstractDSpaceRdfManifestServiceTest.java @@ -1,32 +1,56 @@ -package edu.tamu.iiif.service.dspace.rdf; - -import static org.springframework.test.util.ReflectionTestUtils.setField; - -import edu.tamu.iiif.service.AbstractManifestServiceTest; - -public abstract class AbstractDSpaceRdfManifestServiceTest extends AbstractManifestServiceTest { - - protected static final String DSPACE_URL = "http://localhost:8080"; - - protected static final String DSPACE_WEBAPP = "xmlui"; - - protected static final String DSPACE_RDF_IDENTIFIER = "dspace-rdf"; - - protected void setup(AbstractDSpaceRdfManifestService dspaceRdfManifestService) { - super.setup(dspaceRdfManifestService); - setField(dspaceRdfManifestService, "dspaceUrl", DSPACE_URL); - setField(dspaceRdfManifestService, "dspaceWebapp", DSPACE_WEBAPP); - setField(dspaceRdfManifestService, "dspaceRdfIdentifier", DSPACE_RDF_IDENTIFIER); - } - - @Override - protected String getRepoRdfIdentifier() { - return DSPACE_RDF_IDENTIFIER; - } - - @Override - protected String getRepoBaseUrl() { - return DSPACE_URL + "/"; - } - -} +package edu.tamu.iiif.service.dspace.rdf; + +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.boot.test.mock.mockito.MockBean; + +import edu.tamu.iiif.config.DSpaceRdfIiifConfig; +import edu.tamu.iiif.service.AbstractManifestServiceTest; + +public abstract class AbstractDSpaceRdfManifestServiceTest extends AbstractManifestServiceTest { + + @MockBean + private DSpaceRdfIiifConfig config; + + protected static final String DSPACE_URL = "http://localhost:8080"; + + protected static final String DSPACE_RDF_IDENTIFIER = "dspace-rdf"; + + protected static final String DSPACE_WEBAPP = "xmlui"; + + protected void setup(AbstractDSpaceRdfManifestService dspaceRdfManifestService) { + super.setup(dspaceRdfManifestService); + List labelPrecedence = new ArrayList(); + labelPrecedence.add("http://purl.org/dc/elements/1.1/title"); + labelPrecedence.add("http://purl.org/dc/terms/title"); + labelPrecedence.add("http://www.w3.org/2000/01/rdf-schema#label"); + labelPrecedence.add("http://purl.org/dc/elements/1.1/identifier"); + List descriptionPrecedence = new ArrayList(); + descriptionPrecedence.add("http://purl.org/dc/terms/abstract"); + descriptionPrecedence.add("http://purl.org/dc/terms/description"); + descriptionPrecedence.add("http://purl.org/dc/elements/1.1/description"); + List metadataPrefixes = new ArrayList(); + metadataPrefixes.add("http://purl.org/dc/elements/1.1/"); + metadataPrefixes.add("http://purl.org/dc/terms/"); + when(config.getLabelPrecedence()).thenReturn(labelPrecedence); + when(config.getDescriptionPrecedence()).thenReturn(descriptionPrecedence); + when(config.getMetadataPrefixes()).thenReturn(metadataPrefixes); + when(config.getUrl()).thenReturn(DSPACE_URL); + when(config.getIdentifier()).thenReturn(DSPACE_RDF_IDENTIFIER); + when(config.getWebapp()).thenReturn(DSPACE_WEBAPP); + } + + @Override + protected String getRepoRdfIdentifier() { + return DSPACE_RDF_IDENTIFIER; + } + + @Override + protected String getRepoBaseUrl() { + return DSPACE_URL + "/"; + } + +} diff --git a/src/test/java/edu/tamu/iiif/service/dspace/rdf/DSpaceRdfCollectionManifestServiceTest.java b/src/test/java/edu/tamu/iiif/service/dspace/rdf/DSpaceRdfCollectionManifestServiceTest.java index 0fa20ed..1e7558c 100644 --- a/src/test/java/edu/tamu/iiif/service/dspace/rdf/DSpaceRdfCollectionManifestServiceTest.java +++ b/src/test/java/edu/tamu/iiif/service/dspace/rdf/DSpaceRdfCollectionManifestServiceTest.java @@ -35,6 +35,9 @@ public class DSpaceRdfCollectionManifestServiceTest extends AbstractDSpaceRdfMan @Value("classpath:mock/dspace/json/collection.json") private Resource collection; + @Value("classpath:mock/dspace/rdf/item.rdf") + private Resource itemRdf; + @Value("classpath:mock/dspace/json/collections.json") private Resource collections; @@ -47,7 +50,10 @@ public void setup() { public void testGetManifest() throws IOException, URISyntaxException { when(httpService.get(eq(DSPACE_URL + "/rdf/handle/123456789/158299"))).thenReturn(readFileToString(collectionRdf.getFile(), "UTF-8")); when(httpService.get(eq(DSPACE_URL + "/rdf/handle/123456789/158301"))).thenReturn(readFileToString(subcommunityRdf.getFile(), "UTF-8")); + when(httpService.get(eq(DSPACE_URL + "/rdf/handle/123456789/158302"))).thenReturn(readFileToString(communityRdf.getFile(), "UTF-8")); when(httpService.get(eq(DSPACE_URL + "/rdf/handle/123456789/158298"))).thenReturn(readFileToString(communityRdf.getFile(), "UTF-8")); + when(httpService.get(eq(DSPACE_URL + "/rdf/handle/123456789/158308"))).thenReturn(readFileToString(itemRdf.getFile(), "UTF-8")); + String collectionManifest = dspaceRdfCollectionManifestService.getManifest(ManifestRequest.of("123456789/158299", false)); assertEquals(objectMapper.readValue(collection.getFile(), JsonNode.class), objectMapper.readValue(collectionManifest, JsonNode.class)); diff --git a/src/test/java/edu/tamu/iiif/service/fedora/pcdm/AbstractFedoraPcdmManifestServiceTest.java b/src/test/java/edu/tamu/iiif/service/fedora/pcdm/AbstractFedoraPcdmManifestServiceTest.java index eb4f4f9..cfb6b72 100644 --- a/src/test/java/edu/tamu/iiif/service/fedora/pcdm/AbstractFedoraPcdmManifestServiceTest.java +++ b/src/test/java/edu/tamu/iiif/service/fedora/pcdm/AbstractFedoraPcdmManifestServiceTest.java @@ -1,29 +1,53 @@ -package edu.tamu.iiif.service.fedora.pcdm; - -import static org.springframework.test.util.ReflectionTestUtils.setField; - -import edu.tamu.iiif.service.AbstractManifestServiceTest; - -public abstract class AbstractFedoraPcdmManifestServiceTest extends AbstractManifestServiceTest { - - protected static final String FEDORA_URL = "http://localhost:9000/fcrepo/rest"; - - protected static final String FEDORA_PCDM_IDENTIFIER = "fedora-pcdm"; - - protected void setup(AbstractFedoraPcdmManifestService fedoraPcdmManifestService) { - super.setup(fedoraPcdmManifestService); - setField(fedoraPcdmManifestService, "fedoraUrl", FEDORA_URL); - setField(fedoraPcdmManifestService, "fedoraPcdmIdentifier", FEDORA_PCDM_IDENTIFIER); - } - - @Override - protected String getRepoRdfIdentifier() { - return FEDORA_PCDM_IDENTIFIER; - } - - @Override - protected String getRepoBaseUrl() { - return FEDORA_URL + "/"; - } - -} +package edu.tamu.iiif.service.fedora.pcdm; + +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.boot.test.mock.mockito.MockBean; + +import edu.tamu.iiif.config.FedoraPcdmIiifConfig; +import edu.tamu.iiif.service.AbstractManifestServiceTest; + +public abstract class AbstractFedoraPcdmManifestServiceTest extends AbstractManifestServiceTest { + + @MockBean + private FedoraPcdmIiifConfig config; + + protected static final String FEDORA_URL = "http://localhost:9000/fcrepo/rest"; + + protected static final String FEDORA_PCDM_IDENTIFIER = "fedora-pcdm"; + + protected void setup(AbstractFedoraPcdmManifestService fedoraPcdmManifestService) { + super.setup(fedoraPcdmManifestService); + List labelPrecedence = new ArrayList(); + labelPrecedence.add("http://purl.org/dc/elements/1.1/title"); + labelPrecedence.add("http://purl.org/dc/terms/title"); + labelPrecedence.add("http://www.w3.org/2000/01/rdf-schema#label"); + labelPrecedence.add("http://purl.org/dc/elements/1.1/identifier"); + List descriptionPrecedence = new ArrayList(); + descriptionPrecedence.add("http://purl.org/dc/terms/abstract"); + descriptionPrecedence.add("http://purl.org/dc/terms/description"); + descriptionPrecedence.add("http://purl.org/dc/elements/1.1/description"); + List metadataPrefixes = new ArrayList(); + metadataPrefixes.add("http://purl.org/dc/elements/1.1/"); + metadataPrefixes.add("http://purl.org/dc/terms/"); + when(config.getLabelPrecedence()).thenReturn(labelPrecedence); + when(config.getDescriptionPrecedence()).thenReturn(descriptionPrecedence); + when(config.getMetadataPrefixes()).thenReturn(metadataPrefixes); + when(config.getUrl()).thenReturn(FEDORA_URL); + when(config.getIdentifier()).thenReturn(FEDORA_PCDM_IDENTIFIER); + } + + @Override + protected String getRepoRdfIdentifier() { + return FEDORA_PCDM_IDENTIFIER; + } + + @Override + protected String getRepoBaseUrl() { + return FEDORA_URL + "/"; + } + +} diff --git a/src/test/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmCanvasManifestServiceTest.java b/src/test/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmCanvasManifestServiceTest.java index e86c0dd..b544741 100644 --- a/src/test/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmCanvasManifestServiceTest.java +++ b/src/test/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmCanvasManifestServiceTest.java @@ -33,8 +33,8 @@ public class FedoraPcdmCanvasManifestServiceTest extends AbstractFedoraPcdmManif @Value("classpath:mock/fedora/rdf/item_container_files_entry.rdf") private Resource itemFilesEntryRdf; - @Value("classpath:mock/fedora/json/image0.json") - private Resource image0; + @Value("classpath:mock/fedora/json/image.json") + private Resource image; @Value("classpath:mock/fedora/json/canvas.json") private Resource canvas; @@ -48,7 +48,7 @@ public void setup() { public void testGetManifest() throws IOException, URISyntaxException { when(httpService.contentType(any(String.class))).thenReturn("image/png; charset=utf-8"); - when(httpService.get(any(String.class))).thenReturn(readFileToString(image0.getFile(), "UTF-8")); + when(httpService.get(any(String.class))).thenReturn(readFileToString(image.getFile(), "UTF-8")); when(httpService.get(eq(FEDORA_URL + "/mwbObjects/TGWCatalog/Pages/ExCat0084"))).thenReturn(readFileToString(itemRdf.getFile(), "UTF-8")); when(httpService.get(eq(FEDORA_URL + "/mwbObjects/TGWCatalog/Pages/ExCat0084/files/fcr:metadata"))).thenReturn(readFileToString(itemFilesRdf.getFile(), "UTF-8")); diff --git a/src/test/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmImageManifestServiceTest.java b/src/test/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmImageManifestServiceTest.java index e03c90c..ef7bfc1 100644 --- a/src/test/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmImageManifestServiceTest.java +++ b/src/test/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmImageManifestServiceTest.java @@ -23,8 +23,8 @@ public class FedoraPcdmImageManifestServiceTest extends AbstractFedoraPcdmManife @InjectMocks private FedoraPcdmImageManifestService fedoraPcdmImageManifestService; - @Value("classpath:mock/fedora/json/image0.json") - private Resource image0; + @Value("classpath:mock/fedora/json/image.json") + private Resource image; @Before public void setup() { @@ -33,9 +33,9 @@ public void setup() { @Test public void testGetManifest() throws IOException, URISyntaxException { - when(httpService.get(any(String.class))).thenReturn(readFileToString(image0.getFile(), "UTF-8")); + when(httpService.get(any(String.class))).thenReturn(readFileToString(image.getFile(), "UTF-8")); String manifest = fedoraPcdmImageManifestService.getManifest(ManifestRequest.of("mwbObjects/TGWCatalog/Pages/ExCat0084/files/ExCat0084.jpg", false)); - assertEquals(objectMapper.readValue(image0.getFile(), JsonNode.class), objectMapper.readValue(manifest, JsonNode.class)); + assertEquals(objectMapper.readValue(image.getFile(), JsonNode.class), objectMapper.readValue(manifest, JsonNode.class)); } } diff --git a/src/test/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmPresentationManifestServiceTest.java b/src/test/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmPresentationManifestServiceTest.java index aaf3645..740ac33 100644 --- a/src/test/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmPresentationManifestServiceTest.java +++ b/src/test/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmPresentationManifestServiceTest.java @@ -39,7 +39,7 @@ public class FedoraPcdmPresentationManifestServiceTest extends AbstractFedoraPcd @Value("classpath:mock/fedora/rdf/item_container_files_entry.rdf") private Resource itemFilesEntryRdf; - @Value("classpath:mock/fedora/json/image0.json") + @Value("classpath:mock/fedora/json/image.json") private Resource image; @Value("classpath:mock/fedora/json/presentation.json") diff --git a/src/test/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmSequenceManifestServiceTest.java b/src/test/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmSequenceManifestServiceTest.java index 3eaa294..54fa167 100644 --- a/src/test/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmSequenceManifestServiceTest.java +++ b/src/test/java/edu/tamu/iiif/service/fedora/pcdm/FedoraPcdmSequenceManifestServiceTest.java @@ -33,8 +33,8 @@ public class FedoraPcdmSequenceManifestServiceTest extends AbstractFedoraPcdmMan @Value("classpath:mock/fedora/rdf/item_container_files_entry.rdf") private Resource itemFilesEntryRdf; - @Value("classpath:mock/fedora/json/image0.json") - private Resource image0; + @Value("classpath:mock/fedora/json/image.json") + private Resource image; @Value("classpath:mock/fedora/json/sequence.json") private Resource sequence; @@ -48,7 +48,7 @@ public void setup() { public void testGetManifest() throws IOException, URISyntaxException { when(httpService.contentType(any(String.class))).thenReturn("image/png; charset=utf-8"); - when(httpService.get(any(String.class))).thenReturn(readFileToString(image0.getFile(), "UTF-8")); + when(httpService.get(any(String.class))).thenReturn(readFileToString(image.getFile(), "UTF-8")); when(httpService.get(eq(FEDORA_URL + "/mwbObjects/TGWCatalog/Pages/ExCat0084"))).thenReturn(readFileToString(itemRdf.getFile(), "UTF-8")); when(httpService.get(eq(FEDORA_URL + "/mwbObjects/TGWCatalog/Pages/ExCat0084/files/fcr:metadata"))).thenReturn(readFileToString(itemFilesRdf.getFile(), "UTF-8")); diff --git a/src/test/java/edu/tamu/iiif/utility/RdfModelUtilityTest.java b/src/test/java/edu/tamu/iiif/utility/RdfModelUtilityTest.java index 6d2f5f2..d9f6aa0 100644 --- a/src/test/java/edu/tamu/iiif/utility/RdfModelUtilityTest.java +++ b/src/test/java/edu/tamu/iiif/utility/RdfModelUtilityTest.java @@ -36,7 +36,7 @@ public void testGetIdByPredicate() { String rdf = Files.contentOf(new File("src/test/resources/mock/fedora/rdf/collection_container.rdf"), "UTF-8"); Model model = RdfModelUtility.createRdfModel(rdf); Assert.assertNotNull(model); - Optional firstId = RdfModelUtility.getIdByPredicate(model, IANA_FIRST_PREDICATE); + Optional firstId = RdfModelUtility.getObject(model, IANA_FIRST_PREDICATE); Assert.assertTrue(firstId.isPresent()); Assert.assertEquals("http://localhost:9000/fcrepo/rest/mwbObjects/TGWCatalog/orderProxies/ExCat0001Proxy", firstId.get()); } diff --git a/src/test/resources/application.yaml b/src/test/resources/application.yaml index 47b1467..91f8797 100644 --- a/src/test/resources/application.yaml +++ b/src/test/resources/application.yaml @@ -32,11 +32,33 @@ iiif: image.server.url: http://localhost:8182/iiif/2 logo.url: https://brandguide.tamu.edu/assets/downloads/logos/TAM-Logo.png dspace: + label-precedence: + - "http://purl.org/dc/elements/1.1/title" + - "http://purl.org/dc/terms/title" + - "http://www.w3.org/2000/01/rdf-schema#label" + - "http://purl.org/dc/elements/1.1/identifier" + description-precedence: + - "http://purl.org/dc/terms/abstract" + - "http://purl.org/dc/terms/description" + - "http://purl.org/dc/elements/1.1/description" + metadata-prefixes: + - "http://purl.org/dc/elements/1.1/" + - "http://purl.org/dc/terms/" url: http://localhost:8080 webapp: xmlui - identifier: - dspace-rdf: dspace + identifier: dspace fedora: + label-precedence: + - "http://purl.org/dc/elements/1.1/title" + - "http://purl.org/dc/terms/title" + - "http://www.w3.org/2000/01/rdf-schema#label" + - "http://purl.org/dc/elements/1.1/identifier" + description-precedence: + - "http://purl.org/dc/terms/abstract" + - "http://purl.org/dc/terms/description" + - "http://purl.org/dc/elements/1.1/description" + metadata-prefixes: + - "http://purl.org/dc/elements/1.1/" + - "http://purl.org/dc/terms/" url: http://localhost:9000/fcrepo/rest - identifier: - fedora-pcdm: fedora \ No newline at end of file + identifier: fedora \ No newline at end of file diff --git a/src/test/resources/mock/dspace/json/collection-presentation.json b/src/test/resources/mock/dspace/json/collection-presentation.json index 92cd1dc..426220e 100644 --- a/src/test/resources/mock/dspace/json/collection-presentation.json +++ b/src/test/resources/mock/dspace/json/collection-presentation.json @@ -1,225 +1,61 @@ { + "@context": "http://iiif.io/api/presentation/2/context.json", + "@id": "http://localhost:9000/dspace-rdf/presentation/123456789/158299", + "@type": "sc:Manifest", + "label": "Cool Cars", "logo": "https://brandguide.tamu.edu/assets/downloads/logos/TAM-Logo.png", - "description": "No description available!", - "label": "dspace-rdf:rdf/handle/123456789/158299", + "metadata": [ + { + "label": "title", + "value": "Cool Cars" + } + ], "sequences": [ { + "@id": "http://localhost:9000/dspace-rdf/sequence/123456789/158308", + "@type": "sc:Sequence", "canvases": [ { + "@id": "http://localhost:9000/dspace-rdf/canvas/123456789/158308/1/sports-car-146873_960_720.png", + "@type": "sc:Canvas", "height": 480, "images": [ { + "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/info.json", + "@type": "oa:Annotation", "motivation": "sc:painting", "on": "http://localhost:9000/dspace-rdf/canvas/123456789/158308/1/sports-car-146873_960_720.png", "resource": { - "format": "image/png; charset=utf-8", - "height": 480, - "width": 960, - "service": { - "label": "DSpace IIIF Image Resource Service", - "profile": "http://iiif.io/api/image/2/level0.json", - "@context": "http://iiif.io/api/image/2/context.json", - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n" - }, "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/full/full/0/default.jpg", - "@type": "dctypes:Image" - }, - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/info.json", - "@type": "oa:Annotation" - } - ], - "label": "1sports-car-146873_960_720.png", - "width": 960, - "@type": "sc:Canvas", - "@id": "http://localhost:9000/dspace-rdf/canvas/123456789/158308/1/sports-car-146873_960_720.png" - }, - { - "height": 480, - "images": [ - { - "motivation": "sc:painting", - "on": "http://localhost:9000/dspace-rdf/canvas/123456789/158310/1/sports-car-146873_960_720.png", - "resource": { + "@type": "dctypes:Image", "format": "image/png; charset=utf-8", "height": 480, - "width": 960, "service": { "label": "DSpace IIIF Image Resource Service", "profile": "http://iiif.io/api/image/2/level0.json", "@context": "http://iiif.io/api/image/2/context.json", - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMxMC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n" - }, - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMxMC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/full/full/0/default.jpg", - "@type": "dctypes:Image" - }, - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMxMC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/info.json", - "@type": "oa:Annotation" - } - ], - "label": "1sports-car-146873_960_720.png", - "width": 960, - "@type": "sc:Canvas", - "@id": "http://localhost:9000/dspace-rdf/canvas/123456789/158310/1/sports-car-146873_960_720.png" - }, - { - "height": 480, - "images": [ - { - "motivation": "sc:painting", - "on": "http://localhost:9000/dspace-rdf/canvas/123456789/158313/1/sports-car-146873_960_720.png", - "resource": { - "format": "image/png; charset=utf-8", - "height": 480, - "width": 960, - "service": { - "label": "DSpace IIIF Image Resource Service", - "profile": "http://iiif.io/api/image/2/level0.json", - "@context": "http://iiif.io/api/image/2/context.json", - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMxMy8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n" - }, - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMxMy8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/full/full/0/default.jpg", - "@type": "dctypes:Image" - }, - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMxMy8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/info.json", - "@type": "oa:Annotation" - } - ], - "label": "1sports-car-146873_960_720.png", - "width": 960, - "@type": "sc:Canvas", - "@id": "http://localhost:9000/dspace-rdf/canvas/123456789/158313/1/sports-car-146873_960_720.png" - }, - { - "height": 480, - "images": [ - { - "motivation": "sc:painting", - "on": "http://localhost:9000/dspace-rdf/canvas/123456789/158312/1/sports-car-146873_960_720.png", - "resource": { - "format": "image/png; charset=utf-8", - "height": 480, - "width": 960, - "service": { - "label": "DSpace IIIF Image Resource Service", - "profile": "http://iiif.io/api/image/2/level0.json", - "@context": "http://iiif.io/api/image/2/context.json", - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMxMi8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n" - }, - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMxMi8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/full/full/0/default.jpg", - "@type": "dctypes:Image" - }, - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMxMi8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/info.json", - "@type": "oa:Annotation" - } - ], - "label": "1sports-car-146873_960_720.png", - "width": 960, - "@type": "sc:Canvas", - "@id": "http://localhost:9000/dspace-rdf/canvas/123456789/158312/1/sports-car-146873_960_720.png" - }, - { - "height": 480, - "images": [ - { - "motivation": "sc:painting", - "on": "http://localhost:9000/dspace-rdf/canvas/123456789/158317/1/sports-car-146873_960_720.png", - "resource": { - "format": "image/png; charset=utf-8", - "height": 480, - "width": 960, - "service": { - "label": "DSpace IIIF Image Resource Service", - "profile": "http://iiif.io/api/image/2/level0.json", - "@context": "http://iiif.io/api/image/2/context.json", - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMxNy8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n" - }, - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMxNy8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/full/full/0/default.jpg", - "@type": "dctypes:Image" - }, - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMxNy8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/info.json", - "@type": "oa:Annotation" - } - ], - "label": "1sports-car-146873_960_720.png", - "width": 960, - "@type": "sc:Canvas", - "@id": "http://localhost:9000/dspace-rdf/canvas/123456789/158317/1/sports-car-146873_960_720.png" - }, - { - "height": 480, - "images": [ - { - "motivation": "sc:painting", - "on": "http://localhost:9000/dspace-rdf/canvas/123456789/158307/1/sports-car-146873_960_720.png", - "resource": { - "format": "image/png; charset=utf-8", - "height": 480, - "width": 960, - "service": { - "label": "DSpace IIIF Image Resource Service", - "profile": "http://iiif.io/api/image/2/level0.json", - "@context": "http://iiif.io/api/image/2/context.json", - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwNy8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n" - }, - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwNy8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/full/full/0/default.jpg", - "@type": "dctypes:Image" - }, - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwNy8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/info.json", - "@type": "oa:Annotation" - } - ], - "label": "1sports-car-146873_960_720.png", - "width": 960, - "@type": "sc:Canvas", - "@id": "http://localhost:9000/dspace-rdf/canvas/123456789/158307/1/sports-car-146873_960_720.png" - }, - { - "height": 480, - "images": [ - { - "motivation": "sc:painting", - "on": "http://localhost:9000/dspace-rdf/canvas/123456789/158316/1/sports-car-146873_960_720.png", - "resource": { - "format": "image/png; charset=utf-8", - "height": 480, - "width": 960, - "service": { - "label": "DSpace IIIF Image Resource Service", - "profile": "http://iiif.io/api/image/2/level0.json", - "@context": "http://iiif.io/api/image/2/context.json", - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMxNi8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n" + "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n" }, - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMxNi8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/full/full/0/default.jpg", - "@type": "dctypes:Image" - }, - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMxNi8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/info.json", - "@type": "oa:Annotation" + "width": 960 + } } ], "label": "1sports-car-146873_960_720.png", - "width": 960, - "@type": "sc:Canvas", - "@id": "http://localhost:9000/dspace-rdf/canvas/123456789/158316/1/sports-car-146873_960_720.png" + "width": 960 } ], - "label": "123456789/158308", - "@type": "sc:Sequence", - "@id": "http://localhost:9000/dspace-rdf/sequence/123456789/158308" + "label": "Cool Cars" } ], "thumbnail": { + "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/full/!100,100/0/default.jpg", "services": [ { - "label": "DSpace IIIF Image Resource Service", - "profile": "http://iiif.io/api/image/2/level0.json", "@context": "http://iiif.io/api/image/2/context.json", - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n" + "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n", + "label": "DSpace IIIF Image Resource Service", + "profile": "http://iiif.io/api/image/2/level0.json" } - ], - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/full/!100,100/0/default.jpg" - }, - "@type": "sc:Manifest", - "@id": "http://localhost:9000/dspace-rdf/presentation/123456789/158299", - "@context": "http://iiif.io/api/presentation/2/context.json", - "metadata": [] + ] + } } \ No newline at end of file diff --git a/src/test/resources/mock/dspace/json/collection.json b/src/test/resources/mock/dspace/json/collection.json index 212de08..ba78428 100644 --- a/src/test/resources/mock/dspace/json/collection.json +++ b/src/test/resources/mock/dspace/json/collection.json @@ -1,47 +1,21 @@ { + "@context": "http://iiif.io/api/presentation/2/context.json", + "@id": "http://localhost:9000/dspace-rdf/collection/123456789/158299", + "@type": "sc:Collection", + "label": "Cool Cars", "logo": "https://brandguide.tamu.edu/assets/downloads/logos/TAM-Logo.png", - "description": "No description available!", - "label": "dspace-rdf:rdf/handle/123456789/158299", - "metadata": [], "manifests": [ { - "label": "123456789/158308", "@id": "http://localhost:9000/dspace-rdf/presentation/123456789/158308", - "@type": "sc:Manifest" - }, - { - "label": "123456789/158310", - "@id": "http://localhost:9000/dspace-rdf/presentation/123456789/158310", - "@type": "sc:Manifest" - }, - { - "label": "123456789/158313", - "@id": "http://localhost:9000/dspace-rdf/presentation/123456789/158313", - "@type": "sc:Manifest" - }, - { - "label": "123456789/158312", - "@id": "http://localhost:9000/dspace-rdf/presentation/123456789/158312", - "@type": "sc:Manifest" - }, - { - "label": "123456789/158317", - "@id": "http://localhost:9000/dspace-rdf/presentation/123456789/158317", - "@type": "sc:Manifest" - }, - { - "label": "123456789/158307", - "@id": "http://localhost:9000/dspace-rdf/presentation/123456789/158307", - "@type": "sc:Manifest" - }, + "@type": "sc:Manifest", + "label": "Corvette" + } + ], + "metadata": [ { - "label": "123456789/158316", - "@id": "http://localhost:9000/dspace-rdf/presentation/123456789/158316", - "@type": "sc:Manifest" + "label": "title", + "value": "Cool Cars" } ], - "viewingHint": "multi-part", - "@type": "sc:Collection", - "@id": "http://localhost:9000/dspace-rdf/collection/123456789/158299", - "@context": "http://iiif.io/api/presentation/2/context.json" + "viewingHint": "multi-part" } \ No newline at end of file diff --git a/src/test/resources/mock/dspace/json/collections.json b/src/test/resources/mock/dspace/json/collections.json index 5cf9ca9..a2655e0 100644 --- a/src/test/resources/mock/dspace/json/collections.json +++ b/src/test/resources/mock/dspace/json/collections.json @@ -1,28 +1,27 @@ { - "logo": "https://brandguide.tamu.edu/assets/downloads/logos/TAM-Logo.png", - "description": "No description available!", - "label": "dspace-rdf:rdf/handle/123456789/158298", - "metadata": [], - "manifests": [], - "viewingHint": "multi-part", - "@type": "sc:Collection", - "@id": "http://localhost:9000/dspace-rdf/collection/123456789/158298", "@context": "http://iiif.io/api/presentation/2/context.json", + "@id": "http://localhost:9000/dspace-rdf/collection/123456789/158298", + "@type": "sc:Collection", "collections": [ { - "label": "123456789/158301", "@id": "http://localhost:9000/dspace-rdf/collection/123456789/158301", - "@type": "sc:Collection" + "@type": "sc:Collection", + "label": "Fast Cars" }, { - "label": "123456789/158299", "@id": "http://localhost:9000/dspace-rdf/collection/123456789/158299", - "@type": "sc:Collection" - }, + "@type": "sc:Collection", + "label": "Cool Cars" + } + ], + "label": "Cars", + "logo": "https://brandguide.tamu.edu/assets/downloads/logos/TAM-Logo.png", + "manifests": [], + "metadata": [ { - "label": "123456789/158300", - "@id": "http://localhost:9000/dspace-rdf/collection/123456789/158300", - "@type": "sc:Collection" + "label": "title", + "value": "Cars" } - ] + ], + "viewingHint": "multi-part" } \ No newline at end of file diff --git a/src/test/resources/mock/dspace/json/presentation-allow.json b/src/test/resources/mock/dspace/json/presentation-allow.json index bb44cfd..c7ee9f2 100644 --- a/src/test/resources/mock/dspace/json/presentation-allow.json +++ b/src/test/resources/mock/dspace/json/presentation-allow.json @@ -1,70 +1,69 @@ { + "@context": "http://iiif.io/api/presentation/2/context.json", + "@id": "http://localhost:9000/dspace-rdf/presentation/123456789/158308?allow=image/png;image/jpeg", + "@type": "sc:Manifest", + "label": "Corvette", "logo": "https://brandguide.tamu.edu/assets/downloads/logos/TAM-Logo.png", - "description": "No description available!", - "label": "dspace-rdf:rdf/handle/123456789/158308", + "metadata": [ + { + "label": "date", + "value": "2018-04-24T13:29:59Z^^http://www.w3.org/2001/XMLSchema#dateTime" + }, + { + "label": "title", + "value": "Corvette" + }, + { + "label": "available", + "value": "2018-04-24T13:29:59Z^^http://www.w3.org/2001/XMLSchema#dateTime" + } + ], "sequences": [ { + "@id": "http://localhost:9000/dspace-rdf/sequence/123456789/158308?allow=image/png;image/jpeg", + "@type": "sc:Sequence", "canvases": [ { + "@id": "http://localhost:9000/dspace-rdf/canvas/123456789/158308/1/sports-car-146873_960_720.png?allow=image/png;image/jpeg", + "@type": "sc:Canvas", "height": 480, "images": [ { + "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/info.json", + "@type": "oa:Annotation", "motivation": "sc:painting", "on": "http://localhost:9000/dspace-rdf/canvas/123456789/158308/1/sports-car-146873_960_720.png?allow=image/png;image/jpeg", "resource": { + "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/full/full/0/default.jpg", + "@type": "dctypes:Image", "format": "image/png; charset=utf-8", "height": 480, - "width": 960, "service": { "label": "DSpace IIIF Image Resource Service", "profile": "http://iiif.io/api/image/2/level0.json", "@context": "http://iiif.io/api/image/2/context.json", "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n" }, - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/full/full/0/default.jpg", - "@type": "dctypes:Image" - }, - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/info.json", - "@type": "oa:Annotation" + "width": 960 + } } ], "label": "1sports-car-146873_960_720.png", - "width": 960, - "@type": "sc:Canvas", - "@id": "http://localhost:9000/dspace-rdf/canvas/123456789/158308/1/sports-car-146873_960_720.png?allow=image/png;image/jpeg" + "width": 960 } ], - "label": "123456789/158308", - "@type": "sc:Sequence", - "@id": "http://localhost:9000/dspace-rdf/sequence/123456789/158308?allow=image/png;image/jpeg" + "label": "Corvette" } ], "thumbnail": { + "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/full/!100,100/0/default.jpg", "services": [ { - "label": "DSpace IIIF Image Resource Service", - "profile": "http://iiif.io/api/image/2/level0.json", "@context": "http://iiif.io/api/image/2/context.json", - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n" + "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n", + "label": "DSpace IIIF Image Resource Service", + "profile": "http://iiif.io/api/image/2/level0.json" } - ], - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/full/!100,100/0/default.jpg" - }, - "@type": "sc:Manifest", - "@id": "http://localhost:9000/dspace-rdf/presentation/123456789/158308?allow=image/png;image/jpeg", - "@context": "http://iiif.io/api/presentation/2/context.json", - "metadata": [ - { - "label": "date", - "value": "2018-04-24T13:29:59Z^^http://www.w3.org/2001/XMLSchema#dateTime" - }, - { - "label": "title", - "value": "Corvette" - }, - { - "label": "available", - "value": "2018-04-24T13:29:59Z^^http://www.w3.org/2001/XMLSchema#dateTime" - } - ] + ] + } } \ No newline at end of file diff --git a/src/test/resources/mock/dspace/json/presentation-disallow.json b/src/test/resources/mock/dspace/json/presentation-disallow.json index 7c8049c..5c65604 100644 --- a/src/test/resources/mock/dspace/json/presentation-disallow.json +++ b/src/test/resources/mock/dspace/json/presentation-disallow.json @@ -1,70 +1,69 @@ { + "@context": "http://iiif.io/api/presentation/2/context.json", + "@id": "http://localhost:9000/dspace-rdf/presentation/123456789/158308?disallow=image/bmp;image/jpeg", + "@type": "sc:Manifest", + "label": "Corvette", "logo": "https://brandguide.tamu.edu/assets/downloads/logos/TAM-Logo.png", - "description": "No description available!", - "label": "dspace-rdf:rdf/handle/123456789/158308", + "metadata": [ + { + "label": "date", + "value": "2018-04-24T13:29:59Z^^http://www.w3.org/2001/XMLSchema#dateTime" + }, + { + "label": "title", + "value": "Corvette" + }, + { + "label": "available", + "value": "2018-04-24T13:29:59Z^^http://www.w3.org/2001/XMLSchema#dateTime" + } + ], "sequences": [ { + "@id": "http://localhost:9000/dspace-rdf/sequence/123456789/158308?disallow=image/bmp;image/jpeg", + "@type": "sc:Sequence", "canvases": [ { + "@id": "http://localhost:9000/dspace-rdf/canvas/123456789/158308/1/sports-car-146873_960_720.png?disallow=image/bmp;image/jpeg", + "@type": "sc:Canvas", "height": 480, "images": [ { + "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/info.json", + "@type": "oa:Annotation", "motivation": "sc:painting", "on": "http://localhost:9000/dspace-rdf/canvas/123456789/158308/1/sports-car-146873_960_720.png?disallow=image/bmp;image/jpeg", "resource": { + "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/full/full/0/default.jpg", + "@type": "dctypes:Image", "format": "image/png; charset=utf-8", "height": 480, - "width": 960, "service": { "label": "DSpace IIIF Image Resource Service", "profile": "http://iiif.io/api/image/2/level0.json", "@context": "http://iiif.io/api/image/2/context.json", "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n" }, - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/full/full/0/default.jpg", - "@type": "dctypes:Image" - }, - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/info.json", - "@type": "oa:Annotation" + "width": 960 + } } ], "label": "1sports-car-146873_960_720.png", - "width": 960, - "@type": "sc:Canvas", - "@id": "http://localhost:9000/dspace-rdf/canvas/123456789/158308/1/sports-car-146873_960_720.png?disallow=image/bmp;image/jpeg" + "width": 960 } ], - "label": "123456789/158308", - "@type": "sc:Sequence", - "@id": "http://localhost:9000/dspace-rdf/sequence/123456789/158308?disallow=image/bmp;image/jpeg" + "label": "Corvette" } ], "thumbnail": { + "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/full/!100,100/0/default.jpg", "services": [ { - "label": "DSpace IIIF Image Resource Service", - "profile": "http://iiif.io/api/image/2/level0.json", "@context": "http://iiif.io/api/image/2/context.json", - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n" + "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n", + "label": "DSpace IIIF Image Resource Service", + "profile": "http://iiif.io/api/image/2/level0.json" } - ], - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/full/!100,100/0/default.jpg" - }, - "@type": "sc:Manifest", - "@id": "http://localhost:9000/dspace-rdf/presentation/123456789/158308?disallow=image/bmp;image/jpeg", - "@context": "http://iiif.io/api/presentation/2/context.json", - "metadata": [ - { - "label": "date", - "value": "2018-04-24T13:29:59Z^^http://www.w3.org/2001/XMLSchema#dateTime" - }, - { - "label": "title", - "value": "Corvette" - }, - { - "label": "available", - "value": "2018-04-24T13:29:59Z^^http://www.w3.org/2001/XMLSchema#dateTime" - } - ] + ] + } } \ No newline at end of file diff --git a/src/test/resources/mock/dspace/json/presentation.json b/src/test/resources/mock/dspace/json/presentation.json index 306b1c3..7750cd4 100644 --- a/src/test/resources/mock/dspace/json/presentation.json +++ b/src/test/resources/mock/dspace/json/presentation.json @@ -1,70 +1,69 @@ { + "@context": "http://iiif.io/api/presentation/2/context.json", + "@id": "http://localhost:9000/dspace-rdf/presentation/123456789/158308", + "@type": "sc:Manifest", + "label": "Corvette", "logo": "https://brandguide.tamu.edu/assets/downloads/logos/TAM-Logo.png", - "description": "No description available!", - "label": "dspace-rdf:rdf/handle/123456789/158308", + "metadata": [ + { + "label": "date", + "value": "2018-04-24T13:29:59Z^^http://www.w3.org/2001/XMLSchema#dateTime" + }, + { + "label": "title", + "value": "Corvette" + }, + { + "label": "available", + "value": "2018-04-24T13:29:59Z^^http://www.w3.org/2001/XMLSchema#dateTime" + } + ], "sequences": [ { + "@id": "http://localhost:9000/dspace-rdf/sequence/123456789/158308", + "@type": "sc:Sequence", "canvases": [ { + "@id": "http://localhost:9000/dspace-rdf/canvas/123456789/158308/1/sports-car-146873_960_720.png", + "@type": "sc:Canvas", "height": 480, "images": [ { + "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/info.json", + "@type": "oa:Annotation", "motivation": "sc:painting", "on": "http://localhost:9000/dspace-rdf/canvas/123456789/158308/1/sports-car-146873_960_720.png", "resource": { + "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/full/full/0/default.jpg", + "@type": "dctypes:Image", "format": "image/png; charset=utf-8", "height": 480, - "width": 960, "service": { "label": "DSpace IIIF Image Resource Service", "profile": "http://iiif.io/api/image/2/level0.json", "@context": "http://iiif.io/api/image/2/context.json", "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n" }, - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/full/full/0/default.jpg", - "@type": "dctypes:Image" - }, - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/info.json", - "@type": "oa:Annotation" + "width": 960 + } } ], "label": "1sports-car-146873_960_720.png", - "width": 960, - "@type": "sc:Canvas", - "@id": "http://localhost:9000/dspace-rdf/canvas/123456789/158308/1/sports-car-146873_960_720.png" + "width": 960 } ], - "label": "123456789/158308", - "@type": "sc:Sequence", - "@id": "http://localhost:9000/dspace-rdf/sequence/123456789/158308" + "label": "Corvette" } ], "thumbnail": { + "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/full/!100,100/0/default.jpg", "services": [ { - "label": "DSpace IIIF Image Resource Service", - "profile": "http://iiif.io/api/image/2/level0.json", "@context": "http://iiif.io/api/image/2/context.json", - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n" + "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n", + "label": "DSpace IIIF Image Resource Service", + "profile": "http://iiif.io/api/image/2/level0.json" } - ], - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/full/!100,100/0/default.jpg" - }, - "@type": "sc:Manifest", - "@id": "http://localhost:9000/dspace-rdf/presentation/123456789/158308", - "@context": "http://iiif.io/api/presentation/2/context.json", - "metadata": [ - { - "label": "date", - "value": "2018-04-24T13:29:59Z^^http://www.w3.org/2001/XMLSchema#dateTime" - }, - { - "label": "title", - "value": "Corvette" - }, - { - "label": "available", - "value": "2018-04-24T13:29:59Z^^http://www.w3.org/2001/XMLSchema#dateTime" - } - ] + ] + } } \ No newline at end of file diff --git a/src/test/resources/mock/dspace/json/sequence.json b/src/test/resources/mock/dspace/json/sequence.json index 73990a9..6750db9 100644 --- a/src/test/resources/mock/dspace/json/sequence.json +++ b/src/test/resources/mock/dspace/json/sequence.json @@ -1,36 +1,35 @@ { + "@id": "http://localhost:9000/dspace-rdf/sequence/123456789/158308", + "@type": "sc:Sequence", "canvases": [ { + "@id": "http://localhost:9000/dspace-rdf/canvas/123456789/158308/1/sports-car-146873_960_720.png", + "@type": "sc:Canvas", "height": 480, "images": [ { + "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/info.json", + "@type": "oa:Annotation", "motivation": "sc:painting", "on": "http://localhost:9000/dspace-rdf/canvas/123456789/158308/1/sports-car-146873_960_720.png", "resource": { + "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/full/full/0/default.jpg", + "@type": "dctypes:Image", "format": "image/png; charset=utf-8", "height": 480, - "width": 960, "service": { "label": "DSpace IIIF Image Resource Service", "profile": "http://iiif.io/api/image/2/level0.json", "@context": "http://iiif.io/api/image/2/context.json", "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n" }, - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/full/full/0/default.jpg", - "@type": "dctypes:Image" - }, - "@id": "http://localhost:8182/iiif/2/ZHNwYWNlLXJkZjp4bWx1aS9iaXRzdHJlYW0vMTIzNDU2Nzg5LzE1ODMwOC8xL3Nwb3J0cy1jYXItMTQ2ODczXzk2MF83MjAucG5n/info.json", - "@type": "oa:Annotation" + "width": 960 + } } ], "label": "1sports-car-146873_960_720.png", - "width": 960, - "@type": "sc:Canvas", - "@id": "http://localhost:9000/dspace-rdf/canvas/123456789/158308/1/sports-car-146873_960_720.png" + "width": 960 } ], - "description": "No description available!", - "label": "123456789/158308", - "@type": "sc:Sequence", - "@id": "http://localhost:9000/dspace-rdf/sequence/123456789/158308" + "label": "123456789/158308" } \ No newline at end of file diff --git a/src/test/resources/mock/dspace/rdf/collection.rdf b/src/test/resources/mock/dspace/rdf/collection.rdf index 902b3b7..cad5bfc 100644 --- a/src/test/resources/mock/dspace/rdf/collection.rdf +++ b/src/test/resources/mock/dspace/rdf/collection.rdf @@ -7,9 +7,10 @@ a bibo:Collection ; - dspace:hasItem , , , , , , ; + dspace:hasItem ; dspace:isPartOfCommunity ; - dcterms:hasPart , , , , , , ; + dcterms:hasPart ; dcterms:isPartOf ; + dcterms:title "Cool Cars" ; void:sparqlEndpoint ; foaf:homepage . \ No newline at end of file diff --git a/src/test/resources/mock/dspace/rdf/community.rdf b/src/test/resources/mock/dspace/rdf/community.rdf index 096191d..09e5a0d 100644 --- a/src/test/resources/mock/dspace/rdf/community.rdf +++ b/src/test/resources/mock/dspace/rdf/community.rdf @@ -7,10 +7,11 @@ a bibo:Collection ; - dspace:hasCollection , , ; + dspace:hasCollection ; dspace:hasSubcommunity ; dspace:isPartOfRepository ; - dcterms:hasPart , , , ; + dcterms:hasPart , ; dcterms:isPartOf ; + dcterms:title "Cars" ; void:sparqlEndpoint ; foaf:homepage . \ No newline at end of file diff --git a/src/test/resources/mock/dspace/rdf/subcommunity.rdf b/src/test/resources/mock/dspace/rdf/subcommunity.rdf index 5568161..1055399 100644 --- a/src/test/resources/mock/dspace/rdf/subcommunity.rdf +++ b/src/test/resources/mock/dspace/rdf/subcommunity.rdf @@ -11,5 +11,6 @@ dspace:isSubcommunityOf ; dcterms:hasPart ; dcterms:isPartOf ; + dcterms:title "Fast Cars" ; void:sparqlEndpoint ; foaf:homepage . \ No newline at end of file diff --git a/src/test/resources/mock/fedora/json/collection.json b/src/test/resources/mock/fedora/json/collection.json index 8d4069f..319e84b 100644 --- a/src/test/resources/mock/fedora/json/collection.json +++ b/src/test/resources/mock/fedora/json/collection.json @@ -1,7 +1,17 @@ { - "logo": "https://brandguide.tamu.edu/assets/downloads/logos/TAM-Logo.png", + "@context": "http://iiif.io/api/presentation/2/context.json", + "@id": "http://localhost:9000/fedora-pcdm/collection/mwbObjects/TGWCatalog", + "@type": "sc:Collection", "description": "A page level collection of The Great War exhibit catalog. The assets are JPEGs created from TIFFs created when the catalog was digitized.", "label": "The Great War Exhibit Catalog", + "logo": "https://brandguide.tamu.edu/assets/downloads/logos/TAM-Logo.png", + "manifests": [ + { + "@id": "http://localhost:9000/fedora-pcdm/presentation/mwbObjects/TGWCatalog/Pages/ExCat0084", + "@type": "sc:Manifest", + "label": "The Great War Exhibit Catalog" + } + ], "metadata": [ { "label": "isPartOf", @@ -28,15 +38,5 @@ "value": "The Great War Exhibit Catalog" } ], - "manifests": [ - { - "label": "fedora-pcdm:mwbObjects/TGWCatalog/Pages/ExCat0084", - "@id": "http://localhost:9000/fedora-pcdm/presentation/mwbObjects/TGWCatalog/Pages/ExCat0084", - "@type": "sc:Manifest" - } - ], - "viewingHint": "multi-part", - "@type": "sc:Collection", - "@id": "http://localhost:9000/fedora-pcdm/collection/mwbObjects/TGWCatalog", - "@context": "http://iiif.io/api/presentation/2/context.json" + "viewingHint": "multi-part" } \ No newline at end of file diff --git a/src/test/resources/mock/fedora/json/image0.json b/src/test/resources/mock/fedora/json/image.json similarity index 100% rename from src/test/resources/mock/fedora/json/image0.json rename to src/test/resources/mock/fedora/json/image.json diff --git a/src/test/resources/mock/fedora/json/sequence.json b/src/test/resources/mock/fedora/json/sequence.json index 73d87b2..e115123 100644 --- a/src/test/resources/mock/fedora/json/sequence.json +++ b/src/test/resources/mock/fedora/json/sequence.json @@ -1,26 +1,30 @@ { + "@id": "http://localhost:9000/fedora-pcdm/sequence/mwbObjects/TGWCatalog/Pages/ExCat0084", + "@type": "sc:Sequence", "canvases": [ { + "@id": "http://localhost:9000/fedora-pcdm/canvas/mwbObjects/TGWCatalog/Pages/ExCat0084", + "@type": "sc:Canvas", "height": 3000, "images": [ { + "@id": "http://localhost:8182/iiif/2/ZmVkb3JhLXBjZG06bXdiT2JqZWN0cy9UR1dDYXRhbG9nL1BhZ2VzL0V4Q2F0MDA4NC9maWxlcy9FeENhdDAwODQuanBn/info.json", + "@type": "oa:Annotation", "motivation": "sc:painting", "on": "http://localhost:9000/fedora-pcdm/canvas/mwbObjects/TGWCatalog/Pages/ExCat0084", "resource": { + "@id": "http://localhost:8182/iiif/2/ZmVkb3JhLXBjZG06bXdiT2JqZWN0cy9UR1dDYXRhbG9nL1BhZ2VzL0V4Q2F0MDA4NC9maWxlcy9FeENhdDAwODQuanBn/full/full/0/default.jpg", + "@type": "dctypes:Image", "format": "image/png; charset=utf-8", "height": 3000, - "width": 2400, "service": { "label": "Fedora IIIF Image Resource Service", "profile": "http://iiif.io/api/image/2/level0.json", "@context": "http://iiif.io/api/image/2/context.json", "@id": "http://localhost:8182/iiif/2/ZmVkb3JhLXBjZG06bXdiT2JqZWN0cy9UR1dDYXRhbG9nL1BhZ2VzL0V4Q2F0MDA4NC9maWxlcy9FeENhdDAwODQuanBn" }, - "@id": "http://localhost:8182/iiif/2/ZmVkb3JhLXBjZG06bXdiT2JqZWN0cy9UR1dDYXRhbG9nL1BhZ2VzL0V4Q2F0MDA4NC9maWxlcy9FeENhdDAwODQuanBn/full/full/0/default.jpg", - "@type": "dctypes:Image" - }, - "@id": "http://localhost:8182/iiif/2/ZmVkb3JhLXBjZG06bXdiT2JqZWN0cy9UR1dDYXRhbG9nL1BhZ2VzL0V4Q2F0MDA4NC9maWxlcy9FeENhdDAwODQuanBn/info.json", - "@type": "oa:Annotation" + "width": 2400 + } } ], "label": "ExCat0084", @@ -46,13 +50,8 @@ "value": "1/5/2018" } ], - "width": 2400, - "@type": "sc:Canvas", - "@id": "http://localhost:9000/fedora-pcdm/canvas/mwbObjects/TGWCatalog/Pages/ExCat0084" + "width": 2400 } ], - "description": "Back Cover", - "label": "ExCat0084", - "@type": "sc:Sequence", - "@id": "http://localhost:9000/fedora-pcdm/sequence/mwbObjects/TGWCatalog/Pages/ExCat0084" + "label": "ExCat0084" } \ No newline at end of file