Mercurial > dive4elements > framework
annotate artifact-database/src/main/java/de/intevation/artifactdatabase/state/FacetActivity.java @ 415:d4a846ee35b8
Implement ArtifactDatabase findUser method
artifacts/trunk@5262 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Bjoern Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Fri, 24 Aug 2012 14:08:31 +0000 |
parents | e1738650bfca |
children | 15179c77aa1d |
rev | line source |
---|---|
403
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.artifactdatabase.state; |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import de.intevation.artifacts.Artifact; |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 |
405
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
5 import java.util.ArrayList; |
403
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 import java.util.HashMap; |
405
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
7 import java.util.List; |
403
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 import java.util.Map; |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 public interface FacetActivity |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 { |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 public static final FacetActivity ACTIVE = new FacetActivity() { |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 @Override |
405
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
14 public Boolean isInitialActive( |
403
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 Artifact artifact, |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 Facet facet, |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 String output |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 ) { |
405
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
19 return Boolean.TRUE; |
403
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 } |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 }; |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 public static final FacetActivity INACTIVE = new FacetActivity() { |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 @Override |
405
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
25 public Boolean isInitialActive( |
403
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 Artifact artifact, |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 Facet facet, |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 String output |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 ) { |
405
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
30 return Boolean.FALSE; |
403
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 } |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 }; |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 |
405
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
34 Boolean isInitialActive(Artifact artifact, Facet facet, String output); |
403
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 public static final class Registry { |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 private static final Registry INSTANCE = new Registry(); |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 |
405
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
40 private Map<String, List<FacetActivity>> activities; |
403
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 private Registry() { |
405
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
43 activities = new HashMap<String, List<FacetActivity>>(); |
403
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 } |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 |
404
4c78c5d2b367
FacetActivity: Made Registry.getInstance() access static.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
403
diff
changeset
|
46 public static Registry getInstance() { |
403
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 return INSTANCE; |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 } |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 |
405
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
50 public synchronized boolean isInitialActive( |
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
51 String key, |
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
52 Artifact artifact, |
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
53 Facet facet, |
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
54 String output |
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
55 ) { |
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
56 List<FacetActivity> activityList = activities.get(key); |
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
57 if (activityList == null) { |
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
58 return true; |
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
59 } |
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
60 for (FacetActivity activity: activityList) { |
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
61 Boolean isActive = |
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
62 activity.isInitialActive(artifact, facet, output); |
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
63 if (isActive != null) { |
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
64 return isActive; |
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
65 } |
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
66 } |
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
67 return true; |
403
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 } |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 public synchronized void register(String key, FacetActivity activity) { |
405
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
71 List<FacetActivity> activityList = activities.get(key); |
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
72 if (activityList == null) { |
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
73 activityList = new ArrayList<FacetActivity>(3); |
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
74 activities.put(key, activityList); |
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
75 } |
e1738650bfca
FacetActivity: use Chain-of-responsibility pattern to figure out if facet should be active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
404
diff
changeset
|
76 activityList.add(activity); |
403
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
77 } |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
78 } |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
79 } |
bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
80 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |