use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by infiniteautomation.
the class PermissionService method get.
/**
* Get a permission from the cache, load from db if necessary
* @param id
* @return
* @throws NotFoundException if permission with this ID not found
*/
public MangoPermission get(Integer id) throws NotFoundException {
Objects.requireNonNull(id);
MangoPermission permission = permissionCache.computeIfAbsent(id, this::loadPermission);
if (permission == null) {
throw new NotFoundException();
} else {
return permission.withId(id);
}
}
use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by infiniteautomation.
the class DataPointService method getReadPermission.
/**
* Get the read permission for this data point
*/
public MangoPermission getReadPermission(int dataPointId) throws NotFoundException, PermissionException {
PermissionHolder user = Common.getUser();
Integer permissionId = dao.getReadPermissionId(dataPointId);
if (permissionId == null) {
throw new NotFoundException();
}
MangoPermission read = permissionService.get(permissionId);
permissionService.ensurePermission(user, read);
return read;
}
use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by infiniteautomation.
the class EventInstanceDao method savePreRelationalData.
@Override
public void savePreRelationalData(EventInstanceVO existing, EventInstanceVO vo) {
MangoPermission readPermission = permissionService.findOrCreate(vo.getReadPermission());
vo.setReadPermission(readPermission);
}
use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by infiniteautomation.
the class EventInstanceDao method mapRecord.
@Override
@NonNull
public EventInstanceVO mapRecord(@NonNull Record record) {
EventInstanceVO event = new EventInstanceVO();
event.setId(record.get(table.id));
EventType type = createEventType(record);
event.setEventType(type);
event.setActiveTimestamp(record.get(table.activeTs));
event.setRtnApplicable(charToBool(record.get(table.rtnApplicable)));
event.setAlarmLevel(AlarmLevels.fromValue(record.get(table.alarmLevel)));
TranslatableMessage message = BaseDao.readTranslatableMessage(record.get(table.message));
if (message == null)
event.setMessage(new TranslatableMessage("common.noMessage"));
else
event.setMessage(message);
// Set the Return to normal
Long rtnTs = record.get(table.rtnTs);
if (rtnTs != null) {
// if(event.isActive()){ Probably don't need this
event.setRtnTimestamp(rtnTs);
event.setRtnCause(ReturnCause.fromValue(record.get(table.rtnCause)));
// }
}
MangoPermission read = new MangoPermission(record.get(table.readPermissionId));
event.supplyReadPermission(() -> read);
Long ackTs = record.get(table.ackTs);
if (ackTs != null) {
// Compute total time
event.setAcknowledgedTimestamp(ackTs);
Integer ackUserId = record.get(table.ackUserId);
if (ackUserId != null) {
event.setAcknowledgedByUserId(ackUserId);
event.setAcknowledgedByUsername(record.get(users.username));
}
event.setAlternateAckSource(BaseDao.readTranslatableMessage(record.get(table.alternateAckSource)));
}
event.setHasComments(record.get(commentCount) > 0);
return event;
}
use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by infiniteautomation.
the class MailingListDao method savePreRelationalData.
@Override
public void savePreRelationalData(MailingList existing, MailingList vo) {
MangoPermission readPermission = permissionService.findOrCreate(vo.getReadPermission());
vo.setReadPermission(readPermission);
MangoPermission editPermission = permissionService.findOrCreate(vo.getEditPermission());
vo.setEditPermission(editPermission);
}
Aggregations