use of org.n52.sos.ds.hibernate.util.HibernateObservationBuilder 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);
}
}
use of org.n52.sos.ds.hibernate.util.HibernateObservationBuilder 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);
}
use of org.n52.sos.ds.hibernate.util.HibernateObservationBuilder in project SOS by 52North.
the class TemporalRestrictionPeriodInstantTest method createScenario.
@Override
public TimeInstant createScenario(Session session) throws OwsExceptionReport {
Transaction transaction = null;
try {
DateTime ref = new DateTime(DateTimeZone.UTC).minusDays(1);
transaction = session.beginTransaction();
HibernateObservationBuilder b = getBuilder(session);
b.createObservation(TemporalRestrictionTest.Identifier.PI_BEGUN_BY_ID, ref, ref.plus(1));
b.createObservation(TemporalRestrictionTest.Identifier.PI_ENDED_BY_ID, ref.minus(1), ref);
b.createObservation(TemporalRestrictionTest.Identifier.PI_AFTER_ID, ref.plus(1), ref.plus(2));
b.createObservation(TemporalRestrictionTest.Identifier.PI_BEFORE_ID, ref.minus(2), ref.minus(1));
b.createObservation(TemporalRestrictionTest.Identifier.PI_CONTAINS_ID, ref.minus(1), ref.plus(1));
session.flush();
transaction.commit();
return new TimeInstant(ref);
} catch (HibernateException he) {
if (transaction != null) {
transaction.rollback();
}
throw he;
}
}
use of org.n52.sos.ds.hibernate.util.HibernateObservationBuilder in project SOS by 52North.
the class ObservationDAOTest method fillObservations.
@Before
public void fillObservations() throws OwsExceptionReport {
Session session = getSession();
HibernateMetadataCache.init(session);
Transaction transaction = null;
try {
I18NDAORepository i18NDAORepository = new I18NDAORepository();
DaoFactory daoFactory = new DaoFactory();
daoFactory.setI18NDAORepository(i18NDAORepository);
observationDAO = daoFactory.getObservationDAO();
offeringDAO = daoFactory.getOfferingDAO();
transaction = session.beginTransaction();
HibernateObservationBuilder b;
b = new HibernateObservationBuilder(session, daoFactory);
DateTime begin = DateTimeHelper.parseIsoString2DateTime("2019-10-01T12:00:00.000Z");
for (int i = 0; i < 50; ++i) {
b.createObservation(String.valueOf(i), begin.plusHours(i));
}
session.flush();
transaction.commit();
} catch (HibernateException he) {
if (transaction != null) {
transaction.rollback();
}
throw he;
} finally {
returnSession(session);
}
}
use of org.n52.sos.ds.hibernate.util.HibernateObservationBuilder in project SOS by 52North.
the class TemporalRestrictionInstantPeriodTest method createScenario.
@Override
protected TimePeriod createScenario(Session session) throws OwsExceptionReport {
Transaction transaction = null;
try {
DateTime ref = new DateTime(DateTimeZone.UTC).minusDays(1);
transaction = session.beginTransaction();
HibernateObservationBuilder b = getBuilder(session);
b.createObservation(TemporalRestrictionTest.Identifier.IP_BEFORE_ID, ref.minus(2));
b.createObservation(TemporalRestrictionTest.Identifier.IP_BEGINS_ID, ref.minus(1));
b.createObservation(TemporalRestrictionTest.Identifier.IP_DURING_ID, ref);
b.createObservation(TemporalRestrictionTest.Identifier.IP_ENDS_ID, ref.plus(1));
b.createObservation(TemporalRestrictionTest.Identifier.IP_AFTER_ID, ref.plus(2));
session.flush();
transaction.commit();
return new TimePeriod(ref.minus(1), ref.plus(1));
} catch (HibernateException he) {
if (transaction != null) {
transaction.rollback();
}
throw he;
}
}
Aggregations