use of eu.europeana.metis.schema.jibx.Temporal 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.Temporal in project metis-framework by europeana.
the class EnrichmentUtilsTest method testSetAdditionalDataAllYearFieldValues.
@Test
void testSetAdditionalDataAllYearFieldValues() {
Choice dateChoice = new Choice();
Date date = new Date();
Choice temporalChoice = new Choice();
Temporal temporal = new Temporal();
Choice createdChoice = new Choice();
Created created = new Created();
Choice issuedChoice = new Choice();
Issued issued = new Issued();
date.setString("1990");
dateChoice.setDate(date);
temporal.setString("1991");
temporalChoice.setTemporal(temporal);
created.setString("1992");
createdChoice.setCreated(created);
issued.setString("1993");
issuedChoice.setIssued(issued);
ArrayList<Choice> choices = new ArrayList<>();
choices.add(dateChoice);
choices.add(temporalChoice);
choices.add(createdChoice);
choices.add(issuedChoice);
PROXY_PROVIDER.setChoiceList(choices);
ArrayList<ProxyType> proxyList = new ArrayList<>();
proxyList.add(PROXY_EUROPEANA);
proxyList.add(PROXY_PROVIDER);
TEST_RDF.setProxyList(proxyList);
EnrichmentUtils.setAdditionalData(TEST_RDF);
ProxyType proxyResult = TEST_RDF.getProxyList().stream().filter(x -> x.getEuropeanaProxy().isEuropeanaProxy()).collect(Collectors.toList()).get(0);
assertEquals(4, proxyResult.getYearList().size());
assertEquals("1990", proxyResult.getYearList().get(0).getString());
assertEquals("1991", proxyResult.getYearList().get(1).getString());
assertEquals("1992", proxyResult.getYearList().get(2).getString());
assertEquals("1993", proxyResult.getYearList().get(3).getString());
}
use of eu.europeana.metis.schema.jibx.Temporal in project metis-framework by europeana.
the class DereferenceUtilsTest method testProxyListExtractedValues.
@Test
void testProxyListExtractedValues() {
RDF rdf = new RDF();
ProxyType proxy = new ProxyType();
HasMet hasMet = new HasMet();
hasMet.setResource("http://dummy1.dum");
ArrayList<HasMet> hasMetList = new ArrayList<>();
hasMetList.add(hasMet);
proxy.setHasMetList(hasMetList);
HasType hasType = new HasType();
ResourceOrLiteralType.Resource resource2 = new ResourceOrLiteralType.Resource();
resource2.setResource("http://dummy2.dum");
hasType.setResource(resource2);
ArrayList<HasType> hasTypeList = new ArrayList<>();
hasTypeList.add(hasType);
proxy.setHasTypeList(hasTypeList);
Incorporates incorporates = new Incorporates();
incorporates.setResource("http://dummy3.dum");
ArrayList<Incorporates> incorporatesList = new ArrayList<>();
incorporatesList.add(incorporates);
proxy.setIncorporateList(incorporatesList);
IsDerivativeOf isDerivativeOf = new IsDerivativeOf();
isDerivativeOf.setResource("http://dummy4.dum");
ArrayList<IsDerivativeOf> isDerivativeOfList = new ArrayList<>();
isDerivativeOfList.add(isDerivativeOf);
proxy.setIsDerivativeOfList(isDerivativeOfList);
IsRelatedTo isRelatedTo = new IsRelatedTo();
ResourceOrLiteralType.Resource resource5 = new ResourceOrLiteralType.Resource();
resource5.setResource("http://dummy5.dum");
isRelatedTo.setResource(resource5);
ArrayList<IsRelatedTo> isRelatedToList = new ArrayList<>();
isRelatedToList.add(isRelatedTo);
proxy.setIsRelatedToList(isRelatedToList);
IsSimilarTo isSimilarTo = new IsSimilarTo();
isSimilarTo.setResource("http://dummy6.dum");
ArrayList<IsSimilarTo> isSimilarToList = new ArrayList<>();
isSimilarToList.add(isSimilarTo);
proxy.setIsSimilarToList(isSimilarToList);
IsSuccessorOf isSuccessorOf = new IsSuccessorOf();
isSuccessorOf.setResource("http://dummy7.dum");
ArrayList<IsSuccessorOf> isSuccessorOfList = new ArrayList<>();
isSuccessorOfList.add(isSuccessorOf);
proxy.setIsSuccessorOfList(isSuccessorOfList);
Realizes realizes = new Realizes();
realizes.setResource("http://dummy8.dum");
ArrayList<Realizes> realizesList = new ArrayList<>();
realizesList.add(realizes);
proxy.setRealizeList(realizesList);
CurrentLocation currentLocation = new CurrentLocation();
ResourceOrLiteralType.Resource resource9 = new ResourceOrLiteralType.Resource();
resource9.setResource("http://dummy9.dum");
currentLocation.setResource(resource9);
proxy.setCurrentLocation(currentLocation);
ProxyType.Choice choice11 = new ProxyType.Choice();
Extent extent = new Extent();
ResourceOrLiteralType.Resource resource20 = new ResourceOrLiteralType.Resource();
resource20.setResource("http://dummy20.dum");
extent.setResource(resource20);
choice11.setExtent(extent);
ProxyType.Choice choice13 = new ProxyType.Choice();
HasFormat hasFormat = new HasFormat();
ResourceOrLiteralType.Resource resource22 = new ResourceOrLiteralType.Resource();
resource22.setResource("http://dummy22.dum");
hasFormat.setResource(resource22);
choice13.setHasFormat(hasFormat);
ProxyType.Choice choice14 = new ProxyType.Choice();
HasPart hasPart = new HasPart();
ResourceOrLiteralType.Resource resource23 = new ResourceOrLiteralType.Resource();
resource23.setResource("http://dummy23.dum");
hasPart.setResource(resource23);
choice14.setHasPart(hasPart);
ProxyType.Choice choice15 = new ProxyType.Choice();
HasVersion hasVersion = new HasVersion();
ResourceOrLiteralType.Resource resource24 = new ResourceOrLiteralType.Resource();
resource24.setResource("http://dummy24.dum");
hasVersion.setResource(resource24);
choice15.setHasVersion(hasVersion);
ProxyType.Choice choice18 = new ProxyType.Choice();
Temporal temporal = new Temporal();
ResourceOrLiteralType.Resource resource27 = new ResourceOrLiteralType.Resource();
resource27.setResource("http://dummy27.dum");
temporal.setResource(resource27);
choice18.setTemporal(temporal);
ProxyType.Choice choice19 = new ProxyType.Choice();
IsFormatOf isFormatOf = new IsFormatOf();
ResourceOrLiteralType.Resource resource28 = new ResourceOrLiteralType.Resource();
resource28.setResource("http://dummy28.dum");
isFormatOf.setResource(resource28);
choice19.setIsFormatOf(isFormatOf);
ProxyType.Choice choice20 = new ProxyType.Choice();
IsPartOf isPartOf = new IsPartOf();
ResourceOrLiteralType.Resource resource29 = new ResourceOrLiteralType.Resource();
resource29.setResource("http://dummy29.dum");
isPartOf.setResource(resource29);
choice20.setIsPartOf(isPartOf);
ProxyType.Choice choice21 = new ProxyType.Choice();
IsReferencedBy isReferencedBy = new IsReferencedBy();
ResourceOrLiteralType.Resource resource30 = new ResourceOrLiteralType.Resource();
resource30.setResource("http://dummy30.dum");
isReferencedBy.setResource(resource30);
choice21.setIsReferencedBy(isReferencedBy);
ProxyType.Choice choice29 = new ProxyType.Choice();
IsReplacedBy isReplacedBy = new IsReplacedBy();
ResourceOrLiteralType.Resource resource25 = new ResourceOrLiteralType.Resource();
resource25.setResource("http://dummy25.dum");
isReplacedBy.setResource(resource25);
choice29.setIsReplacedBy(isReplacedBy);
ProxyType.Choice choice22 = new ProxyType.Choice();
IsRequiredBy isRequiredBy = new IsRequiredBy();
ResourceOrLiteralType.Resource resource31 = new ResourceOrLiteralType.Resource();
resource31.setResource("http://dummy31.dum");
isRequiredBy.setResource(resource31);
choice22.setIsRequiredBy(isRequiredBy);
ProxyType.Choice choice23 = new ProxyType.Choice();
Issued issued = new Issued();
ResourceOrLiteralType.Resource resource32 = new ResourceOrLiteralType.Resource();
resource32.setResource("http://dummy32.dum");
issued.setResource(resource32);
choice23.setIssued(issued);
ProxyType.Choice choice24 = new ProxyType.Choice();
IsVersionOf isVersionOf = new IsVersionOf();
ResourceOrLiteralType.Resource resource33 = new ResourceOrLiteralType.Resource();
resource33.setResource("http://dummy33.dum");
isVersionOf.setResource(resource33);
choice24.setIsVersionOf(isVersionOf);
ProxyType.Choice choice25 = new ProxyType.Choice();
Medium medium = new Medium();
ResourceOrLiteralType.Resource resource34 = new ResourceOrLiteralType.Resource();
resource34.setResource("http://dummy34.dum");
medium.setResource(resource34);
choice25.setMedium(medium);
ProxyType.Choice choice30 = new ProxyType.Choice();
Publisher publisher = new Publisher();
ResourceOrLiteralType.Resource resource36 = new ResourceOrLiteralType.Resource();
resource36.setResource("http://dummy36.dum");
publisher.setResource(resource36);
choice30.setPublisher(publisher);
ProxyType.Choice choice31 = new ProxyType.Choice();
References references = new References();
ResourceOrLiteralType.Resource resource37 = new ResourceOrLiteralType.Resource();
resource37.setResource("http://dummy37.dum");
references.setResource(resource37);
choice31.setReferences(references);
ProxyType.Choice choice32 = new ProxyType.Choice();
Relation relation = new Relation();
ResourceOrLiteralType.Resource resource38 = new ResourceOrLiteralType.Resource();
resource38.setResource("http://dummy38.dum");
relation.setResource(resource38);
choice32.setRelation(relation);
ProxyType.Choice choice33 = new ProxyType.Choice();
Replaces replaces = new Replaces();
ResourceOrLiteralType.Resource resource39 = new ResourceOrLiteralType.Resource();
resource39.setResource("http://dummy39.dum");
replaces.setResource(resource39);
choice33.setReplaces(replaces);
ProxyType.Choice choice34 = new ProxyType.Choice();
Source source = new Source();
ResourceOrLiteralType.Resource resource40 = new ResourceOrLiteralType.Resource();
resource40.setResource("http://dummy40.dum");
source.setResource(resource40);
choice34.setSource(source);
// Should be rejected
ProxyType.Choice choice27 = new ProxyType.Choice();
Alternative alternative = new Alternative();
alternative.setString("Alternative");
choice27.setAlternative(alternative);
ArrayList<ProxyType.Choice> choiceList = new ArrayList<>();
choiceList.add(choice11);
choiceList.add(choice13);
choiceList.add(choice14);
choiceList.add(choice15);
choiceList.add(choice18);
choiceList.add(choice19);
choiceList.add(choice20);
choiceList.add(choice21);
choiceList.add(choice22);
choiceList.add(choice23);
choiceList.add(choice24);
choiceList.add(choice25);
choiceList.add(choice27);
choiceList.add(choice29);
choiceList.add(choice30);
choiceList.add(choice31);
choiceList.add(choice32);
choiceList.add(choice33);
choiceList.add(choice34);
proxy.setChoiceList(choiceList);
ArrayList<ProxyType> proxyList = new ArrayList<>();
proxyList.add(proxy);
rdf.setProxyList(proxyList);
Set<String> result = DereferenceUtils.extractReferencesForDereferencing(rdf);
assertNotNull(result);
assertEquals(25, result.size());
assertTrue(result.contains("http://dummy1.dum"));
assertTrue(result.contains("http://dummy2.dum"));
assertTrue(result.contains("http://dummy3.dum"));
assertTrue(result.contains("http://dummy4.dum"));
assertTrue(result.contains("http://dummy5.dum"));
assertTrue(result.contains("http://dummy6.dum"));
assertTrue(result.contains("http://dummy7.dum"));
assertTrue(result.contains("http://dummy8.dum"));
assertTrue(result.contains("http://dummy9.dum"));
assertTrue(result.contains("http://dummy20.dum"));
assertTrue(result.contains("http://dummy22.dum"));
assertTrue(result.contains("http://dummy25.dum"));
assertTrue(result.contains("http://dummy28.dum"));
assertTrue(result.contains("http://dummy30.dum"));
assertTrue(result.contains("http://dummy31.dum"));
assertTrue(result.contains("http://dummy33.dum"));
assertTrue(result.contains("http://dummy36.dum"));
assertTrue(result.contains("http://dummy37.dum"));
assertTrue(result.contains("http://dummy38.dum"));
assertTrue(result.contains("http://dummy39.dum"));
assertTrue(result.contains("http://dummy40.dum"));
}
use of eu.europeana.metis.schema.jibx.Temporal in project metis-framework by europeana.
the class EnrichmentUtilsTest method testSetAdditionalDataYearFieldWithoutDuplicates.
@Test
void testSetAdditionalDataYearFieldWithoutDuplicates() {
Choice dateChoice = new Choice();
Date date = new Date();
Choice temporalChoice = new Choice();
Temporal temporal = new Temporal();
date.setString("1990");
dateChoice.setDate(date);
temporal.setString("1990");
temporalChoice.setTemporal(temporal);
ArrayList<Choice> choices = new ArrayList<>();
choices.add(dateChoice);
choices.add(temporalChoice);
PROXY_PROVIDER.setChoiceList(choices);
ArrayList<ProxyType> proxyList = new ArrayList<>();
proxyList.add(PROXY_EUROPEANA);
proxyList.add(PROXY_PROVIDER);
TEST_RDF.setProxyList(proxyList);
EnrichmentUtils.setAdditionalData(TEST_RDF);
ProxyType proxyResult = TEST_RDF.getProxyList().stream().filter(x -> x.getEuropeanaProxy().isEuropeanaProxy()).collect(Collectors.toList()).get(0);
assertEquals(1, proxyResult.getYearList().size());
assertEquals("1990", proxyResult.getYearList().get(0).getString());
}
use of eu.europeana.metis.schema.jibx.Temporal in project metis-framework by europeana.
the class LanguageTagStatisticsTest method testAddToStatisticsForChoice.
@Test
void testAddToStatisticsForChoice() {
// Create the mock.
final LanguageTagStatistics statistics = spy(new LanguageTagStatistics(null, null, null));
// Test sanity check.
statistics.addToStatistics(null);
statistics.addToStatistics(new Choice());
verify(statistics, never()).addToStatistics(any(ResourceOrLiteralType.class), any());
verify(statistics, never()).addToStatistics(any(LiteralType.class), any());
// Test actual values
testAddToStatisticsForChoice(new Coverage(), Choice::setCoverage, PropertyType.DC_COVERAGE);
testAddToStatisticsForChoice(new Description(), Choice::setDescription, PropertyType.DC_DESCRIPTION);
testAddToStatisticsForChoice(new Format(), Choice::setFormat, PropertyType.DC_FORMAT);
testAddToStatisticsForChoice(new Relation(), Choice::setRelation, PropertyType.DC_RELATION);
testAddToStatisticsForChoice(new Rights(), Choice::setRights, PropertyType.DC_RIGHTS);
testAddToStatisticsForChoice(new Source(), Choice::setSource, PropertyType.DC_SOURCE);
testAddToStatisticsForChoice(new Subject(), Choice::setSubject, PropertyType.DC_SUBJECT);
testAddToStatisticsForChoice(new Title(), Choice::setTitle, PropertyType.DC_TITLE);
testAddToStatisticsForChoice(new Type(), Choice::setType, PropertyType.DC_TYPE);
testAddToStatisticsForChoice(new Alternative(), Choice::setAlternative, PropertyType.DCTERMS_ALTERNATIVE);
testAddToStatisticsForChoice(new HasPart(), Choice::setHasPart, PropertyType.DCTERMS_HAS_PART);
testAddToStatisticsForChoice(new IsPartOf(), Choice::setIsPartOf, PropertyType.DCTERMS_IS_PART_OF);
testAddToStatisticsForChoice(new IsReferencedBy(), Choice::setIsReferencedBy, PropertyType.DCTERMS_IS_REFERENCED_BY);
testAddToStatisticsForChoice(new Medium(), Choice::setMedium, PropertyType.DCTERMS_MEDIUM);
testAddToStatisticsForChoice(new Provenance(), Choice::setProvenance, PropertyType.DCTERMS_PROVENANCE);
testAddToStatisticsForChoice(new References(), Choice::setReferences, PropertyType.DCTERMS_REFERENCES);
testAddToStatisticsForChoice(new Spatial(), Choice::setSpatial, PropertyType.DCTERMS_SPATIAL);
testAddToStatisticsForChoice(new TableOfContents(), Choice::setTableOfContents, PropertyType.DCTERMS_TABLE_OF_CONTENTS);
testAddToStatisticsForChoice(new Temporal(), Choice::setTemporal, PropertyType.DCTERMS_TEMPORAL);
}
Aggregations