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; }
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}); }
private void insertDataSource(final DataSourceVO<?> vo) { vo.setId( doInsert( "insert into dataSources (xid, name, dataSourceType, data) values (?,?,?,?)", new Object[] { vo.getXid(), vo.getName(), vo.getDefinition().getDataSourceTypeName(), SerializationHelper.writeObject(vo) }, new int[] {Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BLOB})); AuditEventType.raiseAddedEvent(AuditEventType.TYPE_DATA_SOURCE, vo); }
public int compare(DataSourceVO<?> ds1, DataSourceVO<?> ds2) { if (StringUtils.isBlank(ds1.getName())) return -1; return ds1.getName().compareToIgnoreCase(ds2.getName()); }