Commit fc405c5d authored by Mathieu Gicquel's avatar Mathieu Gicquel
Browse files

Create Facade and FacadeFactory - #24

parent 51a05602
package fr.alma.gtd.server.main;
import fr.alma.gtd.server.core.*;
import java.util.ArrayList;
import java.util.List;
public class Facade {
private static Facade instance = null;
public static Facade getInstance() {
if(instance==null) instance = new Facade();
return instance;
}
private List<IProject> projects ;
private List<IContext> contexts ;
private List<IParticipant> user;
private List<ITag> tags;
private List<IIdea> ideas;
private List<ITask> tasks;
public Facade() {
this.projects = new ArrayList<>();
this.contexts = new ArrayList<>();
this.user = new ArrayList<>();
this.tags = new ArrayList<>();
this.ideas = new ArrayList<>();
this.tasks = new ArrayList<>();
}
public List<IProject> getProjects() {
return projects;
}
public void setProjects(List<IProject> projects) {
this.projects = projects;
}
public List<IContext> getContexts() {
return contexts;
}
public void setContexts(List<IContext> contexts) {
this.contexts = contexts;
}
public List<IParticipant> getUser() {
return user;
}
public void setUser(List<IParticipant> user) {
this.user = user;
}
public List<ITag> getTags() {
return tags;
}
public void setTags(List<ITag> tags) {
this.tags = tags;
}
public List<IIdea> getIdeas() {
return ideas;
}
public void setIdeas(List<IIdea> ideas) {
this.ideas = ideas;
}
public List<ITask> getTasks() {
return tasks;
}
public void setTasks(List<ITask> tasks) {
this.tasks = tasks;
}
}
package fr.alma.gtd.server.main;
import fr.alma.gtd.server.core.*;
import fr.alma.gtd.server.main.donnees.*;
import fr.alma.gtd.server.persistence.data.Utilisateur;
public class FacadeFactory {
static IProject getProject(String idServeur, Progress progress, String projectName) {
Project p = new Project(idServeur, progress, projectName);
Facade.getInstance().getProjects().add(p);
return p;
}
static IContext getContext(final String name) {
Context c = new Context(name);
Facade.getInstance().getContexts().add(c);
return c;
}
static IParticipant getUser() {
Utilisateur u = new Utilisateur();
Facade.getInstance().getUser().add(u);
return u;
}
static IParticipant getUser(String login) {
IParticipant u1 = FacadeFactory.getUser();
u1.setPseudonym(login);
return u1;
}
static ITag getTag(String name) {
Tag tag = new Tag();
Facade.getInstance().getTags().add(tag);
tag.setName(name);
return tag;
}
static IIdea getIdea() {
Idea idea = new Idea();
Facade.getInstance().getIdeas().add(idea);
return idea;
}
static IIdea getIdea(String name, String description, String idServeur) {
IIdea idea = FacadeFactory.getIdea();
idea.setName(name);
idea.setDescription(description);
idea.setServerIdentifier(idServeur);
return idea;
}
static ITask getTask() {
Task task = new Task();
Facade.getInstance().getTasks().add(task);
return new Task();
}
static ITask getTask(String name) {
ITask task = FacadeFactory.getTask();
task.setName(name);
return task;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment