use of net.opengis.cat.csw.v_2_0_2.AbstractRecordType 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;
}
Aggregations