Unverified Commit 0565310e authored by Mathieu Gicquel's avatar Mathieu Gicquel
Browse files

Refactor - Send association to Interface

Association : Context -- Task
parent 0331e214
......@@ -26,4 +26,6 @@ public interface IContext extends IServerObject {
* @param c The new value of the creator.
*/
void setCreator(final IParticipant c);
MultipleReference<ITask> getTaskReference();
}
......@@ -195,4 +195,5 @@ public interface ITask extends IServerObject {
*/
void setContactsList(final List<IContact> contacts);
SingleReference<IContext> getContextReference();
}
......@@ -2,6 +2,7 @@ package fr.alma.gtd.server.main.donnees;
import fr.alma.gtd.server.core.IContext;
import fr.alma.gtd.server.core.IParticipant;
import fr.alma.gtd.server.core.ITask;
import fr.alma.gtd.server.core.MultipleReference;
import java.util.Date;
......@@ -11,7 +12,7 @@ public class Context implements IContext {
private String nom;
private String idServeur;
private MultipleReference<Task> tasks;
private MultipleReference<ITask> tasks;
public Context() {
this.tasks = new ReferenceContextToTasks(this);
......@@ -64,7 +65,7 @@ public class Context implements IContext {
}
public MultipleReference<Task> getTaskReference() {
public MultipleReference<ITask> getTaskReference() {
return this.tasks;
}
}
......@@ -6,9 +6,9 @@ import fr.alma.gtd.server.core.MultipleReference;
import java.util.ArrayList;
import java.util.List;
public class ReferenceContextToTasks implements MultipleReference<Task> {
public class ReferenceContextToTasks implements MultipleReference<ITask> {
Context c;
List<Task> tasks;
List<ITask> tasks;
public ReferenceContextToTasks(Context c) {
this.c = c;
......@@ -16,7 +16,7 @@ public class ReferenceContextToTasks implements MultipleReference<Task> {
}
@Override
public boolean add(Task value) {
public boolean add(ITask value) {
if(value.getContextReference().isSet()) value.getContextReference().unset();
value.getContextReference().basicSet(c);
......@@ -27,13 +27,13 @@ public class ReferenceContextToTasks implements MultipleReference<Task> {
}
@Override
public void remove(Task value) {
public void remove(ITask value) {
if(value.getContextReference().isSet() && this.contains(value)) value.getContextReference().unset();
this.basicRemove(value);
}
@Override
public boolean contains(Task value) {
public boolean contains(ITask value) {
return this.tasks.contains(value);
}
......@@ -43,12 +43,12 @@ public class ReferenceContextToTasks implements MultipleReference<Task> {
}
@Override
public void basicAdd(Task value) {
public void basicAdd(ITask value) {
this.tasks.add(value);
}
@Override
public void basicRemove(Task value) {
public void basicRemove(ITask value) {
this.tasks.remove(value);
}
}
......@@ -3,16 +3,16 @@ package fr.alma.gtd.server.main.donnees;
import fr.alma.gtd.server.core.IContext;
import fr.alma.gtd.server.core.SingleReference;
public class ReferenceTaskToContext implements SingleReference<Context> {
public class ReferenceTaskToContext implements SingleReference<IContext> {
Task t;
Context c;
IContext c;
public ReferenceTaskToContext(Task t) {
this.t = t;
}
@Override
public void set(Context newValue) {
public void set(IContext newValue) {
if(this.isSet()) this.unset();
newValue.getTaskReference().add(t);
......@@ -20,7 +20,7 @@ public class ReferenceTaskToContext implements SingleReference<Context> {
}
@Override
public Context get() {
public IContext get() {
return this.c;
}
......@@ -37,7 +37,7 @@ public class ReferenceTaskToContext implements SingleReference<Context> {
}
@Override
public void basicSet(Context newValue) {
public void basicSet(IContext newValue) {
this.c = newValue;
}
......
......@@ -15,7 +15,7 @@ public class Task implements ITask {
private Date debut,fin;
private ReferenceToTags tags;
private SingleReference<Context> context;
private SingleReference<IContext> context;
public Task() {
tags = new ReferenceToTags();
......@@ -179,9 +179,7 @@ public class Task implements ITask {
return this.context.get();
}
public SingleReference<Context> getContextReference() {
return this.context;
}
@Override
public void setContext(IContext c) throws ClassCastException{
......@@ -218,6 +216,11 @@ public class Task implements ITask {
}
@Override
public SingleReference<IContext> getContextReference() {
return this.context;
}
@Override
public List<ITask> getPreviousTasksList() {
return null;
......
......@@ -64,7 +64,12 @@ public final class Context extends AbstractContext {
public Participant getCreator() {
return (Participant) this.creator;
}
@Override
public MultipleReference<ITask> getTaskReference() {
throw new UnsupportedOperationException();
}
@Override
@Basic
public Date getLastModificationDate() {
......
......@@ -168,8 +168,13 @@ public final class Task extends AbstractTask {
public List<IContact> getListeContacts() {
return contacts;
}
@Override
public SingleReference<IContext> getContextReference() {
throw new UnsupportedOperationException();
}
/*
* Methodes privees appelees uniquement par Hibernate :
* getters et setters permettant d'assurer la persistance des listes :
......
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