Skip to content

Commit 86b3a51

Browse files
committed
Merge remote-tracking branch 'origin/master' into reactIntegrate
2 parents c5e5f06 + 3772f5f commit 86b3a51

5 files changed

Lines changed: 78 additions & 14 deletions

File tree

dataspread-ui/src/Components/Navigation.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,8 @@ export default class Navigation extends Component {
10621062
queryObj.last = lastR;
10631063
queryObj.conditions = cond;
10641064
queryObj.values = value;
1065+
let childlist = this.computePath();
1066+
queryObj.path = " " + childlist;
10651067

10661068
fetch(this.state.urlPrefix + '/api/' + 'getBrushColorList', {
10671069
method: "POST",

webapp/src/api/controller/NavigationController.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ public HashMap<String, Object> getBrushColorList(@RequestBody String value) {
241241
JSONObject dict = (JSONObject) parser.parse(value);
242242
String bookId = (String) dict.get("bookId");
243243
String sheetName = (String) dict.get("sheetName");
244+
String path = (String) dict.get("path");
245+
244246
JSONArray first_ls = (JSONArray) dict.get("first");
245247
JSONArray last_ls = (JSONArray) dict.get("last");
246248
JSONArray cond_ls = (JSONArray) dict.get("conditions");
@@ -249,7 +251,8 @@ public HashMap<String, Object> getBrushColorList(@RequestBody String value) {
249251
SBook book = BookBindings.getBookById(bookId);
250252
SSheet currentSheet = book.getSheetByName(sheetName);
251253

252-
ArrayList<Integer> indices = new ArrayList<Integer>();
254+
255+
List cellIndices;
253256
Model model = currentSheet.getDataModel();
254257
//Todo: when on demand loading available
255258
/*for(int i=0;i<first_ls.size();i++)
@@ -264,13 +267,19 @@ public HashMap<String, Object> getBrushColorList(@RequestBody String value) {
264267
double queryValue = Double.parseDouble((String) val_ls.get(i));
265268
266269
if(model.navS.isConditionSatisfied(currvalue,(String) cond_ls.get(i),queryValue))
267-
indices.add(j);
270+
cellIndices.add(j);
268271
}
269272
}*/
270273

271274
System.out.println("Calling brush color list");
275+
276+
272277
int first = (Integer) first_ls.get(0);
273278
int last = (Integer) last_ls.get(0);
279+
280+
//cellIndices = model.navS.getBrushColotList(first,last,val_ls,cond_ls,attrIndex);
281+
282+
cellIndices = new ArrayList<Integer>();
274283
for(int j=first;j<=last;j++)
275284
{
276285
SCell sCell = currentSheet.getCell(j, attrIndex);
@@ -280,19 +289,19 @@ public HashMap<String, Object> getBrushColorList(@RequestBody String value) {
280289
double queryValue = Double.parseDouble((String) val_ls.get(0));
281290

282291
if (model.navS.isConditionSatisfied(currvalue, (String) cond_ls.get(0), queryValue))
283-
indices.add(j);
292+
cellIndices.add(j);
284293
}catch (Exception e)
285294
{
286295
String currvalue = String.valueOf(sCell.getValue());
287296
String queryValue = (String) val_ls.get(0);
288297

289298
if (model.navS.isConditionSatisfiedStr(currvalue, (String) cond_ls.get(0), queryValue))
290-
indices.add(j);
299+
cellIndices.add(j);
291300
}
292301
}
293302

294303

295-
return JsonWrapper.generateJson(indices);
304+
return JsonWrapper.generateJson(cellIndices);
296305
}
297306

298307
private int[] getIndices(String path) {

zssmodel/src/org/zkoss/zss/model/impl/Bucket.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class Bucket<T> implements Serializable {
1919
String summary;
2020
ArrayList<Bucket> children;
2121
Map<String, Object> aggMem;
22+
Map<String, Object> summaryStat;
2223

2324
Bucket() {
2425
aggMem = new HashMap<>();

zssmodel/src/org/zkoss/zss/model/impl/NavChartsPrototype.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,13 @@ private int getChartType(String formulaStr) {
7878

7979

8080

81-
public HashMap<String,Double> summaryStat(int attr, Bucket<String> subGroup)
81+
public Map<String,Object> summaryStat(int attr, Bucket<String> subGroup)
8282
{
83+
if(subGroup.summaryStat!=null)
84+
return subGroup.summaryStat;
85+
8386
ArrayList<Double> numData = navS.collectDoubleValues(attr, subGroup);
84-
HashMap<String,Double> result = new HashMap<String,Double>();
87+
Map<String,Object> result = new HashMap<>();
8588
//min, max, average, var, STDDEV
8689
// 0, 1, 2, 3, 4
8790
double min = Double.MAX_VALUE;
@@ -107,7 +110,7 @@ public HashMap<String,Double> summaryStat(int attr, Bucket<String> subGroup)
107110
result.put("AVERAGE",avg/numData.size());
108111
result.put("STDEV",Double.MAX_VALUE);
109112
result.put("VAR",Double.MAX_VALUE);
110-
113+
subGroup.summaryStat = result;
111114
return result;
112115
}
113116

@@ -133,14 +136,14 @@ private void type0Chart(Map<String, Object> obj, int attr, Bucket<String> subGro
133136
private void type0Chart(Map<String, Object> obj, int attr, Bucket<String> subGroup, String formula) {
134137
obj.put("chartType", 0);
135138
List<Double> chartData = new ArrayList<>();
136-
HashMap<String,Double> res = summaryStat(attr,subGroup);
139+
Map<String, Object> res = summaryStat(attr,subGroup);
137140
List<String> emptyList = new ArrayList<>();
138141
emptyList.add("");
139142
for (String f : type0Stat) {
140143
if(!f.equals("MEDIAN"))
141144
{
142-
chartData.add(res.get(f));
143-
navS.setBucketAggWithMemoization(model,subGroup,attr,f,emptyList,res.get(f));
145+
chartData.add((Double) res.get(f));
146+
navS.setBucketAggWithMemoization(model,subGroup,attr,f,emptyList,(Double) res.get(f));
144147
}
145148
else if(formula.equals("MEDIAN"))
146149
{
@@ -177,7 +180,7 @@ private void type2Chart(Map<String, Object> obj, int attr, Bucket<String> subGro
177180
NavigationHistogram hist = new NavigationHistogram(navS.collectDoubleValues(attr, subGroup));
178181
hist.formattedOutput(obj, null);
179182

180-
HashMap<String,Double> res = summaryStat(attr,subGroup);
183+
Map<String, Object> res = summaryStat(attr,subGroup);
181184

182185
HashMap<String, Object> chartData = (HashMap) obj.get("chartData");
183186
List<String> emptyList = new ArrayList<>();
@@ -186,12 +189,12 @@ private void type2Chart(Map<String, Object> obj, int attr, Bucket<String> subGro
186189
if(f.equals("AVERAGE"))
187190
{
188191
chartData.put(f,res.get(f));
189-
navS.setBucketAggWithMemoization(model,subGroup,attr,f,emptyList,res.get(f));
192+
navS.setBucketAggWithMemoization(model,subGroup,attr,f,emptyList,(Double) res.get(f));
190193
}
191194
else
192195
{
193196
Map<String, Object> resMed = navS.getBucketAggWithMemoization(model, subGroup, attr, f, emptyList);
194-
chartData.put(f,(Double) resMed.get("value"));
197+
chartData.put(f,resMed.get("value"));
195198
}
196199
}
197200
}

zssmodel/src/org/zkoss/zss/model/impl/NavigationStructure.java

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.model.AutoRollbackConnection;
99
import org.model.DBContext;
1010
import org.model.DBHandler;
11+
import org.zkoss.json.JSONArray;
1112
import org.zkoss.zss.model.CellRegion;
1213
import org.zkoss.zss.model.SBook;
1314
import org.zkoss.zss.model.SCell;
@@ -32,6 +33,9 @@ public class NavigationStructure {
3233
*/
3334
private ReturnBuffer returnBuffer;
3435
public int isNumericNavAttr;
36+
List cellIndices;
37+
38+
3539

3640

3741
class ReturnBuffer {
@@ -98,6 +102,51 @@ else if (condition.equals("<="))
98102

99103
}
100104

105+
public List<Integer> getBrushColotList(int first, int last, JSONArray val_ls,JSONArray cond_ls, int attrIndex) {
106+
107+
System.out.println(first+","+last);
108+
List newCellIndices = new ArrayList<Integer>();
109+
if(cellIndices!=null)
110+
{
111+
112+
for(int i=first-1;i<last;i++)
113+
{
114+
if((int) cellIndices.get(i)==1)
115+
newCellIndices.add(i+1);
116+
}
117+
return newCellIndices;
118+
}
119+
cellIndices = new ArrayList<Integer>();
120+
for(int j=first;j<=last;j++)
121+
{
122+
SCell sCell = currentSheet.getCell(j, attrIndex);
123+
124+
try {
125+
double currvalue = Double.parseDouble(String.valueOf(sCell.getValue()));
126+
double queryValue = Double.parseDouble((String) val_ls.get(0));
127+
128+
if (isConditionSatisfied(currvalue, (String) cond_ls.get(0), queryValue)) {
129+
cellIndices.add(1);
130+
newCellIndices.add(j);
131+
}
132+
else
133+
cellIndices.add(0);
134+
}catch (Exception e)
135+
{
136+
String currvalue = String.valueOf(sCell.getValue());
137+
String queryValue = (String) val_ls.get(0);
138+
139+
if (isConditionSatisfiedStr(currvalue, (String) cond_ls.get(0), queryValue)){
140+
cellIndices.add(1);
141+
newCellIndices.add(j);
142+
}
143+
else
144+
cellIndices.add(0);
145+
}
146+
}
147+
return newCellIndices;
148+
}
149+
101150
public boolean isConditionSatisfied(double currValue, String condition, double queryValue) {
102151
int conditionCode = getConditionCode(condition);
103152

0 commit comments

Comments
 (0)