use of com.serotonin.m2m2.vo.role.RoleVO in project ma-modules-public by infiniteautomation.
the class RoleRestController method update.
@ApiOperation(value = "Update a Role List", notes = "Admin only")
@RequestMapping(method = RequestMethod.PUT, value = "/{xid}")
public ResponseEntity<RoleModel> update(@ApiParam(value = "XID of Role to update", required = true, allowMultiple = false) @PathVariable String xid, @ApiParam(value = "Role List of update", required = true, allowMultiple = false) @RequestBody RoleModel model, @AuthenticationPrincipal PermissionHolder user, UriComponentsBuilder builder) {
RoleVO vo = service.update(xid, mapping.unmap(model, user, mapper));
URI location = builder.path("/roles/{xid}").buildAndExpand(vo.getXid()).toUri();
HttpHeaders headers = new HttpHeaders();
headers.setLocation(location);
return new ResponseEntity<>(mapping.map(vo, user, mapper), headers, HttpStatus.OK);
}
use of com.serotonin.m2m2.vo.role.RoleVO in project ma-modules-public by infiniteautomation.
the class RoleRestController method partialUpdate.
@ApiOperation(value = "Partially update a Role", notes = "Admin only")
@RequestMapping(method = RequestMethod.PATCH, value = "/{xid}")
public ResponseEntity<RoleModel> partialUpdate(@PathVariable String xid, @ApiParam(value = "Updated role", required = true) @PatchVORequestBody(service = RoleService.class, modelClass = RoleModel.class) RoleModel model, @AuthenticationPrincipal PermissionHolder user, UriComponentsBuilder builder) {
RoleVO vo = service.update(xid, mapping.unmap(model, user, mapper));
URI location = builder.path("/roles/{xid}").buildAndExpand(vo.getXid()).toUri();
HttpHeaders headers = new HttpHeaders();
headers.setLocation(location);
return new ResponseEntity<>(mapping.map(vo, user, mapper), headers, HttpStatus.OK);
}
use of com.serotonin.m2m2.vo.role.RoleVO in project ma-modules-public by infiniteautomation.
the class RoleModelMapping method map.
@Override
public RoleModel map(Object from, PermissionHolder user, RestModelMapper mapper) {
RoleVO role = (RoleVO) from;
RoleModel model = new RoleModel(role);
if (role.getInherited() != null) {
Set<String> inherited = new HashSet<>(role.getInherited().size());
model.setInherited(inherited);
for (Role inheritedRole : role.getInherited()) {
inherited.add(inheritedRole.getXid());
}
}
return model;
}
use of com.serotonin.m2m2.vo.role.RoleVO in project ma-core-public by infiniteautomation.
the class PermissionService method loadRoleInheritance.
private RoleInheritance loadRoleInheritance(String xid) {
RoleInheritance i = new RoleInheritance();
RoleVO roleVo = roleDao.getByXid(xid);
if (roleVo == null) {
return null;
}
i.role = roleVo.getRole();
i.inherited = roleDao.getFlatInheritance(roleVo.getRole());
i.inheritedBy = roleDao.getRolesThatInherit(roleVo.getRole());
return i;
}
use of com.serotonin.m2m2.vo.role.RoleVO in project ma-core-public by infiniteautomation.
the class H2DatabaseTest method test1AutoIncrement.
@Test
public void test1AutoIncrement() throws SQLException {
DSLContext context = Common.getBean(DatabaseProxy.class).getContext();
Roles r = Roles.ROLES;
context.insertInto(r, r.id, r.xid, r.name).values(10, "xid", "name").execute();
context.insertInto(r, r.xid, r.name).values("test", "test").execute();
RoleVO role = Common.getBean(RoleDao.class).getByXid("test");
assertEquals(11, role.getId());
}
Aggregations