use of eu.europeana.metis.schema.jibx.ResourceOrLiteralType in project metis-framework by europeana.
the class QualityAnnotationFieldInput method apply.
@Override
public QualityAnnotationImpl apply(QualityAnnotation qualityAnnotation) {
QualityAnnotationImpl qualityAnnotationImpl = new QualityAnnotationImpl();
qualityAnnotationImpl.setAbout(qualityAnnotation.getAbout());
qualityAnnotationImpl.setCreated(Optional.ofNullable(qualityAnnotation.getCreated()).map(ResourceOrLiteralType::getString).orElse(null));
qualityAnnotationImpl.setTarget(FieldInputUtils.resourceListToArray(qualityAnnotation.getHasTargetList()));
qualityAnnotationImpl.setBody(Optional.ofNullable(qualityAnnotation.getHasBody()).map(ResourceType::getResource).orElse(null));
return qualityAnnotationImpl;
}
use of eu.europeana.metis.schema.jibx.ResourceOrLiteralType in project metis-framework by europeana.
the class ItemExtractorUtilsTest method testExtractLabelResourceWithoutValue.
@Test
void testExtractLabelResourceWithoutValue() {
LabelResource label = new LabelResource("lang1", null);
label.setResource("resource1");
ResourceOrLiteralType output = ItemExtractorUtils.extractLabelResource(label, ResourceOrLiteralType::new);
assertNotNull(output);
assertEquals("", output.getString());
assertEquals("lang1", output.getLang().getLang());
assertEquals("resource1", output.getResource().getResource());
}
use of eu.europeana.metis.schema.jibx.ResourceOrLiteralType in project metis-framework by europeana.
the class ItemExtractorUtilsTest method extractLabelResources.
@Test
void extractLabelResources() {
List<LabelResource> labelResources = new ArrayList<>();
LabelResource labelResource1 = new LabelResource("resource1");
LabelResource labelResource2 = new LabelResource("resource2");
LabelResource labelResource3 = new LabelResource("resource3");
labelResources.add(labelResource1);
labelResources.add(labelResource2);
labelResources.add(labelResource3);
List<ResourceOrLiteralType> output = ItemExtractorUtils.extractLabelResources(labelResources, ResourceOrLiteralType::new);
for (LabelResource labelResource : labelResources) {
List<ResourceOrLiteralType> result = output.stream().filter(x -> x.getResource().getResource().equals(labelResource.getResource())).collect(Collectors.toList());
assertEquals(1, result.size());
}
}
use of eu.europeana.metis.schema.jibx.ResourceOrLiteralType in project metis-framework by europeana.
the class ItemExtractorUtilsTest method testExtractPart.
@Test
void testExtractPart() {
Part part = new Part("resource");
ResourceOrLiteralType output = ItemExtractorUtils.extractPart(part, ResourceOrLiteralType::new);
assertNotNull(output);
assertEquals("", output.getString());
assertEquals("resource", output.getResource().getResource());
}
use of eu.europeana.metis.schema.jibx.ResourceOrLiteralType 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