Search in sources :

Example 21 with RecordType

use of net.opengis.cat.csw._3.RecordType in project openaire-cris-validator by EuroCRIS.

the class FileLoggingConnectionStreamFactory method wrapCheckOAIIdentifier.

private CheckingIterable<RecordType> wrapCheckOAIIdentifier(final CheckingIterable<RecordType> checker) {
    final Optional<String> repoIdentifier = endpoint.getRepositoryIdentifer();
    if (repoIdentifier.isPresent()) {
        final Function<RecordType, Set<String>> expectedFunction = new Function<RecordType, Set<String>>() {

            @Override
            public Set<String> apply(final RecordType x) {
                final MetadataType metadata = x.getMetadata();
                final Set<String> results = new HashSet<>();
                if (metadata != null) {
                    final Element el = (Element) metadata.getAny();
                    final String id = el.getAttribute("id");
                    results.add("oai:" + repoIdentifier.get() + ":" + el.getLocalName() + "s/" + id);
                    results.add("oai:" + repoIdentifier.get() + ":" + id);
                } else {
                    // make the test trivially satisfied for records with no metadata
                    results.add(x.getHeader().getIdentifier());
                }
                return results;
            }
        };
        return checker.checkForAllValueInSet(expectedFunction, ((final RecordType record) -> record.getHeader().getIdentifier()), "OAI identifier other than expected");
    } else {
        return checker;
    }
}
Also used : Function(java.util.function.Function) Set(java.util.Set) HashSet(java.util.HashSet) RecordType(org.openarchives.oai._2.RecordType) JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) MetadataType(org.openarchives.oai._2.MetadataType) HashSet(java.util.HashSet)

Aggregations

ArrayList (java.util.ArrayList)8 AbstractRecordType (org.geotoolkit.csw.xml.v202.AbstractRecordType)7 BriefRecordType (org.geotoolkit.csw.xml.v202.BriefRecordType)7 RecordType (org.geotoolkit.csw.xml.v202.RecordType)7 SummaryRecordType (org.geotoolkit.csw.xml.v202.SummaryRecordType)7 SimpleLiteral (org.geotoolkit.dublincore.xml.v2.elements.SimpleLiteral)7 BoundingBoxType (org.geotoolkit.ows.xml.v100.BoundingBoxType)7 WGS84BoundingBoxType (org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType)7 Test (org.junit.Test)7 List (java.util.List)6 RecordType (org.openarchives.oai._2.RecordType)6 OAIPMH (org.openarchives.oai._2.OAIPMH)5 ResumptionTokenType (org.openarchives.oai._2.ResumptionTokenType)5 StringWriter (java.io.StringWriter)4 Marshaller (javax.xml.bind.Marshaller)4 Property (org.osate.aadl2.Property)4 RecordType (org.osate.aadl2.RecordType)4 JAXBElement (javax.xml.bind.JAXBElement)3 BasicProperty (org.osate.aadl2.BasicProperty)3 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)3