added project idea popup with watson boxes to fill in when student entering project idea tab. also some refactoring of panels that are being used in more than one place
This commit is contained in:
parent
468739997b
commit
f82710dec5
src
main/java/se/su/dsv/scipro
match/dataobject
project
pages
panels
springdata
repos
serviceimpls
services
test/java/se/su/dsv/scipro/springdata
@ -30,7 +30,7 @@ public abstract class Idea extends DomainObject {
|
||||
@SortableField
|
||||
private ProjectClass projectClass;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "pk.supervisorIdea")
|
||||
@OneToMany(fetch = FetchType.EAGER, mappedBy = "pk.supervisorIdea")
|
||||
@QueryInit("ideaParticipations.pk.student")
|
||||
private Set<IdeaParticipation> ideaParticipations = new HashSet<IdeaParticipation>();
|
||||
|
||||
|
@ -23,6 +23,7 @@ import se.su.dsv.scipro.datatables.project.GenericDataPanel;
|
||||
import se.su.dsv.scipro.match.dataobject.Idea.IdeaStatus;
|
||||
import se.su.dsv.scipro.match.dataobject.SupervisorIdea;
|
||||
import se.su.dsv.scipro.project.panels.AcceptIdeaDialogPanel;
|
||||
import se.su.dsv.scipro.project.panels.CompleteIdeaDialogPanel;
|
||||
import se.su.dsv.scipro.springdata.services.GenericService;
|
||||
import se.su.dsv.scipro.springdata.services.StudentService;
|
||||
import se.su.dsv.scipro.springdata.services.SupervisorIdeaService;
|
||||
@ -52,11 +53,10 @@ public class ProjectIdeaStartPage extends AbstractProjectIdeaPage {
|
||||
}
|
||||
|
||||
private void checkForUnconfirmedIdeas() {
|
||||
boolean hasUnconfirmed = ideaService.hasUnconfirmedIdea(getUser());
|
||||
boolean hasUnconfirmed = ideaService.hasTakenIdeas(getUser(), false);
|
||||
if(hasUnconfirmed) {
|
||||
System.out.println("Unconfirmed idea available");
|
||||
Student author = studentService.findByUser(getUser());
|
||||
final List<SupervisorIdea> ideas = ideaService.findUnconfirmedIdeasByStatusAndAuthor(IdeaStatus.TAKEN, author);
|
||||
final List<SupervisorIdea> ideas = ideaService.findIdeas(IdeaStatus.TAKEN, author, false);
|
||||
if(ideas.size()>1)
|
||||
System.out.println("More than one unconfirmed idea");
|
||||
else {
|
||||
@ -75,8 +75,32 @@ public class ProjectIdeaStartPage extends AbstractProjectIdeaPage {
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
System.out.println("No ideas available");
|
||||
else {
|
||||
checkForConfirmedIdeas();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkForConfirmedIdeas() {
|
||||
boolean hasConfirmed = ideaService.hasTakenIdeas(getUser(), true);
|
||||
if(hasConfirmed){
|
||||
Student author = studentService.findByUser(getUser());
|
||||
final List<SupervisorIdea> ideas = ideaService.findIdeas(IdeaStatus.TAKEN, author, true);
|
||||
add(new AbstractAjaxTimerBehavior(Duration.milliseconds(1)) {
|
||||
private static final long serialVersionUID = 8249890924500999472L;
|
||||
|
||||
@Override
|
||||
protected void onTimer(AjaxRequestTarget target) {
|
||||
dialog.replace(new CompleteIdeaDialogPanel("dialogPanel",Model.of(ideas.get(0))));
|
||||
dialog.setWidth(550);
|
||||
dialog.setHeight(700);
|
||||
dialog.setTitle("Selected supervisor project idea");
|
||||
target.addComponent(dialog);
|
||||
dialog.open(target);
|
||||
stop();
|
||||
}
|
||||
});
|
||||
} else
|
||||
System.out.println("No confirmed ideas");
|
||||
}
|
||||
|
||||
private void addDialog() {
|
||||
|
@ -9,31 +9,14 @@
|
||||
<form wicket:id="form">
|
||||
<div wicket:id="unconfirmedContainer" >
|
||||
<div class="info-box rounded-box last">
|
||||
You have been selected as a partner to be the author for this project together with <span wicket:id="authorLabel"></span><br />
|
||||
You have been selected as a partner to be the author for this project<br />
|
||||
<div class="prepend-top">
|
||||
<input type="submit" wicket:id="partnerAccept" value="Accept"/>
|
||||
<input type="submit" wicket:id="partnerDecline" value="Decline"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="append-bottom"><b>Level: </b><br />
|
||||
<span wicket:id="level"></span>
|
||||
</div>
|
||||
<div class="append-bottom"><b>Required prerequisites:</b><br />
|
||||
<span wicket:id="reqs"></span>
|
||||
</div>
|
||||
<div class="append-bottom"><b>Title:</b><br />
|
||||
<span wicket:id="title"></span>
|
||||
</div>
|
||||
<div class="append-bottom"><b>Description:</b><br />
|
||||
<span wicket:id="description"></span>
|
||||
</div>
|
||||
<div class="append-bottom"><b>Research area:</b><br />
|
||||
<span wicket:id="noAreaLabel"></span>
|
||||
<span wicket:id="researchAreas"><span wicket:id="areaName"></span><br /></span>
|
||||
</div>
|
||||
<div class="append-bottom"><b>Keywords:</b><br />
|
||||
<span wicket:id="noKeysLabel"></span>
|
||||
<span wicket:id="keywords"><span wicket:id="keyName"></span><br /></span>
|
||||
</div>
|
||||
<div wicket:id="ideaDetails"></div>
|
||||
<div>
|
||||
<wicket:enclosure child="partnerPanel">
|
||||
<b>Partner:</b><br />
|
||||
|
@ -1,7 +1,7 @@
|
||||
package se.su.dsv.scipro.project.panels;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
@ -15,24 +15,19 @@ import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.ResearchArea;
|
||||
import se.su.dsv.scipro.data.dataobjects.Student;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.match.dataobject.Keyword;
|
||||
import se.su.dsv.scipro.match.dataobject.IdeaParticipation;
|
||||
import se.su.dsv.scipro.match.dataobject.SupervisorIdea;
|
||||
import se.su.dsv.scipro.reusable.AddRemoveStudentsPanel;
|
||||
import se.su.dsv.scipro.springdata.services.SupervisorIdeaService;
|
||||
import se.su.dsv.scipro.springdata.services.SupervisorService;
|
||||
import se.su.dsv.scipro.util.JavascriptEventConfirmation;
|
||||
|
||||
public class AcceptIdeaDialogPanel extends Panel {
|
||||
|
||||
@SpringBean
|
||||
private SupervisorIdeaService ideaService;
|
||||
@SpringBean
|
||||
private SupervisorService supervisorService;
|
||||
|
||||
public AcceptIdeaDialogPanel(String id, IModel<SupervisorIdea> model, final User loggedInUser, boolean unconfirmed) {
|
||||
super(id, model);
|
||||
@ -48,26 +43,13 @@ public class AcceptIdeaDialogPanel extends Panel {
|
||||
|
||||
public AcceptIdeaForm(String id, final IModel<SupervisorIdea> model, final User loggedInUser, final boolean unconfirmed) {
|
||||
super(id, model);
|
||||
Employee ideaCreator = supervisorService.findOne(model.getObject().getCreator().getId());
|
||||
add(new Label("level", model.getObject().getProjectClass().getName()));
|
||||
add(new Label("reqs", model.getObject().getRequirements()));
|
||||
add(new Label("title", model.getObject().getTitle()));
|
||||
add(new Label("description", model.getObject().getDescription()));
|
||||
addResearchAreas(ideaCreator);
|
||||
addKeywords(model);
|
||||
addPartnerPanel(model, unconfirmed);
|
||||
addUnconfirmedContainer(model, loggedInUser, unconfirmed);
|
||||
add(new ProjectIdeaDetailsPanel("ideaDetails", model, unconfirmed));
|
||||
addUnconfirmedContainer(model, loggedInUser, unconfirmed); //Info box with accept/decline buttons
|
||||
addButton(model, loggedInUser, unconfirmed);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void addUnconfirmedContainer(final IModel<SupervisorIdea> model, final User loggedInUser, final boolean unconfirmed) {
|
||||
Label authorLabel = new Label("authorLabel", "Kalle");
|
||||
authorLabel.setVisible(unconfirmed);
|
||||
EnclosureContainer cont = new EnclosureContainer("unconfirmedContainer", authorLabel);
|
||||
cont.add(authorLabel);
|
||||
|
||||
Button acceptButton = new Button("partnerAccept"){
|
||||
private static final long serialVersionUID = -7001493750138777577L;
|
||||
|
||||
@ -77,6 +59,8 @@ public class AcceptIdeaDialogPanel extends Panel {
|
||||
getSession().info("You have accepted to be a part of the project: "+ model.getObject().getTitle());
|
||||
}
|
||||
};
|
||||
EnclosureContainer cont = new EnclosureContainer("unconfirmedContainer", acceptButton);
|
||||
acceptButton.setVisible(unconfirmed);
|
||||
acceptButton.add(new JavascriptEventConfirmation("onClick", "Are you sure you want to be a part of this project?"));
|
||||
Button declineButton = new Button("partnerDecline"){
|
||||
private static final long serialVersionUID = -3519373023312617322L;
|
||||
@ -94,38 +78,6 @@ public class AcceptIdeaDialogPanel extends Panel {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void addResearchAreas(Employee ideaCreator) {
|
||||
final Set<ResearchArea> areas = ideaCreator.getActiveResearchAreas();
|
||||
ListView<ResearchArea> areaList = new ListView<ResearchArea>("researchAreas", new ArrayList<ResearchArea>(areas)) {
|
||||
private static final long serialVersionUID = 1745649109195334927L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(ListItem<ResearchArea> item) {
|
||||
item.add(new Label("areaName", item.getModelObject().getTitle()));
|
||||
}
|
||||
};
|
||||
add(new Label("noAreaLabel","No research area available").setVisible(areas.isEmpty()));
|
||||
add(areaList);
|
||||
}
|
||||
|
||||
private void addKeywords(IModel<SupervisorIdea> model) {
|
||||
final Set<Keyword> keywords = model.getObject().getKeywords();
|
||||
ListView<Keyword> keyList = new ListView<Keyword>("keywords", new ArrayList<Keyword>(keywords)) {
|
||||
private static final long serialVersionUID = 470796140309547562L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(ListItem<Keyword> item) {
|
||||
item.add(new Label("keyName", item.getModelObject().getKeyword()));
|
||||
}
|
||||
|
||||
};
|
||||
add(new Label("noKeysLabel", "No keywords available").setVisible(keywords.isEmpty()));
|
||||
add(keyList);
|
||||
|
||||
}
|
||||
|
||||
private void addPartnerPanel(IModel<SupervisorIdea> model, boolean unconfirmed) {
|
||||
partnerPanel = new AddRemoveStudentsPanel("partnerPanel", new TreeSet<Student>()) {
|
||||
|
@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html
|
||||
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<head>
|
||||
<meta http-equiv="Content-type" content="text/html;charset=UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<form wicket:id="form">
|
||||
<div wicket:id="ideaDetails"></div>
|
||||
<div class="prepend-top" wicket:id="watsonDetails"></div>
|
||||
<input type="submit" wicket:id="saveButton" value="Save"/>
|
||||
</form>
|
||||
</wicket:panel>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,55 @@
|
||||
package se.su.dsv.scipro.project.panels;
|
||||
|
||||
import org.apache.wicket.markup.html.form.Button;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.match.dataobject.SupervisorIdea;
|
||||
import se.su.dsv.scipro.springdata.services.SupervisorIdeaService;
|
||||
import se.su.dsv.scipro.util.JavascriptEventConfirmation;
|
||||
|
||||
public class CompleteIdeaDialogPanel extends Panel {
|
||||
|
||||
@SpringBean
|
||||
private SupervisorIdeaService ideaService;
|
||||
|
||||
public CompleteIdeaDialogPanel(String id, IModel<SupervisorIdea> model) {
|
||||
super(id, model);
|
||||
add(new CompleteIdeaForm("form", model));
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 29731924490786784L;
|
||||
|
||||
private class CompleteIdeaForm extends Form<SupervisorIdea> {
|
||||
|
||||
private static final long serialVersionUID = -9118352523380756043L;
|
||||
|
||||
public CompleteIdeaForm(String id, final IModel<SupervisorIdea> model) {
|
||||
super(id, model);
|
||||
add(new ProjectIdeaDetailsPanel("ideaDetails", model, true));
|
||||
add(new ProjectIdeaWatsonPanel("watsonDetails", model));
|
||||
addSaveButton(model);
|
||||
}
|
||||
|
||||
private void addSaveButton(final IModel<SupervisorIdea> model) {
|
||||
Button button = new Button("saveButton") {
|
||||
|
||||
private static final long serialVersionUID = 8805671593150004137L;
|
||||
|
||||
@Override
|
||||
public void onSubmit() {
|
||||
ideaService.updateIdea(model);
|
||||
getSession().info("Project idea updated");
|
||||
}
|
||||
};
|
||||
button.add(new JavascriptEventConfirmation("onClick", "Are you sure you want to save your changes?"));
|
||||
add(button);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
<!DOCTYPE html>
|
||||
<html
|
||||
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<head>
|
||||
<meta http-equiv="Content-type" content="text/html;charset=UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<div class="append-bottom"><b>Level: </b><br />
|
||||
<span wicket:id="level"></span>
|
||||
</div>
|
||||
<div class="append-bottom"><b>Required prerequisites:</b><br />
|
||||
<span wicket:id="reqs"></span>
|
||||
</div>
|
||||
<div class="append-bottom"><b>Title:</b><br />
|
||||
<span wicket:id="title"></span>
|
||||
</div>
|
||||
<div class="append-bottom"><b>Description:</b><br />
|
||||
<span wicket:id="description"></span>
|
||||
</div>
|
||||
<div class="append-bottom"><b>Research area:</b><br />
|
||||
<span wicket:id="noAreaLabel"></span>
|
||||
<span wicket:id="researchAreas"><span wicket:id="areaName"></span><br /></span>
|
||||
</div>
|
||||
<div class="append-bottom"><b>Keywords:</b><br />
|
||||
<span wicket:id="noKeysLabel"></span>
|
||||
<span wicket:id="keywords"><span wicket:id="keyName"></span><br /></span>
|
||||
</div>
|
||||
<div class="append-bottom" wicket:id="authorsEnclosure">
|
||||
<b>Authors:</b><br />
|
||||
<span wicket:id="authorList"><span wicket:id="authorName"></span><br /></span>
|
||||
</div>
|
||||
</wicket:panel>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,88 @@
|
||||
package se.su.dsv.scipro.project.panels;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.wicket.markup.html.basic.EnclosureContainer;
|
||||
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.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.data.dataobjects.ResearchArea;
|
||||
import se.su.dsv.scipro.data.dataobjects.Student;
|
||||
import se.su.dsv.scipro.match.dataobject.IdeaParticipation;
|
||||
import se.su.dsv.scipro.match.dataobject.Keyword;
|
||||
import se.su.dsv.scipro.match.dataobject.SupervisorIdea;
|
||||
import se.su.dsv.scipro.springdata.services.SupervisorService;
|
||||
|
||||
public class ProjectIdeaDetailsPanel extends Panel {
|
||||
|
||||
private static final long serialVersionUID = -8165939637975042836L;
|
||||
@SpringBean
|
||||
private SupervisorService supervisorService;
|
||||
|
||||
public ProjectIdeaDetailsPanel(String id, IModel<SupervisorIdea> model, boolean showAuthors) {
|
||||
super(id, model);
|
||||
Employee ideaCreator = supervisorService.findOne(model.getObject().getCreator().getId());
|
||||
add(new Label("level", model.getObject().getProjectClass().getName()));
|
||||
add(new Label("reqs", model.getObject().getRequirements()));
|
||||
add(new Label("title", model.getObject().getTitle()));
|
||||
add(new Label("description", model.getObject().getDescription()));
|
||||
addResearchAreas(ideaCreator);
|
||||
addKeywords(model);
|
||||
addAuthorsEnclosure(model, showAuthors); //List of authors so the partner knows who to write with before accepting
|
||||
}
|
||||
|
||||
private void addResearchAreas(Employee ideaCreator) {
|
||||
final Set<ResearchArea> areas = ideaCreator.getActiveResearchAreas();
|
||||
ListView<ResearchArea> areaList = new ListView<ResearchArea>("researchAreas", new ArrayList<ResearchArea>(areas)) {
|
||||
private static final long serialVersionUID = 1745649109195334927L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(ListItem<ResearchArea> item) {
|
||||
item.add(new Label("areaName", item.getModelObject().getTitle()));
|
||||
}
|
||||
};
|
||||
add(new Label("noAreaLabel","No research area available").setVisible(areas.isEmpty()));
|
||||
add(areaList);
|
||||
}
|
||||
|
||||
private void addKeywords(IModel<SupervisorIdea> model) {
|
||||
final Set<Keyword> keywords = model.getObject().getKeywords();
|
||||
ListView<Keyword> keyList = new ListView<Keyword>("keywords", new ArrayList<Keyword>(keywords)) {
|
||||
private static final long serialVersionUID = 470796140309547562L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(ListItem<Keyword> item) {
|
||||
item.add(new Label("keyName", item.getModelObject().getKeyword()));
|
||||
}
|
||||
|
||||
};
|
||||
add(new Label("noKeysLabel", "No keywords available").setVisible(keywords.isEmpty()));
|
||||
add(keyList);
|
||||
}
|
||||
|
||||
private void addAuthorsEnclosure(IModel<SupervisorIdea> model, boolean showAuthors) {
|
||||
List<Student> authors = new ArrayList<Student>();
|
||||
for (IdeaParticipation ip : model.getObject().getIdeaParticipations())
|
||||
authors.add(ip.getStudent());
|
||||
ListView<Student> authorList = new ListView<Student>("authorList", authors) {
|
||||
private static final long serialVersionUID = -3951835080975833866L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(ListItem<Student> item) {
|
||||
item.add(new Label("authorName", item.getModelObject().getNameAsString()));
|
||||
}
|
||||
};
|
||||
authorList.setVisible(showAuthors);
|
||||
EnclosureContainer authorEnc = new EnclosureContainer("authorsEnclosure", authorList);
|
||||
authorEnc.add(authorList);
|
||||
add(authorEnc);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html
|
||||
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<head>
|
||||
<meta http-equiv="Content-type" content="text/html;charset=UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<b>What?</b><br />
|
||||
<textarea class="span-12" wicket:id="watsonWhat"></textarea>
|
||||
<b>Why?</b><br />
|
||||
<textarea class="span-12" wicket:id="watsonWhy"></textarea>
|
||||
<b>Theoretically how?</b><br />
|
||||
<textarea class="span-12" wicket:id="watsonHowTheory"></textarea>
|
||||
<b>Practically how?</b><br />
|
||||
<textarea class="span-12" wicket:id="watsonHowPrac"></textarea>
|
||||
</wicket:panel>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,36 @@
|
||||
package se.su.dsv.scipro.project.panels;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.form.TextArea;
|
||||
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.PropertyModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.data.dataobjects.ResearchArea;
|
||||
import se.su.dsv.scipro.match.dataobject.Keyword;
|
||||
import se.su.dsv.scipro.match.dataobject.SupervisorIdea;
|
||||
import se.su.dsv.scipro.springdata.services.SupervisorService;
|
||||
|
||||
public class ProjectIdeaWatsonPanel extends Panel {
|
||||
|
||||
private static final long serialVersionUID = -8165939637975042836L;
|
||||
@SpringBean
|
||||
private SupervisorService supervisorService;
|
||||
|
||||
public ProjectIdeaWatsonPanel(String id, IModel<SupervisorIdea> model) {
|
||||
super(id, model);
|
||||
add(new TextArea<String>("watsonWhat", new PropertyModel<String>(model, "watson.what")));
|
||||
add(new TextArea<String>("watsonWhy", new PropertyModel<String>(model, "watson.why")));
|
||||
add(new TextArea<String>("watsonHowTheory", new PropertyModel<String>(model, "watson.theoryHow")));
|
||||
add(new TextArea<String>("watsonHowPrac", new PropertyModel<String>(model, "watson.practicalHow")));
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -22,6 +22,6 @@ public interface SupervisorIdeaRepo extends JpaRepository<SupervisorIdea, Long>,
|
||||
@Query("select idea from SupervisorIdea idea, Student author join idea.ideaParticipations ideaPart join author.ideaParticipations authorPart where ideaPart = authorPart and author = ? and idea.ideaStatus = ?")
|
||||
List<SupervisorIdea> findIdeasByAuthorAndStatus(Student author, IdeaStatus status);
|
||||
|
||||
@Query("select idea from SupervisorIdea idea, Student author join idea.ideaParticipations ideaPart join author.ideaParticipations authorPart where ideaPart = authorPart and author = ? and idea.ideaStatus = ? and ideaPart.confirmed = false")
|
||||
List<SupervisorIdea> findUnconfirmedIdeasByAuthorAndStatus(Student author, IdeaStatus status);
|
||||
@Query("select idea from SupervisorIdea idea, Student author join idea.ideaParticipations ideaPart join author.ideaParticipations authorPart where ideaPart = authorPart and author = ? and idea.ideaStatus = ? and ideaPart.confirmed = ?")
|
||||
List<SupervisorIdea> findIdeas(Student author, IdeaStatus status, boolean confirmed);
|
||||
}
|
||||
|
@ -142,15 +142,25 @@ public class SupervisorIdeaServiceImpl extends AbstractQueryService<SupervisorId
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional ( readOnly = false )
|
||||
public void updateIdea(IModel<SupervisorIdea> model) {
|
||||
SupervisorIdea idea = supervisorIdeaRepo.findOne(model.getObject().getId());
|
||||
idea.getWatson().setWhat(model.getObject().getWatson().getWhat());
|
||||
idea.getWatson().setWhy(model.getObject().getWatson().getWhy());
|
||||
idea.getWatson().setTheoryHow(model.getObject().getWatson().getTheoryHow());
|
||||
idea.getWatson().setPracticalHow(model.getObject().getWatson().getPracticalHow());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean hasUnconfirmedIdea(User authorUser) {
|
||||
public boolean hasTakenIdeas(User authorUser, boolean confirmed) {
|
||||
Student author = studentService.findByUser(authorUser);
|
||||
|
||||
// find unconfirmed ideas by author
|
||||
List<SupervisorIdea> unconfirmedIdeas = findUnconfirmedIdeasByStatusAndAuthor(IdeaStatus.TAKEN, author);
|
||||
List<SupervisorIdea> ideas = findIdeas(IdeaStatus.TAKEN, author, confirmed);
|
||||
|
||||
if(!unconfirmedIdeas.isEmpty())
|
||||
if(!ideas.isEmpty())
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
@ -183,11 +193,11 @@ public class SupervisorIdeaServiceImpl extends AbstractQueryService<SupervisorId
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SupervisorIdea> findUnconfirmedIdeasByStatusAndAuthor(IdeaStatus status, Student author) {
|
||||
List<SupervisorIdea> ideas = supervisorIdeaRepo.findUnconfirmedIdeasByAuthorAndStatus(author, status);
|
||||
public List<SupervisorIdea> findIdeas(IdeaStatus status, Student author, boolean confirmed) {
|
||||
List<SupervisorIdea> ideas = supervisorIdeaRepo.findIdeas(author, status, confirmed);
|
||||
return ideas;
|
||||
}
|
||||
|
||||
|
||||
private Predicate predicateFromParams(FilterParams params) {
|
||||
return levelFilter(params.getLevels()).and(bySupervisor(params.getSupervisor()));
|
||||
}
|
||||
@ -222,11 +232,6 @@ public class SupervisorIdeaServiceImpl extends AbstractQueryService<SupervisorId
|
||||
private BooleanExpression byStatus(IdeaStatus status){
|
||||
return QSupervisorIdea.supervisorIdea.ideaStatus.eq(status);
|
||||
}
|
||||
|
||||
private BooleanExpression byAuthor(Student author){
|
||||
return QSupervisorIdea.supervisorIdea.ideaParticipations.any().pk.student.eq(author);
|
||||
//return QSupervisorIdea.supervisorIdea.authors.contains(author);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countByStatus(IdeaStatus status) {
|
||||
|
@ -8,7 +8,6 @@ import java.util.SortedSet;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
@ -22,7 +21,7 @@ public interface SupervisorIdeaService extends GenericService<SupervisorIdea, Lo
|
||||
Page<SupervisorIdea> findAll(FilterParams params, Pageable pageable);
|
||||
Page<SupervisorIdea> findByStatus(IdeaStatus status, Pageable pageable);
|
||||
List<SupervisorIdea> findByStatusAndAuthor(IdeaStatus status, Student author);
|
||||
List<SupervisorIdea> findUnconfirmedIdeasByStatusAndAuthor(IdeaStatus status, Student author);
|
||||
List<SupervisorIdea> findIdeas(IdeaStatus status, Student author, boolean confirmed);
|
||||
|
||||
Long countByStatus(IdeaStatus status);
|
||||
|
||||
@ -30,9 +29,10 @@ public interface SupervisorIdeaService extends GenericService<SupervisorIdea, Lo
|
||||
void deleteWaitingIdea(IModel<SupervisorIdea> model);
|
||||
void partnerAcceptIdea(IModel<SupervisorIdea> model, User loggedInUser);
|
||||
void partnerDeclineIdea(IModel<SupervisorIdea> model);
|
||||
void updateIdea(IModel<SupervisorIdea> model);
|
||||
|
||||
boolean acceptIdea(IModel<SupervisorIdea> model, User mainAuthor, SortedSet<Student> sortedSet);
|
||||
boolean hasUnconfirmedIdea(User authorUser);
|
||||
boolean hasTakenIdeas(User authorUser, boolean confirmed);
|
||||
boolean isIdeaEditable(IModel<SupervisorIdea> model, User currentUser);
|
||||
|
||||
public static class FilterParams implements Serializable {
|
||||
|
@ -36,7 +36,6 @@ import se.su.dsv.scipro.match.dataobject.Keyword;
|
||||
import se.su.dsv.scipro.match.dataobject.KeywordType;
|
||||
import se.su.dsv.scipro.match.dataobject.SupervisorIdea;
|
||||
import se.su.dsv.scipro.match.facade.ApplicationPeriodFacade;
|
||||
import se.su.dsv.scipro.springdata.repos.SupervisorIdeaRepo;
|
||||
import se.su.dsv.scipro.springdata.services.ProjectClassService;
|
||||
import se.su.dsv.scipro.springdata.services.RoleService;
|
||||
import se.su.dsv.scipro.springdata.services.SupervisorIdeaService;
|
||||
@ -213,7 +212,7 @@ public class TestSupervisorIdea {
|
||||
@Transactional
|
||||
@Rollback
|
||||
public void testIfAuthorHaveUnconfirmedParticipationOnIdea() {
|
||||
boolean shouldBeFalse = ideaService.hasUnconfirmedIdea(authorUser1);
|
||||
boolean shouldBeFalse = ideaService.hasTakenIdeas(authorUser1, false);
|
||||
Assert.assertFalse("Not false",shouldBeFalse);
|
||||
|
||||
IdeaParticipation participation = new IdeaParticipation();
|
||||
@ -222,7 +221,7 @@ public class TestSupervisorIdea {
|
||||
participation.setConfirmed(false);
|
||||
author2.addIdeaParticipation(participation);
|
||||
|
||||
boolean shouldBeTrue = ideaService.hasUnconfirmedIdea(authorUser2);
|
||||
boolean shouldBeTrue = ideaService.hasTakenIdeas(authorUser2, false);
|
||||
Assert.assertTrue("Not true",shouldBeTrue);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user