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"));
}
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);
}
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("");
});
}
}
Aggregations