Search in sources :

Example 1 with I18NDAORepository

use of org.n52.iceland.i18n.I18NDAORepository in project SOS by 52North.

the class HibernateFeatureQueryHandlerTest method setUp.

@Before
public void setUp() throws ConfigurationError {
    geometryHandler = new GeometryHandler();
    geometryHandler.setStorageEpsg(4326);
    geometryHandler.setStorage3DEpsg(4979);
    geometryHandler.setEpsgCodesWithNorthingFirstAxisOrder("2044-2045;2081-2083;2085-2086;2093;2096-2098;2105-2132;2169-2170;2176-2180;2193;2200;2206-2212;2319;" + "2320-2462;2523-2549;2551-2735;2738-2758;2935-2941;2953;3006-3030;3034-3035;3058-3059;3068;" + "3114-3118;3126-3138;3300-3301;3328-3335;3346;3350-3352;3366;3416;4001-4999;20004-20032;" + "20064-20092;21413-21423;21473-21483;21896-21899;22171;22181-22187;22191-22197;25884;27205-27232;" + "27391-27398;27492;28402-28432;28462-28492;30161-30179;30800;31251-31259;31275-31279;31281-31290;" + "31466-31700");
    geometryHandler.setDatasourceNorthingFirst(false);
    contentCacheController.setPersistenceStrategy(Mockito.mock(ContentCachePersistenceStrategy.class));
    contentCacheController.setCacheFactory(Mockito.mock(ContentCacheFactory.class));
    contentCacheController.setCompleteCacheUpdateFactory(Mockito.mock(CompleteCacheUpdateFactory.class));
    contentCacheController.setCache(cache);
    featureQueryHandler = new HibernateFeatureQueryHandler();
    featureQueryHandler.setGeometryHandler(geometryHandler);
    featureQueryHandler.setContentCacheController(contentCacheController);
    featureQueryHandler.setI18NDAORepository(i18NDAORepository);
}
Also used : CompleteCacheUpdateFactory(org.n52.iceland.cache.ctrl.CompleteCacheUpdateFactory) GeometryHandler(org.n52.sos.util.GeometryHandler) ContentCachePersistenceStrategy(org.n52.iceland.cache.ContentCachePersistenceStrategy) ContentCacheFactory(org.n52.iceland.cache.ctrl.ContentCacheFactory) Before(org.junit.Before)

Example 2 with I18NDAORepository

use of org.n52.iceland.i18n.I18NDAORepository in project SOS by 52North.

the class CacheQueryTest method fillObservations.

@BeforeClass
public static void fillObservations() throws OwsExceptionReport {
    Session session = getSession();
    Transaction transaction = null;
    try {
        transaction = session.beginTransaction();
        I18NDAORepository i18NDAORepository = new I18NDAORepository();
        DaoFactory daoFactory = new DaoFactory();
        daoFactory.setI18NDAORepository(i18NDAORepository);
        HibernateObservationBuilder b = new HibernateObservationBuilder(session, daoFactory);
        DateTime begin = new DateTime();
        int numObs = 10000;
        for (int i = 0; i < numObs; ++i) {
            if (i % 50 == 0) {
                LOGGER.debug(LOG_TEMPLATE, i, numObs);
                session.flush();
                session.clear();
            }
            b.createObservation(String.valueOf(i), begin.plusHours(i));
        }
        LOGGER.debug(LOG_TEMPLATE, numObs, numObs);
        session.flush();
        transaction.commit();
    } catch (HibernateException | CodedException he) {
        if (transaction != null) {
            transaction.rollback();
        }
        throw he;
    } finally {
        returnSession(session);
    }
}
Also used : Transaction(org.hibernate.Transaction) CodedException(org.n52.shetland.ogc.ows.exception.CodedException) HibernateException(org.hibernate.HibernateException) I18NDAORepository(org.n52.iceland.i18n.I18NDAORepository) HibernateObservationBuilder(org.n52.sos.ds.hibernate.util.HibernateObservationBuilder) DateTime(org.joda.time.DateTime) Session(org.hibernate.Session) BeforeClass(org.junit.BeforeClass)

Example 3 with I18NDAORepository

use of org.n52.iceland.i18n.I18NDAORepository in project SOS by 52North.

the class TemporalRestrictionTest method getBuilder.

protected HibernateObservationBuilder getBuilder(Session session) throws OwsExceptionReport {
    I18NDAORepository i18NDAORepository = new I18NDAORepository();
    DaoFactory daoFactory = new DaoFactory();
    daoFactory.setI18NDAORepository(i18NDAORepository);
    return new HibernateObservationBuilder(session, daoFactory);
}
Also used : I18NDAORepository(org.n52.iceland.i18n.I18NDAORepository) DaoFactory(org.n52.sos.ds.hibernate.dao.DaoFactory)

Example 4 with I18NDAORepository

use of org.n52.iceland.i18n.I18NDAORepository in project SOS by 52North.

the class AbstractInsertDAOTest method setUp.

public void setUp() throws OwsExceptionReport, ConverterException, EncodingException {
    GEOMETRY.setSRID(4326);
    SOSHibernateSessionHolder holder = new SOSHibernateSessionHolder();
    holder.setConnectionProvider(this);
    daoFactory.setSweHelper(new SweHelper());
    SosHelper sosHelper = new SosHelper();
    sosHelper.setServiceURL(URI.create("http://test.org"));
    daoFactory.setSosHelper(sosHelper);
    GeometryHandler geometryHandler = new GeometryHandler();
    initGeometryHandler(geometryHandler);
    daoFactory.setGeometryHandler(geometryHandler);
    HibernateFeatureQueryHandler featureQueryHandler = new HibernateFeatureQueryHandler();
    featureQueryHandler.setDaoFactory(daoFactory);
    featureQueryHandler.setI18NDAORepository(i18NDAORepository);
    featureQueryHandler.setGeometryHandler(geometryHandler);
    featureQueryHandler.setContentCacheController(contentCacheController);
    daoFactory.setFeatureQueryHandler(featureQueryHandler);
    daoFactory.setDecoderRepository(decoderRepository);
    daoFactory.setEncoderRepository(encoderRepository);
    daoFactory.setI18NDAORepository(i18NDAORepository);
    daoFactory.setSweHelper(initSweHelper());
    cacheFeeder.setConnectionProvider(holder);
    cacheFeeder.setI18NDAORepository(i18NDAORepository);
    cacheFeeder.setGeometryHandler(geometryHandler);
    initEncoder();
    initDecoder();
    bindingRepository.setComponentFactories(Optional.empty());
    bindingRepository.setComponents(Optional.empty());
    additionalObservationCreatorRepository.setComponentFactories(Optional.empty());
    additionalObservationCreatorRepository.setComponents(Optional.empty());
    contentCacheController.setPersistenceStrategy(Mockito.mock(ContentCachePersistenceStrategy.class));
    contentCacheController.setCacheFactory(Mockito.mock(ContentCacheFactory.class));
    contentCacheController.setCompleteCacheUpdateFactory(Mockito.mock(CompleteCacheUpdateFactory.class));
    contentCacheController.setCache(cache);
    cache.setSupportedTypeRepository(Mockito.mock(SupportedTypeRepository.class));
    i18NDAORepository.init();
    decoderRepository.init();
    converterRepository.init();
    factoryRepository.init();
    bindingRepository.init();
    additionalObservationCreatorRepository.init();
    DefaultContentModificationListener defaultContentModificationListener = new DefaultContentModificationListener(cacheFeeder, contentCacheController);
    defaultContentModificationListener.setConverterRepository(converterRepository);
    serviceEventBus.register(defaultContentModificationListener);
    ctx = new HibernateProcedureCreationContext(serviceMetadataRepository, decoderRepository, factoryRepository, i18NDAORepository, daoFactory, converterRepository, null, bindingRepository, null, contentCacheController, Mockito.mock(ProcedureDescriptionSettings.class));
    observationCtx = new OmObservationCreatorContext(serviceMetadataRepository, i18NDAORepository, daoFactory, new ProfileHanlderMock(), additionalObservationCreatorRepository, contentCacheController, featureQueryHandler, converterRepository, factoryRepository, geometryHandler, decoderRepository, null, bindingRepository);
    observationCtx.setDefaultLanguage("eng");
    Session session = null;
    try {
        session = getSession();
        HibernateMetadataCache.init(session);
    } finally {
        returnSession(session);
    }
    initDaos();
}
Also used : CompleteCacheUpdateFactory(org.n52.iceland.cache.ctrl.CompleteCacheUpdateFactory) GeometryHandler(org.n52.sos.util.GeometryHandler) OmObservationCreatorContext(org.n52.sos.ds.hibernate.util.observation.OmObservationCreatorContext) ContentCachePersistenceStrategy(org.n52.iceland.cache.ContentCachePersistenceStrategy) HibernateProcedureCreationContext(org.n52.sos.ds.hibernate.util.procedure.HibernateProcedureCreationContext) SupportedTypeRepository(org.n52.iceland.coding.SupportedTypeRepository) DefaultContentModificationListener(org.n52.sos.cache.ctrl.DefaultContentModificationListener) SOSHibernateSessionHolder(org.n52.series.db.da.sos.SOSHibernateSessionHolder) SosHelper(org.n52.sos.util.SosHelper) ContentCacheFactory(org.n52.iceland.cache.ctrl.ContentCacheFactory) SweHelper(org.n52.svalbard.util.SweHelper) Session(org.hibernate.Session)

Example 5 with I18NDAORepository

use of org.n52.iceland.i18n.I18NDAORepository in project SOS by 52North.

the class ObservablePropertyDAOTest method save.

protected Map<String, PhenomenonEntity> save(List<AbstractPhenomenon> abstractPhenomenons, Session session) {
    I18NDAORepository i18NDAORepository = new I18NDAORepository();
    DaoFactory daoFactory = new DaoFactory();
    daoFactory.setI18NDAORepository(i18NDAORepository);
    ObservablePropertyDAO dao = daoFactory.getObservablePropertyDAO();
    Collection<PhenomenonEntity> savedObservableProperties = dao.getOrInsertObservableProperty(abstractPhenomenons, session);
    return asMap(savedObservableProperties);
}
Also used : ObservablePropertyDAO(org.n52.sos.ds.hibernate.dao.ObservablePropertyDAO) PhenomenonEntity(org.n52.series.db.beans.PhenomenonEntity) I18NDAORepository(org.n52.iceland.i18n.I18NDAORepository) DaoFactory(org.n52.sos.ds.hibernate.dao.DaoFactory)

Aggregations

I18NDAORepository (org.n52.iceland.i18n.I18NDAORepository)5 DaoFactory (org.n52.sos.ds.hibernate.dao.DaoFactory)4 Session (org.hibernate.Session)3 HibernateException (org.hibernate.HibernateException)2 Transaction (org.hibernate.Transaction)2 DateTime (org.joda.time.DateTime)2 Before (org.junit.Before)2 ContentCachePersistenceStrategy (org.n52.iceland.cache.ContentCachePersistenceStrategy)2 CompleteCacheUpdateFactory (org.n52.iceland.cache.ctrl.CompleteCacheUpdateFactory)2 ContentCacheFactory (org.n52.iceland.cache.ctrl.ContentCacheFactory)2 GeometryHandler (org.n52.sos.util.GeometryHandler)2 BeforeClass (org.junit.BeforeClass)1 SupportedTypeRepository (org.n52.iceland.coding.SupportedTypeRepository)1 PhenomenonEntity (org.n52.series.db.beans.PhenomenonEntity)1 SOSHibernateSessionHolder (org.n52.series.db.da.sos.SOSHibernateSessionHolder)1 CodedException (org.n52.shetland.ogc.ows.exception.CodedException)1 DefaultContentModificationListener (org.n52.sos.cache.ctrl.DefaultContentModificationListener)1 ObservablePropertyDAO (org.n52.sos.ds.hibernate.dao.ObservablePropertyDAO)1 HibernateObservationBuilder (org.n52.sos.ds.hibernate.util.HibernateObservationBuilder)1 OmObservationCreatorContext (org.n52.sos.ds.hibernate.util.observation.OmObservationCreatorContext)1