Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WDifferencesState.java @ 1661:a890bf077de5
Use StringUtil.wWrap , fix wrong loop, minor refac and cosmetics.
flys-artifacts/trunk@2860 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 28 Sep 2011 15:47:57 +0000 |
parents | d251e5929860 |
children | fc9719cddbc6 |
comparison
equal
deleted
inserted
replaced
1660:804c58c56422 | 1661:a890bf077de5 |
---|---|
80 String id = getID(); | 80 String id = getID(); |
81 | 81 |
82 // Load the Artifacts/facets that we want to subtract and display. | 82 // Load the Artifacts/facets that we want to subtract and display. |
83 // Expected format is: | 83 // Expected format is: |
84 // [42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;0]#[1231f2-....] | 84 // [42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;0]#[1231f2-....] |
85 String datas[] = winfo.getDataAsString("diffids").split("#"); | 85 String diffids = winfo.getDataAsString("diffids"); |
86 String datas[] = diffids.split("#"); | |
86 | 87 |
87 // Validate the Data-Strings. | 88 // Validate the Data-Strings. |
88 for (String s: datas) { | 89 for (String s: datas) { |
89 if (!WaterlevelSelectState.isValueValid(winfo.getDataAsString("diffids"))) { | 90 if (!WaterlevelSelectState.isValueValid(winfo.getDataAsString("diffids"))) { |
90 // TODO: escalate. | 91 // TODO: escalate. |
96 ; | 97 ; |
97 } | 98 } |
98 | 99 |
99 List<WKms> wkmss = new ArrayList<WKms>(); | 100 List<WKms> wkmss = new ArrayList<WKms>(); |
100 | 101 |
101 for(int i = 0; i < datas.length /2; i++) { | 102 for(int i = 0; i < datas.length; i+=2) { |
102 // e.g.: | 103 // e.g.: |
103 // 42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;1 | 104 // 42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;1 |
104 String[] def1 = StringUtil.unbracket(datas[i+0]).split(";"); | 105 String[] def1 = StringUtil.unbracket(datas[i+0]).split(";"); |
105 String[] def2 = StringUtil.unbracket(datas[i+1]).split(";"); | 106 String[] def2 = StringUtil.unbracket(datas[i+1]).split(";"); |
106 String uuid1 = def1[0]; | 107 String uuid1 = def1[0]; |
123 } | 124 } |
124 // TODO: Issue of multiple results in calculation | 125 // TODO: Issue of multiple results in calculation |
125 String facetName = "diff ()"; | 126 String facetName = "diff ()"; |
126 | 127 |
127 if (flys1 != null && flys2 != null) { | 128 if (flys1 != null && flys2 != null) { |
128 // TODO Also check size. | |
129 // TODO Also need index of wqkms. | |
130 WQKms[] minuend = (WQKms[]) flys1.getWaterlevelData(). | 129 WQKms[] minuend = (WQKms[]) flys1.getWaterlevelData(). |
131 getData(); | 130 getData(); |
132 WQKms[] subtrahend = (WQKms[]) flys2.getWaterlevelData(). | 131 WQKms[] subtrahend = (WQKms[]) flys2.getWaterlevelData(). |
133 getData(); | 132 getData(); |
134 | 133 |
135 if (datas.length > 2) { | 134 facetName = StringUtil.wWrap(minuend[idx1].getName()) |
136 logger.error("Cannot keep more than one calculation."); | 135 + " - " + StringUtil.wWrap(subtrahend[idx2].getName()); |
137 } | 136 WKms wkms = WKmsOperation.SUBTRACTION.operate(minuend[idx1], |
138 facetName = "W (" + minuend[idx1].getName() + ") - W (" + subtrahend[idx2].getName() + ")"; | 137 subtrahend[idx2]); |
139 WKms wkms = WKmsOperation.SUBTRACTION.operate(minuend[idx1], subtrahend[idx2]); | |
140 wkms.setName(facetName); | 138 wkms.setName(facetName); |
141 wkmss.add(wkms); | 139 wkmss.add(wkms); |
142 logger.debug("WKMSSubtraction happened"); | 140 logger.debug("WKMSSubtraction happened"); |
143 } | 141 } |
144 | 142 |