Search in sources :

Example 16 with MangoPermission

use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by infiniteautomation.

the class EventDao method deletePostRelationalData.

public void deletePostRelationalData(EventInstance vo) {
    MangoPermission readPermission = vo.getReadPermission();
    permissionService.deletePermissions(readPermission);
}
Also used : MangoPermission(com.infiniteautomation.mango.permission.MangoPermission)

Example 17 with MangoPermission

use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by infiniteautomation.

the class DataSourceDao method deletePostRelationalData.

@Override
public void deletePostRelationalData(DataSourceVO vo) {
    // Clean permissions
    MangoPermission readPermission = vo.getReadPermission();
    MangoPermission editPermission = vo.getEditPermission();
    permissionService.deletePermissions(readPermission, editPermission);
    vo.getDefinition().deletePostRelationalData(vo);
}
Also used : MangoPermission(com.infiniteautomation.mango.permission.MangoPermission)

Example 18 with MangoPermission

use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by infiniteautomation.

the class EventDao method mapRecord.

public EventInstance mapRecord(Record record) {
    EventType type = createEventType(record);
    EventInstance event = new EventInstance(type, record.get(table.activeTs), charToBool(record.get(table.rtnApplicable)), AlarmLevels.fromValue(record.get(table.alarmLevel)), BaseDao.readTranslatableMessage(record.get(table.message)), null);
    event.setId(record.get(table.id));
    Long rtnTs = record.get(table.rtnTs);
    if (rtnTs != null)
        event.returnToNormal(rtnTs, 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) {
        event.setAcknowledgedTimestamp(ackTs);
        Integer ackUserId = record.get(table.ackUserId);
        if (ackUserId != null)
            event.setAcknowledgedByUsername(record.get(userTable.username));
        event.setAlternateAckSource(BaseDao.readTranslatableMessage(record.get(table.alternateAckSource)));
    }
    Integer cnt = (Integer) record.get("cnt");
    event.setHasComments(cnt != null && cnt > 0);
    return event;
}
Also used : EventInstance(com.serotonin.m2m2.rt.event.EventInstance) AuditEventType(com.serotonin.m2m2.rt.event.type.AuditEventType) MissingEventType(com.serotonin.m2m2.rt.event.type.MissingEventType) DataSourceEventType(com.serotonin.m2m2.rt.event.type.DataSourceEventType) EventType(com.serotonin.m2m2.rt.event.type.EventType) SystemEventType(com.serotonin.m2m2.rt.event.type.SystemEventType) DataPointEventType(com.serotonin.m2m2.rt.event.type.DataPointEventType) PublisherEventType(com.serotonin.m2m2.rt.event.type.PublisherEventType) MangoPermission(com.infiniteautomation.mango.permission.MangoPermission)

Example 19 with MangoPermission

use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by infiniteautomation.

the class EventHandlerDao method deletePostRelationalData.

@Override
public void deletePostRelationalData(AbstractEventHandlerVO vo) {
    vo.getDefinition().deletePostRelationalData(vo);
    // Clean permissions
    MangoPermission readPermission = vo.getReadPermission();
    MangoPermission editPermission = vo.getEditPermission();
    permissionService.deletePermissions(readPermission, editPermission);
}
Also used : MangoPermission(com.infiniteautomation.mango.permission.MangoPermission)

Example 20 with MangoPermission

use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by infiniteautomation.

the class EventHandlerDao method loadRelationalData.

@Override
public void loadRelationalData(AbstractEventHandlerVO vo) {
    vo.setEventTypes(getEventTypesForHandler(vo.getId()));
    vo.getDefinition().loadRelationalData(vo);
    // Populate permissions
    MangoPermission read = vo.getReadPermission();
    vo.supplyReadPermission(() -> permissionService.get(read.getId()));
    MangoPermission edit = vo.getEditPermission();
    vo.supplyEditPermission(() -> permissionService.get(edit.getId()));
}
Also used : MangoPermission(com.infiniteautomation.mango.permission.MangoPermission)

Aggregations

MangoPermission (com.infiniteautomation.mango.permission.MangoPermission)93 Role (com.serotonin.m2m2.vo.role.Role)22 HashSet (java.util.HashSet)21 Set (java.util.Set)18 HashMap (java.util.HashMap)13 NotFoundException (com.infiniteautomation.mango.util.exception.NotFoundException)12 PermissionDefinition (com.serotonin.m2m2.module.PermissionDefinition)11 JsonException (com.serotonin.json.JsonException)10 ValidationException (com.infiniteautomation.mango.util.exception.ValidationException)9 TranslatableJsonException (com.serotonin.m2m2.i18n.TranslatableJsonException)8 JsonValue (com.serotonin.json.type.JsonValue)7 ArrayList (java.util.ArrayList)7 JsonArray (com.serotonin.json.type.JsonArray)6 JsonObject (com.serotonin.json.type.JsonObject)6 User (com.serotonin.m2m2.vo.User)6 OutputStream (java.io.OutputStream)5 Test (org.junit.Test)5 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)4 IOException (java.io.IOException)4 ResultSet (java.sql.ResultSet)4