use of com.serotonin.m2m2.module.DataPointChangeDefinition in project ma-core-public by infiniteautomation.
the class DataPointDao method deleteDataPoints.
public void deleteDataPoints(final int dataSourceId) {
List<DataPointVO> old = getDataPoints(dataSourceId, null, true);
for (DataPointVO dp : old) {
for (DataPointChangeDefinition def : ModuleRegistry.getDefinitions(DataPointChangeDefinition.class)) def.beforeDelete(dp.getId());
}
getTransactionTemplate().execute(new TransactionCallbackWithoutResult() {
@SuppressWarnings("synthetic-access")
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
List<Integer> pointIds = queryForList("select id from dataPoints where dataSourceId=?", new Object[] { dataSourceId }, Integer.class);
if (pointIds.size() > 0)
deleteDataPointImpl(createDelimitedList(new HashSet<>(pointIds), ",", null));
}
});
for (DataPointVO dp : old) {
for (DataPointChangeDefinition def : ModuleRegistry.getDefinitions(DataPointChangeDefinition.class)) def.afterDelete(dp.getId());
AuditEventType.raiseDeletedEvent(AuditEventType.TYPE_DATA_POINT, dp);
this.countMonitor.decrement();
}
}
use of com.serotonin.m2m2.module.DataPointChangeDefinition in project ma-core-public by infiniteautomation.
the class DataPointDao method insertDataPoint.
void insertDataPoint(final DataPointVO dp) {
for (DataPointChangeDefinition def : ModuleRegistry.getDefinitions(DataPointChangeDefinition.class)) def.beforeInsert(dp);
// Create a default text renderer
if (dp.getTextRenderer() == null)
dp.defaultTextRenderer();
dp.setId(ejt.doInsert(//
"insert into dataPoints (xid, dataSourceId, name, deviceName, enabled, pointFolderId, loggingType, " + //
"intervalLoggingPeriodType, intervalLoggingPeriod, intervalLoggingType, tolerance, " + //
"purgeOverride, purgeType, purgePeriod, defaultCacheSize, discardExtremeValues, " + //
"engineeringUnits, readPermission, setPermission, templateId, rollup, dataTypeId, data) " + //
"values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", new Object[] { dp.getXid(), dp.getDataSourceId(), dp.getName(), dp.getDeviceName(), boolToChar(dp.isEnabled()), dp.getPointFolderId(), dp.getLoggingType(), dp.getIntervalLoggingPeriodType(), dp.getIntervalLoggingPeriod(), dp.getIntervalLoggingType(), dp.getTolerance(), boolToChar(dp.isPurgeOverride()), dp.getPurgeType(), dp.getPurgePeriod(), dp.getDefaultCacheSize(), boolToChar(dp.isDiscardExtremeValues()), dp.getEngineeringUnits(), dp.getReadPermission(), dp.getSetPermission(), dp.getTemplateId(), dp.getRollup(), dp.getPointLocator().getDataTypeId(), //
SerializationHelper.writeObject(dp) }, new int[] { Types.VARCHAR, Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.CHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.DOUBLE, Types.CHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.CHAR, Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.BINARY }));
// Save the relational information.
saveRelationalData(dp, true);
AuditEventType.raiseAddedEvent(AuditEventType.TYPE_DATA_POINT, dp);
for (DataPointChangeDefinition def : ModuleRegistry.getDefinitions(DataPointChangeDefinition.class)) def.afterInsert(dp);
this.countMonitor.increment();
}
use of com.serotonin.m2m2.module.DataPointChangeDefinition in project ma-core-public by infiniteautomation.
the class DataPointDao method deleteDataPoint.
public void deleteDataPoint(final int dataPointId) {
DataPointVO dp = getDataPoint(dataPointId);
if (dp != null) {
for (DataPointChangeDefinition def : ModuleRegistry.getDefinitions(DataPointChangeDefinition.class)) def.beforeDelete(dataPointId);
getTransactionTemplate().execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
deleteDataPointImpl(Integer.toString(dataPointId));
}
});
for (DataPointChangeDefinition def : ModuleRegistry.getDefinitions(DataPointChangeDefinition.class)) def.afterDelete(dataPointId);
AuditEventType.raiseDeletedEvent(AuditEventType.TYPE_DATA_POINT, dp);
countMonitor.decrement();
}
}
use of com.serotonin.m2m2.module.DataPointChangeDefinition in project ma-core-public by infiniteautomation.
the class DataPointDao method updateDataPoint.
void updateDataPoint(final DataPointVO dp) {
for (DataPointChangeDefinition def : ModuleRegistry.getDefinitions(DataPointChangeDefinition.class)) def.beforeUpdate(dp);
DataPointVO old = getDataPoint(dp.getId());
// If have a new data type we will wipe our history
if (old.getPointLocator().getDataTypeId() != dp.getPointLocator().getDataTypeId())
Common.databaseProxy.newPointValueDao().deletePointValues(dp.getId());
// Save the VO information.
updateDataPointShallow(dp);
AuditEventType.raiseChangedEvent(AuditEventType.TYPE_DATA_POINT, old, dp);
// Save the relational information.
saveRelationalData(dp, false);
for (DataPointChangeDefinition def : ModuleRegistry.getDefinitions(DataPointChangeDefinition.class)) def.afterUpdate(dp);
}
Aggregations