Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java @ 473:a6a33ef35809
Added support to step back to previous states. Add state names to xform nodes in describe document and append old targets to list of reachable targets.
gnv-artifacts/trunk@539 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 13 Jan 2010 23:10:56 +0000 |
parents | b7bb66440cc8 |
children | 20dde2b6f1b5 |
comparison
equal
deleted
inserted
replaced
472:d6a100d5f74a | 473:a6a33ef35809 |
---|---|
61 private final static String MINVALUEFIELDNAME = "minvalue"; | 61 private final static String MINVALUEFIELDNAME = "minvalue"; |
62 private final static String MAXVALUEFIELDNAME = "maxvalue"; | 62 private final static String MAXVALUEFIELDNAME = "maxvalue"; |
63 | 63 |
64 private final static String NODATASELECTIONKEY = "n/n"; | 64 private final static String NODATASELECTIONKEY = "n/n"; |
65 | 65 |
66 private final static String DESCRIBEDATAKEY = "_DESCRIBEDATA"; | 66 public final static String DESCRIBEDATAKEY = "_DESCRIBEDATA"; |
67 | 67 |
68 private String id = null; | 68 private String id = null; |
69 | 69 |
70 private String description = null; | 70 private String description = null; |
71 | 71 |
117 } | 117 } |
118 | 118 |
119 | 119 |
120 public void reset(String uuid) { | 120 public void reset(String uuid) { |
121 | 121 |
122 // clear input values of the current state | 122 if (parent != null) { |
123 Iterator iter = inputValueNames.iterator(); | 123 inputData = parent.inputData(); |
124 while (iter.hasNext()) { | 124 } |
125 String name = (String) iter.next(); | 125 } |
126 inputValues.remove(name); | 126 |
127 } | |
128 | |
129 // remove data of last state from cache | |
130 List describeData = getDescibeData(uuid); | |
131 if (describeData != null && describeData.size() != 0) { | |
132 describeData.remove(describeData.size()-1); | |
133 } | |
134 } | |
135 | 127 |
136 /** | 128 /** |
137 * @see de.intevation.gnv.state.State#setup(org.w3c.dom.Node) | 129 * @see de.intevation.gnv.state.State#setup(org.w3c.dom.Node) |
138 */ | 130 */ |
139 public void setup(Node configuration) { | 131 public void setup(Node configuration) { |
498 NamedCollection<KeyValueDescibeData> keyValueDescibeData = new NamedArrayList<KeyValueDescibeData>( | 490 NamedCollection<KeyValueDescibeData> keyValueDescibeData = new NamedArrayList<KeyValueDescibeData>( |
499 this.dataName, dataSize); | 491 this.dataName, dataSize); |
500 keyValueDescibeData.setMultiSelect(this.dataMultiSelect); | 492 keyValueDescibeData.setMultiSelect(this.dataMultiSelect); |
501 | 493 |
502 if (this.dataNoSelect){ | 494 if (this.dataNoSelect){ |
503 keyValueDescibeData.add(new DefaultKeyValueDescribeData(NODATASELECTIONKEY, | 495 keyValueDescibeData.add(new DefaultKeyValueDescribeData( |
504 "No Selection")); | 496 NODATASELECTIONKEY, |
505 } | 497 "No Selection", |
498 getID() | |
499 )); | |
500 } | |
501 | |
506 boolean initialized = false; | 502 boolean initialized = false; |
507 int keyPos= 0; | 503 int keyPos = 0; |
508 int valuePos = 1; | 504 int valuePos = 1; |
509 String previousKey = null; | 505 String previousKey = null; |
506 | |
510 while (rit.hasNext()) { | 507 while (rit.hasNext()) { |
511 Result resultValue = rit.next(); | 508 Result resultValue = rit.next(); |
512 if (!initialized){ | 509 if (!initialized){ |
513 keyPos = resultValue.getResultDescriptor().getColumnIndex(keyid); | 510 keyPos = resultValue.getResultDescriptor().getColumnIndex(keyid); |
514 valuePos = resultValue.getResultDescriptor().getColumnIndex(valueid); | 511 valuePos = resultValue.getResultDescriptor().getColumnIndex(valueid); |
519 } | 516 } |
520 String tmpKey = resultValue.getString(keyPos); | 517 String tmpKey = resultValue.getString(keyPos); |
521 // TODO: FIXME: We have to do that because the arcsde does not support a distinct Query on Layers. | 518 // TODO: FIXME: We have to do that because the arcsde does not support a distinct Query on Layers. |
522 if (previousKey == null || !tmpKey.equals(previousKey)){ | 519 if (previousKey == null || !tmpKey.equals(previousKey)){ |
523 previousKey = tmpKey; | 520 previousKey = tmpKey; |
524 keyValueDescibeData.add(new DefaultKeyValueDescribeData(tmpKey, resultValue.getString(valuePos))); | 521 keyValueDescibeData.add(new DefaultKeyValueDescribeData(tmpKey, resultValue.getString(valuePos), getID())); |
525 } | 522 } |
526 } | 523 } |
527 return keyValueDescibeData; | 524 return keyValueDescibeData; |
528 } | 525 } |
529 | 526 |
558 | 555 |
559 while (it.hasNext()) { | 556 while (it.hasNext()) { |
560 Object o = it.next(); | 557 Object o = it.next(); |
561 if ((!it.hasNext() && dataName != null)) { | 558 if ((!it.hasNext() && dataName != null)) { |
562 appendToDynamicNode( | 559 appendToDynamicNode( |
563 xCreator, document, dynamic, callMeta, o); | 560 creator, xCreator, document, dynamic, callMeta, o); |
564 } | 561 } |
565 else { | 562 else { |
566 appendToStaticNode( | 563 appendToStaticNode( |
567 xCreator, document, staticNode, callMeta, o); | 564 creator, xCreator, document, staticNode, callMeta, o); |
568 } | 565 } |
569 } | 566 } |
570 } | 567 } |
571 } | 568 } |
572 | 569 |
573 | 570 |
574 protected void appendToStaticNode( | 571 protected void appendToStaticNode( |
572 XMLUtils.ElementCreator artCreator, | |
575 XMLUtils.ElementCreator creator, | 573 XMLUtils.ElementCreator creator, |
576 Document document, | 574 Document document, |
577 Node staticNode, | 575 Node staticNode, |
578 CallMeta callMeta, | 576 CallMeta callMeta, |
579 Object o | 577 Object o |
602 Iterator<KeyValueDescibeData> resultIt = values.iterator(); | 600 Iterator<KeyValueDescibeData> resultIt = values.iterator(); |
603 while (resultIt.hasNext()) { | 601 while (resultIt.hasNext()) { |
604 KeyValueDescibeData result = resultIt.next(); | 602 KeyValueDescibeData result = resultIt.next(); |
605 | 603 |
606 if (result.isSelected()) { | 604 if (result.isSelected()) { |
605 artCreator.addAttr( | |
606 selectNode, "state", result.getState(), true | |
607 ); | |
608 | |
607 Element itemNode = creator.create("item"); | 609 Element itemNode = creator.create("item"); |
608 | 610 |
609 creator.addAttr(itemNode, "selected", "true"); | 611 creator.addAttr(itemNode, "selected", "true"); |
610 | 612 |
611 Element choiceLableNode = creator.create("label"); | 613 Element choiceLableNode = creator.create("label"); |
623 | 625 |
624 staticNode.appendChild(selectNode); | 626 staticNode.appendChild(selectNode); |
625 } | 627 } |
626 else if (o instanceof MinMaxDescribeData) { | 628 else if (o instanceof MinMaxDescribeData) { |
627 appendMinMaxDescribeData( | 629 appendMinMaxDescribeData( |
630 artCreator, | |
628 creator, | 631 creator, |
629 document, | 632 document, |
630 staticNode, | 633 staticNode, |
631 callMeta, | 634 callMeta, |
632 o); | 635 o); |
633 } | 636 } |
634 else if (o instanceof SingleValueDescribeData) { | 637 else if (o instanceof SingleValueDescribeData) { |
635 appendSingleValueDescribeData( | 638 appendSingleValueDescribeData( |
639 artCreator, | |
636 creator, | 640 creator, |
637 document, | 641 document, |
638 staticNode, | 642 staticNode, |
639 callMeta, | 643 callMeta, |
640 o); | 644 o); |
641 } | 645 } |
642 } | 646 } |
643 | 647 |
644 | 648 |
645 protected void appendToDynamicNode( | 649 protected void appendToDynamicNode( |
650 XMLUtils.ElementCreator artCreator, | |
646 XMLUtils.ElementCreator creator, | 651 XMLUtils.ElementCreator creator, |
647 Document document, | 652 Document document, |
648 Node dynamicNode, | 653 Node dynamicNode, |
649 CallMeta callMeta, | 654 CallMeta callMeta, |
650 Object o | 655 Object o |
693 | 698 |
694 dynamicNode.appendChild(selectNode); | 699 dynamicNode.appendChild(selectNode); |
695 } | 700 } |
696 else if (o instanceof MinMaxDescribeData) { | 701 else if (o instanceof MinMaxDescribeData) { |
697 appendMinMaxDescribeData( | 702 appendMinMaxDescribeData( |
703 artCreator, | |
698 creator, | 704 creator, |
699 document, | 705 document, |
700 dynamicNode, | 706 dynamicNode, |
701 callMeta, | 707 callMeta, |
702 o); | 708 o); |
703 } | 709 } |
704 else if (o instanceof SingleValueDescribeData) { | 710 else if (o instanceof SingleValueDescribeData) { |
705 appendSingleValueDescribeData( | 711 appendSingleValueDescribeData( |
712 artCreator, | |
706 creator, | 713 creator, |
707 document, | 714 document, |
708 dynamicNode, | 715 dynamicNode, |
709 callMeta, | 716 callMeta, |
710 o); | 717 o); |
711 } | 718 } |
712 } | 719 } |
713 | 720 |
714 | 721 |
715 protected void appendMinMaxDescribeData( | 722 protected void appendMinMaxDescribeData( |
723 XMLUtils.ElementCreator artCreator, | |
716 XMLUtils.ElementCreator creator, | 724 XMLUtils.ElementCreator creator, |
717 Document document, | 725 Document document, |
718 Node node, | 726 Node node, |
719 CallMeta callMeta, | 727 CallMeta callMeta, |
720 Object o | 728 Object o |
731 Date d = ((GregorianCalendar) max).getTime(); | 739 Date d = ((GregorianCalendar) max).getTime(); |
732 max = DateUtils.getPatternedDateAmer(d); | 740 max = DateUtils.getPatternedDateAmer(d); |
733 } | 741 } |
734 | 742 |
735 Element groupNode = creator.create("group"); | 743 Element groupNode = creator.create("group"); |
744 artCreator.addAttr(groupNode, "state", minMaxDescibeData.getState(), true); | |
745 | |
736 creator.addAttr(groupNode, "ref", minMaxDescibeData.getName()); | 746 creator.addAttr(groupNode, "ref", minMaxDescibeData.getName()); |
737 Element groupNodeLableNode = creator.create("label"); | 747 Element groupNodeLableNode = creator.create("label"); |
738 groupNodeLableNode.setTextContent(RessourceFactory | 748 groupNodeLableNode.setTextContent(RessourceFactory |
739 .getInstance().getRessource( | 749 .getInstance().getRessource( |
740 callMeta.getLanguages(), | 750 callMeta.getLanguages(), |
773 | 783 |
774 node.appendChild(groupNode); | 784 node.appendChild(groupNode); |
775 } | 785 } |
776 | 786 |
777 | 787 |
778 | |
779 protected void appendSingleValueDescribeData( | 788 protected void appendSingleValueDescribeData( |
789 XMLUtils.ElementCreator artCreator, | |
780 XMLUtils.ElementCreator creator, | 790 XMLUtils.ElementCreator creator, |
781 Document document, | 791 Document document, |
782 Node node, | 792 Node node, |
783 CallMeta callMeta, | 793 CallMeta callMeta, |
784 Object o | 794 Object o |
785 ) { | 795 ) { |
786 SingleValueDescribeData svdb = (SingleValueDescribeData) o; | 796 SingleValueDescribeData svdb = (SingleValueDescribeData) o; |
787 | 797 |
788 Element groupNode = creator.create("group"); | 798 Element groupNode = creator.create("group"); |
799 artCreator.addAttr(groupNode, "state", svdb.getState(), true); | |
789 creator.addAttr(groupNode, "ref", svdb.getName()); | 800 creator.addAttr(groupNode, "ref", svdb.getName()); |
790 | 801 |
791 Element groupNodeLableNode = creator.create("label"); | 802 Element groupNodeLableNode = creator.create("label"); |
792 groupNodeLableNode.setTextContent(RessourceFactory | 803 groupNodeLableNode.setTextContent(RessourceFactory |
793 .getInstance().getRessource( | 804 .getInstance().getRessource( |
837 log.debug("Hash for Queryelements: " + key); | 848 log.debug("Hash for Queryelements: " + key); |
838 CacheFactory.getInstance().getCache().put(new net.sf.ehcache.Element(key, describeData)); | 849 CacheFactory.getInstance().getCache().put(new net.sf.ehcache.Element(key, describeData)); |
839 } | 850 } |
840 } | 851 } |
841 | 852 |
853 public Map<String, InputData> inputData() { | |
854 return inputData; | |
855 } | |
856 | |
842 /** | 857 /** |
843 * @see de.intevation.gnv.state.State#getInputData() | 858 * @see de.intevation.gnv.state.State#getInputData() |
844 */ | 859 */ |
845 public Collection<InputData> getInputData() throws StateException { | 860 public Collection<InputData> getInputData() throws StateException { |
846 return this.inputData != null ? this.inputData.values() : null; | 861 return this.inputData != null ? this.inputData.values() : null; |