Création de conf STATEFUL (pas fini)
This commit is contained in:
@@ -0,0 +1,234 @@
|
||||
package org.yacos.core.conferences;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.ejb.Stateful;
|
||||
|
||||
|
||||
@Stateful
|
||||
public class ConferenceSession implements IConferenceSession, Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// ###########################################################
|
||||
|
||||
private static int nextPerson = 1;
|
||||
|
||||
private List<PersonBean> listPersonBean;
|
||||
private List<PersonBean> listPersonFiltered;
|
||||
private List<PersonBean> listPersonAdded;
|
||||
private List<String> listInvitations;
|
||||
|
||||
public void fillUser(String text) {
|
||||
if (text.equals(""))
|
||||
listPersonFiltered = listPersonBean;
|
||||
else {
|
||||
listPersonFiltered = new ArrayList<PersonBean>();
|
||||
for (PersonBean b : listPersonBean) {
|
||||
if (b.getFirstName().toLowerCase().startsWith(text.toLowerCase()) || b.getLastName().toLowerCase().startsWith(text.toLowerCase())){
|
||||
listPersonFiltered.add(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 deletePerson(PersonBean b) {
|
||||
|
||||
PersonBean truePerson = getTruePerson(b.getLogin());
|
||||
|
||||
listPersonAdded.remove(truePerson);
|
||||
listPersonBean.add(truePerson);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private static synchronized int getNextPerson()
|
||||
{
|
||||
return nextPerson++;
|
||||
}
|
||||
|
||||
public List<PersonBean> getUsersFiltered() {
|
||||
return listPersonFiltered;
|
||||
}
|
||||
|
||||
public List<PersonBean> getUsers() {
|
||||
return listPersonBean;
|
||||
}
|
||||
|
||||
public List<PersonBean> getUsersAdded() {
|
||||
return listPersonAdded;
|
||||
}
|
||||
|
||||
public List<String> getInvitation(){
|
||||
return listInvitations;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public void removeInvitations(List<String> emailList){
|
||||
for(String email : emailList){
|
||||
listInvitations.remove(email);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ###########################################################
|
||||
|
||||
|
||||
private static int nextId = 1;
|
||||
|
||||
private Set<CriterionBean> criteria;
|
||||
private Set<CriterionBean> criteriaAll;
|
||||
|
||||
public Set<CriterionBean> getCriteriaAll() {
|
||||
return criteriaAll;
|
||||
}
|
||||
|
||||
public Set<CriterionBean> getCriteriaAdded() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
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) {
|
||||
if (c.getId() == -1) {
|
||||
c.setId(getNextId());
|
||||
}
|
||||
|
||||
criteria.remove(c);
|
||||
criteria.add(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) {
|
||||
|
||||
CriterionBean trueCriteria = getTrueCriteria(c.getId());
|
||||
|
||||
|
||||
|
||||
criteria.remove(trueCriteria);
|
||||
criteriaAll.add(trueCriteria);
|
||||
}
|
||||
|
||||
private static synchronized int getNextId()
|
||||
{
|
||||
return nextId++;
|
||||
}
|
||||
|
||||
|
||||
public void setListPersonBean(List<PersonBean> listPersonBean) {
|
||||
this.listPersonBean = listPersonBean;
|
||||
}
|
||||
|
||||
public void setListPersonFiltered(List<PersonBean> listPersonFiltered) {
|
||||
this.listPersonFiltered = listPersonFiltered;
|
||||
}
|
||||
|
||||
public void setListPersonAdded(List<PersonBean> listPersonAdded) {
|
||||
this.listPersonAdded = listPersonAdded;
|
||||
}
|
||||
|
||||
public void setListInvitations(List<String> listInvitations) {
|
||||
this.listInvitations = listInvitations;
|
||||
}
|
||||
|
||||
public void setCriteria(Set<CriterionBean> criteria) {
|
||||
this.criteria = criteria;
|
||||
}
|
||||
|
||||
public void setCriteriaAll(Set<CriterionBean> criteriaAll) {
|
||||
this.criteriaAll = criteriaAll;
|
||||
}
|
||||
|
||||
// ###########################################################
|
||||
|
||||
public int getNextId2() {
|
||||
return nextId;
|
||||
}
|
||||
|
||||
public void setNextId2(int nextId2){
|
||||
nextId = nextId2;
|
||||
}
|
||||
|
||||
public void setNextPerson2(int nextPerson2){
|
||||
nextPerson = nextPerson2;
|
||||
}
|
||||
|
||||
|
||||
public int getNextPerson2(){
|
||||
return nextPerson;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package org.yacos.core.conferences;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class CriterionBean implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 6392466372370560230L;
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package org.yacos.core.conferences;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.ejb.Remote;
|
||||
|
||||
|
||||
@Remote
|
||||
public interface IConferenceSession {
|
||||
|
||||
public void fillUser(String text);
|
||||
|
||||
public void setPerson(PersonBean b);
|
||||
|
||||
public void deletePerson(PersonBean b);
|
||||
|
||||
public List<PersonBean> getUsersFiltered();
|
||||
|
||||
public List<PersonBean> getUsers();
|
||||
|
||||
public List<PersonBean> getUsersAdded();
|
||||
|
||||
public List<String> getInvitation();
|
||||
|
||||
public boolean addInvitation(String email);
|
||||
|
||||
public void removeInvitations(List<String> emailList);
|
||||
|
||||
public Set<CriterionBean> getCriteriaAll();
|
||||
|
||||
public Set<CriterionBean> getCriteriaAdded();
|
||||
|
||||
public void setCriterionClick(CriterionBean c);
|
||||
|
||||
public void setCriterion(CriterionBean c);
|
||||
|
||||
public void deleteCriterion(CriterionBean c);
|
||||
|
||||
|
||||
public void setListPersonBean(List<PersonBean> listPersonBean);
|
||||
|
||||
public void setListPersonFiltered(List<PersonBean> listPersonFiltered) ;
|
||||
|
||||
public void setListPersonAdded(List<PersonBean> listPersonAdded) ;
|
||||
|
||||
public void setListInvitations(List<String> listInvitations) ;
|
||||
|
||||
public void setCriteria(Set<CriterionBean> criteria) ;
|
||||
|
||||
public void setCriteriaAll(Set<CriterionBean> criteriaAll) ;
|
||||
|
||||
public int getNextId2();
|
||||
|
||||
public void setNextId2(int nextId2);
|
||||
|
||||
public void setNextPerson2(int nextPerson2);
|
||||
|
||||
|
||||
public int getNextPerson2();
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package org.yacos.core.conferences;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class PersonBean implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -1832356235818712606L;
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user