use of com.infiniteautomation.mango.permission.MangoPermission in project ma-modules-public by infiniteautomation.
the class AbstractDataSourceModel method toVO.
@Override
public T toVO() {
T vo = super.toVO();
vo.setEnabled(enabled);
if (eventAlarmLevels != null) {
for (EventTypeAlarmLevelModel eval : eventAlarmLevels) {
vo.setAlarmLevel(eval.getEventType(), eval.getLevel());
}
}
if (purgeSettings != null)
purgeSettings.toVO(vo);
vo.setEditPermission(editPermission != null ? editPermission.getPermission() : new MangoPermission());
vo.setReadPermission(readPermission != null ? readPermission.getPermission() : new MangoPermission());
vo.setData(data);
return vo;
}
use of com.infiniteautomation.mango.permission.MangoPermission in project ma-modules-public by infiniteautomation.
the class JsonDataModel method toVO.
@Override
public JsonDataVO toVO() throws ValidationException {
JsonDataVO vo = super.toVO();
vo.setReadPermission(readPermission != null ? readPermission.getPermission() : new MangoPermission());
vo.setEditPermission(editPermission != null ? editPermission.getPermission() : new MangoPermission());
vo.setJsonData(jsonData);
return vo;
}
use of com.infiniteautomation.mango.permission.MangoPermission in project ma-modules-public by infiniteautomation.
the class WatchListDao method mapRecord.
@Override
public WatchListVO mapRecord(Record record) {
WatchListVO wl = new WatchListVO();
wl.setId(record.get(table.id));
wl.setXid(record.get(table.xid));
wl.setName(record.get(table.name));
String type = record.get(table.type);
if (type != null) {
wl.setType(WatchListType.valueOf(type.toUpperCase(Locale.ROOT)));
}
// Read the data
try {
String c = record.get(table.data);
if (c != null) {
WatchListDbDataModel data = getObjectReader(WatchListDbDataModel.class).readValue(c);
if (data != null) {
wl.setQuery(data.query);
wl.setParams(data.params);
wl.setData(data.data);
}
}
} catch (Exception e) {
LOG.error(e.getMessage(), e);
}
wl.setReadPermission(new MangoPermission(record.get(table.readPermissionId)));
wl.setEditPermission(new MangoPermission(record.get(table.editPermissionId)));
return wl;
}
use of com.infiniteautomation.mango.permission.MangoPermission in project ma-modules-public by infiniteautomation.
the class WatchListModelMapping method unmap.
@Override
public WatchListVO unmap(Object from, PermissionHolder user, RestModelMapper mapper) throws ValidationException {
WatchListModel model = (WatchListModel) from;
WatchListVO vo = model.toVO();
vo.setReadPermission(model.getReadPermission() != null ? model.getReadPermission().getPermission() : new MangoPermission());
vo.setEditPermission(model.getEditPermission() != null ? model.getEditPermission().getPermission() : new MangoPermission());
if (vo.getType() == WatchListType.STATIC && model.getPoints() != null) {
vo.setPointList(model.getPoints().stream().map(m -> {
DataPointSummary summary = new DataPointSummary();
summary.setXid(m.getXid());
return summary;
}).collect(Collectors.toList()));
}
return vo;
}
use of com.infiniteautomation.mango.permission.MangoPermission in project ma-modules-public by infiniteautomation.
the class Upgrade6 method upgrade.
@Override
protected void upgrade() throws Exception {
OutputStream out = createUpdateLogOutputStream();
// First drop any watch lists of type 'hierarhcy'
ejt.update("DELETE FROM watchLists WHERE type='hierarchy'");
// Create permission columns
Map<String, String[]> scripts = new HashMap<>();
scripts.put(DatabaseType.MYSQL.name(), addPermissionsSQL);
scripts.put(DatabaseType.H2.name(), addPermissionsSQL);
scripts.put(DatabaseType.MSSQL.name(), addPermissionsSQL);
scripts.put(DatabaseType.POSTGRES.name(), addPermissionsSQL);
runScript(scripts, out);
// Convert permissions into roles
// Move current permissions to roles
ejt.query("SELECT id, readPermission, editPermission FROM watchLists", rs -> {
int voId = rs.getInt(1);
// Add role/mapping
MangoPermission readPermissions = PermissionMigration.parseLegacyPermission(rs.getString(2));
Integer read = getOrCreatePermission(readPermissions).getId();
MangoPermission editPermissions = PermissionMigration.parseLegacyPermission(rs.getString(3));
Integer edit = getOrCreatePermission(editPermissions).getId();
ejt.update("UPDATE watchLists SET readPermissionId=?, editPermissionId=? WHERE id=?", read, edit, voId);
});
// Modify permission columns
scripts = new HashMap<>();
scripts.put(DatabaseType.MYSQL.name(), permissionsNotNullMySQL);
scripts.put(DatabaseType.H2.name(), permissionsNotNullSQL);
scripts.put(DatabaseType.MSSQL.name(), permissionsNotNullSQL);
scripts.put(DatabaseType.POSTGRES.name(), permissionsNotNullSQL);
runScript(scripts, out);
scripts = new HashMap<>();
scripts.put(DatabaseType.MYSQL.name(), sql);
scripts.put(DatabaseType.H2.name(), sql);
scripts.put(DatabaseType.MSSQL.name(), sql);
scripts.put(DatabaseType.POSTGRES.name(), sql);
runScript(scripts, out);
}
Aggregations