001package com.identityworksllc.iiq.common.reporting;
002
003import net.sf.jasperreports.engine.JRException;
004import net.sf.jasperreports.engine.JRField;
005import sailpoint.api.SailPointContext;
006import sailpoint.object.Attributes;
007import sailpoint.object.LiveReport;
008import sailpoint.object.QueryOptions;
009import sailpoint.object.ReportColumnConfig;
010import sailpoint.object.ReportDataSource;
011import sailpoint.object.Sort;
012import sailpoint.reporting.datasource.JavaDataSource;
013import sailpoint.task.Monitor;
014import sailpoint.tools.GeneralException;
015import sailpoint.tools.Util;
016
017import java.util.ArrayList;
018import java.util.List;
019
020/**
021 * Parent class for Java data sources, making certain things easier
022 */
023public abstract class AbstractJavaDataSource implements JavaDataSource {
024
025        protected SailPointContext context;
026        protected String groupBy;
027        protected Attributes<Object, Object> inputs;
028        protected int limit;
029        protected LiveReport liveReport;
030        protected Monitor monitor;
031        protected ArrayList<Object> sortBy;
032        protected int start;
033
034        @Override
035        public void close() {
036                // No-op by default
037        }
038
039        @Override
040        public String getBaseHql() {
041                // TODO Auto-generated method stub
042                return null;
043        }
044
045        @Override
046        public QueryOptions getBaseQueryOptions() {
047                // TODO Auto-generated method stub
048                return null;
049        }
050
051        public Object getFieldValue(JRField jrField) throws JRException {
052                String name = jrField.getName();
053                Object value = null;
054                try {
055                        value = getFieldValue(name);
056                } catch (GeneralException e) {
057                        throw new JRException(e);
058                }
059                return value;
060        }
061        
062        @Override
063        public int getSizeEstimate() throws GeneralException {
064                return 0;
065        }
066
067        @Override
068        public void initialize(SailPointContext context, LiveReport liveReport, Attributes<String, Object> taskArguments, String groupBy, List<Sort> sortBy) throws GeneralException {
069                this.context = context;
070                this.liveReport = liveReport;
071                this.inputs = new Attributes<>();
072                if (taskArguments != null) {
073                        this.inputs.putAll(taskArguments);
074                }
075                this.groupBy = groupBy;
076
077                this.sortBy = new ArrayList<>();
078                if (sortBy != null) {
079                        this.sortBy.addAll(sortBy);
080                }
081        }
082
083        @Override
084        public void setLimit(int arg0, int arg1) {
085                start = arg0;
086                limit = arg1;
087        }
088
089        @Override
090        public void setMonitor(Monitor arg0) {
091                this.monitor = arg0;
092        }
093
094}