Search in sources :

Example 1 with Year

use of eu.europeana.metis.schema.jibx.Year 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);
}
Also used : Year(eu.europeana.metis.schema.jibx.Year) Completeness(eu.europeana.metis.schema.jibx.Completeness) Objects(java.util.Objects) ProxyType(eu.europeana.metis.schema.jibx.ProxyType) EuropeanaAggregationType(eu.europeana.metis.schema.jibx.EuropeanaAggregationType)

Example 2 with Year

use of eu.europeana.metis.schema.jibx.Year in project metis-framework by europeana.

the class EnrichmentUtils method createYear.

private static Year createYear(Integer year) {
    final Year result = new Year();
    result.setString(year.toString());
    return result;
}
Also used : Year(eu.europeana.metis.schema.jibx.Year)

Aggregations

Year (eu.europeana.metis.schema.jibx.Year)2 Completeness (eu.europeana.metis.schema.jibx.Completeness)1 EuropeanaAggregationType (eu.europeana.metis.schema.jibx.EuropeanaAggregationType)1 ProxyType (eu.europeana.metis.schema.jibx.ProxyType)1 Objects (java.util.Objects)1