UC Modify conference finit normalement

This commit is contained in:
Frederic Debuire
2008-02-11 15:20:44 +00:00
parent 5fcf032b9f
commit a195dd4a7e
8 changed files with 185 additions and 73 deletions

View File

@@ -118,7 +118,8 @@ preference.ok=You have successfully chosen all your preferences about each artic
dispatch.title=Dispatch the articles to the members dispatch.title=Dispatch the articles to the members
# Conference Form # Conference Form
conference.titleMenu=Add a conference conference.titleAdd=Add a conference
conference.titleModify=Modify a conference
conference.title=Title conference.title=Title
conference.description=Description conference.description=Description
conference.otherInformations=Complementary information conference.otherInformations=Complementary information

View File

@@ -18,7 +18,7 @@
<h4><fmt:message key="menu.chairman.title" /></h4> <h4><fmt:message key="menu.chairman.title" /></h4>
<ul> <ul>
<li><a href="<c:url value="addConference.htm"/>"><fmt:message key="menu.chairman.conference.create" /></a></li> <li><a href="<c:url value="addConference.htm"/>"><fmt:message key="menu.chairman.conference.create" /></a></li>
<li><a href="<c:url value="#"/>"><fmt:message key="menu.chairman.conference.modify" /></a></li> <li><a href="<c:url value="addConference.htm?action=modify"/>"><fmt:message key="menu.chairman.conference.modify" /></a></li>
<li><a href="<c:url value="dispatchArticleList.htm"/>"><fmt:message key="menu.chairman.article.dispatch" /></a></li> <li><a href="<c:url value="dispatchArticleList.htm"/>"><fmt:message key="menu.chairman.article.dispatch" /></a></li>
<li><a href="<c:url value="#"/>"><fmt:message key="menu.chairman.article.validate" /></a></li> <li><a href="<c:url value="#"/>"><fmt:message key="menu.chairman.article.validate" /></a></li>
</ul> </ul>

View File

@@ -4,7 +4,17 @@
<head></head> <head></head>
<body> <body>
<h4 class="title"><fmt:message key="conference.titleMenu" /></h4> <h4 class="title">
<c:choose>
<c:when test="${param['action'] eq 'modify'}">
<fmt:message key="conference.titleModify" />
</c:when>
<c:otherwise>
<fmt:message key="conference.titleAdd" />
</c:otherwise>
</c:choose>
</h4>
<form:form commandName="formConference" name="monForm"> <form:form commandName="formConference" name="monForm">
<fmt:message key="conference.title" /> <form:input path="title"/> <form:errors path="title" /> <br/><br /> <fmt:message key="conference.title" /> <form:input path="title"/> <form:errors path="title" /> <br/><br />

View File

@@ -8,7 +8,16 @@
<body> <body>
<h4 class="title"><fmt:message key="conference.titleMenu" /></h4> <h4 class="title">
<c:choose>
<c:when test="${param['action'] eq 'modify'}">
<fmt:message key="conference.titleModify" />
</c:when>
<c:otherwise>
<fmt:message key="conference.titleAdd" />
</c:otherwise>
</c:choose>
</h4>
<form:form commandName="formConference" name="monForm"> <form:form commandName="formConference" name="monForm">

View File

@@ -5,7 +5,16 @@
<body> <body>
<h4 class="title"><fmt:message key="conference.titleMenu" /></h4> <h4 class="title">
<c:choose>
<c:when test="${param['action'] eq 'modify'}">
<fmt:message key="conference.titleModify" />
</c:when>
<c:otherwise>
<fmt:message key="conference.titleAdd" />
</c:otherwise>
</c:choose>
</h4>
<form:form commandName="formConference" name="monForm"> <form:form commandName="formConference" name="monForm">

View File

@@ -128,7 +128,16 @@ function clearPerson() {
<body> <body>
<h4 class="title"><fmt:message key="conference.titleMenu" /></h4> <h4 class="title">
<c:choose>
<c:when test="${param['action'] eq 'modify'}">
<fmt:message key="conference.titleModify" />
</c:when>
<c:otherwise>
<fmt:message key="conference.titleAdd" />
</c:otherwise>
</c:choose>
</h4>
<form:form commandName="formConference" name="monForm"> <form:form commandName="formConference" name="monForm">

View File

@@ -116,7 +116,16 @@ function filterUser(el, value) {
</head> </head>
<body> <body>
<h4 class="title"><fmt:message key="conference.titleMenu" /></h4> <h4 class="title">
<c:choose>
<c:when test="${param['action'] eq 'modify'}">
<fmt:message key="conference.titleModify" />
</c:when>
<c:otherwise>
<fmt:message key="conference.titleAdd" />
</c:otherwise>
</c:choose>
</h4>
<form:form commandName="formConference" name="monForm"> <form:form commandName="formConference" name="monForm">

View File

@@ -33,7 +33,7 @@ public class AddConferenceController extends AbstractWizardFormController {
private IConferenceManager conferenceManager; private IConferenceManager conferenceManager;
private IUserManager userManager; private IUserManager userManager;
private IEvaluationManager evaluationManager; private IEvaluationManager evaluationManager;
public IEvaluationManager getEvaluationManager() { public IEvaluationManager getEvaluationManager() {
@@ -88,7 +88,7 @@ public class AddConferenceController extends AbstractWizardFormController {
listPersonBean.remove(truePerson); listPersonBean.remove(truePerson);
listPersonFiltered.remove(truePerson); listPersonFiltered.remove(truePerson);
} }
public void addInvitation(String email){ public void addInvitation(String email){
PersonBean invitationBean = new PersonBean(); PersonBean invitationBean = new PersonBean();
invitationBean.setLogin(email); invitationBean.setLogin(email);
@@ -145,7 +145,7 @@ public class AddConferenceController extends AbstractWizardFormController {
private Set<CriterionBean> criteria; private Set<CriterionBean> criteria;
private Set<CriterionBean> criteriaAll; private Set<CriterionBean> criteriaAll;
public Set<CriterionBean> getCriteriaAll() { public Set<CriterionBean> getCriteriaAll() {
return criteriaAll; return criteriaAll;
} }
@@ -153,7 +153,7 @@ public class AddConferenceController extends AbstractWizardFormController {
public Set<CriterionBean> getCriteriaAdded() { public Set<CriterionBean> getCriteriaAdded() {
return criteria; return criteria;
} }
public CriterionBean getTrueCriteria(int id) { public CriterionBean getTrueCriteria(int id) {
for (CriterionBean cb : criteriaAll) { for (CriterionBean cb : criteriaAll) {
if (cb.getId() == id){ if (cb.getId() == id){
@@ -166,15 +166,15 @@ public class AddConferenceController extends AbstractWizardFormController {
return cb; return cb;
} }
} }
return null; return null;
} }
public void setCriterionClick(CriterionBean c) { public void setCriterionClick(CriterionBean c) {
if (c.getId() == -1) { if (c.getId() == -1) {
c.setId(getNextId()); c.setId(getNextId());
} }
criteria.remove(c); criteria.remove(c);
criteria.add(c); criteria.add(c);
} }
@@ -185,18 +185,18 @@ public class AddConferenceController extends AbstractWizardFormController {
} }
CriterionBean trueCriteria = getTrueCriteria(c.getId()); CriterionBean trueCriteria = getTrueCriteria(c.getId());
criteria.remove(trueCriteria); criteria.remove(trueCriteria);
criteria.add(trueCriteria); criteria.add(trueCriteria);
criteriaAll.remove(trueCriteria); criteriaAll.remove(trueCriteria);
} }
public void deleteCriterion(CriterionBean c) { public void deleteCriterion(CriterionBean c) {
CriterionBean trueCriteria = getTrueCriteria(c.getId()); CriterionBean trueCriteria = getTrueCriteria(c.getId());
criteria.remove(trueCriteria); criteria.remove(trueCriteria);
criteriaAll.add(trueCriteria); criteriaAll.add(trueCriteria);
} }
@@ -216,18 +216,27 @@ public class AddConferenceController extends AbstractWizardFormController {
protected Object formBackingObject(HttpServletRequest request) throws ModelAndViewDefiningException { protected Object formBackingObject(HttpServletRequest request) throws ModelAndViewDefiningException {
logger.info(this.getClass().toString() + " dans le formBackingObject"); logger.info(this.getClass().toString() + " dans le formBackingObject");
FormConference conference = new FormConference(); FormConference conference = new FormConference();
String action = request.getParameter("action"); String action = request.getParameter("action");
if (action == null || action.equals("")) if (action == null || action.equals("")) {
{ // TODO : tester ici si le gars a le droit d'<27>tre ici
// TODO : tester ici si le gars a le droit d'<27>tre ici // a-t-il le droit de cr<63>er une conf<6E>rence ?
// a-t-il le droit de cr<63>er une conf<6E>rence ?
criteria = new HashSet<CriterionBean>(); criteria = new HashSet<CriterionBean>();
criteriaAll = new HashSet<CriterionBean>(); criteriaAll = new HashSet<CriterionBean>();
List<Criterion> listCriterion = evaluationManager.getCriterions(); List<Criterion> listCriterion = evaluationManager.getCriterions();
int maxNext = 0;
for (Criterion crit : listCriterion) {
if (maxNext <= crit.getId())
maxNext = crit.getId();
}
nextId = maxNext + 1;
for (Criterion crit : listCriterion) { for (Criterion crit : listCriterion) {
CriterionBean cb = new CriterionBean(); CriterionBean cb = new CriterionBean();
cb.setId(crit.getId()); cb.setId(crit.getId());
@@ -237,7 +246,7 @@ public class AddConferenceController extends AbstractWizardFormController {
criteriaAll.add(cb); criteriaAll.add(cb);
getNextId(); getNextId();
} }
listPersonBean = new ArrayList<PersonBean>(); listPersonBean = new ArrayList<PersonBean>();
listPersonAdded = new ArrayList<PersonBean>(); listPersonAdded = new ArrayList<PersonBean>();
listPersonFiltered = listPersonBean; listPersonFiltered = listPersonBean;
@@ -250,16 +259,26 @@ public class AddConferenceController extends AbstractWizardFormController {
pb.setLogin(user.getLogin()); pb.setLogin(user.getLogin());
listPersonBean.add(pb); listPersonBean.add(pb);
} }
return conference; return conference;
} }
else if (action.equals("modify")) { else if (action.equals("modify")) {
Conference conf = SessionService.getInstance().getCurrentConference(); Conference conf = SessionService.getInstance().getCurrentConference();
criteria = new HashSet<CriterionBean>(); criteria = new HashSet<CriterionBean>();
criteriaAll = new HashSet<CriterionBean>(); criteriaAll = new HashSet<CriterionBean>();
List<Criterion> listCriterionForConf = evaluationManager.getCriterions(conf.getId()); List<Criterion> listCriterionForConf = evaluationManager.getCriterions(conf.getId());
List<Criterion> listCriterion = evaluationManager.getCriterions();
int maxNext = 0;
for (Criterion crit : listCriterion) {
if (maxNext <= crit.getId())
maxNext = crit.getId();
}
nextId = maxNext + 1;
for (Criterion crit : listCriterionForConf) { for (Criterion crit : listCriterionForConf) {
CriterionBean cb = new CriterionBean(); CriterionBean cb = new CriterionBean();
cb.setId(crit.getId()); cb.setId(crit.getId());
@@ -269,8 +288,7 @@ public class AddConferenceController extends AbstractWizardFormController {
criteria.add(cb); criteria.add(cb);
getNextId(); getNextId();
} }
List<Criterion> listCriterion = evaluationManager.getCriterions();
for (Criterion crit : listCriterion) { for (Criterion crit : listCriterion) {
CriterionBean cb = new CriterionBean(); CriterionBean cb = new CriterionBean();
cb.setId(crit.getId()); cb.setId(crit.getId());
@@ -280,7 +298,15 @@ public class AddConferenceController extends AbstractWizardFormController {
criteriaAll.add(cb); criteriaAll.add(cb);
getNextId(); getNextId();
} }
// remove of the criteria already added
Set<CriterionBean> criteriaAllIter = new HashSet<CriterionBean>(criteriaAll);
for (CriterionBean crit : criteriaAllIter)
for (CriterionBean crit2 : criteria)
if (crit.getId() == crit2.getId())
criteriaAll.remove(crit);
listPersonBean = new ArrayList<PersonBean>(); listPersonBean = new ArrayList<PersonBean>();
listPersonAdded = new ArrayList<PersonBean>(); listPersonAdded = new ArrayList<PersonBean>();
listPersonFiltered = listPersonBean; listPersonFiltered = listPersonBean;
@@ -293,11 +319,8 @@ public class AddConferenceController extends AbstractWizardFormController {
pb.setLogin(user.getLogin()); pb.setLogin(user.getLogin());
listPersonBean.add(pb); listPersonBean.add(pb);
} }
List<User> listUsersForConf = userManager.getUsers(conf.getId(), RoleType.PCMEMBER);
// FIXME : bug here when we remove a person
// and remove the person added from the list above
List<User> listUsersForConf = userManager.getUsers(conf.getId());
for (User user : listUsersForConf) { for (User user : listUsersForConf) {
PersonBean pb = new PersonBean(); PersonBean pb = new PersonBean();
pb.setId(getNextPerson()); pb.setId(getNextPerson());
@@ -306,9 +329,16 @@ public class AddConferenceController extends AbstractWizardFormController {
pb.setLogin(user.getLogin()); pb.setLogin(user.getLogin());
listPersonAdded.add(pb); listPersonAdded.add(pb);
} }
// remove of the person already added
List<PersonBean> listPersonIter = new ArrayList<PersonBean>(listPersonBean);
for (PersonBean person : listPersonIter)
for (PersonBean person2 : listPersonAdded)
if (person.getLogin().equals(person2.getLogin()))
listPersonBean.remove(person);
DateFormat format = new SimpleDateFormat("yyyy-MM-dd"); DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
conference.setTitle(conf.getTitle()); conference.setTitle(conf.getTitle());
conference.setDateArticleParsed(conf.getDateArticle()); conference.setDateArticleParsed(conf.getDateArticle());
conference.setDateArticle(format.format(conf.getDateArticle())); conference.setDateArticle(format.format(conf.getDateArticle()));
@@ -320,7 +350,7 @@ public class AddConferenceController extends AbstractWizardFormController {
conference.setDateStart(format.format(conf.getDateStart())); conference.setDateStart(format.format(conf.getDateStart()));
conference.setDescription(conf.getDescription()); conference.setDescription(conf.getDescription());
conference.setOtherInformations(conf.getOtherInformations()); conference.setOtherInformations(conf.getOtherInformations());
// TODO : ajouter ca ds conf ejb... // TODO : ajouter ca ds conf ejb...
/*conference.setPageNumber(pageNumber); /*conference.setPageNumber(pageNumber);
conference.setSendInfo(sendInfo); conference.setSendInfo(sendInfo);
@@ -328,18 +358,18 @@ public class AddConferenceController extends AbstractWizardFormController {
conference.setTypeODT(typeODT); conference.setTypeODT(typeODT);
conference.setTypePDF(typePDF); conference.setTypePDF(typePDF);
conference.setTypeWord(typeWord);*/ conference.setTypeWord(typeWord);*/
return conference; return conference;
} }
else { else {
throw new ModelAndViewDefiningException(new ModelAndView("404error")); throw new ModelAndViewDefiningException(new ModelAndView("404error"));
} }
} }
protected void validatePage(Object command, Errors errors, int page) { protected void validatePage(Object command, Errors errors, int page) {
FormConference conference = (FormConference) command; FormConference conference = (FormConference) command;
ConferenceValidator conferenceValidator = (ConferenceValidator) getValidator(); ConferenceValidator conferenceValidator = (ConferenceValidator) getValidator();
@@ -360,36 +390,71 @@ public class AddConferenceController extends AbstractWizardFormController {
HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) { HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) {
FormConference conference = (FormConference) command; FormConference conference = (FormConference) command;
String action = request.getParameter("action");
Conference conf = conferenceManager.addConference( if (action == null || action.equals("")) {
conference.getTitle(),
conference.getDescription(), Conference conf = conferenceManager.addConference(
conference.getOtherInformations(), conference.getTitle(),
conference.getDateArticleParsed(), conference.getDescription(),
conference.getDateArticleParsed(), conference.getOtherInformations(),
conference.getDateEvaluationParsed(), conference.getDateArticleParsed(),
conference.getDateStartParsed(), conference.getDateArticleParsed(),
conference.getDateEndParsed()); conference.getDateEvaluationParsed(),
conference.getDateStartParsed(),
conference.setConferenceId(conf.getId()); conference.getDateEndParsed());
SessionService.getInstance().setCurrentConference(conf);
conference.setConferenceId(conf.getId());
for(CriterionBean criterion : criteria){ SessionService.getInstance().setCurrentConference(conf);
conferenceManager.addCriterionToConference(
conf.getId(), for(CriterionBean criterion : criteria){
criterion.getLabel(), conferenceManager.addCriterionToConference(
criterion.getMin(), conf.getId(),
criterion.getMax()); criterion.getLabel(),
criterion.getMin(),
criterion.getMax());
}
for(PersonBean personBean : listPersonAdded){
conferenceManager.addPCMemberToConference(
conf.getId(),
personBean.getLogin());
}
conferenceManager.addRole(RoleType.CHAIRMAN, SessionService.getInstance().getCurrentUserLogin(), conf.getId());
} }
else {
for(PersonBean personBean : listPersonAdded){ Conference conf = SessionService.getInstance().getCurrentConference();
conferenceManager.addPCMemberToConference( conf.setTitle(conference.getTitle());
conf.getId(), conf.setDescription(conference.getDescription());
personBean.getLogin()); conf.setOtherInformations(conference.getOtherInformations());
conf.setDateArticle(conference.getDateArticleParsed());
conf.setDateAbstract(conference.getDateArticleParsed());
conf.setDateEnd(conference.getDateEndParsed());
conf.setDateStart(conference.getDateStartParsed());
conf.setDateEvaluation(conference.getDateEvaluationParsed());
conferenceManager.update(conf);
conferenceManager.removeCriterionToConference(conf.getId());
for(CriterionBean criterion : criteria){
conferenceManager.addCriterionToConference(
conf.getId(),
criterion.getLabel(),
criterion.getMin(),
criterion.getMax());
}
conferenceManager.removePCMemberForConf(conf.getId());
for(PersonBean personBean : listPersonAdded){
conferenceManager.addPCMemberToConference(
conf.getId(),
personBean.getLogin());
}
} }
conferenceManager.addRole(RoleType.CHAIRMAN, SessionService.getInstance().getCurrentUserLogin(), conf.getId());
return new ModelAndView("main"); return new ModelAndView("main");
} }