#4 -- Add ajax methods for variables and terms
Some checks failed
CI fuzzy controller / container-test-job (push) Failing after 12s
Some checks failed
CI fuzzy controller / container-test-job (push) Failing after 12s
This commit is contained in:
parent
1873df74a1
commit
3359db7b97
@ -8,16 +8,29 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import ru.ulstu.fc.rule.model.FuzzyRuleForm;
|
import ru.ulstu.fc.rule.model.FuzzyRuleForm;
|
||||||
|
import ru.ulstu.fc.rule.model.FuzzyTerm;
|
||||||
|
import ru.ulstu.fc.rule.model.Variable;
|
||||||
import ru.ulstu.fc.rule.service.FuzzyRuleService;
|
import ru.ulstu.fc.rule.service.FuzzyRuleService;
|
||||||
|
import ru.ulstu.fc.rule.service.FuzzyTermService;
|
||||||
|
import ru.ulstu.fc.rule.service.VariableService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("rule")
|
@RequestMapping("rule")
|
||||||
public class FuzzyRuleController {
|
public class FuzzyRuleController {
|
||||||
private final FuzzyRuleService ruleService;
|
private final FuzzyRuleService fuzzyRuleService;
|
||||||
|
private final VariableService variableService;
|
||||||
|
private final FuzzyTermService fuzzyTermService;
|
||||||
|
|
||||||
public FuzzyRuleController(FuzzyRuleService ruleService) {
|
public FuzzyRuleController(FuzzyRuleService fuzzyRuleService,
|
||||||
this.ruleService = ruleService;
|
VariableService variableService,
|
||||||
|
FuzzyTermService fuzzyTermService) {
|
||||||
|
this.fuzzyRuleService = fuzzyRuleService;
|
||||||
|
this.variableService = variableService;
|
||||||
|
this.fuzzyTermService = fuzzyTermService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/edit/{projectId}/{ruleId}")
|
@GetMapping("/edit/{projectId}/{ruleId}")
|
||||||
@ -26,7 +39,7 @@ public class FuzzyRuleController {
|
|||||||
model.addAttribute("projectId", projectId);
|
model.addAttribute("projectId", projectId);
|
||||||
model.addAttribute("fuzzyRuleForm",
|
model.addAttribute("fuzzyRuleForm",
|
||||||
(id != null && id != 0)
|
(id != null && id != 0)
|
||||||
? new FuzzyRuleForm(id, ruleService.getById(id))
|
? new FuzzyRuleForm(id, fuzzyRuleService.getById(id))
|
||||||
: new FuzzyRuleForm(id, projectId));
|
: new FuzzyRuleForm(id, projectId));
|
||||||
return "rule/edit";
|
return "rule/edit";
|
||||||
}
|
}
|
||||||
@ -37,15 +50,27 @@ public class FuzzyRuleController {
|
|||||||
model.addAttribute("projectId", fuzzyRuleForm.getProjectId());
|
model.addAttribute("projectId", fuzzyRuleForm.getProjectId());
|
||||||
return "rule/edit";
|
return "rule/edit";
|
||||||
}
|
}
|
||||||
ruleService.save(fuzzyRuleForm);
|
fuzzyRuleService.save(fuzzyRuleForm);
|
||||||
return "redirect:/project/edit/" + fuzzyRuleForm.getProjectId();
|
return "redirect:/project/edit/" + fuzzyRuleForm.getProjectId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "save", params = "delete")
|
@PostMapping(value = "save", params = "delete")
|
||||||
public String delete(FuzzyRuleForm fuzzyRuleForm) {
|
public String delete(FuzzyRuleForm fuzzyRuleForm) {
|
||||||
if (fuzzyRuleForm != null && fuzzyRuleForm.getId() != null) {
|
if (fuzzyRuleForm != null && fuzzyRuleForm.getId() != null) {
|
||||||
ruleService.delete(fuzzyRuleForm);
|
fuzzyRuleService.delete(fuzzyRuleForm);
|
||||||
}
|
}
|
||||||
return "redirect:/project/edit/" + fuzzyRuleForm.getProjectId();
|
return "redirect:/project/edit/" + fuzzyRuleForm.getProjectId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@GetMapping("/getVariables/{projectId}")
|
||||||
|
public List<Variable> getVariables(@PathVariable("projectId") Integer projectId) {
|
||||||
|
return variableService.getAllByProject(projectId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@GetMapping("/getFuzzyTerms/{variableId}")
|
||||||
|
public List<FuzzyTerm> getTerms(@PathVariable("variableId") Integer variableId) {
|
||||||
|
return fuzzyTermService.getByVariableId(variableId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user