Search in sources :

Example 1 with ResourceType

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

the class ContextualClassesBreakdownClassifierTest method testHasProperty.

@Test
void testHasProperty() {
    final ContextualClassesClassifier classifier = new ContextualClassesClassifier();
    // Test for literals
    assertFalse(classifier.hasProperty((LiteralType) null));
    final LiteralType literal = new LiteralType();
    literal.setString(null);
    assertFalse(classifier.hasProperty(literal));
    literal.setString(" ");
    assertFalse(classifier.hasProperty(literal));
    literal.setString("test 1");
    assertTrue(classifier.hasProperty(literal));
    // Test for resources
    assertFalse(classifier.hasProperty((ResourceType) null));
    final ResourceType resource = new ResourceType();
    resource.setResource(null);
    assertFalse(classifier.hasProperty(resource));
    resource.setResource(" ");
    assertFalse(classifier.hasProperty(resource));
    resource.setResource("test 2");
    assertTrue(classifier.hasProperty(resource));
    // Test for resource/literal objects
    assertFalse(classifier.hasProperty((ResourceOrLiteralType) null));
    final ResourceOrLiteralType object = new ResourceOrLiteralType();
    object.setResource(null);
    object.setString(null);
    assertFalse(classifier.hasProperty(object));
    object.setString(" ");
    assertFalse(classifier.hasProperty(object));
    object.setString("test");
    assertTrue(classifier.hasProperty(object));
    object.setString(null);
    object.setResource(new Resource());
    object.getResource().setResource(null);
    assertFalse(classifier.hasProperty(object));
    object.getResource().setResource(" ");
    assertFalse(classifier.hasProperty(object));
    object.getResource().setResource("test 3");
    assertTrue(classifier.hasProperty(object));
}
Also used : Resource(eu.europeana.metis.schema.jibx.ResourceOrLiteralType.Resource) ResourceOrLiteralType(eu.europeana.metis.schema.jibx.ResourceOrLiteralType) LiteralType(eu.europeana.metis.schema.jibx.LiteralType) ResourceType(eu.europeana.metis.schema.jibx.ResourceType) ResourceOrLiteralType(eu.europeana.metis.schema.jibx.ResourceOrLiteralType) Test(org.junit.jupiter.api.Test)

Example 2 with ResourceType

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

the class ItemExtractorUtilsTest method testExtractAsResource.

@Test
void testExtractAsResource() {
    String string = "resource";
    ResourceType output = ItemExtractorUtils.extractAsResource(string, ResourceType::new, String::toUpperCase);
    assertNotNull(output);
    assertEquals(string.toUpperCase(), output.getResource());
}
Also used : ResourceType(eu.europeana.metis.schema.jibx.ResourceType) Test(org.junit.jupiter.api.Test)

Example 3 with ResourceType

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

the class ItemExtractorUtilsTest method testExtractAsResourceNullValue.

@Test
void testExtractAsResourceNullValue() {
    ResourceType output = ItemExtractorUtils.extractAsResource(null, ResourceType::new, x -> null);
    assertNotNull(output);
    assertEquals("", output.getResource());
}
Also used : ResourceType(eu.europeana.metis.schema.jibx.ResourceType) Test(org.junit.jupiter.api.Test)

Example 4 with ResourceType

use of eu.europeana.metis.schema.jibx.ResourceType 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;
}
Also used : Type2(eu.europeana.metis.schema.jibx.Type2) ProxyImpl(eu.europeana.corelib.solr.entity.ProxyImpl) Choice(eu.europeana.metis.schema.jibx.EuropeanaType.Choice) ResourceType(eu.europeana.metis.schema.jibx.ResourceType) IsNextInSequence(eu.europeana.metis.schema.jibx.IsNextInSequence) EuropeanaProxy(eu.europeana.metis.schema.jibx.EuropeanaProxy)

Example 5 with ResourceType

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

the class AggregationFieldInput method processResource.

private String processResource(List<WebResourceImpl> aggregationWebResources, ResourceType resource) {
    String resourceString = Optional.ofNullable(resource).map(ResourceType::getResource).map(String::trim).orElse(null);
    if (resourceString != null && !referencedWebResourceAbouts.contains(resourceString)) {
        final WebResourceImpl matchingWebResource = recordWebResourcesMap.get(resourceString);
        if (matchingWebResource != null) {
            aggregationWebResources.add(matchingWebResource);
            referencedWebResourceAbouts.add(matchingWebResource.getAbout());
            recordWebResourcesMap.remove(matchingWebResource.getAbout());
        } else {
            WebResourceImpl webResource = new WebResourceImpl();
            webResource.setAbout(resourceString);
            aggregationWebResources.add(webResource);
            referencedWebResourceAbouts.add(webResource.getAbout());
        }
    }
    return resourceString;
}
Also used : WebResourceImpl(eu.europeana.corelib.solr.entity.WebResourceImpl) ResourceType(eu.europeana.metis.schema.jibx.ResourceType)

Aggregations

ResourceType (eu.europeana.metis.schema.jibx.ResourceType)8 Test (org.junit.jupiter.api.Test)4 ResourceOrLiteralType (eu.europeana.metis.schema.jibx.ResourceOrLiteralType)3 LiteralType (eu.europeana.metis.schema.jibx.LiteralType)2 ProxyImpl (eu.europeana.corelib.solr.entity.ProxyImpl)1 QualityAnnotationImpl (eu.europeana.corelib.solr.entity.QualityAnnotationImpl)1 WebResourceImpl (eu.europeana.corelib.solr.entity.WebResourceImpl)1 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 Choice (eu.europeana.metis.schema.jibx.Concept.Choice)1 EuropeanaProxy (eu.europeana.metis.schema.jibx.EuropeanaProxy)1 Choice (eu.europeana.metis.schema.jibx.EuropeanaType.Choice)1 IsNextInSequence (eu.europeana.metis.schema.jibx.IsNextInSequence)1 Lang (eu.europeana.metis.schema.jibx.LiteralType.Lang)1