comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java @ 2095:8cb679d4ec49

Implemented initialize() in FloodMapState to enable cloning floodmaps. flys-artifacts/trunk@3642 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 10 Jan 2012 11:50:01 +0000
parents ebc2aa64c1be
children 85d31c2620e5
comparison
equal deleted inserted replaced
2094:22732713c54d 2095:8cb679d4ec49
260 260
261 for (String stateId: stateIds) { 261 for (String stateId: stateIds) {
262 State state = getState(context, stateId); 262 State state = getState(context, stateId);
263 263
264 if (state != null) { 264 if (state != null) {
265 state.initialize(artifact, context, callMeta); 265 state.initialize(artifact, this, context, callMeta);
266 } 266 }
267 } 267 }
268 } 268 }
269 269
270 270
618 public Collection<StateData> getAllData() { 618 public Collection<StateData> getAllData() {
619 return data.values(); 619 return data.values();
620 } 620 }
621 621
622 622
623 public List<Facet> getFacets() {
624 List<Facet> all = new ArrayList<Facet>();
625
626 Set<Map.Entry<String, List<Facet>>> entries = facets.entrySet();
627 for (Map.Entry<String, List<Facet>> entry: entries) {
628 List<Facet> fs = entry.getValue();
629 for (Facet f: fs) {
630 all.add(f);
631 }
632 }
633
634 return all;
635 }
636
637
623 /** 638 /**
624 * Get facet as stored internally, with equalling name and index than given 639 * Get facet as stored internally, with equalling name and index than given
625 * facet. 640 * facet.
626 * @param facet that defines index and name of facet searched. 641 * @param facet that defines index and name of facet searched.
627 * @return facet instance or null if not found. 642 * @return facet instance or null if not found.
770 * Return List of outputs, where combinations of outputname and filtername 785 * Return List of outputs, where combinations of outputname and filtername
771 * that match content in filterFacets is left out. 786 * that match content in filterFacets is left out.
772 * @return filtered Outputlist. 787 * @return filtered Outputlist.
773 */ 788 */
774 protected List<Output> filterOutputs(List<Output> outs) { 789 protected List<Output> filterOutputs(List<Output> outs) {
775
776 if (filterFacets == null || filterFacets.isEmpty()) { 790 if (filterFacets == null || filterFacets.isEmpty()) {
777 logger.debug("No filter for Outputs."); 791 logger.debug("No filter for Outputs.");
778 return outs; 792 return outs;
779 } 793 }
780 794
795 logger.debug("Filter Facets with " + filterFacets.size() + " filters.");
796
781 List<Output> filtered = new ArrayList<Output>(); 797 List<Output> filtered = new ArrayList<Output>();
782 798
783 for (Output out: outs) { 799 for (Output out: outs) {
784 800 String outName = out.getName();
785 List<Facet> fFacets = filterFacets.get(out.getName()); 801
802 logger.debug(" filter Facets for Output: " + outName);
803
804 List<Facet> fFacets = filterFacets.get(outName);
786 if (fFacets != null) { 805 if (fFacets != null) {
806 logger.debug("" + fFacets.size() + " filters for: " + outName);
807
808 if (logger.isDebugEnabled()) {
809 for (Facet tmp: fFacets) {
810 logger.debug(" filter = '" + tmp.getName() + "'");
811 }
812 }
787 813
788 List<Facet> resultFacets = new ArrayList<Facet>(); 814 List<Facet> resultFacets = new ArrayList<Facet>();
789 815
790 for (Facet facet: out.getFacets()) { 816 for (Facet facet: out.getFacets()) {
791 for (Facet fFacet: fFacets) { 817 for (Facet fFacet: fFacets) {
795 break; 821 break;
796 } 822 }
797 } 823 }
798 } 824 }
799 825
826 logger.debug("Facets after filtering = " + resultFacets.size());
827
800 if (!resultFacets.isEmpty()) { 828 if (!resultFacets.isEmpty()) {
801 DefaultOutput nout = new DefaultOutput( 829 DefaultOutput nout = new DefaultOutput(
802 out.getName(), 830 out.getName(),
803 out.getDescription(), 831 out.getDescription(),
804 out.getMimeType(), 832 out.getMimeType(),
806 filtered.add(nout); 834 filtered.add(nout);
807 } 835 }
808 } 836 }
809 } 837 }
810 838
839 logger.debug("All Facets after filtering = " + filtered.size());
840
811 return filtered; 841 return filtered;
812 } 842 }
813 843
814 844
815 /** 845 /**
817 * all previous states). 847 * all previous states).
818 * 848 *
819 * @return list of outputs 849 * @return list of outputs
820 */ 850 */
821 public List<Output> getOutputs(Object context) { 851 public List<Output> getOutputs(Object context) {
852 logger.debug("##### Get Outputs for: " + identifier() + " #####");
853
822 List<String> stateIds = getPreviousStateIds(); 854 List<String> stateIds = getPreviousStateIds();
823 List<Output> generated = new ArrayList<Output>(); 855 List<Output> generated = new ArrayList<Output>();
824 856
825 for (String stateId: stateIds) { 857 for (String stateId: stateIds) {
826 DefaultState state = (DefaultState) getState(context, stateId); 858 DefaultState state = (DefaultState) getState(context, stateId);
855 * Get output(s) for a specific state. 887 * Get output(s) for a specific state.
856 * @param state State of interest 888 * @param state State of interest
857 * @return list of output(s) for given state. 889 * @return list of output(s) for given state.
858 */ 890 */
859 protected List<Output> getOutputForState(DefaultState state) { 891 protected List<Output> getOutputForState(DefaultState state) {
892 logger.debug("Find Outputs for State: " + state.getID());
893
860 List<Output> list = state.getOutputs(); 894 List<Output> list = state.getOutputs();
861 if (list == null || list.size() == 0) { 895 if (list == null || list.size() == 0) {
862 logger.debug("-> No output modes for this state."); 896 logger.debug("-> No output modes for this state.");
863 return new ArrayList<Output>(); 897 return new ArrayList<Output>();
864 } 898 }
865 899
866 List<Facet> fs = facets.get(state.getID()); 900 String stateId = state.getID();
901
902 List<Facet> fs = facets.get(stateId);
867 903
868 if (fs == null || fs.size() == 0) { 904 if (fs == null || fs.size() == 0) {
869 logger.debug("No facets found."); 905 logger.debug("No facets found.");
870 return new ArrayList<Output>(); 906 return new ArrayList<Output>();
871 } 907 }
872 908
873 return generateOutputs(list, fs); 909 List<Output> gen = generateOutputs(list, fs);
910
911 logger.debug("State '" + stateId + "' has " + gen.size() + " outs");
912
913 return gen;
874 } 914 }
875 915
876 916
877 /** 917 /**
878 * Generate a list of outputs with facets from fs if type is found in list 918 * Generate a list of outputs with facets from fs if type is found in list
1075 logger.debug("- State: " + id); 1115 logger.debug("- State: " + id);
1076 } 1116 }
1077 1117
1078 logger.debug("CURRENT STATE: " + getCurrentStateId()); 1118 logger.debug("CURRENT STATE: " + getCurrentStateId());
1079 1119
1120 debugFacets();
1121 dumpFilterFacets();
1122
1080 logger.debug("++++++++++++++ END ARTIFACT DUMP +++++++++++++++++"); 1123 logger.debug("++++++++++++++ END ARTIFACT DUMP +++++++++++++++++");
1081 } 1124 }
1125 }
1126
1127
1128 protected void debugFacets() {
1129 logger.debug("######### FACETS #########");
1130 Set<Map.Entry<String, List<Facet>>> entries = facets.entrySet();
1131
1132 for (Map.Entry<String, List<Facet>> entry: entries) {
1133 String out = entry.getKey();
1134 List<Facet> fs = entry.getValue();
1135 for (Facet f: fs) {
1136 logger.debug(" # " + out + " : " + f.getName());
1137 }
1138 }
1139
1140 logger.debug("######## FACETS END ########");
1141 }
1142
1143
1144 protected void dumpFilterFacets() {
1145 logger.debug("######## FILTER FACETS ########");
1146
1147 if (filterFacets == null || filterFacets.isEmpty()) {
1148 logger.debug("No Filter Facets defined.");
1149 return;
1150 }
1151
1152 Set<Map.Entry<String, List<Facet>>> entries = filterFacets.entrySet();
1153 for (Map.Entry<String, List<Facet>> entry: entries) {
1154 String out = entry.getKey();
1155 List<Facet> filters = entry.getValue();
1156
1157 logger.debug("There are " + filters.size() + " filters for: " +out);
1158
1159 for (Facet filter: filters) {
1160 logger.debug(" filter: " + filter.getName());
1161 }
1162 }
1163
1164 logger.debug("######## FILTER FACETS END ########");
1082 } 1165 }
1083 1166
1084 1167
1085 protected void destroyState(String id, Object context) { 1168 protected void destroyState(String id, Object context) {
1086 State s = getState(context, id); 1169 State s = getState(context, id);

http://dive4elements.wald.intevation.org