comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java @ 815:22c18083225e

Removed compiler warnings while JavaDoc generation. gnv-artifacts/trunk@900 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 12 Apr 2010 06:59:33 +0000
parents feae2f9d6c6f
children 499cfbbb61bc
comparison
equal deleted inserted replaced
814:9d427dd2a96a 815:22c18083225e
72 /** 72 /**
73 * the logger, used to log exceptions and additonaly information 73 * the logger, used to log exceptions and additonaly information
74 */ 74 */
75 private static Logger log = Logger.getLogger(StateBase.class); 75 private static Logger log = Logger.getLogger(StateBase.class);
76 76
77 /**
78 *
79 */
80 protected final static String MINVALUEFIELDNAME = "minvalue"; 77 protected final static String MINVALUEFIELDNAME = "minvalue";
81 /** 78
82 *
83 */
84 protected final static String MAXVALUEFIELDNAME = "maxvalue"; 79 protected final static String MAXVALUEFIELDNAME = "maxvalue";
85 80
86 private final static String NODATASELECTIONKEY = "n/n"; 81 private final static String NODATASELECTIONKEY = "n/n";
87 82
88 /**
89 *
90 */
91 public final static String DESCRIBEDATAKEY = "_DESCRIBEDATA"; 83 public final static String DESCRIBEDATAKEY = "_DESCRIBEDATA";
92 84
93 /**
94 *
95 */
96 public final static String XPATH_STATIC_UI = "art:static"; 85 public final static String XPATH_STATIC_UI = "art:static";
97 /** 86
98 *
99 */
100 public final static String XPATH_DYNAMIC_UI = "art:dynamic"; 87 public final static String XPATH_DYNAMIC_UI = "art:dynamic";
101 88
102 /**
103 *
104 */
105 public static final String EXCEPTION_NO_INPUT = "no.input.data"; 89 public static final String EXCEPTION_NO_INPUT = "no.input.data";
106 /** 90
107 *
108 */
109 public static final String EXCEPTION_INVALID_INPUT = 91 public static final String EXCEPTION_INVALID_INPUT =
110 "input.is.not.valid"; 92 "input.is.not.valid";
111 93
112 /** input value names which should not be rendered from State itself */ 94 /** input value names which should not be rendered from State itself */
113 public final static String[] BLACKLIST = {"sourceid", "fisname"}; 95 public final static String[] BLACKLIST = {"sourceid", "fisname"};
114 96
115 private String id = null; 97 private String id = null;
116 98
117 /**
118 *
119 */
120 protected String hash; 99 protected String hash;
121 100
122 private String description = null; 101 private String description = null;
123 102
124 /**
125 *
126 */
127 protected String dataName = null; 103 protected String dataName = null;
128 104
129 /**
130 *
131 */
132 protected String preSettingsName = null; 105 protected String preSettingsName = null;
133 106
134 /**
135 *
136 */
137 protected boolean dataMultiSelect = false; 107 protected boolean dataMultiSelect = false;
138 108
139 /**
140 *
141 */
142 protected boolean dataNoSelect = false; 109 protected boolean dataNoSelect = false;
143 110
144 /**
145 *
146 */
147 protected String queryID = null; 111 protected String queryID = null;
148 112
149 /**
150 *
151 */
152 protected Collection<String> inputValueNames = null; 113 protected Collection<String> inputValueNames = null;
153 114
154 /**
155 *
156 */
157 protected Map<String, InputValue> inputValues = null; 115 protected Map<String, InputValue> inputValues = null;
158 116
159 /**
160 *
161 */
162 protected State parent = null; 117 protected State parent = null;
163 118
164 /**
165 *
166 */
167 protected Map<String, InputData> inputData = null; 119 protected Map<String, InputData> inputData = null;
168 120
169 /**
170 *
171 */
172 protected Map<String, InputData> preSettings = null; 121 protected Map<String, InputData> preSettings = null;
173 122
174 /** 123 /**
175 * Constructor 124 * Constructor
176 */ 125 */
177 public StateBase() { 126 public StateBase() {
178 super(); 127 super();
179 } 128 }
180 129
181 /** 130
182 * @return
183 */
184 public String getID() { 131 public String getID() {
185 return this.id; 132 return this.id;
186 } 133 }
187 134
188 /** 135
189 * @return
190 */
191 public String getDescription() { 136 public String getDescription() {
192 return this.description; 137 return this.description;
193 } 138 }
194 139
195 140
196
197 /**
198 * @return
199 */
200 public Collection<InputValue> getRequiredInputValues() { 141 public Collection<InputValue> getRequiredInputValues() {
201 return this.inputValues.values(); 142 return this.inputValues.values();
202 } 143 }
203 144
204 145
205 /**
206 *
207 * @param uuid
208 */
209 public void reset(String uuid) { 146 public void reset(String uuid) {
210 inputData.remove(dataName); 147 inputData.remove(dataName);
211 } 148 }
212 149
213 150
214 /**
215 * @param configuration
216 * @see de.intevation.gnv.state.State#setup(org.w3c.dom.Node)
217 */
218 public void setup(Node configuration) { 151 public void setup(Node configuration) {
219 this.id = ((Element)configuration).getAttribute("id"); 152 this.id = ((Element)configuration).getAttribute("id");
220 this.description = ((Element)configuration).getAttribute("description"); 153 this.description = ((Element)configuration).getAttribute("description");
221 154
222 log.info("State-ID = " + this.id); 155 log.info("State-ID = " + this.id);
266 199
267 this.preSettingsName = Config.getStringXPath(configuration, "presettings-name"); 200 this.preSettingsName = Config.getStringXPath(configuration, "presettings-name");
268 201
269 } 202 }
270 203
271 /** 204
272 * @return
273 * @see de.intevation.gnv.state.State#getParent()
274 */
275 public State getParent() { 205 public State getParent() {
276 return this.parent; 206 return this.parent;
277 } 207 }
278 208
279 /** 209
280 * @param state
281 * @see de.intevation.gnv.state.State#setParent(de.intevation.gnv.state.State)
282 */
283 public void setParent(State state) { 210 public void setParent(State state) {
284 this.parent = state; 211 this.parent = state;
285 } 212 }
286 213
287 214
288 /**
289 *
290 * @param context
291 * @param inputData
292 * @param uuid
293 * @return
294 * @throws StateException
295 */
296 public Document feed( 215 public Document feed(
297 CallContext context, 216 CallContext context,
298 Collection<InputData> inputData, 217 Collection<InputData> inputData,
299 String uuid) 218 String uuid)
300 throws StateException 219 throws StateException
356 return feedFailure(msg); 275 return feedFailure(msg);
357 } 276 }
358 } 277 }
359 278
360 279
361 /**
362 *
363 * @return
364 */
365 protected Document feedSuccess() { 280 protected Document feedSuccess() {
366 return ArtifactXMLUtilities.createSuccessReport( 281 return ArtifactXMLUtilities.createSuccessReport(
367 "Initialize success", XMLUtils.newDocument()); 282 "Initialize success", XMLUtils.newDocument());
368 } 283 }
369 284
370 285
371 /**
372 *
373 * @param msg
374 * @return
375 */
376 protected Document feedFailure(String msg) { 286 protected Document feedFailure(String msg) {
377 return ArtifactXMLUtilities.createInputExceptionReport( 287 return ArtifactXMLUtilities.createInputExceptionReport(
378 msg, XMLUtils.newDocument()); 288 msg, XMLUtils.newDocument());
379 } 289 }
380 290
381 291
382 /**
383 *
384 * @param data
385 * @param uuid
386 * @return
387 */
388 protected String[] getDescriptionForInputData(InputData data, String uuid) { 292 protected String[] getDescriptionForInputData(InputData data, String uuid) {
389 // there is only one element in the list, so take the first 293 // there is only one element in the list, so take the first
390 Object obj = getDescibeData(uuid).get(0); 294 Object obj = getDescibeData(uuid).get(0);
391 List descs = new ArrayList(); 295 List descs = new ArrayList();
392 296
421 325
422 return (String[]) descs.toArray(new String[descs.size()]); 326 return (String[]) descs.toArray(new String[descs.size()]);
423 } 327 }
424 328
425 329
426 /**
427 * @param inputData
428 * @param uuid
429 * @throws StateException
430 * @see de.intevation.gnv.state.State#putInputData(java.util.Collection)
431 */
432 @SuppressWarnings({"static-access", "static-access", "static-access", "static-access"}) 330 @SuppressWarnings({"static-access", "static-access", "static-access", "static-access"})
433 public void putInputData(Collection<InputData> inputData, String uuid) 331 public void putInputData(Collection<InputData> inputData, String uuid)
434 throws StateException { 332 throws StateException {
435 if (inputData != null) { 333 if (inputData != null) {
436 Iterator<InputData> it = inputData.iterator(); 334 Iterator<InputData> it = inputData.iterator();
511 409
512 setHash(uuid); 410 setHash(uuid);
513 } 411 }
514 412
515 413
516 /**
517 *
518 * @param preSettings
519 * @see de.intevation.gnv.state.State#setPreSettings(java.util.Map)
520 */
521 public void setPreSettings(Map<String, InputData> preSettings) { 414 public void setPreSettings(Map<String, InputData> preSettings) {
522 this.preSettings = preSettings; 415 this.preSettings = preSettings;
523 } 416 }
524 417
525 418
526
527 /**
528 *
529 * @return
530 */
531 public Map<String, InputData> getPreSettings() { 419 public Map<String, InputData> getPreSettings() {
532 return this.preSettings; 420 return this.preSettings;
533 } 421 }
534 422
535 /** 423
536 *
537 * @param inputData
538 * @param inputName
539 * @return
540 */
541 protected String getInputValue4ID(Collection<InputData> inputData, String inputName){ 424 protected String getInputValue4ID(Collection<InputData> inputData, String inputName){
542 Iterator<InputData> it = inputData.iterator(); 425 Iterator<InputData> it = inputData.iterator();
543 while (it.hasNext()) { 426 while (it.hasNext()) {
544 InputData tmpItem = it.next(); 427 InputData tmpItem = it.next();
545 if (tmpItem.getName().equals(inputName)){ 428 if (tmpItem.getName().equals(inputName)){
548 } 431 }
549 return null; 432 return null;
550 } 433 }
551 434
552 435
553 /**
554 * @param uuid
555 * @param context
556 * @throws StateException
557 * @see de.intevation.gnv.state.State#advance(java.lang.String,
558 * de.intevation.artifacts.CallMeta)
559 */
560 public void advance(String uuid, CallContext context) 436 public void advance(String uuid, CallContext context)
561 throws StateException 437 throws StateException
562 { 438 {
563 } 439 }
564 440
565 /** 441
566 *
567 * @param uuid
568 * @param context
569 * @throws StateException
570 */
571 public void initialize(String uuid, CallContext context) 442 public void initialize(String uuid, CallContext context)
572 throws StateException 443 throws StateException
573 { 444 {
574 } 445 }
575 446
576 /** 447
577 * @return
578 */
579 protected String[] generateFilterValuesFromInputData() { 448 protected String[] generateFilterValuesFromInputData() {
580 List<String> list = new ArrayList<String>(); 449 List<String> list = new ArrayList<String>();
581 Iterator<String> it = this.inputValueNames.iterator(); 450 Iterator<String> it = this.inputValueNames.iterator();
582 while (it.hasNext()) { 451 while (it.hasNext()) {
583 String value = it.next(); 452 String value = it.next();
606 } 475 }
607 String[] filterValues = list.toArray(new String[list.size()]); 476 String[] filterValues = list.toArray(new String[list.size()]);
608 return filterValues; 477 return filterValues;
609 } 478 }
610 479
611 /** 480
612 *
613 * @param value
614 * @return
615 */
616 protected String prepareInputData4RegionDBQuery(String value){ 481 protected String prepareInputData4RegionDBQuery(String value){
617 return value; 482 return value;
618 } 483 }
619 484
620 private String prepareInputData4DateDBQuery(String value) { 485 private String prepareInputData4DateDBQuery(String value) {
650 515
651 return value; 516 return value;
652 517
653 } 518 }
654 519
655 /** 520
656 * @param result
657 * @param uuid
658 * @return
659 */
660 protected List<Object> purifyResult(Collection<Result> result, String uuid) { 521 protected List<Object> purifyResult(Collection<Result> result, String uuid) {
661 List<Object> describeData = new ArrayList<Object>(); 522 List<Object> describeData = new ArrayList<Object>();
662 523
663 NamedCollection<KeyValueDescibeData> keyValueDescibeData = 524 NamedCollection<KeyValueDescibeData> keyValueDescibeData =
664 extractKVP(result, "KEY", "VALUE"); 525 extractKVP(result, "KEY", "VALUE");
666 describeData.add(keyValueDescibeData); 527 describeData.add(keyValueDescibeData);
667 528
668 return describeData; 529 return describeData;
669 } 530 }
670 531
671 /** 532
672 * @param result
673 * @param keyid
674 * @param valueid
675 * @return
676 */
677 protected NamedCollection<KeyValueDescibeData> extractKVP(Collection<Result> result, 533 protected NamedCollection<KeyValueDescibeData> extractKVP(Collection<Result> result,
678 String keyid, 534 String keyid,
679 String valueid) { 535 String valueid) {
680 Iterator<Result> rit = result.iterator(); 536 Iterator<Result> rit = result.iterator();
681 int dataSize = (this.dataNoSelect ? result.size()+1 : result.size()); 537 int dataSize = (this.dataNoSelect ? result.size()+1 : result.size());
734 } 590 }
735 return keyValueDescibeData; 591 return keyValueDescibeData;
736 } 592 }
737 593
738 594
739 /**
740 *
741 * @param key
742 * @return
743 */
744 public static boolean inBlackList(String key) { 595 public static boolean inBlackList(String key) {
745 int length = BLACKLIST.length; 596 int length = BLACKLIST.length;
746 for (int i = 0; i < length; i++) { 597 for (int i = 0; i < length; i++) {
747 if (BLACKLIST[i].equals(key)) { 598 if (BLACKLIST[i].equals(key)) {
748 return true; 599 return true;
750 } 601 }
751 602
752 return false; 603 return false;
753 } 604 }
754 605
755 /** 606
756 * @param document
757 * @param rootNode
758 * @param context
759 * @param uuid
760 * @see de.intevation.gnv.state.State#describe(org.w3c.dom.Document,
761 * org.w3c.dom.Node, de.intevation.artifacts.CallMeta,
762 * java.lang.String)
763 */
764 public void describe( 607 public void describe(
765 Document document, 608 Document document,
766 Node rootNode, 609 Node rootNode,
767 CallContext context, 610 CallContext context,
768 String uuid) 611 String uuid)
804 creator,xCreator, document, staticNode, context,uuid); 647 creator,xCreator, document, staticNode, context,uuid);
805 } 648 }
806 } 649 }
807 650
808 651
809 /**
810 *
811 * @param artCreator
812 * @param creator
813 * @param document
814 * @param dynamic
815 * @param context
816 * @param uuid
817 */
818 protected void describeDynamic( 652 protected void describeDynamic(
819 XMLUtils.ElementCreator artCreator, 653 XMLUtils.ElementCreator artCreator,
820 XMLUtils.ElementCreator creator, 654 XMLUtils.ElementCreator creator,
821 Document document, 655 Document document,
822 Node dynamic, 656 Node dynamic,
841 } 675 }
842 } 676 }
843 } 677 }
844 678
845 679
846 /**
847 *
848 * @param artCreator
849 * @param creator
850 * @param document
851 * @param staticNode
852 * @param context
853 * @param uuid
854 */
855 protected void describeStatic( 680 protected void describeStatic(
856 XMLUtils.ElementCreator artCreator, 681 XMLUtils.ElementCreator artCreator,
857 XMLUtils.ElementCreator creator, 682 XMLUtils.ElementCreator creator,
858 Document document, 683 Document document,
859 Node staticNode, 684 Node staticNode,
869 CallMeta callMeta = context.getMeta(); 694 CallMeta callMeta = context.getMeta();
870 appendToStaticNode(artCreator, creator, document, staticNode, callMeta); 695 appendToStaticNode(artCreator, creator, document, staticNode, callMeta);
871 } 696 }
872 697
873 698
874 /**
875 *
876 * @param artCreator
877 * @param creator
878 * @param document
879 * @param staticNode
880 * @param callMeta
881 */
882 protected void appendToStaticNode( 699 protected void appendToStaticNode(
883 XMLUtils.ElementCreator artCreator, 700 XMLUtils.ElementCreator artCreator,
884 XMLUtils.ElementCreator creator, 701 XMLUtils.ElementCreator creator,
885 Document document, 702 Document document,
886 Node staticNode, 703 Node staticNode,
930 747
931 staticNode.appendChild(selectNode); 748 staticNode.appendChild(selectNode);
932 } 749 }
933 750
934 751
935 /**
936 *
937 * @param artCreator
938 * @param creator
939 * @param document
940 * @param dynamicNode
941 * @param callMeta
942 * @param o
943 */
944 protected void appendToDynamicNode( 752 protected void appendToDynamicNode(
945 XMLUtils.ElementCreator artCreator, 753 XMLUtils.ElementCreator artCreator,
946 XMLUtils.ElementCreator creator, 754 XMLUtils.ElementCreator creator,
947 Document document, 755 Document document,
948 Node dynamicNode, 756 Node dynamicNode,
1012 o); 820 o);
1013 } 821 }
1014 } 822 }
1015 823
1016 824
1017 /**
1018 *
1019 * @param artCreator
1020 * @param creator
1021 * @param document
1022 * @param node
1023 * @param callMeta
1024 * @param o
1025 */
1026 protected void appendMinMaxDescribeData( 825 protected void appendMinMaxDescribeData(
1027 XMLUtils.ElementCreator artCreator, 826 XMLUtils.ElementCreator artCreator,
1028 XMLUtils.ElementCreator creator, 827 XMLUtils.ElementCreator creator,
1029 Document document, 828 Document document,
1030 Node node, 829 Node node,
1087 886
1088 node.appendChild(groupNode); 887 node.appendChild(groupNode);
1089 } 888 }
1090 889
1091 890
1092 /**
1093 *
1094 * @param artCreator
1095 * @param creator
1096 * @param document
1097 * @param node
1098 * @param callMeta
1099 * @param o
1100 */
1101 protected void appendSingleValueDescribeData( 891 protected void appendSingleValueDescribeData(
1102 XMLUtils.ElementCreator artCreator, 892 XMLUtils.ElementCreator artCreator,
1103 XMLUtils.ElementCreator creator, 893 XMLUtils.ElementCreator creator,
1104 Document document, 894 Document document,
1105 Node node, 895 Node node,
1135 925
1136 node.appendChild(groupNode); 926 node.appendChild(groupNode);
1137 } 927 }
1138 928
1139 929
1140 /**
1141 *
1142 * @param uuid
1143 */
1144 protected void setHash(String uuid) { 930 protected void setHash(String uuid) {
1145 this.hash = uuid + id + inputData.hashCode(); 931 this.hash = uuid + id + inputData.hashCode();
1146 } 932 }
1147 933
1148 934
1149 /**
1150 *
1151 * @return
1152 */
1153 protected String getHash() { 935 protected String getHash() {
1154 return this.hash; 936 return this.hash;
1155 } 937 }
1156 938
1157 939
1158 /**
1159 * @param uuid
1160 * @return
1161 * @see de.intevation.gnv.state.State#getDescibeData()
1162 */
1163 public List<Object> getDescibeData(String uuid) { 940 public List<Object> getDescibeData(String uuid) {
1164 CacheFactory factory = CacheFactory.getInstance(); 941 CacheFactory factory = CacheFactory.getInstance();
1165 if (factory.isInitialized()) { 942 if (factory.isInitialized()) {
1166 // we use a cache 943 // we use a cache
1167 log.debug("Using cache."); 944 log.debug("Using cache.");
1208 } 985 }
1209 986
1210 return null; 987 return null;
1211 } 988 }
1212 989
1213 /** 990
1214 *
1215 * @param filterValues
1216 * @param uuid
1217 * @return
1218 * @throws QueryException
1219 */
1220 protected List<Object> queryDatabase(String[] filterValues, String uuid) 991 protected List<Object> queryDatabase(String[] filterValues, String uuid)
1221 throws QueryException { 992 throws QueryException {
1222 Collection<Result> result = null; 993 Collection<Result> result = null;
1223 994
1224 if (queryID != null) { 995 if (queryID != null) {
1229 } 1000 }
1230 return purifyResult(result, uuid); 1001 return purifyResult(result, uuid);
1231 } 1002 }
1232 1003
1233 1004
1234 /** 1005
1235 *
1236 * @return
1237 */
1238 public Map<String, InputData> inputData() { 1006 public Map<String, InputData> inputData() {
1239 return inputData; 1007 return inputData;
1240 } 1008 }
1241 1009
1242 /** 1010
1243 * @return
1244 * @throws StateException
1245 * @see de.intevation.gnv.state.State#getInputData()
1246 */
1247 public Collection<InputData> getInputData() throws StateException { 1011 public Collection<InputData> getInputData() throws StateException {
1248 return this.inputData != null ? this.inputData.values() : null; 1012 return this.inputData != null ? this.inputData.values() : null;
1249 } 1013 }
1250 1014
1251 /** 1015
1252 *
1253 * @param name
1254 * @return
1255 */
1256 public InputData getInputDataByName(String name) { 1016 public InputData getInputDataByName(String name) {
1257 State state = this; 1017 State state = this;
1258 1018
1259 while (state != null) { 1019 while (state != null) {
1260 InputData data = state.inputData().get(name); 1020 InputData data = state.inputData().get(name);
1266 } 1026 }
1267 1027
1268 return null; 1028 return null;
1269 } 1029 }
1270 1030
1271 /** 1031
1272 *
1273 * @param globalContext
1274 */
1275 public void endOfLife(Object globalContext) { 1032 public void endOfLife(Object globalContext) {
1276 } 1033 }
1277 1034
1278 1035
1279 /**
1280 *
1281 * @param context
1282 */
1283 public void cleanup(Object context) { 1036 public void cleanup(Object context) {
1284 } 1037 }
1285 } 1038 }
1286 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 1039 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org