use of eu.europeana.metis.schema.jibx.Completeness in project metis-framework by europeana.
the class EnrichmentUtils method setAdditionalData.
/**
* <p>
* This method is executed at the end of the enrichment process and sets additional values/fields
* in the RDF, based on all the data that has been collected.
* </p>
* <p>
* Currently sets the edm:year fields (obtained from the provider proxy) in the europeana proxy.
* If no europeana or provider proxy is present, this method has no effect.
* </p>
*
* @param rdf The RDF in which to set additional field values.
*/
public static void setAdditionalData(RDF rdf) {
// Get the provider and europeana proxy
final List<ProxyType> providerProxies = RdfEntityUtils.getProviderProxies(rdf);
if (providerProxies.isEmpty()) {
return;
}
final ProxyType europeanaProxy = RdfEntityUtils.getEuropeanaProxy(rdf);
// Calculate completeness first
EuropeanaAggregationType europeanaAggregation = rdf.getEuropeanaAggregationList().stream().findAny().orElse(null);
if (europeanaAggregation != null) {
Completeness completeness = new Completeness();
completeness.setString(Integer.toString(computeEuropeanaCompleteness(providerProxies, rdf.getAggregationList())));
europeanaAggregation.setCompleteness(completeness);
}
// Obtain the date strings from the various proxy fields.
final List<String> dateStrings = providerProxies.stream().map(EuropeanaType::getChoiceList).filter(Objects::nonNull).flatMap(Collection::stream).map(EnrichmentUtils::getDateFromChoice).filter(Objects::nonNull).collect(Collectors.toList());
// Parse them and set them in the europeana proxy.
final List<Year> yearList = new YearParser().parse(dateStrings).stream().map(EnrichmentUtils::createYear).collect(Collectors.toList());
europeanaProxy.setYearList(yearList);
}
Aggregations