Search in sources :

Example 1 with ConceptImpl

use of eu.europeana.corelib.solr.entity.ConceptImpl in project corelib by europeana.

the class MockFullBean method setConcepts.

private static void setConcepts(FullBeanImpl bean) {
    List<ConceptImpl> concepts = new ArrayList<>();
    ConceptImpl concept = new ConceptImpl();
    concepts.add(concept);
    concept.setRelated(new String[] { "http://dbpedia.org/resource/Category:Agriculture" });
    concept.setExactMatch(new String[] { "http://bg.dbpedia.org/resource/Селско_стопанство", "http://ia.dbpedia.org/resource/Agricultura", "http://sl.dbpedia.org/resource/Kmetijstvo", "http://pnb.dbpedia.org/resource/وائی_بیجی", "http://el.dbpedia.org/resource/Γεωργία_(δραστηριότητα)" });
    concept.setPrefLabel(new HashMap<>());
    concept.getPrefLabel().put("no", new ArrayList<>());
    concept.getPrefLabel().get("no").add(MockBeanConstants.CONCEPT_PREF_LABEL_1);
    concept.getPrefLabel().put("de", new ArrayList<>());
    concept.getPrefLabel().get("de").add(MockBeanConstants.CONCEPT_PREF_LABEL_2);
    concept.setNote(new HashMap<>());
    concept.getNote().put("no", new ArrayList<>());
    concept.getNote().get("no").add(MockBeanConstants.CONCEPT_NOTE_1);
    concept.getNote().put("de", new ArrayList<>());
    concept.getNote().get("de").add(MockBeanConstants.CONCEPT_NOTE_2);
    concept.setAbout(MockBeanConstants.DC_CREATOR_4);
    bean.setConcepts(concepts);
}
Also used : ConceptImpl(eu.europeana.corelib.solr.entity.ConceptImpl) ArrayList(java.util.ArrayList)

Example 2 with ConceptImpl

use of eu.europeana.corelib.solr.entity.ConceptImpl in project metis-framework by europeana.

the class ConceptFieldInput method apply.

@Override
public ConceptImpl apply(Concept concept) {
    ConceptImpl conceptMongo = new ConceptImpl();
    conceptMongo.setAbout(concept.getAbout());
    if (concept.getChoiceList() != null) {
        for (Concept.Choice choice : concept.getChoiceList()) {
            applyChoice(choice, conceptMongo);
        }
    }
    return conceptMongo;
}
Also used : ConceptImpl(eu.europeana.corelib.solr.entity.ConceptImpl) Concept(eu.europeana.metis.schema.jibx.Concept)

Example 3 with ConceptImpl

use of eu.europeana.corelib.solr.entity.ConceptImpl in project metis-framework by europeana.

the class FullBeanUpdaterTest method testUpdate.

@Test
void testUpdate() {
    // Craete objects for execution
    final FullBeanUpdater updater = new FullBeanUpdater(null);
    @SuppressWarnings("unchecked") final MongoPropertyUpdater<FullBeanImpl> propertyUpdater = mock(MongoPropertyUpdater.class);
    // Make the call
    updater.update(propertyUpdater, null);
    // Test all the values
    testArrayPropertyUpdate(propertyUpdater, "title", FullBeanImpl::setTitle);
    testArrayPropertyUpdate(propertyUpdater, "year", FullBeanImpl::setYear);
    testArrayPropertyUpdate(propertyUpdater, "provider", FullBeanImpl::setProvider);
    testArrayPropertyUpdate(propertyUpdater, "language", FullBeanImpl::setLanguage);
    testArrayPropertyUpdate(propertyUpdater, "country", FullBeanImpl::setCountry);
    testArrayPropertyUpdate(propertyUpdater, "europeanaCollectionName", FullBeanImpl::setEuropeanaCollectionName);
    testObjectPropertyUpdate(propertyUpdater, "timestampCreated", FullBeanImpl::setTimestampCreated, new Date());
    testObjectPropertyUpdate(propertyUpdater, "timestampUpdated", FullBeanImpl::setTimestampUpdated, new Date());
    testObjectPropertyUpdate(propertyUpdater, "type", FullBeanImpl::setType, DocType.IMAGE.name());
    testObjectPropertyUpdate(propertyUpdater, "europeanaCompleteness", FullBeanImpl::setEuropeanaCompleteness, 5);
    this.<Place, Void>testReferencedEntitiesPropertyUpdate(propertyUpdater, "places", FullBeanImpl::setPlaces, null, PlaceImpl::new);
    this.<Agent, Void>testReferencedEntitiesPropertyUpdate(propertyUpdater, "agents", FullBeanImpl::setAgents, null, AgentImpl::new);
    this.<Timespan, Void>testReferencedEntitiesPropertyUpdate(propertyUpdater, "timespans", FullBeanImpl::setTimespans, null, TimespanImpl::new);
    this.<Concept, Void>testReferencedEntitiesPropertyUpdate(propertyUpdater, "concepts", FullBeanImpl::setConcepts, null, ConceptImpl::new);
    this.<ProvidedCHO, Void>testReferencedEntitiesPropertyUpdate(propertyUpdater, "providedCHOs", FullBeanImpl::setProvidedCHOs, null, ProvidedCHOImpl::new);
    this.<Aggregation, RootAboutWrapper>testReferencedEntitiesPropertyUpdate(propertyUpdater, "aggregations", FullBeanImpl::setAggregations, RootAboutWrapper.class, AggregationImpl::new);
    this.<Organization, RootAboutWrapper>testReferencedEntitiesPropertyUpdate(propertyUpdater, "organizations", FullBeanImpl::setOrganizations, null, OrganizationImpl::new);
    this.<EuropeanaAggregation, RootAboutWrapper>testReferencedEntityPropertyUpdate(propertyUpdater, "europeanaAggregation", FullBeanImpl::setEuropeanaAggregation, RootAboutWrapper.class, EuropeanaAggregationImpl::new);
    this.<Proxy, Void>testReferencedEntitiesPropertyUpdate(propertyUpdater, "proxies", FullBeanImpl::setProxies, null, ProxyImpl::new);
    this.<Service, Void>testReferencedEntitiesPropertyUpdate(propertyUpdater, "services", FullBeanImpl::setServices, null, ServiceImpl::new);
    this.<License, Void>testReferencedEntitiesPropertyUpdate(propertyUpdater, "licenses", FullBeanImpl::setLicenses, null, LicenseImpl::new);
    final FullBeanImpl fullBean = new FullBeanImpl();
    fullBean.setQualityAnnotations(new ArrayList<>());
    @SuppressWarnings("unchecked") final ArgumentCaptor<Function<FullBeanImpl, List<Object>>> getterCaptor = ArgumentCaptor.forClass(Function.class);
    verify(propertyUpdater, times(1)).updateObjectList(eq("qualityAnnotations"), getterCaptor.capture());
    assertSame(fullBean.getQualityAnnotations(), getterCaptor.getValue().apply(fullBean));
    // And that should be it.
    verifyNoMoreInteractions(propertyUpdater);
}
Also used : TimespanImpl(eu.europeana.corelib.solr.entity.TimespanImpl) Organization(eu.europeana.corelib.definitions.edm.entity.Organization) ProxyImpl(eu.europeana.corelib.solr.entity.ProxyImpl) EuropeanaAggregation(eu.europeana.corelib.definitions.edm.entity.EuropeanaAggregation) License(eu.europeana.corelib.definitions.edm.entity.License) EuropeanaAggregationImpl(eu.europeana.corelib.solr.entity.EuropeanaAggregationImpl) AggregationImpl(eu.europeana.corelib.solr.entity.AggregationImpl) LicenseImpl(eu.europeana.corelib.solr.entity.LicenseImpl) Aggregation(eu.europeana.corelib.definitions.edm.entity.Aggregation) EuropeanaAggregation(eu.europeana.corelib.definitions.edm.entity.EuropeanaAggregation) Function(java.util.function.Function) Proxy(eu.europeana.corelib.definitions.edm.entity.Proxy) ProvidedCHO(eu.europeana.corelib.definitions.edm.entity.ProvidedCHO) PlaceImpl(eu.europeana.corelib.solr.entity.PlaceImpl) Concept(eu.europeana.corelib.definitions.edm.entity.Concept) ConceptImpl(eu.europeana.corelib.solr.entity.ConceptImpl) Agent(eu.europeana.corelib.definitions.edm.entity.Agent) Timespan(eu.europeana.corelib.definitions.edm.entity.Timespan) EuropeanaAggregationImpl(eu.europeana.corelib.solr.entity.EuropeanaAggregationImpl) ServiceImpl(eu.europeana.corelib.solr.entity.ServiceImpl) Service(eu.europeana.corelib.definitions.edm.entity.Service) AgentImpl(eu.europeana.corelib.solr.entity.AgentImpl) Date(java.util.Date) RootAboutWrapper(eu.europeana.indexing.mongo.property.RootAboutWrapper) OrganizationImpl(eu.europeana.corelib.solr.entity.OrganizationImpl) FullBeanImpl(eu.europeana.corelib.solr.bean.impl.FullBeanImpl) ProvidedCHOImpl(eu.europeana.corelib.solr.entity.ProvidedCHOImpl) Place(eu.europeana.corelib.definitions.edm.entity.Place) Test(org.junit.jupiter.api.Test)

Example 4 with ConceptImpl

use of eu.europeana.corelib.solr.entity.ConceptImpl in project metis-framework by europeana.

the class ConceptFieldInputTest method testConcept.

@Test
void testConcept() {
    // create concept from jibx bindings
    Concept concept = new Concept();
    concept.setAbout("test about");
    ConceptImpl conceptImpl = new ConceptImpl();
    conceptImpl.setAbout(concept.getAbout());
    RecordDao mongoServerMock = mock(RecordDao.class);
    Datastore datastoreMock = mock(Datastore.class);
    @SuppressWarnings("unchecked") Query<ConceptImpl> queryMock = mock(Query.class);
    when(mongoServerMock.getDatastore()).thenReturn(datastoreMock);
    when(mongoServerMock.getDatastore()).thenReturn(datastoreMock);
    when(datastoreMock.find(ConceptImpl.class)).thenReturn(queryMock);
    when(datastoreMock.save(conceptImpl)).thenReturn(conceptImpl);
    when(queryMock.filter(Filters.eq("about", concept.getAbout()))).thenReturn(queryMock);
    Concept.Choice choice = new Concept.Choice();
    AltLabel altLabel = new AltLabel();
    Lang lang = new Lang();
    lang.setLang("en");
    altLabel.setLang(lang);
    altLabel.setString("test alt label");
    assertNotNull(altLabel);
    choice.setAltLabel(altLabel);
    choice.clearChoiceListSelect();
    Note note = new Note();
    note.setString("test note");
    assertNotNull(note);
    choice.setNote(note);
    choice.clearChoiceListSelect();
    PrefLabel prefLabel = new PrefLabel();
    prefLabel.setLang(lang);
    prefLabel.setString("test pred label");
    assertNotNull(prefLabel);
    choice.setPrefLabel(prefLabel);
    choice.clearChoiceListSelect();
    List<Concept.Choice> choiceList = new ArrayList<>();
    choiceList.add(choice);
    concept.setChoiceList(choiceList);
    // store in mongo
    ConceptImpl conceptMongo = new ConceptFieldInput().apply(concept);
    mongoServerMock.getDatastore().save(conceptMongo);
    assertEquals(concept.getAbout(), conceptMongo.getAbout());
    for (Concept.Choice choice2 : concept.getChoiceList()) {
        if (choice2.ifNote()) {
            assertEquals(choice2.getNote().getString(), conceptMongo.getNote().values().iterator().next().get(0));
        }
        if (choice2.ifAltLabel()) {
            assertTrue(conceptMongo.getAltLabel().containsKey(choice2.getAltLabel().getLang().getLang()));
            assertEquals(choice2.getAltLabel().getString(), conceptMongo.getAltLabel().values().iterator().next().get(0));
        }
        if (choice2.ifPrefLabel()) {
            assertTrue(conceptMongo.getPrefLabel().containsKey(choice2.getPrefLabel().getLang().getLang()));
            assertEquals(choice2.getPrefLabel().getString(), conceptMongo.getPrefLabel().values().iterator().next().get(0));
        }
    }
}
Also used : Concept(eu.europeana.metis.schema.jibx.Concept) ConceptImpl(eu.europeana.corelib.solr.entity.ConceptImpl) ArrayList(java.util.ArrayList) Lang(eu.europeana.metis.schema.jibx.LiteralType.Lang) RecordDao(eu.europeana.metis.mongo.dao.RecordDao) Datastore(dev.morphia.Datastore) AltLabel(eu.europeana.metis.schema.jibx.AltLabel) Note(eu.europeana.metis.schema.jibx.Note) PrefLabel(eu.europeana.metis.schema.jibx.PrefLabel) Test(org.junit.jupiter.api.Test)

Aggregations

ConceptImpl (eu.europeana.corelib.solr.entity.ConceptImpl)4 Concept (eu.europeana.metis.schema.jibx.Concept)2 ArrayList (java.util.ArrayList)2 Test (org.junit.jupiter.api.Test)2 Datastore (dev.morphia.Datastore)1 Agent (eu.europeana.corelib.definitions.edm.entity.Agent)1 Aggregation (eu.europeana.corelib.definitions.edm.entity.Aggregation)1 Concept (eu.europeana.corelib.definitions.edm.entity.Concept)1 EuropeanaAggregation (eu.europeana.corelib.definitions.edm.entity.EuropeanaAggregation)1 License (eu.europeana.corelib.definitions.edm.entity.License)1 Organization (eu.europeana.corelib.definitions.edm.entity.Organization)1 Place (eu.europeana.corelib.definitions.edm.entity.Place)1 ProvidedCHO (eu.europeana.corelib.definitions.edm.entity.ProvidedCHO)1 Proxy (eu.europeana.corelib.definitions.edm.entity.Proxy)1 Service (eu.europeana.corelib.definitions.edm.entity.Service)1 Timespan (eu.europeana.corelib.definitions.edm.entity.Timespan)1 FullBeanImpl (eu.europeana.corelib.solr.bean.impl.FullBeanImpl)1 AgentImpl (eu.europeana.corelib.solr.entity.AgentImpl)1 AggregationImpl (eu.europeana.corelib.solr.entity.AggregationImpl)1 EuropeanaAggregationImpl (eu.europeana.corelib.solr.entity.EuropeanaAggregationImpl)1