Search in sources :

Example 1 with MetadataTierBreakdown

use of eu.europeana.indexing.tiers.view.MetadataTierBreakdown in project metis-framework by europeana.

the class RecordTierCalculationViewGenerator method tierClassification.

private RecordTierCalculationView tierClassification(final String xml) {
    final RDF rdf;
    try {
        // Perform the tier classification
        rdf = RdfConversionUtils.convertStringToRdf(xml);
        final RdfWrapper rdfWrapper = new RdfWrapper(rdf);
        final TierClassification<MediaTier, ContentTierBreakdown> mediaTierClassification = ClassifierFactory.getMediaClassifier().classify(rdfWrapper);
        final TierClassification<MetadataTier, MetadataTierBreakdown> metadataTierClassification = ClassifierFactory.getMetadataClassifier().classify(rdfWrapper);
        RecordTierCalculationSummary recordTierCalculationSummary = new RecordTierCalculationSummary();
        recordTierCalculationSummary.setEuropeanaRecordId(europeanaId);
        recordTierCalculationSummary.setProviderRecordId(providerId);
        recordTierCalculationSummary.setContentTier(mediaTierClassification.getTier());
        recordTierCalculationSummary.setMetadataTier(metadataTierClassification.getTier());
        recordTierCalculationSummary.setPortalRecordLink(portalRecordLink);
        final ContentTierBreakdown mediaTierClassificationWithErrors = new ContentTierBreakdown(mediaTierClassification.getClassification(), processingErrors);
        return new RecordTierCalculationView(recordTierCalculationSummary, mediaTierClassificationWithErrors, metadataTierClassification.getClassification());
    } catch (SerializationException e) {
        throw new TierCalculationException("Error during calculation of tiers", e);
    }
}
Also used : MediaTier(eu.europeana.indexing.tiers.model.MediaTier) MetadataTier(eu.europeana.indexing.tiers.model.MetadataTier) SerializationException(eu.europeana.metis.schema.convert.SerializationException) TierCalculationException(eu.europeana.indexing.exception.TierCalculationException) RdfWrapper(eu.europeana.indexing.utils.RdfWrapper) RecordTierCalculationSummary(eu.europeana.indexing.tiers.view.RecordTierCalculationSummary) RDF(eu.europeana.metis.schema.jibx.RDF) RecordTierCalculationView(eu.europeana.indexing.tiers.view.RecordTierCalculationView) MetadataTierBreakdown(eu.europeana.indexing.tiers.view.MetadataTierBreakdown) ContentTierBreakdown(eu.europeana.indexing.tiers.view.ContentTierBreakdown)

Example 2 with MetadataTierBreakdown

use of eu.europeana.indexing.tiers.view.MetadataTierBreakdown in project metis-framework by europeana.

the class MetadataClassifierTest method testClassify.

@Test
void testClassify() {
    // The entity under consideration
    final RdfWrapper testEntity = mock(RdfWrapper.class);
    final LanguageClassifier languageClassifier = mock(LanguageClassifier.class);
    final EnablingElementsClassifier enablingElementsClassifier = mock(EnablingElementsClassifier.class);
    final ContextualClassesClassifier contextualClassesClassifier = mock(ContextualClassesClassifier.class);
    // The tiers
    final MetadataTier lowTier = MetadataTier.T0;
    final MetadataTier middleTier = MetadataTier.TA;
    final MetadataTier highTier = MetadataTier.TC;
    assertThrows(NullPointerException.class, () -> new MetadataClassifier(null, null, null));
    assertThrows(NullPointerException.class, () -> new MetadataClassifier(languageClassifier, null, null));
    assertThrows(NullPointerException.class, () -> new MetadataClassifier(languageClassifier, enablingElementsClassifier, null));
    when(languageClassifier.classifyBreakdown(testEntity)).thenReturn(new LanguageBreakdown(2, Set.of(PropertyType.DC_COVERAGE.name(), PropertyType.DC_DESCRIPTION.name()), lowTier));
    when(enablingElementsClassifier.classifyBreakdown(testEntity)).thenReturn(new EnablingElementsBreakdown(Collections.emptySet(), Collections.emptySet(), middleTier));
    when(contextualClassesClassifier.classifyBreakdown(testEntity)).thenReturn(new ContextualClassesBreakdown(5, Set.of(TimeSpanType.class.getSimpleName(), PlaceType.class.getSimpleName()), highTier));
    final TierClassification<MetadataTier, MetadataTierBreakdown> metadataTierClassification = new MetadataClassifier(languageClassifier, enablingElementsClassifier, contextualClassesClassifier).classify(testEntity);
    assertEquals(lowTier, metadataTierClassification.getTier());
    assertNotNull(metadataTierClassification.getClassification());
}
Also used : PlaceType(eu.europeana.metis.schema.jibx.PlaceType) TimeSpanType(eu.europeana.metis.schema.jibx.TimeSpanType) EnablingElementsBreakdown(eu.europeana.indexing.tiers.view.EnablingElementsBreakdown) ContextualClassesClassifier(eu.europeana.indexing.tiers.metadata.ContextualClassesClassifier) RdfWrapper(eu.europeana.indexing.utils.RdfWrapper) EnablingElementsClassifier(eu.europeana.indexing.tiers.metadata.EnablingElementsClassifier) LanguageBreakdown(eu.europeana.indexing.tiers.view.LanguageBreakdown) LanguageClassifier(eu.europeana.indexing.tiers.metadata.LanguageClassifier) ContextualClassesBreakdown(eu.europeana.indexing.tiers.view.ContextualClassesBreakdown) MetadataTierBreakdown(eu.europeana.indexing.tiers.view.MetadataTierBreakdown) Test(org.junit.jupiter.api.Test)

Example 3 with MetadataTierBreakdown

use of eu.europeana.indexing.tiers.view.MetadataTierBreakdown in project metis-framework by europeana.

the class MetadataClassifier method classify.

@Override
public TierClassification<MetadataTier, MetadataTierBreakdown> classify(RdfWrapper entity) {
    final LanguageBreakdown languageBreakdownTierClassification = languageClassifier.classifyBreakdown(entity);
    final EnablingElementsBreakdown enablingElementsTierClassification = enablingElementsClassifier.classifyBreakdown(entity);
    final ContextualClassesBreakdown contextualClassesTierClassification = contextualClassesClassifier.classifyBreakdown(entity);
    final MetadataTierBreakdown metadataTierBreakdown = new MetadataTierBreakdown(languageBreakdownTierClassification, enablingElementsTierClassification, contextualClassesTierClassification);
    MetadataTier metadataTier = Stream.of(languageBreakdownTierClassification.getMetadataTier(), enablingElementsTierClassification.getMetadataTier(), contextualClassesTierClassification.getMetadataTier()).reduce(Tier::min).orElseThrow(IllegalStateException::new);
    return new TierClassification<>(metadataTier, metadataTierBreakdown);
}
Also used : LanguageBreakdown(eu.europeana.indexing.tiers.view.LanguageBreakdown) EnablingElementsBreakdown(eu.europeana.indexing.tiers.view.EnablingElementsBreakdown) ContextualClassesBreakdown(eu.europeana.indexing.tiers.view.ContextualClassesBreakdown) MetadataTierBreakdown(eu.europeana.indexing.tiers.view.MetadataTierBreakdown)

Aggregations

MetadataTierBreakdown (eu.europeana.indexing.tiers.view.MetadataTierBreakdown)3 ContextualClassesBreakdown (eu.europeana.indexing.tiers.view.ContextualClassesBreakdown)2 EnablingElementsBreakdown (eu.europeana.indexing.tiers.view.EnablingElementsBreakdown)2 LanguageBreakdown (eu.europeana.indexing.tiers.view.LanguageBreakdown)2 RdfWrapper (eu.europeana.indexing.utils.RdfWrapper)2 TierCalculationException (eu.europeana.indexing.exception.TierCalculationException)1 ContextualClassesClassifier (eu.europeana.indexing.tiers.metadata.ContextualClassesClassifier)1 EnablingElementsClassifier (eu.europeana.indexing.tiers.metadata.EnablingElementsClassifier)1 LanguageClassifier (eu.europeana.indexing.tiers.metadata.LanguageClassifier)1 MediaTier (eu.europeana.indexing.tiers.model.MediaTier)1 MetadataTier (eu.europeana.indexing.tiers.model.MetadataTier)1 ContentTierBreakdown (eu.europeana.indexing.tiers.view.ContentTierBreakdown)1 RecordTierCalculationSummary (eu.europeana.indexing.tiers.view.RecordTierCalculationSummary)1 RecordTierCalculationView (eu.europeana.indexing.tiers.view.RecordTierCalculationView)1 SerializationException (eu.europeana.metis.schema.convert.SerializationException)1 PlaceType (eu.europeana.metis.schema.jibx.PlaceType)1 RDF (eu.europeana.metis.schema.jibx.RDF)1 TimeSpanType (eu.europeana.metis.schema.jibx.TimeSpanType)1 Test (org.junit.jupiter.api.Test)1