use of com.serotonin.m2m2.vo.permission.Permissions in project ma-core-public by infiniteautomation.
the class DataPointDao method copy.
@Override
public int copy(final int existingId, final String newXid, final String newName) {
TransactionCallback<Integer> callback = new TransactionCallback<Integer>() {
@Override
public Integer doInTransaction(TransactionStatus status) {
DataPointVO dataPoint = get(existingId);
// Copy the vo
DataPointVO copy = dataPoint.copy();
copy.setId(Common.NEW_ID);
copy.setXid(generateUniqueXid());
copy.setName(dataPoint.getName());
copy.setDeviceName(dataPoint.getDeviceName());
copy.setDataSourceId(dataPoint.getDataSourceId());
copy.setEnabled(dataPoint.isEnabled());
copy.getComments().clear();
// Copy the event detectors
List<AbstractEventDetectorVO<?>> existing = EventDetectorDao.instance.getWithSourceId(EventType.EventTypeNames.DATA_POINT, dataPoint.getId());
List<AbstractPointEventDetectorVO<?>> detectors = new ArrayList<AbstractPointEventDetectorVO<?>>(existing.size());
for (AbstractEventDetectorVO<?> ed : existing) {
AbstractPointEventDetectorVO<?> ped = (AbstractPointEventDetectorVO<?>) ed;
ped.setId(Common.NEW_ID);
ped.njbSetDataPoint(copy);
}
copy.setEventDetectors(detectors);
Common.runtimeManager.saveDataPoint(copy);
// Copy permissions.
return copy.getId();
}
};
return getTransactionTemplate().execute(callback);
}
Aggregations