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