#26 -- Fix variables and term spaces
All checks were successful
CI fuzzy controller / container-test-job (push) Successful in 1m2s

This commit is contained in:
Anton Romanov 2025-03-14 15:40:41 +04:00
parent 7c0eb7ad33
commit 962d677f93
3 changed files with 10 additions and 13 deletions

View File

@ -41,6 +41,12 @@ public class Variable extends BaseEntity {
this.fuzzyTerms = fuzzyTerms;
}
public Variable(VariableForm variableForm) {
setId(variableForm.getId());
this.name = variableForm.getName();
this.input = variableForm.isInput();
}
public String getName() {
return name;
}

View File

@ -39,7 +39,7 @@ public class FuzzyTermService {
} else {
term = getById(fuzzyTermForm.getId());
}
term.setDescription(fuzzyTermForm.getDescription());
term.setDescription(fuzzyTermForm.getDescription().replaceAll(" ", ""));
term.setCrispValue(fuzzyTermForm.getCrispValue());
FuzzyTerm ft = fuzzyTermRepository.save(term);
if (fuzzyTermForm.getId() == null || fuzzyTermForm.getId() == 0) {

View File

@ -30,16 +30,7 @@ public class VariableService {
}
public Variable save(VariableForm variableForm) {
Variable variable;
if (variableForm.getId() == null || variableForm.getId() == 0) {
variable = new Variable();
} else {
variable = getById(variableForm.getId());
}
variable.setProject(projectService.getById(variableForm.getProjectId()));
variable.setName(variableForm.getName());
variable.setInput(variableForm.isInput());
return variableRepository.save(variable);
return save(new Variable(variableForm), variableForm.getProjectId());
}
public Variable save(Variable variable, Integer projectId) {
@ -50,9 +41,9 @@ public class VariableService {
dbVariable = getById(variable.getId());
}
dbVariable.setProject(projectService.getById(projectId));
dbVariable.setName(variable.getName());
dbVariable.setName(variable.getName().replaceAll(" ", ""));
dbVariable.setInput(variable.isInput());
return variableRepository.save(variable);
return variableRepository.save(dbVariable);
}
public void delete(VariableForm ruleForm) {