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

Cleaned out LOG comments from debugging. Code for creation of

category and property ("trait" or Parameter) otherwise seems to work.
The next part for validation if Method.
parent 88f4507d
...@@ -572,36 +572,19 @@ public class GenesysServiceImpl implements GenesysService, TraitService, Dataset ...@@ -572,36 +572,19 @@ public class GenesysServiceImpl implements GenesysService, TraitService, Dataset
@PreAuthorize("isAuthenticated()") @PreAuthorize("isAuthenticated()")
@Transactional(readOnly = false) @Transactional(readOnly = false)
public Parameter addParameter(Crop crop, String category, String title) { public Parameter addParameter(Crop crop, String category, String title) {
LOG.info("addParameter(Crop:"+(crop!=null?crop.getName():"null")+","+category+","+title+")");
LOG.info("new Parameter() ");
Parameter parameter = new Parameter(); Parameter parameter = new Parameter();
LOG.info("setCrop "); parameter.setCrop(crop);
parameter.setCrop(crop); // BEWARE: Crop Rules are defective in JSON rendering
LOG.info("parameterCategoryRepository.findByName(category)");
ParameterCategory parameterCategory = ParameterCategory parameterCategory =
parameterCategoryRepository.findByName(category); parameterCategoryRepository.findByName(category);
LOG.info("setCategory(parameterCategory);");
parameter.setCategory(parameterCategory); parameter.setCategory(parameterCategory);
LOG.info("setTitle(title)");
parameter.setTitle(title); parameter.setTitle(title);
LOG.info("parameterRepository.save(parameter)");
parameterRepository.save(parameter); parameterRepository.save(parameter);
LOG.info("return parameter");
return parameter; return parameter;
} }
......
...@@ -157,41 +157,33 @@ public class TraitsController extends RestController { ...@@ -157,41 +157,33 @@ public class TraitsController extends RestController {
@PathVariable("crop") String cropName, @PathVariable("crop") String cropName,
@RequestBody PropertyJson propertyJson @RequestBody PropertyJson propertyJson
) throws ValidationException { ) throws ValidationException {
LOG.info("Creating property for crop '"+cropName+"':"); LOG.info("Creating property for crop '"+cropName+"':");
Validator validator = new Validator(); Validator validator = new Validator();
List<ConstraintViolation> violations = validator.validate(propertyJson); List<ConstraintViolation> violations = validator.validate(propertyJson);
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);
} }
LOG.info("Calling cropService.getCrop('"+cropName+"'):"); LOG.info("Calling cropService.getCrop('"+cropName+"'):");
Crop crop = cropService.getCrop(cropName) ; Crop crop = cropService.getCrop(cropName) ;
//LOG.debug("getParameter? "); LOG.debug("Calling getParameter()");
Parameter property = traitService.getParameter(crop, propertyJson.title);
if(property == null) {
// create if not available already?
property = traitService.addParameter(crop, propertyJson.category, propertyJson.title);
} else
LOG.warn("Property '"+propertyJson.title+"' in category '"+
propertyJson.category+"' for crop '"+
cropName+"' already exists?");
//Parameter property = traitService.getParameter(crop, propertyJson.title);
//LOG.debug(property.toString());
//if(property == null) { // create if not available already?
LOG.info("Calling traitService.addParameter()");
Parameter property = traitService.addParameter(crop, propertyJson.category, propertyJson.title);
LOG.info("Returning from createProperty()");
// property = traitService.addParameter(crop, propertyJson.category, propertyJson.title);
// LOG.debug("...done.");
//} else
// LOG.warn("Property '"+propertyJson.title+"' in category '"+
// propertyJson.category+"' for crop '"+
// cropName+"' already exists?");
return property; return property;
} }
......
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