AbstractMerger.java
1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.sling.commons.json.JSONArray
* org.apache.sling.commons.json.JSONException
* org.apache.sling.commons.json.JSONObject
*/
package com.day.cq.analytics.sitecatalyst.rsmerger;
import com.day.cq.analytics.sitecatalyst.rsmerger.MergedVariable;
import com.day.cq.analytics.sitecatalyst.rsmerger.Merger;
import com.day.cq.analytics.sitecatalyst.rsmerger.ReportSuiteVariable;
import com.day.cq.analytics.sitecatalyst.rsmerger.Variable;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import org.apache.sling.commons.json.JSONArray;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;
@Deprecated
public abstract class AbstractMerger
implements Merger {
protected JSONObject jsonObj;
protected Map<Integer, MergedVariable> varMap;
public AbstractMerger(JSONArray variables) throws JSONException {
this.jsonObj = variables.length() > 0 ? variables.getJSONObject(0) : new JSONObject();
this.varMap = new TreeMap<Integer, MergedVariable>();
}
protected void intertwine(ReportSuiteVariable rsvar) {
int index = 0;
for (Variable var : rsvar.getVariables()) {
MergedVariable mVar = this.varMap.get(index);
if (mVar == null) {
mVar = new MergedVariable(var.getJSONObject());
this.varMap.put(index, mVar);
}
mVar.put(var.getName(), rsvar.getRsid());
++index;
}
}
protected JSONArray getVariables() throws JSONException {
JSONArray jsonArray = new JSONArray();
for (Map.Entry<Integer, MergedVariable> entry : this.varMap.entrySet()) {
JSONObject jsonVar = this.mergeVariable(entry.getKey(), entry.getValue());
jsonArray.put((Object)jsonVar);
}
return jsonArray;
}
}