use of eu.europeana.metis.schema.jibx.EuropeanaProxy in project metis-framework by europeana.
the class LanguageClassifierTest method testCreateLanguageTagStatistics.
@Test
void testCreateLanguageTagStatistics() {
// Create the RDF
final RdfWrapper rdf = mock(RdfWrapper.class);
// Create the contextual classes
final PlaceType place1 = new PlaceType();
place1.setAbout("place about 1");
final PlaceType place2 = new PlaceType();
place2.setAbout("place about 2");
final TimeSpanType timeSpan = new TimeSpanType();
timeSpan.setAbout("time span about");
final Concept concept = new Concept();
concept.setAbout("concept about");
doReturn(Arrays.asList(place1, place2)).when(rdf).getPlaces();
doReturn(Collections.singletonList(timeSpan)).when(rdf).getTimeSpans();
doReturn(Collections.singletonList(concept)).when(rdf).getConcepts();
// Create proxies
final ProxyType providerProxy1 = new ProxyType();
providerProxy1.setEuropeanaProxy(new EuropeanaProxy());
providerProxy1.getEuropeanaProxy().setEuropeanaProxy(false);
final ProxyType providerProxy2 = new ProxyType();
providerProxy2.setEuropeanaProxy(new EuropeanaProxy());
providerProxy2.getEuropeanaProxy().setEuropeanaProxy(false);
doReturn(Arrays.asList(providerProxy1, providerProxy2, null)).when(rdf).getProviderProxies();
// Test the method.
final LanguageClassifier classifier = spy(new LanguageClassifier());
final LanguageTagStatistics result = classifier.createLanguageTagStatistics(rdf);
verify(classifier, times(1)).addProxyToStatistics(providerProxy1, result);
verify(classifier, times(1)).addProxyToStatistics(providerProxy2, result);
verify(classifier, times(2)).addProxyToStatistics(any(), any());
}
use of eu.europeana.metis.schema.jibx.EuropeanaProxy 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.metis.schema.jibx.EuropeanaProxy in project metis-framework by europeana.
the class EnrichmentUtilsTest method testSetAdditionalDataEmptyProxies.
@Test
void testSetAdditionalDataEmptyProxies() {
RDF newRdf = new RDF();
RDF toCompare = new RDF();
ProxyType emptyEuropeanaProxy = new ProxyType();
emptyEuropeanaProxy.setEuropeanaProxy(new EuropeanaProxy());
emptyEuropeanaProxy.getEuropeanaProxy().setEuropeanaProxy(true);
ProxyType emptyProviderProxy = new ProxyType();
EuropeanaAggregationType emptyAggregation = new EuropeanaAggregationType();
List<ProxyType> proxyList = List.of(emptyEuropeanaProxy, emptyProviderProxy);
newRdf.setEuropeanaAggregationList(Collections.singletonList(emptyAggregation));
newRdf.setProxyList(proxyList);
toCompare.setEuropeanaAggregationList(Collections.singletonList(emptyAggregation));
toCompare.setProxyList(proxyList);
EnrichmentUtils.setAdditionalData(newRdf);
assertArrayEquals(toCompare.getProxyList().toArray(), newRdf.getProxyList().toArray());
assertEquals(toCompare.getEuropeanaAggregationList().get(0), newRdf.getEuropeanaAggregationList().get(0));
}
use of eu.europeana.metis.schema.jibx.EuropeanaProxy in project metis-framework by europeana.
the class EnrichmentUtilsTest method setUp.
@BeforeEach
void setUp() {
EuropeanaProxy europeanaProxy = new EuropeanaProxy();
EuropeanaProxy providerProxy = new EuropeanaProxy();
europeanaProxy.setEuropeanaProxy(true);
providerProxy.setEuropeanaProxy(false);
PROXY_EUROPEANA.setAbout("/proxy/europeana/260/_kmo_av_sid_45006");
PROXY_EUROPEANA.setEuropeanaProxy(europeanaProxy);
PROXY_PROVIDER.setAbout("/proxy/provider/260/_kmo_av_sid_45006");
PROXY_PROVIDER.setEuropeanaProxy(providerProxy);
EUROPEANA_AGGREGATION_TYPE.setAbout("/aggregation/europeana/260/_kmo_av_sid_45006");
TEST_RDF.setEuropeanaAggregationList(Collections.singletonList(EUROPEANA_AGGREGATION_TYPE));
doReturn(Collections.singletonList(new Aggregation())).when(TEST_RDF).getAggregationList();
}
use of eu.europeana.metis.schema.jibx.EuropeanaProxy in project metis-framework by europeana.
the class ProxyFieldInput method apply.
@Override
public ProxyImpl apply(ProxyType proxy) {
final ProxyImpl mongoProxy = new ProxyImpl();
mongoProxy.setAbout(proxy.getAbout());
mongoProxy.setEuropeanaProxy(Optional.ofNullable(proxy.getEuropeanaProxy()).map(EuropeanaProxy::isEuropeanaProxy).orElse(Boolean.FALSE));
mongoProxy.setEdmCurrentLocation(FieldInputUtils.createResourceOrLiteralMapFromString(proxy.getCurrentLocation()));
List<IsNextInSequence> seqList = proxy.getIsNextInSequenceList();
if (seqList != null) {
mongoProxy.setEdmIsNextInSequence(seqList.stream().map(IsNextInSequence::getResource).toArray(String[]::new));
}
final String docType = Optional.ofNullable(proxy.getType()).map(Type2::getType).map(EdmType::xmlValue).orElse(null);
mongoProxy.setEdmType(docType);
mongoProxy.setProxyFor(Optional.ofNullable(proxy.getProxyFor()).map(ResourceType::getResource).orElse(null));
mongoProxy.setProxyIn(FieldInputUtils.resourceListToArray(proxy.getProxyInList()));
mongoProxy.setLineage(FieldInputUtils.resourceListToArray(proxy.getLineageList()));
mongoProxy.setEdmHasMet(FieldInputUtils.createResourceMapFromList(proxy.getHasMetList()));
mongoProxy.setYear(FieldInputUtils.createLiteralMapFromList(proxy.getYearList()));
mongoProxy.setEdmHasType(FieldInputUtils.createResourceOrLiteralMapFromList(proxy.getHasTypeList()));
mongoProxy.setEdmIncorporates(FieldInputUtils.resourceListToArray(proxy.getIncorporateList()));
mongoProxy.setEdmIsDerivativeOf(FieldInputUtils.resourceListToArray(proxy.getIsDerivativeOfList()));
mongoProxy.setEdmIsRelatedTo(FieldInputUtils.createResourceOrLiteralMapFromList(proxy.getIsRelatedToList()));
if (proxy.getIsRepresentationOf() != null) {
mongoProxy.setEdmIsRepresentationOf(proxy.getIsRepresentationOf().getResource());
}
mongoProxy.setEdmIsSimilarTo(FieldInputUtils.resourceListToArray(proxy.getIsSimilarToList()));
mongoProxy.setEdmRealizes(FieldInputUtils.resourceListToArray(proxy.getRealizeList()));
mongoProxy.setEdmIsSuccessorOf(FieldInputUtils.resourceListToArray(proxy.getIsSuccessorOfList()));
List<Choice> europeanaTypeList = proxy.getChoiceList();
if (europeanaTypeList != null) {
for (Choice europeanaType : europeanaTypeList) {
applyToChoice(europeanaType, mongoProxy);
}
}
return mongoProxy;
}
Aggregations