Rev 1315 | Rev 1326 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1314 | jmachado | 1 | package pt.estgp.estgweb.domain; |
2 | |||
1325 | jmachado | 3 | import org.apache.log4j.Logger; |
1314 | jmachado | 4 | import pt.estgp.estgweb.utils.ConfigProperties; |
5 | |||
6 | import java.lang.reflect.InvocationTargetException; |
||
7 | import java.lang.reflect.Method; |
||
1325 | jmachado | 8 | import java.text.MessageFormat; |
9 | import java.text.SimpleDateFormat; |
||
10 | import java.util.ArrayList; |
||
11 | import java.util.Date; |
||
12 | import java.util.List; |
||
13 | import java.util.Locale; |
||
1314 | jmachado | 14 | |
15 | /** |
||
16 | * Created by jorgemachado on 09/03/16. |
||
17 | */ |
||
18 | public class QuestionarioImpl extends Questionario |
||
19 | { |
||
20 | |||
1325 | jmachado | 21 | private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(QuestionarioImpl.class); |
22 | |||
1314 | jmachado | 23 | public enum 1.5.0/docs/api/org/omg/PortableServer/POAManagerPackage/State.html">State |
24 | { |
||
1315 | jmachado | 25 | |
26 | CREATED(1), |
||
1325 | jmachado | 27 | ASSIGNATION_DETAILS(2), |
28 | ASSIGNING_ANSWERS_PROCESSEMENT(3), |
||
29 | ASSIGNED_ANSWERS(4), |
||
30 | PROCESSING(5), |
||
31 | PROCESSING_WITH_ANSWERS(6), |
||
32 | STOPED_WITH_ANSWERS(6), |
||
33 | CLOSED(7), |
||
34 | PROCESSING_OLAP(8), |
||
35 | OLAP(9); |
||
1315 | jmachado | 36 | |
37 | private int pos = 1; |
||
38 | |||
39 | 1.5.0/docs/api/org/omg/PortableServer/POAManagerPackage/State.html">State(int pos) |
||
40 | { |
||
41 | this.pos = pos; |
||
42 | } |
||
43 | |||
44 | public static 1.5.0/docs/api/org/omg/PortableServer/POAManagerPackage/State.html">State parse(1.5.0/docs/api/java/lang/String.html">String state) |
||
45 | { |
||
46 | for(1.5.0/docs/api/org/omg/PortableServer/POAManagerPackage/State.html">State s: 1.5.0/docs/api/org/omg/PortableServer/POAManagerPackage/State.html">State.values()) |
||
47 | { |
||
48 | if(s.name().equals(state)) |
||
49 | return s; |
||
50 | } |
||
51 | return CREATED; |
||
52 | } |
||
53 | |||
1325 | jmachado | 54 | |
1315 | jmachado | 55 | public int getPosition() |
56 | { |
||
57 | return pos; |
||
58 | } |
||
1314 | jmachado | 59 | } |
60 | |||
1315 | jmachado | 61 | |
62 | |||
1325 | jmachado | 63 | |
1314 | jmachado | 64 | public QuestionarioImpl() { |
65 | super(); |
||
66 | |||
67 | setState(1.5.0/docs/api/org/omg/PortableServer/POAManagerPackage/State.html">State.CREATED.name()); |
||
1315 | jmachado | 68 | |
1325 | jmachado | 69 | 1.5.0/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat sdf = new 1.5.0/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat("MMMM yyyy",new 1.5.0/docs/api/java/util/Locale.html">Locale("pt")); |
70 | 1.5.0/docs/api/java/lang/String.html">String month = sdf.format(new 5+0%2Fdocs%2Fapi+Date">Date()); |
||
71 | 1.5.0/docs/api/java/lang/String.html">String introHtml = ConfigProperties.getProperty("questionario.intro.text"); |
||
72 | |||
73 | 1.5.0/docs/api/java/lang/String.html">String introWithMonth = 1.5.0/docs/api/java/text/MessageFormat.html">MessageFormat.format(introHtml, month); |
||
74 | |||
75 | setIntroHtml(introWithMonth); |
||
1314 | jmachado | 76 | setGroup1Title(ConfigProperties.getProperty("questionario.group1.title")); |
77 | setGroup2Title(ConfigProperties.getProperty("questionario.group2.title")); |
||
78 | setGroup3Title(ConfigProperties.getProperty("questionario.group3.title")); |
||
79 | setGroup4Title(ConfigProperties.getProperty("questionario.group4.title")); |
||
80 | setGroup5Title(ConfigProperties.getProperty("questionario.group5.title")); |
||
1325 | jmachado | 81 | setGroup6Title(ConfigProperties.getProperty("questionario.group6.title")); |
82 | setGroup7Title(ConfigProperties.getProperty("questionario.group7.title")); |
||
83 | setGroup8Title(ConfigProperties.getProperty("questionario.group8.title")); |
||
84 | setGroup9Title(ConfigProperties.getProperty("questionario.group9.title")); |
||
85 | setGroup10Title(ConfigProperties.getProperty("questionario.group10.title")); |
||
1314 | jmachado | 86 | |
87 | |||
1325 | jmachado | 88 | setGroup1Code(ConfigProperties.getProperty("questionario.group1.code")); |
89 | setGroup2Code(ConfigProperties.getProperty("questionario.group2.code")); |
||
90 | setGroup3Code(ConfigProperties.getProperty("questionario.group3.code")); |
||
91 | setGroup4Code(ConfigProperties.getProperty("questionario.group4.code")); |
||
92 | setGroup5Code(ConfigProperties.getProperty("questionario.group5.code")); |
||
93 | setGroup6Code(ConfigProperties.getProperty("questionario.group6.code")); |
||
94 | setGroup7Code(ConfigProperties.getProperty("questionario.group7.code")); |
||
95 | setGroup8Code(ConfigProperties.getProperty("questionario.group8.code")); |
||
96 | setGroup9Code(ConfigProperties.getProperty("questionario.group9.code")); |
||
97 | setGroup10Code(ConfigProperties.getProperty("questionario.group10.code")); |
||
98 | |||
99 | |||
100 | for(int i = 1; i <=40;i++) |
||
1314 | jmachado | 101 | { |
102 | |||
103 | try { |
||
104 | 1.5.0/docs/api/java/lang/String.html">String group = ConfigProperties.getProperty("questionario.p" + i + ".group"); |
||
105 | 1.5.0/docs/api/java/lang/reflect/Method.html">Method m = this.getClass().getMethod("setP" + i + "Group",1.5.0/docs/api/java/lang/String.html">String.class); |
||
106 | m.invoke(this,group); |
||
107 | |||
108 | 1.5.0/docs/api/java/lang/String.html">String pergunta = ConfigProperties.getProperty("questionario.p" + i); |
||
109 | 1.5.0/docs/api/java/lang/reflect/Method.html">Method m2 = this.getClass().getMethod("setP" + i,1.5.0/docs/api/java/lang/String.html">String.class); |
||
110 | m2.invoke(this,pergunta); |
||
111 | } catch (1.5.0/docs/api/java/lang/NoSuchMethodException.html">NoSuchMethodException e) { |
||
112 | e.printStackTrace(); |
||
113 | } catch (1.5.0/docs/api/java/lang/reflect/InvocationTargetException.html">InvocationTargetException e) { |
||
114 | e.printStackTrace(); |
||
115 | } catch (1.5.0/docs/api/java/lang/IllegalAccessException.html">IllegalAccessException e) { |
||
116 | e.printStackTrace(); |
||
117 | } |
||
118 | } |
||
1325 | jmachado | 119 | } |
1314 | jmachado | 120 | |
1325 | jmachado | 121 | static List<IAnswersProcessor> answersProcessors = null; |
122 | |||
123 | public IAnswersProcessor getiAnswersProcessorClass() |
||
124 | { |
||
125 | if(getiAnswersProcessor() != null) |
||
126 | { |
||
127 | try { |
||
128 | return (IAnswersProcessor) 1.5.0/docs/api/java/lang/Class.html">Class.forName(getiAnswersProcessor()).newInstance(); |
||
129 | } catch (1.5.0/docs/api/java/lang/Exception.html">Exception e) { |
||
130 | logger.error(e,e); |
||
131 | } |
||
132 | } |
||
133 | |||
134 | return new IAnswersProcessor() { |
||
135 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
136 | public 1.5.0/docs/api/java/lang/String.html">String getHistoryDriveConstraint() { |
||
137 | return null; |
||
138 | } |
||
139 | |||
140 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
141 | public 1.5.0/docs/api/java/lang/String.html">String getTitle() { |
||
142 | return "---"; |
||
143 | } |
||
144 | |||
145 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
146 | public 1.5.0/docs/api/java/lang/String.html">String getAfetacoesManagementForward() { |
||
147 | return null; |
||
148 | } |
||
149 | }; |
||
1314 | jmachado | 150 | } |
151 | |||
1325 | jmachado | 152 | public static List<IAnswersProcessor> getIAnswerProcessors() |
153 | { |
||
154 | if(answersProcessors == null) |
||
155 | { |
||
156 | answersProcessors = new ArrayList<IAnswersProcessor>(); |
||
157 | List<String> processors = ConfigProperties.getListValues("pt.estgp.estgweb.domain.IAnswersProcessor."); |
||
158 | for(1.5.0/docs/api/java/lang/String.html">String p: processors) |
||
159 | { |
||
160 | try { |
||
161 | IAnswersProcessor iAnswersProcessor = (IAnswersProcessor) 1.5.0/docs/api/java/lang/Class.html">Class.forName(p).newInstance(); |
||
162 | answersProcessors.add(iAnswersProcessor); |
||
163 | } catch (1.5.0/docs/api/java/lang/Exception.html">Exception e) { |
||
164 | logger.error(e, e); |
||
165 | } |
||
166 | } |
||
167 | } |
||
168 | return answersProcessors; |
||
169 | } |
||
170 | |||
1314 | jmachado | 171 | public static void main(1.5.0/docs/api/java/lang/String.html">String[] args) |
172 | { |
||
173 | QuestionarioImpl q = new QuestionarioImpl(); |
||
174 | 1.5.0/docs/api/java/lang/System.html">System.out.println(q); |
||
175 | } |
||
1315 | jmachado | 176 | |
177 | public 1.5.0/docs/api/org/omg/PortableServer/POAManagerPackage/State.html">State getStateEnum() |
||
178 | { |
||
179 | return 1.5.0/docs/api/org/omg/PortableServer/POAManagerPackage/State.html">State.parse(getState()); |
||
180 | } |
||
1314 | jmachado | 181 | } |