Search in sources :

Example 1 with Choice

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

the class DereferenceUtilsTest method testConceptListExtractedValues.

@Test
void testConceptListExtractedValues() {
    RDF rdf = new RDF();
    ProxyType proxy = new ProxyType();
    ArrayList<ProxyType> proxyList = new ArrayList<>();
    proxyList.add(proxy);
    rdf.setProxyList(proxyList);
    Concept concept = new Concept();
    concept.setAbout("http://dummy1.dum");
    Choice choice1 = new Choice();
    BroadMatch broadMatch = new BroadMatch();
    broadMatch.setResource("http://dummy2.dum");
    choice1.setBroadMatch(broadMatch);
    Choice choice2 = new Choice();
    CloseMatch closeMatch = new CloseMatch();
    closeMatch.setResource("http://dummy3.dum");
    choice2.setCloseMatch(closeMatch);
    Choice choice3 = new Choice();
    ExactMatch exactMatch = new ExactMatch();
    exactMatch.setResource("http://dummy4.dum");
    choice3.setExactMatch(exactMatch);
    Choice choice4 = new Choice();
    NarrowMatch narrowMatch = new NarrowMatch();
    narrowMatch.setResource("http://dummy5.dum");
    choice4.setNarrowMatch(narrowMatch);
    Choice choice5 = new Choice();
    RelatedMatch relatedMatch = new RelatedMatch();
    relatedMatch.setResource("http://dummy6.dum");
    choice5.setRelatedMatch(relatedMatch);
    Choice choice6 = new Choice();
    Related related = new Related();
    related.setResource("http://dummy7.dum");
    choice6.setRelated(related);
    Choice choice7 = new Choice();
    Broader broader = new Broader();
    broader.setResource("http://dummy8.dum");
    choice7.setBroader(broader);
    Choice choice8 = new Choice();
    Note note = new Note();
    note.setString("Note");
    choice8.setNote(note);
    ArrayList<Choice> choiceList = new ArrayList<>();
    choiceList.add(choice1);
    choiceList.add(choice2);
    choiceList.add(choice3);
    choiceList.add(choice4);
    choiceList.add(choice5);
    choiceList.add(choice6);
    choiceList.add(choice7);
    concept.setChoiceList(choiceList);
    ArrayList<Concept> conceptList = new ArrayList<>();
    conceptList.add(concept);
    rdf.setConceptList(conceptList);
    Set<String> result = DereferenceUtils.extractReferencesForDereferencing(rdf);
    assertNotNull(result);
    assertEquals(1, result.size());
    assertTrue(result.contains("http://dummy8.dum"));
}
Also used : Concept(eu.europeana.metis.schema.jibx.Concept) RelatedMatch(eu.europeana.metis.schema.jibx.RelatedMatch) Broader(eu.europeana.metis.schema.jibx.Broader) Choice(eu.europeana.metis.schema.jibx.Concept.Choice) CloseMatch(eu.europeana.metis.schema.jibx.CloseMatch) ArrayList(java.util.ArrayList) ExactMatch(eu.europeana.metis.schema.jibx.ExactMatch) Related(eu.europeana.metis.schema.jibx.Related) BroadMatch(eu.europeana.metis.schema.jibx.BroadMatch) RDF(eu.europeana.metis.schema.jibx.RDF) Note(eu.europeana.metis.schema.jibx.Note) ProxyType(eu.europeana.metis.schema.jibx.ProxyType) NarrowMatch(eu.europeana.metis.schema.jibx.NarrowMatch) Test(org.junit.jupiter.api.Test)

Example 2 with Choice

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

the class ItemExtractorUtilsTest method testToChoices.

@Test
void testToChoices() {
    List<Choice> choices = new ArrayList<>();
    List<AltLabel> altLabels = new ArrayList<>();
    AltLabel label1 = new AltLabel();
    AltLabel label2 = new AltLabel();
    AltLabel label3 = new AltLabel();
    Lang lang1 = new Lang();
    lang1.setLang("lang1");
    Lang lang2 = new Lang();
    lang2.setLang("lang2");
    Lang lang3 = new Lang();
    lang3.setLang("lang3");
    label1.setString("value1");
    label1.setLang(lang1);
    label2.setString("value2");
    label1.setLang(lang2);
    label3.setString("value3");
    label1.setLang(lang3);
    altLabels.add(label1);
    altLabels.add(label3);
    altLabels.add(label3);
    ItemExtractorUtils.toChoices(altLabels, Choice::setAltLabel, choices);
    assertTrue(choices.size() > 0);
    for (AltLabel label : altLabels) {
        List<Choice> result = choices.stream().filter(x -> x.getAltLabel().equals(label)).collect(Collectors.toList());
        assertTrue(result.size() > 0);
    }
}
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) Choice(eu.europeana.metis.schema.jibx.Concept.Choice) AltLabel(eu.europeana.metis.schema.jibx.AltLabel) ArrayList(java.util.ArrayList) Lang(eu.europeana.metis.schema.jibx.LiteralType.Lang) Test(org.junit.jupiter.api.Test)

Example 3 with Choice

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

the class ItemExtractorUtils method toChoices.

static <T> void toChoices(List<T> inputList, BiConsumer<Choice, T> propertySetter, List<Choice> destination) {
    for (T input : inputList) {
        final Choice choice = new Choice();
        propertySetter.accept(choice, input);
        destination.add(choice);
    }
}
Also used : Choice(eu.europeana.metis.schema.jibx.Concept.Choice)

Example 4 with Choice

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

the class ContextualClassesBreakdownClassifierTest method testEntityQualifiesForConcept.

@Test
void testEntityQualifiesForConcept() {
    // Create objects
    final ContextualClassesClassifier classifier = spy(new ContextualClassesClassifier());
    final Concept concept = new Concept();
    final PrefLabel prefLabel = new PrefLabel();
    final Note note = new Note();
    final Broader broader = new Broader();
    final Narrower narrower = new Narrower();
    final ExactMatch exactMatch = new ExactMatch();
    final CloseMatch closeMatch = new CloseMatch();
    final Related related = new Related();
    // Test empty concept
    concept.setChoiceList(null);
    assertFalse(classifier.entityQualifies(concept));
    concept.setChoiceList(new ArrayList<>());
    assertFalse(classifier.entityQualifies(concept));
    concept.getChoiceList().add(new Choice());
    assertFalse(classifier.entityQualifies(concept));
    // Set values
    concept.setChoiceList(IntStream.range(0, 7).mapToObj(index -> new Choice()).collect(Collectors.toList()));
    concept.getChoiceList().get(0).setPrefLabel(prefLabel);
    concept.getChoiceList().get(1).setNote(note);
    concept.getChoiceList().get(2).setBroader(broader);
    concept.getChoiceList().get(3).setNarrower(narrower);
    concept.getChoiceList().get(4).setExactMatch(exactMatch);
    concept.getChoiceList().get(5).setCloseMatch(closeMatch);
    concept.getChoiceList().get(6).setRelated(related);
    // Test prefLabel absent (and rest present)
    doReturn(false).when(classifier).hasProperty(prefLabel);
    doReturn(true).when(classifier).hasProperty(note);
    doReturn(true).when(classifier).hasProperty(broader);
    doReturn(true).when(classifier).hasProperty(narrower);
    doReturn(true).when(classifier).hasProperty(exactMatch);
    doReturn(true).when(classifier).hasProperty(closeMatch);
    doReturn(true).when(classifier).hasProperty(related);
    assertFalse(classifier.entityQualifies(concept));
    // Test prefLabel present (and rest absent)
    doReturn(true).when(classifier).hasProperty(prefLabel);
    doReturn(false).when(classifier).hasProperty(note);
    doReturn(false).when(classifier).hasProperty(broader);
    doReturn(false).when(classifier).hasProperty(narrower);
    doReturn(false).when(classifier).hasProperty(exactMatch);
    doReturn(false).when(classifier).hasProperty(closeMatch);
    doReturn(false).when(classifier).hasProperty(related);
    assertFalse(classifier.entityQualifies(concept));
    // Test prefLabel and note present
    doReturn(true).when(classifier).hasProperty(note);
    assertTrue(classifier.entityQualifies(concept));
    doReturn(false).when(classifier).hasProperty(note);
    assertFalse(classifier.entityQualifies(concept));
    // Test prefLabel and broader present
    doReturn(true).when(classifier).hasProperty(broader);
    assertTrue(classifier.entityQualifies(concept));
    doReturn(false).when(classifier).hasProperty(broader);
    assertFalse(classifier.entityQualifies(concept));
    // Test prefLabel and narrower present
    doReturn(true).when(classifier).hasProperty(narrower);
    assertTrue(classifier.entityQualifies(concept));
    doReturn(false).when(classifier).hasProperty(narrower);
    assertFalse(classifier.entityQualifies(concept));
    // Test prefLabel and exactMatch present
    doReturn(true).when(classifier).hasProperty(exactMatch);
    assertTrue(classifier.entityQualifies(concept));
    doReturn(false).when(classifier).hasProperty(exactMatch);
    assertFalse(classifier.entityQualifies(concept));
    // Test prefLabel and closeMatch present
    doReturn(true).when(classifier).hasProperty(closeMatch);
    assertTrue(classifier.entityQualifies(concept));
    doReturn(false).when(classifier).hasProperty(closeMatch);
    assertFalse(classifier.entityQualifies(concept));
    // Test prefLabel and related present
    doReturn(true).when(classifier).hasProperty(related);
    assertTrue(classifier.entityQualifies(concept));
    doReturn(false).when(classifier).hasProperty(related);
    assertFalse(classifier.entityQualifies(concept));
}
Also used : Concept(eu.europeana.metis.schema.jibx.Concept) ExactMatch(eu.europeana.metis.schema.jibx.ExactMatch) Broader(eu.europeana.metis.schema.jibx.Broader) Narrower(eu.europeana.metis.schema.jibx.Narrower) Related(eu.europeana.metis.schema.jibx.Related) Choice(eu.europeana.metis.schema.jibx.Concept.Choice) Note(eu.europeana.metis.schema.jibx.Note) CloseMatch(eu.europeana.metis.schema.jibx.CloseMatch) PrefLabel(eu.europeana.metis.schema.jibx.PrefLabel) Test(org.junit.jupiter.api.Test)

Aggregations

Choice (eu.europeana.metis.schema.jibx.Concept.Choice)4 Test (org.junit.jupiter.api.Test)3 Broader (eu.europeana.metis.schema.jibx.Broader)2 CloseMatch (eu.europeana.metis.schema.jibx.CloseMatch)2 Concept (eu.europeana.metis.schema.jibx.Concept)2 ExactMatch (eu.europeana.metis.schema.jibx.ExactMatch)2 Note (eu.europeana.metis.schema.jibx.Note)2 Related (eu.europeana.metis.schema.jibx.Related)2 ArrayList (java.util.ArrayList)2 Agent (eu.europeana.enrichment.api.external.model.Agent)1 EnrichmentBase (eu.europeana.enrichment.api.external.model.EnrichmentBase)1 Label (eu.europeana.enrichment.api.external.model.Label)1 LabelResource (eu.europeana.enrichment.api.external.model.LabelResource)1 Part (eu.europeana.enrichment.api.external.model.Part)1 Resource (eu.europeana.enrichment.api.external.model.Resource)1 AboutType (eu.europeana.metis.schema.jibx.AboutType)1 AltLabel (eu.europeana.metis.schema.jibx.AltLabel)1 BroadMatch (eu.europeana.metis.schema.jibx.BroadMatch)1 LiteralType (eu.europeana.metis.schema.jibx.LiteralType)1 Lang (eu.europeana.metis.schema.jibx.LiteralType.Lang)1