| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
package org.demosys.web.iteration.impl; |
| 7 |
|
import java.util.ArrayList; |
| 8 |
|
import java.util.HashMap; |
| 9 |
|
import org.demosys.web.iteration.*; |
| 10 |
|
|
| 11 |
|
|
| 12 |
24 |
public class MemoryIterationService implements IterationService { |
| 13 |
24 |
private HashMap memory = new HashMap(); |
| 14 |
|
|
| 15 |
|
public synchronized void newIteration(IterationView iteration) |
| 16 |
|
throws CreateIterationException { |
| 17 |
0 |
if (memory.containsKey(iteration.getTitle())) { |
| 18 |
0 |
throw new CreateIterationException("Existe deja en Base"); |
| 19 |
|
} |
| 20 |
|
|
| 21 |
0 |
memory.put(iteration.getTitle(), iteration.clone()); |
| 22 |
0 |
} |
| 23 |
|
|
| 24 |
|
|
| 25 |
|
public synchronized void updateIteration(IterationView iteration) |
| 26 |
|
throws CreateIterationException { |
| 27 |
0 |
if (memory.containsKey(iteration.getTitle())) { |
| 28 |
0 |
throw new CreateIterationException("Existe deja en Base"); |
| 29 |
|
} |
| 30 |
|
|
| 31 |
0 |
memory.put(iteration.getTitle(), iteration.clone()); |
| 32 |
0 |
} |
| 33 |
|
|
| 34 |
|
|
| 35 |
|
public synchronized IterationViewList getAllIterations() { |
| 36 |
0 |
IterationViewList list = new IterationViewList(); |
| 37 |
0 |
list.setIterations(new ArrayList(memory.values())); |
| 38 |
0 |
return list; |
| 39 |
|
} |
| 40 |
|
|
| 41 |
|
|
| 42 |
|
public synchronized void deleteIteration(String title) |
| 43 |
|
throws UnknownIterationException { |
| 44 |
0 |
if (memory.containsKey(title) == false) { |
| 45 |
0 |
throw new UnknownIterationException(); |
| 46 |
|
} |
| 47 |
|
|
| 48 |
0 |
memory.remove(title); |
| 49 |
0 |
} |
| 50 |
|
} |