]> SALOME platform Git repositories - tools/siman.git/blob - Workspace/Siman-Common/src/org/splat/service/dto/SimulationContextFacade.java
Salome HOME
Update copyrights 2014.
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / service / dto / SimulationContextFacade.java
1 package org.splat.service.dto;
2
3 import java.util.Iterator;
4 import java.util.List;
5
6 import org.splat.dal.bo.som.ProgressState;
7 import org.splat.dal.bo.som.SimulationContext;
8 import org.splat.dal.bo.som.SimulationContextType;
9 import org.splat.service.technical.ProjectSettingsService;
10
11 public class SimulationContextFacade {
12
13         private transient final SimulationContext _my;
14         private transient final String _name;
15         private transient int _at;
16         private transient ProgressState _state;
17
18         // ==============================================================================================================================
19         // Constructor
20         // ==============================================================================================================================
21
22         public SimulationContextFacade(final SimulationContext represented,
23                         final List<ProjectSettingsService.Step> steps) {
24                 // --------------------------------------------------------------
25                 SimulationContextType mytype;
26
27                 _my = represented;
28                 mytype = _my.getType();
29                 for (Iterator<ProjectSettingsService.Step> i = steps.iterator(); i
30                                 .hasNext();) {
31                         ProjectSettingsService.Step step = i.next();
32                         if (!mytype.isAttachedTo(step)) {
33                                 continue;
34                         }
35                         _at = step.getNumber(); // There is no direct service for getting the step number
36                         break;
37                 }
38                 _name = _my.getType().getName();
39                 if (mytype.isApproved()) {
40                         _state = ProgressState.inCHECK;
41                         // RKV: TODO: Do translation in presentation layer by struts tools: name = ResourceBundle.getBundle("som",
42                         // ApplicationSettings.getCurrentLocale()).getString("type.context." + name);
43                 } else {
44                         _state = ProgressState.inDRAFT;
45                 }
46         }
47
48         // ==============================================================================================================================
49         // Getters
50         // ==============================================================================================================================
51
52         public String getEditIcon() {
53                 // ----------------------------
54                 StringBuffer result = new StringBuffer("icon.ed").append(_state).append(
55                                 ".png");
56                 return result.toString();
57         }
58
59         public String getIndex() {
60                 // -------------------------
61                 return String.valueOf(_my.getIndex());
62         }
63
64         public int getStepNumber() {
65                 // ---------------------------
66                 return _at;
67         }
68
69         public String getTypeName() {
70                 // ----------------------------
71                 return _name;
72         }
73
74         public String getValue() {
75                 // -------------------------
76                 return _my.getValue();
77         }
78 }