SAINTDefaultTransformer.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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.cq.scheduled.exporter.TransformationException
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Service
* org.apache.sling.api.resource.Resource
* org.apache.sling.api.resource.ValueMap
*/
package com.day.cq.analytics.sitecatalyst.impl.exporter;
import com.adobe.cq.scheduled.exporter.TransformationException;
import com.day.cq.analytics.sitecatalyst.ClassificationsTransformer;
import java.util.Collection;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
@Component
@Service
public class SAINTDefaultTransformer
implements ClassificationsTransformer {
private static final String COLUMNNAME_KEY = "Key";
@Override
public String[] getHeader(Resource resource) {
LinkedList<String> header = new LinkedList<String>();
header.add("Key");
ValueMap properties = (ValueMap)resource.adaptTo(ValueMap.class);
LinkedList keys = new LinkedList(properties.keySet());
for (String key : keys) {
if (key.indexOf(":") >= 0) continue;
header.add(key);
}
return header.toArray(new String[0]);
}
public String[] transform(Resource resource) throws TransformationException {
LinkedList<String> row = new LinkedList<String>();
row.add(resource.getName());
ValueMap properties = (ValueMap)resource.adaptTo(ValueMap.class);
LinkedList entries = new LinkedList(properties.entrySet());
for (Map.Entry entry : entries) {
if (((String)entry.getKey()).indexOf(":") >= 0) continue;
row.add(entry.getValue().toString());
}
return row.toArray(new String[0]);
}
}