Search in sources :

Example 1 with SearchTermContext

use of eu.europeana.enrichment.api.internal.SearchTermContext in project metis-framework by europeana.

the class MetisRecordParserTest method testExtractedFieldValuesForEnrichment.

@Test
public void testExtractedFieldValuesForEnrichment() {
    RDF rdf = new RDF();
    ProxyType proxy = new ProxyType();
    ArrayList<Choice> choiceList = new ArrayList<>();
    Choice choice1 = new Choice();
    Creator creator = new Creator();
    creator.setString("Creator");
    Lang language1 = new Lang();
    language1.setLang("English");
    creator.setLang(language1);
    choice1.setCreator(creator);
    choiceList.add(choice1);
    Choice choice2 = new Choice();
    Contributor contributor = new Contributor();
    contributor.setString("Contributor");
    Lang language2 = new Lang();
    language2.setLang("Dutch");
    contributor.setLang(language2);
    choice2.setContributor(contributor);
    choiceList.add(choice2);
    Choice choice3 = new Choice();
    Date date = new Date();
    date.setString("Date");
    Lang language3 = new Lang();
    language3.setLang("German");
    date.setLang(language3);
    choice3.setDate(date);
    choiceList.add(choice3);
    Choice choice4 = new Choice();
    Issued issued = new Issued();
    issued.setString("Issued");
    Lang language4 = new Lang();
    language4.setLang("French");
    issued.setLang(language4);
    choice4.setIssued(issued);
    choiceList.add(choice4);
    Choice choice5 = new Choice();
    Created created = new Created();
    created.setString("Created");
    Lang language5 = new Lang();
    language5.setLang("Italian");
    created.setLang(language5);
    choice5.setCreated(created);
    choiceList.add(choice5);
    Choice choice6 = new Choice();
    Coverage coverage = new Coverage();
    coverage.setString("Coverage");
    Lang language6 = new Lang();
    language6.setLang("Spanish");
    coverage.setLang(language6);
    choice6.setCoverage(coverage);
    choiceList.add(choice6);
    Choice choice7 = new Choice();
    Temporal temporal = new Temporal();
    temporal.setString("Temporal");
    Lang language7 = new Lang();
    language7.setLang("Polish");
    temporal.setLang(language7);
    choice7.setTemporal(temporal);
    choiceList.add(choice7);
    Choice choice8 = new Choice();
    Type type = new Type();
    type.setString("Type");
    Lang language8 = new Lang();
    language8.setLang("Romanian");
    type.setLang(language8);
    choice8.setType(type);
    choiceList.add(choice8);
    Choice choice9 = new Choice();
    Spatial spatial = new Spatial();
    spatial.setString("Spatial");
    Lang language9 = new Lang();
    language9.setLang("Greek");
    spatial.setLang(language9);
    choice9.setSpatial(spatial);
    choiceList.add(choice9);
    Choice choice10 = new Choice();
    Subject subject = new Subject();
    subject.setString("Subject");
    Lang language10 = new Lang();
    language10.setLang("Bulgarian");
    subject.setLang(language10);
    choice10.setSubject(subject);
    choiceList.add(choice10);
    // Should be rejected
    Choice choice11 = new Choice();
    Extent extent = new Extent();
    extent.setString("Extent");
    Lang language11 = new Lang();
    language11.setLang("Ukrainian");
    extent.setLang(language11);
    choice11.setExtent(extent);
    choiceList.add(choice11);
    proxy.setChoiceList(choiceList);
    ArrayList<ProxyType> proxyList = new ArrayList<>();
    proxyList.add(proxy);
    // Should be rejected
    ProxyType proxyEuropeana = new ProxyType();
    EuropeanaProxy europeanaProxy = new EuropeanaProxy();
    europeanaProxy.setEuropeanaProxy(true);
    proxyEuropeana.setEuropeanaProxy(europeanaProxy);
    proxyList.add(proxyEuropeana);
    rdf.setProxyList(proxyList);
    Set<SearchTermContext> result = new MetisRecordParser().parseSearchTerms(rdf);
    assertNotNull(result);
    assertEquals(10, result.size());
    ArrayList<String> resultProcessed = new ArrayList<>();
    for (SearchTermContext searchValue : result) {
        resultProcessed.add(searchValue.getTextValue() + "|" + searchValue.getLanguage());
    }
    assertTrue(resultProcessed.contains("Creator|English"));
    assertTrue(resultProcessed.contains("Contributor|Dutch"));
    assertTrue(resultProcessed.contains("Date|German"));
    assertTrue(resultProcessed.contains("Issued|French"));
    assertTrue(resultProcessed.contains("Created|Italian"));
    assertTrue(resultProcessed.contains("Coverage|Spanish"));
    assertTrue(resultProcessed.contains("Temporal|Polish"));
    assertTrue(resultProcessed.contains("Type|Romanian"));
    assertTrue(resultProcessed.contains("Spatial|Greek"));
    assertTrue(resultProcessed.contains("Subject|Bulgarian"));
}
Also used : Choice(eu.europeana.metis.schema.jibx.EuropeanaType.Choice) Extent(eu.europeana.metis.schema.jibx.Extent) ArrayList(java.util.ArrayList) Contributor(eu.europeana.metis.schema.jibx.Contributor) Lang(eu.europeana.metis.schema.jibx.ResourceOrLiteralType.Lang) Coverage(eu.europeana.metis.schema.jibx.Coverage) Creator(eu.europeana.metis.schema.jibx.Creator) Date(eu.europeana.metis.schema.jibx.Date) Subject(eu.europeana.metis.schema.jibx.Subject) EuropeanaProxy(eu.europeana.metis.schema.jibx.EuropeanaProxy) Created(eu.europeana.metis.schema.jibx.Created) SearchTermContext(eu.europeana.enrichment.api.internal.SearchTermContext) Type(eu.europeana.metis.schema.jibx.Type) EuropeanaAggregationType(eu.europeana.metis.schema.jibx.EuropeanaAggregationType) ProxyType(eu.europeana.metis.schema.jibx.ProxyType) Temporal(eu.europeana.metis.schema.jibx.Temporal) RDF(eu.europeana.metis.schema.jibx.RDF) Spatial(eu.europeana.metis.schema.jibx.Spatial) Issued(eu.europeana.metis.schema.jibx.Issued) ProxyType(eu.europeana.metis.schema.jibx.ProxyType) Test(org.junit.jupiter.api.Test)

Example 2 with SearchTermContext

use of eu.europeana.enrichment.api.internal.SearchTermContext in project metis-framework by europeana.

the class PersistentEntityResolverTest method resolveByText_WithTwoLetterLanguageAndFieldType.

@Test
void resolveByText_WithTwoLetterLanguageAndFieldType() {
    final SearchTermContext searchTerm = new SearchTermContext("Clarence Williams", "pl", Set.of(ProxyFieldType.DC_CREATOR, ProxyFieldType.DCTERMS_ISSUED));
    assertResolveByText(searchTerm, enrichmentObjectUtils.agentTerm1);
}
Also used : SearchTermContext(eu.europeana.enrichment.api.internal.SearchTermContext) Test(org.junit.jupiter.api.Test)

Example 3 with SearchTermContext

use of eu.europeana.enrichment.api.internal.SearchTermContext 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

SearchTermContext (eu.europeana.enrichment.api.internal.SearchTermContext)3 ProxyType (eu.europeana.metis.schema.jibx.ProxyType)2 RDF (eu.europeana.metis.schema.jibx.RDF)2 Lang (eu.europeana.metis.schema.jibx.ResourceOrLiteralType.Lang)2 ArrayList (java.util.ArrayList)2 Test (org.junit.jupiter.api.Test)2 AggregationFieldType (eu.europeana.enrichment.api.internal.AggregationFieldType)1 FieldType (eu.europeana.enrichment.api.internal.FieldType)1 ProxyFieldType (eu.europeana.enrichment.api.internal.ProxyFieldType)1 SearchTerm (eu.europeana.enrichment.api.internal.SearchTerm)1 AboutType (eu.europeana.metis.schema.jibx.AboutType)1 Aggregation (eu.europeana.metis.schema.jibx.Aggregation)1 Contributor (eu.europeana.metis.schema.jibx.Contributor)1 Coverage (eu.europeana.metis.schema.jibx.Coverage)1 Created (eu.europeana.metis.schema.jibx.Created)1 Creator (eu.europeana.metis.schema.jibx.Creator)1 Date (eu.europeana.metis.schema.jibx.Date)1 EuropeanaAggregationType (eu.europeana.metis.schema.jibx.EuropeanaAggregationType)1 EuropeanaProxy (eu.europeana.metis.schema.jibx.EuropeanaProxy)1 EuropeanaType (eu.europeana.metis.schema.jibx.EuropeanaType)1