-
Type:
Improvement
-
Status: Closed (View Workflow)
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 0.7 swallows
-
Fix Version/s: 0.7 swallows
-
Labels:None
We have DRY principle violation in the branches and sections adding/editing code.
Violating code for sections:
poulpe-view/poulpe-web-controller/src/main/java/org/jtalks/poulpe/web/controller/section/SectionPresenter.java
public void editSection(final String name, final String description) {
final Section section = (Section) this.currentSectionTreeComponent.getSelectedObject();
String errorLabel = validateSection(name, description);
if (errorLabel != null) {
sectionView.openErrorPopupInEditSectionDialog(errorLabel);
return;
}
DialogManager dm = new DialogManagerImpl();
dm.confirmEdition(name, new DialogManager.Performable() {
@Override
public void execute() {
section.setName(name);
section.setDescription(description);
try {
sectionService.saveSection(section);
} catch (NotUniqueException e) {
Logger.getLogger(BranchPresenter.class.getName()).log(Level.SEVERE, null, e);
sectionView.openErrorPopupInEditSectionDialog("sections.error.exeption_during_saving_process");
}
// its not necessary here because of section was transferred as
// a reference
SectionPresenter.this.currentSectionTreeComponent.updateSectionInView(section);
sectionView.closeEditSectionDialog();
}
});
sectionView.closeEditSectionDialog();
public void addNewSection(final String name, final String description) {
// final String name = sectionView.getNewSectionName();
// final String description = sectionView.getNewSectionDescription();
String errorLabel = validateSection(name, description);
if (errorLabel != null) {
sectionView.openErrorPopupInNewSectionDialog(errorLabel);
return;
}
DialogManager dm = new DialogManagerImpl();
dm.confirmCreation(name, new DialogManager.Performable() {
@Override
public void execute() {
Section section = new Section();
section.setName(name);
section.setDescription(description);
try {
sectionService.saveSection(section);
} catch (NotUniqueException e) {
Logger.getLogger(BranchPresenter.class.getName()).log(Level.SEVERE, null, e);
sectionView.openErrorPopupInNewSectionDialog("sections.error.exeption_during_saving_process");
}
sectionView.showSection(section);
sectionView.closeNewSectionDialog();
}
});
}
Same violation is for branches adding/editing.