diff --git a/YACOSWeb/WebContent/WEB-INF/yacos-servlet.xml b/YACOSWeb/WebContent/WEB-INF/yacos-servlet.xml index 4839d8f..699e917 100644 --- a/YACOSWeb/WebContent/WEB-INF/yacos-servlet.xml +++ b/YACOSWeb/WebContent/WEB-INF/yacos-servlet.xml @@ -238,8 +238,7 @@ + class="org.yacos.web.chairman.controller.AddConferenceController"> @@ -247,8 +246,10 @@ value="org.yacos.web.chairman.form.FormConference" /> - - + + + + + class="org.yacos.core.conferences.CriterionBean"> + class="org.yacos.core.conferences.PersonBean"> + listPersonBean; - private List listPersonFiltered; - private List listPersonAdded; - private List listInvitations; - + public void fillUser(String text) { - if (text.equals("")) - listPersonFiltered = listPersonBean; - else { - listPersonFiltered = new ArrayList(); - for (PersonBean b : listPersonBean) { - if (b.getFirstName().toLowerCase().startsWith(text.toLowerCase()) || b.getLastName().toLowerCase().startsWith(text.toLowerCase())){ - listPersonFiltered.add(b); - } - } - } + conferenceSession.fillUser(text); + } - - public void setPerson(PersonBean b) { - if (b.getId() == -1) { - b.setId(getNextPerson()); - } - - PersonBean truePerson = getTruePerson(b.getLogin()); - - listPersonAdded.remove(truePerson); - listPersonAdded.add(truePerson); - listPersonBean.remove(truePerson); - listPersonFiltered.remove(truePerson); + + public void setPerson(PersonBean b){ + conferenceSession.setPerson(b); } - - public void deletePerson(PersonBean b) { - - PersonBean truePerson = getTruePerson(b.getLogin()); - - listPersonAdded.remove(truePerson); - listPersonBean.add(truePerson); + + public void deletePerson(PersonBean b){ + conferenceSession.deletePerson(b); } - - public PersonBean getTruePerson(String login) { - for (PersonBean b : listPersonBean) { - if (b.getLogin().equals(login)){ - return b; - } - } - - for (PersonBean b : listPersonAdded) { - if (b.getLogin().equals(login)){ - return b; - } - } - - return null; + + public List getUsersFiltered(){ + return conferenceSession.getUsersFiltered(); } - - - private static synchronized int getNextPerson() - { - return nextPerson++; + + public List getUsers(){ + return conferenceSession.getUsers(); } - - public List getUsersFiltered() { - return listPersonFiltered; + + public List getUsersAdded(){ + return conferenceSession.getUsersAdded(); } - - public List getUsers() { - return listPersonBean; - } - - public List getUsersAdded() { - return listPersonAdded; - } - + public List getInvitation(){ - return listInvitations; + return conferenceSession.getInvitation(); } - + public boolean addInvitation(String email){ - email = email.toLowerCase(); - Pattern emailPattern = Pattern.compile("^[a-z0-9._-]+@[a-z0-9._-]{2,}[.][a-z]{2,4}$"); // Regex - Matcher emailMatcher = emailPattern.matcher(email); - - if(!emailMatcher.matches()){ - return false; - } - - listInvitations.add(email); - - return true; + return conferenceSession.addInvitation(email); } - + public void removeInvitations(List emailList){ - for(String email : emailList){ - listInvitations.remove(email); - } + conferenceSession.removeInvitations(emailList); } - - - // ########################################################### - - - private static int nextId = 1; - - private Set criteria; - private Set criteriaAll; - - public Set getCriteriaAll() { - return criteriaAll; + + public Set getCriteriaAll(){ + return conferenceSession.getCriteriaAll(); } - - public Set getCriteriaAdded() { - return criteria; + + public Set getCriteriaAdded(){ + return conferenceSession.getCriteriaAdded(); } - - public CriterionBean getTrueCriteria(int id) { - for (CriterionBean cb : criteriaAll) { - if (cb.getId() == id){ - return cb; - } - } - - for (CriterionBean cb : criteria) { - if (cb.getId() == id){ - return cb; - } - } - - return null; + + public void setCriterionClick(CriterionBean c){ + conferenceSession.setCriterionClick(c); } - - public void setCriterionClick(CriterionBean c) { - if (c.getId() == -1) { - c.setId(getNextId()); - } - - criteria.remove(c); - criteria.add(c); + + public void setCriterion(CriterionBean c){ + conferenceSession.setCriterion(c); } - - public void setCriterion(CriterionBean c) { - if (c.getId() == -1) { - c.setId(getNextId()); - } - - CriterionBean trueCriteria = getTrueCriteria(c.getId()); - - criteria.remove(trueCriteria); - criteria.add(trueCriteria); - criteriaAll.remove(trueCriteria); + + public void deleteCriterion(CriterionBean c){ + conferenceSession.deleteCriterion(c); } - - public void deleteCriterion(CriterionBean c) { - - CriterionBean trueCriteria = getTrueCriteria(c.getId()); - - - - criteria.remove(trueCriteria); - criteriaAll.add(trueCriteria); - } - - private static synchronized int getNextId() - { - return nextId++; - } - - // ########################################################### - + public AddConferenceController() { setCommandName("formConference"); @@ -244,7 +132,7 @@ public class AddConferenceController extends AbstractWizardFormController { protected Object formBackingObject(HttpServletRequest request) throws ModelAndViewDefiningException { logger.info(this.getClass().toString() + " dans le formBackingObject"); - + FormConference conference = new FormConference(); String action = request.getParameter("action"); @@ -255,8 +143,13 @@ public class AddConferenceController extends AbstractWizardFormController { throw new ModelAndViewDefiningException(new ModelAndView("denied")); } - criteria = new HashSet(); - criteriaAll = new HashSet(); + SessionService.getInstance().resetCurrentConference(); + + + int nextId; + + conferenceSession.setCriteria(new HashSet()); + conferenceSession.setCriteriaAll(new HashSet()); List listCriterion = evaluationManager.getCriterions(); @@ -266,8 +159,12 @@ public class AddConferenceController extends AbstractWizardFormController { maxNext = crit.getId(); } + nextId = conferenceSession.getNextId2(); nextId = maxNext + 1; + conferenceSession.setNextId2(nextId); + Set criteriaAll = new HashSet(); + for (Criterion crit : listCriterion) { CriterionBean cb = new CriterionBean(); cb.setId(crit.getId()); @@ -275,17 +172,22 @@ public class AddConferenceController extends AbstractWizardFormController { cb.setMax(crit.getMax_rating()); cb.setMin(crit.getMin_rating()); criteriaAll.add(cb); - getNextId(); + conferenceSession.setNextId2(conferenceSession.getNextId2() + 1); } + conferenceSession.setCriteriaAll(criteriaAll); - listPersonBean = new ArrayList(); - listPersonAdded = new ArrayList(); - listInvitations = new ArrayList(); - listPersonFiltered = listPersonBean; + conferenceSession.setListPersonBean(new ArrayList()); + conferenceSession.setListPersonAdded(new ArrayList()); + conferenceSession.setListInvitations(new ArrayList()); + conferenceSession.setListPersonFiltered(conferenceSession.getUsersFiltered()); + + List listPersonBean = conferenceSession.getUsers(); + List listUsers = userManager.getUsers(); for (User user : listUsers) { PersonBean pb = new PersonBean(); - pb.setId(getNextPerson()); + conferenceSession.setNextPerson2(conferenceSession.getNextPerson2() + 1); + pb.setId(conferenceSession.getNextPerson2()); pb.setFirstName(user.getFirstName()); pb.setLastName(user.getLastName()); pb.setLogin(user.getLogin()); @@ -295,26 +197,33 @@ public class AddConferenceController extends AbstractWizardFormController { listPersonBean.add(pb); } } + conferenceSession.setListPersonBean(listPersonBean); return conference; } else if (action.equals("modify")) { Conference conf = SessionService.getInstance().getCurrentConference(); - criteria = new HashSet(); - criteriaAll = new HashSet(); + conferenceSession.setCriteria(new HashSet()); + conferenceSession.setCriteriaAll(new HashSet()); List listCriterionForConf = evaluationManager.getCriterions(conf.getId()); List listCriterion = evaluationManager.getCriterions(); + int nextId; + int maxNext = 0; for (Criterion crit : listCriterion) { if (maxNext <= crit.getId()) maxNext = crit.getId(); } + nextId = conferenceSession.getNextId2(); nextId = maxNext + 1; + conferenceSession.setNextId2(nextId); + + Set criteria = new HashSet(); for (Criterion crit : listCriterionForConf) { CriterionBean cb = new CriterionBean(); cb.setId(crit.getId()); @@ -322,9 +231,11 @@ public class AddConferenceController extends AbstractWizardFormController { cb.setMax(crit.getMax_rating()); cb.setMin(crit.getMin_rating()); criteria.add(cb); - getNextId(); + conferenceSession.setNextId2(conferenceSession.getNextId2() + 1); } + conferenceSession.setCriteria(criteria); + Set criteriaAll = new HashSet(); for (Criterion crit : listCriterion) { CriterionBean cb = new CriterionBean(); cb.setId(crit.getId()); @@ -332,52 +243,61 @@ public class AddConferenceController extends AbstractWizardFormController { cb.setMax(crit.getMax_rating()); cb.setMin(crit.getMin_rating()); criteriaAll.add(cb); - getNextId(); + conferenceSession.setNextId2(conferenceSession.getNextId2() + 1); } + // remove of the criteria already added Set criteriaAllIter = new HashSet(criteriaAll); - for (CriterionBean crit : criteriaAllIter) - for (CriterionBean crit2 : criteria) + for (CriterionBean crit : criteriaAllIter) { + Set criteriatmp = conferenceSession.getCriteriaAdded(); + for (CriterionBean crit2 : criteriatmp) if (crit.getId() == crit2.getId()) criteriaAll.remove(crit); + } + conferenceSession.setCriteriaAll(criteriaAll); - - listPersonBean = new ArrayList(); - listPersonAdded = new ArrayList(); - // Should get the invitation tokens and allow them to be removed - listInvitations = new ArrayList(); - listPersonFiltered = listPersonBean; + conferenceSession.setListPersonBean(new ArrayList()); + conferenceSession.setListPersonAdded(new ArrayList()); + conferenceSession.setListInvitations(new ArrayList()); + conferenceSession.setListPersonFiltered(conferenceSession.getUsersFiltered()); List listUsers = userManager.getUsers(); + List listPersonBean = conferenceSession.getUsers(); + for (User user : listUsers) { PersonBean pb = new PersonBean(); - pb.setId(getNextPerson()); + conferenceSession.setNextPerson2(conferenceSession.getNextPerson2() + 1); + pb.setId(conferenceSession.getNextPerson2()); pb.setFirstName(user.getFirstName()); pb.setLastName(user.getLastName()); pb.setLogin(user.getLogin()); - - if(!SessionService.getInstance().getCurrentUserLogin().equals(user.getLogin())){ - - listPersonBean.add(pb); - } - } + if(! SessionService.getInstance().getCurrentUserLogin().equals(user.getLogin())){ + listPersonBean.add(pb); + } + } + List listUsersForConf = userManager.getUsers(conf.getId(), RoleType.PCMEMBER); + List listPersonAddedTmp = new ArrayList(); for (User user : listUsersForConf) { PersonBean pb = new PersonBean(); - pb.setId(getNextPerson()); + conferenceSession.setNextPerson2(conferenceSession.getNextPerson2() + 1); + pb.setId(conferenceSession.getNextPerson2()); pb.setFirstName(user.getFirstName()); pb.setLastName(user.getLastName()); pb.setLogin(user.getLogin()); - listPersonAdded.add(pb); + listPersonAddedTmp.add(pb); } // remove of the person already added List listPersonIter = new ArrayList(listPersonBean); - for (PersonBean person : listPersonIter) - for (PersonBean person2 : listPersonAdded) + for (PersonBean person : listPersonIter) { + for (PersonBean person2 : listPersonAddedTmp) if (person.getLogin().equals(person2.getLogin())) listPersonBean.remove(person); + } + conferenceSession.setListPersonBean(listPersonBean); + DateFormat format = new SimpleDateFormat("yyyy-MM-dd"); @@ -460,7 +380,8 @@ public class AddConferenceController extends AbstractWizardFormController { conference.setConferenceId(conf.getId()); SessionService.getInstance().setCurrentConference(conf); - for(CriterionBean criterion : criteria){ + Set criteriaTmp = conferenceSession.getCriteriaAdded(); + for(CriterionBean criterion : criteriaTmp){ conferenceManager.addCriterionToConference( conf.getId(), criterion.getLabel(), @@ -468,7 +389,8 @@ public class AddConferenceController extends AbstractWizardFormController { criterion.getMax()); } - for(PersonBean personBean : listPersonAdded){ + List listPersonAddedTmp = conferenceSession.getUsersAdded(); + for(PersonBean personBean : listPersonAddedTmp){ conferenceManager.addPCMemberToConference( conf.getId(), personBean.getLogin()); @@ -490,7 +412,9 @@ public class AddConferenceController extends AbstractWizardFormController { mailBody += YACOSUtils.fullURL("registerUser.htm")+" \n"; mailBody += "Please note that you MUST use this eMail address in the registration form in order to get the appropriate credentials."; // TODO : use a template - for(String invitationEmail : listInvitations){ + + List listInvitationsTmp = conferenceSession.getInvitation(); + for(String invitationEmail : listInvitationsTmp){ try { conferenceManager.addInvitationToken(invitationEmail, RoleType.PCMEMBER, conf.getId()); MailSenderService.getInstance().sendEMail(invitationEmail, mailSubject , mailBody); @@ -529,7 +453,8 @@ public class AddConferenceController extends AbstractWizardFormController { conferenceManager.removeCriterionToConference(conf.getId()); - for(CriterionBean criterion : criteria){ + Set criteriaTmp = conferenceSession.getCriteriaAdded(); + for(CriterionBean criterion : criteriaTmp){ conferenceManager.addCriterionToConference( conf.getId(), criterion.getLabel(), @@ -538,8 +463,9 @@ public class AddConferenceController extends AbstractWizardFormController { } conferenceManager.removePCMemberForConf(conf.getId()); - - for(PersonBean personBean : listPersonAdded){ + + List listPersonAddedTmp = conferenceSession.getUsersAdded(); + for(PersonBean personBean : listPersonAddedTmp){ conferenceManager.addPCMemberToConference( conf.getId(), personBean.getLogin()); @@ -549,5 +475,11 @@ public class AddConferenceController extends AbstractWizardFormController { return new ModelAndView(new RedirectView("reportConfCreate.htm")); } + public IConferenceSession getConferenceSession() { + return conferenceSession; + } + public void setConferenceSession(IConferenceSession conferenceSession) { + this.conferenceSession = conferenceSession; + } } diff --git a/YACOSWeb/src/org/yacos/web/chairman/controller/CriterionBean.java b/YACOSWeb/src/org/yacos/web/chairman/controller/CriterionBean.java deleted file mode 100644 index 5902789..0000000 --- a/YACOSWeb/src/org/yacos/web/chairman/controller/CriterionBean.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.yacos.web.chairman.controller; - -public class CriterionBean { - - private int id; - private String label; - private int min; - private int max; - - public int getId() { - return id; - } - public void setId(int id) { - this.id = id; - } - public String getLabel() { - return label; - } - public void setLabel(String label) { - this.label = label; - } - public int getMin() { - return min; - } - public void setMin(int min) { - this.min = min; - } - public int getMax() { - return max; - } - public void setMax(int max) { - this.max = max; - } - - public int hashCode() - { - return 5924 + id; - } - - public boolean equals(Object obj) - { - if (obj == null) - { - return false; - } - - if (obj == this) - { - return true; - } - - if (!this.getClass().equals(obj.getClass())) - { - return false; - } - - CriterionBean that = (CriterionBean) obj; - - if (this.id != that.id) - { - return false; - } - - return true; - } - -} diff --git a/YACOSWeb/src/org/yacos/web/chairman/controller/PersonBean.java b/YACOSWeb/src/org/yacos/web/chairman/controller/PersonBean.java deleted file mode 100644 index 3036517..0000000 --- a/YACOSWeb/src/org/yacos/web/chairman/controller/PersonBean.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.yacos.web.chairman.controller; - -public class PersonBean { - - private int id; - private String firstName; - private String lastName; - private String login; - - public String getLogin() { - return login; - } - - public void setLogin(String login) { - this.login = login; - } - - public PersonBean() {} - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - -} diff --git a/YACOSWeb/src/org/yacos/web/chairman/form/FormConference.java b/YACOSWeb/src/org/yacos/web/chairman/form/FormConference.java index 51498f2..7b25d6d 100644 --- a/YACOSWeb/src/org/yacos/web/chairman/form/FormConference.java +++ b/YACOSWeb/src/org/yacos/web/chairman/form/FormConference.java @@ -2,6 +2,7 @@ package org.yacos.web.chairman.form; import java.util.Date; + public class FormConference { private Integer id; @@ -223,4 +224,5 @@ public class FormConference { public void setPageNumberChecked(Integer pageNumberChecked) { this.pageNumberChecked = pageNumberChecked; } + }