use of com.serotonin.m2m2.vo.permission.PermissionHolder in project ma-core-public by infiniteautomation.
the class AuditEventService method raiseSystemSettingAuditEvent.
private void raiseSystemSettingAuditEvent(int changeType, String auditEventType, PermissionHolder permissionHolder, String systemSettingKey, String key, Map<String, Object> context) {
User raisingUser = permissionHolder.getUser();
Object username = permissionHolder.getPermissionHolderName();
if (raisingUser != null) {
username = raisingUser.getUsername() + " (" + raisingUser.getId() + ")";
}
TranslatableMessage message = new TranslatableMessage(key, username, systemSettingKey);
AuditEventType type = new AuditEventType(auditEventType, changeType, Common.NEW_ID);
type.setRaisingUser(raisingUser);
Common.eventManager.raiseEvent(type, Common.timer.currentTimeMillis(), false, AuditEventType.getEventType(type.getAuditEventType()).getAlarmLevel(), message, context);
}
use of com.serotonin.m2m2.vo.permission.PermissionHolder in project ma-core-public by infiniteautomation.
the class AuditEventService method raiseVoAuditEvent.
/**
* Common raise event logic
*/
private void raiseVoAuditEvent(int changeType, String auditEventType, PermissionHolder permissionHolder, AbstractVO to, String key, Map<String, Object> context) {
User raisingUser = permissionHolder.getUser();
Object username = permissionHolder.getPermissionHolderName();
if (raisingUser != null) {
username = raisingUser.getUsername() + " (" + raisingUser.getId() + ")";
}
TranslatableMessage message = new TranslatableMessage(key, username, new TranslatableMessage(to.getTypeKey()), to.getName(), to.getXid());
AuditEventType type = new AuditEventType(auditEventType, changeType, to.getId());
type.setRaisingUser(raisingUser);
Common.eventManager.raiseEvent(type, Common.timer.currentTimeMillis(), false, AuditEventType.getEventType(type.getAuditEventType()).getAlarmLevel(), message, context);
}
use of com.serotonin.m2m2.vo.permission.PermissionHolder in project ma-core-public by infiniteautomation.
the class DataPointService method setValue.
/**
* Set the value of a data point
* @throws PermissionException - if the setting permission holder does not have set permission
* @throws RTException - if the point is not enabled and settable
*/
public void setValue(int id, PointValueTime valueTime, SetPointSource source) throws NotFoundException, PermissionException, RTException {
DataPointVO vo = get(id);
PermissionHolder user = Common.getUser();
ensureSetPermission(user, vo);
getRuntimeManager().setDataPointValue(vo.getId(), valueTime, source);
}
use of com.serotonin.m2m2.vo.permission.PermissionHolder in project ma-core-public by infiniteautomation.
the class DataPointService method getDataPoints.
/**
*/
public List<DataPointVO> getDataPoints(int dataSourceId) {
List<DataPointVO> points = dao.getDataPoints(dataSourceId);
PermissionHolder user = Common.getUser();
for (DataPointVO point : points) {
ensureReadPermission(user, point);
}
return points;
}
use of com.serotonin.m2m2.vo.permission.PermissionHolder in project ma-core-public by infiniteautomation.
the class DataPointService method update.
@Override
protected DataPointVO update(DataPointVO existing, DataPointVO vo) throws PermissionException, ValidationException {
PermissionHolder user = Common.getUser();
ensureEditPermission(user, existing);
vo.setId(existing.getId());
for (DataPointChangeDefinition def : changeDefinitions) {
def.preUpdate(vo);
}
ensureValid(existing, vo);
getRuntimeManager().stopDataPoint(vo.getId());
dao.update(existing, vo);
for (DataPointChangeDefinition def : changeDefinitions) {
def.postUpdate(vo);
}
if (vo.isEnabled()) {
List<AbstractPointEventDetectorVO> detectors = eventDetectorDao.getWithSource(vo.getId(), vo);
getRuntimeManager().startDataPoint(new DataPointWithEventDetectors(vo, detectors));
}
return vo;
}
Aggregations