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 { ...@@ -190,22 +190,31 @@ public class TraitsController extends RestController {
* @return * @return
* @throws ValidationException * @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 public @ResponseBody
Object createMethod(@RequestBody MethodJson methodJson) throws ValidationException { Object createMethod(
LOG.info("Creating method:"); @PathVariable("propertyId") long propertyId,
@RequestBody MethodJson methodJson
) throws ValidationException {
LOG.info("Creating method for property:");
Validator validator = new Validator(); Validator validator = new Validator();
List<ConstraintViolation> violations = validator.validate(methodJson); List<ConstraintViolation> violations = validator.validate(methodJson);
if (violations.size() > 0) { if (violations.size() > 0) {
// TODO We could do better messages on validation error // TODO We could do better messages on validation error
throw new ModelValidationException("Validation problem", violations); 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, 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; return method;
} }
public static class MethodJson { public static class MethodJson {
@NotNull @NotNull
@NotBlank @NotBlank
@MinLength(10) @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