Search in sources :

Example 21 with MangoPermission

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

the class EventHandlerDao method savePreRelationalData.

@Override
public void savePreRelationalData(AbstractEventHandlerVO existing, AbstractEventHandlerVO vo) {
    MangoPermission readPermission = permissionService.findOrCreate(vo.getReadPermission());
    vo.setReadPermission(readPermission);
    MangoPermission editPermission = permissionService.findOrCreate(vo.getEditPermission());
    vo.setEditPermission(editPermission);
    vo.getDefinition().savePreRelationalData(existing, vo);
}
Also used : MangoPermission(com.infiniteautomation.mango.permission.MangoPermission)

Example 22 with MangoPermission

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

the class FileStoreDao method savePreRelationalData.

@Override
public void savePreRelationalData(FileStore existing, FileStore vo) {
    MangoPermission readPermission = permissionService.findOrCreate(vo.getReadPermission());
    vo.setReadPermission(readPermission);
    MangoPermission writePermission = permissionService.findOrCreate(vo.getWritePermission());
    vo.setWritePermission(writePermission);
}
Also used : MangoPermission(com.infiniteautomation.mango.permission.MangoPermission)

Example 23 with MangoPermission

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

the class FileStoreDao method mapRecord.

@Override
public FileStore mapRecord(Record record) {
    FileStore result = new FileStore();
    result.setId(record.get(table.id));
    result.setXid(record.get(table.xid));
    result.setName(record.get(table.name));
    result.setReadPermission(new MangoPermission(record.get(table.readPermissionId)));
    result.setWritePermission(new MangoPermission(record.get(table.writePermissionId)));
    return result;
}
Also used : FileStore(com.serotonin.m2m2.vo.FileStore) MangoPermission(com.infiniteautomation.mango.permission.MangoPermission)

Example 24 with MangoPermission

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

the class JsonDataDao method mapRecord.

@Override
public JsonDataVO mapRecord(Record record) {
    JsonDataVO vo = new JsonDataVO();
    vo.setId(record.get(table.id));
    vo.setXid(record.get(table.xid));
    vo.setName(record.get(table.name));
    vo.setJsonData(extractDataFromObject(record.get(table.data)));
    vo.setReadPermission(new MangoPermission(record.get(table.readPermissionId)));
    vo.setEditPermission(new MangoPermission(record.get(table.editPermissionId)));
    return vo;
}
Also used : JsonDataVO(com.serotonin.m2m2.vo.json.JsonDataVO) MangoPermission(com.infiniteautomation.mango.permission.MangoPermission)

Example 25 with MangoPermission

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

the class ConfigurationExportData method createExportDataMap.

/**
 * Get a map of desired export data.
 *
 * @param exportElements if null full export is returned
 */
public static Map<String, Object> createExportDataMap(String[] exportElements) {
    if (exportElements == null)
        exportElements = getAllExportNames();
    Map<String, Object> data = new LinkedHashMap<>();
    if (ArrayUtils.contains(exportElements, DATA_SOURCES))
        data.put(DATA_SOURCES, DataSourceDao.getInstance().getAll());
    if (ArrayUtils.contains(exportElements, DATA_POINTS))
        data.put(DATA_POINTS, DataPointDao.getInstance().getAll());
    if (ArrayUtils.contains(exportElements, USERS))
        data.put(USERS, UserDao.getInstance().getAll());
    if (ArrayUtils.contains(exportElements, MAILING_LISTS))
        data.put(MAILING_LISTS, MailingListDao.getInstance().getAll());
    if (ArrayUtils.contains(exportElements, PUBLISHERS))
        data.put(PUBLISHERS, PublisherDao.getInstance().getAll());
    if (ArrayUtils.contains(exportElements, PUBLISHED_POINTS))
        data.put(PUBLISHED_POINTS, Common.getBean(PublishedPointDao.class).getAll());
    if (ArrayUtils.contains(exportElements, EVENT_HANDLERS))
        data.put(EVENT_HANDLERS, EventHandlerDao.getInstance().getAll());
    if (ArrayUtils.contains(exportElements, SYSTEM_SETTINGS))
        data.put(SYSTEM_SETTINGS, SystemSettingsDao.getInstance().getAllSystemSettingsAsCodes());
    if (ArrayUtils.contains(exportElements, VIRTUAL_SERIAL_PORTS))
        data.put(VIRTUAL_SERIAL_PORTS, VirtualSerialPortConfigDao.getInstance().getAll());
    if (ArrayUtils.contains(exportElements, JSON_DATA))
        data.put(JSON_DATA, JsonDataDao.getInstance().getAll());
    if (ArrayUtils.contains(exportElements, ROLES))
        data.put(ROLES, Common.getBean(RoleDao.class).getAll());
    if (ArrayUtils.contains(exportElements, PERMISSIONS)) {
        List<Map<String, MangoPermission>> permissions = new ArrayList<>();
        for (PermissionDefinition def : ModuleRegistry.getPermissionDefinitions().values()) {
            Map<String, MangoPermission> toExport = new HashMap<>();
            toExport.put(def.getPermissionTypeName(), def.getPermission());
            permissions.add(toExport);
        }
        data.put(PERMISSIONS, permissions);
    }
    for (EmportDefinition def : ModuleRegistry.getDefinitions(EmportDefinition.class)) {
        if (ArrayUtils.contains(exportElements, def.getElementId()))
            data.put(def.getElementId(), def.getExportData());
    }
    return data;
}
Also used : PermissionDefinition(com.serotonin.m2m2.module.PermissionDefinition) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) PublishedPointDao(com.serotonin.m2m2.db.dao.PublishedPointDao) LinkedHashMap(java.util.LinkedHashMap) EmportDefinition(com.serotonin.m2m2.module.EmportDefinition) RoleDao(com.serotonin.m2m2.db.dao.RoleDao) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) 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