Search in sources :

Example 11 with ResourceOrLiteralType

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

the class QualityAnnotationFieldInput method apply.

@Override
public QualityAnnotationImpl apply(QualityAnnotation qualityAnnotation) {
    QualityAnnotationImpl qualityAnnotationImpl = new QualityAnnotationImpl();
    qualityAnnotationImpl.setAbout(qualityAnnotation.getAbout());
    qualityAnnotationImpl.setCreated(Optional.ofNullable(qualityAnnotation.getCreated()).map(ResourceOrLiteralType::getString).orElse(null));
    qualityAnnotationImpl.setTarget(FieldInputUtils.resourceListToArray(qualityAnnotation.getHasTargetList()));
    qualityAnnotationImpl.setBody(Optional.ofNullable(qualityAnnotation.getHasBody()).map(ResourceType::getResource).orElse(null));
    return qualityAnnotationImpl;
}
Also used : ResourceType(eu.europeana.metis.schema.jibx.ResourceType) ResourceOrLiteralType(eu.europeana.metis.schema.jibx.ResourceOrLiteralType) QualityAnnotationImpl(eu.europeana.corelib.solr.entity.QualityAnnotationImpl)

Example 12 with ResourceOrLiteralType

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

the class ItemExtractorUtilsTest method testExtractLabelResourceWithoutValue.

@Test
void testExtractLabelResourceWithoutValue() {
    LabelResource label = new LabelResource("lang1", null);
    label.setResource("resource1");
    ResourceOrLiteralType output = ItemExtractorUtils.extractLabelResource(label, ResourceOrLiteralType::new);
    assertNotNull(output);
    assertEquals("", output.getString());
    assertEquals("lang1", output.getLang().getLang());
    assertEquals("resource1", output.getResource().getResource());
}
Also used : LabelResource(eu.europeana.enrichment.api.external.model.LabelResource) ResourceOrLiteralType(eu.europeana.metis.schema.jibx.ResourceOrLiteralType) Test(org.junit.jupiter.api.Test)

Example 13 with ResourceOrLiteralType

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

the class ItemExtractorUtilsTest method extractLabelResources.

@Test
void extractLabelResources() {
    List<LabelResource> labelResources = new ArrayList<>();
    LabelResource labelResource1 = new LabelResource("resource1");
    LabelResource labelResource2 = new LabelResource("resource2");
    LabelResource labelResource3 = new LabelResource("resource3");
    labelResources.add(labelResource1);
    labelResources.add(labelResource2);
    labelResources.add(labelResource3);
    List<ResourceOrLiteralType> output = ItemExtractorUtils.extractLabelResources(labelResources, ResourceOrLiteralType::new);
    for (LabelResource labelResource : labelResources) {
        List<ResourceOrLiteralType> result = output.stream().filter(x -> x.getResource().getResource().equals(labelResource.getResource())).collect(Collectors.toList());
        assertEquals(1, result.size());
    }
}
Also used : Label(eu.europeana.enrichment.api.external.model.Label) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) EnrichmentBase(eu.europeana.enrichment.api.external.model.EnrichmentBase) Lang(eu.europeana.metis.schema.jibx.LiteralType.Lang) AltLabel(eu.europeana.metis.schema.jibx.AltLabel) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) Choice(eu.europeana.metis.schema.jibx.Concept.Choice) Collectors(java.util.stream.Collectors) ResourceOrLiteralType(eu.europeana.metis.schema.jibx.ResourceOrLiteralType) ArrayList(java.util.ArrayList) ResourceType(eu.europeana.metis.schema.jibx.ResourceType) Test(org.junit.jupiter.api.Test) AboutType(eu.europeana.metis.schema.jibx.AboutType) List(java.util.List) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) LiteralType(eu.europeana.metis.schema.jibx.LiteralType) Part(eu.europeana.enrichment.api.external.model.Part) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Agent(eu.europeana.enrichment.api.external.model.Agent) LabelResource(eu.europeana.enrichment.api.external.model.LabelResource) Resource(eu.europeana.enrichment.api.external.model.Resource) LabelResource(eu.europeana.enrichment.api.external.model.LabelResource) ArrayList(java.util.ArrayList) ResourceOrLiteralType(eu.europeana.metis.schema.jibx.ResourceOrLiteralType) Test(org.junit.jupiter.api.Test)

Example 14 with ResourceOrLiteralType

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

the class ItemExtractorUtilsTest method testExtractPart.

@Test
void testExtractPart() {
    Part part = new Part("resource");
    ResourceOrLiteralType output = ItemExtractorUtils.extractPart(part, ResourceOrLiteralType::new);
    assertNotNull(output);
    assertEquals("", output.getString());
    assertEquals("resource", output.getResource().getResource());
}
Also used : Part(eu.europeana.enrichment.api.external.model.Part) ResourceOrLiteralType(eu.europeana.metis.schema.jibx.ResourceOrLiteralType) Test(org.junit.jupiter.api.Test)

Example 15 with ResourceOrLiteralType

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

the class RdfEntityUtils method replaceValueWithLinkInAggregation.

/**
 * Replace matching aggregation values with their found corresponding links.
 *
 * @param rdf the rdf to update
 * @param link the about value to use
 * @param searchTermAggregation the aggregation search term to use for finding the matched values
 */
public static void replaceValueWithLinkInAggregation(RDF rdf, String link, SearchTermContext searchTermAggregation) {
    final List<Aggregation> aggregationList = rdf.getAggregationList();
    for (FieldType<? extends AboutType> aggregationFieldType : searchTermAggregation.getFieldTypes()) {
        aggregationList.stream().flatMap(((AggregationFieldType) aggregationFieldType)::extractFields).filter(resourceOrLiteralType -> resourceOrLiteralAndSearchTermEquality(resourceOrLiteralType, searchTermAggregation)).forEach(resourceOrLiteralType -> {
            final Resource resource = new Resource();
            resource.setResource(link);
            resourceOrLiteralType.setResource(resource);
            resourceOrLiteralType.setLang(new Lang());
            resourceOrLiteralType.setString("");
        });
    }
}
Also used : Aggregation(eu.europeana.metis.schema.jibx.Aggregation) Arrays(java.util.Arrays) AggregationFieldType(eu.europeana.enrichment.api.internal.AggregationFieldType) SearchTerm(eu.europeana.enrichment.api.internal.SearchTerm) RDF(eu.europeana.metis.schema.jibx.RDF) Supplier(java.util.function.Supplier) StringUtils(org.apache.commons.lang3.StringUtils) Aggregation(eu.europeana.metis.schema.jibx.Aggregation) ResourceOrLiteralType(eu.europeana.metis.schema.jibx.ResourceOrLiteralType) ArrayList(java.util.ArrayList) ProxyFieldType(eu.europeana.enrichment.api.internal.ProxyFieldType) AboutType(eu.europeana.metis.schema.jibx.AboutType) Lang(eu.europeana.metis.schema.jibx.ResourceOrLiteralType.Lang) Resource(eu.europeana.metis.schema.jibx.ResourceOrLiteralType.Resource) FieldType(eu.europeana.enrichment.api.internal.FieldType) SearchTermContext(eu.europeana.enrichment.api.internal.SearchTermContext) Map(java.util.Map) EuropeanaType(eu.europeana.metis.schema.jibx.EuropeanaType) EnumMap(java.util.EnumMap) Collection(java.util.Collection) Set(java.util.Set) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) Consumer(java.util.function.Consumer) List(java.util.List) ProxyType(eu.europeana.metis.schema.jibx.ProxyType) Optional(java.util.Optional) Collections(java.util.Collections) Resource(eu.europeana.metis.schema.jibx.ResourceOrLiteralType.Resource) Lang(eu.europeana.metis.schema.jibx.ResourceOrLiteralType.Lang)

Aggregations

ResourceOrLiteralType (eu.europeana.metis.schema.jibx.ResourceOrLiteralType)21 Test (org.junit.jupiter.api.Test)16 LabelResource (eu.europeana.enrichment.api.external.model.LabelResource)6 Resource (eu.europeana.metis.schema.jibx.ResourceOrLiteralType.Resource)6 List (java.util.List)6 ArrayList (java.util.ArrayList)5 Lang (eu.europeana.metis.schema.jibx.LiteralType.Lang)4 ResourceType (eu.europeana.metis.schema.jibx.ResourceType)4 Part (eu.europeana.enrichment.api.external.model.Part)3 AboutType (eu.europeana.metis.schema.jibx.AboutType)3 Choice (eu.europeana.metis.schema.jibx.EuropeanaType.Choice)3 ProxyType (eu.europeana.metis.schema.jibx.ProxyType)3 Collectors (java.util.stream.Collectors)3 CurrentLocation (eu.europeana.metis.schema.jibx.CurrentLocation)2 LiteralType (eu.europeana.metis.schema.jibx.LiteralType)2 Arrays (java.util.Arrays)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 Map (java.util.Map)2 Optional (java.util.Optional)2