use of net.opengis.cat.csw._3.RecordType in project osate2 by osate.
the class AadlBaNameResolver method getBasicPropertyResolver.
private BasicProperty getBasicPropertyResolver(BehaviorVariable bv, Property p, String basicPropertyName) {
QualifiedNamedElement qne = (QualifiedNamedElement) p;
Property propNE = resolveProperty(qne);
PropertyType pt = propNE.getPropertyType();
if (pt instanceof RecordType) {
RecordType rt = (RecordType) pt;
for (BasicProperty bp : rt.getOwnedFields()) {
if (bp.getName().equalsIgnoreCase(basicPropertyName)) {
return bp;
}
}
}
return null;
}
use of net.opengis.cat.csw._3.RecordType in project ddf by codice.
the class TestCswSourceBase method generateCswCollection.
protected CswRecordCollection generateCswCollection(String file) {
InputStream stream = getClass().getResourceAsStream(file);
GetRecordsResponseType recordsResponse = parseXml(stream);
GetRecordsResponseType records = new GetRecordsResponseType();
recordsResponse.copyTo(records);
List<Metacard> cswRecords = new LinkedList<>();
for (JAXBElement<? extends AbstractRecordType> rec : records.getSearchResults().getAbstractRecord()) {
MetacardImpl metacard = new MetacardImpl();
cswRecords.add(metacard);
if (rec.getValue() instanceof BriefRecordType) {
BriefRecordType record = (BriefRecordType) rec.getValue();
metacard.setId(record.getIdentifier().get(0).getValue().getContent().get(0));
if (!CollectionUtils.isEmpty(record.getType().getContent())) {
metacard.setContentTypeName(record.getType().getContent().get(0));
}
} else if (rec.getValue() instanceof SummaryRecordType) {
SummaryRecordType record = (SummaryRecordType) rec.getValue();
metacard.setId(record.getIdentifier().get(0).getValue().getContent().get(0));
if (!CollectionUtils.isEmpty(record.getType().getContent())) {
metacard.setContentTypeName(record.getType().getContent().get(0));
}
} else if (rec.getValue() instanceof RecordType) {
RecordType record = (RecordType) rec.getValue();
for (JAXBElement<SimpleLiteral> jb : record.getDCElement()) {
if ("identifier".equals(jb.getName().getLocalPart())) {
metacard.setId(jb.getValue().getContent().get(0));
}
if ("type".equals(jb.getName().getLocalPart()) && !CollectionUtils.isEmpty(jb.getValue().getContent())) {
metacard.setContentTypeName(jb.getValue().getContent().get(0));
}
}
}
}
CswRecordCollection collection = new CswRecordCollection();
collection.setCswRecords(cswRecords);
collection.setNumberOfRecordsMatched(records.getSearchResults().getNumberOfRecordsMatched().intValue());
collection.setNumberOfRecordsReturned(records.getSearchResults().getNumberOfRecordsReturned().intValue());
return collection;
}
use of net.opengis.cat.csw._3.RecordType in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method verifyHeaderDateStamp.
private void verifyHeaderDateStamp(OAIPMH oaipmh, VerbType verbType, String timeGranularity) {
String verb = verbType.value();
if (verb.equals(LIST_RECORDS.value())) {
oaipmh.getListRecords().getRecords().stream().map(RecordType::getHeader).map(HeaderType::getDatestamp).forEach(headerDateStamp -> verifyHeaderDateStamp(headerDateStamp, timeGranularity));
} else if (verb.equals(LIST_IDENTIFIERS.value())) {
oaipmh.getListIdentifiers().getHeaders().stream().map(HeaderType::getDatestamp).forEach(headerDateStamp -> verifyHeaderDateStamp(headerDateStamp, timeGranularity));
} else if (verb.equals(GET_RECORD.value())) {
String datestamp = oaipmh.getGetRecord().getRecord().getHeader().getDatestamp();
verifyHeaderDateStamp(datestamp, timeGranularity);
}
}
use of net.opengis.cat.csw._3.RecordType in project mod-oai-pmh by folio-org.
the class MarcWithHoldingsRequestHelper method buildRecordsResponse.
private Future<Response> buildRecordsResponse(Request request, String requestId, List<JsonObject> batch, Map<String, JsonObject> srsResponse, boolean firstBatch, String nextInstanceId, boolean deletedRecordSupport) {
Promise<Response> promise = Promise.promise();
try {
List<RecordType> records = buildRecordsList(request, batch, srsResponse, deletedRecordSupport);
logger.debug("Build records response, instances = {}, instances with srs records = {}.", batch.size(), records.size());
ResponseHelper responseHelper = getResponseHelper();
OAIPMH oaipmh = responseHelper.buildBaseOaipmhResponse(request);
if (records.isEmpty() && nextInstanceId == null && firstBatch) {
oaipmh.withErrors(createNoRecordsFoundError());
} else {
oaipmh.withListRecords(new ListRecordsType().withRecords(records));
}
Response response;
if (oaipmh.getErrors().isEmpty()) {
if (!firstBatch || nextInstanceId != null) {
ResumptionTokenType resumptionToken = buildResumptionTokenFromRequest(request, requestId, records.size(), nextInstanceId);
oaipmh.getListRecords().withResumptionToken(resumptionToken);
}
response = responseHelper.buildSuccessResponse(oaipmh);
} else {
response = responseHelper.buildFailureResponse(oaipmh, request);
}
promise.complete(response);
} catch (Exception e) {
handleException(promise, e);
}
return promise.future();
}
use of net.opengis.cat.csw._3.RecordType in project mod-oai-pmh by folio-org.
the class MarcWithHoldingsRequestHelper method buildRecordsList.
private List<RecordType> buildRecordsList(Request request, List<JsonObject> batch, Map<String, JsonObject> srsResponse, boolean deletedRecordSupport) {
RecordMetadataManager metadataManager = RecordMetadataManager.getInstance();
final boolean suppressedRecordsProcessing = getBooleanProperty(request.getRequestId(), REPOSITORY_SUPPRESSED_RECORDS_PROCESSING);
List<RecordType> records = new ArrayList<>();
batch.stream().filter(instance -> {
final String instanceId = instance.getString(INSTANCE_ID_FIELD_NAME);
final JsonObject srsInstance = srsResponse.get(instanceId);
return Objects.nonNull(srsInstance);
}).forEach(instance -> {
final String instanceId = instance.getString(INSTANCE_ID_FIELD_NAME);
final JsonObject srsInstance = srsResponse.get(instanceId);
RecordType record = createRecord(request, srsInstance, instanceId);
JsonObject updatedSrsWithItemsData = metadataManager.populateMetadataWithItemsData(srsInstance, instance, suppressedRecordsProcessing);
JsonObject updatedSrsInstance = metadataManager.populateMetadataWithHoldingsData(updatedSrsWithItemsData, instance, suppressedRecordsProcessing);
if (deletedRecordSupport && storageHelper.isRecordMarkAsDeleted(updatedSrsInstance)) {
record.getHeader().setStatus(StatusType.DELETED);
}
String source = storageHelper.getInstanceRecordSource(updatedSrsInstance);
if (source != null && record.getHeader().getStatus() == null) {
if (suppressedRecordsProcessing) {
source = metadataManager.updateMetadataSourceWithDiscoverySuppressedData(source, updatedSrsInstance);
source = metadataManager.updateElectronicAccessFieldWithDiscoverySuppressedData(source, updatedSrsInstance);
}
try {
record.withMetadata(buildOaiMetadata(request, source));
} catch (Exception e) {
logger.error("Error occurred while converting record to xml representation: {}.", e.getMessage(), e);
logger.debug("Skipping problematic record due the conversion error. Source record id - {}.", storageHelper.getRecordId(srsInstance));
return;
}
}
if (filterInstance(request, srsInstance)) {
records.add(record);
}
});
return records;
}
Aggregations