use of eu.europeana.corelib.solr.bean.impl.FullBeanImpl in project corelib by europeana.
the class MockBeanUtils method MockMinimalBean.
static FullBeanImpl MockMinimalBean() {
FullBeanImpl bean = new FullBeanImpl();
bean.setAbout(ABOUT);
// europeana proxy
bean.setProxies(new ArrayList<>());
ProxyImpl proxy = new ProxyImpl();
proxy.setAbout(EUROPEANA_PROXY_ABOUT);
proxy.setProxyFor(PROXY_FOR);
proxy.setEdmType(DocType.IMAGE.getEnumNameValue());
proxy.setProxyIn(new String[] { EUROPEANA_PROXY_IN });
proxy.setEuropeanaProxy(true);
bean.getProxies().add(proxy);
// 1st proxy
proxy = new ProxyImpl();
proxy.setAbout(PROVIDER_PROXY_ABOUT);
proxy.setProxyFor(PROXY_FOR);
proxy.setEdmType(DocType.IMAGE.getEnumNameValue());
proxy.setProxyIn(new String[] { DATAPROVIDER_AGGREGATION_ABOUT });
bean.getProxies().add(proxy);
bean.setProvidedCHOs(new ArrayList<>());
ProvidedCHOImpl providedCHO = new ProvidedCHOImpl();
providedCHO.setAbout(ABOUT);
bean.getProvidedCHOs().add(providedCHO);
bean.setAggregations(new ArrayList<>());
// 2nd aggregation
AggregationImpl aggregation = new AggregationImpl();
aggregation.setAbout(SECOND_AGGREGATION_ABOUT);
aggregation.setEdmIsShownAt(IS_SHOWN_AT);
aggregation.setEdmIsShownBy(IS_SHOWN_BY);
bean.getAggregations().add(aggregation);
// empty webresources
List<WebResourceImpl> webResources = new ArrayList<>();
aggregation.setWebResources(webResources);
EuropeanaAggregationImpl europeanaAggregation = new EuropeanaAggregationImpl();
europeanaAggregation.setAbout(EUROPEANA_AGGREGATION_ABOUT);
bean.setEuropeanaAggregation(europeanaAggregation);
bean.setEuropeanaCollectionName(new String[] { EUROPEANA_COLLECTION_NAME });
return bean;
}
use of eu.europeana.corelib.solr.bean.impl.FullBeanImpl in project corelib by europeana.
the class MockBeanUtils method MockBeanWithLineageProxy.
static FullBeanImpl MockBeanWithLineageProxy() {
FullBeanImpl bean = new FullBeanImpl();
bean.setAbout(ABOUT);
// europeana proxy
bean.setProxies(new ArrayList<>());
ProxyImpl proxy = new ProxyImpl();
proxy.setAbout(EUROPEANA_PROXY_ABOUT);
proxy.setProxyFor(PROXY_FOR);
proxy.setEdmType(DocType.IMAGE.getEnumNameValue());
proxy.setProxyIn(new String[] { EUROPEANA_PROXY_IN });
proxy.setLineage(new String[] { PROVIDER_PROXY_ABOUT });
proxy.setEuropeanaProxy(true);
bean.getProxies().add(proxy);
// 1st proxy
proxy = new ProxyImpl();
proxy.setAbout(PROVIDER_PROXY_ABOUT);
proxy.setProxyFor(PROXY_FOR);
proxy.setEdmType(DocType.IMAGE.getEnumNameValue());
proxy.setProxyIn(new String[] { DATAPROVIDER_AGGREGATION_ABOUT });
proxy.setLineage(new String[] { "dummy" });
bean.getProxies().add(proxy);
bean.setProvidedCHOs(new ArrayList<>());
ProvidedCHOImpl providedCHO = new ProvidedCHOImpl();
providedCHO.setAbout(ABOUT);
bean.getProvidedCHOs().add(providedCHO);
bean.setAggregations(new ArrayList<>());
// 2nd aggregation
AggregationImpl aggregation = new AggregationImpl();
aggregation.setAbout(SECOND_AGGREGATION_ABOUT);
aggregation.setEdmIsShownAt(IS_SHOWN_AT);
aggregation.setEdmIsShownBy(IS_SHOWN_BY);
bean.getAggregations().add(aggregation);
// empty webresources
List<WebResourceImpl> webResources = new ArrayList<>();
aggregation.setWebResources(webResources);
EuropeanaAggregationImpl europeanaAggregation = new EuropeanaAggregationImpl();
europeanaAggregation.setAbout(EUROPEANA_AGGREGATION_ABOUT);
bean.setEuropeanaAggregation(europeanaAggregation);
bean.setEuropeanaCollectionName(new String[] { EUROPEANA_COLLECTION_NAME });
return bean;
}
use of eu.europeana.corelib.solr.bean.impl.FullBeanImpl in project metis-framework by europeana.
the class RecordDao method getFullBean.
/**
* Get a full bean using an identifier matching it's {@code about} field.
*
* @param id the identifier of the fullbean
* @return the matched full bean
* @throws EuropeanaException if anything when wrong with the request
*/
public FullBean getFullBean(String id) throws EuropeanaException {
try {
long start = 0;
if (LOGGER.isDebugEnabled()) {
start = System.currentTimeMillis();
}
FullBeanImpl result = datastore.find(FullBeanImpl.class).filter(Filters.eq("about", id)).first();
LOGGER.debug("Mongo query find fullbean {} finished in {} ms", id, (System.currentTimeMillis() - start));
return result;
} catch (RuntimeException re) {
if (re.getCause() != null && (re.getCause() instanceof MappingException || re.getCause() instanceof ClassCastException)) {
throw new MongoDBException(ProblemType.RECORD_RETRIEVAL_ERROR, re);
} else {
throw new MongoRuntimeException(ProblemType.MONGO_UNREACHABLE, re);
}
}
}
use of eu.europeana.corelib.solr.bean.impl.FullBeanImpl in project metis-framework by europeana.
the class RecordDaoTest method getFullBean.
private static FullBean getFullBean() {
final FullBeanImpl fullBean = new FullBeanImpl();
fullBean.setEuropeanaId(new ObjectId("81eec080f582833f364dad08"));
fullBean.setLanguage(new String[] { "Nederlands", "Vlams", "Duits", "Frans", "Spaans", "Italians", "Duits", "Portuguese" });
fullBean.setCountry(new String[] { "Nederland", "Belgiƫ", "Duitsland", "Frankrijk", "Spanje", "Italiƫ", "Switzerland", "Portugal" });
fullBean.setYear(new String[] { "2022", "2023", "2024", "2025", "2026", "2027", "2028", "2029" });
fullBean.setAbout("fullBeanAbout");
fullBean.setType("TEXT");
fullBean.setTimestampCreated(Date.from(Instant.parse("2022-01-26T12:35:12.00Z")));
fullBean.setTimestampUpdated(Date.from(Instant.parse("2022-01-26T12:35:12.00Z")));
fullBean.setProvider(new String[] { "Pro1", "Prov2", "Prov3", "Prov4", "Prov5", "Prov6", "Prov7", "Prov8" });
fullBean.setUserTags(new String[] { "UsrTag1", "UsrTag2", "UsrTag3", "UsrTag4", "UsrTag5", "UsrTag6", "UsrTag7", "UsrTag8" });
fullBean.setEuropeanaCollectionName(new String[] { "Collection1", "Collection2", "Collection3", "Collection4", "Collection5" });
fullBean.setEuropeanaCompleteness(100);
return fullBean;
}
use of eu.europeana.corelib.solr.bean.impl.FullBeanImpl in project metis-framework by europeana.
the class SolrDocumentPopulator method populateWithProperties.
/**
* Populates a Solr document with the properties of the full bean. Please note: this method should
* only be called once on a given document, otherwise the behavior is not defined.
*
* @param document The Solr document to populate.
* @param fullBean The FullBean to populate from.
*/
public void populateWithProperties(SolrInputDocument document, FullBeanImpl fullBean) {
// Get the type: filter duplicates
final String[] types = Optional.ofNullable(fullBean.getProxies()).stream().flatMap(List::stream).filter(Objects::nonNull).map(ProxyImpl::getEdmType).filter(Objects::nonNull).distinct().toArray(String[]::new);
SolrPropertyUtils.addValues(document, EdmLabel.PROVIDER_EDM_TYPE, types);
// Gather the licenses.
final List<LicenseImpl> licenses = Optional.ofNullable(fullBean.getLicenses()).stream().flatMap(List::stream).filter(Objects::nonNull).collect(Collectors.toList());
// Gather the quality annotations.
final Set<String> acceptableTargets = Optional.ofNullable(fullBean.getAggregations()).stream().flatMap(Collection::stream).filter(Objects::nonNull).map(AggregationImpl::getAbout).filter(Objects::nonNull).collect(Collectors.toSet());
final Predicate<QualityAnnotation> hasAcceptableTarget = annotation -> Optional.ofNullable(annotation.getTarget()).stream().flatMap(Arrays::stream).anyMatch(acceptableTargets::contains);
final Map<String, QualityAnnotation> qualityAnnotations = Optional.ofNullable(fullBean.getQualityAnnotations()).map(List::stream).orElseGet(Stream::empty).filter(Objects::nonNull).filter(annotation -> StringUtils.isNotBlank(annotation.getAbout())).filter(hasAcceptableTarget).collect(Collectors.toMap(QualityAnnotation::getAbout, Function.identity(), (v1, v2) -> v1));
// Add the containing objects.
new ProvidedChoSolrCreator().addToDocument(document, fullBean.getProvidedCHOs().get(0));
new AggregationSolrCreator(licenses, fullBean.getOrganizations()).addToDocument(document, getDataProviderAggregations(fullBean).get(0));
new EuropeanaAggregationSolrCreator(licenses, qualityAnnotations::get).addToDocument(document, fullBean.getEuropeanaAggregation());
new ProxySolrCreator().addAllToDocument(document, fullBean.getProxies());
new ConceptSolrCreator().addAllToDocument(document, fullBean.getConcepts());
new TimespanSolrCreator().addAllToDocument(document, fullBean.getTimespans());
new AgentSolrCreator().addAllToDocument(document, fullBean.getAgents());
new PlaceSolrCreator().addAllToDocument(document, fullBean.getPlaces());
new ServiceSolrCreator().addAllToDocument(document, fullBean.getServices());
// Add the licenses.
final Set<String> defRights = fullBean.getAggregations().stream().map(AggregationImpl::getEdmRights).filter(Objects::nonNull).flatMap(SolrPropertyUtils::getRightsFromMap).collect(Collectors.toSet());
new LicenseSolrCreator(license -> defRights.contains(license.getAbout())).addAllToDocument(document, fullBean.getLicenses());
// Add the top-level properties.
document.addField(EdmLabel.EUROPEANA_COMPLETENESS.toString(), fullBean.getEuropeanaCompleteness());
document.addField(EdmLabel.EUROPEANA_COLLECTIONNAME.toString(), fullBean.getEuropeanaCollectionName()[0]);
document.addField(EdmLabel.TIMESTAMP_CREATED.toString(), fullBean.getTimestampCreated());
document.addField(EdmLabel.TIMESTAMP_UPDATED.toString(), fullBean.getTimestampUpdated());
}
Aggregations