Пример #1
0
  public static void addState(final Session session, final State state) {
    final Date now = new Date();
    state.setCreationDate(now);
    state.setEditingDate(now);

    if (session != null) session.save(state);
  }
Пример #2
0
  private CrossSection commitCrossSection(
      final Session session, final String dbType, final GafProfile profile) throws Exception {
    final CrossSection crossSection = new CrossSection();

    final String protoName = String.format("%s", profile.getStation()); // $NON-NLS-1$

    final String name = m_sectionNameGenerator.createUniqueName(protoName);
    crossSection.setName(name);

    crossSection.setState(m_state);
    crossSection.setWaterBody(m_waterBody);

    crossSection.setDescription(StringUtils.EMPTY);

    crossSection.setStation(profile.getStation());

    /* Copy initial dates from state */
    crossSection.setCreationDate(m_state.getCreationDate());
    crossSection.setEditingDate(m_state.getEditingDate());
    crossSection.setEditingUser(m_state.getEditingUser());
    crossSection.setMeasurementDate(m_state.getMeasurementDate());

    final Geometry line = profile.createLine(dbType);
    crossSection.setLine(line);

    session.save(crossSection);

    return crossSection;
  }
Пример #3
0
  private void commitWaterLevel(final Session session) {
    if (m_waterlevelEvent != null) {
      m_waterlevelEvent.setCreationDate(m_state.getCreationDate());
      m_waterlevelEvent.setEditingDate(m_state.getEditingDate());
      m_waterlevelEvent.setEditingUser(m_state.getEditingUser());
      m_waterlevelEvent.setMeasurementDate(m_state.getMeasurementDate());

      m_waterlevelEvent.setWaterBody(m_waterBody);
      m_waterlevelEvent.setState(m_state);

      session.save(m_waterlevelEvent);
    }
  }
Пример #4
0
  @Override
  public void execute(final Session session) throws PdbConnectException {
    try {
      final GafProfile[] profiles = m_profiles.getProfiles();
      m_monitor.beginTask(Messages.getString("Gaf2Db.1"), profiles.length); // $NON-NLS-1$

      if (m_waterlevelEvent != null) m_state.getEvents().add(m_waterlevelEvent);

      addState(session, m_state);
      commitWaterLevel(session);

      for (final GafProfile profile : profiles) {
        m_monitor.subTask(
            String.format(Messages.getString("Gaf2Db.2"), profile.getStation())); // $NON-NLS-1$
        commitProfile(session, m_dbType, profile);
        m_monitor.worked(1);
      }

      m_monitor.subTask(Messages.getString("Gaf2Db.3")); // $NON-NLS-1$
    } catch (final Exception e) {
      e.printStackTrace();
      throw new PdbConnectException(Messages.getString("Gaf2Db.4"), e); // $NON-NLS-1$
    }
  }