SAINTDefaultTransformer.java 1.93 KB
/*
 * 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]);
    }
}