diff --git a/Jenkinsfile b/Jenkinsfile index c46a3a12f0e46740faa95eb11d3291b65184cec2..97786591986729ccbf4e6c9fbe05e30f1af129e0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -19,8 +19,14 @@ node { if (snapshot) { // doDebSnapshot(pName, 'oaipmh-webapp/target', pVersion) } +<<<<<<< HEAD else { // doDebRelease(pName, 'oaipmh-webapp/target', pVersion) } +======= + //else { + // doDebRelease(pName, 'oaipmh-webapp/target', pVersion) + //} +>>>>>>> feature/elastic6 } } diff --git a/oaipmh-core/pom.xml b/oaipmh-core/pom.xml index 2a0b99040a2638315216598ebe92b427d4e35ad5..12815de90c27bf3a1f3fa2ab506126333d4cd109 100644 --- a/oaipmh-core/pom.xml +++ b/oaipmh-core/pom.xml @@ -11,13 +11,27 @@ <artifactId>oaipmh-core</artifactId> <packaging>jar</packaging> <name>DARIAHDE :: OAI-PMH DataProvider :: Core</name> - <url>http://maven.apache.org</url> - -<dependencies> -<dependency> + <url>https://projects.gwdg.de/projects/oai-pmh</url> + <dependencies> + <dependency> + <groupId>org.eclipse.rdf4j</groupId> + <artifactId>rdf4j-repository-api</artifactId> + <version>3.0.2</version> + </dependency> + <dependency> <groupId>info.textgrid.middleware</groupId> - <artifactId>crud-common</artifactId> - <version>${tgcrud.version}</version> + <artifactId>const</artifactId> + <version>${common.version}</version> + </dependency> + <dependency> + <groupId>info.textgrid.utils</groupId> + <artifactId>httpclients</artifactId> + <version>${common.version}</version> + </dependency> + <dependency> + <groupId>info.textgrid.middleware.clients</groupId> + <artifactId>textgrid-clients</artifactId> + <version>${common.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> @@ -51,15 +65,10 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.elasticsearch</groupId> - <artifactId>elasticsearch</artifactId> + <groupId>org.elasticsearch.client</groupId> + <artifactId>elasticsearch-rest-high-level-client</artifactId> <version>${elasticsearch.version}</version> </dependency> - <dependency> - <groupId>info.textgrid.utils</groupId> - <artifactId>httpclients</artifactId> - <version>${tghttpclients.version}</version> - </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> @@ -85,13 +94,28 @@ <dependency> <groupId>org.classicmayan.tools</groupId> <artifactId>metsModsMapping</artifactId> - <version>1.1.13</version> + <version>1.1.9</version> </dependency> <dependency> <groupId>de.shadowhunt.maven.plugins</groupId> <artifactId>package-info-maven-plugin</artifactId> <version>1.4.5</version> </dependency> + <!-- https://mvnrepository.com/artifact/org.json/json --> + <dependency> + <groupId>org.json</groupId> + <artifactId>json</artifactId> + <version>20190722</version> + </dependency> + +<!-- https://mvnrepository.com/artifact/com.thoughtworks.xstream/xstream --> +<dependency> + <groupId>com.thoughtworks.xstream</groupId> + <artifactId>xstream</artifactId> + <version>1.4.12</version> +</dependency> + + </dependencies> <build> <pluginManagement> diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/DARIAHConstants.java b/oaipmh-core/src/main/java/info/textgrid/middleware/DARIAHConstants.java index 35fd6de95723ad75da30714d03a3504a8eae86bb..b3d4938062688a0b46f3ae0ac54d7a26b95a5dbf 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/DARIAHConstants.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/DARIAHConstants.java @@ -4,15 +4,20 @@ import java.util.Arrays; import java.util.List; /** - * Collection of values never changing its content + * <p> + * Collection of values never changing its content. + * </p> * - * @author Maximilian Brodhun: SUB + * @author Maximilian Brodhun, SUB Göttingen */ public final class DARIAHConstants { + /** + * + */ private DARIAHConstants() { - // not called + // } public static final String ITEM_IDENTIFIER_PREFIX = "hdl:"; @@ -21,48 +26,33 @@ public final class DARIAHConstants { public static final List<String> TEXTGRID_REP_ADMIN_CONTACT = Arrays.asList("support@de.dariah.eu"); - /* - * Rep Identification String Constants - */ - + // Rep Identification String Constants public static final String DARIAH_REP_BASEURL = "repository.de.dariah.eu"; public static final String METADATA_DC_PREFIX = "rdf:RDF/rdf:Description"; - /* - * Error String Constants - */ - + // Error String Constants public static final String OAI_BAD_ARGUMENT = "BadArgument"; public static final String OAI_METADATA_FORMAT_ERROR = "FormatError"; public static final String OAI_NO_RECORD_MATCH = "RecordMatchError"; public static final String OAI_NO_SET_HIERARCHY = "SetHierarchyError"; - /* - * TextGrid Metadata Fields for OAI-PMH Request (Mapping to DC) - */ - + // TextGrid Metadata Fields for OAI-PMH Request (Mapping to DC) public static final String CREATED = "descriptiveMetadata.dc:date"; public static final String FORMAT = "descriptiveMetadata.dc:format"; public static final String IDENTIFIER = "administrativeMetadata.dcterms:identifier"; public static final String DATA_CONTRIBUTOR = "descriptiveMetadata.dc:contributor"; - - public static final String[] DARIAHFields = { - "descriptiveMetadata.dc:contributor", "descriptiveMetadata.dc:coverage", - "administrativeMetadata.dcterms:created", "administrativeMetadata.dcterms:modified", - "descriptiveMetadata.dc:description", "descriptiveMetadata.dc:format", - "descriptiveMetadata.dc:identifier", "descriptiveMetadata.dc:language", - "descriptiveMetadata.dc:publisher", "descriptiveMetadata.dc:relation", - "descriptiveMetadata.dc:rights", "descriptiveMetadata.:source", - "descriptiveMetadata.dc:subject", - "descriptiveMetadata.dc:title", "descriptiveMetadata.dc:type", - "administrativeMetadata.dcterms:identifier"}; - + public static final String[] DARIAHFields = + {"descriptiveMetadata.dc:contributor", "descriptiveMetadata.dc:coverage", + "administrativeMetadata.dcterms:created", "administrativeMetadata.dcterms:modified", + "descriptiveMetadata.dc:description", "descriptiveMetadata.dc:format", + "descriptiveMetadata.dc:identifier", "descriptiveMetadata.dc:language", + "descriptiveMetadata.dc:publisher", "descriptiveMetadata.dc:relation", + "descriptiveMetadata.dc:rights", "descriptiveMetadata.:source", + "descriptiveMetadata.dc:subject", "descriptiveMetadata.dc:title", + "descriptiveMetadata.dc:type", "administrativeMetadata.dcterms:identifier"}; public static final String[] DARIAHCollectionFields = {"metadata.dc:title"}; - /* - * String Arrays to define which TextGrid fields belongs to the regarding DC fields - */ - + // String Arrays to define which TextGrid fields belongs to the regarding DC fields public static final String[] CONTRIBUTOR_LIST = {"descriptiveMetadata.dc:contributor"}; public static final String[] COVERAGE_LIST = {"descriptiveMetadata.dc:coverage"}; public static final String[] CREATOR_LIST = {"descriptiveMetadata.dc:cretor"}; diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/DublinCoreBuilder.java b/oaipmh-core/src/main/java/info/textgrid/middleware/DublinCoreBuilder.java index fefc729da89cd9e6262f7387b788f57e40cd764a..c9d9c5b1ae8510d53b60023aee3144947d0d80c9 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/DublinCoreBuilder.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/DublinCoreBuilder.java @@ -1,7 +1,10 @@ package info.textgrid.middleware; +import java.text.ParseException; import java.util.List; import javax.xml.bind.JAXBElement; +import javax.xml.datatype.DatatypeConfigurationException; + import info.textgrid.middleware.oaipmh.ElementType; import info.textgrid.middleware.oaipmh.MetadataType; import info.textgrid.middleware.oaipmh.OaiDcType; @@ -27,6 +30,7 @@ public final class DublinCoreBuilder { // MetadataType of OAI schema. private MetadataType metadata = new MetadataType(); + // OAI_DC type of oai_dc schema. private OaiDcType tgMappedDC = new OaiDcType(); @@ -104,12 +108,14 @@ public final class DublinCoreBuilder { * </p> * * @param dates + * @throws DatatypeConfigurationException + * @throws ParseException */ - public void setDate(List<String> dates) { + public void setDate(List<String> dates) throws ParseException, DatatypeConfigurationException { for (String dcdate : dates) { ElementType dateElement = new ElementType(); JAXBElement<ElementType> dcCoreDate = oaiDcObj.createDate(dateElement); - dateElement.setValue(dcdate); + dateElement.setValue(OAIPMHUtilities.convertDateFormat(dcdate).toString()); this.tgMappedDC.getTitleOrCreatorOrSubject().add(dcCoreDate); } } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/DublinCoreFieldLoader.java b/oaipmh-core/src/main/java/info/textgrid/middleware/DublinCoreFieldLoader.java index 23a08fc77dcc0abea9f41cb865cf3c373df9ae56..e297994616716a23c56de181ef691589e9df8f0c 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/DublinCoreFieldLoader.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/DublinCoreFieldLoader.java @@ -3,8 +3,8 @@ package info.textgrid.middleware; import java.text.ParseException; import java.util.ArrayList; import java.util.List; +import java.util.Map; import javax.xml.datatype.DatatypeConfigurationException; -import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.search.SearchHit; @@ -12,140 +12,34 @@ import org.elasticsearch.search.SearchHit; /** * <p> * The Dublin Core Field Loader takes the results of the ElasticSearch request and puts them into a - * String-List. For each element of Dublin Core exists a seperate list. + * String-List. For each element of Dublin Core exists a separate list. * </p> * * <p> * For each element two functions are necessary because the datatype "SeachHit" could contain more - * then one results and the GetResponse just one + * then one results and the GetResponse just one. * </p> * * @author Maximilian Brodhun, SUB Göttingen * @author Stefan E. Funk, SUB Göttingen - * @version 24.05.2019 - * @since 18.02.2014 + * @version 2019-10-29 + * @since 2014-02-18 */ public class DublinCoreFieldLoader { - private static Log log = LogFactory.getLog(OAIPMHImpl.class); + // ** + // STATICS + // ** - /** - * @param hit contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core - */ - public static List<String> setContributor(SearchHit hit, String[] fields) { - - List<String> contributors = new ArrayList<String>(); - - for (String field : fields) { - if (hit.getFields().get(field) != null) { - contributors.add(hit.getFields().get(field).values().get(0) - .toString()); - } - } - - return contributors; - } + private static org.apache.commons.logging.Log log = LogFactory.getLog(OAIPMHImpl.class); /** - * @param responseWorkValues contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core + * This function takes the results of the ElasticSearch resuest + * and fills the String-Lists with the specific values for the dublin core field + * @param responseOfGetRequest result of the ElasticSearch request from a getRequest (Single Result) + * @param fields String List for the specific dublin core field + * @return String List containing the values for the specific dublin core field */ - public static List<String> setContributor(GetResponse responseWorkValues, String[] fields) { - - List<String> contributors = new ArrayList<String>(); - - if (responseWorkValues.isExists()) { - for (String field : fields) { - if (responseWorkValues.getField(field) != null) { - contributors.add(responseWorkValues.getField(field).getValue().toString()); - } - } - } - - return contributors; - } - - - /** - * @param responseWorkValues contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core - */ - public static List<String> setCreator(GetResponse responseWorkValues, String[] fields) { - - List<String> creators = new ArrayList<String>(); - - if (responseWorkValues.isExists()) { - for (String field : fields) { - if (responseWorkValues.getField(field) != null) { - creators.add(responseWorkValues.getField(field).getValue().toString()); - } - } - } - - return creators; - } - - /** - * @param hit contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core - */ - public static List<String> setCreator(SearchHit hit, String[] fields) { - - List<String> creators = new ArrayList<String>(); - - for (String field : fields) { - if (hit.getFields().get(field) != null) { - creators.add(hit.getFields().get(field).values().get(0) - .toString()); - } - } - - return creators; - } - - /** - * @param responseWorkValues contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core - */ - public static List<String> setCoverage(GetResponse responseWorkValues, String[] fields) { - - List<String> coverages = new ArrayList<String>(); - - if (responseWorkValues.isExists()) { - for (String field : fields) { - if (responseWorkValues.getField(field) != null) { - coverages.add(responseWorkValues.getField(field).getValue().toString()); - } - } - } - - return coverages; - } - - /** - * @param hit contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core - */ - public static List<String> setCoverage(SearchHit hit, String[] fields) { - - List<String> coverages = new ArrayList<String>(); - - for (String field : fields) { - if (hit.getFields().get(field) != null) { - coverages.add(hit.getFields().get(field).values().get(0) - .toString()); - } - } - - return coverages; - } /** * @param responseWorkValues contains results of the ElasticSearch request @@ -154,8 +48,12 @@ public class DublinCoreFieldLoader { */ public static List<String> setDate(GetResponse responseWorkValues, String[] fields) { + // TODO We don't need this here, I suppose? We have to check the dates here! + // return fillList(responseWorkValues, fields); + List<String> dates = new ArrayList<String>(); + // Transform to OAI-PMH certificated time stamp if (responseWorkValues.isExists()) { for (String field : fields) { try { @@ -193,12 +91,15 @@ public class DublinCoreFieldLoader { List<String> dates = new ArrayList<String>(); + // FIXME TADAA? + System.out.println("TADA"); + for (String field : fields) { if (hit.getFields().get(field) != null) { - try { - dates.add(OAIPMHUtilities.convertDateFormat( - hit.getFields().get(field).values().get(0).toString()).toXMLFormat()); + dates.add(OAIPMHUtilities + .convertDateFormat(hit.getFields().get(field).getValues().get(0).toString()) + .toXMLFormat()); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -212,466 +113,87 @@ public class DublinCoreFieldLoader { return dates; } - /** - * @param responseWorkValues contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core - */ - public static List<String> setDescription(GetResponse responseWorkValues, String[] fields) { - - List<String> descriptions = new ArrayList<String>(); - - if (responseWorkValues.isExists()) { - for (String field : fields) { - if (responseWorkValues.getField(field) != null) { - descriptions.add(responseWorkValues.getField(field).getValue().toString()); - } - } - } - - return descriptions; - } - - /** - * @param hit contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core - */ - public static List<String> setDescription(SearchHit hit, String[] fields) { - - List<String> descriptions = new ArrayList<String>(); - - for (String field : fields) { - if (hit.getFields().get(field) != null) { - descriptions.add(hit.getFields().get(field).values().get(0) - .toString()); - } - } - - return descriptions; - } - - /** - * @param hit contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core - */ - public static List<String> setFormat(SearchHit hit, String[] fields) { - - List<String> formats = new ArrayList<String>(); - - for (String field : fields) { - if (hit.getFields().get(field) != null) { - formats.add(hit.getFields().get(field).values().get(0) - .toString()); - } - } - - return formats; - } - - /** - * @param responseWorkValues contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core - */ - public static List<String> setFormat(GetResponse responseWorkValues, String[] fields) { - - List<String> formats = new ArrayList<String>(); - - if (responseWorkValues.isExists()) { - for (String field : fields) { - if (responseWorkValues.getField(field) != null) { - formats.add(responseWorkValues.getField(field).getValue().toString()); - } - } - } - - return formats; - } - - /** - * @param hit contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core - */ - public static List<String> setIdentifier(SearchHit hit, String[] fields) { - - List<String> identifiers = new ArrayList<String>(); - String identifier = ""; - for (String field : fields) { - if (hit.getFields().get(field) != null) { - for (int i = 0; i < hit.getFields().get(field).getValues().size(); i++) { - if (hit.getFields().get(field).values().get(i).toString().startsWith("textgrid")) { - identifier = hit.getFields().get(field).values().get(i).toString(); - identifier = identifier.replace(identifier, "https://textgridrep.org/" + identifier); - identifiers.add(identifier); + public static List<String> fillList(GetResponse responseWorkValues, String[] fields) { + + List<String> list = new ArrayList<String>(); + + if (responseWorkValues.isExists()) { + if (fields != null) { + for (String field : fields) { + if (responseWorkValues.getSourceAsMap().get(field) == null) { + String[] requestedField = field.split("\\."); + Map<String, Object> nestedMap = responseWorkValues.getSourceAsMap(); + String valueOfRequestedField = null; + Map<String, Object> nestedMap2 = null; + for (int i = 0; i < requestedField.length; i++) { + if (i < requestedField.length - 1 && nestedMap != null + && nestedMap.get(requestedField[i]) != null) { + + nestedMap2 = (Map<String, Object>) nestedMap.get(requestedField[i]); + } + if (i == requestedField.length - 1 && + nestedMap2 != null && nestedMap2.get(requestedField[i]) != null) { + valueOfRequestedField = nestedMap2.get(requestedField[i]).toString(); + + if (valueOfRequestedField.length() > 0) { + + list.add(valueOfRequestedField); + } + } + nestedMap = nestedMap2; + } } else { - identifiers.add(hit.getFields().get(field).values().get(i).toString()); + + list.add(responseWorkValues.getSourceAsMap().get(field).toString()); } } } } - - return identifiers; + return list; } /** - * @param responseWorkValues contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core - */ - public static List<String> setIdentifier(GetResponse responseWorkValues, String[] fields) { - - List<String> identifiers = new ArrayList<String>(); - - if (responseWorkValues.isExists()) { - for (String field : fields) { - - if (responseWorkValues.getField(field) != null) { - List<Object> entireIdentifier = responseWorkValues.getField(field).getValues(); - for (int i = 0; i < responseWorkValues.getField(field).getValues().size(); i++) { - identifiers.add(entireIdentifier.get(i).toString()); - } - } - } - } - - return identifiers; - } - - /** - * @param hit contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core - */ - public static List<String> setLanguage(SearchHit hit, String[] fields) { - - List<String> languages = new ArrayList<String>(); - - for (String field : fields) { - if (hit.getFields().get(field) != null) { - languages.add(hit.getFields().get(field).values().get(0).toString()); - } - } - - return languages; - } - - /** - * @param responseWorkValues contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core - */ - public static List<String> setLanguage(GetResponse responseWorkValues, String[] fields) { - - List<String> languages = new ArrayList<String>(); - - if (responseWorkValues.isExists()) { - for (String field : fields) { - if (responseWorkValues.getField(field) != null) { - languages.add(responseWorkValues.getField(field).getValue().toString()); - } - } - } - - return languages; - } - - /** - * @param hit contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core - */ - public static List<String> setPublisher(SearchHit hit, String[] fields) { - - List<String> publishers = new ArrayList<String>(); - - for (String field : fields) { - if (hit.getFields().get(field) != null) { - publishers.add(hit.getFields().get(field).values().get(0).toString()); - } - } - - return publishers; - } - - /** - * @param responseWorkValues contains results of the ElasticSearch request + * @param hit * @param fields - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core - */ - public static List<String> setPublisher(GetResponse responseWorkValues, String[] fields) { - - List<String> publishers = new ArrayList<String>(); - - if (responseWorkValues.isExists()) { - for (String field : fields) { - if (responseWorkValues.getField(field) != null) { - publishers.add(responseWorkValues.getField(field).getValue().toString()); - } - } - } - - return publishers; - } - - /** - * @param hit contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core + * @return */ - public static List<String> setRelation(SearchHit hit, String[] fields) { + public static List<String> fillList(SearchHit hit, String[] fields) { - List<String> relations = new ArrayList<String>(); - - for (String field : fields) { - if (hit.getFields().get(field) != null) { - for (int i = 0; i < hit.getFields().get(field).getValues().size(); i++) { - relations.add(hit.getFields().get(field).values().get(i).toString()); - } - } - } - - return relations; - } - - /** - * @param responseWorkValues contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core - */ - public static List<String> setRelation(GetResponse responseWorkValues, String[] fields) { - - List<String> relations = new ArrayList<String>(); - - if (responseWorkValues.isExists()) { + List<String> list = new ArrayList<String>(); + + if (fields != null) { for (String field : fields) { - if (responseWorkValues.getField(field) != null) { - relations.add(responseWorkValues.getField(field).getValue().toString()); - } - } - } - - return relations; - } - - /** - * @param responseWorkValues contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core - */ - public static List<String> setRelationForWork(GetResponse responseWorkValues, String[] fields) { - - List<String> relations = new ArrayList<String>(); - - if (responseWorkValues.isExists()) { - for (String field : fields) { - if (responseWorkValues.getField(field) != null) { - relations.add(responseWorkValues.getField(field).getValue().toString()); - } - } - } - - return relations; - } - - /** - * @param hit contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core - */ - public static List<String> setRights(SearchHit hit, String[] fields) { - - List<String> rights = new ArrayList<String>(); - - for (String field : fields) { - if (hit.getFields().get(field) != null) { - rights.add(hit.getFields().get(field).values().get(0).toString()); - } - } - - return rights; - } - - /** - * @param responseWorkValues contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core - */ - public static List<String> setRights(GetResponse responseWorkValues, String[] fields) { - - List<String> rights = new ArrayList<String>(); - - if (responseWorkValues.isExists()) { - for (String field : fields) { - if (responseWorkValues.getField(field) != null) { - rights.add(responseWorkValues.getField(field).getValue().toString()); - } - } - } - - return rights; - } - - /** - * @param hit contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core - */ - public static List<String> setSources(SearchHit hit, String[] fields) { - - List<String> sources = new ArrayList<String>(); - - for (String field : fields) { - if (hit.getFields().get(field) != null) { - sources.add(hit.getFields().get(field).values().get(0).toString()); - } - } - - return sources; - } - - /** - * @param responseWorkValues contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core - */ - public static List<String> setSources(GetResponse responseWorkValues, String[] fields) { - - List<String> sources = new ArrayList<String>(); - - if (responseWorkValues.isExists()) { - for (String field : fields) { - if (responseWorkValues.getField(field) != null) { - sources.add(responseWorkValues.getField(field).getValue().toString()); - } - } - } - - return sources; - } - - /** - * @param responseWorkValues contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core - */ - public static List<String> setSubject(GetResponse responseWorkValues, String[] fields) { - - List<String> subjects = new ArrayList<String>(); - - for (String field : fields) { - if (responseWorkValues.getField(field) != null) { - subjects.add(responseWorkValues.getField(field).getValue().toString()); - } - } - - return subjects; - } - - /** - * @param hit contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core - */ - public static List<String> setSubject(SearchHit hit, String[] fields) { - - List<String> subjects = new ArrayList<String>(); - - for (String field : fields) { - if (hit.getFields().get(field) != null) { - subjects.add(hit.getFields().get(field).values().get(0).toString()); - } - } - - return subjects; - } - - /** - * @param hit contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core - */ - public static List<String> setTitle(SearchHit hit, String[] fields) { - - List<String> titles = new ArrayList<String>(); - - for (String field : fields) { - if (hit.getFields().get(field) != null) { - for (int i = 0; i < hit.getFields().get(field).getValues().size(); i++) { - titles.add(hit.getFields().get(field).values().get(i).toString()); - } - } - } - - return titles; - } - - /** - * @param responseWorkValues contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core - */ - public static List<String> setTitle(GetResponse responseWorkValues, String[] fields) { - - List<String> titles = new ArrayList<String>(); - - if (responseWorkValues.isExists()) { - for (String field : fields) { - List<Object> entireTitles = responseWorkValues.getField(field).getValues(); - if (responseWorkValues.getField(field) != null) { - for (int i = 0; i < responseWorkValues.getField(field).getValues().size(); i++) { - titles.add(entireTitles.get(i).toString()); + if (hit.getSourceAsMap().get(field) == null) { + String[] requestedField = field.split("\\."); + Map<String, Object> nestedMap = hit.getSourceAsMap(); + String valueOfRequestedField = null; + Map<String, Object> nestedMap2 = null; + for (int i = 0; i < requestedField.length; i++) { + if (i < requestedField.length - 1 && nestedMap != null + && nestedMap.get(requestedField[i]) != null) { + try { + nestedMap2 = (Map<String, Object>) nestedMap.get(requestedField[i]); + } catch (ClassCastException cce) { + + } + } + if (i == requestedField.length - 1 && + nestedMap2 != null && nestedMap2.get(requestedField[i]) != null) { + valueOfRequestedField = nestedMap2.get(requestedField[i]).toString(); + if (valueOfRequestedField.length() > 0) { + list.add(valueOfRequestedField); + } + } + nestedMap = nestedMap2; } + } else { + list.add(hit.getSourceAsMap().get(field).toString()); } } } - return titles; - } - - /** - * @param responseWorkValues contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core - */ - public static List<String> setType(GetResponse responseWorkValues, String[] fields) { - - List<String> types = new ArrayList<String>(); - - if (responseWorkValues.isExists()) { - if (fields != null) { - for (String field : fields) { - if (responseWorkValues.getField(field) != null) { - types.add(responseWorkValues.getField(field).getValue().toString()); - } - } - } - } - - return types; - } - - /** - * @param hit contains results of the ElasticSearch request - * @param fields containing all fields from ElasticSearch related to this Dublin Core field - * @return all elements mapped from TetxGrid metadata scheme to Dublin Core - */ - public static List<String> setType(SearchHit hit, String[] fields) { - - List<String> types = new ArrayList<String>(); - - for (String field : fields) { - if (hit.getFields().get(field) != null) { - for (int i = 0; i < hit.getFields().get(field).getValues().size(); i++) { - types.add(hit.getFields().get(field).values().get(i).toString()); - } - } - } - - return types; + return list; } } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/ErrorHandler.java b/oaipmh-core/src/main/java/info/textgrid/middleware/ErrorHandler.java index 0179698bacf690b712cdebaf30228a6e3d8c6ff7..7ee3483ee6630e3c3247bb7e5f05c1637aa27cf1 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/ErrorHandler.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/ErrorHandler.java @@ -27,14 +27,14 @@ public class ErrorHandler { if (errorDescription.equals("BadArgument")) { this.errorCode = OAIPMHerrorcodeType.BAD_ARGUMENT; - } else if (errorDescription.equals("ResumptionTokenError")) { + } else if (errorDescription.equals("badResumptionToken")) { this.errorCode = OAIPMHerrorcodeType.BAD_RESUMPTION_TOKEN; } else if (errorDescription.equals("VerbError")) { this.errorCode = OAIPMHerrorcodeType.BAD_VERB; this.error.setValue("Illegal OAI-PMH verb"); } else if (errorDescription.equals("FormatError")) { this.errorCode = OAIPMHerrorcodeType.CANNOT_DISSEMINATE_FORMAT; - } else if (errorDescription.equals("IDError")) { + } else if (errorDescription.equals("idDoesNotExist")) { this.errorCode = OAIPMHerrorcodeType.ID_DOES_NOT_EXIST; } else if (errorDescription.equals("MetadataFormatError")) { this.error.setValue("There are no metadata formats available for the specified item."); @@ -42,7 +42,9 @@ public class ErrorHandler { this.errorCode = OAIPMHerrorcodeType.NO_RECORDS_MATCH; } else if (errorDescription.equals("SetHierarchyError")) { this.errorCode = OAIPMHerrorcodeType.NO_SET_HIERARCHY; - } + } else if (errorDescription.equals("badVerb")) { + this.errorCode = OAIPMHerrorcodeType.BAD_VERB; + } this.error.setCode(this.errorCode); this.error.setValue(errorValue); diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererAbstract.java b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererAbstract.java index b94d7206b13f27d818585ef1abd7b61ebecca228..53c51563491ae2928fee1851fd69c4f874c207a7 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererAbstract.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererAbstract.java @@ -1,9 +1,33 @@ package info.textgrid.middleware; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.text.ParseException; import java.util.ArrayList; +import java.util.Hashtable; import java.util.List; +import java.util.Map; +import java.util.Properties; + +//import javax.swing.plaf.synth.SynthSpinnerUI; + +import org.apache.commons.logging.LogFactory; +import org.elasticsearch.action.search.SearchRequest; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.search.SearchScrollRequest; +import org.elasticsearch.client.RequestOptions; +import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.index.query.QueryBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.search.SearchHit; +import org.elasticsearch.search.builder.SearchSourceBuilder; + import info.textgrid.middleware.oaipmh.ListIdentifiersType; import info.textgrid.middleware.oaipmh.RequestType; +import info.textgrid.middleware.oaipmh.ResumptionTokenType; +import info.textgrid.namespaces.middleware.tgcrud.common.TextGridMimetypes; /** * @@ -12,7 +36,16 @@ public abstract class IdentifierListDelivererAbstract implements IdentifierListD protected boolean textgrid; protected boolean dariah; - + private boolean foundItems; + private long resultSize; + private int searchResponseSize; + public String rangeField; + + protected static Map<String, Integer> cursorCollector = new Hashtable<String, Integer>(); + public ResumptionTokenType resTokenForResponse; + + private static org.apache.commons.logging.Log log = LogFactory.getLog(RecordListDelivererAbstract.class); + /** * @param textgrid * @param dariah @@ -29,11 +62,141 @@ public abstract class IdentifierListDelivererAbstract implements IdentifierListD * String, java.lang.String, java.lang.String, java.lang.String) */ @Override - public ListIdentifiersType processIdentifierList(String from, String to, String set, - String resumptionToken) { + public ListIdentifiersType processIdentifierList(String from, String until, String set, + String resumptionToken) throws IOException, ParseException { return null; } + + public List<String> getUriListOfAllEditions(String from, String until, String set, String resumptionToken) throws IOException { + + /* InputStream input = null; + try { + input = new FileInputStream("/etc/dhrep/oaipmh/oaipmh.properties"); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + Properties prop = new Properties(); + prop.load(input);*/ + + QueryBuilder query; + + System.out.println("FROM: " + from); + System.out.println("TO: " + until); + + QueryBuilder rangeQuery = QueryBuilders.rangeQuery("created").from(from).to(until); + QueryBuilder filterSandBox = QueryBuilders.matchPhraseQuery("nearlyPublished", "true"); + if(set!=null) { + String[] setParts = set.split(":"); + + String queryField = ""; + String valueField = ""; + + if (setParts[0].equals(TGConstants.SET_FIELD_FOR_TEXTGRID)) { + queryField = TGConstants.PROJECT_ID_FOR_TEXTGRID; + valueField = setParts[1]; + } + System.out.println(""); + QueryBuilder matchQuery = QueryBuilders.matchPhraseQuery(queryField, valueField); + QueryBuilder boolQuery = QueryBuilders.boolQuery().must(rangeQuery).must(matchQuery).mustNot(filterSandBox); + + query = boolQuery; + }else { + query = QueryBuilders.boolQuery().must(rangeQuery).mustNot(filterSandBox); + } + + return getConentFromESIndex(query, resumptionToken, set); + } + + private List<String> getConentFromESIndex(QueryBuilder query, String resumptionToken, + String set) throws IOException { + + List<String> uriList = new ArrayList<String>(); + QueryBuilder recordFilter = QueryBuilders.boolQuery().must(query) + .must(QueryBuilders.matchPhraseQuery(TGConstants.FORMAT, TextGridMimetypes.EDITION)); + + SearchRequest searchRequest = new SearchRequest(OAI_ESClient.getEsIndex()); + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); + + /* InputStream input = null; + try { + input = new FileInputStream("/etc/dhrep/oaipmh/oaipmh.properties"); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + Properties prop = new Properties(); + prop.load(input);*/ + + searchSourceBuilder.query(recordFilter); + searchSourceBuilder.size(100); + searchRequest.source(searchSourceBuilder); + + SearchResponse scrollResp = new SearchResponse(); + + if (resumptionToken != null) { + SearchScrollRequest scrollRequest = new SearchScrollRequest(resumptionToken); + scrollRequest.scroll(TimeValue.timeValueHours(24L)); + + try { + scrollResp = OAI_ESClient.getEsClient().scroll(scrollRequest, RequestOptions.DEFAULT); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else { + searchRequest.source(searchSourceBuilder); + searchRequest.scroll(TimeValue.timeValueHours(24L)); + try { + scrollResp = OAI_ESClient.getEsClient().search(searchRequest,RequestOptions.DEFAULT); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + String scrollID = scrollResp.getScrollId(); + long completeListSize = scrollResp.getHits().totalHits; + setResultSize(completeListSize); + + if (completeListSize > 0) { + + setFoundItems(true); + int i=0; + + for (SearchHit hit : scrollResp.getHits().getHits()) { + i++; + if (hit != null && hit.getFields() != null) { + uriList.add(hit.getSourceAsMap().get(TGConstants.URI).toString()); + } + } + + if(resumptionToken!=null && resTokenForResponse.getCursor().intValue()>=completeListSize) { + try{ + cursorCollector.remove(resumptionToken); + }catch(NullPointerException couldNotRemove) { + log.info("Could net remove hash value: " + resumptionToken + " from hash map"); + } + resTokenForResponse.setValue(""); + }else { + + resTokenForResponse = OAIPMHUtilities.getResumptionToken( + completeListSize, resumptionToken, cursorCollector, scrollID, this.searchResponseSize, i); + } + + }else { + setFoundItems(false); + } + + + return uriList; + + } + + /** * @param request * @return @@ -44,8 +207,9 @@ public abstract class IdentifierListDelivererAbstract implements IdentifierListD // Check if metadata prefix is existing and valid. if (request.getMetadataPrefix() != null - && !request.getMetadataPrefix().equals(TGConstants.METADATA_DC_PREFIX) - && !request.getMetadataPrefix().equals(TGConstants.METADATA_IDIOM_PREFIX)) { + && !request.getMetadataPrefix().equals(OAIPMHUtilities.OAIDC_PREFIX) + && !request.getMetadataPrefix().equals(TGConstants.METADATA_IDIOM_PREFIX) + && !request.getMetadataPrefix().equals(TGConstants.METADATA_OPENAIRE_PREFIX)) { result.setError(TGConstants.OAI_METADATA_FORMAT_ERROR, "The value of the metadataPrefix: " + request.getMetadataPrefix() + " is not supported by the item identified by the value of: " @@ -54,21 +218,22 @@ public abstract class IdentifierListDelivererAbstract implements IdentifierListD // Check if resumptionToken is invalid or existing. if (request.getResumptionToken() != null) { - boolean restokDCExisting = RecordListDelivererIDIOM.cursorCollector != null - && RecordListDelivererIDIOM.cursorCollector.containsKey(request.getResumptionToken()); - boolean restokIDIOMExisting = RecordListDelivererDC.cursorCollector != null - && RecordListDelivererDC.cursorCollector.containsKey(request.getResumptionToken()); - if (restokDCExisting || restokIDIOMExisting) { - result.setError(TGConstants.OAI_BAD_RESUMPTION_TOKEN, "The value of the " + boolean restokDCExisting = IdentifierListDelivererDC.cursorCollector != null + && IdentifierListDelivererDC.cursorCollector.containsKey(request.getResumptionToken()); + boolean restokIDIOMExisting = IdentifierListDelivererIDIOM.cursorCollector != null + && IdentifierListDelivererDC.cursorCollector.containsKey(request.getResumptionToken()); + boolean restok = cursorCollector != null + && cursorCollector.containsKey(request.getResumptionToken()); + + if (!restokDCExisting && !restokIDIOMExisting && !restok) { + + result.setError(TGConstants.OAI_BAD_RESUMPTION_TOKEN, "The value of the " + request.getResumptionToken() + " argument is invalid or expired."); } } List<String> errorValues = new ArrayList<String>(); - if (request.getResumptionToken() != null && request.getMetadataPrefix() != null) { - errorValues.add("metadataPrefix"); - } if (request.getResumptionToken() == null && request.getMetadataPrefix() == null) { errorValues.add("metadataPrefix"); } @@ -83,4 +248,36 @@ public abstract class IdentifierListDelivererAbstract implements IdentifierListD return result; } + public boolean isFoundItems() { + return foundItems; + } + + public void setFoundItems(boolean foundItems) { + this.foundItems = foundItems; + } + + public long getResultSize() { + return resultSize; + } + + public void setResultSize(long resultSize) { + this.resultSize = resultSize; + } + + public ResumptionTokenType getResTokenForResponse() { + return resTokenForResponse; + } + + public void setResTokenForResponse(ResumptionTokenType resTokenForResponse) { + this.resTokenForResponse = resTokenForResponse; + } + + public String getRangeField() { + return rangeField; + } + + public void setRangeField(String rangeField) { + this.rangeField = rangeField; + } + } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererDC.java b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererDC.java index 6dd234652ce7fac69e2b44696972cd27e38c449d..56d9d4024a50f8799eafc9e7bc0f092f22b66a76 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererDC.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererDC.java @@ -1,34 +1,46 @@ package info.textgrid.middleware; +import java.io.IOException; import java.text.ParseException; import java.util.Hashtable; import java.util.Map; import javax.xml.datatype.DatatypeConfigurationException; import org.apache.commons.logging.LogFactory; +import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.search.SearchScrollRequest; +import org.elasticsearch.action.search.SearchType; +import org.elasticsearch.client.RequestOptions; +import org.elasticsearch.common.Strings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.SearchHit; +import org.elasticsearch.search.builder.SearchSourceBuilder; +import org.elasticsearch.search.fetch.subphase.FetchSourceContext; + import info.textgrid.middleware.oaipmh.HeaderType; import info.textgrid.middleware.oaipmh.ListIdentifiersType; import info.textgrid.middleware.oaipmh.ResumptionTokenType; import info.textgrid.namespaces.middleware.tgcrud.common.TextGridMimetypes; - /** - * Class to build the Element for a ListIdentifiers request + * <p> + * Class to build the Element for a ListIdentifiers request. + * </p> * - * @author Maximilian Brodhun, SUB - * @version 1.0 - * @since 20.02.2014 + * @author Maximilian Brodhun, SUB Göttingen + * @version 2019-10-28 + * @since 2014-02-20 */ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { private static org.apache.commons.logging.Log log = LogFactory.getLog(IdentifierListDelivererDC.class); + public static Map<String, Integer> cursorCollector = new Hashtable<String, Integer>(); + private String datestamp; private boolean idExist = true; private OAI_ESClient oaiEsClient; @@ -38,27 +50,25 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { private String dateOfObjectCreation; // Field for the object creation in the repository private String repositoryObjectURIPrefix; // private String identifierField; - private static final int lifeTimeResToken = 10000; - - public static Map<String, Integer> cursorCollector = new Hashtable<String, Integer>(); - + private static final int lifeTimeResToken = 100; private int searchResponseSize; + private long resultSize; /** + * <p> * In OAIPMH a ListIdentifiers request is answered by responding the datestamp and the identifier - * of an object Both will be responded in a header element. This function build the header element + * of an object Both will be responded in a header element. This function build the header + * element. + * </p> * * @param datestamp taken from the elasticSearch index (created element) * @param identifier taken from the elasticSearch index (textgridUri) * @return the ListIdentifierElement with the responded header element */ - public IdentifierListDelivererDC(boolean textgrid, boolean dariah) { super(textgrid, dariah); } - - /** * @param datestamp * @param identifier @@ -69,8 +79,8 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { private static ListIdentifiersType setListIdentifierHeader(String datestamp, String identifier, ListIdentifiersType lit, String set) { - // FIXME Delete this function and check for empty set string in setListIdentifierHeaderWithSet - + // FIXME Delete this function and check for empty set string in setListIdentifierHeaderWithSet + HeaderType header = new HeaderType(); header.setDatestamp(datestamp); header.setIdentifier(identifier); @@ -84,19 +94,23 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { } /** + * <p> * To get the required values for the ListIdentifiers request this function will ask ElasticSearch * for a specific textgridUri the values "created" and "textgridUri". + * </p> * + * <p> * Since the ListIdentifiers request enables the possibility the limit the request in a specific - * time interval, it is necessary to perform a range query on the ElasticSearch index + * time interval, it is necessary to perform a range query on the ElasticSearch index.</p * * @param from : start value for the range query * @param to : end value to the range query * @return after calling the function "setListIdentifierHeader" the return value is the whole * ListIdentifiers element + * @throws IOException */ public ListIdentifiersType processIdentifierList(String from, String to, String set, - String resumptionToken) { + String resumptionToken) throws IOException { // FIXME combine it with with getIdentifierListWithSet and check for empty set @@ -104,19 +118,31 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { QueryBuilder query = setOrNot(set, from, to); SearchResponse listListIdentiferValues; + String[] includes = this.identifierListFields; + String[] excludes = Strings.EMPTY_ARRAY; + //TODO: necessary? + FetchSourceContext fetchSourceContext = new FetchSourceContext(true, includes, excludes); + + + SearchRequest searchRequest = + new SearchRequest(OAI_ESClient.getEsIndex()).searchType(SearchType.QUERY_THEN_FETCH); + + + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); + searchSourceBuilder.query(query); + searchSourceBuilder.size(this.searchResponseSize); + searchSourceBuilder.fetchSource(includes, excludes); + if (resumptionToken != null) { - listListIdentiferValues = OAI_ESClient.getOaiESClient().prepareSearchScroll(resumptionToken) - .setScroll(new TimeValue(lifeTimeResToken)).execute().actionGet(); + SearchScrollRequest scrollRequest = new SearchScrollRequest(resumptionToken); + scrollRequest.scroll(TimeValue.timeValueSeconds(lifeTimeResToken)); + listListIdentiferValues = + OAI_ESClient.getEsClient().scroll(scrollRequest, RequestOptions.DEFAULT); } else { - listListIdentiferValues = OAI_ESClient - .getOaiESClient().prepareSearch(OAI_ESClient.getEsIndex()) - .setTypes(OAI_ESClient.getEsType()) - .setScroll(new TimeValue(lifeTimeResToken)) - .addFields(this.identifierListFields) - .setQuery(query) - .setSize(this.searchResponseSize) - .execute() - .actionGet(); + searchRequest.source(searchSourceBuilder); + searchRequest.scroll(TimeValue.timeValueMinutes(lifeTimeResToken)); + listListIdentiferValues = + OAI_ESClient.getEsClient().search(searchRequest, RequestOptions.DEFAULT); } listListIdentiferValues = hitHandling(listListIdentiferValues, lit, set, listListIdentiferValues.getScrollId()); @@ -135,11 +161,12 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { String set, String resumptionToken) { int i = 0; + setResultSize(listFurtherValues.getHits().totalHits); for (SearchHit hit : listFurtherValues.getHits().getHits()) { i++; if (this.textgrid) { - - String datestamp = hit.getFields().get(this.dateOfObjectCreation).getValue().toString(); + // hit.getSourceAsMap().get(this.dateOfObjectCreation).toString(); + String datestamp = hit.getSourceAsMap().get(this.dateOfObjectCreation).toString(); try { datestamp = OAIPMHUtilities.convertDateFormat(datestamp).toXMLFormat(); } catch (ParseException e1) { @@ -147,25 +174,27 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { } catch (DatatypeConfigurationException e1) { log.debug(e1); } - String identifier = hit.getFields().get(this.identifierField).getValue().toString(); + String identifier = hit.getSourceAsMap().get(this.identifierField).toString(); lit = setListIdentifierHeader(datestamp, identifier, lit, set); } if (this.dariah) { - this.datestamp = hit.getFields().get(this.dateOfObjectCreation).getValue().toString(); + this.datestamp = hit.getSourceAsMap().get(this.dateOfObjectCreation).toString(); try { - this.datestamp = hit.getFields().get(this.dateOfObjectCreation).getValue().toString(); + + this.datestamp = hit.getSourceAsMap().get(this.dateOfObjectCreation).toString(); this.datestamp = OAIPMHUtilities.convertDateFormat(this.datestamp).toXMLFormat(); + } catch (ParseException e1) { log.debug(e1); } catch (DatatypeConfigurationException e1) { log.debug(e1); } - String identifier = hit.getFields().get(this.identifierField).getValue().toString(); + String identifier = hit.getSourceAsMap().get(this.identifierField).toString(); lit = setListIdentifierHeader(this.datestamp, identifier, lit, set); } } @@ -184,10 +213,10 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { /** * @param set * @param from - * @param to + * @param until * @return */ - public QueryBuilder setOrNot(String set, String from, String to) { + public QueryBuilder setOrNot(String set, String from, String until) { String filterFormat = ""; if (this.textgrid == true) { @@ -196,7 +225,7 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { filterFormat = TextGridMimetypes.DARIAH_COLLECTION; } - QueryBuilder rangeQuery = QueryBuilders.rangeQuery(this.rangeField).from(from).to(to); + QueryBuilder rangeQuery = QueryBuilders.rangeQuery(this.rangeField).from(from).to(until); QueryBuilder formatQuery = QueryBuilders.matchPhrasePrefixQuery("format", filterFormat); QueryBuilder query; @@ -221,7 +250,7 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { if (this.dariah) { query = matchQuery; } else { - query = QueryBuilders.boolQuery().must(matchQuery).must(formatQuery); + query = QueryBuilders.boolQuery().must(matchQuery).must(formatQuery).must(rangeQuery); } } else { @@ -354,4 +383,18 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { this.oaiEsClient = oaiEsClient; } + /** + * @return + */ + public long getResultSize() { + return this.resultSize; + } + + /** + * @param resultSize + */ + public void setResultSize(long resultSize) { + this.resultSize = resultSize; + } + } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererIDIOM.java b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererIDIOM.java index b16a4120ad34045c5cceef79143fd9ed0b26a4d9..5641c9a7dc06ea7c4130367fb1cb98fab0c958cb 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererIDIOM.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererIDIOM.java @@ -1,5 +1,6 @@ package info.textgrid.middleware; +import java.text.ParseException; import java.util.ArrayList; import java.util.Hashtable; import java.util.List; @@ -37,7 +38,7 @@ public class IdentifierListDelivererIDIOM extends IdentifierListDelivererAbstrac * String, java.lang.String, java.lang.String, java.lang.String) */ public ListIdentifiersType processIdentifierList(final String from, final String to, - final String set, final String resumptionToken) { + final String set, final String resumptionToken) throws ParseException { String resTokenValue = resumptionToken; diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererInterface.java b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererInterface.java index 2e9b56f3cc793b0b6c6b322c1bff0733c0fe8fd3..81068740ca4c4907c06a0b004875b47ab0715fe3 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererInterface.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererInterface.java @@ -1,5 +1,6 @@ package info.textgrid.middleware; +import java.io.IOException; import java.text.ParseException; import info.textgrid.middleware.oaipmh.ListIdentifiersType; @@ -15,8 +16,9 @@ public interface IdentifierListDelivererInterface { * @param resumptionToken * @return * @throws ParseException + * @throws IOException */ public ListIdentifiersType processIdentifierList(String from, String to, String set, - String resumptionToken) throws ParseException; + String resumptionToken) throws ParseException, IOException; } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/MetadataFormatListDeliverer.java b/oaipmh-core/src/main/java/info/textgrid/middleware/MetadataFormatListDeliverer.java index 6f43397e45deb2dfea88839daab401e6f5acc8ea..978700bc296127a902f8cec3b4d9c5b5f201063a 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/MetadataFormatListDeliverer.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/MetadataFormatListDeliverer.java @@ -1,7 +1,11 @@ package info.textgrid.middleware; -import org.elasticsearch.action.get.GetRequestBuilder; +import java.io.IOException; +import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.client.RequestOptions; +import org.elasticsearch.common.Strings; +import org.elasticsearch.search.fetch.subphase.FetchSourceContext; import info.textgrid.middleware.oaipmh.ListMetadataFormatsType; import info.textgrid.middleware.oaipmh.MetadataFormatType; import info.textgrid.middleware.oaipmh.RequestType; @@ -26,23 +30,38 @@ public class MetadataFormatListDeliverer { */ public ListMetadataFormatsType setMetadataFormatList(String id) { + String[] includes = new String[] {TGConstants.URI}; + String[] excludes = Strings.EMPTY_ARRAY; + FetchSourceContext fetchSourceContext = new FetchSourceContext(true, includes, excludes); + ListMetadataFormatsType lmft = new ListMetadataFormatsType(); MetadataFormatType mft = new MetadataFormatType(); - - GetRequestBuilder recordById = OAI_ESClient.getOaiESClient().prepareGet() - .setIndex(OAI_ESClient.getEsIndex()) - .setType(OAI_ESClient.getEsType()) - .setFields(TGConstants.URI) - .setId(id); - - GetResponse tgObject = recordById.execute().actionGet(); + MetadataFormatType openAireMetadataFormat = new MetadataFormatType(); + + GetRequest getRequest = new GetRequest(OAI_ESClient.getEsIndex(), OAI_ESClient.getEsType(), id.replace("textgrid:", "")) + .fetchSourceContext(fetchSourceContext); + + GetResponse tgObject = null; + try { + tgObject = OAI_ESClient.getEsClient().get(getRequest, RequestOptions.DEFAULT); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } if (tgObject.isExists()) { setIdExist(true); - mft.setMetadataPrefix(TGConstants.METADATA_DC_PREFIX); + mft.setMetadataPrefix(OAIPMHUtilities.OAIDC_PREFIX); mft.setMetadataNamespace(OAIPMHUtilities.OAIDC_NAMESPACE); mft.setSchema(OAIPMHUtilities.OAIDC_SCHEMA_LOCATION); + + openAireMetadataFormat.setMetadataNamespace(OAIPMHUtilities.OPEN_AIRE_NAMESPACE); + openAireMetadataFormat.setMetadataPrefix(TGConstants.METADATA_OPENAIRE_PREFIX); + openAireMetadataFormat.setSchema(OAIPMHUtilities.OPEN_AIRE_SCHEMA_LOCATION); + lmft.getMetadataFormat().add(mft); + lmft.getMetadataFormat().add(openAireMetadataFormat); + } else { setIdExist(false); lmft = null; @@ -59,8 +78,9 @@ public class MetadataFormatListDeliverer { ListMetadataFormatsType lmft = new ListMetadataFormatsType(); MetadataFormatType mft = new MetadataFormatType(); MetadataFormatType mftIdiomMets = new MetadataFormatType(); + MetadataFormatType openAireMetadataFormat = new MetadataFormatType(); - mft.setMetadataPrefix(TGConstants.METADATA_DC_PREFIX); + mft.setMetadataPrefix(OAIPMHUtilities.OAIDC_PREFIX); mft.setMetadataNamespace(OAIPMHUtilities.OAIDC_NAMESPACE); mft.setSchema(OAIPMHUtilities.OAIDC_SCHEMA_LOCATION); lmft.getMetadataFormat().add(mft); @@ -68,7 +88,13 @@ public class MetadataFormatListDeliverer { mftIdiomMets.setMetadataPrefix(TGConstants.METADATA_IDIOM_PREFIX); mftIdiomMets.setMetadataNamespace(OAIPMHUtilities.METS_NAMESPACE); mftIdiomMets.setSchema(OAIPMHUtilities.METS_SCHEMA_LOCATION); + + openAireMetadataFormat.setMetadataNamespace(OAIPMHUtilities.OPEN_AIRE_NAMESPACE); + openAireMetadataFormat.setMetadataPrefix(TGConstants.METADATA_OPENAIRE_PREFIX); + openAireMetadataFormat.setSchema(OAIPMHUtilities.OPEN_AIRE_SCHEMA_LOCATION); + lmft.getMetadataFormat().add(mftIdiomMets); + lmft.getMetadataFormat().add(openAireMetadataFormat); return lmft; } @@ -81,12 +107,10 @@ public class MetadataFormatListDeliverer { boolean requestCheck = true; - if (request.getFrom() != null || - request.getMetadataPrefix() != null || - request.getResumptionToken() != null) { - + if (request.getFrom() != null + || request.getMetadataPrefix() != null + || request.getResumptionToken() != null) { requestCheck = false; - } else if (request.getSet() != null || request.getUntil() != null) { requestCheck = false; diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java index 1a31c6115a8ae5e188cab871cc1b0cacaeaad94e..4edbd9b2c0c1e3e850e1191c412dfb2f29631d0d 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java @@ -52,7 +52,9 @@ public class OAIPMHImpl implements OAIPMHProducer { private RepIdentification rep; private RecordListDelivererDC recordListDC; private RecordListDelivererIDIOM recordListIDIOM; - + private OpenAireRecord openAireRecord; + private OpenAireRecordList openAireRecordList; + private OpenAireIdentifierList openAireIdentifierList; private RecordDelivererDC recDelivDC; private RecordDelivererIDIOM recDelivIDIOM; @@ -80,20 +82,32 @@ public class OAIPMHImpl implements OAIPMHProducer { * @param identifierList * @param identifierListIDIOM */ - public OAIPMHImpl(RepIdentification rep, RecordDelivererDC recDelivDC, - RecordDelivererIDIOM recDelivIDIOM, RecordListDelivererDC recordListDC, - RecordListDelivererIDIOM recordListIDIOM, MetadataFormatListDeliverer metadataFormatList, - SetDeliverer setList, IdentifierListDelivererDC identifierList, - IdentifierListDelivererIDIOM identifierListIDIOM) { + public OAIPMHImpl( + RepIdentification rep, //0 + RecordDelivererDC recDelivDC, //1 + RecordDelivererIDIOM recDelivIDIOM, //2 + OpenAireRecord openAireRecord, //3 + RecordListDelivererDC recordListDC, //4 + RecordListDelivererIDIOM recordListIDIOM, //5 + OpenAireRecordList openAireRecordList, //6 + MetadataFormatListDeliverer metadataFormatList, //7 + SetDeliverer setList, //8 + IdentifierListDelivererDC identifierList, //9 + IdentifierListDelivererIDIOM identifierListIDIOM, //10 + OpenAireIdentifierList openAireIdentifierList //11 + ) { this.rep = rep; this.recDelivDC = recDelivDC; this.recDelivIDIOM = recDelivIDIOM; + this.openAireRecord = openAireRecord; this.recordListDC = recordListDC; this.recordListIDIOM = recordListIDIOM; + this.openAireRecordList = openAireRecordList; this.metadataFormatList = metadataFormatList; this.setList = setList; this.identifierListDC = identifierList; this.identifierListIDIOM = identifierListIDIOM; + this.openAireIdentifierList = openAireIdentifierList; } /* @@ -108,8 +122,10 @@ public class OAIPMHImpl implements OAIPMHProducer { String result = ""; try { + result = getStringFromJAXBOAIElement(verb, handleRequest(verb, identifier, metadataPrefix, set, from, until, resumptionToken)); + } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -128,10 +144,18 @@ public class OAIPMHImpl implements OAIPMHProducer { String set, String from, String until, String resumptionToken) { String result = ""; - + try { result = getStringFromJAXBOAIElement(verb, - handleRequest(verb, identifier, metadataPrefix, set, from, until, resumptionToken)); + handleRequest( + verb, + identifier, + metadataPrefix, + set, + from, + until, + resumptionToken)); + } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -233,19 +257,29 @@ public class OAIPMHImpl implements OAIPMHProducer { if (request.getMetadataPrefix().equals(TGConstants.METADATA_IDIOM_PREFIX)) { recDeliv = this.recDelivIDIOM; } - + if(request.getMetadataPrefix().equals(TGConstants.METADATA_OPENAIRE_PREFIX)) { + recDeliv = this.openAireRecord; + } + // Finally start the QUERY! GetRecordType getRecord = new GetRecordType(); String id = request.getIdentifier(); - getRecord = recDeliv.getRecordById(id); + try { + getRecord = recDeliv.getRecordById(id); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (DatatypeConfigurationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } if (getRecord != null) { oaipmhRoot.setGetRecord(getRecord); } else { - ErrorHandler idError = new ErrorHandler(); - idError.setError(TGConstants.OAI_NO_RECORD_MATCH, "The value of the identifier: " - + request.getIdentifier() + " is unknown or illegal in this repository"); + ErrorHandler idError = new ErrorHandler(); + idError.setError(TGConstants.OAI_ID_DOES_NOT_EXIST, "No matching identifier "); oaipmhRoot.getError().add(idError.getError()); } } @@ -276,10 +310,12 @@ public class OAIPMHImpl implements OAIPMHProducer { // If metadataFormat IS SET, set recordListDeliverer accordingly. IdentifierListDelivererInterface idListDeliv = null; if (request.getMetadataPrefix() != null) { - if (request.getMetadataPrefix().equals(TGConstants.METADATA_DC_PREFIX)) { + if (request.getMetadataPrefix().equals(OAIPMHUtilities.OAIDC_PREFIX)) { idListDeliv = this.identifierListDC; - } else { - idListDeliv = this.identifierListIDIOM; + } else if(request.getMetadataPrefix().equals(TGConstants.METADATA_IDIOM_PREFIX)) { + idListDeliv = this.identifierListIDIOM; + } else if(request.getMetadataPrefix().equals(TGConstants.METADATA_OPENAIRE_PREFIX)) { + idListDeliv = this.openAireIdentifierList; } } @@ -291,18 +327,31 @@ public class OAIPMHImpl implements OAIPMHProducer { boolean restokIDIOMExisting = IdentifierListDelivererIDIOM.cursorCollector != null && IdentifierListDelivererIDIOM.cursorCollector .containsKey(request.getResumptionToken()); + boolean restokOpenAireExisting = OAIPMHUtilities.cursorCollector != null + && IdentifierListDelivererAbstract.cursorCollector.containsKey(request.getResumptionToken()); if (restokDCExisting) { idListDeliv = this.identifierListDC; } else if (restokIDIOMExisting) { - idListDeliv = this.identifierListIDIOM; + idListDeliv = this.identifierListIDIOM; + } else if (restokOpenAireExisting) { + idListDeliv = this.openAireIdentifierList; } } - ListIdentifiersType listIdentifiers = idListDeliv.processIdentifierList(request.getFrom(), - request.getUntil(), request.getSet(), request.getResumptionToken()); + ListIdentifiersType listIdentifiers = null; + try { + System.out.println("GET FROM: " + request.getFrom()); + System.out.println("GET UNTIL: " + request.getUntil()); + + listIdentifiers = idListDeliv.processIdentifierList(request.getFrom(), request.getUntil(), + request.getSet(), request.getResumptionToken()); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } if (listIdentifiers != null) { - oaipmhRoot.setListIdentifiers(listIdentifiers); + oaipmhRoot.setListIdentifiers(listIdentifiers); } else { ErrorHandler idError = new ErrorHandler(); idError.setError(TGConstants.OAI_NO_RECORD_MATCH, "The value of the identifier: " @@ -423,8 +472,9 @@ public class OAIPMHImpl implements OAIPMHProducer { * @param oai * @param request * @return + * @throws ParseException */ - public OAIPMHtype listRecordsRequest(OAIPMHtype oaipmhRoot, RequestType request) { + public OAIPMHtype listRecordsRequest(OAIPMHtype oaipmhRoot, RequestType request) throws ParseException { // Check request's syntax. ErrorHandler requestErrors = RecordListDelivererAbstract.requestChecker(request); @@ -436,13 +486,17 @@ public class OAIPMHImpl implements OAIPMHProducer { // If metadataFormat IS SET, set recordListDeliverer accordingly. RecordListDelivererInterface recListDeliv = null; if (request.getMetadataPrefix() != null) { - if (request.getMetadataPrefix().equals(TGConstants.METADATA_DC_PREFIX)) { + if(request.getMetadataPrefix().equals(OAIPMHUtilities.OAIDC_PREFIX)) { recListDeliv = this.recordListDC; - } else { + } + if(request.getMetadataPrefix().equals(TGConstants.METADATA_IDIOM_PREFIX)){ recListDeliv = this.recordListIDIOM; } + if(request.getMetadataPrefix().equals(TGConstants.METADATA_OPENAIRE_PREFIX)){ + recListDeliv = this.openAireRecordList; + } } - + // If metadata format IS NOT SET, check resumption token hash maps to decide if we have to // serve oai_dc or idiom_mets metadata format. else { @@ -450,20 +504,37 @@ public class OAIPMHImpl implements OAIPMHProducer { && RecordListDelivererDC.cursorCollector.containsKey(request.getResumptionToken()); boolean restokIDIOMExisting = RecordListDelivererIDIOM.cursorCollector != null && RecordListDelivererIDIOM.cursorCollector.containsKey(request.getResumptionToken()); +<<<<<<< HEAD +======= + boolean restokOpenAireExisting = RecordListDelivererAbstract.cursorCollector != null + && RecordListDelivererAbstract.cursorCollector.containsKey(request.getResumptionToken()); +>>>>>>> feature/elastic6 if (restokDCExisting) { recListDeliv = this.recordListDC; } else if (restokIDIOMExisting) { recListDeliv = this.recordListIDIOM; - } - } - - ListRecordsType listRecords = recListDeliv.getRecords(request.getFrom(), request.getUntil(), - request.getSet(), request.getResumptionToken()); + } else if (restokOpenAireExisting) { + recListDeliv = this.openAireRecordList; + } + } + + ListRecordsType listRecords = recListDeliv. + getRecords( + request.getFrom(), + request.getUntil(), + request.getSet(), + request.getResumptionToken()); if (listRecords != null) { - oaipmhRoot.setListRecords(listRecords); + /*if (this.recordListDC.getResultSize() == 0) { + requestErrors.setError("RecordMatchError", + "The combination of the values of the from, until, set and metadataPrefix arguments results in an empty list."); + oaipmhRoot.getError().add(requestErrors.getError()); + } else {*/ + oaipmhRoot.setListRecords(listRecords); + //} } } @@ -482,25 +553,20 @@ public class OAIPMHImpl implements OAIPMHProducer { VerbType verbParam = null; - if (verb == null) { - verb = "Identify"; - } - - if (verb != null && verb.equals("Identify")) { + if (verb!=null && verb.equals("Identify")) { verbParam = VerbType.IDENTIFY; - } else if (verb != null && verb.equals("ListMetadataFormats")) { + } else if (verb!=null && verb.equals("ListMetadataFormats")) { verbParam = VerbType.LIST_METADATA_FORMATS; - } else if (verb != null && verb.equals("ListSets")) { + } else if (verb!=null && verb.equals("ListSets")) { verbParam = VerbType.LIST_SETS; - } else if (verb != null && verb.equals("ListIdentifiers")) { + } else if (verb!=null && verb.equals("ListIdentifiers")) { verbParam = VerbType.LIST_IDENTIFIERS; - } else if (verb != null && verb.equals("ListRecords")) { + } else if (verb!=null && verb.equals("ListRecords")) { verbParam = VerbType.LIST_RECORDS; - } else if (verb != null && verb.equals("GetRecord")) { + } else if (verb!=null && verb.equals("GetRecord")) { verbParam = VerbType.GET_RECORD; - } else { - // FIXME What must be fixed here? --fu - this.error.setError("VerbError", "Illegal OAI verb"); + }else if (verb!=null && verb.length()>0){ + this.error.setError(TGConstants.OAI_VERB_ERROR, "Illegal OAI verb"); } return verbParam; @@ -666,11 +732,16 @@ public class OAIPMHImpl implements OAIPMHProducer { } else if (verbParam.value().equals("ListRecords")) { response = listRecordsRequest(response, request); } - } else { - this.error.setError("VerbError", "Illegal OAI verb"); - response.getError().add(this.error.getError()); + } else { + if(this.error.getError().getValue()!=null && this.error.getError().getValue().equals("Illegal OAI verb")){ + this.error.setError(TGConstants.OAI_VERB_ERROR, "Illegal OAI verb"); + response.getError().add(this.error.getError()); + }else { + this.error.setError(TGConstants.OAI_VERB_ERROR, "Illegal OAI verb"); + response.getError().add(this.error.getError()); + } } - + response.setRequest(request); result = obf.createOAIPMH(response); @@ -687,7 +758,7 @@ public class OAIPMHImpl implements OAIPMHProducer { * @param theJAXBOAIElement * @return */ - private static String getStringFromJAXBOAIElement(final String theVerb, + public static String getStringFromJAXBOAIElement(final String theVerb, final JAXBElement<OAIPMHtype> theJAXBOAIElement) { String result = ""; @@ -696,7 +767,7 @@ public class OAIPMHImpl implements OAIPMHProducer { String schemaLocations = OAIPMHUtilities.OAIPMH_NAMESPACE + " " + OAIPMHUtilities.OAIPMH_SCHEMA_LOCATION; // Add OAI_DC and DC schema location if needed. - if (theVerb.equals("GetRecord") || theVerb.endsWith("ListRecords")) { + if (theVerb!=null && (theVerb.equals("GetRecord") || theVerb.endsWith("ListRecords"))) { schemaLocations += OAIPMHUtilities.OAIDC_NAMESPACE + " " + OAIPMHUtilities.OAIDC_SCHEMA_LOCATION + " " + OAIPMHUtilities.DC_NAMESPACE + " " + OAIPMHUtilities.DC_SCHEMA_LOCATION; @@ -727,4 +798,4 @@ public class OAIPMHImpl implements OAIPMHProducer { return result; } -} +} \ No newline at end of file diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHProducer.java b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHProducer.java index 77d71174979a2f2d8d61427441f1336c57c09fda..38f03be698493309be1aedb729ac63b524874bd2 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHProducer.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHProducer.java @@ -1,5 +1,7 @@ package info.textgrid.middleware; +import java.io.IOException; + import javax.ws.rs.DefaultValue; import javax.ws.rs.FormParam; import javax.ws.rs.GET; @@ -40,6 +42,7 @@ public interface OAIPMHProducer { * @param until - End value to filter the response for a specific interval * @param resumptionToken - Indicates how many value will be send back in the response * @return OAIPMHType object containing the whole response + * @throws IOException */ @GET @Path("/") @@ -50,7 +53,7 @@ public interface OAIPMHProducer { @QueryParam("set") @DefaultValue("") String set, @QueryParam("from") @DefaultValue("") String from, @QueryParam("until") @DefaultValue("") String until, - @QueryParam("resumptionToken") @DefaultValue("") String resumptionToken); + @QueryParam("resumptionToken") @DefaultValue("") String resumptionToken) throws IOException; /** * <p> @@ -72,6 +75,7 @@ public interface OAIPMHProducer { * @param until - End value to filter the response for a specific interval * @param resumptionToken - Indicates how many value will be send back in the response * @return OAIPMHType object containing the whole response + * @throws IOException */ @POST @Path("/") @@ -82,7 +86,7 @@ public interface OAIPMHProducer { @FormParam("set") @DefaultValue("") String set, @FormParam("from") @DefaultValue("") String from, @FormParam("until") @DefaultValue("") String until, - @FormParam("resumptionToken") @DefaultValue("") String resumptionToken); + @FormParam("resumptionToken") @DefaultValue("") String resumptionToken) throws IOException; /** * @return diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHUtilities.java b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHUtilities.java index 890419d4ac11403eb71c28c6171732f6044c62ed..14e0b94fbf07e18cd657aa01e03f226d8ee15161 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHUtilities.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHUtilities.java @@ -1,19 +1,67 @@ package info.textgrid.middleware; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.StringWriter; import java.math.BigInteger; +import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Date; import java.util.GregorianCalendar; +import java.util.Hashtable; +import java.util.List; import java.util.Map; +import java.util.Properties; import java.util.TimeZone; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import org.apache.commons.io.IOUtils; import org.apache.commons.logging.LogFactory; +import org.elasticsearch.action.get.GetRequest; +import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.search.SearchRequest; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.search.SearchScrollRequest; +import org.elasticsearch.client.RequestOptions; +import org.elasticsearch.common.Strings; +import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.index.query.QueryBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.search.SearchHit; +import org.elasticsearch.search.builder.SearchSourceBuilder; +import org.elasticsearch.search.fetch.subphase.FetchSourceContext; +import org.json.JSONException; +import org.json.JSONObject; + +import info.textgrid.clients.AuthClient; +import info.textgrid.clients.tgauth.AuthClientException; +import info.textgrid.middleware.oaipmh.GetRecordType; +import info.textgrid.middleware.oaipmh.HeaderType; import info.textgrid.middleware.oaipmh.ListMetadataFormatsType; +import info.textgrid.middleware.oaipmh.ListRecordsType; import info.textgrid.middleware.oaipmh.MetadataFormatType; +import info.textgrid.middleware.oaipmh.MetadataType; +import info.textgrid.middleware.oaipmh.OAIPMHtype; +import info.textgrid.middleware.oaipmh.RecordType; +import info.textgrid.middleware.oaipmh.Resource; import info.textgrid.middleware.oaipmh.ResumptionTokenType; +import info.textgrid.namespaces.middleware.tgauth.ProjectInfo; +import info.textgrid.namespaces.middleware.tgcrud.common.TextGridMimetypes; /** * <p> @@ -34,6 +82,7 @@ public class OAIPMHUtilities { public static final String OAIPMH_NAMESPACE = "http://www.openarchives.org/OAI/2.0/"; public static final String OAIPMH_SCHEMA_LOCATION = "http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd"; + public static final String OAIDC_PREFIX = "oai_dc"; public static final String OAIDC_NAMESPACE = "http://www.openarchives.org/OAI/2.0/oai_dc/"; public static final String OAIDC_SCHEMA_LOCATION = "http://www.openarchives.org/OAI/2.0/oai_dc.xsd"; @@ -42,6 +91,20 @@ public class OAIPMHUtilities { "https://dublincore.org/schemas/xmls/simpledc20021212.xsd"; public static final String METS_NAMESPACE = "http://www.loc.gov/METS/"; public static final String METS_SCHEMA_LOCATION = "http://www.loc.gov/standards/mets/mets.xsd"; + + public static final String OPEN_AIRE_SCHEMA_LOCATION = "https://www.openaire.eu/schema/1.0/oaf-1.0.xsd"; + public static final String OPEN_AIRE_NAMESPACE ="oai_datacite"; + + private String rangeField; + private long resultSize; + private boolean foundItems; + private String formatField; + private ResumptionTokenType resTokenForResponse; + private String formatToFilter; + private int searchResponseSize; + + + protected static Map<String, Integer> cursorCollector = new Hashtable<String, Integer>(); // ** // STATICS @@ -73,6 +136,20 @@ public class OAIPMHUtilities { return tgDublinCore; } + public static List<ProjectInfo> getProjectList() throws AuthClientException { + AuthClient auth = new AuthClient(); + List<ProjectInfo> projectInfos =auth.getAllProjects(); + auth.getAllProjects(); + + return projectInfos; + } + + public static String getProjectName(String projectID) throws AuthClientException { + + AuthClient auth = new AuthClient(); + return auth.getProjectInfo(projectID).getName(); + } + /** * <p> * Producing the list of all metadata formats. @@ -127,7 +204,7 @@ public class OAIPMHUtilities { outFormatter.setTimeZone(TimeZone.getTimeZone("UTC")); String output2 = outFormatter.format(date); XMLGregorianCalendar xmlCal = DatatypeFactory.newInstance().newXMLGregorianCalendar(output2); - + return xmlCal; } @@ -168,6 +245,7 @@ public class OAIPMHUtilities { * @return A resumption token if applicable, null otherwise. */ public static ResumptionTokenType getResumptionToken(final long completeListSize, +<<<<<<< HEAD final String resumptionToken, Map<String, Integer> cursorCollector, final String scrollID, final int searchResponseSize, final int i) { @@ -226,5 +304,422 @@ public class OAIPMHUtilities { return null; } - +======= + final String resumptionToken, Map<String, Integer> cursorCollector, final String scrollID, + final int searchResponseSize, final int i) { + + log.info("Creating a ResumptionToken:\n " + + "CompleteListSize: " + completeListSize + "\n" + + "ResumptionToken: " + resumptionToken + "\n" + + "CursorCollector: " + cursorCollector + "\n" + + "ScrollID: " + scrollID + "\n" + + "SearchResponseSize: " + scrollID + "\n" + + "IterationStep: " + i); + + int cursor; + + // Three cases here: + // 1. Complete list size is > searchResponseSize and a token already is existing: we need to + // check hash map! + // 2. Complete list size is > searchResponseSize and we have no token: we do need one! + // 3. Complete list size is <= searchResponseSize (we do not need a token! do nothing!) + + if (completeListSize > searchResponseSize) { + ResumptionTokenType resTokenForResponse = new ResumptionTokenType(); + + if (resumptionToken != null && cursorCollector.containsKey(resumptionToken)) { + cursor = cursorCollector.get(resumptionToken).intValue() + i; + if(cursor == 100) { + cursor = 200; + } + resTokenForResponse.setCursor(BigInteger.valueOf((long) cursor)); + cursorCollector.put(scrollID, cursor); + } else { + resTokenForResponse.setCursor(BigInteger.valueOf(searchResponseSize)); + cursorCollector.put(scrollID, searchResponseSize); + cursor = 100; + resTokenForResponse.setCursor(BigInteger.valueOf((long) cursor)); + + } + + // Set resumption token string if cursor is less then complete list size: More objects can be + // delivered! + if (cursor < completeListSize) { + resTokenForResponse.setValue(scrollID); + } + + // Remove resumption token string if cursor is bigger then or equal complete list size: This + // is the last response, no more objects are available! + if (cursor >= completeListSize) { + resTokenForResponse.setValue(""); + } + + // Set complete list size. + resTokenForResponse.setCompleteListSize(BigInteger.valueOf(completeListSize)); + + return resTokenForResponse; + } + + return null; + } + + public static boolean isThisDateValid(String dateToValidate){ + + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S"); + + dateFormat.setLenient(false); + try { + dateFormat.parse(dateToValidate.trim()); + } catch (ParseException pe) { + return false; + } + return true; + } + + public static boolean isThisDateValidToOtherTimeStamp(String dateToValidate){ + + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); + + dateFormat.setLenient(false); + dateFormat.setLenient(false); + try { + dateFormat.parse(dateToValidate.trim()); + } catch (ParseException pe) { + return false; + } + return true; + } + + + private static final String[] formats = { + "yyyy-MM-dd'T'HH:mm:ss'Z'", "yyyy-MM-dd'T'HH:mm:ssZ", + "yyyy-MM-dd'T'HH:mm:ss", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", + "yyyy-MM-dd'T'HH:mm:ss.SSSZ", "yyyy-MM-dd HH:mm:ss", + "MM/dd/yyyy HH:mm:ss", "MM/dd/yyyy'T'HH:mm:ss.SSS'Z'", + "MM/dd/yyyy'T'HH:mm:ss.SSSZ", "MM/dd/yyyy'T'HH:mm:ss.SSS", + "MM/dd/yyyy'T'HH:mm:ssZ", "MM/dd/yyyy'T'HH:mm:ss", + "yyyy:MM:dd HH:mm:ss", "yyyyMMdd", }; + + + public static String getFormatOfDate(String d) { + if (d != null) { + for (String parse : formats) { + SimpleDateFormat sdf = new SimpleDateFormat(parse); + try { + sdf.parse(d); + return parse; + } catch (ParseException e) { + + } + } + } + return d; + } +>>>>>>> feature/elastic6 + + + public static List<String> fieldLoader(JSONObject resultFromGetRequestInES, String[] fields){ + + List<String> fieldResulsts = new ArrayList<String>(); + + for(String field : fields) { + String[] fieldPathForESIndex = field.split("\\."); + JSONObject singlePath=resultFromGetRequestInES; + for(int i=0; i<fieldPathForESIndex.length;i++) { + if(i<fieldPathForESIndex.length-1) { + try { + singlePath = singlePath.getJSONObject(fieldPathForESIndex[i]); + }catch(JSONException notFound) { + return null; + } + }else if(fieldPathForESIndex.length == 1){ + fieldResulsts.add(resultFromGetRequestInES.get(fieldPathForESIndex[i]).toString()); + }else { + fieldResulsts.add(singlePath.get(fieldPathForESIndex[i]).toString()); + } + } + } + + return fieldResulsts; + } + + public static String fieldLoader(JSONObject resultFromGetRequestInES, String field){ + + String fieldResulst = ""; + + String[] fieldPathForESIndex = field.split("\\."); + JSONObject singlePath=resultFromGetRequestInES; + for(int i=0; i<fieldPathForESIndex.length;i++) { + + if(i<fieldPathForESIndex.length-1) { + try { + singlePath = singlePath.getJSONObject(fieldPathForESIndex[i]); + }catch(JSONException notFound) { + return null; + } + }else if(fieldPathForESIndex.length == 1){ + //System.out.println(fieldPathForESIndex[i]); + fieldResulst = resultFromGetRequestInES.get(fieldPathForESIndex[i]).toString(); + }else { + try { + fieldResulst = singlePath.get(fieldPathForESIndex[i]).toString(); + }catch(JSONException notFound) { + return null; + } + } + } + + + return fieldResulst; + } + + /** + * + * @param idInElasticSearchIndex + * @param includes including the fields to fetch from the elastic search index + * @param excludes excluding the fields to fetch from the elastic search index + * @return + */ + public static GetResponse getRcordByIDFromElasticSearch(String idInElasticSearchIndex, String[] includes, String[] excludes) { + //Including and excluding the fields to fetch from the elastic search index + + //Setting the source context for fetching the fields from the elastic search index + FetchSourceContext fetchSourceContext = new FetchSourceContext(true, includes, excludes); + //System.out.println("INDEX: " + OAI_ESClient.getEsIndex()); + //Building the getRequest against the elastic search index + GetRequest getRequest = + new GetRequest(OAI_ESClient.getEsIndex(), OAI_ESClient.getEsType(), idInElasticSearchIndex) + .fetchSourceContext(fetchSourceContext); + + //Declaration of the result from the get-reuest + GetResponse esResultObject = null; + + try { + esResultObject = + OAI_ESClient.getEsClient().get(getRequest, RequestOptions.DEFAULT); + + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + log.error("Could not fetch the result of ElasticSearch"); + } + //System.out.println("STRANGE: "); + //System.out.println(esResultObject.getSourceAsString()); + return esResultObject; + } + + public static void marshal(Resource resource) throws JAXBException { + JAXBContext jc = JAXBContext.newInstance(Resource.class); + Marshaller marshaller = jc.createMarshaller(); + StringWriter stringWriter = new StringWriter(); + marshaller.marshal(resource, stringWriter ); + marshaller.marshal(resource, System.out); + } + + + public static GetRecordType getRecordType(Object metadata, HeaderType header) { + + MetadataType metadataType = new MetadataType(); + RecordType recordType = new RecordType(); + GetRecordType getRecordType = new GetRecordType(); + + metadataType.setAny(metadata); + recordType.setMetadata(metadataType); + recordType.setHeader(header); + getRecordType.setRecord(recordType); + + return getRecordType; + } + + public static String[][] fetchArrayFromPropFile(String propertyName, Properties propFile) { + + //get array split up by the semicolin + String[] a = propFile.getProperty(propertyName).split(";"); + + //create the two dimensional array with correct size + String[][] array = new String[a.length][a.length]; + + //combine the arrays split by semicolin and comma + for(int i = 0;i < a.length;i++) { + array[i] = a[i].split(","); + } + + return array; + } + + /*public List<String> getUriListOfAllEditions(String from, String to, String set, String resumptionToken) throws IOException { + + InputStream input = null; + try { + input = new FileInputStream("/etc/dhrep/oaipmh/oaipmh.properties"); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + Properties prop = new Properties(); + prop.load(input); + + QueryBuilder query; + + QueryBuilder rangeQuery = QueryBuilders.rangeQuery(prop.getProperty("rangeField")).from("1900").to("2020"); + + if(set!=null) { + String[] setParts = set.split(":"); + + String queryField = ""; + String valueField = ""; + + if (setParts[0].equals(TGConstants.SET_FIELD_FOR_TEXTGRID)) { + queryField = TGConstants.PROJECT_ID_FOR_TEXTGRID; + valueField = setParts[1]; + } + + QueryBuilder matchQuery = QueryBuilders.matchPhraseQuery(queryField, valueField); + QueryBuilder boolQuery = QueryBuilders.boolQuery().must(rangeQuery).must(matchQuery); + + query = boolQuery; + }else { + query = rangeQuery; + } + + return getConentFromESIndex(query, resumptionToken, set); + } + + private List<String> getConentFromESIndex(QueryBuilder query, String resumptionToken, + String set) throws IOException { + + List<String> uriList = new ArrayList<String>(); + QueryBuilder recordFilter = QueryBuilders.boolQuery().must(query) + .must(QueryBuilders.matchPhraseQuery(TGConstants.FORMAT, TextGridMimetypes.EDITION)); + + SearchRequest searchRequest = new SearchRequest(OAI_ESClient.getEsIndex()); + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); + + InputStream input = null; + try { + input = new FileInputStream("/etc/dhrep/oaipmh/oaipmh.properties"); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + Properties prop = new Properties(); + prop.load(input); + + searchSourceBuilder.query(recordFilter); + searchSourceBuilder.size(Integer.parseInt(prop.getProperty("searchResponseSize"))); + searchRequest.source(searchSourceBuilder); + + SearchResponse scrollResp = new SearchResponse(); + + if (resumptionToken != null) { + + SearchScrollRequest scrollRequest = new SearchScrollRequest(resumptionToken); + scrollRequest.scroll(TimeValue.timeValueSeconds(Integer.parseInt(prop.getProperty("lifetimeForResumptionToken")))); + + try { + scrollResp = OAI_ESClient.getEsClient().scroll(scrollRequest, RequestOptions.DEFAULT); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else { + searchRequest.source(searchSourceBuilder); + searchRequest.scroll(TimeValue.timeValueMinutes(600)); + try { + scrollResp = OAI_ESClient.getEsClient().search(searchRequest,RequestOptions.DEFAULT); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + String scrollID = scrollResp.getScrollId(); + long completeListSize = scrollResp.getHits().totalHits; + setResultSize(completeListSize); + + if (completeListSize > 0) { + + setFoundItems(true); + int i=0; + + for (SearchHit hit : scrollResp.getHits().getHits()) { + i++; + if (hit != null && hit.getFields() != null) { + uriList.add(hit.getSourceAsMap().get(TGConstants.URI).toString()); + } + } + + this.setResTokenForResponse(OAIPMHUtilities.getResumptionToken( + completeListSize, resumptionToken, cursorCollector, scrollID, Integer.parseInt(prop.getProperty("searchResponseSize")), i)); + + }else { + setFoundItems(false); + } + + + return uriList; + + }*/ + + + + public String getRangeField() { + return rangeField; + } + + public void setRangeField(String rangeField) { + this.rangeField = rangeField; + } + + public long getResultSize() { + return resultSize; + } + + public void setResultSize(long resultSize) { + this.resultSize = resultSize; + } + + public boolean isFoundItems() { + return foundItems; + } + + public void setFoundItems(boolean foundItems) { + this.foundItems = foundItems; + } + + public ResumptionTokenType getResTokenForResponse() { + return resTokenForResponse; + } + + public void setResTokenForResponse(ResumptionTokenType resTokenForResponse) { + this.resTokenForResponse = resTokenForResponse; + } + + + public String setFormatField() { + return formatField; + } + + public void setFormatField(String formatField) { + this.formatField = formatField; + } + + public String getFormatToFilter() { + return formatToFilter; + } + + public void setFormatToFilter(String formatToFilter) { + this.formatToFilter = formatToFilter; + } + + public int getSearchResponseSize() { + return searchResponseSize; + } + + public void setSearchResponseSize(int searchResponseSize) { + this.searchResponseSize = searchResponseSize; + } + } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/OAI_ESClient.java b/oaipmh-core/src/main/java/info/textgrid/middleware/OAI_ESClient.java index 26ee2fbb4508c5eae88ffa42cedcee20b2db4316..a22a718248a3cd866875ae8facb2c75ae8bb739c 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/OAI_ESClient.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OAI_ESClient.java @@ -1,30 +1,32 @@ package info.textgrid.middleware; +import java.util.ArrayList; +import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.elasticsearch.client.Client; -import org.elasticsearch.client.transport.TransportClient; -import org.elasticsearch.common.settings.ImmutableSettings; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.transport.InetSocketTransportAddress; +import org.apache.http.HttpHost; +import org.elasticsearch.client.RestClient; +import org.elasticsearch.client.RestHighLevelClient; /** - * Establishing to connection to an ElasticSearch client + * <p> + * Establishing to connection to an ElasticSearch client. + * </p> * - * @author Maximilian Brodhun - * @version 1.0 - * @since 09.01.2014 - * + * @author Maximilian Brodhun, SUB Göttingen + * @author Stefan E. Funk, SUB Göttingen + * @version 2019-10-30 + * @since 2014-01-09 */ public class OAI_ESClient { private Log log = LogFactory.getLog(OAI_ESClient.class); private static String url; - private static int port; + private static int[] ports; private static String esCluster; private static String esIndex; private static String esType; - public static Client oaiESClient; + private static RestHighLevelClient esClient; /** * Constructor for the connection to an ElasticSearch index @@ -33,24 +35,32 @@ public class OAI_ESClient { * @param port for the ElasticSearch connection * @param clusterName indicating the name of the cluster where the index exists */ - @SuppressWarnings("resource") - public OAI_ESClient(String url, String thePort, String clusterName) { - int port = Integer.parseInt(thePort); + public OAI_ESClient(String url, int[] ports, int itemLimit) { - this.log.info("ElasticSearch connection settings:"); - this.log.info("url = " + url); - this.log.info("port = " + port); - this.log.info("cluster name = " + clusterName); + // int port = Integer.parseInt(thePort); + + /* + * this.log.info("ElasticSearch connection settings:"); this.log.info("url = " + url); + * this.log.info("port = " + port); this.log.info("cluster name = " + clusterName); + */ OAI_ESClient.setUrl(url); - OAI_ESClient.setPort(port); - Settings oaiESClusterSettings = - ImmutableSettings.settingsBuilder().put("cluster.name", clusterName).build(); + OAI_ESClient.setPorts(ports); + + + List<HttpHost> hosts = new ArrayList<HttpHost>(); + for (int port : ports) { + hosts.add(new HttpHost(url, port, "http")); + } - oaiESClient = new TransportClient(oaiESClusterSettings) - .addTransportAddress(new InetSocketTransportAddress(url, port)); + setEsClient(new RestHighLevelClient( + RestClient.builder( + hosts.toArray(new HttpHost[hosts.size()])))); + + this.log.info( + "ElasticSearchClient started with settings: " + url + " ," + ports.toString() + " http"); } /** @@ -85,13 +95,7 @@ public class OAI_ESClient { OAI_ESClient.esType = esType; } - /** - * - * @return oaiESClient - */ - public static Client getOaiESClient() { - return oaiESClient; - } + /** * @@ -129,24 +133,38 @@ public class OAI_ESClient { * * @return port */ - public static int getPort() { - return port; + public static int[] getPort() { + return ports; } /** * * @param port */ - public static void setPort(int port) { - OAI_ESClient.port = port; + public static void setPorts(int ports[]) { + OAI_ESClient.ports = ports; } /** * * @param oaiClient */ - public static void setOaiESClient(Client theOaiClient) { - OAI_ESClient.oaiESClient = theOaiClient; + public static void setOaiESClient(RestHighLevelClient theOaiClient) { + OAI_ESClient.esClient = theOaiClient; + } + + /** + * @return + */ + public static RestHighLevelClient getEsClient() { + return esClient; + } + + /** + * @param esClient + */ + public static void setEsClient(RestHighLevelClient esClient) { + OAI_ESClient.esClient = esClient; } } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/OaiPmhClient.java b/oaipmh-core/src/main/java/info/textgrid/middleware/OaiPmhClient.java index 299b78fb99c2eeb6909d50c44ef2d315501e9b1f..f5bcfd8a6390756d37654ffe9bd6fd73011da309 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/OaiPmhClient.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OaiPmhClient.java @@ -1,5 +1,6 @@ package info.textgrid.middleware; +import java.io.IOException; import java.text.ParseException; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -31,8 +32,9 @@ public class OaiPmhClient { * @param verb * @return * @throws ParseException + * @throws IOException */ - public String request(String verb) throws ParseException { + public String request(String verb) throws ParseException, IOException { return this.producer.getRequest(verb, this.identifier, this.metadataPrefix, this.set, this.from, this.until, this.resumptionToken); } @@ -48,4 +50,4 @@ public class OaiPmhClient { + OaipmhServiceVersion.BUILDDATE; } -} +} \ No newline at end of file diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/OpenAireIdentifierList.java b/oaipmh-core/src/main/java/info/textgrid/middleware/OpenAireIdentifierList.java new file mode 100644 index 0000000000000000000000000000000000000000..8eb058adec171e3341c2beb366c5eb92bff76992 --- /dev/null +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OpenAireIdentifierList.java @@ -0,0 +1,49 @@ +package info.textgrid.middleware; + +import java.io.IOException; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.List; + +import javax.xml.datatype.DatatypeConfigurationException; + +import info.textgrid.middleware.oaipmh.HeaderType; +import info.textgrid.middleware.oaipmh.ListIdentifiersType; +import info.textgrid.middleware.oaipmh.ResumptionTokenType; + +public class OpenAireIdentifierList extends IdentifierListDelivererAbstract { + + public ResumptionTokenType resTokenForResponse; + + public OpenAireIdentifierList(boolean textgrid, boolean dariah) { + super(textgrid, dariah); + // TODO Auto-generated constructor stub + } + + public ListIdentifiersType processIdentifierList(String from, String to, String set, String resumptionToken) throws IOException { + + ListIdentifiersType openAireIddentifiersList = new ListIdentifiersType(); + //List<String> uriList = new ArrayList<String>(); + //OAIPMHUtilities oaipmhUtilities = new OAIPMHUtilities(); + + for(String uri : getUriListOfAllEditions(from, to, set, resumptionToken)) { + + OpenAireRecord openAireRecord = new OpenAireRecord(true, false); + HeaderType header = new HeaderType(); + + try { + header = openAireRecord.getRecordById(uri.replace("textgrid:", "")).getRecord().getHeader(); + } catch (ParseException | DatatypeConfigurationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + openAireIddentifiersList.getHeader().add(header); + } + + + //if(oaipmhUtilities.getResTokenForResponse()!=null) { + openAireIddentifiersList.setResumptionToken(getResTokenForResponse()); + //} + return openAireIddentifiersList; + } +} diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/OpenAireRecord.java b/oaipmh-core/src/main/java/info/textgrid/middleware/OpenAireRecord.java new file mode 100644 index 0000000000000000000000000000000000000000..e01921d9b7cf956023ab2cd4c928356c00367ff4 --- /dev/null +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OpenAireRecord.java @@ -0,0 +1,706 @@ +package info.textgrid.middleware; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.text.ParseException; +import java.util.Properties; + +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.datatype.DatatypeConfigurationException; + +import org.apache.commons.logging.LogFactory; +import org.elasticsearch.common.Strings; +import org.json.JSONException; +import org.json.JSONObject; +import org.springframework.stereotype.Component; + +import info.textgrid.middleware.oaipmh.ContributorType; +import info.textgrid.middleware.oaipmh.DateType; +import info.textgrid.middleware.oaipmh.GetRecordType; +import info.textgrid.middleware.oaipmh.HeaderType; +import info.textgrid.middleware.oaipmh.OAIPMHtype; +import info.textgrid.middleware.oaipmh.ObjectFactory; +import info.textgrid.middleware.oaipmh.OpenaireDescriptionType; +import info.textgrid.middleware.oaipmh.RelatedIdentifierType; +import info.textgrid.middleware.oaipmh.RelationType; +import info.textgrid.middleware.oaipmh.Resource; +import info.textgrid.middleware.oaipmh.Resource.AlternateIdentifiers; +import info.textgrid.middleware.oaipmh.Resource.AlternateIdentifiers.AlternateIdentifier; +import info.textgrid.middleware.oaipmh.Resource.Contributors; +import info.textgrid.middleware.oaipmh.Resource.Contributors.Contributor; +//import info.textgrid.middleware.oaipmh.Resource.Contributors.Contributor.NameIdentifier; +import info.textgrid.middleware.oaipmh.Resource.Creators; +import info.textgrid.middleware.oaipmh.Resource.Creators.Creator; +import info.textgrid.middleware.oaipmh.Resource.Creators.Creator.NameIdentifier; +import info.textgrid.middleware.oaipmh.Resource.Dates; +import info.textgrid.middleware.oaipmh.Resource.Dates.Date; +import info.textgrid.middleware.oaipmh.Resource.Descriptions; +import info.textgrid.middleware.oaipmh.Resource.Descriptions.Description; +import info.textgrid.middleware.oaipmh.Resource.Formats; +import info.textgrid.middleware.oaipmh.Resource.GeoLocations; +import info.textgrid.middleware.oaipmh.Resource.GeoLocations.GeoLocation; +import info.textgrid.middleware.oaipmh.Resource.Identifier; +import info.textgrid.middleware.oaipmh.Resource.RelatedIdentifiers; +import info.textgrid.middleware.oaipmh.Resource.RelatedIdentifiers.RelatedIdentifier; +import info.textgrid.middleware.oaipmh.Resource.ResourceType; + +import info.textgrid.middleware.oaipmh.Resource.RightsList; +import info.textgrid.middleware.oaipmh.Resource.RightsList.Rights; +import info.textgrid.middleware.oaipmh.Resource.Sizes; +import info.textgrid.middleware.oaipmh.Resource.Subjects; +import info.textgrid.middleware.oaipmh.Resource.Subjects.Subject; +import info.textgrid.middleware.oaipmh.Resource.Titles; +import info.textgrid.middleware.oaipmh.Resource.Titles.Title; +import info.textgrid.middleware.oaipmh.TitleType; + + +//import info.textgrid.middleware.oaipmh.ResourceType; + +//import info.textgrid.middleware.oaipmh.ResourceType; + +/** + * + * @author Maximilian Brodhun, SUB + * @version 1.0.0 + * @since 13.06.2020 + * + */ + +@Component +public class OpenAireRecord extends RecordDelivererAbstract { + + //Logger for errors and info + private static org.apache.commons.logging.Log log = LogFactory.getLog(OpenAireRecord.class); + + //Array containing all fields to get from the edition dataset in elasticsearch + private String[] fields; + + //Container object for the result of the elasticsearch request. This object contains the source of the response + private JSONObject jsonObj = new JSONObject(); + + //This variables contains the field requested in the ElasticSearch Index. The content will be given by a configuration file + private String[] titleFields; + private String[] dateFields; + private String[] contributorFields; + private String[] languageFields; + private String[] alternateIdentifierFields; + private String[] formatFields; + private String[] rightsFields; + private String[] descriptionFields; + private String[] relatedIdentifierFields; + private String[] workFields; + private String[] geoLocationFields; + private String[] versionFields; + private String[] subjectFields; + private String relationToWorkObject; + private String identifierField; + private String formatField; + private String handle; + private String sizeField; + + //Contains the setting to get connection to the ElasticSearch index. The content will be given by a configuration file + private OAI_ESClient oaiEsClient; + + //This variable contains the XML-content for a whole OpenAire file + private Resource resource = new Resource(); + + /** + * + * @param textgrid flag to indicate that the content of the record is context of the TextGrid repo + * @param dariah flag to indicate that the content of the record is context of the DARIAH repo + * @throws IOException + */ + public OpenAireRecord(boolean textgrid, boolean dariah) throws IOException { + super(textgrid, dariah); + + //Read the fields to request from elasticsearch from content file + InputStream input = null; + try { + input = new FileInputStream("/etc/dhrep/oaipmh/oaipmh.properties"); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + Properties prop = new Properties(); + prop.load(input); + this.setHandle(prop.getProperty("oar.handle")); + this.setFields(OAIPMHUtilities.fetchArrayFromPropFile("fields", prop)[0]); + this.setFormatField(prop.getProperty("formatField")); + this.setTitleFields(OAIPMHUtilities.fetchArrayFromPropFile("oar.titleFields", prop)[0]); + this.setDateFields(OAIPMHUtilities.fetchArrayFromPropFile("oar.dateFields", prop)[0]); + this.setContributorFields(OAIPMHUtilities.fetchArrayFromPropFile("oar.contributorFields", prop)[0]); + this.setLanguageFields(OAIPMHUtilities.fetchArrayFromPropFile("oar.languageFields", prop)[0]); + this.setAlternateIdentifierFields(OAIPMHUtilities.fetchArrayFromPropFile("oar.alternateIdentifierFields", prop)[0]); + this.setFormatFields(OAIPMHUtilities.fetchArrayFromPropFile("oar.formatFields", prop)[0]); + this.setRightsFields(OAIPMHUtilities.fetchArrayFromPropFile("oar.rightsFields", prop)[0]); + this.setDescriptionFields(OAIPMHUtilities.fetchArrayFromPropFile("oar.descriptionFields", prop)[0]); + this.setRelationToWorkObject(prop.getProperty("oar.relationToWorkObject")); + this.setRelatedIdentifierFields(OAIPMHUtilities.fetchArrayFromPropFile("oar.relatedIdentifierFields", prop)[0]); + this.setGeoLocationFields(OAIPMHUtilities.fetchArrayFromPropFile("oar.geoLocationFields", prop)[0]); + this.setVersionFields(OAIPMHUtilities.fetchArrayFromPropFile("oar.versionFields", prop)[0]); + this.setSubjectFields(OAIPMHUtilities.fetchArrayFromPropFile("oar.subjectFields", prop)[0]); + this.setSizeField(prop.getProperty("oar.sizeField")); + } + + /** + * building the record XML object for the OAI-PMH response + * @throws ParseException + */ + public GetRecordType getRecordById(String idInElasticSearchIndex) throws ParseException, DatatypeConfigurationException { + jsonObj = new JSONObject(OAIPMHUtilities.getRcordByIDFromElasticSearch(idInElasticSearchIndex.replace("textgrid:", ""), this.fields, Strings.EMPTY_ARRAY).getSource()); + + HeaderType header = new HeaderType(); + header.setDatestamp(OAIPMHUtilities.datestampAsString(OAIPMHUtilities.fieldLoader(jsonObj, TGConstants.CREATED))); + + if(!idInElasticSearchIndex.startsWith(TGConstants.ITEM_IDENTIFIER_PREFIX)) { + header.setIdentifier(TGConstants.ITEM_IDENTIFIER_PREFIX + idInElasticSearchIndex); + }else { + header.setIdentifier(idInElasticSearchIndex); + } + + GetRecordType grt = OAIPMHUtilities.getRecordType(this.setOpenAireRecord(), header); + + return grt; + } + + /** + * Put the record from open-aire into the JAXBElement container to add it to an oai-pmh object + * @param idInElasticSearchIndex + * @return + * @throws ParseException + * @throws JAXBException + * @throws DatatypeConfigurationException + */ + public JAXBElement<OAIPMHtype> getRecord(String idInElasticSearchIndex) throws ParseException, JAXBException, DatatypeConfigurationException { + ObjectFactory obf = new ObjectFactory(); + JAXBElement<OAIPMHtype> oaijaxb; + OAIPMHtype oai = new OAIPMHtype(); + HeaderType header = new HeaderType(); + + jsonObj = new JSONObject(OAIPMHUtilities.getRcordByIDFromElasticSearch(idInElasticSearchIndex, this.fields, Strings.EMPTY_ARRAY).getSource()); + + //Setting the header for the oaipmh response + header.setDatestamp(OAIPMHUtilities.datestampAsString(OAIPMHUtilities.fieldLoader(jsonObj, TGConstants.CREATED))); + //The id for the response has to be starts with "textgrid:". The id in elasticsearch is missing. In consequence is optional in oaipmh + //request to write textgrid:1233.0 or jsut 1233.0. For the response the prefix has to be added + if(!idInElasticSearchIndex.startsWith(TGConstants.ITEM_IDENTIFIER_PREFIX)) { + header.setIdentifier(TGConstants.ITEM_IDENTIFIER_PREFIX + idInElasticSearchIndex); + }else { + header.setIdentifier(idInElasticSearchIndex); + } + //It is necessary to add the GetRecordType to the OAIPMH object. + GetRecordType grt = OAIPMHUtilities.getRecordType(this.setOpenAireRecord(), header); + oai.setGetRecord(grt); + oaijaxb = obf.createOAIPMH(oai); + oaijaxb.setValue(oai); + + return oaijaxb; + } + + /** + * Adding the open aire record fields to the openaire record object + * @param idInElasticSearchIndex + * @return + * @throws ParseException + * @throws DatatypeConfigurationException + */ + private Resource setOpenAireRecord() throws ParseException, DatatypeConfigurationException { + + resource.setTitles(this.addTitles()); + resource.setPublisher(this.addPublisher()); + resource.setPublicationYear(this.addPublicationYear()); + resource.setDates(this.addDates()); + resource.setContributors(this.addContributors()); + resource.setLanguage(this.addLanguae()); + resource.setAlternateIdentifiers(this.addAlternateIdentifier()); + resource.setFormats(this.addFormats()); + resource.setRightsList(this.addRights()); + resource.setDescriptions(this.addDescriptions()); + resource.setRelatedIdentifiers(this.addRelatedIdentifiers()); + resource.setIdentifier(this.addIdentifier()); + resource.setCreators(this.addCreators()); + this.addGeoLocation(); + resource.setResourceType(this.addResourceType()); + resource.setVersion(this.addVersion()); + + if(addSubjects().getSubject().get(0).getValue()!=null) { + resource.setSubjects(this.addSubjects()); //TODO what if subjects == null? + } + + resource.setSizes(this.addSize()); + + + return resource; + } + + private Sizes addSize() { + Sizes sizes = new Sizes(); + + sizes.getSize().add(OAIPMHUtilities.fieldLoader(jsonObj, sizeField) + " Bytes"); + return sizes; + } + + + private Subjects addSubjects() { + + Subjects subjects = new Subjects(); + + for(String subjectField : subjectFields) { + Subject subject = new Subject(); + subject.setValue(OAIPMHUtilities.fieldLoader(jsonObj, subjectField + ".value")); + subject.setSchemeURI(OAIPMHUtilities.fieldLoader(jsonObj, subjectField + ".id.type")); + subject.setSubjectScheme(OAIPMHUtilities.fieldLoader(jsonObj, subjectField + ".id.value")); + subjects.getSubject().add(subject); + } + if(subjects.getSubject().get(0)!=null) { + return subjects; + }else { + return null; + } + + } + private String addVersion() { + String version = ""; + for(String versionField : versionFields) { + version = OAIPMHUtilities.fieldLoader(jsonObj, versionField); + } + + return version; + } + + private ResourceType addResourceType() { + ResourceType resourceType = new ResourceType(); + + resourceType.setResourceTypeGeneral(info.textgrid.middleware.oaipmh.ResourceType.DATASET); + + return resourceType; + } + + private void addGeoLocation() { + GeoLocations geoLocations = new GeoLocations(); + for(String geoLocationField : geoLocationFields) { + GeoLocation geoLocation = new GeoLocation(); + geoLocation.setGeoLocationPlace(OAIPMHUtilities.fieldLoader(jsonObj, geoLocationField + ".value")); + geoLocations.getGeoLocation().add(geoLocation); + } + if(geoLocations.getGeoLocation().get(0).getGeoLocationPlace()!=null) { + resource.setGeoLocations(geoLocations); + } + //return geoLocations; + } + + private RelatedIdentifiers addRelatedIdentifiers() { + RelatedIdentifiers relatedIdentifiers = new RelatedIdentifiers(); + + for (String relatedIdentifierField: relatedIdentifierFields) { + String[] workFields = {handle}; + RelatedIdentifier relatedIdentifier = new RelatedIdentifier(); + relatedIdentifier.setRelatedIdentifierType(RelatedIdentifierType.HANDLE); + //relatedIdentifier.setRelatedMetadataScheme(TGConstants.TEXTGRID_METADATASCHEME); + relatedIdentifier.setRelationType(RelationType.IS_PART_OF); + //relatedIdentifier.setSchemeType("XSD"); + //relatedIdentifier.setSchemeURI(TGConstants.TEXTGRID_METADATASCHEME_URI); + + String uriForWork = OAIPMHUtilities.fieldLoader(jsonObj, relatedIdentifierField).replace("textgrid:", ""); + relatedIdentifier.setValue(OAIPMHUtilities.fieldLoader(new JSONObject(OAIPMHUtilities.getRcordByIDFromElasticSearch(uriForWork, workFields, Strings.EMPTY_ARRAY).getSource()), handle)); + relatedIdentifiers.getRelatedIdentifier().add(relatedIdentifier); + } + + return relatedIdentifiers; + } + + private Descriptions addDescriptions() { + Descriptions descriptions = new Descriptions(); + + for (String descriptionField: descriptionFields) { + Description description = new Description(); + //description.setOpenaireDescriptionType(OpenaireDescriptionType.ABSTRACT); + //description.setOpenaireDescriptionType(OpenaireDescriptionType.ABSTRACT); + description.setDescriptionType(OpenaireDescriptionType.ABSTRACT); + String idForWorkObject = OAIPMHUtilities.fieldLoader(jsonObj, relationToWorkObject).replace("textgrid:", ""); + JSONObject resultOfFurtherObject = new JSONObject(OAIPMHUtilities.getRcordByIDFromElasticSearch(idForWorkObject, this.workFields, Strings.EMPTY_ARRAY).getSource()); + String abstractFoFWork = + OAIPMHUtilities.fieldLoader( + resultOfFurtherObject, + descriptionField); + description.setLang(abstractFoFWork); + descriptions.getDescription().add(description); + } + return descriptions; + } + + private RightsList addRights() { + RightsList rightsList = new RightsList(); + for (String rightsField: rightsFields) { + Rights rights = new Rights(); + rights.setRightsURI(OAIPMHUtilities.fieldLoader(jsonObj, rightsField + ".licenseUri")); + rights.setValue(OAIPMHUtilities.fieldLoader(jsonObj, rightsField + ".value")); + rightsList.getRights().add(rights); + } + if(rightsList.getRights().get(0).getValue()!=null) { + Rights openAccesRight = new Rights(); + openAccesRight.setRightsURI("info:eu-repo/semantics/openAccess"); + rightsList.getRights().add(openAccesRight); + } + + return rightsList; + } + + private Formats addFormats() { + Formats formats = new Formats(); + for (String formatField: formatFields) { + formats.getFormat().add(OAIPMHUtilities.fieldLoader(jsonObj, formatField)); + } + return formats; + } + + private AlternateIdentifiers addAlternateIdentifier() { + + AlternateIdentifiers alternateIdentifiers = new AlternateIdentifiers(); + for (String alternateIdentifierField: alternateIdentifierFields) { + AlternateIdentifier alternateIdentifier = new AlternateIdentifier(); + alternateIdentifier.setValue(OAIPMHUtilities.fieldLoader(jsonObj, alternateIdentifierField)); + alternateIdentifier.setAlternateIdentifierType(TGConstants.TEXTGRIDURI_IDENTIIER_TYPE); + alternateIdentifiers.getAlternateIdentifier().add(alternateIdentifier); + } + + return alternateIdentifiers; + } + + private String addLanguae() { + + String language=null; + for (String languageField: languageFields) { + language = OAIPMHUtilities.fieldLoader(jsonObj, languageField); + } + + return language; + } + + private Contributors addContributors() { + Contributors contributors = new Contributors(); + for (String contributorField: contributorFields) { + Contributor contributorInOpenAireRecord = new Contributor(); + if(contributorField.equals("project")) { + contributorInOpenAireRecord.setContributorName(OAIPMHUtilities.fieldLoader(jsonObj, contributorField + ".value")); + contributorInOpenAireRecord.setContributorType(ContributorType.OTHER); + info.textgrid.middleware.oaipmh.Resource.Contributors.Contributor.NameIdentifier name = new info.textgrid.middleware.oaipmh.Resource.Contributors.Contributor.NameIdentifier(); + name.setNameIdentifierScheme("textgrid"); + name.setValue(OAIPMHUtilities.fieldLoader(jsonObj, contributorField + ".id")); + name.setSchemeURI("http://www.textgridlab.org/schema/textgrid-metadata_2010.xsd"); + contributorInOpenAireRecord.setNameIdentifier(name); + + }else { + contributorInOpenAireRecord.setContributorName(OAIPMHUtilities.fieldLoader(jsonObj, contributorField)); + contributorInOpenAireRecord.setContributorType(ContributorType.DATA_MANAGER); + /*info.textgrid.middleware.oaipmh.Resource.Contributors.Contributor.NameIdentifier name = new info.textgrid.middleware.oaipmh.Resource.Contributors.Contributor.NameIdentifier(); + name.setNameIdentifierScheme("textgrid"); + name.setValue(""); + name.setSchemeURI("http://www.textgridlab.org/schema/textgrid-metadata_2010.xsd"); + contributorInOpenAireRecord.setNameIdentifier(name);*/ + } + contributors.getContributor().add(contributorInOpenAireRecord); + } + + return contributors; + } + + + private Dates addDates() { + + Dates dates = new Dates(); + + for (String dateField: dateFields) { + Date dateInOpenAireRecord = new Date(); + //System.out.println(dateField); + try { + dateInOpenAireRecord.setValue(OAIPMHUtilities.datestampAsString(OAIPMHUtilities.fieldLoader(jsonObj, dateField))); + } catch (ParseException e) { + // TODO Auto-generated catch block + log.error("Could not parse date field"); + } + if (dateField.equals("created")) { + dateInOpenAireRecord.setDateType(DateType.CREATED); + } + if (dateField.equals("issued")) { + dateInOpenAireRecord.setDateType(DateType.ISSUED); + } + if (dateField.equals("lastModified")) { + dateInOpenAireRecord.setDateType(DateType.UPDATED); + } + dates.getDate().add(dateInOpenAireRecord); + } + + return dates; + } + + private Identifier addIdentifier() { + Identifier identifier = new Identifier(); + identifier.setIdentifierType("Handle"); + //System.out.println(jsonObj.get("textgridUri").toString()); + try { + identifier.setValue(jsonObj.getJSONObject("pid").get("value").toString()); + + }catch(JSONException fieldNotFound) { + identifier.setValue(jsonObj.get("textgridUri").toString()); + } + + + return identifier; + } + + private Creators addCreators() { + + Creators creators = new Creators(); + /** + * Creators Field + */ + //TODO: Fields from configFile + Creator creator = new Creator(); + + creator.setCreatorName(OAIPMHUtilities.fieldLoader(jsonObj, "edition.agent.value")); + NameIdentifier nameIdentifier = new NameIdentifier(); + //TODO: creatorID Field from configfile + String creatorID = OAIPMHUtilities.fieldLoader(jsonObj, "edition.source.bibliographicCitation.author.id"); + + if (creatorID != null && creatorID.contains(":")) { + nameIdentifier.setValue(creatorID.split(":")[1]); + nameIdentifier.setNameIdentifierScheme(creatorID.split(":")[0]); + /* + * TODO Check if the scheme URI is correct + */ + nameIdentifier.setSchemeURI("https://ref.de.dariah.eu/pndsearch/pndquery.xql?id="); + }else { + nameIdentifier.setValue(creatorID); + } + creator.setNameIdentifier(nameIdentifier); + nameIdentifier.setSchemeURI("https://ref.de.dariah.eu/pndsearch/pndquery.xql?id="); + creators.getCreator().add(creator); + + return creators; + + } + + private Titles addTitles() { + Titles titles = new Titles(); + for (String titleField: titleFields) { + + Title tileInOpenAireRecord = new Title(); + tileInOpenAireRecord.setValue(OAIPMHUtilities.fieldLoader(jsonObj, titleField)); + tileInOpenAireRecord.setTitleType(TitleType.OTHER); + titles.getTitle().add(tileInOpenAireRecord); + } + + return titles; + } + + + private String addPublisher() { + /** + * Publisher fields + */ + //TODO: fields from config file + //TODO: for each field + //return OAIPMHUtilities.fieldLoader(jsonObj, "edition.source.bibliographicCitation.publisher.value"); + return "TextGrid"; + + } + + private String addPublicationYear() throws ParseException, DatatypeConfigurationException { + /** + * Publication Year fields + */ + //TODO: fields from config file + + return Integer.toString(OAIPMHUtilities.convertDateFormat(OAIPMHUtilities.fieldLoader(jsonObj, "created")).getYear()); + } + /** + * @param formatField + */ + public void setFormatField(String formatField) { + this.formatField = formatField; + } + + public String getFormatField() { + return formatField; + } + /** + * @param fields + */ + public void setFields(String[] fields) { + this.fields = fields; + } + + /** + * @return + */ + public String[] getFields() { + return this.fields; + } + + public OAI_ESClient getOaiEsClient() { + return oaiEsClient; + } + + public void setOaiEsClient(OAI_ESClient oaiEsClient) { + this.oaiEsClient = oaiEsClient; + } + + public String[] getTitleFields() { + return titleFields; + } + + public void setTitleFields(String[] titleFields) { + this.titleFields = titleFields; + } + + public Resource getResource() { + return resource; + } + + public void setResource(Resource resource) { + this.resource = resource; + } + + public String[] getDateFields() { + return dateFields; + } + + public void setDateFields(String[] dateFields) { + this.dateFields = dateFields; + } + + public String[] getContributorFields() { + return contributorFields; + } + + public void setContributorFields(String[] contributorFields) { + this.contributorFields = contributorFields; + } + + public String[] getLanguageFields() { + return languageFields; + } + + public void setLanguageFields(String[] languageFields) { + this.languageFields = languageFields; + } + + public String[] getAlternateIdentifierFields() { + return alternateIdentifierFields; + } + + public void setAlternateIdentifierFields(String[] alternateIdentifierFields) { + this.alternateIdentifierFields = alternateIdentifierFields; + } + + public String[] getFormatFields() { + return formatFields; + } + + public void setFormatFields(String[] formatFields) { + this.formatFields = formatFields; + } + + + + public String[] getRightsFields() { + return rightsFields; + } + + public void setRightsFields(String[] rightsFields) { + this.rightsFields = rightsFields; + } + + public String[] getDescriptionFields() { + return descriptionFields; + } + + public void setDescriptionFields(String[] descriptionFields) { + this.descriptionFields = descriptionFields; + } + + public String[] getRelatedIdentifierFields() { + return relatedIdentifierFields; + } + + public void setRelatedIdentifierFields(String[] relatedIdentifierFields) { + this.relatedIdentifierFields = relatedIdentifierFields; + } + + public String getRelationToWorkObject() { + return relationToWorkObject; + } + + public void setRelationToWorkObject(String relationToWorkObject) { + this.relationToWorkObject = relationToWorkObject; + } + + /** + * @return + */ + public String[] getWorkFields() { + return this.workFields; + } + + /** + * @param workFields + */ + public void setWorkFields(String[] workFields) { + this.workFields = workFields; + } + + public String getIdentifierField() { + return identifierField; + } + + public void setIdentifierField(String identifierField) { + this.identifierField = identifierField; + } + + public String[] getGeoLocationFields() { + return geoLocationFields; + } + + public void setGeoLocationFields(String[] geoLocationFields) { + this.geoLocationFields = geoLocationFields; + } + + public String getHandle() { + return handle; + } + + public void setHandle(String handle) { + this.handle = handle; + } + + public String[] getVersionFields() { + return versionFields; + } + + public void setVersionFields(String[] versionFields) { + this.versionFields = versionFields; + } + + public String[] getSubjectFields() { + return subjectFields; + } + + public void setSubjectFields(String[] subjectFields) { + this.subjectFields = subjectFields; + } + + public String getSizeField() { + return sizeField; + } + + public void setSizeField(String size) { + this.sizeField = size; + } + + + +} \ No newline at end of file diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/OpenAireRecordList.java b/oaipmh-core/src/main/java/info/textgrid/middleware/OpenAireRecordList.java new file mode 100644 index 0000000000000000000000000000000000000000..dcc0806937a7ac7939564a81794ec3511489801c --- /dev/null +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OpenAireRecordList.java @@ -0,0 +1,134 @@ +package info.textgrid.middleware; + +import java.io.IOException; +import java.text.ParseException; +import java.util.Hashtable; +import java.util.Map; + +import javax.xml.datatype.DatatypeConfigurationException; + +import info.textgrid.middleware.oaipmh.GetRecordType; +import info.textgrid.middleware.oaipmh.HeaderType; +import info.textgrid.middleware.oaipmh.ListRecordsType; +import info.textgrid.middleware.oaipmh.ResumptionTokenType; + +public class OpenAireRecordList extends RecordListDelivererAbstract { + + //protected static Map<String, Integer> cursorCollector = new Hashtable<String, Integer>(); + + + private String rangeField; + private String formatField; + private String formatToFilter; + private int searchResponseSize; + private long resultSize; + private boolean foundItems; + public ResumptionTokenType resTokenForResponse; + + public OpenAireRecordList(boolean textgrid, boolean dariah) { + super(textgrid, dariah); + } + + + public ListRecordsType getRecords(String from, String to, String set, String resumptionToken){ + ListRecordsType openAireRecordList = new ListRecordsType(); + OpenAireRecord openAireRecord; + + for(String uri : getUriList(from, to, set, resumptionToken)) { + try { + try { + openAireRecord = new OpenAireRecord(true, false); + GetRecordType grt = openAireRecord.getRecordById(uri.replace("textgrid:", "")); + openAireRecordList.getRecord().add(grt.getRecord()); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + + } catch (DatatypeConfigurationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + //if (resTokenForResponse != null) { + //System.out.println("RESTOKEN: "); + //System.out.println(getResTokenForResponse().getValue()); + //System.out.println(getResumptionToken()); + //resTokenForResponse = OAIPMHUtilities.getResumptionToken( + // 94146, resumptionToken, cursorCollector, scrollID, this.searchResponseSize, i) + openAireRecordList.setResumptionToken(getResTokenForResponse()); + //} + + return openAireRecordList; + } + + @Override + public HeaderType setHeader(String set, String headerIdentifier, String setSpec) { + // TODO Auto-generated method stub + return null; + } + + //GETTER AND SETTER + + public String getRangeField() { + return rangeField; + } + + public void setRangeField(String rangeField) { + this.rangeField = rangeField; + } + + + /** + * @param formatToFilter + */ + public void setFormatToFilter(String formatToFilter) { + this.formatToFilter = formatToFilter; + } + + /** + * @param formatField + */ + public void setFormatField(String formatField) { + this.formatField = formatField; + } + + public int getSearchResponseSize() { + return searchResponseSize; + } + + public void setSearchResponseSize(int searchResponseSize) { + this.searchResponseSize = searchResponseSize; + } + + public long getResultSize() { + return resultSize; + } + + public void setResultSize(long resultSize) { + this.resultSize = resultSize; + } + + public boolean isFoundItems() { + return foundItems; + } + + public void setFoundItems(boolean foundItems) { + this.foundItems = foundItems; + } + + + /*public ResumptionTokenType getResTokenForResponse() { + return resTokenForResponse; + } + + public void setResTokenForResponse(ResumptionTokenType resTokenForResponse) { + this.resTokenForResponse = resTokenForResponse; + }*/ + +} diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererAbstract.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererAbstract.java index c5af207168d447627aac9536b323ab8e738838ef..4249d47aef2f9a280e84a4783e7b10c2f57b1282 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererAbstract.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererAbstract.java @@ -39,8 +39,9 @@ public abstract class RecordDelivererAbstract implements RecordDelivererInterfac // Check if metadata prefix is existing and valid. if (request.getMetadataPrefix() != null - && !request.getMetadataPrefix().equals(TGConstants.METADATA_DC_PREFIX) - && !request.getMetadataPrefix().equals(TGConstants.METADATA_IDIOM_PREFIX)) { + && !request.getMetadataPrefix().equals(OAIPMHUtilities.OAIDC_PREFIX) + && !request.getMetadataPrefix().equals(TGConstants.METADATA_IDIOM_PREFIX) + && !request.getMetadataPrefix().equals(TGConstants.METADATA_OPENAIRE_PREFIX)) { result.setError(TGConstants.OAI_METADATA_FORMAT_ERROR, "The value of the metadataPrefix: " + request.getMetadataPrefix() + " is not supported by the item identified by the value of: " diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDC.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDC.java index be88db7b8646cb9735e96be9703bc0d15c7fd777..a6bf031e08280dbe5410ed8eff619126579766dd 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDC.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDC.java @@ -1,26 +1,34 @@ package info.textgrid.middleware; +import java.io.IOException; import java.text.ParseException; import javax.xml.datatype.DatatypeConfigurationException; -import org.elasticsearch.action.get.GetRequestBuilder; +import org.apache.commons.logging.LogFactory; +import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.client.RequestOptions; +import org.elasticsearch.common.Strings; +import org.elasticsearch.search.fetch.subphase.FetchSourceContext; +import org.springframework.stereotype.Component; + import info.textgrid.middleware.oaipmh.GetRecordType; import info.textgrid.middleware.oaipmh.HeaderType; import info.textgrid.middleware.oaipmh.RecordType; /** - * FIXME + * FIXME Was magst Du denn hier fixen, Herr Max? * - * @author Maximilian Brodhun SUB - * @version 1.1 - * @since 17.02.2014 + * @author Maximilian Brodhun, SUB Göttingen + * @author Stefan E. Funk, SUB Göttingen + * @version 2019-10-30 + * @since 2014-02-17 */ +@Component public class RecordDelivererDC extends RecordDelivererAbstract { private String[] fields; private String[] workFields; - private String formatField; private String formatToFilter; private String dateOfObjectCreation; @@ -43,13 +51,16 @@ public class RecordDelivererDC extends RecordDelivererAbstract { private String[] languageList; private String[] publisherList; private String[] relationList; - private String[] relationForWorkList; + // FIXME Why is this commented out? I just adapted beans.xml file. + // private String[] relationsForWorkList; private String[] rightList; private String[] sourceList; private String[] subjectList; private String[] titleList; private String[] typeList; + + private static org.apache.commons.logging.Log log = LogFactory.getLog(RecordDelivererDC.class); private OAI_ESClient oaiEsClient; /** @@ -65,7 +76,11 @@ public class RecordDelivererDC extends RecordDelivererAbstract { * * @see info.textgrid.middleware.RecordDelivererInterface#getRecordById(java.lang.String) */ - public GetRecordType getRecordById(String id) { + public GetRecordType getRecordById(String id) throws ParseException, DatatypeConfigurationException { + + String[] includes = this.fields; + String[] excludes = Strings.EMPTY_ARRAY; + FetchSourceContext fetchSourceContext = new FetchSourceContext(true, includes, excludes); GetRecordType getRecordType = new GetRecordType(); RecordType record = new RecordType(); @@ -76,17 +91,20 @@ public class RecordDelivererDC extends RecordDelivererAbstract { changedId = changedId.replace(this.repositoryObjectURIPrefix, ""); } - // TODO Must Index and Type be set here? Isn't it already set in beans.xml? - GetRequestBuilder recordById = - OAI_ESClient - .getOaiESClient() - .prepareGet() - .setIndex(OAI_ESClient.getEsIndex()) - .setType(OAI_ESClient.getEsType()) - .setFields(this.fields) - .setId(changedId); + GetRequest getRequest = + new GetRequest(OAI_ESClient.getEsIndex(), OAI_ESClient.getEsType(), id) + .fetchSourceContext(fetchSourceContext); + GetResponse esResultObject = null; + + try { + esResultObject = + OAI_ESClient.getEsClient().get(getRequest, RequestOptions.DEFAULT); - GetResponse esResultObject = recordById.execute().actionGet(); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + log.error("Could not fetch the result of ElasticSearch"); + } if (esResultObject.isExists()) { @@ -94,14 +112,14 @@ public class RecordDelivererDC extends RecordDelivererAbstract { if (this.dariah == true) { dublinCoreBuilder = putContentIntoDCFieldLists(esResultObject); - identifier = esResultObject.getField(this.identifierField).getValue().toString(); + identifier = esResultObject.getSourceAsMap().get(this.identifierField).toString(); String dateOfCreation = "NO_DATE_SET!"; if (esResultObject.getField(this.dateOfObjectCreation) != null) { try { dateOfCreation = OAIPMHUtilities .convertDateFormat( - esResultObject.getField(this.dateOfObjectCreation).getValue().toString()) + esResultObject.getSourceAsMap().get(this.dateOfObjectCreation).toString()) .toXMLFormat(); } catch (ParseException e) { // TODO Auto-generated catch block @@ -112,28 +130,34 @@ public class RecordDelivererDC extends RecordDelivererAbstract { } record.setMetadata(dublinCoreBuilder.getDC()); } - - setRecordHeader(dateOfCreation, identifier, record, dublinCoreBuilder); + String setSpec = DublinCoreFieldLoader.fillList(esResultObject, DARIAHConstants.IDENTIFIER_LIST).get(0); + setRecordHeader(OAIPMHUtilities + .convertDateFormat(dateOfCreation).toString(), identifier, record, dublinCoreBuilder, setSpec); } - if (this.textgrid == true && esResultObject.getField(this.formatField).getValue().toString() - .equals(this.formatToFilter)) { + if (this.textgrid == true + && esResultObject.getSourceAsMap().get(this.formatField).equals(this.formatToFilter)) { - String workUri = - esResultObject.getField(this.relationToFurtherMetadataObject).getValue().toString(); + + String workUri = DublinCoreFieldLoader + .fillList(esResultObject, new String[] {this.relationToFurtherMetadataObject}).get(0); workUri = workUri.substring(this.repositoryObjectURIPrefix.length()); dublinCoreBuilder = putContentIntoDCFieldLists(esResultObject, furtherDCElements(workUri)); - identifier = esResultObject.getField(this.identifierField).getValue().toString(); + identifier = esResultObject.getSourceAsMap().get(this.identifierField).toString(); String dateOfCreation = - esResultObject.getField(this.dateOfObjectCreation).getValue().toString(); - setRecordHeader(dateOfCreation, identifier, record, dublinCoreBuilder); + esResultObject.getSourceAsMap().get(this.dateOfObjectCreation).toString(); + + String setSpec = "project:" + DublinCoreFieldLoader.fillList(esResultObject, TGConstants.RELATIONS_LIST).get(0); + + setRecordHeader(OAIPMHUtilities.convertDateFormat(dateOfCreation).toString(), identifier, record, dublinCoreBuilder, setSpec); + record.setMetadata(dublinCoreBuilder.getDC()); } getRecordType.setRecord(record); } else { - getRecordType = null; + return null; } return getRecordType; @@ -144,19 +168,22 @@ public class RecordDelivererDC extends RecordDelivererAbstract { // ** /** + * This function builds the header element in the XML file for the OAI-PMH response + * * @param dateOfCreation * @param identifier - * @param record - * @param dbc + * @param record object containing all elements for the record in the OAI-PMH response + * @param dbc object containing the dublin core elements for the XML file * @return */ private static RecordType setRecordHeader(String dateOfCreation, String identifier, - RecordType record, DublinCoreBuilder dbc) { + RecordType record, DublinCoreBuilder dbc, String setSpec) { HeaderType recordHeader = new HeaderType(); - + recordHeader.setIdentifier(identifier); recordHeader.setDatestamp(dateOfCreation); + recordHeader.getSetSpec().add(setSpec); // FIXME Do add set spec here! // if (set != null) { @@ -175,99 +202,98 @@ public class RecordDelivererDC extends RecordDelivererAbstract { */ private GetResponse furtherDCElements(String id) { + String[] includes = this.workFields; + String[] excludes = Strings.EMPTY_ARRAY; + FetchSourceContext fetchSourceContext = + new FetchSourceContext(true, includes, excludes); + if (!id.endsWith(".0")) { id = id.concat(".0"); } - GetRequestBuilder getWorkValues = - OAI_ESClient.getOaiESClient() - .prepareGet() - .setIndex(OAI_ESClient.getEsIndex()) - .setType(OAI_ESClient.getEsType()) - .setId(id) - .setFields(this.workFields); - - GetResponse responseWorkValues = getWorkValues.execute().actionGet(); - - // FIXME MAX!!! DO WE NEED THST DATE??? - // FIXME MAX!!! DO WE NEED THST DATE??? - // FIXME MAX!!! DO WE NEED THST DATE??? - - // try { - // if (responseWorkValues.getField(this.dateOfObjectCreation) != null) { - // this.dates.add(OAIPMHUtillities.convertDateFormat( - // responseWorkValues.getField(this.dateOfObjectCreation).getValue().toString()) - // .toXMLFormat()); - // } - // } catch (ParseException e) { - // log.debug(e); - // } catch (DatatypeConfigurationException e) { - // log.debug(e); - // } + GetRequest getRequest = new GetRequest(OAI_ESClient.getEsIndex(), OAI_ESClient.getEsType(), id) + .fetchSourceContext(fetchSourceContext); + GetResponse responseWorkValues = null; + + try { + responseWorkValues = OAI_ESClient.getEsClient().get(getRequest, RequestOptions.DEFAULT); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } return responseWorkValues; } /** - * @param responseWorkValues - * @param relatedWorkObject + * In case of TextGrid data from two objects are necessary. The edition object and the linked work + * object. In result for building the DC-Object both objects from the ES-Index are needed + * + * @param responseWorkValues contains the edition object + * @param relatedWorkObject contains the work object related to edition object + * @throws DatatypeConfigurationException + * @throws ParseException */ private DublinCoreBuilder putContentIntoDCFieldLists(GetResponse responseWorkValues, - GetResponse relatedWorkObject) { + GetResponse relatedWorkObject) throws ParseException, DatatypeConfigurationException { DublinCoreBuilder result = new DublinCoreBuilder(); // Set DublinCore lists with content from elastic search results due to configuration. result.setContributor( - DublinCoreFieldLoader.setContributor(responseWorkValues, this.contributorList)); - result.setCoverage(DublinCoreFieldLoader.setCoverage(responseWorkValues, this.coverageList)); - result.setCreator(DublinCoreFieldLoader.setCreator(relatedWorkObject, this.creatorList)); - result.setDate(DublinCoreFieldLoader.setDate(relatedWorkObject, this.dateList)); + DublinCoreFieldLoader.fillList(responseWorkValues, this.contributorList)); + result.setCoverage(DublinCoreFieldLoader.fillList(responseWorkValues, this.coverageList)); + result.setCreator(DublinCoreFieldLoader.fillList(relatedWorkObject, this.creatorList)); + result.setDate(DublinCoreFieldLoader.fillList(relatedWorkObject, this.dateList)); result.setDescription( - DublinCoreFieldLoader.setDescription(relatedWorkObject, this.descriptionList)); - result.setFormat(DublinCoreFieldLoader.setFormat(responseWorkValues, this.formatList)); + DublinCoreFieldLoader.fillList(relatedWorkObject, this.descriptionList)); + result.setFormat(DublinCoreFieldLoader.fillList(responseWorkValues, this.formatList)); result.setIdentifier( - DublinCoreFieldLoader.setIdentifier(responseWorkValues, this.identifierList)); - result.setLanguage(DublinCoreFieldLoader.setLanguage(responseWorkValues, this.languageList)); - result.setPublisher(DublinCoreFieldLoader.setPublisher(responseWorkValues, this.publisherList)); + DublinCoreFieldLoader.fillList(responseWorkValues, this.identifierList)); + result.setLanguage(DublinCoreFieldLoader.fillList(responseWorkValues, this.languageList)); + result.setPublisher(DublinCoreFieldLoader.fillList(responseWorkValues, this.publisherList)); result.setRelation( - DublinCoreFieldLoader.setRelationForWork(responseWorkValues, this.relationList)); - result.setRights(DublinCoreFieldLoader.setRights(responseWorkValues, this.rightList)); - result.setSource(DublinCoreFieldLoader.setSources(responseWorkValues, this.sourceList)); - result.setSubject(DublinCoreFieldLoader.setSubject(relatedWorkObject, this.subjectList)); - result.setTitle(DublinCoreFieldLoader.setTitle(responseWorkValues, this.titleList)); - result.setType(DublinCoreFieldLoader.setType(relatedWorkObject, this.typeList)); + DublinCoreFieldLoader.fillList(responseWorkValues, this.relationList)); + result.setRights(DublinCoreFieldLoader.fillList(responseWorkValues, this.rightList)); + result.setSource(DublinCoreFieldLoader.fillList(responseWorkValues, this.sourceList)); + result.setSubject(DublinCoreFieldLoader.fillList(relatedWorkObject, this.subjectList)); + result.setTitle(DublinCoreFieldLoader.fillList(responseWorkValues, this.titleList)); + result.setType(DublinCoreFieldLoader.fillList(relatedWorkObject, this.typeList)); return result; } /** + * This function with just one object as parameter is for DARIAH + * * @param responseWorkValues + * @throws DatatypeConfigurationException + * @throws ParseException */ - private DublinCoreBuilder putContentIntoDCFieldLists(GetResponse responseWorkValues) { + private DublinCoreBuilder putContentIntoDCFieldLists(GetResponse responseWorkValues) throws ParseException, DatatypeConfigurationException { DublinCoreBuilder result = new DublinCoreBuilder(); // Set DublinCore lists with content from elastic search results due to configuration. result.setContributor( - DublinCoreFieldLoader.setContributor(responseWorkValues, this.contributorList)); - result.setCoverage(DublinCoreFieldLoader.setCoverage(responseWorkValues, this.coverageList)); - result.setCreator(DublinCoreFieldLoader.setCreator(responseWorkValues, this.creatorList)); - result.setDate(DublinCoreFieldLoader.setDate(responseWorkValues, this.dateList)); + DublinCoreFieldLoader.fillList(responseWorkValues, this.contributorList)); + result.setCoverage(DublinCoreFieldLoader.fillList(responseWorkValues, this.coverageList)); + result.setCreator(DublinCoreFieldLoader.fillList(responseWorkValues, this.creatorList)); + result.setDate(DublinCoreFieldLoader.fillList(responseWorkValues, this.dateList)); result.setDescription( - DublinCoreFieldLoader.setDescription(responseWorkValues, this.descriptionList)); - result.setFormat(DublinCoreFieldLoader.setFormat(responseWorkValues, this.formatList)); + DublinCoreFieldLoader.fillList(responseWorkValues, this.descriptionList)); + result.setFormat(DublinCoreFieldLoader.fillList(responseWorkValues, this.formatList)); result.setIdentifier( - DublinCoreFieldLoader.setIdentifier(responseWorkValues, this.identifierList)); - result.setLanguage(DublinCoreFieldLoader.setLanguage(responseWorkValues, this.languageList)); - result.setPublisher(DublinCoreFieldLoader.setPublisher(responseWorkValues, this.publisherList)); + DublinCoreFieldLoader.fillList(responseWorkValues, this.identifierList)); + result.setLanguage(DublinCoreFieldLoader.fillList(responseWorkValues, this.languageList)); + result.setPublisher(DublinCoreFieldLoader.fillList(responseWorkValues, this.publisherList)); result.setRelation( - DublinCoreFieldLoader.setRelation(responseWorkValues, this.relationList)); - result.setRights(DublinCoreFieldLoader.setRights(responseWorkValues, this.rightList)); - result.setSource(DublinCoreFieldLoader.setSources(responseWorkValues, this.sourceList)); - result.setSubject(DublinCoreFieldLoader.setSubject(responseWorkValues, this.subjectList)); - result.setTitle(DublinCoreFieldLoader.setTitle(responseWorkValues, this.titleList)); - result.setType(DublinCoreFieldLoader.setType(responseWorkValues, this.typeList)); + DublinCoreFieldLoader.fillList(responseWorkValues, this.relationList)); + result.setRights(DublinCoreFieldLoader.fillList(responseWorkValues, this.rightList)); + result.setSource(DublinCoreFieldLoader.fillList(responseWorkValues, this.sourceList)); + result.setSubject(DublinCoreFieldLoader.fillList(responseWorkValues, this.subjectList)); + result.setTitle(DublinCoreFieldLoader.fillList(responseWorkValues, this.titleList)); + result.setType(DublinCoreFieldLoader.fillList(responseWorkValues, this.typeList)); return result; } @@ -423,12 +449,12 @@ public class RecordDelivererDC extends RecordDelivererAbstract { this.relationList = relationsList; } - /** - * @param relationsList - */ - public void setRelationsForWork(String[] relationsList) { - this.relationForWorkList = relationsList; - } + // /** + // * @param relationsForWorkList + // */ + // public void setRelationsForWork(String[] relationsForWorkList) { + // this.relationsForWorkList = relationsForWorkList; + // } /** * @param rightsList diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererIDIOM.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererIDIOM.java index e14a05110e965234284ff5aa9b148314f5bfd583..4ec901147058b80c3f23c6d78f478bff7e4e5ab8 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererIDIOM.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererIDIOM.java @@ -1,15 +1,21 @@ package info.textgrid.middleware; +import java.io.IOException; import java.io.StringReader; import java.text.ParseException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; -import org.w3c.dom.Document; -import org.xml.sax.InputSource; import org.apache.commons.logging.LogFactory; import org.classicmayan.tools.ClassicMayanMetsMods; -import org.elasticsearch.action.get.GetRequestBuilder; +import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.client.RequestOptions; +import org.elasticsearch.common.Strings; +import org.elasticsearch.search.fetch.subphase.FetchSourceContext; +import org.json.JSONObject; +import org.springframework.stereotype.Component; +import org.w3c.dom.Document; +import org.xml.sax.InputSource; import info.textgrid.middleware.oaipmh.GetRecordType; import info.textgrid.middleware.oaipmh.HeaderType; import info.textgrid.middleware.oaipmh.MetadataType; @@ -17,13 +23,13 @@ import info.textgrid.middleware.oaipmh.RecordType; import info.textgrid.middleware.oaipmh.StatusType; /** - * * @author Maximilian Brodhun, SUB Göttingen - * @since 2019-03-08 + * @author Stefan E. Funk, SUB Göttingen + * @since 2019-10-28 * @version 2019-03-12 - * */ +@Component public class RecordDelivererIDIOM extends RecordDelivererAbstract { private String dateOfObjectCreation; @@ -51,15 +57,22 @@ public class RecordDelivererIDIOM extends RecordDelivererAbstract { */ /** + * <p> * ElasticSearch request in non-public index to get the datestamps for the object creation and - * last modification date in TextGrid-Repo + * last modification date in TextGrid-Repo. + * </p> * * @param idInDatabase + * @throws ParseException */ + public void setDatestamps(String idInDatabase) throws ParseException { - public void setDatestamps(String idInDatabase) { String changedId = idInDatabase; + String[] includes = new String[] {TGConstants.CREATED, TGConstants.MODIFIED_FIELD}; + String[] excludes = Strings.EMPTY_ARRAY; + FetchSourceContext fetchSourceContext = new FetchSourceContext(true, includes, excludes); + if (idInDatabase.startsWith("textgrid:")) { changedId = idInDatabase.substring("textgrid:".length()); } @@ -73,6 +86,7 @@ public class RecordDelivererIDIOM extends RecordDelivererAbstract { if(changedId.contains(".1")) { changedId = changedId.replace(".1", ""); } +<<<<<<< HEAD System.out.println("id in elasticsearch is: " + changedId); @@ -88,17 +102,45 @@ public class RecordDelivererIDIOM extends RecordDelivererAbstract { this.dateOfObjectCreation = objectInDatabase.getField(TGConstants.CREATED).getValue().toString(); +======= + + GetRequest getRequest = + new GetRequest(OAI_ESClient.getEsIndex(), OAI_ESClient.getEsType(), changedId) + .fetchSourceContext(fetchSourceContext); + GetResponse objectInDatabase = null; + + try { + objectInDatabase = OAI_ESClient.getEsClient().get(getRequest, RequestOptions.DEFAULT); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + JSONObject json = new JSONObject(); + String[] fields = {TGConstants.CREATED,TGConstants.MODIFIED_FIELD}; + json = new JSONObject(OAIPMHUtilities.getRcordByIDFromElasticSearch(changedId, fields, Strings.EMPTY_ARRAY).getSource()); + + System.out.println("id in elasticsearch is: " + OAIPMHUtilities.datestampAsString(OAIPMHUtilities.fieldLoader(json, TGConstants.CREATED))); + System.out.println(json); + this.dateOfObjectCreation = OAIPMHUtilities.datestampAsString(OAIPMHUtilities.fieldLoader(json, TGConstants.CREATED)); + //objectInDatabase.getField(TGConstants.CREATED).getValue().toString(); +>>>>>>> feature/elastic6 - this.dateOfLastOblectModification = - objectInDatabase.getField(TGConstants.MODIFIED_FIELD).getValue().toString(); + this.dateOfLastOblectModification = OAIPMHUtilities.datestampAsString(OAIPMHUtilities.fieldLoader(json, TGConstants.MODIFIED_FIELD)); + // objectInDatabase.getField(TGConstants.MODIFIED_FIELD).getValue().toString(); } /** * building the record XML object for the OAI-PMH response + * @throws ParseException */ +<<<<<<< HEAD public GetRecordType getRecordById(String id) { ClassicMayanMetsMods metsmods; +======= + public GetRecordType getRecordById(String id) throws ParseException { + +>>>>>>> feature/elastic6 GetRecordType grt = new GetRecordType(); setDatestamps(id); @@ -135,13 +177,19 @@ public class RecordDelivererIDIOM extends RecordDelivererAbstract { // ** /** - * Getting the Mets/Mods object for the ClassicMayan artefact and put them into metadata element - * of the OAI-PMH response + * <p> + * Getting the Mets/Mods object for the ClassicMayan artifact and put them into metadata element + * of the OAI-PMH response. + * </p> * - * @return metadata XML-Elment + * @return */ +<<<<<<< HEAD private MetadataType idiomMets(ClassicMayanMetsMods metsmods) { +======= + private MetadataType idiomMets() { +>>>>>>> feature/elastic6 MetadataType metadataMets = new MetadataType(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); @@ -158,12 +206,9 @@ public class RecordDelivererIDIOM extends RecordDelivererAbstract { return metadataMets; } - - /** * @param dateOfCreation * @param identifier - * @return * @throws ParseException */ private void setRecordHeader(String dateOfCreation, String identifier) throws ParseException { @@ -177,10 +222,16 @@ public class RecordDelivererIDIOM extends RecordDelivererAbstract { // return recordHeader; } + /** + * @return + */ public OAI_ESClient getOaiEsClient() { return this.oaiEsClient; } + /** + * @param oaiEsClient + */ public void setOaiEsClient(OAI_ESClient oaiEsClient) { this.oaiEsClient = oaiEsClient; } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererInterface.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererInterface.java index 133a902258065444fc5e24e4a3915ccade5026ea..c4b353b0a34e26d235d8630f3183247c14924cc2 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererInterface.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererInterface.java @@ -1,5 +1,9 @@ package info.textgrid.middleware; +import java.text.ParseException; + +import javax.xml.datatype.DatatypeConfigurationException; + import info.textgrid.middleware.oaipmh.GetRecordType; /** @@ -18,7 +22,9 @@ public interface RecordDelivererInterface { * * @param id identifier within database * @return Get the GetRecord response for the request + * @throws DatatypeConfigurationException + * @throws ParseException */ - GetRecordType getRecordById(String id); + GetRecordType getRecordById(String id) throws ParseException, DatatypeConfigurationException; } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererAbstract.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererAbstract.java index a62afe19609d2a17f75bac188d051f98d7913555..41c047dde1b9c192e2737c64caf29ce12d4c70d7 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererAbstract.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererAbstract.java @@ -1,17 +1,49 @@ package info.textgrid.middleware; +import java.io.IOException; import java.util.ArrayList; +import java.util.Hashtable; import java.util.List; +import java.util.Map; + +import org.apache.commons.logging.LogFactory; +import org.apache.jena.atlas.logging.Log; +import org.elasticsearch.action.search.SearchRequest; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.search.SearchScrollRequest; +import org.elasticsearch.client.RequestOptions; +import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.index.query.QueryBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.search.SearchHit; +import org.elasticsearch.search.builder.SearchSourceBuilder; + import info.textgrid.middleware.oaipmh.RequestType; +import info.textgrid.middleware.oaipmh.ResumptionTokenType; /** * */ public abstract class RecordListDelivererAbstract implements RecordListDelivererInterface { + private OAI_ESClient oaiEsClient; + protected boolean textgrid; protected boolean dariah; + private String rangeField; + private String formatField; + private String formatToFilter; + private int searchResponseSize; + private long resultSize; + private boolean foundItems; + public ResumptionTokenType resTokenForResponse; + + private static final int LIFETIME_RES_TOKEN = 600; + protected static Map<String, Integer> cursorCollector = new Hashtable<String, Integer>(); + + private static org.apache.commons.logging.Log log = LogFactory.getLog(RecordListDelivererAbstract.class); + /** * @param textgrid * @param dariah @@ -21,6 +53,117 @@ public abstract class RecordListDelivererAbstract implements RecordListDeliverer this.dariah = dariah; } + public List<String> getUriList(String from, String to, String set, String resumptionToken) { + + QueryBuilder query; + //System.out.println("RANGEFIELD: " + "created"); + QueryBuilder rangeQuery = QueryBuilders.rangeQuery("created").from(from).to(to); + + QueryBuilder filterSandBox = QueryBuilders.matchPhraseQuery("nearlyPublished", "true"); + + if(set!=null && !set.equals("openaire_data")) { + String[] setParts = set.split(":"); + + String queryField = ""; + String valueField = ""; + + if (setParts[0].equals(TGConstants.SET_FIELD_FOR_TEXTGRID)) { + queryField = TGConstants.PROJECT_ID_FOR_TEXTGRID; + valueField = setParts[1]; + } + + QueryBuilder matchQuery = QueryBuilders.matchPhraseQuery(queryField, valueField); + QueryBuilder boolQuery = QueryBuilders.boolQuery().must(rangeQuery).must(matchQuery).mustNot(filterSandBox); + + query = boolQuery; + }else { + //query = rangeQuery; + query = QueryBuilders.boolQuery().must(rangeQuery).mustNot(filterSandBox); + } + + return getFieldsFromESIndex(query, resumptionToken, set); + } + + + public List<String> getFieldsFromESIndex(QueryBuilder query, String resumptionToken, + String set) { + + List<String> uriList = new ArrayList<String>(); + QueryBuilder recordFilter = QueryBuilders.boolQuery().must(query) + .must(QueryBuilders.matchPhraseQuery("format", "text/tg.edition+tg.aggregation+xml")); + + SearchRequest searchRequest = new SearchRequest(OAI_ESClient.getEsIndex()); + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); + + + searchSourceBuilder.query(recordFilter); + searchSourceBuilder.size(100); + searchRequest.source(searchSourceBuilder); + + SearchResponse scrollResp = new SearchResponse(); + + if (resumptionToken != null) { + + SearchScrollRequest scrollRequest = new SearchScrollRequest(resumptionToken); + scrollRequest.scroll(TimeValue.timeValueHours(24L)); + + try { + + scrollResp = OAI_ESClient.getEsClient().scroll(scrollRequest, RequestOptions.DEFAULT); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else { + searchRequest.source(searchSourceBuilder); + searchRequest.scroll(TimeValue.timeValueHours(24L)); + try { + scrollResp = OAI_ESClient.getEsClient().search(searchRequest,RequestOptions.DEFAULT); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + String scrollID = scrollResp.getScrollId(); + long completeListSize = scrollResp.getHits().totalHits; + setResultSize(completeListSize); + + if (completeListSize > 0) { + + setFoundItems(true); + int i=0; + + for (SearchHit hit : scrollResp.getHits().getHits()) { + i++; + if (hit != null && hit.getFields() != null) { + uriList.add(hit.getSourceAsMap().get(TGConstants.URI).toString()); + } + } + if(resumptionToken!=null && resTokenForResponse.getCursor().intValue()>=completeListSize) { + try{ + cursorCollector.remove(resumptionToken); + }catch(NullPointerException couldNotRemove) { + log.info("Could net remove hash value: " + resumptionToken + " from hash map"); + } + resTokenForResponse.setValue(""); + }else { + resTokenForResponse = OAIPMHUtilities.getResumptionToken( + completeListSize, resumptionToken, cursorCollector, scrollID, this.searchResponseSize, i); + } + + // System.out.println("TADA: "); + //System.out.println(cursorCollector); + + }else { + setFoundItems(false); + } + //System.out.println(resTokenForResponse.getValue()); + //System.out.println(resTokenForResponse.getCursor()); + return uriList; + } + + /** * @param request * @return @@ -28,11 +171,12 @@ public abstract class RecordListDelivererAbstract implements RecordListDeliverer public static ErrorHandler requestChecker(RequestType request) { ErrorHandler result = new ErrorHandler(); - + // Check if metadata prefix is existing and valid. if (request.getMetadataPrefix() != null - && !request.getMetadataPrefix().equals(TGConstants.METADATA_DC_PREFIX) - && !request.getMetadataPrefix().equals(TGConstants.METADATA_IDIOM_PREFIX)) { + && !request.getMetadataPrefix().equals(OAIPMHUtilities.OAIDC_PREFIX) + && !request.getMetadataPrefix().equals(TGConstants.METADATA_IDIOM_PREFIX) + && !request.getMetadataPrefix().equals(TGConstants.METADATA_OPENAIRE_PREFIX)) { result.setError(TGConstants.OAI_METADATA_FORMAT_ERROR, "The value of the metadataPrefix: " + request.getMetadataPrefix() + " is not supported by the item identified by the value of: " @@ -41,28 +185,40 @@ public abstract class RecordListDelivererAbstract implements RecordListDeliverer // Check if resumptionToken is invalid or existing. if (request.getResumptionToken() != null) { - boolean restokDCExisting = RecordListDelivererIDIOM.cursorCollector != null - && RecordListDelivererIDIOM.cursorCollector.containsKey(request.getResumptionToken()); - boolean restokIDIOMExisting = RecordListDelivererDC.cursorCollector != null - && RecordListDelivererDC.cursorCollector.containsKey(request.getResumptionToken()); - if (restokDCExisting || restokIDIOMExisting) { - result.setError(TGConstants.OAI_BAD_RESUMPTION_TOKEN, "The value of the " - + request.getResumptionToken() + " argument is invalid or expired."); + boolean restokIDIOMExisting = RecordListDelivererIDIOM.cursorCollector != null + && RecordListDelivererIDIOM.cursorCollector.containsKey(request.getResumptionToken()); + + boolean restokDCExisting = RecordListDelivererDC.cursorCollector != null + && RecordListDelivererDC.cursorCollector.containsKey(request.getResumptionToken()); + boolean restok = cursorCollector != null + && cursorCollector.containsKey(request.getResumptionToken()); + + if (!restokDCExisting && !restokIDIOMExisting && !restok) { + result.setError(TGConstants.OAI_BAD_RESUMPTION_TOKEN, "The value of the " + + request.getResumptionToken() + " argument is invalid or expired."); + } } - } + + // Check params in general. List<String> errorValues = new ArrayList<String>(); - if (request.getResumptionToken() != null && request.getMetadataPrefix() != null) { - errorValues.add("metadataPrefix"); - } if (request.getResumptionToken() == null && request.getMetadataPrefix() == null) { errorValues.add("metadataPrefix"); } if (request.getIdentifier() != null) { errorValues.add("identifier"); } + /* if(request.getFrom()!= null && (!OAIPMHUtilities.isThisDateValid(request.getFrom()) && !OAIPMHUtilities.isThisDateValidToOtherTimeStamp(request.getFrom()))) { + errorValues.add("from"); + } + if(request.getUntil() != null && (!OAIPMHUtilities.isThisDateValid(request.getUntil()) && !OAIPMHUtilities.isThisDateValidToOtherTimeStamp(request.getUntil()))) { + errorValues.add("until"); + } + if(request.getFrom()!= null && request.getUntil()!=null && !OAIPMHUtilities.getFormatOfDate(request.getFrom()).equals(OAIPMHUtilities.getFormatOfDate(request.getFrom()))) { + errorValues.add("until, from"); + }*/ if (errorValues.size() > 0) { result.setError(TGConstants.OAI_BAD_ARGUMENT, "The request includes illegal arguments " + "or is missing required arguments: " + errorValues); @@ -71,4 +227,72 @@ public abstract class RecordListDelivererAbstract implements RecordListDeliverer return result; } + + + //GETTER AND SETTER + + public String getRangeField() { + return rangeField; + } + + public void setRangeField(String rangeField) { + this.rangeField = rangeField; + } + + + /** + * @param formatToFilter + */ + public void setFormatToFilter(String formatToFilter) { + this.formatToFilter = formatToFilter; + } + + /** + * @param formatField + */ + public void setFormatField(String formatField) { + this.formatField = formatField; + } + + public int getSearchResponseSize() { + return searchResponseSize; + } + + public void setSearchResponseSize(int searchResponseSize) { + //System.out.println("SearchResponseSize: " + searchResponseSize); + this.searchResponseSize = searchResponseSize; + } + + public long getResultSize() { + return resultSize; + } + + public void setResultSize(long resultSize) { + this.resultSize = resultSize; + } + + public boolean isFoundItems() { + return foundItems; + } + + public void setFoundItems(boolean foundItems) { + this.foundItems = foundItems; + } + + public OAI_ESClient getOaiEsClient() { + return oaiEsClient; + } + + public void setOaiEsClient(OAI_ESClient oaiEsClient) { + this.oaiEsClient = oaiEsClient; + } + + public ResumptionTokenType getResTokenForResponse() { + return resTokenForResponse; + } + + public void setResTokenForResponse(ResumptionTokenType resTokenForResponse) { + this.resTokenForResponse = resTokenForResponse; + } + } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDC.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDC.java index 621f45e1c84bff637d80cc36963de3a1e8119e00..406de81eb53e766e5a1fdcd137db3940a97cdbe3 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDC.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDC.java @@ -1,5 +1,6 @@ package info.textgrid.middleware; +import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.text.ParseException; @@ -7,14 +8,20 @@ import java.util.Hashtable; import java.util.Map; import javax.xml.datatype.DatatypeConfigurationException; import org.apache.commons.logging.LogFactory; -import org.elasticsearch.action.get.GetRequestBuilder; +import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.client.Client; +import org.elasticsearch.action.search.SearchScrollRequest; +import org.elasticsearch.client.RequestOptions; +import org.elasticsearch.client.RestHighLevelClient; +import org.elasticsearch.common.Strings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.SearchHit; +import org.elasticsearch.search.builder.SearchSourceBuilder; +import org.elasticsearch.search.fetch.subphase.FetchSourceContext; import info.textgrid.middleware.oaipmh.HeaderType; import info.textgrid.middleware.oaipmh.ListRecordsType; import info.textgrid.middleware.oaipmh.MetadataType; @@ -26,17 +33,28 @@ import info.textgrid.middleware.oaipmh.ResumptionTokenType; */ public class RecordListDelivererDC extends RecordListDelivererAbstract { + // ** + // FINALS + // ** + + private static final int LIFETIME_RES_TOKEN = 600; + // ** // STATICS // ** private static org.apache.commons.logging.Log log = LogFactory.getLog(OAIPMHImpl.class); + protected static Map<String, Integer> cursorCollector = new Hashtable<String, Integer>(); // ** // CLASS VARIABLES // ** private OAI_ESClient oaiEsClient; + + private boolean foundItems; + private int searchResponseSize; + private long resultSize; private String[] fields; private String[] workFields; private String formatField; @@ -47,7 +65,7 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract { private String rangeField; private String modifiedField; private String identifierField; - private boolean foundItems; + private String modifiedValue; // ** // DC-Field Lists @@ -63,18 +81,12 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract { private String[] languageList; private String[] publisherList; private String[] relationList; - private String[] relationForWorkList; + private String[] relationsForWorkList; private String[] rightList; private String[] sourceList; private String[] subjectList; private String[] titleList; private String[] typeList; - private String modifiedValue; - private static final int lifeTimeResToken = 60000; - - static Map<String, Integer> cursorCollector = new Hashtable<String, Integer>(); - - private int searchResponseSize; /** * @param textgrid @@ -94,7 +106,7 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract { * @param client * @return */ - public GetResponse furtherDCElements(String id, Client client) { + public GetResponse furtherDCElements(String id, RestHighLevelClient client) { if (id != null) { try { @@ -102,16 +114,20 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract { } catch (UnsupportedEncodingException e) { e.printStackTrace(); } - - GetRequestBuilder getWorkValues = - OAI_ESClient.getOaiESClient() - .prepareGet() - .setIndex(OAI_ESClient.getEsIndex()) - .setType(OAI_ESClient.getEsType()) - .setId(id) - .setFields(this.workFields); - - GetResponse responseWorkValues = getWorkValues.execute().actionGet(); + String[] includes = this.workFields; + String[] excludes = Strings.EMPTY_ARRAY; + FetchSourceContext fetchSourceContext = new FetchSourceContext(true, includes, excludes); + GetRequest getRequest = + new GetRequest(OAI_ESClient.getEsIndex(), OAI_ESClient.getEsType(), id) + .fetchSourceContext(fetchSourceContext); + + GetResponse responseWorkValues = null; + try { + responseWorkValues = OAI_ESClient.getEsClient().get(getRequest, RequestOptions.DEFAULT); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } return responseWorkValues; } @@ -137,6 +153,7 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract { SearchResponse scrollResp; QueryBuilder recordFilter; DublinCoreBuilder dublinCoreBuilder = new DublinCoreBuilder(); + if (this.dariah == true) { recordFilter = query; } else { @@ -144,27 +161,44 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract { .must(QueryBuilders.matchPhraseQuery(this.formatField, this.formatToFilter)); } - if (resumptionToken == null) { - scrollResp = OAI_ESClient.getOaiESClient() - .prepareSearch(OAI_ESClient.getEsIndex()) - .setScroll(new TimeValue(lifeTimeResToken)) - .setTypes(OAI_ESClient.getEsType()) - .addFields(this.fields) - .setQuery(recordFilter) - .setSize(this.searchResponseSize) - .execute() - .actionGet(); + SearchRequest searchRequest = new SearchRequest(OAI_ESClient.getEsIndex()); + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); + + scrollResp = null; + + searchSourceBuilder.query(recordFilter); + searchSourceBuilder.size(100); + searchRequest.source(searchSourceBuilder); + + if (resumptionToken != null) { + SearchScrollRequest scrollRequest = new SearchScrollRequest(resumptionToken); + scrollRequest.scroll(TimeValue.timeValueSeconds(LIFETIME_RES_TOKEN)); + + try { + scrollResp = OAI_ESClient.getEsClient().scroll(scrollRequest, RequestOptions.DEFAULT); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } else { - scrollResp = OAI_ESClient.getOaiESClient().prepareSearchScroll(resumptionToken) - .setScroll(new TimeValue(lifeTimeResToken)).execute().actionGet(); + searchRequest.source(searchSourceBuilder); + searchRequest.scroll(TimeValue.timeValueMinutes(LIFETIME_RES_TOKEN)); + try { + scrollResp = OAI_ESClient.getEsClient().search(searchRequest, RequestOptions.DEFAULT); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } log.info("Queried fields: " + this.fields.toString()); - log.info("Lifetime for resumption token is set to: " + lifeTimeResToken); + log.info("Lifetime for resumption token is set to: " + LIFETIME_RES_TOKEN); scrollID = scrollResp.getScrollId(); - long completeListSize = scrollResp.getHits().totalHits(); + long completeListSize = scrollResp.getHits().totalHits; + setResultSize(completeListSize); + if (completeListSize > 0) { setFoundItems(true); @@ -175,45 +209,62 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract { if (hit != null && hit.getFields() != null) { try { - if (hit.getFields().get(this.dateOfObjectCreation) != null) { - String datestamp = - hit.getFields().get(this.dateOfObjectCreation).getValue().toString(); + if (hit.getSourceAsMap().get(this.dateOfObjectCreation) != null) { + String datestamp = hit.getSourceAsMap().get(this.dateOfObjectCreation).toString(); datestamp = OAIPMHUtilities.convertDateFormat(datestamp).toXMLFormat(); } - } catch (ParseException e1) { - log.debug(e1); - } catch (DatatypeConfigurationException e1) { - log.debug(e1); + } catch (ParseException ee) { + log.debug(ee); + } catch (DatatypeConfigurationException e) { + log.debug(e); } - - this.modifiedValue = hit.getFields().get(this.modifiedField).getValue().toString(); + + this.modifiedValue = hit.getSourceAsMap().get(this.modifiedField).toString(); // TextGrid search! String workUri = ""; - - if (this.textgrid == true && hit.getFields().get(this.formatField).values().get(0) + String[] blaFields = new String[] {this.relationToFurtherMetadataObject}; + if (this.textgrid == true && hit.getSourceAsMap().get(this.formatField) .toString().equals(this.formatToFilter)) { - if (hit.getFields().get(this.relationToFurtherMetadataObject) != null) { - workUri = hit.getFields().get(this.relationToFurtherMetadataObject).values().get(0) - .toString().substring(this.repositoryObjectURIPrefix.length()); + + String setSpec = "project:" + DublinCoreFieldLoader.fillList(hit, TGConstants.RELATIONS_LIST).get(0); + if (DublinCoreFieldLoader.fillList(hit, blaFields).get(0) != null) { + workUri = DublinCoreFieldLoader.fillList(hit, blaFields).get(0) + .substring(this.repositoryObjectURIPrefix.length()); if (!workUri.endsWith(".0")) { workUri = workUri.concat(".0"); } } - - dublinCoreBuilder = putContentIntoDCFieldLists(hit, - furtherDCElements(workUri, OAI_ESClient.getOaiESClient())); - - buildRecord(recordList, set, - hit.getFields().get(this.identifierField).getValue().toString(), dublinCoreBuilder); + try { + dublinCoreBuilder = putContentIntoDCFieldLists(hit, + furtherDCElements(workUri, OAI_ESClient.getEsClient())); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (DatatypeConfigurationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + buildRecord(recordList, set, hit.getSourceAsMap().get(this.identifierField).toString(), + dublinCoreBuilder, setSpec); } if (this.dariah == true) { - dublinCoreBuilder = putContentIntoDCFieldLists2(hit, - furtherDCElements(hit.getId(), OAI_ESClient.getOaiESClient())); + String setSpec = "hdl:" + DublinCoreFieldLoader.fillList(hit, DARIAHConstants.IDENTIFIER_LIST).get(0); + try { + dublinCoreBuilder = putContentIntoDCFieldLists2(hit, + furtherDCElements(hit.getId(), OAI_ESClient.getEsClient())); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (DatatypeConfigurationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } buildRecord(recordList, set, - hit.getFields().get(this.identifierField).getValue().toString(), dublinCoreBuilder); + hit.getSourceAsMap().get(this.identifierField).toString(), dublinCoreBuilder, setSpec); } } } @@ -221,9 +272,13 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract { // Check the need for a resumption token! ResumptionTokenType resTokenForResponse = OAIPMHUtilities.getResumptionToken( completeListSize, resumptionToken, cursorCollector, scrollID, this.searchResponseSize, i); - if (resTokenForResponse != null) { + + //if (resTokenForResponse != null) { + recordList.setResumptionToken(resTokenForResponse); - } + System.out.println("RESTOKEN: "); + System.out.println(recordList.getResumptionToken()); + //} } else { setFoundItems(false); @@ -234,31 +289,33 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract { * @param hit * @param responseWorkValues * @return + * @throws DatatypeConfigurationException + * @throws ParseException */ public DublinCoreBuilder putContentIntoDCFieldLists(SearchHit hit, - GetResponse responseWorkValues) { + GetResponse responseWorkValues) throws ParseException, DatatypeConfigurationException { DublinCoreBuilder result = new DublinCoreBuilder(); - result.setContributor( - DublinCoreFieldLoader.setContributor(responseWorkValues, this.contributorList)); - result.setCoverage(DublinCoreFieldLoader.setCoverage(responseWorkValues, this.coverageList)); - result.setCreator(DublinCoreFieldLoader.setCreator(responseWorkValues, this.creatorList)); - result.setDate(DublinCoreFieldLoader.setDate(responseWorkValues, this.dateList)); + result.setContributor(DublinCoreFieldLoader.fillList(responseWorkValues, this.contributorList)); + result.setCoverage(DublinCoreFieldLoader.fillList(responseWorkValues, this.coverageList)); + result.setCreator(DublinCoreFieldLoader.fillList(responseWorkValues, this.creatorList)); + result.setDate(DublinCoreFieldLoader.fillList(responseWorkValues, this.dateList)); + result.setDescription( - DublinCoreFieldLoader.setDescription(responseWorkValues, this.descriptionList)); - result.setFormat(DublinCoreFieldLoader.setFormat(hit, this.formatList)); - result.setIdentifier(DublinCoreFieldLoader.setIdentifier(hit, this.identifierList)); - result.setLanguage(DublinCoreFieldLoader.setLanguage(hit, this.languageList)); - result.setPublisher(DublinCoreFieldLoader.setPublisher(hit, this.publisherList)); - result.setRelation(DublinCoreFieldLoader.setRelation(hit, this.relationList)); + DublinCoreFieldLoader.fillList(responseWorkValues, this.descriptionList)); + result.setFormat(DublinCoreFieldLoader.fillList(hit, this.formatList)); + result.setIdentifier(DublinCoreFieldLoader.fillList(hit, this.identifierList)); + result.setLanguage(DublinCoreFieldLoader.fillList(hit, this.languageList)); + result.setPublisher(DublinCoreFieldLoader.fillList(hit, this.publisherList)); + result.setRelation(DublinCoreFieldLoader.fillList(hit, this.relationList)); result.setRelation( - DublinCoreFieldLoader.setRelationForWork(responseWorkValues, this.relationForWorkList)); - result.setRights(DublinCoreFieldLoader.setRights(hit, this.rightList)); - result.setSource(DublinCoreFieldLoader.setSources(hit, this.sourceList)); - result.setSubject(DublinCoreFieldLoader.setSubject(hit, this.subjectList)); - result.setTitle(DublinCoreFieldLoader.setTitle(hit, this.titleList)); - result.setType(DublinCoreFieldLoader.setType(responseWorkValues, this.typeList)); + DublinCoreFieldLoader.fillList(responseWorkValues, this.relationsForWorkList)); + result.setRights(DublinCoreFieldLoader.fillList(hit, this.rightList)); + result.setSource(DublinCoreFieldLoader.fillList(hit, this.sourceList)); + result.setSubject(DublinCoreFieldLoader.fillList(hit, this.subjectList)); + result.setTitle(DublinCoreFieldLoader.fillList(hit, this.titleList)); + result.setType(DublinCoreFieldLoader.fillList(responseWorkValues, this.typeList)); return result; } @@ -267,27 +324,29 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract { * @param hit * @param responseWorkValues * @return + * @throws DatatypeConfigurationException + * @throws ParseException */ public DublinCoreBuilder putContentIntoDCFieldLists2(SearchHit hit, - GetResponse responseWorkValues) { + GetResponse responseWorkValues) throws ParseException, DatatypeConfigurationException { DublinCoreBuilder result = new DublinCoreBuilder(); - result.setContributor(DublinCoreFieldLoader.setContributor(hit, this.contributorList)); - result.setCoverage(DublinCoreFieldLoader.setCoverage(hit, this.coverageList)); - result.setCreator(DublinCoreFieldLoader.setCreator(hit, this.creatorList)); - result.setDate(DublinCoreFieldLoader.setDate(hit, this.dateList)); - result.setDescription(DublinCoreFieldLoader.setDescription(hit, this.descriptionList)); - result.setFormat(DublinCoreFieldLoader.setFormat(hit, this.formatList)); - result.setIdentifier(DublinCoreFieldLoader.setIdentifier(hit, this.identifierList)); - result.setLanguage(DublinCoreFieldLoader.setLanguage(hit, this.languageList)); - result.setPublisher(DublinCoreFieldLoader.setPublisher(hit, this.publisherList)); - result.setRelation(DublinCoreFieldLoader.setRelation(hit, this.relationList)); - result.setRights(DublinCoreFieldLoader.setRights(hit, this.rightList)); - result.setSource(DublinCoreFieldLoader.setSources(hit, this.sourceList)); - result.setSubject(DublinCoreFieldLoader.setSources(hit, this.subjectList)); - result.setTitle(DublinCoreFieldLoader.setTitle(hit, this.titleList)); - result.setType(DublinCoreFieldLoader.setType(hit, this.typeList)); + result.setContributor(DublinCoreFieldLoader.fillList(hit, this.contributorList)); + result.setCoverage(DublinCoreFieldLoader.fillList(hit, this.coverageList)); + result.setCreator(DublinCoreFieldLoader.fillList(hit, this.creatorList)); + result.setDate(DublinCoreFieldLoader.fillList(hit, this.dateList)); + result.setDescription(DublinCoreFieldLoader.fillList(hit, this.descriptionList)); + result.setFormat(DublinCoreFieldLoader.fillList(hit, this.formatList)); + result.setIdentifier(DublinCoreFieldLoader.fillList(hit, this.identifierList)); + result.setLanguage(DublinCoreFieldLoader.fillList(hit, this.languageList)); + result.setPublisher(DublinCoreFieldLoader.fillList(hit, this.publisherList)); + result.setRelation(DublinCoreFieldLoader.fillList(hit, this.relationList)); + result.setRights(DublinCoreFieldLoader.fillList(hit, this.rightList)); + result.setSource(DublinCoreFieldLoader.fillList(hit, this.sourceList)); + result.setSubject(DublinCoreFieldLoader.fillList(hit, this.subjectList)); + result.setTitle(DublinCoreFieldLoader.fillList(hit, this.titleList)); + result.setType(DublinCoreFieldLoader.fillList(hit, this.typeList)); return result; } @@ -300,14 +359,14 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract { * @return */ public RecordType buildRecord(ListRecordsType recordList, String set, String headerIdentifier, - DublinCoreBuilder dublinCoreBuilder) { + DublinCoreBuilder dublinCoreBuilder, String setSpec) { MetadataType metadata = new MetadataType(); RecordType record = new RecordType(); metadata = dublinCoreBuilder.getDC(); record.setMetadata(metadata); - record.setHeader(setHeader(set, headerIdentifier)); + record.setHeader(setHeader(set, headerIdentifier, setSpec)); recordList.getRecord().add(record); return record; @@ -329,7 +388,6 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract { QueryBuilder rangeQuery = QueryBuilders.rangeQuery(this.rangeField).from(from).to(to); if (set != null) { - String queryField = ""; String valueField = ""; @@ -341,7 +399,7 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract { if (this.textgrid == true) { String[] setParts = set.split(":"); if (setParts[0].equals("project")) { - queryField = "project.id"; + queryField = "project.id"; valueField = setParts[1]; } } @@ -349,9 +407,12 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract { QueryBuilder matchQuery = QueryBuilders.matchPhraseQuery(queryField, valueField); QueryBuilder boolQuery = QueryBuilders.boolQuery().must(rangeQuery).must(matchQuery); + System.out.println(boolQuery); + query = boolQuery; } else { query = rangeQuery; + } try { fetchFields(query, recordList, resumptionToken, set); @@ -367,7 +428,7 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract { * @param headerIdentifier * @return */ - public HeaderType setHeader(final String set, final String headerIdentifier) { + public HeaderType setHeader(final String set, final String headerIdentifier, String setSpec) { HeaderType header = new HeaderType(); String identifierForHeader = headerIdentifier; @@ -389,10 +450,10 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract { } header.setIdentifier(identifierForHeader); - + // Set set :-) if (set != null) { - header.getSetSpec().add(set); + header.getSetSpec().add(setSpec); } return header; @@ -543,10 +604,10 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract { } /** - * @param relationsList + * @param relationsForWorkList */ - public void setRelationsForWork(String[] relationsList) { - this.relationForWorkList = relationsList; + public void setRelationsForWork(String[] relationsForWorkList) { + this.relationsForWorkList = relationsForWorkList; } /** @@ -689,4 +750,18 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract { this.oaiEsClient = oaiEsClient; } + /** + * @return + */ + public long getResultSize() { + return this.resultSize; + } + + /** + * @param resultSize + */ + public void setResultSize(long resultSize) { + this.resultSize = resultSize; + } + } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererIDIOM.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererIDIOM.java index 28b1d2c560cf59ee260ddd605e88eb1b5c3fc5d6..9f1c478c27bdd43de3daea11bc4bcb6eea6e9123 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererIDIOM.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererIDIOM.java @@ -1,5 +1,6 @@ package info.textgrid.middleware; +import java.text.ParseException; import java.util.Hashtable; import java.util.Map; import org.apache.commons.logging.LogFactory; @@ -61,6 +62,7 @@ public class RecordListDelivererIDIOM extends RecordListDelivererAbstract { @Override public ListRecordsType getRecords(final String from, final String to, final String set, +<<<<<<< HEAD final String resumptionToken) { System.out.println("BUFF"); ListRecordsType recordList = new ListRecordsType(); @@ -123,6 +125,46 @@ public class RecordListDelivererIDIOM extends RecordListDelivererAbstract { } return recordList; +======= + final String resumptionToken) throws ParseException { + + String resTokenValue = resumptionToken; + + log.info("Started List Records with booleans for DARIAH: " + this.dariah + " and TextGrid: " + + this.textgrid); + + ListRecordsType recordList = new ListRecordsType(); + List<String> artefactURIs; + Queries queries = new Queries(); + if (resumptionToken == null) { + artefactURIs = queries.getArtefactList(0); + // Create resumption token for every request only (we do need the same token for resuming + // because we are using a hash map for counting the calls). + resTokenValue = UUID.randomUUID().toString(); + } else { + // Use given resumption token here. + artefactURIs = queries.getArtefactList(cursorCollector.get(resumptionToken)); + } + + long listSize = Queries.getAmountOfArtefacts(); + int i = 0; + + for (String artefactURI : artefactURIs) { + RecordDelivererIDIOM idiomRecord = new RecordDelivererIDIOM(true, false); + recordList.getRecord().add(idiomRecord.getRecordById(artefactURI).getRecord()); + i++; + } + + // Check the need for a resumption token! + ResumptionTokenType resTokenForResponse = OAIPMHUtilities.getResumptionToken(listSize, + resumptionToken, cursorCollector, resTokenValue, 30, i); + + if (resTokenForResponse != null) { + recordList.setResumptionToken(resTokenForResponse); + } + + return recordList; +>>>>>>> feature/elastic6 } /* @@ -132,7 +174,7 @@ public class RecordListDelivererIDIOM extends RecordListDelivererAbstract { * java.lang.String) */ @Override - public HeaderType setHeader(String set, String headerIdentifier) { + public HeaderType setHeader(String set, String headerIdentifier, String setSpec) { return null; } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererInterface.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererInterface.java index 1dd1f5832b436c2cbb48e67d84ade5af662ca634..e3ce3a67c3e116295365ff05ba201c382d7af6cc 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererInterface.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererInterface.java @@ -1,5 +1,7 @@ package info.textgrid.middleware; +import java.text.ParseException; + import info.textgrid.middleware.oaipmh.HeaderType; import info.textgrid.middleware.oaipmh.ListRecordsType; @@ -8,20 +10,22 @@ import info.textgrid.middleware.oaipmh.ListRecordsType; */ public interface RecordListDelivererInterface { + /** * @param from * @param to * @param set * @param resumptionToken * @return + * @throws ParseException */ - public ListRecordsType getRecords(String from, String to, String set, String resumptionToken); + public ListRecordsType getRecords(String from, String to, String set, String resumptionToken) throws ParseException; /** * @param set * @param headerIdentifier * @return */ - public HeaderType setHeader(String set, String headerIdentifier); + public HeaderType setHeader(String set, String headerIdentifier, String setSpec); } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/Rest.java b/oaipmh-core/src/main/java/info/textgrid/middleware/Rest.java index 84c2adfa500a76199a33ed18c6238ac9baacd51c..f0d3a4069db63472c0137f1b004ca64ef19c5e14 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/Rest.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/Rest.java @@ -4,17 +4,14 @@ import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Response; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import info.textgrid.utils.httpclient.TGHttpConnection; /** * */ +@SuppressWarnings("deprecation") public class Rest { - private Log log = LogFactory.getLog(Rest.class); - /** * @return */ diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/SetDeliverer.java b/oaipmh-core/src/main/java/info/textgrid/middleware/SetDeliverer.java index 090d48b707d783c25903e870f6234853c8194046..320a03a0c1cab3904b88e76e5e016df53355c209 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/SetDeliverer.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/SetDeliverer.java @@ -1,30 +1,47 @@ package info.textgrid.middleware; +import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; -import java.util.Hashtable; -import java.util.Iterator; +import java.util.ArrayList; import java.util.LinkedHashSet; -import java.util.Map; +import java.util.List; +import java.util.Map.Entry; import java.util.Set; -import org.elasticsearch.action.get.GetRequestBuilder; + +import org.elasticsearch.search.aggregations.bucket.filter.Filter; +import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.search.SearchRequestBuilder; +import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.index.query.QueryBuilder; +import org.elasticsearch.client.RequestOptions; +import org.elasticsearch.common.Strings; + import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.script.Script; import org.elasticsearch.search.SearchHit; +import org.elasticsearch.search.aggregations.Aggregation; +import org.elasticsearch.search.aggregations.AggregationBuilder; +import org.elasticsearch.search.aggregations.AggregationBuilders; + +import org.elasticsearch.search.aggregations.bucket.terms.Terms; +import org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket; +import org.elasticsearch.search.builder.SearchSourceBuilder; +import org.elasticsearch.search.fetch.subphase.FetchSourceContext; + +import info.textgrid.clients.tgauth.AuthClientException; import info.textgrid.middleware.oaipmh.ListSetsType; import info.textgrid.middleware.oaipmh.RequestType; import info.textgrid.middleware.oaipmh.SetType; import info.textgrid.namespaces.middleware.tgcrud.common.TextGridMimetypes; + /** * */ public class SetDeliverer { - private static Map<String, String> setSet = new Hashtable<String, String>(); + //private static Map<String, String> setSet = new Hashtable<String, String>(); private Set<String> identifier = new LinkedHashSet<String>(); private String formatField; @@ -48,10 +65,13 @@ public class SetDeliverer { /** * @return + * @throws AuthClientException + * @throws IOException */ public ListSetsType setListBuilder() { ListSetsType setList = new ListSetsType(); +<<<<<<< HEAD QueryBuilder aggQuery; if (this.textgrid) { aggQuery = QueryBuilders.matchPhraseQuery("format", TextGridMimetypes.EDITION); @@ -68,36 +88,100 @@ public class SetDeliverer { .addField("project.value") .addField("project.id") .setSize(100000); +======= + //TODO looking for DARIAH if DARIAH works on ES6 + + + SearchRequest request = new SearchRequest(OAI_ESClient.getEsIndex()); + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); + AggregationBuilder agg = null; + AggregationBuilder filterPublicProjects = null; + AggregationBuilder projectNameAndID = null; + + + if (this.textgrid) { + Script mergeProjectIDandProjectName = new Script("doc['project.id'].value + '&' + doc['project.value.untouched'].value"); + + filterPublicProjects = AggregationBuilders.filter("projectsPublic", QueryBuilders.boolQuery() + .mustNot(QueryBuilders.existsQuery("nearlyPublished")) + .must(QueryBuilders.matchPhraseQuery("format", TextGridMimetypes.EDITION))); + + projectNameAndID = AggregationBuilders.terms("projects") + .script(mergeProjectIDandProjectName) + .size(1000); + + filterPublicProjects.subAggregation(projectNameAndID); +>>>>>>> feature/elastic6 - SearchResponse getRecordListItems = request.execute().actionGet(); - - for (SearchHit hit : getRecordListItems.getHits().getHits()) { - if (this.dariah == true && hit.getFields().get(this.identifierField).values().get(0) + } + + if (this.dariah){ + agg = AggregationBuilders + .terms("descriptiveMetadata.dc:format") + .field("descriptiveMetadata.dc:format") + .size(10000); + } + + List<String> fieldsForSetRequest = new ArrayList<String>(); + fieldsForSetRequest.add("project.value"); + fieldsForSetRequest.add("project.id"); + + searchSourceBuilder.size(0); + searchSourceBuilder.aggregation(filterPublicProjects); + //searchSourceBuilder.aggregation(projectNameAndID); + + request.source(searchSourceBuilder); + System.out.println(request); + SearchResponse getRecordListItems = null; + + try { + getRecordListItems = OAI_ESClient.getEsClient().search(request, RequestOptions.DEFAULT); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + if (this.textgrid == true && getRecordListItems.getAggregations()!=null) { + + String projectName=""; + + for (Entry<String, Aggregation> entry : getRecordListItems.getAggregations().asMap().entrySet()) { + String name = entry.getKey(); + + if (name.equals("projectsPublic")) { + + Filter trytry = getRecordListItems.getAggregations().get("projectsPublic"); + Terms trytry2 = trytry.getAggregations().get("projects"); + for(Bucket bentry : trytry2.getBuckets()) { + projectName = bentry.getKey().toString(); + String [] projectInfos = projectName.split("&"); + + SetType setsForTextGrid = new SetType(); + setsForTextGrid.setSetSpec("project:" + projectInfos[0]); + setsForTextGrid.setSetName(projectInfos[1]); + setList.getSet().add(setsForTextGrid); + + } + } + } + SetType setOpenAire = new SetType(); + setOpenAire.setSetName("OpenAIRE"); + setOpenAire.setSetSpec("openaire_data"); + setList.getSet().add(setOpenAire); + + for (SearchHit hit : getRecordListItems.getHits().getHits()) { + + if (this.dariah == true && hit.getSourceAsMap().get(this.identifierField) .toString().startsWith("hdl:")) { - String pid = hit.getFields().get(this.identifierField).values().get(0).toString(); + + String pid = hit.getSourceAsMap().get(this.identifierField).toString(); this.identifier.add(pid); } - - if (this.textgrid == true) { - String projectName = hit.getFields().get("project.value").values().get(0).toString(); - String projectID = hit.getFields().get("project.id").values().get(0).toString(); - String projectSetSpec = projectName.concat(":").concat(projectID); - SetDeliverer.setSet.put(projectID, projectName); + } } - - if (this.textgrid == true) { - Iterator it = setSet.entrySet().iterator(); - while (it.hasNext()) { - Map.Entry pair = (Map.Entry) it.next(); - SetType set = new SetType(); - set.setSetName(pair.getValue().toString()); - set.setSetSpec("project:" + pair.getKey().toString()); - setList.getSet().add(set); - } - } - + if (this.dariah == true) { for (String identifierSetSpec : this.identifier) { String id = identifierSetSpec; @@ -109,15 +193,27 @@ public class SetDeliverer { id = identifierSetSpec.substring(this.repositoryObjectURIPrefix.length()); - GetRequestBuilder collectionNameById = - OAI_ESClient.getOaiESClient().prepareGet().setIndex(OAI_ESClient.getEsIndex()) - .setType(OAI_ESClient.getEsType()).setFields(this.specField).setId(id); + String[] includes2 = new String[] {this.specField}; + String[] excludes2 = Strings.EMPTY_ARRAY; + FetchSourceContext fetchSourceContext2 = + new FetchSourceContext(true, includes2, excludes2); + + GetRequest getRequest = + new GetRequest(OAI_ESClient.getEsIndex(), OAI_ESClient.getEsType(), id) + .fetchSourceContext(fetchSourceContext2); + GetResponse setSpec = null; + + try { + setSpec = OAI_ESClient.getEsClient().get(getRequest, RequestOptions.DEFAULT); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } - GetResponse setSpec = collectionNameById.execute().actionGet(); String setName = ""; if (setSpec != null && setSpec.isExists()) { if (setSpec.getField(this.specField) != null) { - setName = setSpec.getField(this.specField).getValue().toString(); + setName = setSpec.getSourceAsMap().get(this.specField).toString(); } } @@ -175,6 +271,9 @@ public class SetDeliverer { this.formatField = formatField; } + /** + * @return + */ public String getFormatToFilter() { return this.formatToFilter; } @@ -270,4 +369,4 @@ public class SetDeliverer { this.dariah = dariah; } -} +} \ No newline at end of file diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/TGConstants.java b/oaipmh-core/src/main/java/info/textgrid/middleware/TGConstants.java index 50a57cf9d37fbe3eadbd3781c7d04a7fe53d2ef4..d0c594e80d87e7788493cc239f853317669ead6d 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/TGConstants.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/TGConstants.java @@ -4,45 +4,50 @@ import java.util.Arrays; import java.util.List; /** - * Collection of values never changing its content + * <p> + * Collection of values never changing its content. + * </p> * - * @author Maximilian Brodhun: SUB + * @author Maximilian Brodhun, SUB Göttingen */ public final class TGConstants { + /** + * + */ private TGConstants() { - // not called + // } - // public static boolean furtherElements = true; - + + + public static final String SET_FIELD_FOR_TEXTGRID = "project"; + public static final String PROJECT_ID_FOR_TEXTGRID = "project.id"; + public static final String ITEM_IDENTIFIER_PREFIX = "textgrid:"; public static final List<String> TEXTGRID_REP_ADMIN_CONTACT = - Arrays.asList("textgrid-support@gwdg.de"); + Arrays.asList("support@de.dariah.eu"); - /* - * Repository Identification String Constants - */ - - public static final String TG_REP_BASEURL = "www.textgridrep.de"; - public static final String METADATA_DC_PREFIX = "oai_dc"; + // Repository Identification String Constants + public static final String TG_REP_BASEURL = "textgridrep.org"; public static final String METADATA_IDIOM_PREFIX = "oai_idiom_mets"; + public static final String METADATA_OPENAIRE_PREFIX = "oai_datacite"; - /* - * Error String Constants - */ - + // Error String Constants public static final String OAI_BAD_ARGUMENT = "BadArgument"; public static final String OAI_METADATA_FORMAT_ERROR = "FormatError"; public static final String OAI_NO_RECORD_MATCH = "RecordMatchError"; public static final String OAI_NO_SET_HIERARCHY = "SetHierarchyError"; public static final String OAI_BAD_RESUMPTION_TOKEN = "badResumptionToken"; - - /* - * TextGrid Metadata Fields for OAI-PMH Request (Mapping to DC) - */ - + public static final String OAI_ID_DOES_NOT_EXIST = "idDoesNotExist"; + public static final String OAI_VERB_ERROR = "badVerb"; + + public static final String TEXTGRIDURI_IDENTIIER_TYPE = "URI"; + public static final String TEXTGRID_METADATASCHEME = "TextGrid Metadata Scheme"; + public static final String TEXTGRID_METADATASCHEME_URI = "http://textgrid.info/namespaces/metadata/core/2010"; + + // TextGrid Metadata Fields for OAI-PMH Request (Mapping to DC) public static final String CREATED = "created"; public static final String FORMAT = "format"; public static final String IDENTIFIER = "identifier"; @@ -51,6 +56,7 @@ public final class TGConstants { public static final String PROJECT_ID = "project.id"; public static final String IS_DERIVED_FROM = "relations.isDerivedFrom"; public static final String TITLE = "title"; + public static final String ADDITIONAL_TITLE = "edition.source.editionTitle"; //Just for OpenAire public static final String PID = "pid.value"; public static final String EDITION_ISEDITIONOF = "edition.isEditionOf"; public static final String EDITION_AGENT = "edition.agent.value"; @@ -78,27 +84,18 @@ public final class TGConstants { public static final String WORK_AGENT = "work.agent.value"; public static final String WORK_ID = "work.subject.id.value"; public static final String MODIFIED_FIELD = "lastModified"; - - public static final String[] TGFields = { - CREATED, FORMAT, IDENTIFIER, DATA_CONTRIBUTOR, URI, PROJECT_ID, - IS_DERIVED_FROM, TITLE, PID, EDITION_ISEDITIONOF, EDITION_AGENT, - EDITION_LICENSEURI, EDITION_LANGUAGE, BIBCIT_AUTHOR, BIBCIT_EDITOR, - BIBCIT_TITLE, BIBCIT_PLACEPUB, BIBCIT_PUBLISHER, BIBCIT_NO, - BIBCIT_SERIES, BIBCIT_VOLUME, BIBCIT_ISSUE, BIBCIT_EPAGE, - BIBCIT_SPAGE, BIBCIT_BIBID, WORK_ABSTRACT, WORK_GENRE, WORK_TYPE, - WORK_SPATIAL, WORK_TEMPORAL, WORK_AGENT, MODIFIED_FIELD}; - - public static final String[] TGWorkFields = { - CREATED, WORK_ABSTRACT, IS_DERIVED_FROM, URI, WORK_GENRE, TITLE, - WORK_TYPE, WORK_SPATIAL, WORK_TEMPORAL, WORK_AGENT, WORK_ID}; - - /* - * String Arrays to define which TextGrid fields belongs to the regarding DC fields - */ - + public static final String[] TGFields = + {CREATED, FORMAT, IDENTIFIER, DATA_CONTRIBUTOR, URI, PROJECT_ID, IS_DERIVED_FROM, TITLE, PID, + EDITION_ISEDITIONOF, EDITION_AGENT, EDITION_LICENSEURI, EDITION_LANGUAGE, BIBCIT_AUTHOR, + BIBCIT_EDITOR, BIBCIT_TITLE, BIBCIT_PLACEPUB, BIBCIT_PUBLISHER, BIBCIT_NO, BIBCIT_SERIES, + BIBCIT_VOLUME, BIBCIT_ISSUE, BIBCIT_EPAGE, BIBCIT_SPAGE, BIBCIT_BIBID, WORK_ABSTRACT, + WORK_GENRE, WORK_TYPE, WORK_SPATIAL, WORK_TEMPORAL, WORK_AGENT, MODIFIED_FIELD}; + public static final String[] TGWorkFields = {CREATED, WORK_ABSTRACT, IS_DERIVED_FROM, URI, + WORK_GENRE, TITLE, WORK_TYPE, WORK_SPATIAL, WORK_TEMPORAL, WORK_AGENT, WORK_ID}; + + // String Arrays to define which TextGrid fields belongs to the regarding DC fields public static final String[] CONTRIBUTOR_LIST = {DATA_CONTRIBUTOR}; - public static final String[] COVERAGE_LIST = { - WORK_SPATIAL, WORK_TEMPORAL}; + public static final String[] COVERAGE_LIST = {WORK_SPATIAL, WORK_TEMPORAL}; public static final String[] CREATOR_LIST = {WORK_AGENT}; public static final String[] DATE_LIST = {CREATED}; public static final String[] DESCRIPTION_LIST = {WORK_ABSTRACT}; @@ -106,23 +103,16 @@ public final class TGConstants { public static final String[] IDENTIFIER_LIST = {URI, PID, IDENTIFIER}; public static final String[] LANGUAGE_LIST = {EDITION_LANGUAGE}; public static final String[] PUBLISHER_LIST = {BIBCIT_PUBLISHER}; - public static final String[] RELATIONS_LIST = { - PROJECT_ID, IS_DERIVED_FROM}; - public static final String[] RELATIONS_FOR_WORK_LIST = { - IS_DERIVED_FROM, TITLE, URI}; + public static final String[] RELATIONS_LIST = {PROJECT_ID, IS_DERIVED_FROM}; + public static final String[] RELATIONS_FOR_WORK_LIST = {IS_DERIVED_FROM, TITLE, URI}; public static final String[] RIGHTS_LIST = {EDITION_LICENSEURI}; - public static final String[] SOURCE_LIST = { - BIBCIT_AUTHOR, BIBCIT_EDITOR, BIBCIT_TITLE, BIBCIT_PLACEPUB, - BIBCIT_PUBLISHER, BIBCIT_NO, BIBCIT_SERIES, BIBCIT_VOLUME, - BIBCIT_ISSUE, BIBCIT_SPAGE, BIBCIT_EPAGE}; - + public static final String[] SOURCE_LIST = + {BIBCIT_AUTHOR, BIBCIT_EDITOR, BIBCIT_TITLE, BIBCIT_PLACEPUB, BIBCIT_PUBLISHER, BIBCIT_NO, + BIBCIT_SERIES, BIBCIT_VOLUME, BIBCIT_ISSUE, BIBCIT_SPAGE, BIBCIT_EPAGE}; public static final String[] SUBJECT_LIST = {WORK_ID}; public static final String[] TITLE_LIST = {TITLE}; - - public static final String[] TYPE_LIST = { - WORK_GENRE, WORK_TYPE}; - - public static final String[] IDENTIFIER_LIST_FIELDS = {URI, - CREATED, FORMAT}; + public static final String[] TYPE_LIST = {WORK_GENRE, WORK_TYPE}; + public static final String[] IDENTIFIER_LIST_FIELDS = {URI, CREATED, FORMAT}; public static final String RANGE_FIELD = CREATED; + } diff --git a/oaipmh-core/src/main/openaire/include/datacite-contributorType-v3.1.xsd b/oaipmh-core/src/main/openaire/include/datacite-contributorType-v3.1.xsd new file mode 100644 index 0000000000000000000000000000000000000000..c472076af44c0e2a6c30d8e1f7183d6be6ba5e36 --- /dev/null +++ b/oaipmh-core/src/main/openaire/include/datacite-contributorType-v3.1.xsd @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Version 1.0 - Created 2011-01-13 - FZ, TIB, Germany + 2013-05 v3.0: Addition of ID to simpleType element, added values "ResearchGroup" & "Other" + 2014-08-20 v3.1: Addition of value "DataCurator" + 2015-05-14 v4.0 dropped value "Funder", use new "funderReference" --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datacite.org/schema/kernel-3" targetNamespace="http://datacite.org/schema/kernel-3" elementFormDefault="qualified"> + <xs:simpleType name="contributorType" id="contributorType"> + <xs:annotation> + <xs:documentation>The type of contributor of the resource.</xs:documentation> + </xs:annotation> + <xs:restriction base="xs:string"> + <xs:enumeration value="ContactPerson"/> + <xs:enumeration value="DataCollector"/> + <xs:enumeration value="DataCurator"/> + <xs:enumeration value="DataManager"/> + <xs:enumeration value="Distributor"/> + <xs:enumeration value="Editor"/> + <xs:enumeration value="HostingInstitution"/> + <xs:enumeration value="Other"/> + <xs:enumeration value="Producer"/> + <xs:enumeration value="ProjectLeader"/> + <xs:enumeration value="ProjectManager"/> + <xs:enumeration value="ProjectMember"/> + <xs:enumeration value="RegistrationAgency"/> + <xs:enumeration value="RegistrationAuthority"/> + <xs:enumeration value="RelatedPerson"/> + <xs:enumeration value="ResearchGroup"/> + <xs:enumeration value="RightsHolder"/> + <xs:enumeration value="Researcher"/> + <xs:enumeration value="Sponsor"/> + <xs:enumeration value="Supervisor"/> + <xs:enumeration value="WorkPackageLeader"/> + </xs:restriction> + </xs:simpleType> +</xs:schema> diff --git a/oaipmh-core/src/main/openaire/include/datacite-dateType-v3.xsd b/oaipmh-core/src/main/openaire/include/datacite-dateType-v3.xsd new file mode 100644 index 0000000000000000000000000000000000000000..0455f8ac57344bd75fa5119603293297b33353a5 --- /dev/null +++ b/oaipmh-core/src/main/openaire/include/datacite-dateType-v3.xsd @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Version 1.0 - Created 2011-01-13 - FZ, TIB, Germany + 2013-05 v3.0: Addition of ID to simpleType element; addition of value "Collected"; deleted "StartDate" & "EndDate"--> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datacite.org/schema/kernel-3" targetNamespace="http://datacite.org/schema/kernel-3" elementFormDefault="qualified"> + <xs:simpleType name="dateType" id="dateType"> + <xs:annotation> + <xs:documentation>The type of date. Use RKMSâ€ISO8601 standard for depicting date ranges.To indicate the end of an embargo period, use Available. To indicate the start of an embargo period, use Submitted or Accepted, as appropriate.</xs:documentation> + </xs:annotation> + <xs:restriction base="xs:string"> + <xs:enumeration value="Accepted"/> + <xs:enumeration value="Available"/> + <xs:enumeration value="Collected"/> + <xs:enumeration value="Copyrighted"/> + <xs:enumeration value="Created"/> + <xs:enumeration value="Issued"/> + <xs:enumeration value="Submitted"/> + <xs:enumeration value="Updated"/> + <xs:enumeration value="Valid"/> + </xs:restriction> + </xs:simpleType> +</xs:schema> diff --git a/oaipmh-core/src/main/openaire/include/datacite-descriptionType-v3.xsd b/oaipmh-core/src/main/openaire/include/datacite-descriptionType-v3.xsd new file mode 100644 index 0000000000000000000000000000000000000000..881a4dfddd66bf3421e93cb4845f17bde757e81b --- /dev/null +++ b/oaipmh-core/src/main/openaire/include/datacite-descriptionType-v3.xsd @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Version 1.0 - Created 2011-01-13 - FZ, TIB, Germany + 2013-05 v3.0: Addition of ID to simpleType element, addition of value "Methods" + 2015-02-12 v4.0: Addition of value "TechnicalInfo"--> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datacite.org/schema/kernel-3" targetNamespace="http://datacite.org/schema/kernel-3" elementFormDefault="qualified"> + <xs:simpleType name="openaireDescriptionType" id="openaireDescriptionType"> + <xs:annotation> + <xs:documentation>The type of the description.</xs:documentation> + </xs:annotation> + <xs:restriction base="xs:string"> + <xs:enumeration value="Abstract"/> + <xs:enumeration value="Methods"/> + <xs:enumeration value="SeriesInformation"/> + <xs:enumeration value="TableOfContents"/> + <xs:enumeration value="TechnicalInfo"/> + <xs:enumeration value="Other"/> + </xs:restriction> + </xs:simpleType> +</xs:schema> diff --git a/oaipmh-core/src/main/openaire/include/datacite-relatedIdentifierType-v3.1.xsd b/oaipmh-core/src/main/openaire/include/datacite-relatedIdentifierType-v3.1.xsd new file mode 100644 index 0000000000000000000000000000000000000000..a300456d93c1fad4d5bc96f73d9f526b9270db5e --- /dev/null +++ b/oaipmh-core/src/main/openaire/include/datacite-relatedIdentifierType-v3.1.xsd @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Version 1.0 - Created 2011-01-13 - FZ, TIB, Germany + 2013-05 v3.0: Addition of ID to simpleType element; addition of value "PMID" + 2014-08-20 v3.1: Addition of values "arxiv" and "bibcode"--> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datacite.org/schema/kernel-3" targetNamespace="http://datacite.org/schema/kernel-3" elementFormDefault="qualified"> + <xs:simpleType name="relatedIdentifierType" id="relatedIdentifierType"> + <xs:annotation> + <xs:documentation>The type of the RelatedIdentifier.</xs:documentation> + </xs:annotation> + <xs:restriction base="xs:string"> + <xs:enumeration value="ARK"/> + <xs:enumeration value="arXiv"/> + <xs:enumeration value="bibcode"/> + <xs:enumeration value="DOI"/> + <xs:enumeration value="EAN13"/> + <xs:enumeration value="EISSN"/> + <xs:enumeration value="Handle"/> + <xs:enumeration value="ISBN"/> + <xs:enumeration value="ISSN"/> + <xs:enumeration value="ISTC"/> + <xs:enumeration value="LISSN"/> + <xs:enumeration value="LSID"/> + <xs:enumeration value="PMID"/> + <xs:enumeration value="PURL"/> + <xs:enumeration value="UPC"/> + <xs:enumeration value="URL"/> + <xs:enumeration value="URN"/> + </xs:restriction> + </xs:simpleType> +</xs:schema> diff --git a/oaipmh-core/src/main/openaire/include/datacite-relationType-v3.1.xsd b/oaipmh-core/src/main/openaire/include/datacite-relationType-v3.1.xsd new file mode 100644 index 0000000000000000000000000000000000000000..ed8516b52bdd3a92220946e2b22b630de2fa55f3 --- /dev/null +++ b/oaipmh-core/src/main/openaire/include/datacite-relationType-v3.1.xsd @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Version 1.0 - Created 2011-01-13 - FZ, TIB, Germany + 2013-05 v3.0: Addition of ID to simpleType element, addition of values "IsIdenticalTo", "HasMetadata" & "IsMetadataFor" + 2014-08-20 v3.1: Addition of values "Reviews" & "IsReviewedBy" and "IsDerivedFrom" & "IsSourceOf"--> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datacite.org/schema/kernel-3" targetNamespace="http://datacite.org/schema/kernel-3" elementFormDefault="qualified"> + <xs:simpleType name="relationType" id="relationType"> + <xs:annotation> + <xs:documentation>Description of the relationship of the resource being registered (A) and the related resource (B).</xs:documentation> + </xs:annotation> + <xs:restriction base="xs:string"> + <xs:enumeration value="IsCitedBy"/> + <xs:enumeration value="Cites"/> + <xs:enumeration value="IsSupplementTo"/> + <xs:enumeration value="IsSupplementedBy"/> + <xs:enumeration value="IsContinuedBy"/> + <xs:enumeration value="Continues"/> + <xs:enumeration value="IsNewVersionOf"/> + <xs:enumeration value="IsPreviousVersionOf"/> + <xs:enumeration value="IsPartOf"/> + <xs:enumeration value="HasPart"/> + <xs:enumeration value="IsReferencedBy"/> + <xs:enumeration value="References"/> + <xs:enumeration value="IsDocumentedBy"/> + <xs:enumeration value="Documents"/> + <xs:enumeration value="IsCompiledBy"/> + <xs:enumeration value="Compiles"/> + <xs:enumeration value="IsVariantFormOf"/> + <xs:enumeration value="IsOriginalFormOf"/> + <xs:enumeration value="IsIdenticalTo"/> + <xs:enumeration value="HasMetadata"/> + <xs:enumeration value="IsMetadataFor"/> + <xs:enumeration value="Reviews"/> + <xs:enumeration value="IsReviewedBy"/> + <xs:enumeration value="IsDerivedFrom"/> + <xs:enumeration value="IsSourceOf"/> + </xs:restriction> + </xs:simpleType> +</xs:schema> diff --git a/oaipmh-core/src/main/openaire/include/datacite-resourceType-v3.xsd b/oaipmh-core/src/main/openaire/include/datacite-resourceType-v3.xsd new file mode 100644 index 0000000000000000000000000000000000000000..3205a0cd3df8975b6b142061d67fe63622cda082 --- /dev/null +++ b/oaipmh-core/src/main/openaire/include/datacite-resourceType-v3.xsd @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Version 1.0 - Created 2011-01-13 - FZ, TIB, Germany + 2013-05 v3.0: Addition of ID to simpleType element; added values "Audiovisual", "Workflow" & "Other"; deleted value "Film" --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datacite.org/schema/kernel-3" targetNamespace="http://datacite.org/schema/kernel-3" elementFormDefault="qualified"> + <xs:simpleType name="resourceType" id="resourceType"> + <xs:annotation> + <xs:documentation>The general type of a resource.</xs:documentation> + </xs:annotation> + <xs:restriction base="xs:string"> + <xs:enumeration value="Audiovisual"/> + <xs:enumeration value="Collection"/> + <xs:enumeration value="Dataset"/> + <xs:enumeration value="Event"/> + <xs:enumeration value="Image"/> + <xs:enumeration value="InteractiveResource"/> + <xs:enumeration value="Model"/> + <xs:enumeration value="PhysicalObject"/> + <xs:enumeration value="Service"/> + <xs:enumeration value="Software"/> + <xs:enumeration value="Sound"/> + <xs:enumeration value="Text"/> + <xs:enumeration value="Workflow"/> + <xs:enumeration value="Other"/> + </xs:restriction> + </xs:simpleType> +</xs:schema> diff --git a/oaipmh-core/src/main/openaire/include/datacite-titleType-v3.xsd b/oaipmh-core/src/main/openaire/include/datacite-titleType-v3.xsd new file mode 100644 index 0000000000000000000000000000000000000000..ed2508ad8a9e8da913dbf77ea8763ccff13fe1cf --- /dev/null +++ b/oaipmh-core/src/main/openaire/include/datacite-titleType-v3.xsd @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Version 1.0 - Created 2011-01-13 - FZ, TIB, Germany + 2013-05 v3.0: Addition of ID to simpleType element + 2015-02-12 v4.0 Added value "Other" --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datacite.org/schema/kernel-3" targetNamespace="http://datacite.org/schema/kernel-3" elementFormDefault="qualified"> + <xs:simpleType name="titleType" id="titleType"> + <xs:restriction base="xs:string"> + <xs:enumeration value="AlternativeTitle"/> + <xs:enumeration value="Subtitle"/> + <xs:enumeration value="TranslatedTitle"/> + <xs:enumeration value="Other"/> + </xs:restriction> + </xs:simpleType> +</xs:schema> diff --git a/oaipmh-core/src/main/openaire/oaf-1.0.xsd b/oaipmh-core/src/main/openaire/oaf-1.0.xsd new file mode 100644 index 0000000000000000000000000000000000000000..952ae31ddbf10d640b11c920f116bb400f07f257 --- /dev/null +++ b/oaipmh-core/src/main/openaire/oaf-1.0.xsd @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" + xmlns:dri="http://www.driver-repository.eu/namespace/dri" xmlns="http://namespace.openaire.eu/oaf" + targetNamespace="http://namespace.openaire.eu/oaf"> + + <xs:annotation> + <xs:documentation>This schema describes the XML serialization of the OpenAIRE Research Graph. + For an overview of the model, please check the OpenAIRE Research Graph Data Model at https://doi.org/10.5281/zenodo.2643199 + </xs:documentation> + </xs:annotation> + + <xs:include schemaLocation="oaf-result-1.0.xsd"/> + <xs:include schemaLocation="oaf-org-1.0.xsd"/> + <xs:include schemaLocation="oaf-datasource-1.0.xsd"/> + <xs:include schemaLocation="oaf-project-1.0.xsd"/> + + <xs:element name="entity"> + <xs:complexType> + <xs:sequence> + <xs:choice> + <xs:element ref="result"/> + <xs:element ref="organization"/> + <xs:element ref="datasource"/> + <xs:element ref="project"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + </xs:element> + +</xs:schema> diff --git a/oaipmh-core/src/main/openaire/oaf-common-1.0.xsd b/oaipmh-core/src/main/openaire/oaf-common-1.0.xsd new file mode 100644 index 0000000000000000000000000000000000000000..8c52e22a3732c42d8f782bb065f7acfd7e525e0a --- /dev/null +++ b/oaipmh-core/src/main/openaire/oaf-common-1.0.xsd @@ -0,0 +1,298 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" + xmlns="http://namespace.openaire.eu/oaf" targetNamespace="http://namespace.openaire.eu/oaf"> + + <xs:annotation> + <xs:documentation>This schema defines common types that can be re-used.</xs:documentation> + </xs:annotation> + + <xs:simpleType name="emptyType"> + <xs:restriction base="xs:string"> + <xs:length value="0"/> + </xs:restriction> + </xs:simpleType> + + <xs:simpleType name="boolOrEmptyType"> + <xs:union memberTypes="emptyType xs:boolean"/> + </xs:simpleType> + + <xs:simpleType name="stringOrEmptyType"> + <xs:union memberTypes="emptyType xs:string"/> + </xs:simpleType> + + <xs:attributeGroup name="dataInfoAttributeGroup"> + <xs:attribute name="inferred" use="optional" type="xs:boolean"> + <xs:annotation> + <xs:documentation>True if this information has been inferred by the automatic + inference algorithms run by OpenAIRE. </xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute name="trust" use="optional" type="xs:string"> + <xs:annotation> + <xs:documentation>Value of trust of this information in the range [0,1]. More the + value, more trustworthy is the information. </xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute name="inferenceprovenance" use="optional" type="xs:string"> + <xs:annotation> + <xs:documentation>Which algorithm inferred the current property. </xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attributeGroup ref="qualifierAttributeGroup"></xs:attributeGroup> + </xs:attributeGroup> + + <xs:attributeGroup name="qualifierAttributeGroup"> + <xs:attribute name="classid" use="required" type="xs:string"/> + <xs:attribute name="classname" use="required" type="xs:string"/> + <xs:attribute name="schemeid" use="required" type="xs:string"/> + <xs:attribute name="schemename" use="required" type="xs:string"/> + </xs:attributeGroup> + + <xs:complexType name="fieldType"> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attributeGroup ref="dataInfoAttributeGroup"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <xs:complexType name="qualifierType"> + <xs:attributeGroup ref="qualifierAttributeGroup"/> + </xs:complexType> + + <xs:complexType name="dataInfoType"> + <xs:attributeGroup ref="dataInfoAttributeGroup"/> + </xs:complexType> + + <xs:complexType name="structuredPropertyElementType"> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attributeGroup ref="qualifierAttributeGroup"/> + <xs:attributeGroup ref="dataInfoAttributeGroup"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <xs:complexType name="labeledIdElementType"> + <xs:attribute name="id" use="required"/> + <xs:attribute name="label" use="required"/> + </xs:complexType> + + <!-- <oaf:context id="egi" label="EGI" type="community"> + <oaf:category id="egi::virtual" label="EGI virtual organizations"> + <oaf:concept id="egi::virtual::2" label="alice"/> + </oaf:category> + </oaf:context> + <oaf:community id="{@id}" label="{@label}"> + <xsl:apply-templates/> + </oaf:community> + --> + <xs:complexType name="contextType"> + <xs:complexContent> + <xs:extension base="labeledIdElementType"> + <xs:sequence maxOccurs="unbounded"> + <xs:element name="category" type="categoryType"/> + </xs:sequence> + <xs:attributeGroup ref="dataInfoAttributeGroup"/> + </xs:extension> + </xs:complexContent> + </xs:complexType> + + <xs:complexType name="categoryType"> + <xs:complexContent> + <xs:extension base="labeledIdElementType"> + <xs:sequence minOccurs="0" maxOccurs="unbounded"> + <xs:element name="concept" type="conceptType"/> + </xs:sequence> + </xs:extension> + </xs:complexContent> + </xs:complexType> + + <xs:complexType name="conceptType"> + <xs:complexContent> + <xs:extension base="labeledIdElementType"> + <xs:sequence maxOccurs="unbounded" minOccurs="0"> + <xs:element name="concept" type="conceptType"/> + </xs:sequence> + </xs:extension> + </xs:complexContent> + </xs:complexType> + + <xs:complexType name="namedIdElementType"> + <xs:attribute name="id" use="required"/> + <xs:attribute name="name" use="required"/> + <xs:attributeGroup ref="dataInfoAttributeGroup"/> + </xs:complexType> + + <xs:complexType name="relsType"> + <xs:annotation> + <xs:documentation>Relationships to other entities.</xs:documentation> + </xs:annotation> + <xs:choice maxOccurs="unbounded" minOccurs="0"> + <xs:element name="rel" type="relType" minOccurs="0"/> + </xs:choice> + </xs:complexType> + + <xs:complexType name="relType"> + <xs:sequence> + <xs:choice maxOccurs="unbounded"> + <xs:element name="to" type="relToType"/> + <xs:element name="title" type="xs:string"/> + <xs:element name="websiteurl"/> + <xs:choice> + <xs:group ref="relDataSourceGroup"/> + <xs:group ref="relResultGroup"/> + <xs:group ref="relProjectGroup"/> + <xs:group ref="relOrganizationGroup"/> + <xs:group ref="fundingGroup"/> + </xs:choice> + </xs:choice> + </xs:sequence> + <xs:attributeGroup ref="dataInfoAttributeGroup"/> + </xs:complexType> + + <xs:group name="relDataSourceGroup"> + <xs:sequence> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:element name="officialname" type="xs:string"/> + <xs:element name="datasourcetype" type="qualifierType"/> + </xs:choice> + </xs:sequence> + </xs:group> + + <xs:group name="relResultGroup"> + <xs:sequence> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:element name="collectedfrom" type="namedIdElementType"/> + <xs:element name="url" type="xs:string"/> + <xs:element name="pid" type="structuredPropertyElementType"/> + <xs:element name="dateofacceptance" type="xs:string"/> + <xs:element name="publisher" type="xs:string"/> + <xs:element name="resulttype" type="xs:string"> + <xs:annotation> + <xs:documentation> Tells if the related record is about a publication or a + dataset. </xs:documentation> + </xs:annotation> + </xs:element> + <!-- the following fields are available only for similarity relations --> + <xs:element name="similarity" type="xs:double"> + <xs:annotation> + <xs:documentation>The similarity degree expressed in the range (0,1]. This + field is avaiable only when the to/@class is one of + {hasAmongTopNSimilarDocuments, + isAmongTopNSimilarDocuments}</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="type"> + <xs:annotation> + <xs:documentation>The similarity degree expressed in the range (0,1]. This + field is avaiable only when the to/@class is one of + {hasAmongTopNSimilarDocuments, + isAmongTopNSimilarDocuments}</xs:documentation> + </xs:annotation> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:enumeration value="STANDARD"/> + <xs:enumeration value="WEBUSAGE"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + </xs:choice> + </xs:sequence> + </xs:group> + + <xs:group name="relProjectGroup"> + <xs:sequence> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:element name="code" type="xs:string"/> + <xs:element name="acronym" type="xs:string"/> + </xs:choice> + </xs:sequence> + </xs:group> + + <xs:group name="fundingGroup"> + <xs:sequence> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:element name="contracttype" type="qualifierType"/> + <xs:element name="funding" type="fundingFlatType"/> + </xs:choice> + </xs:sequence> + </xs:group> + + <xs:group name="relOrganizationGroup"> + <xs:sequence> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:element name="legalname" type="xs:string"/> + <xs:element name="legalshortname" type="xs:string"/> + <xs:element name="country" type="xs:string"/> + </xs:choice> + </xs:sequence> + </xs:group> + + + <xs:complexType name="relToType"> + <xs:annotation> + <xs:documentation>Information about the related entity. <p>The semantics of the + relationships is expressed by the attributes class and scheme. </p> + </xs:documentation> + </xs:annotation> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="class" use="required" type="xs:string"/> + <xs:attribute name="type" use="required" type="xs:string"> + <xs:annotation> + <xs:documentation>The type of the related entity. <p>Allowed values are: + project, organization, datasource, result, person.</p> + </xs:documentation> + </xs:annotation> + </xs:attribute> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <xs:complexType name="fundingFlatType"> + <xs:sequence> + <xs:element name="funder" type="funderFlatType" minOccurs="1" maxOccurs="1"/> + <xs:element name="funding_level_0" type="namedFundingLevel" minOccurs="0" + maxOccurs="unbounded"/> + <xs:element name="funding_level_1" type="namedFundingLevel" minOccurs="0" + maxOccurs="unbounded"/> + <xs:element name="funding_level_2" type="namedFundingLevel" minOccurs="0" + maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="funderFlatType"> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="id" use="required" type="xs:string"/> + <xs:attribute name="shortname" use="required" type="xs:string"/> + <xs:attribute name="name" use="required" type="xs:string"/> + <xs:attribute name="jurisdiction" use="optional" type="xs:string"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <xs:complexType name="namedFundingLevel"> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="name" use="required" type="xs:string"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <xs:complexType name="externalreferenceType"> + <xs:sequence> + <xs:element name="sitename" type="xs:string" minOccurs="0" maxOccurs="1"/> + <!--<xs:element name="label" type="xs:string" minOccurs="0" maxOccurs="1"/>--> + <xs:element name="url" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="qualifier" type="qualifierType" minOccurs="0" maxOccurs="1"/> + <xs:element name="refidentifier" type="xs:string" minOccurs="0" maxOccurs="1"/> + </xs:sequence> + <xs:attributeGroup ref="dataInfoAttributeGroup"/> + </xs:complexType> + + + <!-- REMOVE FROM HERE TO THE END --> + +</xs:schema> diff --git a/oaipmh-core/src/main/openaire/oaf-datasource-1.0.xsd b/oaipmh-core/src/main/openaire/oaf-datasource-1.0.xsd new file mode 100644 index 0000000000000000000000000000000000000000..c84ec2531dafd7151cd00ac15f6b15aa1fd579af --- /dev/null +++ b/oaipmh-core/src/main/openaire/oaf-datasource-1.0.xsd @@ -0,0 +1,76 @@ +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://namespace.openaire.eu/oaf" + targetNamespace="http://namespace.openaire.eu/oaf" elementFormDefault="qualified"> + + <xs:annotation> + <xs:documentation>This schema describes elements and properties of OpenAIRE datasources: https://issue.openaire.research-infrastructures.eu/projects/openaire2020-wiki/wiki/Core_entity_datasource</xs:documentation> + </xs:annotation> + + <xs:include schemaLocation="oaf-common-1.0.xsd"/> + + <xs:element name="datasource"> + <xs:complexType> + <xs:choice maxOccurs="unbounded"> + <xs:element name="namespaceprefix" type="xs:string" /> + <xs:element name="officialname" type="xs:string" /> + <xs:element name="englishname" type="xs:string" /> + <xs:element name="websiteurl" type="xs:string" /> + <xs:element name="logourl" type="xs:string" /> + <xs:element name="contactemail" type="xs:string" /> + <xs:element name="datasourcetype" type="qualifierType"> + <xs:annotation> + <xs:documentation>For allowed values check terms in:http://api.openaire.eu/vocabularies/dnet:datasource_typologies</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="openairecompatibility" type="qualifierType"> + <xs:annotation> + <xs:documentation> + Level of compatibility of this datasource with regards to the + guidelines. + <p>For allowed values check: + http://api.openaire.eu/vocabularies/dnet:datasourceCompatibilityLevel + </p> + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="dateofvalidation" type="xs:string"> + <xs:annotation> + <xs:documentation>When this datasource has been validated by the + OpenAire + Validator. + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="latitude" type="xs:string" /> + <xs:element name="longitude" type="xs:string" /> + <xs:element name="description" type="xs:string" /> + <xs:element name="subjects" type="structuredPropertyElementType"> + <xs:annotation> + <xs:documentation> + Subjects and keywords. + <p>For allowed values check: + http://api.openaire.eu/vocabularies/dnet:result_subjects + </p> + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="originalId" type="xs:string" /> + <xs:element name="collectedfrom" type="namedIdElementType"> + <xs:annotation> + <xs:documentation>Identifier and name of the datasource from which + this datasource has + been collected from. + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="pid" type="structuredPropertyElementType" /> + <xs:element name="rels" type="relsType"> + <xs:annotation> + <xs:documentation>Relationships to other entities. + </xs:documentation> + </xs:annotation> + </xs:element> + + </xs:choice> + </xs:complexType> + </xs:element> +</xs:schema> diff --git a/oaipmh-core/src/main/openaire/oaf-org-1.0.xsd b/oaipmh-core/src/main/openaire/oaf-org-1.0.xsd new file mode 100644 index 0000000000000000000000000000000000000000..3c46fca44b6462be5fb51d116555cac23ea9d016 --- /dev/null +++ b/oaipmh-core/src/main/openaire/oaf-org-1.0.xsd @@ -0,0 +1,41 @@ +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://namespace.openaire.eu/oaf" + targetNamespace="http://namespace.openaire.eu/oaf" elementFormDefault="qualified"> + + <xs:annotation> + <xs:documentation>This schema describes elements and properties of OpenAIRE entities of type organization: https://issue.openaire.research-infrastructures.eu/projects/openaire2020-wiki/wiki/Core_entity_organization</xs:documentation> + </xs:annotation> + + <xs:include schemaLocation="oaf-common-1.0.xsd"/> + + <xs:element name="organization"> + <xs:complexType> + <xs:choice maxOccurs="unbounded"> + <xs:element name="legalname" type="xs:string"/> + <xs:element name="legalshortname" type="xs:string"/> + <xs:element name="logourl" type="xs:string"/> + <xs:element name="originalId" type="xs:string"/> + <xs:element name="websiteurl" type="xs:string"/> + <xs:element name="country" type="qualifierType"> + <xs:annotation> + <xs:documentation>Countries in ISO 3166-1 alpha-2. </xs:documentation> + </xs:annotation> + </xs:element> + + <xs:element name="collectedfrom" type="namedIdElementType"> + <xs:annotation> + <xs:documentation>Identifier and name of the datasource from which this + organization has been collected from. </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="pid" type="structuredPropertyElementType"/> + <xs:element name="rels" type="relsType"> + <xs:annotation> + <xs:documentation>Relationships to other entities. </xs:documentation> + </xs:annotation> + </xs:element> + <!-- If we decide not to show deduplicated org, then we have to remove this field --> + <!-- <xs:element name="duplicates" type="mergedOrgs"/> --> + </xs:choice> + </xs:complexType> + </xs:element> +</xs:schema> diff --git a/oaipmh-core/src/main/openaire/oaf-project-1.0.xsd b/oaipmh-core/src/main/openaire/oaf-project-1.0.xsd new file mode 100644 index 0000000000000000000000000000000000000000..abcba4d9f63f31996226f01a18ab575541e32827 --- /dev/null +++ b/oaipmh-core/src/main/openaire/oaf-project-1.0.xsd @@ -0,0 +1,111 @@ +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://namespace.openaire.eu/oaf" + targetNamespace="http://namespace.openaire.eu/oaf" elementFormDefault="qualified"> + + <xs:annotation> + <xs:documentation>This schema describes elements and properties of OpenAIRE project entity: https://issue.openaire.research-infrastructures.eu/projects/openaire2020-wiki/wiki/Core_entity_project</xs:documentation> + </xs:annotation> + + <xs:include schemaLocation="oaf-common-1.0.xsd"/> + + <xs:element name="project"> + <xs:complexType> + <xs:choice maxOccurs="unbounded"> + <xs:element name="code" type="xs:string"> + <xs:annotation> + <xs:documentation>Project code as assigned by the project's funder.</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="title" type="xs:string"/> + <xs:element name="acronym" type="xs:string"/> + <xs:element name="callidentifier" type="xs:string"> + <xs:annotation> + <xs:documentation> Identifier of the call for proposal.</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="contactfullname" type="xs:string"/> + <xs:element name="contactfax" type="xs:string"/> + <xs:element name="contactphone" type="xs:string"/> + <xs:element name="contactemail" type="xs:string"/> + <xs:element name="contracttype" type="qualifierType"/> + <xs:element name="keywords" type="xs:string"/> + <xs:element name="websiteurl" type="xs:string"/> + <xs:element name="startdate" type="xs:string"/> + <xs:element name="enddate" type="xs:string"/> + <xs:element name="duration" type="xs:string"/> + <xs:element name="ecsc39" type="boolOrEmptyType"> + <xs:annotation> + <xs:documentation>True if the project has the special clause 39. Available + only for EC FP7 funded projects. </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="oamandatepublications" type="xs:boolean"> + <xs:annotation> + <xs:documentation>True if the project's funding mandates the availability of project's publications in Open Access.</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="ecarticle29_3" type="boolOrEmptyType"> + <xs:annotation> + <xs:documentation>True if the project is under the EC Open Data Pilot. Available only for EC H2020 funded projects. </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="subjects" type="qualifierType"/> + + <xs:element name="fundingtree" type="fundingTreeType"/> + <xs:element name="originalId" type="xs:string"/> + <xs:element name="collectedfrom" type="namedIdElementType"> + <xs:annotation> + <xs:documentation>Identifier and name of the datasource from which this + project has been collected from. </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="pid" type="qualifierType"/> + <xs:element name="rels" type="relsType"> + <xs:annotation> + <xs:documentation>Relationships to other entities. </xs:documentation> + </xs:annotation> + </xs:element> + </xs:choice> + </xs:complexType> + </xs:element> + + <!-- to be removed, and replaced by ContextType --> + <xs:complexType name="fundingTreeType"> + <xs:sequence> + <xs:element name="funder" type="funderType"/> + <xs:choice maxOccurs="unbounded"> + <!-- Three-tier funding hierarchies --> + <xs:element name="funding_level_2" type="fundingType"/> + <!-- Two-tier funding hierarchies --> + <xs:element name="funding_level_1" type="fundingType"/> + <!-- No funding hierarchy --> + <xs:element name="funding_level_0" type="fundingType"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="fundingType"> + <xs:all> + <xs:element name="id" type="xs:string"/> + <xs:element name="description" type="xs:string"/> + <xs:element name="name" type="xs:string"/> + <xs:element name="class" type="xs:string"/> + <xs:element name="parent" type="fundingParentType"/> + </xs:all> + </xs:complexType> + + <xs:complexType name="fundingParentType"> + <xs:choice minOccurs="0"> + <xs:element name="funding_level_1" type="fundingType"/> + <xs:element name="funding_level_0" type="fundingType"/> + </xs:choice> + </xs:complexType> + + <xs:complexType name="funderType"> + <xs:all> + <xs:element name="id" type="xs:string"/> + <xs:element name="shortname" type="xs:string"/> + <xs:element name="name" type="xs:string"/> + <xs:element name="jurisdiction" type="xs:string"/> + </xs:all> + </xs:complexType> +</xs:schema> diff --git a/oaipmh-core/src/main/openaire/oaf-result-1.0.xsd b/oaipmh-core/src/main/openaire/oaf-result-1.0.xsd new file mode 100644 index 0000000000000000000000000000000000000000..2ffd39849cbb1f5da2ebfa5d7cba94ae8d21185f --- /dev/null +++ b/oaipmh-core/src/main/openaire/oaf-result-1.0.xsd @@ -0,0 +1,242 @@ +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" + xmlns="http://namespace.openaire.eu/oaf" targetNamespace="http://namespace.openaire.eu/oaf"> + + <xs:annotation> + <xs:documentation>This schema describes elements and properties of the OpenAIRE Result entity. For an overview of the model, please check the OpenAIRE Research Graph Data Model at https://doi.org/10.5281/zenodo.2643199</xs:documentation> + </xs:annotation> + + <xs:include schemaLocation="oaf-common-1.0.xsd"/> + + <xs:element name="result"> + <xs:complexType> + <xs:choice maxOccurs="unbounded"> + <xs:element name="creator"> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="name" type="xs:string"/> + <xs:attribute name="surname" type="xs:string"/> + <xs:attribute name="ORCID" type="xs:string"/> + <xs:attribute name="rank" type="xs:int"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + <xs:element name="resulttype" type="qualifierType"> + <xs:annotation> + <xs:documentation> Tells if this record is about a publication or a dataset. + <p>For allowed values check: + http://api.openaire.eu/vocabularies/dnet:result_typologies </p> + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="language" type="qualifierType"/> + <xs:element name="country" type="dataInfoType"/> + <xs:element name="subject" type="structuredPropertyElementType"/> + <xs:element name="title" type="structuredPropertyElementType"> + <xs:annotation> + <xs:documentation> Title of this research result. <p>Different types of + titles are allowed: see http://api.openaire.eu/vocabularies/dnet:dataCite_title</p> + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="relevantdate" type="structuredPropertyElementType"/> + <xs:element name="description" type="xs:string"/> + <xs:element name="dateofacceptance" type="xs:string"/> + <xs:element name="publisher" type="xs:string"/> + <xs:element name="embargoenddate" type="xs:string"/> + <xs:element name="source" type="xs:string"> + <xs:annotation> + <xs:documentation>The semantics of this field is inherited from dc:source in + Dublin Core. </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="format" type="xs:string"/> + <xs:element name="contributor" type="xs:string"/> + <xs:element name="resourcetype" type="qualifierType"> + <xs:annotation> + <xs:documentation> This field is valid only if resulttype is "dataset". It + expresses the nature of the dataset. <p>For allowed values check: + http://api.openaire.eu/vocabularies/dnet:publication_resource </p> + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="coverage" type="xs:string"/> + <xs:element name="bestaccessright" type="qualifierType"> + <xs:annotation> + <xs:documentation> The best access right available for this result among the + available licenses of its children elements. <p>For allowed values + check: http://api.openaire.eu/vocabularies/dnet:access_modes </p> + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="journal" type="journalType"/> + <xs:element name="pid" type="structuredPropertyElementType"> + <xs:annotation> + <xs:documentation> Persistent identifier. <p>For allowed pid systems check: + http://api.openaire.eu/vocabularies/dnet:pid_types </p> + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="device" type="xs:string"> + <xs:annotation> + <xs:documentation> This field is valid only if resulttype is "dataset". It + contains information about the device used to generate the dataset. + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="size" type="xs:string"> + <xs:annotation> + <xs:documentation> This field is valid only if resulttype is "dataset". It + contains information about the size of the dataset. </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="version" type="xs:string"> + <xs:annotation> + <xs:documentation> This field is valid only if resulttype is "dataset". It + contains information about the version of the dataset. + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="lastmetadataupdate" type="xs:string"> + <xs:annotation> + <xs:documentation> This field is valid only if resulttype is "dataset". It + is the last update date of the metadata of the dataset. + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="metadataversionnumber" type="xs:string"> + <xs:annotation> + <xs:documentation> This field is valid only if resulttype is "dataset". It + contains information about the version of the metadata of the dataset. + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="originalId" type="xs:string" maxOccurs="unbounded"/> + <xs:element name="collectedfrom" type="namedIdElementType" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>Identifier and name of the datasource from which this + result has been collected from (e.g., "OpenDOAR"). </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="context" type="contextType"> + <xs:annotation> + <xs:documentation>Research community, initiative, infrastructure or funding agency related to this result.</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="rels" type="relsType"> + <xs:annotation> + <xs:documentation>Relationships to other entities. </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="instances" type="instancesType" minOccurs="1" maxOccurs="1"/> + <xs:element name="citations" type="citationsType" maxOccurs="1" minOccurs="0"/> + </xs:choice> + </xs:complexType> + </xs:element> + + <xs:complexType name="citationsType"> + <xs:sequence> + <xs:element name="citation" maxOccurs="unbounded" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="rawText"/> + <xs:element name="id" minOccurs="0" maxOccurs="unbounded"> + <xs:complexType> + <xs:attribute name="value"/> + <xs:attribute name="type"/> + <xs:attribute name="confidenceLevel"/> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + <xs:attribute name="provenance" type="xs:string"/> + <xs:attribute name="trust" type="xs:string"/> + </xs:complexType> + + <xs:complexType name="journalType"> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="eissn" use="optional"/> + <xs:attribute name="issn" use="optional"/> + <xs:attribute name="lissn" use="optional"/> + <xs:attribute name="ep" use="optional"/> + <xs:attribute name="iss" use="optional"/> + <xs:attribute name="sp" use="optional"/> + <xs:attribute name="vol" use="optional"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + <xs:complexType name="instancesType"> + <xs:sequence> + <xs:element name="instance" type="instanceType" minOccurs="1" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>Actual digital representation of the publication or dataset. + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="externalreference" type="externalreferenceType" minOccurs="0" + maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="instanceType"> + <xs:choice maxOccurs="unbounded"> + <xs:element name="license" type="fieldType"> + <xs:annotation> + <xs:documentation> License to access this actual manifestation of the + result. Typically it is a URL. OpenAIRE does not yet attempt any harmonization and reflect the original values that are available in the collected metadata records. + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="accessright" type="qualifierType"/> + <xs:element name="instancetype" type="qualifierType"> + <xs:annotation> + <xs:documentation> Type of the instance, for example: article, thesis, etc. + <p>For allowed values check: http://api.openaire.eu/vocabularies/dnet:publication_resource + </p> + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="collectedfrom" type="namedIdElementType" maxOccurs="1"> + <xs:annotation> + <xs:documentation>Datasource from which OpenAIRE collected the description of this instance.</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="hostedby" type="namedIdElementType" maxOccurs="1"> + <xs:annotation> + <xs:documentation>Datasource hosting this file. </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="webresource" type="webresourceType" minOccurs="1" + maxOccurs="unbounded"/> + <xs:element name="distributionlocation" type="xs:string" minOccurs="0"/> + <xs:element name="dateofacceptance" type="xs:string" minOccurs="0"/> + <xs:element name="processingchargeamount" type="fieldType"> + <xs:annotation> + <xs:documentation> Article/Book Processing Charge </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="processingchargecurrency" type="fieldType"> + <xs:annotation> + <xs:documentation>Currency for the value in processingchargeamount </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="refereed" type="fieldType"> + <xs:annotation> + <xs:documentation>Peer-review status</xs:documentation> + </xs:annotation> + </xs:element> + </xs:choice> + <xs:attribute name="id" use="required"/> + </xs:complexType> + + <xs:complexType name="webresourceType"> + <xs:sequence> + <xs:element name="url" type="xs:string" minOccurs="1" maxOccurs="1"/> + </xs:sequence> + </xs:complexType> + +</xs:schema> diff --git a/oaipmh-core/src/main/openaire/openaire.xsd b/oaipmh-core/src/main/openaire/openaire.xsd new file mode 100644 index 0000000000000000000000000000000000000000..a88a5f0456d1bbad63edf7eef754d1362d41f11d --- /dev/null +++ b/oaipmh-core/src/main/openaire/openaire.xsd @@ -0,0 +1,380 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Revision history + 2010-08-26 Complete revision according to new common specification by the metadata work group after review. AJH, DTIC + 2010-11-17 Revised to current state of kernel review, FZ, TIB + 2011-01-17 Complete revsion after community review. FZ, TIB + 2011-03-17 Release of v2.1: added a namespace; mandatory properties got minLength; changes in the definitions of relationTypes + IsDocumentedBy/Documents and isCompiledBy/Compiles; changes type of property "Date" from xs:date to xs:string. FZ, TIB + 2011-06-27 v2.2: namespace: kernel-2.2, additions to controlled lists "resourceType", "contributorType", "relatedIdentifierType", and "descriptionType". Removal of intermediate include-files. + 2013-05 v3.0: namespace: kernel-3.0; delete LastMetadataUpdate & MetadateVersionNumber; additions to controlled lists "contributorType", "dateType", "descriptionType", "relationType", "relatedIdentifierType" & "resourceType"; deletion of "StartDate" & "EndDate" from list "dateType" and "Film" from "resourceType"; allow arbitrary order of elements; allow optional wrapper elements to be empty; include openaire:lang attribute for title, subject & description; include attribute schemeURI for nameIdentifier of creator, contributor & subject; added new attributes "relatedMetadataScheme", "schemeURI" & "schemeType" to relatedIdentifier; included new property "geoLocation" + 2014-08-20 v3.1: additions to controlled lists "relationType", contributorType" and "relatedIdentifierType"; introduction of new child element "affiliation" to "creator" and "contributor"--> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datacite.org/schema/kernel-3" targetNamespace="http://datacite.org/schema/kernel-3" elementFormDefault="qualified" > + + <xs:include schemaLocation="include/datacite-titleType-v3.xsd"/> + <xs:include schemaLocation="include/datacite-contributorType-v3.1.xsd"/> + <xs:include schemaLocation="include/datacite-dateType-v3.xsd"/> + <xs:include schemaLocation="include/datacite-resourceType-v3.xsd"/> + <xs:include schemaLocation="include/datacite-relationType-v3.1.xsd"/> + <xs:include schemaLocation="include/datacite-relatedIdentifierType-v3.1.xsd"/> + <xs:include schemaLocation="include/datacite-descriptionType-v3.xsd"/> + <xs:element name="resource"> + <xs:annotation> + <xs:documentation> + Root element of a single record. This wrapper element is for XML implementation only and is not defined in the DataCite DOI standard. + Note: This is the case for all wrapper elements within this schema!</xs:documentation> + <xs:documentation>No content in this wrapper element.</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:all> + <!--REQUIRED FIELDS--> + <xs:element name="identifier"> + <xs:annotation> + <xs:documentation>A persistent identifier that identifies a resource.</xs:documentation> + <xs:documentation>Currently, only DOI is allowed.</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="doiType"> + <xs:attribute name="identifierType" use="required" fixed="DOI"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + <xs:element name="creators"> + <xs:complexType> + <xs:sequence> + <xs:element name="creator" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>The main researchers involved working on the data, or the authors of the publication in priority order. May be a corporate/institutional or personal name.</xs:documentation> + <xs:documentation>Format: Family, Given.</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:sequence> + <xs:element name="creatorName"> + <xs:simpleType> + <xs:restriction base="nonemptycontentStringType"/> + </xs:simpleType> + </xs:element> + <xs:element name="nameIdentifier" minOccurs="0"> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="nonemptycontentStringType"> + <xs:attribute name="nameIdentifierScheme" use="required"/> + <xs:attribute name="schemeURI" type="xs:anyURI" use="optional"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + <xs:element name="affiliation" minOccurs="0" maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="titles"> + <xs:complexType> + <xs:sequence> + <xs:element name="title" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>A name or title by which a resource is known.</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="nonemptycontentStringType"> + <xs:attribute name="titleType" type="titleType" use="optional"/> + <xs:attribute name="lang"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="publisher"> + <xs:annotation> + <xs:documentation>The name of the entity that holds, archives, publishes prints, distributes, releases, issues, or produces the resource. This property will be used to formulate the citation, so consider the prominence of the role.</xs:documentation> + <xs:documentation>In the case of datasets, "publish" is understood to mean making the data available to the community of researchers.</xs:documentation> + </xs:annotation> + <xs:simpleType> + <xs:restriction base="nonemptycontentStringType"/> + </xs:simpleType> + </xs:element> + <xs:element name="publicationYear"> + <xs:annotation> + <xs:documentation>Year when the data is made publicly available. If an embargo period has been in effect, use the date when the embargo period ends.</xs:documentation> + <xs:documentation>In the case of datasets, "publish" is understood to mean making the data available on a specific date to the community of researchers. If there is no standard publication year value, use the date that would be preferred from a citation perspective.</xs:documentation> + <xs:documentation>YYYY</xs:documentation> + </xs:annotation> + <xs:simpleType> + <xs:restriction base="yearType"/> + </xs:simpleType> + </xs:element> + <!--OPTIONAL FIELDS--> + <xs:element name="subjects" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="subject" minOccurs="0" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>Subject, keywords, classification codes, or key phrases describing the resource.</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="subjectScheme" use="optional"/> + <xs:attribute name="schemeURI" type="xs:anyURI" use="optional"/> + <xs:attribute name="lang"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="contributors" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="contributor" minOccurs="0" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>The institution or person responsible for collecting, creating, or otherwise contributing to the developement of the dataset.</xs:documentation> + <xs:documentation>The personal name format should be: Family, Given.</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:sequence> + <xs:element name="contributorName"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + <xs:element name="nameIdentifier" minOccurs="0"> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="nameIdentifierScheme" use="required"/> + <xs:attribute name="schemeURI" type="xs:anyURI" use="optional"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + <xs:element name="affiliation" minOccurs="0" maxOccurs="unbounded"/> + </xs:sequence> + <xs:attribute name="contributorType" type="contributorType" use="required"/> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="dates" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="date" minOccurs="0" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>Different dates relevant to the work.</xs:documentation> + <xs:documentation>YYYY,YYYY-MM-DD, YYYY-MM-DDThh:mm:ssTZD or any other format or level of granularity described in W3CDTF. Use RKMS-ISO8601 standard for depicting date ranges.</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="dateType" type="dateType" use="required"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="language" type="xs:language" minOccurs="0"> + <xs:annotation> + <xs:documentation>Primary language of the resource. Allowed values are taken from IETF BCP 47, ISO 639-1 language codes.</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="resourceType" minOccurs="0"> + <xs:annotation> + <xs:documentation>The type of a resource. You may enter an additional free text description.</xs:documentation> + <xs:documentation>The format is open, but the preferred format is a single term of some detail so that a pair can be formed with the sub-property.</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="resourceTypeGeneral" type="resourceType" use="required"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + <xs:element name="alternateIdentifiers" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="alternateIdentifier" minOccurs="0" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>An identifier or identifiers other than the primary Identifier applied to the resource being registered. This may be any alphanumeric string which is unique within its domain of issue. May be used for local identifiers. AlternateIdentifier should be used for another identifier of the same instance (same location, same file).</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="alternateIdentifierType" use="required"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="relatedIdentifiers" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="relatedIdentifier" minOccurs="0" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>Identifiers of related resources. Use this property to indicate subsets of properties, as appropriate.</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="relatedIdentifierType" type="relatedIdentifierType" use="required"/> + <xs:attribute name="relationType" type="relationType" use="required"/> + <xs:attribute name="relatedMetadataScheme" use="optional"/> + <xs:attribute name="schemeURI" type="xs:anyURI" use="optional"/> + <xs:attribute name="schemeType" use="optional"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="sizes" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="size" type="xs:string" minOccurs="0" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>Unstructures size information about the resource.</xs:documentation> + </xs:annotation> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="formats" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="format" type="xs:string" minOccurs="0" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>Technical format of the resource.</xs:documentation> + <xs:documentation>Use file extension or MIME type where possible.</xs:documentation> + </xs:annotation> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="version" type="xs:string" minOccurs="0"> + <xs:annotation> + <xs:documentation>Version number of the resource. If the primary resource has changed the version number increases.</xs:documentation> + <xs:documentation>Register a new identifier for a major version change. Individual stewards need to determine which are major vs. minor versions. May be used in conjunction with properties 11 and 12 (AlternateIdentifier and RelatedIdentifier) to indicate various information updates. May be used in conjunction with property 17 (Description) to indicate the nature and file/record range of version.</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="rightsList" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="rights" minOccurs="0" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>Any rights information for this resource. Provide a rights management statement for the resource or reference a service providing such information. Include embargo information if applicable. +Use the complete title of a license and include version information if applicable.</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="rightsURI" type="xs:anyURI" use="optional"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="descriptions" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="description" minOccurs="0" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>All additional information that does not fit in any of the other categories. May be used for technical information. It is a best practice to supply a description.</xs:documentation> + </xs:annotation> + <xs:complexType mixed="true"> + <xs:choice> + <xs:element name="br" minOccurs="0" maxOccurs="unbounded"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:length value="0"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + </xs:choice> + <xs:attribute name="openaireDescriptionType" type="openaireDescriptionType" use="required"/> + <xs:attribute name="lang"/> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="geoLocations" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="geoLocation" minOccurs="0" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>Spatial region or named place where the data was gathered or about which the data is focused.</xs:documentation> + <xs:documentation>A point contains a single latitude-longitude pair, separated by whitespace.</xs:documentation> + <xs:documentation>A box contains two white space separated latitude-longitude pairs, with each pair separated by whitespace. The first pair is the lower corner, the second is the upper corner.</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:sequence> + <xs:element name="geoLocationPoint" type="point" minOccurs="0"/> + <xs:element name="geoLocationBox" type="box" minOccurs="0"/> + <xs:element name="geoLocationPlace" minOccurs="0"/> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:all> + </xs:complexType> + </xs:element> + <!-- TYPE DECLARATIONS --> + <!-- defines the value for a DOI: DOI must start with "10." --> + <xs:simpleType name="doiType"> + <xs:restriction base="xs:token"> + <xs:pattern value="10\..+/.+"/> + </xs:restriction> + </xs:simpleType> + <!-- defines value for mandatory fields --> + <xs:simpleType name="nonemptycontentStringType"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + </xs:restriction> + </xs:simpleType> + <xs:attributeGroup name="nameId"> + <xs:attribute name="nameIdentifier" type="xs:string" use="optional"/> + <xs:attribute name="nameIdentifierScheme" type="xs:string" use="optional"/> + </xs:attributeGroup> + <!-- defines the value for a year --> + <xs:simpleType name="yearType"> + <xs:restriction base="xs:token"> + <xs:pattern value="[\d]{4}"/> + </xs:restriction> + <!-- definitions for geoLocation --> + </xs:simpleType> + <xs:simpleType name="point"> + <xs:restriction base="listOfDoubles"> + <xs:minLength value="2"/> + <xs:maxLength value="2"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="box"> + <xs:restriction base="listOfDoubles"> + <xs:minLength value="4"/> + <xs:maxLength value="4"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="listOfDoubles"> + <xs:list itemType="xs:double"/> + </xs:simpleType> +</xs:schema> diff --git a/oaipmh-core/src/main/resources/bindings.xjb b/oaipmh-core/src/main/resources/bindings.xjb index a85bd2428058235ab071d54921f098ec53819781..4d1a426b65b80c36f69349980626c0439d7b80b0 100644 --- a/oaipmh-core/src/main/resources/bindings.xjb +++ b/oaipmh-core/src/main/resources/bindings.xjb @@ -2,9 +2,12 @@ <jxb:bindings version="1.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:namespace="http://jaxb2-commons.dev.java.net/namespace-prefix" xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb https://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd http://jaxb2-commons.dev.java.net/namespace-prefix https://raw.githubusercontent.com/Siggen/jaxb2-namespace-prefix/master/src/main/resources/prefix-namespace-schema.xsd"> + <jxb:bindings schemaLocation="oai_pmh.xsd"> <jxb:schemaBindings> <jxb:package name="info.textgrid.middleware.oaipmh" /> @@ -20,6 +23,49 @@ name="oai_dc" /> <namespace:prefix namespaceURI="http://purl.org/dc/elements/1.1/" name="dc" /> + <namespace:prefix + namespaceURI="http://datacite.org/schema/kernel-3" name="datacite" /> + <namespace:prefix + namespaceURI="http://namespace.openaire.eu/oaf" name="open_aire" /> </jxb:bindings> + + + </jxb:bindings> + + <jxb:bindings schemaLocation="openaire.xsd"> + <jxb:schemaBindings> + <jxb:package + name="info.textgrid.middleware.oaipmh.openaire" /> + </jxb:schemaBindings> </jxb:bindings> + + + + + <!-- MIT DIESEM HIER EINKOMMENTIERT, benennt er die Klassen um, scheint + sie aber irgendwo NOCHMAL zu definieren?? --> + + <jxb:bindings schemaLocation="oaf-common-1.0.xsd" multiple="true" node="/xs:schema"> + <jxb:schemaBindings> + <jxb:package name="info.textgrid.middleware.oaipmh.oaf.common" /> + </jxb:schemaBindings> + <jxb:bindings node="//xs:attribute[@name='classname']" multiple="true" > + <jxb:property name="OAFClassnameProperty" /> + </jxb:bindings> + <jxb:bindings node="//xs:attribute[@name='classid']" multiple="true" > + <jxb:property name="OAFClassidProperty" /> + </jxb:bindings> + <jxb:bindings node="//xs:attribute[@name='schemeid']" multiple="true" > + <jxb:property name="OAFSchemeidProperty" /> + </jxb:bindings> + <jxb:bindings node="//xs:attribute[@name='schemename']" multiple="true" > + <jxb:property name="OAFSchemenameProperty" /> + </jxb:bindings> + + </jxb:bindings> + + + + + </jxb:bindings> diff --git a/oaipmh-core/src/main/resources/include/datacite-contributorType-v3.1.xsd b/oaipmh-core/src/main/resources/include/datacite-contributorType-v3.1.xsd new file mode 100644 index 0000000000000000000000000000000000000000..c472076af44c0e2a6c30d8e1f7183d6be6ba5e36 --- /dev/null +++ b/oaipmh-core/src/main/resources/include/datacite-contributorType-v3.1.xsd @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Version 1.0 - Created 2011-01-13 - FZ, TIB, Germany + 2013-05 v3.0: Addition of ID to simpleType element, added values "ResearchGroup" & "Other" + 2014-08-20 v3.1: Addition of value "DataCurator" + 2015-05-14 v4.0 dropped value "Funder", use new "funderReference" --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datacite.org/schema/kernel-3" targetNamespace="http://datacite.org/schema/kernel-3" elementFormDefault="qualified"> + <xs:simpleType name="contributorType" id="contributorType"> + <xs:annotation> + <xs:documentation>The type of contributor of the resource.</xs:documentation> + </xs:annotation> + <xs:restriction base="xs:string"> + <xs:enumeration value="ContactPerson"/> + <xs:enumeration value="DataCollector"/> + <xs:enumeration value="DataCurator"/> + <xs:enumeration value="DataManager"/> + <xs:enumeration value="Distributor"/> + <xs:enumeration value="Editor"/> + <xs:enumeration value="HostingInstitution"/> + <xs:enumeration value="Other"/> + <xs:enumeration value="Producer"/> + <xs:enumeration value="ProjectLeader"/> + <xs:enumeration value="ProjectManager"/> + <xs:enumeration value="ProjectMember"/> + <xs:enumeration value="RegistrationAgency"/> + <xs:enumeration value="RegistrationAuthority"/> + <xs:enumeration value="RelatedPerson"/> + <xs:enumeration value="ResearchGroup"/> + <xs:enumeration value="RightsHolder"/> + <xs:enumeration value="Researcher"/> + <xs:enumeration value="Sponsor"/> + <xs:enumeration value="Supervisor"/> + <xs:enumeration value="WorkPackageLeader"/> + </xs:restriction> + </xs:simpleType> +</xs:schema> diff --git a/oaipmh-core/src/main/resources/include/datacite-dateType-v3.xsd b/oaipmh-core/src/main/resources/include/datacite-dateType-v3.xsd new file mode 100644 index 0000000000000000000000000000000000000000..0455f8ac57344bd75fa5119603293297b33353a5 --- /dev/null +++ b/oaipmh-core/src/main/resources/include/datacite-dateType-v3.xsd @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Version 1.0 - Created 2011-01-13 - FZ, TIB, Germany + 2013-05 v3.0: Addition of ID to simpleType element; addition of value "Collected"; deleted "StartDate" & "EndDate"--> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datacite.org/schema/kernel-3" targetNamespace="http://datacite.org/schema/kernel-3" elementFormDefault="qualified"> + <xs:simpleType name="dateType" id="dateType"> + <xs:annotation> + <xs:documentation>The type of date. Use RKMSâ€ISO8601 standard for depicting date ranges.To indicate the end of an embargo period, use Available. To indicate the start of an embargo period, use Submitted or Accepted, as appropriate.</xs:documentation> + </xs:annotation> + <xs:restriction base="xs:string"> + <xs:enumeration value="Accepted"/> + <xs:enumeration value="Available"/> + <xs:enumeration value="Collected"/> + <xs:enumeration value="Copyrighted"/> + <xs:enumeration value="Created"/> + <xs:enumeration value="Issued"/> + <xs:enumeration value="Submitted"/> + <xs:enumeration value="Updated"/> + <xs:enumeration value="Valid"/> + </xs:restriction> + </xs:simpleType> +</xs:schema> diff --git a/oaipmh-core/src/main/resources/include/datacite-descriptionType-v3.xsd b/oaipmh-core/src/main/resources/include/datacite-descriptionType-v3.xsd new file mode 100644 index 0000000000000000000000000000000000000000..881a4dfddd66bf3421e93cb4845f17bde757e81b --- /dev/null +++ b/oaipmh-core/src/main/resources/include/datacite-descriptionType-v3.xsd @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Version 1.0 - Created 2011-01-13 - FZ, TIB, Germany + 2013-05 v3.0: Addition of ID to simpleType element, addition of value "Methods" + 2015-02-12 v4.0: Addition of value "TechnicalInfo"--> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datacite.org/schema/kernel-3" targetNamespace="http://datacite.org/schema/kernel-3" elementFormDefault="qualified"> + <xs:simpleType name="openaireDescriptionType" id="openaireDescriptionType"> + <xs:annotation> + <xs:documentation>The type of the description.</xs:documentation> + </xs:annotation> + <xs:restriction base="xs:string"> + <xs:enumeration value="Abstract"/> + <xs:enumeration value="Methods"/> + <xs:enumeration value="SeriesInformation"/> + <xs:enumeration value="TableOfContents"/> + <xs:enumeration value="TechnicalInfo"/> + <xs:enumeration value="Other"/> + </xs:restriction> + </xs:simpleType> +</xs:schema> diff --git a/oaipmh-core/src/main/resources/include/datacite-relatedIdentifierType-v3.1.xsd b/oaipmh-core/src/main/resources/include/datacite-relatedIdentifierType-v3.1.xsd new file mode 100644 index 0000000000000000000000000000000000000000..a300456d93c1fad4d5bc96f73d9f526b9270db5e --- /dev/null +++ b/oaipmh-core/src/main/resources/include/datacite-relatedIdentifierType-v3.1.xsd @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Version 1.0 - Created 2011-01-13 - FZ, TIB, Germany + 2013-05 v3.0: Addition of ID to simpleType element; addition of value "PMID" + 2014-08-20 v3.1: Addition of values "arxiv" and "bibcode"--> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datacite.org/schema/kernel-3" targetNamespace="http://datacite.org/schema/kernel-3" elementFormDefault="qualified"> + <xs:simpleType name="relatedIdentifierType" id="relatedIdentifierType"> + <xs:annotation> + <xs:documentation>The type of the RelatedIdentifier.</xs:documentation> + </xs:annotation> + <xs:restriction base="xs:string"> + <xs:enumeration value="ARK"/> + <xs:enumeration value="arXiv"/> + <xs:enumeration value="bibcode"/> + <xs:enumeration value="DOI"/> + <xs:enumeration value="EAN13"/> + <xs:enumeration value="EISSN"/> + <xs:enumeration value="Handle"/> + <xs:enumeration value="ISBN"/> + <xs:enumeration value="ISSN"/> + <xs:enumeration value="ISTC"/> + <xs:enumeration value="LISSN"/> + <xs:enumeration value="LSID"/> + <xs:enumeration value="PMID"/> + <xs:enumeration value="PURL"/> + <xs:enumeration value="UPC"/> + <xs:enumeration value="URL"/> + <xs:enumeration value="URN"/> + </xs:restriction> + </xs:simpleType> +</xs:schema> diff --git a/oaipmh-core/src/main/resources/include/datacite-relationType-v3.1.xsd b/oaipmh-core/src/main/resources/include/datacite-relationType-v3.1.xsd new file mode 100644 index 0000000000000000000000000000000000000000..ed8516b52bdd3a92220946e2b22b630de2fa55f3 --- /dev/null +++ b/oaipmh-core/src/main/resources/include/datacite-relationType-v3.1.xsd @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Version 1.0 - Created 2011-01-13 - FZ, TIB, Germany + 2013-05 v3.0: Addition of ID to simpleType element, addition of values "IsIdenticalTo", "HasMetadata" & "IsMetadataFor" + 2014-08-20 v3.1: Addition of values "Reviews" & "IsReviewedBy" and "IsDerivedFrom" & "IsSourceOf"--> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datacite.org/schema/kernel-3" targetNamespace="http://datacite.org/schema/kernel-3" elementFormDefault="qualified"> + <xs:simpleType name="relationType" id="relationType"> + <xs:annotation> + <xs:documentation>Description of the relationship of the resource being registered (A) and the related resource (B).</xs:documentation> + </xs:annotation> + <xs:restriction base="xs:string"> + <xs:enumeration value="IsCitedBy"/> + <xs:enumeration value="Cites"/> + <xs:enumeration value="IsSupplementTo"/> + <xs:enumeration value="IsSupplementedBy"/> + <xs:enumeration value="IsContinuedBy"/> + <xs:enumeration value="Continues"/> + <xs:enumeration value="IsNewVersionOf"/> + <xs:enumeration value="IsPreviousVersionOf"/> + <xs:enumeration value="IsPartOf"/> + <xs:enumeration value="HasPart"/> + <xs:enumeration value="IsReferencedBy"/> + <xs:enumeration value="References"/> + <xs:enumeration value="IsDocumentedBy"/> + <xs:enumeration value="Documents"/> + <xs:enumeration value="IsCompiledBy"/> + <xs:enumeration value="Compiles"/> + <xs:enumeration value="IsVariantFormOf"/> + <xs:enumeration value="IsOriginalFormOf"/> + <xs:enumeration value="IsIdenticalTo"/> + <xs:enumeration value="HasMetadata"/> + <xs:enumeration value="IsMetadataFor"/> + <xs:enumeration value="Reviews"/> + <xs:enumeration value="IsReviewedBy"/> + <xs:enumeration value="IsDerivedFrom"/> + <xs:enumeration value="IsSourceOf"/> + </xs:restriction> + </xs:simpleType> +</xs:schema> diff --git a/oaipmh-core/src/main/resources/include/datacite-resourceType-v3.xsd b/oaipmh-core/src/main/resources/include/datacite-resourceType-v3.xsd new file mode 100644 index 0000000000000000000000000000000000000000..3205a0cd3df8975b6b142061d67fe63622cda082 --- /dev/null +++ b/oaipmh-core/src/main/resources/include/datacite-resourceType-v3.xsd @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Version 1.0 - Created 2011-01-13 - FZ, TIB, Germany + 2013-05 v3.0: Addition of ID to simpleType element; added values "Audiovisual", "Workflow" & "Other"; deleted value "Film" --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datacite.org/schema/kernel-3" targetNamespace="http://datacite.org/schema/kernel-3" elementFormDefault="qualified"> + <xs:simpleType name="resourceType" id="resourceType"> + <xs:annotation> + <xs:documentation>The general type of a resource.</xs:documentation> + </xs:annotation> + <xs:restriction base="xs:string"> + <xs:enumeration value="Audiovisual"/> + <xs:enumeration value="Collection"/> + <xs:enumeration value="Dataset"/> + <xs:enumeration value="Event"/> + <xs:enumeration value="Image"/> + <xs:enumeration value="InteractiveResource"/> + <xs:enumeration value="Model"/> + <xs:enumeration value="PhysicalObject"/> + <xs:enumeration value="Service"/> + <xs:enumeration value="Software"/> + <xs:enumeration value="Sound"/> + <xs:enumeration value="Text"/> + <xs:enumeration value="Workflow"/> + <xs:enumeration value="Other"/> + </xs:restriction> + </xs:simpleType> +</xs:schema> diff --git a/oaipmh-core/src/main/resources/include/datacite-titleType-v3.xsd b/oaipmh-core/src/main/resources/include/datacite-titleType-v3.xsd new file mode 100644 index 0000000000000000000000000000000000000000..ed2508ad8a9e8da913dbf77ea8763ccff13fe1cf --- /dev/null +++ b/oaipmh-core/src/main/resources/include/datacite-titleType-v3.xsd @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Version 1.0 - Created 2011-01-13 - FZ, TIB, Germany + 2013-05 v3.0: Addition of ID to simpleType element + 2015-02-12 v4.0 Added value "Other" --> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datacite.org/schema/kernel-3" targetNamespace="http://datacite.org/schema/kernel-3" elementFormDefault="qualified"> + <xs:simpleType name="titleType" id="titleType"> + <xs:restriction base="xs:string"> + <xs:enumeration value="AlternativeTitle"/> + <xs:enumeration value="Subtitle"/> + <xs:enumeration value="TranslatedTitle"/> + <xs:enumeration value="Other"/> + </xs:restriction> + </xs:simpleType> +</xs:schema> diff --git a/oaipmh-core/src/main/resources/oaf-1.0.xsd b/oaipmh-core/src/main/resources/oaf-1.0.xsd new file mode 100644 index 0000000000000000000000000000000000000000..952ae31ddbf10d640b11c920f116bb400f07f257 --- /dev/null +++ b/oaipmh-core/src/main/resources/oaf-1.0.xsd @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" + xmlns:dri="http://www.driver-repository.eu/namespace/dri" xmlns="http://namespace.openaire.eu/oaf" + targetNamespace="http://namespace.openaire.eu/oaf"> + + <xs:annotation> + <xs:documentation>This schema describes the XML serialization of the OpenAIRE Research Graph. + For an overview of the model, please check the OpenAIRE Research Graph Data Model at https://doi.org/10.5281/zenodo.2643199 + </xs:documentation> + </xs:annotation> + + <xs:include schemaLocation="oaf-result-1.0.xsd"/> + <xs:include schemaLocation="oaf-org-1.0.xsd"/> + <xs:include schemaLocation="oaf-datasource-1.0.xsd"/> + <xs:include schemaLocation="oaf-project-1.0.xsd"/> + + <xs:element name="entity"> + <xs:complexType> + <xs:sequence> + <xs:choice> + <xs:element ref="result"/> + <xs:element ref="organization"/> + <xs:element ref="datasource"/> + <xs:element ref="project"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + </xs:element> + +</xs:schema> diff --git a/oaipmh-core/src/main/resources/oaf-common-1.0.xsd b/oaipmh-core/src/main/resources/oaf-common-1.0.xsd new file mode 100644 index 0000000000000000000000000000000000000000..b3ffcbbedd1cc20a5401229dbbb30c20d68f5ee6 --- /dev/null +++ b/oaipmh-core/src/main/resources/oaf-common-1.0.xsd @@ -0,0 +1,305 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" + xmlns="http://namespace.openaire.eu/oaf" targetNamespace="http://namespace.openaire.eu/oaf"> + + <xs:annotation> + <xs:documentation>This schema defines common types that can be re-used.</xs:documentation> + </xs:annotation> + + <xs:simpleType name="emptyType"> + <xs:restriction base="xs:string"> + <xs:length value="0"/> + </xs:restriction> + </xs:simpleType> + + <xs:simpleType name="boolOrEmptyType"> + <xs:union memberTypes="emptyType xs:boolean"/> + </xs:simpleType> + + <xs:simpleType name="stringOrEmptyType"> + <xs:union memberTypes="emptyType xs:string"/> + </xs:simpleType> + + <xs:attributeGroup name="dataInfoAttributeGroup"> + <xs:attribute name="inferred" use="optional" type="xs:boolean"> + <xs:annotation> + <xs:documentation>True if this information has been inferred by the automatic + inference algorithms run by OpenAIRE. </xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute name="trust" use="optional" type="xs:string"> + <xs:annotation> + <xs:documentation>Value of trust of this information in the range [0,1]. More the + value, more trustworthy is the information. </xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute name="inferenceprovenance" use="optional" type="xs:string"> + <xs:annotation> + <xs:documentation>Which algorithm inferred the current property. </xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attributeGroup ref="qualifierAttributeGroup"></xs:attributeGroup> + </xs:attributeGroup> + + <xs:attributeGroup name="qualifierAttributeGroup"> + <xs:attribute name="classid" use="required" type="xs:string"/> + <xs:attribute name="classname" use="required" type="xs:string"/> + <xs:attribute name="schemeid" use="required" type="xs:string"/> + <xs:attribute name="schemename" use="required" type="xs:string"/> + </xs:attributeGroup> + + <xs:attributeGroup name="qualifierAttributeGroupAlternative"> + <xs:attribute name="classid_alt" use="required" type="xs:string"/> + <xs:attribute name="classname_alt" use="required" type="xs:string"/> + <xs:attribute name="schemeid_alt" use="required" type="xs:string"/> + <xs:attribute name="schemename_alt" use="required" type="xs:string"/> + </xs:attributeGroup> + + <xs:complexType name="fieldType"> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attributeGroup ref="dataInfoAttributeGroup"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <xs:complexType name="qualifierType"> + <xs:attributeGroup ref="qualifierAttributeGroup"/> + </xs:complexType> + + <xs:complexType name="dataInfoType"> + <xs:attributeGroup ref="dataInfoAttributeGroup"/> + </xs:complexType> + + <xs:complexType name="structuredPropertyElementType"> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attributeGroup ref="qualifierAttributeGroupAlternative"/> + <xs:attributeGroup ref="dataInfoAttributeGroup"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <xs:complexType name="labeledIdElementType"> + <xs:attribute name="id" use="required"/> + <xs:attribute name="label" use="required"/> + </xs:complexType> + + <!-- <oaf:context id="egi" label="EGI" type="community"> + <oaf:category id="egi::virtual" label="EGI virtual organizations"> + <oaf:concept id="egi::virtual::2" label="alice"/> + </oaf:category> + </oaf:context> + <oaf:community id="{@id}" label="{@label}"> + <xsl:apply-templates/> + </oaf:community> + --> + <xs:complexType name="contextType"> + <xs:complexContent> + <xs:extension base="labeledIdElementType"> + <xs:sequence maxOccurs="unbounded"> + <xs:element name="category" type="categoryType"/> + </xs:sequence> + <xs:attributeGroup ref="dataInfoAttributeGroup"/> + </xs:extension> + </xs:complexContent> + </xs:complexType> + + <xs:complexType name="categoryType"> + <xs:complexContent> + <xs:extension base="labeledIdElementType"> + <xs:sequence minOccurs="0" maxOccurs="unbounded"> + <xs:element name="concept" type="conceptType"/> + </xs:sequence> + </xs:extension> + </xs:complexContent> + </xs:complexType> + + <xs:complexType name="conceptType"> + <xs:complexContent> + <xs:extension base="labeledIdElementType"> + <xs:sequence maxOccurs="unbounded" minOccurs="0"> + <xs:element name="concept" type="conceptType"/> + </xs:sequence> + </xs:extension> + </xs:complexContent> + </xs:complexType> + + <xs:complexType name="namedIdElementType"> + <xs:attribute name="id" use="required"/> + <xs:attribute name="name" use="required"/> + <xs:attributeGroup ref="dataInfoAttributeGroup"/> + </xs:complexType> + + <xs:complexType name="relsType"> + <xs:annotation> + <xs:documentation>Relationships to other entities.</xs:documentation> + </xs:annotation> + <xs:choice maxOccurs="unbounded" minOccurs="0"> + <xs:element name="rel" type="relType" minOccurs="0"/> + </xs:choice> + </xs:complexType> + + <xs:complexType name="relType"> + <xs:sequence> + <xs:choice maxOccurs="unbounded"> + <xs:element name="to" type="relToType"/> + <xs:element name="title" type="xs:string"/> + <xs:element name="websiteurl"/> + <xs:choice> + <xs:group ref="relDataSourceGroup"/> + <xs:group ref="relResultGroup"/> + <xs:group ref="relProjectGroup"/> + <xs:group ref="relOrganizationGroup"/> + <xs:group ref="fundingGroup"/> + </xs:choice> + </xs:choice> + </xs:sequence> + <xs:attributeGroup ref="dataInfoAttributeGroup"/> + </xs:complexType> + + <xs:group name="relDataSourceGroup"> + <xs:sequence> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:element name="officialname" type="xs:string"/> + <xs:element name="datasourcetype" type="qualifierType"/> + </xs:choice> + </xs:sequence> + </xs:group> + + <xs:group name="relResultGroup"> + <xs:sequence> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:element name="collectedfrom" type="namedIdElementType"/> + <xs:element name="url" type="xs:string"/> + <xs:element name="pid" type="structuredPropertyElementType"/> + <xs:element name="dateofacceptance" type="xs:string"/> + <xs:element name="publisher" type="xs:string"/> + <xs:element name="resulttype" type="xs:string"> + <xs:annotation> + <xs:documentation> Tells if the related record is about a publication or a + dataset. </xs:documentation> + </xs:annotation> + </xs:element> + <!-- the following fields are available only for similarity relations --> + <xs:element name="similarity" type="xs:double"> + <xs:annotation> + <xs:documentation>The similarity degree expressed in the range (0,1]. This + field is avaiable only when the to/@class is one of + {hasAmongTopNSimilarDocuments, + isAmongTopNSimilarDocuments}</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="type"> + <xs:annotation> + <xs:documentation>The similarity degree expressed in the range (0,1]. This + field is avaiable only when the to/@class is one of + {hasAmongTopNSimilarDocuments, + isAmongTopNSimilarDocuments}</xs:documentation> + </xs:annotation> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:enumeration value="STANDARD"/> + <xs:enumeration value="WEBUSAGE"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + </xs:choice> + </xs:sequence> + </xs:group> + + <xs:group name="relProjectGroup"> + <xs:sequence> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:element name="code" type="xs:string"/> + <xs:element name="acronym" type="xs:string"/> + </xs:choice> + </xs:sequence> + </xs:group> + + <xs:group name="fundingGroup"> + <xs:sequence> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:element name="contracttype" type="qualifierType"/> + <xs:element name="funding" type="fundingFlatType"/> + </xs:choice> + </xs:sequence> + </xs:group> + + <xs:group name="relOrganizationGroup"> + <xs:sequence> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:element name="legalname" type="xs:string"/> + <xs:element name="legalshortname" type="xs:string"/> + <xs:element name="country" type="xs:string"/> + </xs:choice> + </xs:sequence> + </xs:group> + + + <xs:complexType name="relToType"> + <xs:annotation> + <xs:documentation>Information about the related entity. <p>The semantics of the + relationships is expressed by the attributes class and scheme. </p> + </xs:documentation> + </xs:annotation> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="class" use="required" type="xs:string"/> + <xs:attribute name="type" use="required" type="xs:string"> + <xs:annotation> + <xs:documentation>The type of the related entity. <p>Allowed values are: + project, organization, datasource, result, person.</p> + </xs:documentation> + </xs:annotation> + </xs:attribute> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <xs:complexType name="fundingFlatType"> + <xs:sequence> + <xs:element name="funder" type="funderFlatType" minOccurs="1" maxOccurs="1"/> + <xs:element name="funding_level_0" type="namedFundingLevel" minOccurs="0" + maxOccurs="unbounded"/> + <xs:element name="funding_level_1" type="namedFundingLevel" minOccurs="0" + maxOccurs="unbounded"/> + <xs:element name="funding_level_2" type="namedFundingLevel" minOccurs="0" + maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="funderFlatType"> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="id" use="required" type="xs:string"/> + <xs:attribute name="shortname" use="required" type="xs:string"/> + <xs:attribute name="name" use="required" type="xs:string"/> + <xs:attribute name="jurisdiction" use="optional" type="xs:string"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <xs:complexType name="namedFundingLevel"> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="name" use="required" type="xs:string"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <xs:complexType name="externalreferenceType"> + <xs:sequence> + <xs:element name="sitename" type="xs:string" minOccurs="0" maxOccurs="1"/> + <!--<xs:element name="label" type="xs:string" minOccurs="0" maxOccurs="1"/>--> + <xs:element name="url" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="qualifier" type="qualifierType" minOccurs="0" maxOccurs="1"/> + <xs:element name="refidentifier" type="xs:string" minOccurs="0" maxOccurs="1"/> + </xs:sequence> + <xs:attributeGroup ref="dataInfoAttributeGroup"/> + </xs:complexType> + + + <!-- REMOVE FROM HERE TO THE END --> + +</xs:schema> diff --git a/oaipmh-core/src/main/resources/oaf-datasource-1.0.xsd b/oaipmh-core/src/main/resources/oaf-datasource-1.0.xsd new file mode 100644 index 0000000000000000000000000000000000000000..c84ec2531dafd7151cd00ac15f6b15aa1fd579af --- /dev/null +++ b/oaipmh-core/src/main/resources/oaf-datasource-1.0.xsd @@ -0,0 +1,76 @@ +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://namespace.openaire.eu/oaf" + targetNamespace="http://namespace.openaire.eu/oaf" elementFormDefault="qualified"> + + <xs:annotation> + <xs:documentation>This schema describes elements and properties of OpenAIRE datasources: https://issue.openaire.research-infrastructures.eu/projects/openaire2020-wiki/wiki/Core_entity_datasource</xs:documentation> + </xs:annotation> + + <xs:include schemaLocation="oaf-common-1.0.xsd"/> + + <xs:element name="datasource"> + <xs:complexType> + <xs:choice maxOccurs="unbounded"> + <xs:element name="namespaceprefix" type="xs:string" /> + <xs:element name="officialname" type="xs:string" /> + <xs:element name="englishname" type="xs:string" /> + <xs:element name="websiteurl" type="xs:string" /> + <xs:element name="logourl" type="xs:string" /> + <xs:element name="contactemail" type="xs:string" /> + <xs:element name="datasourcetype" type="qualifierType"> + <xs:annotation> + <xs:documentation>For allowed values check terms in:http://api.openaire.eu/vocabularies/dnet:datasource_typologies</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="openairecompatibility" type="qualifierType"> + <xs:annotation> + <xs:documentation> + Level of compatibility of this datasource with regards to the + guidelines. + <p>For allowed values check: + http://api.openaire.eu/vocabularies/dnet:datasourceCompatibilityLevel + </p> + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="dateofvalidation" type="xs:string"> + <xs:annotation> + <xs:documentation>When this datasource has been validated by the + OpenAire + Validator. + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="latitude" type="xs:string" /> + <xs:element name="longitude" type="xs:string" /> + <xs:element name="description" type="xs:string" /> + <xs:element name="subjects" type="structuredPropertyElementType"> + <xs:annotation> + <xs:documentation> + Subjects and keywords. + <p>For allowed values check: + http://api.openaire.eu/vocabularies/dnet:result_subjects + </p> + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="originalId" type="xs:string" /> + <xs:element name="collectedfrom" type="namedIdElementType"> + <xs:annotation> + <xs:documentation>Identifier and name of the datasource from which + this datasource has + been collected from. + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="pid" type="structuredPropertyElementType" /> + <xs:element name="rels" type="relsType"> + <xs:annotation> + <xs:documentation>Relationships to other entities. + </xs:documentation> + </xs:annotation> + </xs:element> + + </xs:choice> + </xs:complexType> + </xs:element> +</xs:schema> diff --git a/oaipmh-core/src/main/resources/oaf-org-1.0.xsd b/oaipmh-core/src/main/resources/oaf-org-1.0.xsd new file mode 100644 index 0000000000000000000000000000000000000000..3c46fca44b6462be5fb51d116555cac23ea9d016 --- /dev/null +++ b/oaipmh-core/src/main/resources/oaf-org-1.0.xsd @@ -0,0 +1,41 @@ +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://namespace.openaire.eu/oaf" + targetNamespace="http://namespace.openaire.eu/oaf" elementFormDefault="qualified"> + + <xs:annotation> + <xs:documentation>This schema describes elements and properties of OpenAIRE entities of type organization: https://issue.openaire.research-infrastructures.eu/projects/openaire2020-wiki/wiki/Core_entity_organization</xs:documentation> + </xs:annotation> + + <xs:include schemaLocation="oaf-common-1.0.xsd"/> + + <xs:element name="organization"> + <xs:complexType> + <xs:choice maxOccurs="unbounded"> + <xs:element name="legalname" type="xs:string"/> + <xs:element name="legalshortname" type="xs:string"/> + <xs:element name="logourl" type="xs:string"/> + <xs:element name="originalId" type="xs:string"/> + <xs:element name="websiteurl" type="xs:string"/> + <xs:element name="country" type="qualifierType"> + <xs:annotation> + <xs:documentation>Countries in ISO 3166-1 alpha-2. </xs:documentation> + </xs:annotation> + </xs:element> + + <xs:element name="collectedfrom" type="namedIdElementType"> + <xs:annotation> + <xs:documentation>Identifier and name of the datasource from which this + organization has been collected from. </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="pid" type="structuredPropertyElementType"/> + <xs:element name="rels" type="relsType"> + <xs:annotation> + <xs:documentation>Relationships to other entities. </xs:documentation> + </xs:annotation> + </xs:element> + <!-- If we decide not to show deduplicated org, then we have to remove this field --> + <!-- <xs:element name="duplicates" type="mergedOrgs"/> --> + </xs:choice> + </xs:complexType> + </xs:element> +</xs:schema> diff --git a/oaipmh-core/src/main/resources/oaf-project-1.0.xsd b/oaipmh-core/src/main/resources/oaf-project-1.0.xsd new file mode 100644 index 0000000000000000000000000000000000000000..abcba4d9f63f31996226f01a18ab575541e32827 --- /dev/null +++ b/oaipmh-core/src/main/resources/oaf-project-1.0.xsd @@ -0,0 +1,111 @@ +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://namespace.openaire.eu/oaf" + targetNamespace="http://namespace.openaire.eu/oaf" elementFormDefault="qualified"> + + <xs:annotation> + <xs:documentation>This schema describes elements and properties of OpenAIRE project entity: https://issue.openaire.research-infrastructures.eu/projects/openaire2020-wiki/wiki/Core_entity_project</xs:documentation> + </xs:annotation> + + <xs:include schemaLocation="oaf-common-1.0.xsd"/> + + <xs:element name="project"> + <xs:complexType> + <xs:choice maxOccurs="unbounded"> + <xs:element name="code" type="xs:string"> + <xs:annotation> + <xs:documentation>Project code as assigned by the project's funder.</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="title" type="xs:string"/> + <xs:element name="acronym" type="xs:string"/> + <xs:element name="callidentifier" type="xs:string"> + <xs:annotation> + <xs:documentation> Identifier of the call for proposal.</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="contactfullname" type="xs:string"/> + <xs:element name="contactfax" type="xs:string"/> + <xs:element name="contactphone" type="xs:string"/> + <xs:element name="contactemail" type="xs:string"/> + <xs:element name="contracttype" type="qualifierType"/> + <xs:element name="keywords" type="xs:string"/> + <xs:element name="websiteurl" type="xs:string"/> + <xs:element name="startdate" type="xs:string"/> + <xs:element name="enddate" type="xs:string"/> + <xs:element name="duration" type="xs:string"/> + <xs:element name="ecsc39" type="boolOrEmptyType"> + <xs:annotation> + <xs:documentation>True if the project has the special clause 39. Available + only for EC FP7 funded projects. </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="oamandatepublications" type="xs:boolean"> + <xs:annotation> + <xs:documentation>True if the project's funding mandates the availability of project's publications in Open Access.</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="ecarticle29_3" type="boolOrEmptyType"> + <xs:annotation> + <xs:documentation>True if the project is under the EC Open Data Pilot. Available only for EC H2020 funded projects. </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="subjects" type="qualifierType"/> + + <xs:element name="fundingtree" type="fundingTreeType"/> + <xs:element name="originalId" type="xs:string"/> + <xs:element name="collectedfrom" type="namedIdElementType"> + <xs:annotation> + <xs:documentation>Identifier and name of the datasource from which this + project has been collected from. </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="pid" type="qualifierType"/> + <xs:element name="rels" type="relsType"> + <xs:annotation> + <xs:documentation>Relationships to other entities. </xs:documentation> + </xs:annotation> + </xs:element> + </xs:choice> + </xs:complexType> + </xs:element> + + <!-- to be removed, and replaced by ContextType --> + <xs:complexType name="fundingTreeType"> + <xs:sequence> + <xs:element name="funder" type="funderType"/> + <xs:choice maxOccurs="unbounded"> + <!-- Three-tier funding hierarchies --> + <xs:element name="funding_level_2" type="fundingType"/> + <!-- Two-tier funding hierarchies --> + <xs:element name="funding_level_1" type="fundingType"/> + <!-- No funding hierarchy --> + <xs:element name="funding_level_0" type="fundingType"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="fundingType"> + <xs:all> + <xs:element name="id" type="xs:string"/> + <xs:element name="description" type="xs:string"/> + <xs:element name="name" type="xs:string"/> + <xs:element name="class" type="xs:string"/> + <xs:element name="parent" type="fundingParentType"/> + </xs:all> + </xs:complexType> + + <xs:complexType name="fundingParentType"> + <xs:choice minOccurs="0"> + <xs:element name="funding_level_1" type="fundingType"/> + <xs:element name="funding_level_0" type="fundingType"/> + </xs:choice> + </xs:complexType> + + <xs:complexType name="funderType"> + <xs:all> + <xs:element name="id" type="xs:string"/> + <xs:element name="shortname" type="xs:string"/> + <xs:element name="name" type="xs:string"/> + <xs:element name="jurisdiction" type="xs:string"/> + </xs:all> + </xs:complexType> +</xs:schema> diff --git a/oaipmh-core/src/main/resources/oaf-result-1.0.xsd b/oaipmh-core/src/main/resources/oaf-result-1.0.xsd new file mode 100644 index 0000000000000000000000000000000000000000..2ffd39849cbb1f5da2ebfa5d7cba94ae8d21185f --- /dev/null +++ b/oaipmh-core/src/main/resources/oaf-result-1.0.xsd @@ -0,0 +1,242 @@ +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" + xmlns="http://namespace.openaire.eu/oaf" targetNamespace="http://namespace.openaire.eu/oaf"> + + <xs:annotation> + <xs:documentation>This schema describes elements and properties of the OpenAIRE Result entity. For an overview of the model, please check the OpenAIRE Research Graph Data Model at https://doi.org/10.5281/zenodo.2643199</xs:documentation> + </xs:annotation> + + <xs:include schemaLocation="oaf-common-1.0.xsd"/> + + <xs:element name="result"> + <xs:complexType> + <xs:choice maxOccurs="unbounded"> + <xs:element name="creator"> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="name" type="xs:string"/> + <xs:attribute name="surname" type="xs:string"/> + <xs:attribute name="ORCID" type="xs:string"/> + <xs:attribute name="rank" type="xs:int"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + <xs:element name="resulttype" type="qualifierType"> + <xs:annotation> + <xs:documentation> Tells if this record is about a publication or a dataset. + <p>For allowed values check: + http://api.openaire.eu/vocabularies/dnet:result_typologies </p> + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="language" type="qualifierType"/> + <xs:element name="country" type="dataInfoType"/> + <xs:element name="subject" type="structuredPropertyElementType"/> + <xs:element name="title" type="structuredPropertyElementType"> + <xs:annotation> + <xs:documentation> Title of this research result. <p>Different types of + titles are allowed: see http://api.openaire.eu/vocabularies/dnet:dataCite_title</p> + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="relevantdate" type="structuredPropertyElementType"/> + <xs:element name="description" type="xs:string"/> + <xs:element name="dateofacceptance" type="xs:string"/> + <xs:element name="publisher" type="xs:string"/> + <xs:element name="embargoenddate" type="xs:string"/> + <xs:element name="source" type="xs:string"> + <xs:annotation> + <xs:documentation>The semantics of this field is inherited from dc:source in + Dublin Core. </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="format" type="xs:string"/> + <xs:element name="contributor" type="xs:string"/> + <xs:element name="resourcetype" type="qualifierType"> + <xs:annotation> + <xs:documentation> This field is valid only if resulttype is "dataset". It + expresses the nature of the dataset. <p>For allowed values check: + http://api.openaire.eu/vocabularies/dnet:publication_resource </p> + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="coverage" type="xs:string"/> + <xs:element name="bestaccessright" type="qualifierType"> + <xs:annotation> + <xs:documentation> The best access right available for this result among the + available licenses of its children elements. <p>For allowed values + check: http://api.openaire.eu/vocabularies/dnet:access_modes </p> + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="journal" type="journalType"/> + <xs:element name="pid" type="structuredPropertyElementType"> + <xs:annotation> + <xs:documentation> Persistent identifier. <p>For allowed pid systems check: + http://api.openaire.eu/vocabularies/dnet:pid_types </p> + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="device" type="xs:string"> + <xs:annotation> + <xs:documentation> This field is valid only if resulttype is "dataset". It + contains information about the device used to generate the dataset. + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="size" type="xs:string"> + <xs:annotation> + <xs:documentation> This field is valid only if resulttype is "dataset". It + contains information about the size of the dataset. </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="version" type="xs:string"> + <xs:annotation> + <xs:documentation> This field is valid only if resulttype is "dataset". It + contains information about the version of the dataset. + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="lastmetadataupdate" type="xs:string"> + <xs:annotation> + <xs:documentation> This field is valid only if resulttype is "dataset". It + is the last update date of the metadata of the dataset. + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="metadataversionnumber" type="xs:string"> + <xs:annotation> + <xs:documentation> This field is valid only if resulttype is "dataset". It + contains information about the version of the metadata of the dataset. + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="originalId" type="xs:string" maxOccurs="unbounded"/> + <xs:element name="collectedfrom" type="namedIdElementType" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>Identifier and name of the datasource from which this + result has been collected from (e.g., "OpenDOAR"). </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="context" type="contextType"> + <xs:annotation> + <xs:documentation>Research community, initiative, infrastructure or funding agency related to this result.</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="rels" type="relsType"> + <xs:annotation> + <xs:documentation>Relationships to other entities. </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="instances" type="instancesType" minOccurs="1" maxOccurs="1"/> + <xs:element name="citations" type="citationsType" maxOccurs="1" minOccurs="0"/> + </xs:choice> + </xs:complexType> + </xs:element> + + <xs:complexType name="citationsType"> + <xs:sequence> + <xs:element name="citation" maxOccurs="unbounded" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="rawText"/> + <xs:element name="id" minOccurs="0" maxOccurs="unbounded"> + <xs:complexType> + <xs:attribute name="value"/> + <xs:attribute name="type"/> + <xs:attribute name="confidenceLevel"/> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + <xs:attribute name="provenance" type="xs:string"/> + <xs:attribute name="trust" type="xs:string"/> + </xs:complexType> + + <xs:complexType name="journalType"> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="eissn" use="optional"/> + <xs:attribute name="issn" use="optional"/> + <xs:attribute name="lissn" use="optional"/> + <xs:attribute name="ep" use="optional"/> + <xs:attribute name="iss" use="optional"/> + <xs:attribute name="sp" use="optional"/> + <xs:attribute name="vol" use="optional"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + <xs:complexType name="instancesType"> + <xs:sequence> + <xs:element name="instance" type="instanceType" minOccurs="1" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>Actual digital representation of the publication or dataset. + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="externalreference" type="externalreferenceType" minOccurs="0" + maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="instanceType"> + <xs:choice maxOccurs="unbounded"> + <xs:element name="license" type="fieldType"> + <xs:annotation> + <xs:documentation> License to access this actual manifestation of the + result. Typically it is a URL. OpenAIRE does not yet attempt any harmonization and reflect the original values that are available in the collected metadata records. + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="accessright" type="qualifierType"/> + <xs:element name="instancetype" type="qualifierType"> + <xs:annotation> + <xs:documentation> Type of the instance, for example: article, thesis, etc. + <p>For allowed values check: http://api.openaire.eu/vocabularies/dnet:publication_resource + </p> + </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="collectedfrom" type="namedIdElementType" maxOccurs="1"> + <xs:annotation> + <xs:documentation>Datasource from which OpenAIRE collected the description of this instance.</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="hostedby" type="namedIdElementType" maxOccurs="1"> + <xs:annotation> + <xs:documentation>Datasource hosting this file. </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="webresource" type="webresourceType" minOccurs="1" + maxOccurs="unbounded"/> + <xs:element name="distributionlocation" type="xs:string" minOccurs="0"/> + <xs:element name="dateofacceptance" type="xs:string" minOccurs="0"/> + <xs:element name="processingchargeamount" type="fieldType"> + <xs:annotation> + <xs:documentation> Article/Book Processing Charge </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="processingchargecurrency" type="fieldType"> + <xs:annotation> + <xs:documentation>Currency for the value in processingchargeamount </xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="refereed" type="fieldType"> + <xs:annotation> + <xs:documentation>Peer-review status</xs:documentation> + </xs:annotation> + </xs:element> + </xs:choice> + <xs:attribute name="id" use="required"/> + </xs:complexType> + + <xs:complexType name="webresourceType"> + <xs:sequence> + <xs:element name="url" type="xs:string" minOccurs="1" maxOccurs="1"/> + </xs:sequence> + </xs:complexType> + +</xs:schema> diff --git a/oaipmh-core/src/main/resources/oai_dc.xsd b/oaipmh-core/src/main/resources/oai_dc.xsd index 88479d78648ab89020b97d1d347cfabc4972e79b..da2b49c8bb402faffb9700b4262c9b3f84b98e7b 100644 --- a/oaipmh-core/src/main/resources/oai_dc.xsd +++ b/oaipmh-core/src/main/resources/oai_dc.xsd @@ -1,8 +1,7 @@ -<schema targetNamespace="http://www.openarchives.org/OAI/2.0/oai_dc/" +<schema targetNamespace="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns="http://www.w3.org/2001/XMLSchema" - + xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <annotation> @@ -14,8 +13,12 @@ </documentation> </annotation> + <!--import namespace="http://purl.org/dc/elements/1.1/" + schemaLocation="file:///home/max/Dokumente/simpledc20021212.xsd"/--> + <import namespace="http://purl.org/dc/elements/1.1/" schemaLocation="https://dublincore.org/schemas/xmls/simpledc20021212.xsd"/> + <element name="dc" type="oai_dc:oai_dcType"/> diff --git a/oaipmh-core/src/main/resources/oai_pmh.xsd b/oaipmh-core/src/main/resources/oai_pmh.xsd index 3fce3b59db458399dfaee104587694ebd9c8805e..12c0cd7a86edb94ded7ed19a3a8ec3c8568a7ae5 100644 --- a/oaipmh-core/src/main/resources/oai_pmh.xsd +++ b/oaipmh-core/src/main/resources/oai_pmh.xsd @@ -313,5 +313,5 @@ <pattern value="([A-Za-z0-9\-_\.!~\*'\(\)])+(:[A-Za-z0-9\-_\.!~\*'\(\)]+)*"/> </restriction> </simpleType> - </schema> + diff --git a/oaipmh-core/src/main/resources/openaire.xsd b/oaipmh-core/src/main/resources/openaire.xsd new file mode 100644 index 0000000000000000000000000000000000000000..496a435cba5b75d82bf8c16bf236014d401e71ae --- /dev/null +++ b/oaipmh-core/src/main/resources/openaire.xsd @@ -0,0 +1,380 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Revision history + 2010-08-26 Complete revision according to new common specification by the metadata work group after review. AJH, DTIC + 2010-11-17 Revised to current state of kernel review, FZ, TIB + 2011-01-17 Complete revsion after community review. FZ, TIB + 2011-03-17 Release of v2.1: added a namespace; mandatory properties got minLength; changes in the definitions of relationTypes + IsDocumentedBy/Documents and isCompiledBy/Compiles; changes type of property "Date" from xs:date to xs:string. FZ, TIB + 2011-06-27 v2.2: namespace: kernel-2.2, additions to controlled lists "resourceType", "contributorType", "relatedIdentifierType", and "descriptionType". Removal of intermediate include-files. + 2013-05 v3.0: namespace: kernel-3.0; delete LastMetadataUpdate & MetadateVersionNumber; additions to controlled lists "contributorType", "dateType", "descriptionType", "relationType", "relatedIdentifierType" & "resourceType"; deletion of "StartDate" & "EndDate" from list "dateType" and "Film" from "resourceType"; allow arbitrary order of elements; allow optional wrapper elements to be empty; include openaire:lang attribute for title, subject & description; include attribute schemeURI for nameIdentifier of creator, contributor & subject; added new attributes "relatedMetadataScheme", "schemeURI" & "schemeType" to relatedIdentifier; included new property "geoLocation" + 2014-08-20 v3.1: additions to controlled lists "relationType", contributorType" and "relatedIdentifierType"; introduction of new child element "affiliation" to "creator" and "contributor"--> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datacite.org/schema/kernel-3" targetNamespace="http://datacite.org/schema/kernel-3" elementFormDefault="qualified" > + + <xs:include schemaLocation="include/datacite-titleType-v3.xsd"/> + <xs:include schemaLocation="include/datacite-contributorType-v3.1.xsd"/> + <xs:include schemaLocation="include/datacite-dateType-v3.xsd"/> + <xs:include schemaLocation="include/datacite-resourceType-v3.xsd"/> + <xs:include schemaLocation="include/datacite-relationType-v3.1.xsd"/> + <xs:include schemaLocation="include/datacite-relatedIdentifierType-v3.1.xsd"/> + <xs:include schemaLocation="include/datacite-descriptionType-v3.xsd"/> + <xs:element name="resource"> + <xs:annotation> + <xs:documentation> + Root element of a single record. This wrapper element is for XML implementation only and is not defined in the DataCite DOI standard. + Note: This is the case for all wrapper elements within this schema!</xs:documentation> + <xs:documentation>No content in this wrapper element.</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:all> + <!--REQUIRED FIELDS--> + <xs:element name="identifier"> + <xs:annotation> + <xs:documentation>A persistent identifier that identifies a resource.</xs:documentation> + <xs:documentation>Currently, only DOI is allowed.</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="doiType"> + <xs:attribute name="identifierType" use="required" fixed="DOI"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + <xs:element name="creators"> + <xs:complexType> + <xs:sequence> + <xs:element name="creator" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>The main researchers involved working on the data, or the authors of the publication in priority order. May be a corporate/institutional or personal name.</xs:documentation> + <xs:documentation>Format: Family, Given.</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:sequence> + <xs:element name="creatorName"> + <xs:simpleType> + <xs:restriction base="nonemptycontentStringType"/> + </xs:simpleType> + </xs:element> + <xs:element name="nameIdentifier" minOccurs="0"> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="nonemptycontentStringType"> + <xs:attribute name="nameIdentifierScheme" use="required"/> + <xs:attribute name="schemeURI" type="xs:anyURI" use="optional"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + <xs:element name="affiliation" minOccurs="0" maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="titles"> + <xs:complexType> + <xs:sequence> + <xs:element name="title" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>A name or title by which a resource is known.</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="nonemptycontentStringType"> + <xs:attribute name="titleType" type="titleType" use="optional"/> + <xs:attribute name="lang"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="publisher"> + <xs:annotation> + <xs:documentation>The name of the entity that holds, archives, publishes prints, distributes, releases, issues, or produces the resource. This property will be used to formulate the citation, so consider the prominence of the role.</xs:documentation> + <xs:documentation>In the case of datasets, "publish" is understood to mean making the data available to the community of researchers.</xs:documentation> + </xs:annotation> + <xs:simpleType> + <xs:restriction base="nonemptycontentStringType"/> + </xs:simpleType> + </xs:element> + <xs:element name="publicationYear"> + <xs:annotation> + <xs:documentation>Year when the data is made publicly available. If an embargo period has been in effect, use the date when the embargo period ends.</xs:documentation> + <xs:documentation>In the case of datasets, "publish" is understood to mean making the data available on a specific date to the community of researchers. If there is no standard publication year value, use the date that would be preferred from a citation perspective.</xs:documentation> + <xs:documentation>YYYY</xs:documentation> + </xs:annotation> + <xs:simpleType> + <xs:restriction base="yearType"/> + </xs:simpleType> + </xs:element> + <!--OPTIONAL FIELDS--> + <xs:element name="subjects" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="subject" minOccurs="0" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>Subject, keywords, classification codes, or key phrases describing the resource.</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="subjectScheme" use="optional"/> + <xs:attribute name="schemeURI" type="xs:anyURI" use="optional"/> + <xs:attribute name="lang"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="contributors" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="contributor" minOccurs="0" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>The institution or person responsible for collecting, creating, or otherwise contributing to the developement of the dataset.</xs:documentation> + <xs:documentation>The personal name format should be: Family, Given.</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:sequence> + <xs:element name="contributorName"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + <xs:element name="nameIdentifier" minOccurs="0"> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="nameIdentifierScheme" use="required"/> + <xs:attribute name="schemeURI" type="xs:anyURI" use="optional"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + <xs:element name="affiliation" minOccurs="0" maxOccurs="unbounded"/> + </xs:sequence> + <xs:attribute name="contributorType" type="contributorType" use="required"/> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="dates" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="date" minOccurs="0" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>Different dates relevant to the work.</xs:documentation> + <xs:documentation>YYYY,YYYY-MM-DD, YYYY-MM-DDThh:mm:ssTZD or any other format or level of granularity described in W3CDTF. Use RKMS-ISO8601 standard for depicting date ranges.</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="dateType" type="dateType" use="required"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="language" type="xs:language" minOccurs="0"> + <xs:annotation> + <xs:documentation>Primary language of the resource. Allowed values are taken from IETF BCP 47, ISO 639-1 language codes.</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="resourceType" minOccurs="0"> + <xs:annotation> + <xs:documentation>The type of a resource. You may enter an additional free text description.</xs:documentation> + <xs:documentation>The format is open, but the preferred format is a single term of some detail so that a pair can be formed with the sub-property.</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="resourceTypeGeneral" type="resourceType" use="required"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + <xs:element name="alternateIdentifiers" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="alternateIdentifier" minOccurs="0" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>An identifier or identifiers other than the primary Identifier applied to the resource being registered. This may be any alphanumeric string which is unique within its domain of issue. May be used for local identifiers. AlternateIdentifier should be used for another identifier of the same instance (same location, same file).</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="alternateIdentifierType" use="required"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="relatedIdentifiers" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="relatedIdentifier" minOccurs="0" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>Identifiers of related resources. Use this property to indicate subsets of properties, as appropriate.</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="relatedIdentifierType" type="relatedIdentifierType" use="required"/> + <xs:attribute name="relationType" type="relationType" use="required"/> + <xs:attribute name="relatedMetadataScheme" use="optional"/> + <xs:attribute name="schemeURI" type="xs:anyURI" use="optional"/> + <xs:attribute name="schemeType" use="optional"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="sizes" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="size" type="xs:string" minOccurs="0" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>Unstructures size information about the resource.</xs:documentation> + </xs:annotation> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="formats" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="format" type="xs:string" minOccurs="0" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>Technical format of the resource.</xs:documentation> + <xs:documentation>Use file extension or MIME type where possible.</xs:documentation> + </xs:annotation> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="version" type="xs:string" minOccurs="0"> + <xs:annotation> + <xs:documentation>Version number of the resource. If the primary resource has changed the version number increases.</xs:documentation> + <xs:documentation>Register a new identifier for a major version change. Individual stewards need to determine which are major vs. minor versions. May be used in conjunction with properties 11 and 12 (AlternateIdentifier and RelatedIdentifier) to indicate various information updates. May be used in conjunction with property 17 (Description) to indicate the nature and file/record range of version.</xs:documentation> + </xs:annotation> + </xs:element> + <xs:element name="rightsList" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="rights" minOccurs="0" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>Any rights information for this resource. Provide a rights management statement for the resource or reference a service providing such information. Include embargo information if applicable. +Use the complete title of a license and include version information if applicable.</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="rightsURI" type="xs:anyURI" use="optional"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="descriptions" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="description" minOccurs="0" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>All additional information that does not fit in any of the other categories. May be used for technical information. It is a best practice to supply a description.</xs:documentation> + </xs:annotation> + <xs:complexType mixed="true"> + <xs:choice> + <xs:element name="br" minOccurs="0" maxOccurs="unbounded"> + <xs:simpleType> + <xs:restriction base="xs:string"> + <xs:length value="0"/> + </xs:restriction> + </xs:simpleType> + </xs:element> + </xs:choice> + <xs:attribute name="descriptionType" type="openaireDescriptionType" use="required"/> + <xs:attribute name="lang"/> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + <xs:element name="geoLocations" minOccurs="0"> + <xs:complexType> + <xs:sequence> + <xs:element name="geoLocation" minOccurs="0" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation>Spatial region or named place where the data was gathered or about which the data is focused.</xs:documentation> + <xs:documentation>A point contains a single latitude-longitude pair, separated by whitespace.</xs:documentation> + <xs:documentation>A box contains two white space separated latitude-longitude pairs, with each pair separated by whitespace. The first pair is the lower corner, the second is the upper corner.</xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:sequence> + <xs:element name="geoLocationPoint" type="point" minOccurs="0"/> + <xs:element name="geoLocationBox" type="box" minOccurs="0"/> + <xs:element name="geoLocationPlace" minOccurs="0"/> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:all> + </xs:complexType> + </xs:element> + <!-- TYPE DECLARATIONS --> + <!-- defines the value for a DOI: DOI must start with "10." --> + <xs:simpleType name="doiType"> + <xs:restriction base="xs:token"> + <xs:pattern value="10\..+/.+"/> + </xs:restriction> + </xs:simpleType> + <!-- defines value for mandatory fields --> + <xs:simpleType name="nonemptycontentStringType"> + <xs:restriction base="xs:string"> + <xs:minLength value="1"/> + </xs:restriction> + </xs:simpleType> + <xs:attributeGroup name="nameId"> + <xs:attribute name="nameIdentifier" type="xs:string" use="optional"/> + <xs:attribute name="nameIdentifierScheme" type="xs:string" use="optional"/> + </xs:attributeGroup> + <!-- defines the value for a year --> + <xs:simpleType name="yearType"> + <xs:restriction base="xs:token"> + <xs:pattern value="[\d]{4}"/> + </xs:restriction> + <!-- definitions for geoLocation --> + </xs:simpleType> + <xs:simpleType name="point"> + <xs:restriction base="listOfDoubles"> + <xs:minLength value="2"/> + <xs:maxLength value="2"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="box"> + <xs:restriction base="listOfDoubles"> + <xs:minLength value="4"/> + <xs:maxLength value="4"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="listOfDoubles"> + <xs:list itemType="xs:double"/> + </xs:simpleType> +</xs:schema> diff --git a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhDARIAHTest.java b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhDARIAHTest.java index 669b00f968e423e7c0a74aee7efdee9770c0316a..bb4a1f96c6a686c6f6327a075baaecfa25863a3e 100644 --- a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhDARIAHTest.java +++ b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhDARIAHTest.java @@ -15,8 +15,6 @@ import info.textgrid.namespaces.middleware.tgcrud.common.TextGridMimetypes; public class OaiPmhDARIAHTest { public static OAI_ESClient oaiEsClient; - DeletedRecordType deletedRecordType = DeletedRecordType.NO; - GranularityType granularityType = GranularityType.YYYY_MM_DD_THH_MM_SS_Z; private static RecordDelivererDC record; private static RecordListDelivererDC recordList; @@ -24,8 +22,15 @@ public class OaiPmhDARIAHTest { private static MetadataFormatListDeliverer metadataFormatList = new MetadataFormatListDeliverer(); private static SetDeliverer setListDARIAH = new SetDeliverer(false, true); + private static OpenAireRecord openAireRecord; + private static OpenAireRecordList openAireRecordList; + private static OpenAireIdentifierList openAireIdentifierList; + + + private DeletedRecordType deletedRecordType = DeletedRecordType.NO; + private GranularityType granularityType = GranularityType.YYYY_MM_DD_THH_MM_SS_Z; private RepIdentification rep = new RepIdentification("DARIAH-DE Repository", - "http://trep.de.dariah.eu", this.deletedRecordType, "2011-06-11T02:32:40Z", + "https://trep.de.dariah.eu", this.deletedRecordType, "2011-06-11T02:32:40Z", this.granularityType, "2.0", "funk@sub.uni-goettingen.de"); /** @@ -36,18 +41,21 @@ public class OaiPmhDARIAHTest { private static IdentifierListDelivererIDIOM identifierListIDIOM = new IdentifierListDelivererIDIOM(true, false); - private OAIPMHImpl request = new OAIPMHImpl(this.rep, OaiPmhDARIAHTest.record, - OaiPmhDARIAHTest.recordIDIOM, OaiPmhDARIAHTest.recordList, OaiPmhDARIAHTest.recordListIDIOM, - OaiPmhDARIAHTest.metadataFormatList, OaiPmhDARIAHTest.setListDARIAH, - OaiPmhDARIAHTest.identifierList, OaiPmhDARIAHTest.identifierListIDIOM); + + private OAIPMHImpl request = new OAIPMHImpl( + this.rep, OaiPmhDARIAHTest.record, OaiPmhDARIAHTest.recordIDIOM, OaiPmhDARIAHTest.openAireRecord, OaiPmhDARIAHTest.recordList, + OaiPmhDARIAHTest.recordListIDIOM, OaiPmhDARIAHTest.openAireRecordList, OaiPmhDARIAHTest.metadataFormatList, + OaiPmhDARIAHTest.setListDARIAH, OaiPmhDARIAHTest.identifierList, OaiPmhDARIAHTest.identifierListIDIOM, OaiPmhDARIAHTest.openAireIdentifierList); + + OAIPMHUtilities settings = new OAIPMHUtilities(); /** * @throws Exception */ @BeforeClass public static void setUp() throws Exception { - - oaiEsClient = new OAI_ESClient("localhost", "9302", "dhrep-dariah-dev-public"); + int[] ports = new int[] {9202}; + oaiEsClient = new OAI_ESClient("localhost", ports, 100); OAI_ESClient.setEsIndex("dariah-public"); OAI_ESClient.setEsType("metadata"); @@ -61,7 +69,6 @@ public class OaiPmhDARIAHTest { */ @Test public void testGetRequestIdentify() throws ParseException { - System.out.println("Test for the verb \"Identify\" with succesfull response"); String r = this.request.getRequest("Identify", "", "", "", "", "", ""); System.out.println(r); diff --git a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhDariahdeOnlineTests.java b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhDariahdeOnlineTests.java index 2778d6f2aad9da32a8d60656f2da6c10f82cbaf2..83088d6bf9e3d33951d2209d81ac6fed07424748 100644 --- a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhDariahdeOnlineTests.java +++ b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhDariahdeOnlineTests.java @@ -9,6 +9,7 @@ import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Test; import info.textgrid.utils.httpclient.TGHttpClient; import info.textgrid.utils.httpclient.TGHttpResponse; @@ -20,6 +21,7 @@ import info.textgrid.utils.httpclient.TGHttpResponse; * * @author Stefan E. Funk, SUB Göttingen */ +@Ignore public class OaiPmhDariahdeOnlineTests { // The OAIPMH host to be tested. diff --git a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java index 75713ab5f8127478a9e82368125467ee9adfcb00..ca9c2a4eb3494ecb08cb8078133bd8c3a14f29ed 100644 --- a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java +++ b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java @@ -1,12 +1,17 @@ package info.textgrid.middleware; +import java.io.IOException; import java.text.ParseException; import java.util.Map; + +import javax.xml.bind.JAXBException; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.XMLGregorianCalendar; + import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; + import info.textgrid.middleware.oaipmh.DeletedRecordType; import info.textgrid.middleware.oaipmh.GranularityType; import info.textgrid.namespaces.middleware.tgcrud.common.TextGridMimetypes; @@ -23,15 +28,18 @@ public class OaiPmhTest { // ** public static OAI_ESClient oaiEsClient; - private static RecordDelivererDC record; private static RecordDelivererIDIOM recordIDIOM; + private static OpenAireRecord openAireRecord; + private static OpenAireRecordList openAireRecordList; + private static OpenAireIdentifierList openAireIdentifierList; private static RecordListDelivererDC recordList; private static RecordListDelivererIDIOM recordListIDIOM; private static IdentifierListDelivererDC identifierList = new IdentifierListDelivererDC(true, false); private static IdentifierListDelivererIDIOM identifierListIDIOM = new IdentifierListDelivererIDIOM(true, false); + private static SetDeliverer setListTextGrid; // ** // CLASS @@ -42,30 +50,38 @@ public class OaiPmhTest { private RepIdentification rep = new RepIdentification("TextGrid-Repository", "www.textgridrep.de", this.bla, "2011-06-11T02:32:40Z", this.bla2, "2.0", "textgrid-support@gwdg.de"); private MetadataFormatListDeliverer metadataFormatList = new MetadataFormatListDeliverer(); - private SetDeliverer setListDARIAH = new SetDeliverer(false, true); - private SetDeliverer setListTextGrid = new SetDeliverer(true, false); - private OAIPMHImpl request = new OAIPMHImpl( - this.rep, OaiPmhTest.record, OaiPmhTest.recordIDIOM, OaiPmhTest.recordList, - OaiPmhTest.recordListIDIOM, this.metadataFormatList, - this.setListDARIAH, OaiPmhTest.identifierList, OaiPmhTest.identifierListIDIOM); + this.rep, OaiPmhTest.record, OaiPmhTest.recordIDIOM, OaiPmhTest.openAireRecord, OaiPmhTest.recordList, + OaiPmhTest.recordListIDIOM, OaiPmhTest.openAireRecordList, this.metadataFormatList, + OaiPmhTest.setListTextGrid, OaiPmhTest.identifierList, OaiPmhTest.identifierListIDIOM, OaiPmhTest.openAireIdentifierList); + OAIPMHUtilities settings = new OAIPMHUtilities(); /** * @throws Exception */ @BeforeClass public static void setUp() throws Exception { - oaiEsClient = new OAI_ESClient("localhost", "9302", "tg-esx2-instance"); + int[] ports = new int[] {9202}; + oaiEsClient = new OAI_ESClient("localhost", ports, 100); OAI_ESClient.setEsIndex("textgrid-public"); OAI_ESClient.setEsType("metadata"); + OAI_ESClient.setPorts(ports); record = new RecordDelivererDC(true, false); record.setOaiEsClient(oaiEsClient); record.setWorkFields(TGConstants.TGWorkFields); recordIDIOM = new RecordDelivererIDIOM(true, false); recordIDIOM.setOaiEsClient(oaiEsClient); - + + /*openAireRecord = new OpenAireRecord(true, false); + openAireRecord.setOaiEsClient(oaiEsClient); + + openAireRecordList = new OpenAireRecordList(true, false); + + openAireIdentifierList = new OpenAireIdentifierList(true, false);*/ + + recordList = new RecordListDelivererDC(true, false); recordList.setFields(TGConstants.TGFields); recordList.setWorkFields(TGConstants.TGWorkFields); @@ -78,8 +94,25 @@ public class OaiPmhTest { identifierList = new IdentifierListDelivererDC(true, false); identifierList.setOaiEsClient(oaiEsClient); identifierList.setIdentifierListFields(TGConstants.IDENTIFIER_LIST_FIELDS); + + setListTextGrid = new SetDeliverer(true, false); } + + @Test + @Ignore + public void testOpenAireIdentifierList() { + + settings.setRangeField(TGConstants.RANGE_FIELD); + settings.setFormatField(TGConstants.FORMAT); + settings.setFormatToFilter(TextGridMimetypes.EDITION); + settings.setSearchResponseSize(100); + + String p = this.request.getRequest("ListIdentifiers", "", "oai_datacite", "", "2013", "2014", ""); + + System.out.println(p); + } + /** * @throws DatatypeConfigurationException */ @@ -158,6 +191,17 @@ public class OaiPmhTest { System.out.println("-----------------------------------\n"); } + /** + * @throws ParseException + */ + @Test + @Ignore + public void testGetDateFormat() throws ParseException { + System.out.println("Test get time format"); + System.out.println(OAIPMHUtilities.getFormatOfDate("2019-12-02T15:36:13Z")); + System.out.println("-----------------------------------\n"); + } + /** * @throws ParseException */ @@ -174,7 +218,7 @@ public class OaiPmhTest { record.setLanguages(TGConstants.LANGUAGE_LIST); record.setPublishers(TGConstants.PUBLISHER_LIST); record.setRelations(TGConstants.RELATIONS_LIST); - record.setRelationsForWork(TGConstants.RELATIONS_FOR_WORK_LIST); + // record.setRelationsForWork(TGConstants.RELATIONS_FOR_WORK_LIST); record.setRights(TGConstants.RIGHTS_LIST); record.setSources(TGConstants.SOURCE_LIST); record.setSubjects(TGConstants.SUBJECT_LIST); @@ -189,7 +233,7 @@ public class OaiPmhTest { record.setIdentifierField("textgridUri"); System.out.println("Test for the verb \"GetRecord\" with succesfull response"); - String p = this.request.getRequest("GetRecord", "textgrid:vqn0.0", "oai_dc", "", "", "", ""); + String p = this.request.getRequest("GetRecord", "textgrid:11hp0.0", "oai_dc", "", "", "", ""); System.out.println(p); System.out.println("-----------------------------------\n"); } @@ -206,6 +250,42 @@ public class OaiPmhTest { System.out.println(p); System.out.println("-----------------------------------\n"); } + + @Test + @Ignore + public void testGetRequestGetRecordOpenAire() throws ParseException, JAXBException, DatatypeConfigurationException, IOException { + System.out.println("Test for OpenAire get record"); + + + + System.out.println("-----------------------------------\n"); + //OAIPMHUtilities.marshal(oar.getResource()); + //System.out.println(OAIPMHImpl.getStringFromJAXBOAIElement("GetRecord", oar.getRecord("24gv8.0"))); + + //OAIPMHUtilities.marshal(oar.getRecord("24gv8.0")); + + String p = this.request.getRequest("GetRecord", "mk7j.0", + TGConstants.METADATA_OPENAIRE_PREFIX, "", "", "", ""); + + System.out.println(p); + } + + + @Test + @Ignore + public void testLIstRecordsOpenAire() throws IOException { + openAireRecordList.setOaiEsClient(oaiEsClient); + openAireRecordList.setRangeField(TGConstants.RANGE_FIELD); + openAireRecordList.setFormatField(TGConstants.FORMAT); + openAireRecordList.setFormatToFilter(TextGridMimetypes.EDITION); + openAireRecordList.setSearchResponseSize(100); + + String p = this.request.getRequest("ListRecords", "", + TGConstants.METADATA_OPENAIRE_PREFIX, "", "", "", ""); + + System.out.println(p); + + } /** * @throws ParseException @@ -232,8 +312,7 @@ public class OaiPmhTest { OaiPmhTest.identifierList.setIdentifierField("textgridUri"); OaiPmhTest.identifierList.setSearchResponseSize("100"); System.out.println("Test for the verb \"ListIdentifiers\" with succesfull response"); - String p = this.request.getRequest("ListIdentifiers", "", "oai_dc", - "project:TGPR-26236625-1acc-b921-a5fa-53567c3eeb80", "", "", ""); + String p = this.request.getRequest("ListIdentifiers", "", "oai_dc", "", "2000-02-05", "", "junk"); System.out.println(p); System.out.println("-----------------------------------\n"); } @@ -281,6 +360,17 @@ public class OaiPmhTest { System.out.println("-----------------------------------\n"); } + @Test + @Ignore + public void testMissingVerbArgument() throws ParseException { + System.out + .println("Test for request with missing verb argument"); + String p = this.request.getRequest("", "", "", "", "", "", ""); + System.out.println(p); + System.out.println("-----------------------------------\n"); + } + + /** * @throws ParseException */ @@ -335,17 +425,21 @@ public class OaiPmhTest { OaiPmhTest.recordList.setIdentifierField("textgridUri"); System.out.println("Test for the verb \"ListRecords\" with sets with succesfull response"); + //String p = this.request.getRequest("ListRecords", "", "oai_dc", "project:TGPR-f89ad029-4eb2-ae5c-6028-5db876513128", "", "", ""); String p = this.request.getRequest("ListRecords", "", "oai_dc", "", "", "", ""); + System.out.println(p); - String resToken = ""; + /*String resToken = ""; for (Map.Entry<String, Integer> entry : RecordListDelivererDC.cursorCollector.entrySet()) { resToken = entry.getKey(); - } - String p2 = this.request.getRequest("ListRecords", "", "", "", "", "", resToken); - System.out.println(p2); - System.out.println("HASH MAP AFTER: "); - System.out.println(RecordListDelivererDC.cursorCollector); - System.out.println("-----------------------------------\n"); + String p2 = this.request.getRequest("ListRecords", "", "", "", "", "", resToken); + System.out.println(p2); + System.out.println("HASH MAP AFTER: "); + System.out.println(RecordListDelivererDC.cursorCollector); + System.out.println("-----------------------------------\n"); + }*/ + + } /** @@ -388,6 +482,7 @@ public class OaiPmhTest { @Test @Ignore public void testListRecords2() throws ParseException { + System.out.println("HU"); OaiPmhTest.recordList.setContributor(TGConstants.CONTRIBUTOR_LIST); OaiPmhTest.recordList.setCoverage(TGConstants.COVERAGE_LIST); OaiPmhTest.recordList.setCreators(TGConstants.CREATOR_LIST); @@ -413,7 +508,6 @@ public class OaiPmhTest { OaiPmhTest.recordList.setModifiedField(TGConstants.CREATED); OaiPmhTest.recordList.setIdentifierField(TGConstants.URI); OaiPmhTest.recordList.setSearchResponseSize("100"); - String r = this.request.getRequest("ListRecords", "", "oai_dc", "", "", "", ""); System.out.println(r); System.out.println("-----------------------------------\n"); @@ -425,7 +519,7 @@ public class OaiPmhTest { @Test @Ignore public void testListMetadataFormatsForIdentifier() throws ParseException { - String r = this.request.getRequest("ListMetadataFormats", "7t.0", "", "", "", "", ""); + String r = this.request.getRequest("ListMetadataFormats", "textgrid:125x1.0", "", "", "", "", ""); System.out.println(r); System.out.println("-----------------------------------\n"); } @@ -446,12 +540,26 @@ public class OaiPmhTest { */ @Test @Ignore - public void testListSets() throws ParseException { - this.setListTextGrid.setFormatField("format"); - this.setListTextGrid.setFormatToFilter(TextGridMimetypes.DARIAH_COLLECTION); - this.setListTextGrid.setIdentifierField("textgridUri"); - this.setListTextGrid.setRepositoryObjectURIPrefix("textgrid:"); + public void testListSetsTG() throws ParseException { + OaiPmhTest.setListTextGrid.setFormatField("format"); + OaiPmhTest.setListTextGrid.setFormatToFilter(TextGridMimetypes.EDITION); + OaiPmhTest.setListTextGrid.setIdentifierField("textgridUri"); + OaiPmhTest.setListTextGrid.setRepositoryObjectURIPrefix("textgrid:"); + String r = this.request.getRequest("ListSets", "", "", "", "", "", ""); + System.out.println(r); + System.out.println("-----------------------------------\n"); + } + /** + * @throws ParseException + */ + @Test + @Ignore + public void testListSetsDH() throws ParseException { + OaiPmhTest.setListTextGrid.setFormatField("format"); + OaiPmhTest.setListTextGrid.setFormatToFilter(TextGridMimetypes.DARIAH_COLLECTION); + OaiPmhTest.setListTextGrid.setIdentifierField("textgridUri"); + OaiPmhTest.setListTextGrid.setRepositoryObjectURIPrefix("textgrid:"); String r = this.request.getRequest("ListSets", "", "", "", "", "", ""); System.out.println(r); System.out.println("-----------------------------------\n"); @@ -469,10 +577,9 @@ public class OaiPmhTest { OaiPmhTest.identifierList.setIdentifierField("textgridUri"); OaiPmhTest.identifierList.setRepositoryObjectURIPrefix("textgrid:"); OaiPmhTest.identifierList.setSearchResponseSize("100"); - String r = this.request.getRequest("", "", "", "", "", "", ""); System.out.println(r); System.out.println("-----------------------------------\n"); } -} +} \ No newline at end of file diff --git a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTextgridOnlineTests.java b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTextgridOnlineTests.java index 952f88aa57dcd74b626760fc72cc7efa981d340f..89829243f5ce567f765e61b29c32c7fb02f38293 100644 --- a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTextgridOnlineTests.java +++ b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTextgridOnlineTests.java @@ -14,6 +14,7 @@ import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Test; import info.textgrid.utils.httpclient.TGHttpClient; import info.textgrid.utils.httpclient.TGHttpResponse; @@ -25,6 +26,7 @@ import info.textgrid.utils.httpclient.TGHttpResponse; * * @author Stefan E. Funk, SUB Göttingen */ +@Ignore public class OaiPmhTextgridOnlineTests { private static final String OAI_DC_PREFIX = "oai_dc"; @@ -951,7 +953,6 @@ public class OaiPmhTextgridOnlineTests { return true; } - } } diff --git a/oaipmh-webapp/pom.xml b/oaipmh-webapp/pom.xml index 2a81386343d3a2e4f42e1c033f7801c931413cb9..c15547c175e121261f968704a14a5cd1c6f44173 100644 --- a/oaipmh-webapp/pom.xml +++ b/oaipmh-webapp/pom.xml @@ -5,13 +5,13 @@ <parent> <artifactId>oaipmh</artifactId> <groupId>info.textgrid.middleware</groupId> - <version>3.3.2.1-ES6-SNAPSHOT</version> + <version>3.3.2.1-ES6-SNAPSHOT</version> </parent> <groupId>info.textgrid.middleware</groupId> <artifactId>oaipmh-webapp</artifactId> <packaging>war</packaging> <name>DARIAHDE :: OAI-PMH DataProvider :: Webapp</name> - <url>http://maven.apache.org</url> + <url>https://projects.gwdg.de/projects/oai-pmh</url> <profiles> <profile> <id>dhrep.deb</id> @@ -77,12 +77,11 @@ <artifactId>oaipmh-core</artifactId> <version>${project.version}</version> </dependency> - </dependencies> <build> <finalName>oaipmh</finalName> <plugins> - <!-- Do not deploy WAR and DEB files to the Nexus repository --> + <!-- Do not deploy WAR and DEB files to the Nexus repository --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> diff --git a/oaipmh-webapp/src/main/webapp/WEB-INF/beans.xml b/oaipmh-webapp/src/main/webapp/WEB-INF/beans.xml index 58fc35dfa03945d96eab35d472ab0039abf56b42..1147de30742b2a6c99b40ebb922d88762640d838 100644 --- a/oaipmh-webapp/src/main/webapp/WEB-INF/beans.xml +++ b/oaipmh-webapp/src/main/webapp/WEB-INF/beans.xml @@ -14,12 +14,14 @@ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd"> - <description>Configuration for the TextGrid/DARIAH-DE OAI-PMH Interface</description> + <description>Configuration for the TextGrid/DARIAH-DE OAI-PMH Interface + </description> <import resource="classpath:META-INF/cxf/cxf.xml" /> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> - <bean id="propertyPlaceholderConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> + <bean id="propertyPlaceholderConfigurer" + class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>file:/etc/dhrep/oaipmh/oaipmh.properties</value> @@ -29,36 +31,47 @@ <property name="ignoreUnresolvablePlaceholders" value="true" /> </bean> - <bean id="ElasticSearchClient" class="info.textgrid.middleware.OAI_ESClient"> - <constructor-arg index="0" value="${elasticSearch.url}" /> - <constructor-arg index="1" value="${elasticSearch.port}" /> - <constructor-arg index="2" value="${elasticSearch.clusterName}" /> + <bean id="ElasticSearchClient" + class="info.textgrid.middleware.OAI_ESClient"> + <constructor-arg index="0" + value="${elasticSearch.url}" /> + <constructor-arg index="1" + value="${elasticSearch.ports}" /> + <constructor-arg index="2" + value="${elasticSearch.itemLimit}" /> <property name="esIndex" value="${elasticSearch.index}" /> <property name="esType" value="${elasticSearch.type}" /> </bean> <!--bean id="drc" class="info.textgrid.middleware.oaipmh.${DeletedRecordInfo}" --> - <bean id="RepIdentification" class="info.textgrid.middleware.RepIdentification"> + <bean id="RepIdentification" + class="info.textgrid.middleware.RepIdentification"> <constructor-arg index="0" value="${RepositoryName}" /> <constructor-arg index="1" value="${BaseUrl}" /> - <constructor-arg index="2" value="${DeletedRecordInfo}" /> - <constructor-arg index="3" value="${EarliestDateStamp}" /> + <constructor-arg index="2" + value="${DeletedRecordInfo}" /> + <constructor-arg index="3" + value="${EarliestDateStamp}" /> <constructor-arg index="4" value="${Granularity}" /> <constructor-arg index="5" value="${ProtocolVersion}" /> <constructor-arg index="6" value="${AdminMail}" /> </bean> - <bean id="RecordListDC" class="info.textgrid.middleware.RecordListDelivererDC"> + <bean id="RecordListDC" + class="info.textgrid.middleware.RecordListDelivererDC"> <constructor-arg index="0" value="${textgrid}" /> <constructor-arg index="1" value="${dariah}" /> <property name="fields" value="${fields}" /> <property name="workFields" value="${workFields}" /> <property name="formatField" value="${formatField}" /> <property name="formatToFilter" value="${formatToFilter}" /> - <property name="dateOfObjectCreation" value="${dateOfObjectCreation}" /> - <property name="relationToFurtherMetadataObject" value="${relationToFurtherMetadataObject}" /> - <property name="repositoryObjectURIPrefix" value="${repositoryObjectURIPrefix}" /> + <property name="dateOfObjectCreation" + value="${dateOfObjectCreation}" /> + <property name="relationToFurtherMetadataObject" + value="${relationToFurtherMetadataObject}" /> + <property name="repositoryObjectURIPrefix" + value="${repositoryObjectURIPrefix}" /> <property name="FieldForRange" value="${rangeField}" /> <property name="contributor" value="${contributorList}" /> <property name="coverage" value="${coverageList}" /> @@ -70,7 +83,8 @@ <property name="languages" value="${languageList}" /> <property name="publishers" value="${publisherList}" /> <property name="relations" value="${relationList}" /> - <property name="relationsForWork" value="${relationsForWorkList}" /> + <property name="relationsForWork" + value="${relationsForWorkList}" /> <property name="rights" value="${rightsList}" /> <property name="sources" value="${sourceList}" /> <property name="subjects" value="${subjectList}" /> @@ -78,22 +92,87 @@ <property name="types" value="${typeList}" /> <property name="modifiedField" value="${modifiedField}" /> <property name="identifierField" value="${identifierField}" /> - <property name="searchResponseSize" value="${searchResponseSize}" /> + <property name="searchResponseSize" + value="${searchResponseSize}" /> </bean> - <bean id="RecordListIDIOM" class="info.textgrid.middleware.RecordListDelivererIDIOM"> + <bean id="RecordListIDIOM" + class="info.textgrid.middleware.RecordListDelivererIDIOM"> + <constructor-arg index="0" value="${textgrid}" /> + <constructor-arg index="1" value="${dariah}" /> + </bean> + + <bean id="OpenAireRecord" + class="info.textgrid.middleware.OpenAireRecord"> + <constructor-arg index="0" value="${textgrid}" /> + <constructor-arg index="1" value="${dariah}" /> + <property name="titleFields" value="${oar.titleFields}" /> + <property name="dateFields" value="${oar.dateFields}" /> + <property name="contributorFields" value="${oar.contributorFields}" /> + <property name="languageFields" value="${oar.languageFields}" /> + <property name="alternateIdentifierFields" value="${oar.alternateIdentifierFields}" /> + <property name="formatFields" value="${oar.formatFields}" /> + <property name="rightsFields" value="${oar.rightsFields}" /> + <property name="descriptionFields" value="${oar.descriptionFields}" /> + <property name="relatedIdentifierFields" value="${oar.relatedIdentifierFields}" /> + <property name="workFields" value="${workFields}" /> + <property name="relationToWorkObject" value="${oar.relationToWorkObject}" /> + <property name="identifierField" value="${identifierField}" /> + <property name="geoLocationFields" value="${oar.geoLocationFields}"/> + <property name="handle" value="${oar.handle}"/> + <property name="versionFields" value="${oar.versionFields}"/> + <property name="subjectFields" value="${oar.subjectFields}"/> + <property name="sizeField" value="${oar.sizeField}"/> + </bean> + + <bean id="AbstractRecordList" abstract="true" + class="info.textgrid.middleware.RecordListDelivererAbstract"> + <constructor-arg index="0" value="${textgrid}" /> + <constructor-arg index="1" value="${dariah}" /> + <property name="rangeField" value="${rangeField}" /> + <property name="formatField" value="${oar.formatFields}" /> + <property name="formatToFilter" value="${formatToFilter}" /> + <property name="searchResponseSize" value="${searchResponseSize}" /> + </bean> + + + + + <bean id="OpenAireRecordList" + class="info.textgrid.middleware.OpenAireRecordList"> + <constructor-arg index="0" value="${textgrid}" /> + <constructor-arg index="1" value="${dariah}" /> + </bean> + + <bean id="AbstractIdentifierList" abstract="true" + class="info.textgrid.middleware.IdentifierListDelivererAbstract"> + <constructor-arg index="0" value="${textgrid}" /> + <constructor-arg index="1" value="${dariah}" /> + <property name="rangeField" value="${rangeField}" /> + <property name="formatField" value="${oar.formatFields}" /> + <property name="formatToFilter" value="${formatToFilter}" /> + <property name="searchResponseSize" value="${searchResponseSize}" /> + </bean> + + + <bean id="OpenAireIdentifierList" + class="info.textgrid.middleware.OpenAireIdentifierList"> <constructor-arg index="0" value="${textgrid}" /> <constructor-arg index="1" value="${dariah}" /> </bean> - <bean scope="prototype" id="RecordDC" class="info.textgrid.middleware.RecordDelivererDC"> + <bean scope="prototype" id="RecordDC" + class="info.textgrid.middleware.RecordDelivererDC"> <constructor-arg index="0" value="${textgrid}" /> <constructor-arg index="1" value="${dariah}" /> <property name="formatField" value="${formatField}" /> <property name="formatToFilter" value="${formatToFilter}" /> - <property name="dateOfObjectCreation" value="${dateOfObjectCreation}" /> - <property name="relationToFurtherMetadataObject" value="${relationToFurtherMetadataObject}" /> - <property name="repositoryObjectURIPrefix" value="${repositoryObjectURIPrefix}" /> + <property name="dateOfObjectCreation" + value="${dateOfObjectCreation}" /> + <property name="relationToFurtherMetadataObject" + value="${relationToFurtherMetadataObject}" /> + <property name="repositoryObjectURIPrefix" + value="${repositoryObjectURIPrefix}" /> <property name="identifierField" value="${identifierField}" /> <property name="fields" value="${fields}" /> <property name="workFields" value="${workFields}" /> @@ -107,54 +186,65 @@ <property name="languages" value="${languageList}" /> <property name="publishers" value="${publisherList}" /> <property name="relations" value="${relationList}" /> - <property name="relationsForWork" value="${relationsForWorkList}" /> + <!-- property name="relationsForWork" value="${relationsForWorkList}" / --> <property name="rights" value="${rightsList}" /> <property name="sources" value="${sourceList}" /> <property name="subjects" value="${subjectList}" /> <property name="titles" value="${titleList}" /> <property name="types" value="${typeList}" /> </bean> - - <bean id="RecordIDIOM" class="info.textgrid.middleware.RecordDelivererIDIOM"> + + <bean id="RecordIDIOM" + class="info.textgrid.middleware.RecordDelivererIDIOM"> <constructor-arg index="0" value="${textgrid}" /> <constructor-arg index="1" value="${dariah}" /> </bean> - <bean id="ListIdentifierDC" class="info.textgrid.middleware.IdentifierListDelivererDC"> + <bean id="ListIdentifierDC" + class="info.textgrid.middleware.IdentifierListDelivererDC"> <constructor-arg index="0" value="${textgrid}" /> <constructor-arg index="1" value="${dariah}" /> - <property name="dateOfObjectCreation" value="${dateOfObjectCreation}" /> - <property name="repositoryObjectURIPrefix" value="${repositoryObjectURIPrefix}" /> - <property name="identifierListFields" value="${identifierListFields}"></property> + <property name="dateOfObjectCreation" + value="${dateOfObjectCreation}" /> + <property name="repositoryObjectURIPrefix" + value="${repositoryObjectURIPrefix}" /> + <property name="identifierListFields" + value="${identifierListFields}"></property> <property name="FieldForRange" value="${rangeField}" /> <property name="identifierField" value="${identifierField}" /> - <property name="searchResponseSize" value="${searchResponseSize}" /> + <property name="searchResponseSize" + value="${searchResponseSize}" /> </bean> - - <bean id="ListIdentifierIDIOM" class="info.textgrid.middleware.IdentifierListDelivererIDIOM"> + + <bean id="ListIdentifierIDIOM" + class="info.textgrid.middleware.IdentifierListDelivererIDIOM"> <constructor-arg index="0" value="${textgrid}" /> <constructor-arg index="1" value="${dariah}" /> </bean> - <bean id="SetDeliverer" class="info.textgrid.middleware.SetDeliverer"> + <bean id="SetDeliverer" + class="info.textgrid.middleware.SetDeliverer"> <constructor-arg index="0" value="${textgrid}" /> <constructor-arg index="1" value="${dariah}" /> <property name="formatField" value="${formatField}" /> <property name="formatToFilter" value="${formatToFilter}" /> <property name="identifierField" value="${identifierField}" /> - <property name="repositoryObjectURIPrefix" value="${repositoryObjectURIPrefix}" /> + <property name="repositoryObjectURIPrefix" + value="${repositoryObjectURIPrefix}" /> <property name="specField" value="${specField}" /> <property name="specFieldPrefix" value="${specFieldPrefix}" /> </bean> - <bean id="MetadataFormatList" class="info.textgrid.middleware.MetadataFormatListDeliverer"> + <bean id="MetadataFormatList" + class="info.textgrid.middleware.MetadataFormatListDeliverer"> </bean> <!-- REST Interface --> <bean id="rest" class="info.textgrid.middleware.Rest" /> - <bean id="cors-filter" class="org.apache.cxf.rs.security.cors.CrossOriginResourceSharingFilter"> + <bean id="cors-filter" + class="org.apache.cxf.rs.security.cors.CrossOriginResourceSharingFilter"> <property name="allowOrigins"> <util:list /> </property> @@ -164,17 +254,21 @@ <constructor-arg ref="RepIdentification" /> <constructor-arg ref="RecordDC" /> <constructor-arg ref="RecordIDIOM" /> + <constructor-arg ref="OpenAireRecord" /> <constructor-arg ref="RecordListDC" /> <constructor-arg ref="RecordListIDIOM" /> + <constructor-arg ref="OpenAireRecordList" /> <constructor-arg ref="MetadataFormatList" /> <constructor-arg ref="SetDeliverer" /> <constructor-arg ref="ListIdentifierDC" /> <constructor-arg ref="ListIdentifierIDIOM" /> + <constructor-arg ref="OpenAireIdentifierList" /> <property name="textGrid" value="${textgrid}" /> <property name="dariah" value="${dariah}" /> </bean> - <jaxrs:server id="root" address="/root" publishedEndpointUrl="${RS_ENDPOINT}"> + <jaxrs:server id="root" address="/root" + publishedEndpointUrl="${RS_ENDPOINT}"> <jaxrs:serviceBeans> <ref bean="rest" /> </jaxrs:serviceBeans> @@ -183,7 +277,8 @@ </jaxrs:providers> </jaxrs:server> - <jaxrs:server id="queryEndpoint" address="/oai" publishedEndpointUrl="${RS_ENDPOINT}"> + <jaxrs:server id="queryEndpoint" address="/oai" + publishedEndpointUrl="${RS_ENDPOINT}"> <jaxrs:serviceBeans> <ref bean="oai" /> </jaxrs:serviceBeans> diff --git a/oaipmh-webapp/src/main/webapp/WEB-INF/oaipmh.dariah.properties b/oaipmh-webapp/src/main/webapp/WEB-INF/oaipmh.dariah.properties index d0c1e94744e1d9da66c675ce6193752b66b81516..d361cc2610e5a880d6efff60d232b343fe7d93d6 100644 --- a/oaipmh-webapp/src/main/webapp/WEB-INF/oaipmh.dariah.properties +++ b/oaipmh-webapp/src/main/webapp/WEB-INF/oaipmh.dariah.properties @@ -2,7 +2,7 @@ ## ElasticSearch Endpoint ## ############################## -RS_ENDPOINT = http://trep.de.dariah.eu/oaipmh +RS_ENDPOINT = https://repository.de.dariah.eu/1.0/oaipmh ############################ ## ElasticSearch Config ## @@ -26,12 +26,12 @@ dariah = true ############################# RepositoryName = DARIAH-DE Repository -BaseUrl = http://trep.de.dariah.eu +BaseUrl = https://repository.de.dariah.eu/1.0/oaipmh/oai DeletedRecordInfo = NO EarliestDateStamp = 2011-06-11T02:32:40Z Granularity = YYYY_MM_DD_THH_MM_SS_Z ProtocolVersion = 2.0 -AdminMail = funk@sub.uni-goettingen.de +AdminMail = support@de.dariah.eu ###################### ## Field Settings ## diff --git a/oaipmh-webapp/src/main/webapp/WEB-INF/oaipmh.textgrid.properties b/oaipmh-webapp/src/main/webapp/WEB-INF/oaipmh.textgrid.properties index 0e733f528141eb0b7b09fef86df5b2e5143f1cf5..2c11a65a298030ca7cb7a33f0d6b36217ef23a13 100644 --- a/oaipmh-webapp/src/main/webapp/WEB-INF/oaipmh.textgrid.properties +++ b/oaipmh-webapp/src/main/webapp/WEB-INF/oaipmh.textgrid.properties @@ -9,10 +9,15 @@ RS_ENDPOINT = https://textgridlab.org/1.0/tgoaipmh ############################ elasticSearch.url = 127.0.0.1 +<<<<<<< HEAD elasticSearch.port = 9302 elasticSearch.clusterName = tg-esx2-instance +======= +elasticSearch.ports = 9202 9203 +>>>>>>> feature/elastic6 elasticSearch.index = textgrid-public elasticSearch.type = metadata +elasticSearch.itemLimit = 100 ######################## ## Project Choosing ## @@ -37,8 +42,26 @@ AdminMail = support@de.dariah.eu ## Field Settings ## ###################### -fields = created, format, identifier, dataContributor, textgridUri, project.id, relations.isDerivedFrom, title, pid.value, edition.isEditionOf, edition.agent.value, edition.license.licenseUri, edition.language, edition.source.bibliographicCitation.author.value, edition.source.bibliographicCitation.editor.value, edition.source.bibliographicCitation.editionTitle, edition.source.bibliographicCitation.placeOfPublication.value, edition.source.bibliographicCitation.publisher.value, edition.source.bibliographicCitation.editionNo, edition.source.bibliographicCitation.series, edition.source.bibliographicCitation.volume, edition.source.bibliographicCitation.issue, edition.source.bibliographicCitation.epage, edition.source.bibliographicCitation.spage, edition.source.bibliographicCitation.bibidentifier, work.abstract, work.genre, work.type, work.spatial.value, work.temporal.value, work.agent.value, work.subject.id.value, lastModified -workFields = created, work.abstract, relations.isDerivedFrom, textgridUri, work.genre, title, work.type, work.spatial.value, work.temporal.spatial, work.agent.value, work.subject.id.value +fields = revision,edition.source.bibliographicCitation,edition.license,created,issued,format,identifier,dataContributor,textgridUri,project,project.id,relations.isDerivedFrom,title,pid.value,edition.isEditionOf,edition.agent.value,edition.license.licenseUri,edition.language,edition.source.bibliographicCitation.author.value,edition.source.bibliographicCitation.editor.value,edition.source.bibliographicCitation.editionTitle,edition.source.bibliographicCitation.placeOfPublication.value,edition.source.bibliographicCitation.publisher.value,edition.source.bibliographicCitation.editionNo,edition.source.bibliographicCitation.series,edition.source.bibliographicCitation.volume,edition.source.bibliographicCitation.issue,edition.source.bibliographicCitation.epage,edition.source.bibliographicCitation.spage,edition.source.bibliographicCitation.bibidentifier,work.abstract,work.genre,work.type,work.spatial.value,work.temporal.value,work.agent.value,work.subject.id.value,lastModified +workFields = created,work.abstract,relations.isDerivedFrom,textgridUri,work.genre,title,work.type,work.spatial.value,work.temporal.spatial,work.agent.value,work.subject.id.value + + +###################### +## OpenAireRecords ### +###################### + +oar.titleFields = title,edition.source.bibliographicCitation.editionTitle +oar.dateFields = created,issued,lastModified +oar.contributorFields = dataContributor, project +oar.languageFields = edition.language +oar.alternateIdentifierFields = textgridUri +oar.formatFields = format +oar.rightsFields = edition.license +oar.descriptionFields = work.abstract +oar.relatedIdentifierFields = edition.isEditionOf +oar.relationToWorkObject = edition.isEditionOf +oar.geoLocationFields = edition.source.bibliographicCitation.placeOfPublication +oar.handle = pid.value ###################### ## OpenAireRecords ### @@ -62,28 +85,28 @@ oar.relationToWorkObject = edition.isEditionOf ########################## contributorList = dataContributor -coverageList = work.spatial.value, work.temporal.value +coverageList = work.spatial.value,work.temporal.value creatorList = work.agent.value dateList = created descriptionList = work.abstract formatList = format -identifierList = textgridUri, pid.value, identifier +identifierList = textgridUri,pid.value,identifier languageList = edition.language publisherList = edition.source.bibliographicCitation.publisher.value -relationList = project.id, relations.isDerivedFrom -relationsForWorkList = relations.isDerivedFrom, title, textgridUri +relationList = project.id,relations.isDerivedFrom +relationsForWorkList = relations.isDerivedFrom,title,textgridUri rightsList = edition.license.licenseUri -sourceList = edition.source.bibliographicCitation.author.value, edition.source.bibliographicCitation.editor.value, edition.source.bibliographicCitation.editionTitle, edition.source.bibliographicCitation.placeOfPublication.value, edition.source.bibliographicCitation.publisher.value, edition.source.bibliographicCitation.editionNo, edition.source.bibliographicCitation.series, edition.source.bibliographicCitation.volume, edition.source.bibliographicCitation.issue, edition.source.bibliographicCitation.epage, edition.source.bibliographicCitation.spage +sourceList = edition.source.bibliographicCitation.author.value,edition.source.bibliographicCitation.editor.value,edition.source.bibliographicCitation.editionTitle,edition.source.bibliographicCitation.placeOfPublication.value,edition.source.bibliographicCitation.publisher.value,edition.source.bibliographicCitation.editionNo,edition.source.bibliographicCitation.series,edition.source.bibliographicCitation.volume,edition.source.bibliographicCitation.issue,edition.source.bibliographicCitation.epage,edition.source.bibliographicCitation.spage subjectList = work.subject.id.value titleList = title -typeList = work.genre, work.type +typeList = work.genre,work.type ############################# ## ListIdentifierSetting ## ############################# rangeField = created -identifierListFields = textgridUri, created, format +identifierListFields = textgridUri,created,format formatField = format formatToFilter = text/tg.edition+tg.aggregation+xml dateOfObjectCreation = created diff --git a/pom.xml b/pom.xml index 1e97608a4d189851e82e1c12ec5e15e21b5a57c7..87e89fae9ea753846ac66d1df6f68e6f6ba20e27 100644 --- a/pom.xml +++ b/pom.xml @@ -8,12 +8,11 @@ <packaging>pom</packaging> <name>DARIAHDE :: OAI-PMH DataProvider</name> <properties> - <tgcrud.version>10.2.0-SNAPSHOT</tgcrud.version> - <tghttpclients.version>3.3.1</tghttpclients.version> + <common.version>3.7.0-ES6-SNAPSHOT</common.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <cxf.version>3.2.8</cxf.version> <spring.version>4.0.2.RELEASE</spring.version> - <elasticsearch.version>1.7.5</elasticsearch.version> + <elasticsearch.version>6.5.4</elasticsearch.version> <antlr-runtime.version>3.2</antlr-runtime.version> <antlr-maven-plugin.version>3.2</antlr-maven-plugin.version> <slf4j.version>1.7.5</slf4j.version> @@ -28,15 +27,14 @@ <properties-maven-plugin.version>1.0-alpha-2</properties-maven-plugin.version> </properties> <url>https://projects.gwdg.de/projects/oai-pmh</url> - <scm> <connection>scm:git@git.projects.gwdg.de:oai-pmh.git</connection> <developerConnection>scm:git@git.projects.gwdg.de:oai-pmh.git</developerConnection> <url>https://projects.gwdg.de/projects/oai-pmh</url> </scm> <issueManagement> - <system>chili</system> - <url>https://projects.gwdg.de/projects/tg/issues</url> + <system>GWDG Project Management Service</system> + <url>https://projects.gwdg.de/projects/tg/work_packages</url> </issueManagement> <licenses> <license> @@ -47,7 +45,7 @@ </licenses> <organization> <name>SUB Göttingen</name> - <url>http://www.sub.uni-goettingen.de</url> + <url>https://sub.uni-goettingen.de</url> </organization> <build> <defaultGoal>package</defaultGoal>