Search in sources :

Example 86 with MangoPermission

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

the class DataSourceDao method savePreRelationalData.

@Override
public void savePreRelationalData(DataSourceVO existing, DataSourceVO 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 87 with MangoPermission

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

the class DataPointDao method loadRelationalData.

/**
 * Loads the event detectors, point comments, tags data source and template name
 * Used by getFull()
 */
@Override
public void loadRelationalData(DataPointVO vo) {
    vo.supplyTags(() -> dataPointTagsDao.getTagsForDataPointId(vo.getId()));
    // Populate permissions
    MangoPermission read = vo.getReadPermission();
    vo.supplyReadPermission(() -> permissionService.get(read.getId()));
    MangoPermission edit = vo.getEditPermission();
    vo.supplyEditPermission(() -> permissionService.get(edit.getId()));
    MangoPermission set = vo.getSetPermission();
    vo.supplySetPermission(() -> permissionService.get(set.getId()));
    DataSourceDefinition<? extends DataSourceVO> def = ModuleRegistry.getDataSourceDefinition(vo.getPointLocator().getDataSourceType());
    if (def != null) {
        def.loadRelationalData(vo);
    }
}
Also used : MangoPermission(com.infiniteautomation.mango.permission.MangoPermission)

Example 88 with MangoPermission

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

the class DataPointDao method savePreRelationalData.

@Override
public void savePreRelationalData(DataPointVO existing, DataPointVO vo) {
    // Shall we generate a new series ID?
    if (vo.getSeriesId() <= 0) {
        if (existing == null) {
            int seriesId = insertNewTimeSeries();
            vo.setSeriesId(seriesId);
        } else {
            vo.setSeriesId(existing.getSeriesId());
        }
    }
    MangoPermission readPermission = permissionService.findOrCreate(vo.getReadPermission());
    vo.setReadPermission(readPermission);
    MangoPermission editPermission = permissionService.findOrCreate(vo.getEditPermission());
    vo.setEditPermission(editPermission);
    MangoPermission setPermission = permissionService.findOrCreate(vo.getSetPermission());
    vo.setSetPermission(setPermission);
}
Also used : MangoPermission(com.infiniteautomation.mango.permission.MangoPermission)

Example 89 with MangoPermission

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

the class DataPointDao method mapRecord.

@Override
public DataPointVO mapRecord(Record record) {
    int id = record.get(table.id);
    String xid = record.get(table.xid);
    String name = record.get(table.name);
    DataPointVO dp = (DataPointVO) SerializationHelper.readObjectInContextFromArray(record.get(table.data));
    dp.setId(id);
    dp.setXid(xid);
    dp.setName(name);
    dp.setDataSourceId(record.get(table.dataSourceId));
    dp.setDeviceName(record.get(table.deviceName));
    dp.setEnabled(charToBool(record.get(table.enabled)));
    dp.setLoggingType(record.get(table.loggingType));
    dp.setIntervalLoggingPeriodType(record.get(table.intervalLoggingPeriodType));
    dp.setIntervalLoggingPeriod(record.get(table.intervalLoggingPeriod));
    dp.setIntervalLoggingType(record.get(table.intervalLoggingType));
    dp.setTolerance(record.get(table.tolerance));
    dp.setPurgeOverride(charToBool(record.get(table.purgeOverride)));
    dp.setPurgeType(record.get(table.purgeType));
    dp.setPurgePeriod(record.get(table.purgePeriod));
    dp.setDefaultCacheSize(record.get(table.defaultCacheSize));
    dp.setDiscardExtremeValues(charToBool(record.get(table.discardExtremeValues)));
    dp.setEngineeringUnits(record.get(table.engineeringUnits));
    dp.setRollup(record.get(table.rollup));
    // // read and discard dataTypeId
    // record.get(table.xyz);
    // // read and discard settable boolean
    // record.get(table.xyz);
    dp.setData(extractDataFromObject(record.get(table.jsonData)));
    dp.setSeriesId(record.get(table.seriesId));
    MangoPermission read = new MangoPermission(record.get(table.readPermissionId));
    dp.supplyReadPermission(() -> read);
    MangoPermission edit = new MangoPermission(record.get(table.editPermissionId));
    dp.supplyEditPermission(() -> edit);
    MangoPermission set = new MangoPermission(record.get(table.setPermissionId));
    dp.supplySetPermission(() -> set);
    // Data source information from join
    dp.setDataSourceName(record.get(dataSources.name));
    dp.setDataSourceXid(record.get(dataSources.xid));
    dp.setDataSourceTypeName(record.get(dataSources.dataSourceType));
    dp.ensureUnitsCorrect();
    return dp;
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) MangoPermission(com.infiniteautomation.mango.permission.MangoPermission)

Example 90 with MangoPermission

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

the class EventDao method loadRelationalData.

public void loadRelationalData(EventInstance vo) {
    if (vo.isHasComments()) {
        List<UserCommentVO> comments = new ArrayList<>();
        userCommentDao.getEventComments(vo.getId(), comments::add);
        vo.setEventComments(comments);
    }
    MangoPermission read = vo.getReadPermission();
    vo.supplyReadPermission(() -> permissionService.get(read.getId()));
}
Also used : ArrayList(java.util.ArrayList) UserCommentVO(com.serotonin.m2m2.vo.comment.UserCommentVO) 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