use of com.infiniteautomation.mango.rest.latest.model.permissions.MangoPermissionModel in project ma-modules-public by infiniteautomation.
the class DataPointModel method fromVO.
@Override
public void fromVO(DataPointVO point) {
this.id = point.getId();
this.xid = point.getXid();
this.name = point.getName();
this.enabled = point.isEnabled();
this.deviceName = point.getDeviceName();
this.readPermission = new MangoPermissionModel(point.getReadPermission());
this.editPermission = new MangoPermissionModel(point.getEditPermission());
this.setPermission = new MangoPermissionModel(point.getSetPermission());
this.purgeOverride = point.isPurgeOverride();
if (this.purgeOverride) {
this.purgePeriod = new TimePeriodModel(point.getPurgePeriod(), point.getPurgeType());
}
this.unit = JUnitUtil.formatLocal(point.getUnit());
this.useIntegralUnit = point.isUseIntegralUnit();
if (this.useIntegralUnit) {
this.integralUnit = JUnitUtil.formatLocal(point.getIntegralUnit());
}
this.useRenderedUnit = point.isUseRenderedUnit();
if (this.useRenderedUnit) {
this.renderedUnit = JUnitUtil.formatLocal(point.getRenderedUnit());
}
// The Point Locator will be set by the RestModelMapper after
this.chartColour = point.getChartColour();
this.plotType = DataPointVO.PLOT_TYPE_CODES.getCode(point.getPlotType());
this.tags = point.getTags();
this.loggingProperties = new LoggingPropertiesModel(point);
this.dataSourceId = point.getDataSourceId();
this.dataSourceXid = point.getDataSourceXid();
this.dataSourceName = point.getDataSourceName();
this.dataSourceTypeName = point.getDataSourceTypeName();
this.rollup = Common.ROLLUP_CODES.getCode(point.getRollup());
this.simplifyType = DataPointVO.SIMPLIFY_TYPE_CODES.getCode(point.getSimplifyType());
this.simplifyTolerance = point.getSimplifyTolerance();
this.simplifyTarget = point.getSimplifyTarget();
this.preventSetExtremeValues = point.isPreventSetExtremeValues();
if (this.preventSetExtremeValues) {
this.setExtremeLowLimit = point.getSetExtremeLowLimit();
this.setExtremeHighLimit = point.getSetExtremeHighLimit();
}
this.extendedName = point.getExtendedName();
this.data = point.getData();
}
use of com.infiniteautomation.mango.rest.latest.model.permissions.MangoPermissionModel in project ma-modules-public by infiniteautomation.
the class WatchListModelMapping method map.
@Override
public WatchListModel map(Object from, PermissionHolder user, RestModelMapper mapper) {
WatchListVO vo = (WatchListVO) from;
WatchListModel model = new WatchListModel(vo);
model.setReadPermission(new MangoPermissionModel(vo.getReadPermission()));
model.setEditPermission(new MangoPermissionModel(vo.getEditPermission()));
if (vo.getType() == WatchListType.STATIC) {
// Set the point summaries
model.setPoints(vo.getPointList().stream().map(WatchListDataPointModel::new).collect(Collectors.toList()));
}
return model;
}
use of com.infiniteautomation.mango.rest.latest.model.permissions.MangoPermissionModel in project ma-modules-public by infiniteautomation.
the class WatchListSummaryModelMapping method map.
@Override
public WatchListSummaryModel map(Object from, PermissionHolder user, RestModelMapper mapper) {
WatchListVO vo = (WatchListVO) from;
WatchListSummaryModel model = new WatchListSummaryModel(vo);
model.setReadPermission(new MangoPermissionModel(vo.getReadPermission()));
model.setEditPermission(new MangoPermissionModel(vo.getEditPermission()));
return model;
}
use of com.infiniteautomation.mango.rest.latest.model.permissions.MangoPermissionModel in project ma-modules-public by infiniteautomation.
the class MaintenanceEventModel method fromVO.
@Override
public void fromVO(MaintenanceEventVO vo) {
super.fromVO(vo);
if (vo.getDataSources().size() > 0) {
dataSources = new ArrayList<>();
for (int id : vo.getDataSources()) {
String xid = DataSourceDao.getInstance().getXidById(id);
if (xid != null)
dataSources.add(xid);
}
}
if (vo.getDataPoints().size() > 0) {
dataPoints = new ArrayList<>();
for (int id : vo.getDataPoints()) {
String xid = DataPointDao.getInstance().getXidById(id);
if (xid != null)
dataPoints.add(xid);
}
}
alarmLevel = vo.getAlarmLevel();
scheduleType = MaintenanceEventVO.TYPE_CODES.getCode(vo.getScheduleType());
disabled = vo.isDisabled();
activeYear = vo.getActiveYear();
activeMonth = vo.getActiveMonth();
activeDay = vo.getActiveDay();
activeHour = vo.getActiveHour();
activeMinute = vo.getActiveMinute();
activeSecond = vo.getActiveMinute();
activeCron = vo.getActiveCron();
inactiveYear = vo.getInactiveYear();
inactiveMonth = vo.getInactiveMonth();
inactiveDay = vo.getInactiveDay();
inactiveHour = vo.getInactiveHour();
inactiveMinute = vo.getInactiveMinute();
inactiveSecond = vo.getInactiveSecond();
inactiveCron = vo.getInactiveCron();
timeoutPeriods = vo.getTimeoutPeriods();
timeoutPeriodType = Common.TIME_PERIOD_CODES.getCode(vo.getTimeoutPeriodType());
togglePermission = new MangoPermissionModel(vo.getTogglePermission());
}
use of com.infiniteautomation.mango.rest.latest.model.permissions.MangoPermissionModel in project ma-modules-public by infiniteautomation.
the class MangoPermissionModelDeserializer method nodeToModel.
@SuppressWarnings("unchecked")
public MangoPermissionModel nodeToModel(JsonNode tree, ObjectMapper mapper) throws JsonProcessingException {
Set<Set<Role>> roles = new HashSet<>();
if (tree instanceof ArrayNode) {
Set<Object> outerSet = mapper.treeToValue(tree, Set.class);
for (Object o : outerSet) {
Set<Role> innerRoles = new HashSet<>();
roles.add(innerRoles);
if (o instanceof Iterable) {
for (String xid : (Iterable<String>) o) {
Role role = permissionService.getRole(xid);
if (role != null) {
innerRoles.add(role);
} else {
// Let validation pick this up
innerRoles.add(new Role(Common.NEW_ID, xid));
}
}
} else {
String xid = (String) o;
Role role = permissionService.getRole(xid);
if (role != null) {
innerRoles.add(role);
} else {
// Let validation pick this up
innerRoles.add(new Role(Common.NEW_ID, xid));
}
}
}
} else if (tree instanceof TextNode) {
Set<String> xids = PermissionService.explodeLegacyPermissionGroups(tree.asText());
for (String xid : xids) {
Role role = permissionService.getRole(xid);
if (role != null) {
roles.add(Collections.singleton(role));
} else {
// Let validation pick this up
roles.add(Collections.singleton(new Role(Common.NEW_ID, xid)));
}
}
}
return new MangoPermissionModel(new MangoPermission(roles));
}
Aggregations