]> SALOME platform Git repositories - tools/siman.git/blob - Workspace/Siman/src/org/splat/simer/ValidationFacade.java
Salome HOME
Modifications to respect PMD rules.
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / ValidationFacade.java
1 package org.splat.simer;
2
3 import java.util.ResourceBundle;
4
5 import org.splat.dal.bo.kernel.User;
6 import org.splat.dal.bo.som.ValidationCycle;
7 import org.splat.dal.bo.som.ValidationStep;
8 import org.splat.kernel.Name;
9
10 public class ValidationFacade {
11
12         private transient String _myicon;
13         private transient String _myname;
14         private transient Name _mypublisher;
15         private transient Name _myreviewer;
16         private transient Name _myapprover;
17
18         protected static class UserOption implements Name {
19                 protected transient String _name;
20                 protected transient long _index;
21
22                 public long getIndex() {
23                         return _index;
24                 }
25
26                 @Override
27                 public String toString() {
28                         return _name;
29                 }
30         }
31
32         protected static class NotRequired extends UserOption {
33                 protected NotRequired() {
34                         super();
35                         _name = ResourceBundle.getBundle("labels",
36                                         ApplicationSettings.getCurrentLocale()).getString(
37                                         "label.skipped");
38                         _index = 0;
39                 }
40         }
41
42         protected static class ByAuthor extends UserOption {
43                 protected ByAuthor() {
44                         super();
45                         _name = ResourceBundle.getBundle("labels",
46                                         ApplicationSettings.getCurrentLocale()).getString(
47                                         "label.bytheauthor");
48                         _index = 0;
49                 }
50         }
51
52         protected static class ByManager extends UserOption {
53                 protected ByManager(final User manager) {
54                         super();
55                         _name = ResourceBundle.getBundle("labels",
56                                         ApplicationSettings.getCurrentLocale()).getString(
57                                         "label.me");
58                         _index = manager.getIndex();
59                 }
60         }
61
62         // ==============================================================================================================================
63         // Constructors
64         // ==============================================================================================================================
65
66         public ValidationFacade(final ValidationCycle cycle) {
67                 _myicon = "icon.empty.png";
68                 if (cycle.isDefault()) {
69                         _myname = "default";
70                 } else {
71                         if (cycle.isAssigned()) {
72                                 _myicon = "icon.done.png";
73                         }
74                         _myname = cycle.getDocumentType().getName();
75                 }
76                 _mypublisher = cycle.getActor(ValidationStep.PROMOTION);
77                 _myreviewer = cycle.getActor(ValidationStep.REVIEW);
78                 _myapprover = cycle.getActor(ValidationStep.APPROVAL);
79                 if (_mypublisher == null) {
80                         _mypublisher = new ByAuthor();
81                 }
82                 if (_myreviewer == null || _myapprover == null) {
83                         Name skipped = new NotRequired();
84                         if (_myreviewer == null) {
85                                 _myreviewer = skipped;
86                         }
87                         if (_myapprover == null) {
88                                 _myapprover = skipped;
89                         }
90                 }
91         }
92
93         // ==============================================================================================================================
94         // Getters
95         // ==============================================================================================================================
96
97         public String getDocumentType() {
98                 return _myname;
99         }
100
101         public long getApproverIndex() {
102                 return _myapprover.getIndex();
103         }
104
105         public String getApproverName() {
106                 return _myapprover.toString();
107         }
108
109         public String getIcon() {
110                 return _myicon;
111         }
112
113         public long getPublisherIndex() {
114                 return _mypublisher.getIndex();
115         }
116
117         public String getPublisherName() {
118                 return _mypublisher.toString();
119         }
120
121         public long getReviewerIndex() {
122                 return _myreviewer.getIndex();
123         }
124
125         public String getReviewerName() {
126                 return _myreviewer.toString();
127         }
128 }