use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by infiniteautomation.
the class EventInstanceDao method deletePostRelationalData.
@Override
public void deletePostRelationalData(EventInstanceVO vo) {
MangoPermission readPermission = vo.getReadPermission();
permissionService.deletePermissions(readPermission);
}
use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by infiniteautomation.
the class MailingListDao method mapRecord.
@Override
public MailingList mapRecord(Record record) {
MailingList ml = new MailingList();
ml.setId(record.get(table.id));
ml.setXid(record.get(table.xid));
ml.setName(record.get(table.name));
ml.setReceiveAlarmEmails(AlarmLevels.fromValue(record.get(table.receiveAlarmEmails)));
ml.setReadPermission(new MangoPermission(record.get(table.readPermissionId)));
ml.setEditPermission(new MangoPermission(record.get(table.editPermissionId)));
return ml;
}
use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by infiniteautomation.
the class SystemPermissionDao method insert.
/**
* Update the permission
*/
public void insert(String permissionTypeName, MangoPermission permission) {
MangoPermission toInsert = permissionService.findOrCreate(permission);
this.create.insertInto(SYSTEM_PERMISSIONS).columns(SYSTEM_PERMISSIONS.permissionId, SYSTEM_PERMISSIONS.permissionType).values(toInsert.getId(), permissionTypeName).execute();
}
use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by infiniteautomation.
the class Upgrade29 method convertDataSources.
private void convertDataSources(OutputStream out) {
Map<String, String[]> scripts = new HashMap<>();
scripts.put(DatabaseType.MYSQL.name(), dataSourcePermissionMySQL);
scripts.put(DatabaseType.H2.name(), dataSourcePermissionH2);
scripts.put(DatabaseType.MSSQL.name(), dataSourcePermissionMSSQL);
scripts.put(DatabaseType.POSTGRES.name(), dataSourcePermissionMySQL);
runScript(scripts, out);
// Move current permissions to roles
ejt.query("SELECT id, editPermission FROM dataSources", rs -> {
int voId = rs.getInt(1);
// Add role/mapping
MangoPermission editPermissions = PermissionMigration.parseLegacyPermission(rs.getString(2));
Integer edit = getOrCreatePermission(editPermissions).getId();
ejt.update("UPDATE dataSources SET editPermissionId=?,readPermissionId=? WHERE id=?", edit, edit, voId);
});
// Restrict to NOT NULL
scripts = new HashMap<>();
scripts.put(DatabaseType.MYSQL.name(), dataSourcePermissionNotNullMySQL);
scripts.put(DatabaseType.H2.name(), dataSourcePermissionNotNull);
scripts.put(DatabaseType.MSSQL.name(), dataSourcePermissionNotNull);
scripts.put(DatabaseType.POSTGRES.name(), dataSourcePermissionNotNull);
runScript(scripts, out);
// Drop columns
scripts = new HashMap<>();
scripts.put(DatabaseType.MYSQL.name(), dataSourcesMySQL);
scripts.put(DatabaseType.H2.name(), dataSourcesH2);
scripts.put(DatabaseType.MSSQL.name(), dataSourcesMSSQL);
scripts.put(DatabaseType.POSTGRES.name(), dataSourcesMySQL);
runScript(scripts, out);
}
use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by infiniteautomation.
the class Upgrade29 method convertDataPoints.
/**
* Convert data points AFTER data sources so we can reference the readPermissionId and editPermissionId
*/
private void convertDataPoints(OutputStream out) {
// Create permission columns
Map<String, String[]> scripts = new HashMap<>();
scripts.put(DatabaseType.MYSQL.name(), dataPointPermissionMySQL);
scripts.put(DatabaseType.H2.name(), dataPointPermissionH2);
scripts.put(DatabaseType.MSSQL.name(), dataPointPermissionMSSQL);
scripts.put(DatabaseType.POSTGRES.name(), dataPointPermissionMySQL);
runScript(scripts, out);
// Move current permissions to roles
ejt.query("SELECT dp.id, dp.readPermission, dp.setPermission, ds.editPermissionId " + "FROM dataPoints AS dp LEFT JOIN dataSources AS ds ON dp.dataSourceId = ds.id", rs -> {
int voId = rs.getInt(1);
// Add role/mapping
MangoPermission readPermissions = PermissionMigration.parseLegacyPermission(rs.getString(2));
Integer read = getOrCreatePermission(readPermissions).getId();
MangoPermission setPermissions = PermissionMigration.parseLegacyPermission(rs.getString(3));
Integer set = getOrCreatePermission(setPermissions).getId();
int edit = rs.getInt(4);
if (edit == 0)
throw new IllegalStateException("dataSource.editPermissionId was null for dataPoint.id " + voId);
ejt.update("UPDATE dataPoints SET readPermissionId=?,editPermissionId=?,setPermissionId=? WHERE id=?", read, edit, set, voId);
});
// Restrict to NOT NULL
scripts = new HashMap<>();
scripts.put(DatabaseType.MYSQL.name(), dataPointPermissionNotNullMySQL);
scripts.put(DatabaseType.H2.name(), dataPointPermissionNotNull);
scripts.put(DatabaseType.MSSQL.name(), dataPointPermissionNotNull);
scripts.put(DatabaseType.POSTGRES.name(), dataPointPermissionNotNull);
runScript(scripts, out);
scripts = new HashMap<>();
scripts.put(DatabaseType.MYSQL.name(), dataPointsMySQL);
scripts.put(DatabaseType.H2.name(), dataPointsH2);
scripts.put(DatabaseType.MSSQL.name(), dataPointsMSSQL);
scripts.put(DatabaseType.POSTGRES.name(), dataPointsMySQL);
runScript(scripts, out);
}
Aggregations