added listCheckListPanel
This commit is contained in:
parent
6e36c1b685
commit
a2b09124f7
src/main
java/se/su/dsv/scipro
admin/pages
checklists/panels
CreateCheckListTemplatePanel.javaListCheckListPanel.javaListCheckListTemplatePanel.javaViewCheckListPanel.java
data
dao
dataobjects
enums
project/pages
resources
@ -6,7 +6,21 @@
|
||||
</head>
|
||||
<body>
|
||||
<wicket:extend>
|
||||
<div wicket:id="cCLPanel"></div>
|
||||
|
||||
<div class="span-22 last">
|
||||
<!-- Left column -->
|
||||
<div class="span-10 colborder">
|
||||
<div class="span-10 last">
|
||||
<div wicket:id="cCLPanel"></div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Right column -->
|
||||
<div class="span-10 last">
|
||||
<div class="span-10 last">
|
||||
<div wicket:id="listCLPanel"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</wicket:extend>
|
||||
|
||||
</body>
|
||||
|
@ -9,6 +9,7 @@ import org.apache.wicket.model.PropertyModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.checklists.panels.CreateCheckListTemplatePanel;
|
||||
import se.su.dsv.scipro.checklists.panels.ListCheckListTemplatePanel;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.GeneralSystemSettingsDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.GeneralSystemSettings;
|
||||
import se.su.dsv.scipro.project.panels.ProjectPartnerPanel;
|
||||
@ -29,6 +30,7 @@ public class AdminCheckListPage extends AbstractAdminPage {
|
||||
public AdminCheckListPage(PageParameters pp) {
|
||||
super(pp);
|
||||
add(new CreateCheckListTemplatePanel("cCLPanel"));
|
||||
add(new ListCheckListTemplatePanel("listCLPanel"));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -133,7 +133,6 @@ public class CreateCheckListTemplatePanel extends Panel {
|
||||
question = "";
|
||||
target.addComponent(questionField);
|
||||
target.addComponent(container);
|
||||
System.out.println("mooooo");
|
||||
|
||||
}
|
||||
};
|
||||
@ -145,7 +144,6 @@ public class CreateCheckListTemplatePanel extends Panel {
|
||||
form.add(addQuestionForm);
|
||||
form.add(save);
|
||||
add(form);
|
||||
//add(addQuestionLink);
|
||||
|
||||
};
|
||||
|
||||
|
@ -0,0 +1,66 @@
|
||||
package se.su.dsv.scipro.checklists.panels;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.list.ListItem;
|
||||
import org.apache.wicket.markup.html.list.ListView;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.model.LoadableDetachableModel;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.CheckListDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.CheckList;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.enums.CheckListRole;
|
||||
|
||||
/**
|
||||
* @author Fredrik Norberg fnorbe@dsv.su.se
|
||||
*
|
||||
*/
|
||||
|
||||
public class ListCheckListPanel extends Panel {
|
||||
|
||||
private List<CheckList> checkLists;
|
||||
private CheckListRole role;
|
||||
private CheckListDao checkListDao;
|
||||
private Project project;
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ListCheckListPanel(String id, CheckListRole role, final Project project) {
|
||||
super(id);
|
||||
this.role = role;
|
||||
checkLists = checkListDao.findCheckLists(project, role);
|
||||
|
||||
IModel<List<CheckList>> checkListModel = new LoadableDetachableModel<List<CheckList>>() {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected List<CheckList> load() {
|
||||
return project.getCheckLists();
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
final WebMarkupContainer container = new WebMarkupContainer("container");
|
||||
container.setOutputMarkupId(true);
|
||||
ListView<CheckList> checkLists = new ListView<CheckList>("checkLists", checkListModel) {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(ListItem<CheckList> item) {
|
||||
Label listName = new Label("listName", item.getModel().getObject().getName());
|
||||
item.add(listName);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
container.add(checkLists);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package se.su.dsv.scipro.checklists.panels;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.list.ListItem;
|
||||
import org.apache.wicket.markup.html.list.ListView;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.model.LoadableDetachableModel;
|
||||
import org.apache.wicket.model.PropertyModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.CheckListTemplateDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.CheckListTemplate;
|
||||
|
||||
|
||||
/**
|
||||
* @author Fredrik Norberg - fnorbe@dsv.su.se
|
||||
*
|
||||
*/
|
||||
|
||||
public class ListCheckListTemplatePanel extends Panel{
|
||||
|
||||
@SpringBean
|
||||
private CheckListTemplateDao checkListTemplateDao;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ListCheckListTemplatePanel(String id) {
|
||||
super(id);
|
||||
|
||||
IModel<List<CheckListTemplate>> checkListTemplateModel = new LoadableDetachableModel<List<CheckListTemplate>>() {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected List<CheckListTemplate> load() {
|
||||
return checkListTemplateDao.findAll();
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
final WebMarkupContainer container = new WebMarkupContainer("container");
|
||||
container.setOutputMarkupId(true);
|
||||
ListView<CheckListTemplate> checkListTemplates = new ListView<CheckListTemplate>("checkListTemplates", checkListTemplateModel) {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(ListItem<CheckListTemplate> item) {
|
||||
Label templateName = new Label("templateName", new PropertyModel<String>(item.getModel(),"name"));
|
||||
Label templateOwner = new Label("templateOwner", new PropertyModel<String>(item.getModel(), "owner"));
|
||||
item.add(templateName);
|
||||
item.add(templateOwner);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
container.add(checkListTemplates);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class ViewCheckListPanel extends Panel {
|
||||
public ViewCheckListPanel(String id){
|
||||
super(id);
|
||||
|
||||
List<CheckList> checkLists = checkListDao.findCheckLists(SciProSession.get()
|
||||
/* List<CheckList> checkLists = checkListDao.findCheckLists(SciProSession.get()
|
||||
.getActiveProject());{
|
||||
if (checkLists.size() < 1) {
|
||||
CheckList checkList = new CheckList("Test", SciProSession.get().getActiveProject());
|
||||
@ -48,13 +48,12 @@ public class ViewCheckListPanel extends Panel {
|
||||
checkListQuestion = checkListQuestionDao.save(checkListQuestion);
|
||||
checkList.getQuestions().add(checkListQuestion);
|
||||
checkList = checkListDao.save(checkList);
|
||||
|
||||
}
|
||||
|
||||
ListView<CheckList> checkListsListView = new ListView<CheckList>("checkLists", checkLists) {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
@ -104,7 +103,7 @@ public class ViewCheckListPanel extends Panel {
|
||||
};
|
||||
|
||||
add(checkListsListView);
|
||||
};
|
||||
};*/
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,11 @@ import java.util.List;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.CheckList;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.enums.CheckListRole;
|
||||
|
||||
public interface CheckListDao extends Dao<CheckList> {
|
||||
|
||||
public List<CheckList> findCheckLists(final Project project);
|
||||
public List<CheckList> findCheckLists(final Project project, CheckListRole role);
|
||||
//use this if a dataview is necesary
|
||||
//public int countCheckLists (final CheckList cl, Project project);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package se.su.dsv.scipro.data.dao.jpa;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
@ -9,12 +10,16 @@ import javax.persistence.PersistenceException;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
import org.hibernate.ejb.QueryHints;
|
||||
import org.joda.time.DateTime;
|
||||
import org.springframework.orm.jpa.JpaCallback;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.CheckListDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.CheckList;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.enums.CheckListRole;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -29,7 +34,7 @@ public class CheckListDaoJPAImp extends AbstractDaoJPAImp<CheckList> implements
|
||||
super(CheckList.class);
|
||||
}
|
||||
|
||||
public List<CheckList> findCheckLists(final Project project) {
|
||||
public List<CheckList> findCheckLists(final Project project, CheckListRole role) {
|
||||
return getJpaTemplate().execute(new JpaCallback<List<CheckList>>() {
|
||||
public List<CheckList> doInJpa(EntityManager em) throws PersistenceException {
|
||||
String q = "select s " + "from CheckList s " + "where s.project = :project";
|
||||
@ -47,4 +52,23 @@ public class CheckListDaoJPAImp extends AbstractDaoJPAImp<CheckList> implements
|
||||
|
||||
});
|
||||
}
|
||||
//use this if a dataview is necesary
|
||||
/*@Override
|
||||
@Transactional(readOnly = true)
|
||||
public int countCheckLists(final CheckList cl,final Project project) {
|
||||
return getJpaTemplate().execute(new JpaCallback<Integer>() {
|
||||
|
||||
@Override
|
||||
public Integer doInJpa(EntityManager em)
|
||||
throws PersistenceException {
|
||||
String q = "SELECT COUNT(cl) from CheckList cl WHERE cl.project = :p" ;
|
||||
TypedQuery<Long> query = em.createQuery(q,
|
||||
Long.class);
|
||||
query.setHint(QueryHints.HINT_CACHEABLE, "true");
|
||||
query.setParameter("p", project);
|
||||
|
||||
return (query.getSingleResult()).intValue();
|
||||
}
|
||||
});
|
||||
}*/
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package se.su.dsv.scipro.data.dataobjects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
@ -41,6 +43,7 @@ public class Project extends DomainObject implements Comparable<Project>, Iconiz
|
||||
private static final long serialVersionUID = 9071570648984376188L;
|
||||
|
||||
public static final String PP_PROJECT_ID = "pid";
|
||||
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@ -82,6 +85,10 @@ public class Project extends DomainObject implements Comparable<Project>, Iconiz
|
||||
private String statusMessage = "";
|
||||
|
||||
private Date daisyStartDate;
|
||||
|
||||
@OneToMany(targetEntity=CheckList.class, cascade=CascadeType.ALL, orphanRemoval=true)
|
||||
@Sort(type=SortType.NATURAL) //Required by hibernate
|
||||
private List<CheckList> checkLists = new ArrayList<CheckList>();
|
||||
|
||||
public Project() {}
|
||||
|
||||
@ -208,6 +215,18 @@ public class Project extends DomainObject implements Comparable<Project>, Iconiz
|
||||
public void setStatusMessage(String statusMessage) {
|
||||
this.statusMessage = statusMessage;
|
||||
}
|
||||
|
||||
public List<CheckList> getCheckLists() {
|
||||
return checkLists;
|
||||
}
|
||||
|
||||
public void setCheckLists(List<CheckList> checkLists) {
|
||||
this.checkLists = checkLists;
|
||||
}
|
||||
|
||||
public void addCheckList(CheckList cl){
|
||||
checkLists.add(cl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
@ -268,6 +287,5 @@ public class Project extends DomainObject implements Comparable<Project>, Iconiz
|
||||
final public String getCommentKey() {
|
||||
return Project.class.getCanonicalName().toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
package se.su.dsv.scipro.data.enums;
|
||||
|
||||
public enum CheckListRole {
|
||||
AUTHOR,
|
||||
SUPERVISOR,
|
||||
ADMIN
|
||||
}
|
@ -2,6 +2,9 @@ package se.su.dsv.scipro.project.pages;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.checklists.panels.ListCheckListPanel;
|
||||
import se.su.dsv.scipro.data.enums.CheckListRole;
|
||||
import se.su.dsv.scipro.security.auth.Authorization;
|
||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
|
||||
@ -10,11 +13,13 @@ import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
*
|
||||
*/
|
||||
|
||||
@Authorization(authorizedRoles={Roles.SYSADMIN}) //TODO Hidden for initial deployment
|
||||
@Authorization(authorizedRoles={Roles.SYSADMIN})
|
||||
public class ProjectChecklistPage extends ProjectPage {
|
||||
|
||||
public ProjectChecklistPage(PageParameters pp) {
|
||||
super(pp);
|
||||
add(new ListCheckListPanel("listCheckListPanel", CheckListRole.AUTHOR,
|
||||
SciProSession.get().getActiveProject()));
|
||||
//add(new TrafficLightPanel("trafficLightPanel"));
|
||||
//add(new CreateCheckListTemplatePanel("createCheckList"));
|
||||
}
|
||||
|
@ -7,7 +7,6 @@
|
||||
<div class="span-22 last">
|
||||
<div wicket:id=feedback></div>
|
||||
<!-- Left column -->
|
||||
|
||||
<div class="span-10 colborder">
|
||||
<div class="span-10 last">
|
||||
<h5 class="peer-title">Look for project partner</h5>
|
||||
|
@ -59,7 +59,6 @@ public class ProjectPartnerPage extends ProjectPage {
|
||||
|
||||
private DataView<ProjectPartner> dataView;
|
||||
private WebMarkupContainer wmc;
|
||||
private IModel<List<ProjectPartner>> listModel;
|
||||
|
||||
private RadioChoice<ProjectClass> degreeChoice;
|
||||
private RadioChoice<ProjectClass> showChoice;
|
||||
@ -76,7 +75,7 @@ public class ProjectPartnerPage extends ProjectPage {
|
||||
|
||||
settings = generalSystemSettingsDao.getGeneralSystemSettingsInstance();
|
||||
choices = new ArrayList<ProjectClass>();
|
||||
days = settings.getProjectPartnerDaysToLive();
|
||||
setDays(settings.getProjectPartnerDaysToLive());
|
||||
ProjectClass bachelor = projectClassDao.getProjectClass(ProjectClass.BACHELOR);
|
||||
choices.add(bachelor);
|
||||
choices.add(projectClassDao.getProjectClass(ProjectClass.MASTER));
|
||||
@ -142,7 +141,6 @@ public class ProjectPartnerPage extends ProjectPage {
|
||||
|
||||
private void loadListView(ProjectPartnerDataProvider projectPartnerDataProvider){
|
||||
dataView = new DataView<ProjectPartner>("list", projectPartnerDataProvider, 5 ){
|
||||
//wmc.add(new ListView<ProjectPartner>("list", new PropertyModel<List<ProjectPartner>>(this, "ProjectPartnerDao.getProjectPartner")){
|
||||
|
||||
|
||||
|
||||
@ -160,5 +158,13 @@ public class ProjectPartnerPage extends ProjectPage {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public int getDays() {
|
||||
return days;
|
||||
}
|
||||
|
||||
public void setDays(int days) {
|
||||
this.days = days;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,10 @@
|
||||
"projectClassDao"
|
||||
"projectScheduleDao"
|
||||
"projectFollowerDao"
|
||||
"checkListDao"
|
||||
"checkListQuestion"
|
||||
"checkListTemplate"
|
||||
"checkListAnswer"
|
||||
"stringResourceDao"
|
||||
"fileDescriptionDao"
|
||||
"projectEventTemplateDao"
|
||||
|
Loading…
x
Reference in New Issue
Block a user