Salome HOME
Siman codebase is refactored. Spring beans are introduced in the context.
[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.kernel.Name;
6 import org.splat.dal.bo.kernel.User;
7 import org.splat.dal.bo.som.ValidationCycle;
8 import org.splat.dal.bo.som.ValidationStep;
9
10
11 public class ValidationFacade {
12
13         String  myicon;
14         String  myname;
15         Name    mypublisher;
16     Name    myreviewer;
17     Name    myapprover;
18
19     protected static abstract class UserOption implements Name {
20 //  ----------------------------------------------------------
21       protected String name;
22       protected int    index;
23
24       public int getIndex() {
25         return index;
26       }
27       public String toString () {
28         return name;
29       }
30     }
31     protected static class NotRequired extends UserOption {
32 //  -----------------------------------------------------
33       protected NotRequired () {
34         name  = ResourceBundle.getBundle("labels", ApplicationSettings.getCurrentLocale()).getString("label.skipped");
35         index = 0;
36       }
37     }
38     protected static class ByAuthor extends UserOption {
39 //  --------------------------------------------------
40       protected ByAuthor () {
41         name  = ResourceBundle.getBundle("labels", ApplicationSettings.getCurrentLocale()).getString("label.bytheauthor");
42         index = 0;
43       }
44     }
45     protected static class ByManager extends UserOption {
46 //  ---------------------------------------------------
47       protected ByManager (User manager) {
48         name  = ResourceBundle.getBundle("labels", ApplicationSettings.getCurrentLocale()).getString("label.me");
49         index = manager.getIndex();
50       }
51     }
52
53 //  ==============================================================================================================================
54 //  Constructors
55 //  ==============================================================================================================================
56
57         public ValidationFacade (ValidationCycle cycle) {
58 //  -----------------------------------------------
59       myicon  = "icon.empty.png";
60           if (cycle.isDefault()) {
61             myname    = "default";
62           } else {
63         if (cycle.isAssigned()) myicon = "icon.done.png";
64         myname    = cycle.getDocumentType().getName();
65           }
66       mypublisher = cycle.getActor(ValidationStep.PROMOTION);
67       myreviewer  = cycle.getActor(ValidationStep.REVIEW);
68       myapprover  = cycle.getActor(ValidationStep.APPROVAL);
69       if (mypublisher == null) {
70         mypublisher = new ByAuthor();
71       }
72       if (myreviewer == null || myapprover == null) {
73         Name  skipped = new NotRequired();
74         if (myreviewer == null) myreviewer = skipped;
75         if (myapprover == null) myapprover = skipped;
76       }
77         }
78
79 //  ==============================================================================================================================
80 //  Getters
81 //  ==============================================================================================================================
82
83     public String getDocumentType () {
84 //  --------------------------------
85       return myname;
86     }
87     public int getApproverIndex () {
88 //  ------------------------------
89       return myapprover.getIndex();
90     }
91     public String getApproverName () {
92 //  --------------------------------
93       return myapprover.toString();
94     }
95     public String getIcon () {
96 //  ------------------------
97       return myicon;
98     }
99     public int getPublisherIndex () {
100 //  -------------------------------
101       return mypublisher.getIndex();
102     }
103     public String getPublisherName () {
104 //  ---------------------------------
105       return mypublisher.toString();
106     }
107     public int getReviewerIndex () {
108 //  ------------------------------
109       return myreviewer.getIndex();
110     }
111     public String getReviewerName () {
112 //  --------------------------------
113       return myreviewer.toString();
114     }
115 }