Commit 22694705 authored by Richard Bruskiewich's avatar Richard Bruskiewich Committed by Matija Obreza
Browse files

A Method is always linked to a descriptor Property ("Parameter") so

modified the /methods call to /{propertyId}/method.
parent 1771d9e6
......@@ -190,22 +190,31 @@ public class TraitsController extends RestController {
* @return
* @throws ValidationException
*/
@RequestMapping(value = "/methods", method = { RequestMethod.PUT, RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE })
@RequestMapping(value = "/{propertyId}/method", method = { RequestMethod.PUT, RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE })
public @ResponseBody
Object createMethod(@RequestBody MethodJson methodJson) throws ValidationException {
LOG.info("Creating method:");
Object createMethod(
@PathVariable("propertyId") long propertyId,
@RequestBody MethodJson methodJson
) throws ValidationException {
LOG.info("Creating method for property:");
Validator validator = new Validator();
List<ConstraintViolation> violations = validator.validate(methodJson);
if (violations.size() > 0) {
// TODO We could do better messages on validation error
throw new ModelValidationException("Validation problem", violations);
}
Parameter property = traitService.getTrait(propertyId);
Method method = traitService.addMethod(methodJson.description, methodJson.unit, methodJson.fieldName, methodJson.fieldType, methodJson.fieldSize,
methodJson.options, methodJson.range, null);
methodJson.options, methodJson.range, property);
return method;
}
public static class MethodJson {
@NotNull
@NotBlank
@MinLength(10)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment