deletion of projects no longer results in errors
This commit is contained in:
parent
2658a51490
commit
7d294432c0
src/main/java/se/su/dsv/scipro
@ -4,6 +4,7 @@ import java.util.Date;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@ -11,32 +12,37 @@ import se.su.dsv.scipro.data.dao.interfaces.CheckListDao;
|
|||||||
import se.su.dsv.scipro.data.dao.interfaces.CheckListQuestionDao;
|
import se.su.dsv.scipro.data.dao.interfaces.CheckListQuestionDao;
|
||||||
import se.su.dsv.scipro.data.dao.interfaces.CheckListTemplateDao;
|
import se.su.dsv.scipro.data.dao.interfaces.CheckListTemplateDao;
|
||||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectDao;
|
import se.su.dsv.scipro.data.dao.interfaces.ProjectDao;
|
||||||
|
import se.su.dsv.scipro.data.dao.interfaces.UserSettingsDao;
|
||||||
import se.su.dsv.scipro.data.dataobjects.CheckList;
|
import se.su.dsv.scipro.data.dataobjects.CheckList;
|
||||||
import se.su.dsv.scipro.data.dataobjects.CheckListQuestion;
|
import se.su.dsv.scipro.data.dataobjects.CheckListQuestion;
|
||||||
import se.su.dsv.scipro.data.dataobjects.CheckListTemplate;
|
import se.su.dsv.scipro.data.dataobjects.CheckListTemplate;
|
||||||
import se.su.dsv.scipro.data.dataobjects.ChecklistCategory;
|
import se.su.dsv.scipro.data.dataobjects.ChecklistCategory;
|
||||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||||
|
import se.su.dsv.scipro.data.dataobjects.Student;
|
||||||
import se.su.dsv.scipro.data.enums.ProjectStatus;
|
import se.su.dsv.scipro.data.enums.ProjectStatus;
|
||||||
import se.su.dsv.scipro.data.enums.StateOfMind;
|
import se.su.dsv.scipro.data.enums.StateOfMind;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class ProjectFacade {
|
public class ProjectFacade {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CheckListTemplateDao checkListTemplateDao;
|
private CheckListTemplateDao checkListTemplateDao;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CheckListDao checkListDao;
|
private CheckListDao checkListDao;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CheckListQuestionDao checkListQuestionDao;
|
private CheckListQuestionDao checkListQuestionDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserSettingsDao userSettingsDao;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProjectDao projectDao;
|
private ProjectDao projectDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
private CheckListTemplateDao checklistTemplateDao;
|
private CheckListTemplateDao checklistTemplateDao;
|
||||||
|
|
||||||
public void completedProjectStatus(Project project){
|
public void completedProjectStatus(Project project){
|
||||||
if (project!=null){
|
if (project!=null){
|
||||||
project = projectDao.reLoad(project);
|
project = projectDao.reLoad(project);
|
||||||
@ -47,38 +53,49 @@ public class ProjectFacade {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deleteProject(Project project){
|
||||||
|
project = projectDao.reLoad(project);
|
||||||
|
for (Student s : project.getProjectParticipants()){
|
||||||
|
if (userSettingsDao.getUserSettings(s.getUser()).getActiveProject()!=null && userSettingsDao.getUserSettings(s.getUser()).getActiveProject().equals(project)){
|
||||||
|
userSettingsDao.getUserSettings(s.getUser()).setActiveProject(null);
|
||||||
|
userSettingsDao.save(userSettingsDao.getUserSettings(s.getUser()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
projectDao.delete(project);
|
||||||
|
}
|
||||||
|
|
||||||
public void generateChecklists(Project project){
|
public void generateChecklists(Project project){
|
||||||
List<CheckListTemplate> templates;
|
List<CheckListTemplate> templates;
|
||||||
project = projectDao.reLoad(project);
|
project = projectDao.reLoad(project);
|
||||||
|
|
||||||
if(project.getProjectClass().getCode().equals(ProjectClass.BACHELOR)){
|
if(project.getProjectClass().getCode().equals(ProjectClass.BACHELOR)){
|
||||||
templates = checkListTemplateDao.findTemplatesByCategory("Bachelor");
|
templates = checkListTemplateDao.findTemplatesByCategory("Bachelor");
|
||||||
}else{
|
}else{
|
||||||
templates = checkListTemplateDao.findTemplatesByCategory("Master");
|
templates = checkListTemplateDao.findTemplatesByCategory("Master");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for(CheckListTemplate template : templates){
|
for(CheckListTemplate template : templates){
|
||||||
|
|
||||||
List<CheckList> addedCheckLists = project.getCheckLists(); //list with all the checklist already added to the project
|
List<CheckList> addedCheckLists = project.getCheckLists(); //list with all the checklist already added to the project
|
||||||
|
|
||||||
boolean alreadyAdded = false;
|
boolean alreadyAdded = false;
|
||||||
|
|
||||||
for (CheckList check : addedCheckLists){ //loop through the list
|
for (CheckList check : addedCheckLists){ //loop through the list
|
||||||
if (check.getName().equals(template.getName())){ //if the name of the template we want to add already exists as a checklist
|
if (check.getName().equals(template.getName())){ //if the name of the template we want to add already exists as a checklist
|
||||||
alreadyAdded = true; //set the boolean to true
|
alreadyAdded = true; //set the boolean to true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!alreadyAdded){ //if its NOT already added, then add a new checklist based on the template
|
if (!alreadyAdded){ //if its NOT already added, then add a new checklist based on the template
|
||||||
|
|
||||||
CheckListTemplate clt2 = checklistTemplateDao.reLoad(template);
|
CheckListTemplate clt2 = checklistTemplateDao.reLoad(template);
|
||||||
List<ChecklistCategory> categoryList = new ArrayList<ChecklistCategory>();
|
List<ChecklistCategory> categoryList = new ArrayList<ChecklistCategory>();
|
||||||
for(ChecklistCategory cc : clt2.getCategories()){
|
for(ChecklistCategory cc : clt2.getCategories()){
|
||||||
categoryList.add(cc);
|
categoryList.add(cc);
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckList cl = new CheckList(template.getName(), project, categoryList);
|
CheckList cl = new CheckList(template.getName(), project, categoryList);
|
||||||
for(String question : template.getQuestions()){
|
for(String question : template.getQuestions()){
|
||||||
CheckListQuestion clQuestion = new CheckListQuestion(question, cl.getNumberOfQuestions());
|
CheckListQuestion clQuestion = new CheckListQuestion(question, cl.getNumberOfQuestions());
|
||||||
@ -87,10 +104,10 @@ public class ProjectFacade {
|
|||||||
}
|
}
|
||||||
cl.setCategories(template.getCategories());
|
cl.setCategories(template.getCategories());
|
||||||
project.addCheckList(checkListDao.save(cl));
|
project.addCheckList(checkListDao.save(cl));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
projectDao.save(project);
|
projectDao.save(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@
|
|||||||
<th>Supervisor</th>
|
<th>Supervisor</th>
|
||||||
<th>Reviewer</th>
|
<th>Reviewer</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
<th class="rounded-right-top">Edit</th>
|
<th>Edit</th>
|
||||||
<!-- <th class="rounded-right-top">Delete</th> -->
|
<th class="rounded-right-top">Delete</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
@ -64,12 +64,12 @@
|
|||||||
<td wicket:id="statusLabel">Other role</td>
|
<td wicket:id="statusLabel">Other role</td>
|
||||||
<!-- <td wicket:id="editLabel">Other role</td> -->
|
<!-- <td wicket:id="editLabel">Other role</td> -->
|
||||||
<td><a href="#" wicket:id="testLink">Edit</a></td>
|
<td><a href="#" wicket:id="testLink">Edit</a></td>
|
||||||
<!-- <td><a href="#" wicket:id="deleteLink">Delete</a></td> -->
|
<td><a href="#" wicket:id="deleteLink">Delete</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td wicket:id="emptyLabel" colspan="7"></td>
|
<td wicket:id="emptyLabel" colspan="8"></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -21,6 +21,7 @@ import se.su.dsv.scipro.admin.pages.ProjectManagementPage;
|
|||||||
import se.su.dsv.scipro.data.dao.interfaces.Dao.SortableParams.Sort;
|
import se.su.dsv.scipro.data.dao.interfaces.Dao.SortableParams.Sort;
|
||||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectDao;
|
import se.su.dsv.scipro.data.dao.interfaces.ProjectDao;
|
||||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||||
|
import se.su.dsv.scipro.data.facade.ProjectFacade;
|
||||||
import se.su.dsv.scipro.dataproviders.NewProjectDataProvider;
|
import se.su.dsv.scipro.dataproviders.NewProjectDataProvider;
|
||||||
import se.su.dsv.scipro.reusable.DatesPanel;
|
import se.su.dsv.scipro.reusable.DatesPanel;
|
||||||
import se.su.dsv.scipro.reusable.FilterProjectClassPanel;
|
import se.su.dsv.scipro.reusable.FilterProjectClassPanel;
|
||||||
@ -29,9 +30,9 @@ import se.su.dsv.scipro.reusable.FilterStringPanel;
|
|||||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||||
|
|
||||||
public class ProjectManagementPanel extends Panel {
|
public class ProjectManagementPanel extends Panel {
|
||||||
|
|
||||||
@SpringBean
|
@SpringBean
|
||||||
private ProjectDao projectDao;
|
private ProjectFacade projectFacade;
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@ -130,18 +131,16 @@ public class ProjectManagementPanel extends Panel {
|
|||||||
};
|
};
|
||||||
item.add(testLink);
|
item.add(testLink);
|
||||||
|
|
||||||
// AjaxLink deleteLink = new AjaxLink<Void>("deleteLink"){
|
AjaxLink deleteLink = new AjaxLink<Void>("deleteLink"){
|
||||||
// private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
// @Override
|
@Override
|
||||||
// public void onClick(AjaxRequestTarget target) {
|
public void onClick(AjaxRequestTarget target) {
|
||||||
// Project p2 = projectDao.reLoad(p);
|
projectFacade.deleteProject(p);
|
||||||
// projectDao.delete(p2);
|
ajaxRefresh(target);
|
||||||
// ajaxRefresh(target);
|
}
|
||||||
// }
|
|
||||||
//
|
};
|
||||||
// };
|
item.add(deleteLink);
|
||||||
// item.add(deleteLink);
|
|
||||||
//>>>>>>> cascade
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user