예제 #1
0
  private boolean initializeDataSource(DataSourceVO<?> vo) {
    synchronized (runningDataSources) {
      // If the data source is already running, just quit.
      if (isDataSourceRunning(vo.getId())) return false;

      // Ensure that the data source is enabled.
      Assert.isTrue(vo.isEnabled());

      // Create and initialize the runtime version of the data source.
      DataSourceRT dataSource = vo.createDataSourceRT();
      dataSource.initialize();

      // Add it to the list of running data sources.
      runningDataSources.add(dataSource);

      // Add the enabled points to the data source.
      List<DataPointVO> dataSourcePoints = new DataPointDao().getDataPoints(vo.getId(), null);
      for (DataPointVO dataPoint : dataSourcePoints) {
        if (dataPoint.isEnabled()) startDataPoint(dataPoint);
      }

      LOG.info("Data source '" + vo.getName() + "' initialized");

      return true;
    }
  }
  @DwrPermission(admin = true)
  public ProcessResult getMaintenanceEvents() {
    ProcessResult response = new ProcessResult();
    final Translations translations = getTranslations();

    List<MaintenanceEventVO> events = new MaintenanceEventDao().getMaintenanceEvents();
    Collections.sort(
        events,
        new Comparator<MaintenanceEventVO>() {
          @Override
          public int compare(MaintenanceEventVO m1, MaintenanceEventVO m2) {
            return m1.getDescription()
                .translate(translations)
                .compareTo(m1.getDescription().translate(translations));
          }
        });
    response.addData("events", events);

    List<IntStringPair> dataSources = new ArrayList<IntStringPair>();
    for (DataSourceVO<?> ds : new DataSourceDao().getDataSources())
      dataSources.add(new IntStringPair(ds.getId(), ds.getName()));
    response.addData("dataSources", dataSources);

    return response;
  }
예제 #3
0
 @SuppressWarnings("unchecked")
 private void updateDataSource(final DataSourceVO<?> vo) {
   DataSourceVO<?> old = getDataSource(vo.getId());
   _updateDataSource(vo);
   AuditEventType.raiseChangedEvent(
       AuditEventType.TYPE_DATA_SOURCE, old, (ChangeComparable<DataSourceVO<?>>) vo);
 }
예제 #4
0
 public void _updateDataSource(DataSourceVO<?> vo) {
   ejt.update(
       "update dataSources set xid=?, name=?, dataSourceType=?, data=? where id=?",
       new Object[] {
         vo.getXid(),
         vo.getName(),
         vo.getDefinition().getDataSourceTypeName(),
         SerializationHelper.writeObject(vo),
         vo.getId()
       },
       new int[] {Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BLOB, Types.INTEGER});
 }
예제 #5
0
  public void saveDataSource(DataSourceVO<?> vo) {
    // If the data source is running, stop it.
    stopDataSource(vo.getId());

    // In case this is a new data source, we need to save to the database first so that it has a
    // proper id.
    new DataSourceDao().saveDataSource(vo);

    // If the data source is enabled, start it.
    if (vo.isEnabled()) {
      if (initializeDataSource(vo)) startDataSourcePolling(vo);
    }
  }
예제 #6
0
 private void startDataSourcePolling(DataSourceVO<?> vo) {
   DataSourceRT dataSource = getRunningDataSource(vo.getId());
   if (dataSource != null) dataSource.beginPolling();
 }
예제 #7
0
 public void saveDataSource(final DataSourceVO<?> vo) {
   // Decide whether to insert or update.
   if (vo.getId() == Common.NEW_ID) insertDataSource(vo);
   else updateDataSource(vo);
 }