Search in sources :

Example 1 with FullBeanImpl

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;
}
Also used : FullBeanImpl(eu.europeana.corelib.solr.bean.impl.FullBeanImpl) ArrayList(java.util.ArrayList)

Example 2 with FullBeanImpl

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;
}
Also used : FullBeanImpl(eu.europeana.corelib.solr.bean.impl.FullBeanImpl) ArrayList(java.util.ArrayList)

Example 3 with FullBeanImpl

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);
        }
    }
}
Also used : FullBeanImpl(eu.europeana.corelib.solr.bean.impl.FullBeanImpl) MongoRuntimeException(eu.europeana.corelib.edm.exceptions.MongoRuntimeException) MongoDBException(eu.europeana.corelib.edm.exceptions.MongoDBException) MongoRuntimeException(eu.europeana.corelib.edm.exceptions.MongoRuntimeException) MappingException(dev.morphia.mapping.MappingException)

Example 4 with FullBeanImpl

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;
}
Also used : FullBeanImpl(eu.europeana.corelib.solr.bean.impl.FullBeanImpl) ObjectId(org.bson.types.ObjectId)

Example 5 with FullBeanImpl

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());
}
Also used : ProxyImpl(eu.europeana.corelib.solr.entity.ProxyImpl) Arrays(java.util.Arrays) FacetEncoder(eu.europeana.indexing.solr.facet.FacetEncoder) RdfWrapper(eu.europeana.indexing.utils.RdfWrapper) ProxySolrCreator(eu.europeana.indexing.solr.property.ProxySolrCreator) AgentSolrCreator(eu.europeana.indexing.solr.property.AgentSolrCreator) MediaType(eu.europeana.metis.schema.model.MediaType) WebResourceWrapper(eu.europeana.indexing.utils.WebResourceWrapper) ArrayUtils(org.apache.commons.lang3.ArrayUtils) Function(java.util.function.Function) StringUtils(org.apache.commons.lang3.StringUtils) HashSet(java.util.HashSet) FullBeanImpl(eu.europeana.corelib.solr.bean.impl.FullBeanImpl) AggregationSolrCreator(eu.europeana.indexing.solr.property.AggregationSolrCreator) EuropeanaAggregationSolrCreator(eu.europeana.indexing.solr.property.EuropeanaAggregationSolrCreator) Map(java.util.Map) EnumSet(java.util.EnumSet) WebResourceLinkType(eu.europeana.indexing.utils.WebResourceLinkType) ProvidedChoSolrCreator(eu.europeana.indexing.solr.property.ProvidedChoSolrCreator) Predicate(java.util.function.Predicate) Collection(java.util.Collection) Set(java.util.Set) AggregationImpl(eu.europeana.corelib.solr.entity.AggregationImpl) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) ConceptSolrCreator(eu.europeana.indexing.solr.property.ConceptSolrCreator) PlaceSolrCreator(eu.europeana.indexing.solr.property.PlaceSolrCreator) SolrPropertyUtils(eu.europeana.indexing.solr.property.SolrPropertyUtils) List(java.util.List) ServiceSolrCreator(eu.europeana.indexing.solr.property.ServiceSolrCreator) Stream(java.util.stream.Stream) TimespanSolrCreator(eu.europeana.indexing.solr.property.TimespanSolrCreator) QualityAnnotation(eu.europeana.corelib.definitions.edm.entity.QualityAnnotation) Optional(java.util.Optional) LicenseImpl(eu.europeana.corelib.solr.entity.LicenseImpl) Predicate.not(java.util.function.Predicate.not) LicenseSolrCreator(eu.europeana.indexing.solr.property.LicenseSolrCreator) SolrInputDocument(org.apache.solr.common.SolrInputDocument) AgentSolrCreator(eu.europeana.indexing.solr.property.AgentSolrCreator) ProvidedChoSolrCreator(eu.europeana.indexing.solr.property.ProvidedChoSolrCreator) AggregationImpl(eu.europeana.corelib.solr.entity.AggregationImpl) LicenseImpl(eu.europeana.corelib.solr.entity.LicenseImpl) AggregationSolrCreator(eu.europeana.indexing.solr.property.AggregationSolrCreator) EuropeanaAggregationSolrCreator(eu.europeana.indexing.solr.property.EuropeanaAggregationSolrCreator) LicenseSolrCreator(eu.europeana.indexing.solr.property.LicenseSolrCreator) PlaceSolrCreator(eu.europeana.indexing.solr.property.PlaceSolrCreator) ServiceSolrCreator(eu.europeana.indexing.solr.property.ServiceSolrCreator) List(java.util.List) Stream(java.util.stream.Stream) ConceptSolrCreator(eu.europeana.indexing.solr.property.ConceptSolrCreator) TimespanSolrCreator(eu.europeana.indexing.solr.property.TimespanSolrCreator) EuropeanaAggregationSolrCreator(eu.europeana.indexing.solr.property.EuropeanaAggregationSolrCreator) Objects(java.util.Objects) Collection(java.util.Collection) QualityAnnotation(eu.europeana.corelib.definitions.edm.entity.QualityAnnotation) ProxySolrCreator(eu.europeana.indexing.solr.property.ProxySolrCreator)

Aggregations

FullBeanImpl (eu.europeana.corelib.solr.bean.impl.FullBeanImpl)25 ArrayList (java.util.ArrayList)12 Test (org.junit.Test)5 AggregationImpl (eu.europeana.corelib.solr.entity.AggregationImpl)3 ProxyImpl (eu.europeana.corelib.solr.entity.ProxyImpl)3 EuropeanaAggregationImpl (eu.europeana.corelib.solr.entity.EuropeanaAggregationImpl)2 LicenseImpl (eu.europeana.corelib.solr.entity.LicenseImpl)2 ProvidedCHOImpl (eu.europeana.corelib.solr.entity.ProvidedCHOImpl)2 WebResourceImpl (eu.europeana.corelib.solr.entity.WebResourceImpl)2 IndexerRelatedIndexingException (eu.europeana.indexing.exception.IndexerRelatedIndexingException)2 IOException (java.io.IOException)2 Date (java.util.Date)2 SolrServerException (org.apache.solr.client.solrj.SolrServerException)2 MongoClientException (com.mongodb.MongoClientException)1 MongoConfigurationException (com.mongodb.MongoConfigurationException)1 MongoIncompatibleDriverException (com.mongodb.MongoIncompatibleDriverException)1 MongoInternalException (com.mongodb.MongoInternalException)1 MongoInterruptedException (com.mongodb.MongoInterruptedException)1 MongoSecurityException (com.mongodb.MongoSecurityException)1 MongoSocketException (com.mongodb.MongoSocketException)1