@Test public void testQueryWithManyDsNames() throws UnsupportedOperationException, JRException { TestDatasetImpl reportDataset = new TestDatasetImpl(); reportDataset.setQueryText("--rrdDir share/rrd/snmp --nodeId 47 --resourceName opennms-jvm --dsName TotalMemory,DsName1,DsName2,DsName3"); ResourceQueryFieldsProvider provider = new ResourceQueryFieldsProvider(); JRField[] fields = provider.getFields(null, reportDataset, null); assertNotNull(fields); assertEquals(5, fields.length); assertEquals("Path", fields[0].getName()); assertEquals("TotalMemory", fields[1].getName()); assertEquals("DsName1", fields[2].getName()); assertEquals("DsName2", fields[3].getName()); assertEquals("DsName3", fields[4].getName()); }
public JRField[] getFields(IReportConnection irConn, JRDataset reportDataset, Map parameters) throws JRException, UnsupportedOperationException { String query = ""; if(reportDataset.getQuery() == null || reportDataset.getQuery().getText() == null || reportDataset.getQuery().getText().length() == 0) { return new JRField[0]; } List<JRField> fields = new ArrayList<JRField>(); query = reportDataset.getQuery().getText(); addPathColumn(fields); if(query.contains("--dsName")) { String[] splitDsNames = query.split("--dsName"); String dsNames = splitDsNames[splitDsNames.length - 1]; String[] dsNameList = checkForCommandsAndTrim(dsNames).split(","); for(String ds : dsNameList) { JRDesignField field = new JRDesignField(); field.setName(ds.trim()); field.setDescription(ds.trim()); field.setValueClass(String.class); fields.add(field); } } if(query.contains("--string")) { String[] splitStrProps = query.split("--string"); String strProp = splitStrProps[splitStrProps.length - 1]; String[] strPropList = checkForCommandsAndTrim(strProp).split(","); for(String prop : strPropList) { JRDesignField field = new JRDesignField(); field.setName(prop.trim()); field.setDescription(prop.trim()); field.setValueClass(String.class); fields.add(field); } } return fields.toArray(new JRField[fields.size()]); }
ResourceQueryFieldsProvider implements FieldsProvider { public JRField[] getFields(IReportConnection irConn, JRDataset reportDataset, Map parameters) throws JRException, UnsupportedOperationException { String query = ""; if(reportDataset.getQuery() == null || reportDataset.getQuery().getText() == null || reportDataset.getQuery().getText().length() == 0) { return new JRField[0]; } List<JRField> fields = new ArrayList<JRField>(); query = reportDataset.getQuery().getText(); addPathColumn(fields); if(query.contains("--dsName")) { String[] splitDsNames = query.split("--dsName"); String dsNames = splitDsNames[splitDsNames.length - 1]; String[] dsNameList = checkForCommandsAndTrim(dsNames).split(","); for(String ds : dsNameList) { JRDesignField field = new JRDesignField(); field.setName(ds.trim()); field.setDescription(ds.trim()); field.setValueClass(String.class); fields.add(field); } } if(query.contains("--string")) { String[] splitStrProps = query.split("--string"); String strProp = splitStrProps[splitStrProps.length - 1]; String[] strPropList = checkForCommandsAndTrim(strProp).split(","); for(String prop : strPropList) { JRDesignField field = new JRDesignField(); field.setName(prop.trim()); field.setDescription(prop.trim()); field.setValueClass(String.class); fields.add(field); } } return fields.toArray(new JRField[fields.size()]); } }
ResourceQueryFieldsProvider implements FieldsProvider { public JRField[] getFields(IReportConnection irConn, JRDataset reportDataset, Map parameters) throws JRException, UnsupportedOperationException { String query = ""; if(reportDataset.getQuery() == null || reportDataset.getQuery().getText() == null || reportDataset.getQuery().getText().length() == 0) { return new JRField[0]; } List<JRField> fields = new ArrayList<JRField>(); query = reportDataset.getQuery().getText(); addPathColumn(fields); if(query.contains("--dsName")) { String[] splitDsNames = query.split("--dsName"); String dsNames = splitDsNames[splitDsNames.length - 1]; String[] dsNameList = checkForCommandsAndTrim(dsNames).split(","); for(String ds : dsNameList) { JRDesignField field = new JRDesignField(); field.setName(ds.trim()); field.setDescription(ds.trim()); field.setValueClass(String.class); fields.add(field); } } if(query.contains("--string")) { String[] splitStrProps = query.split("--string"); String strProp = splitStrProps[splitStrProps.length - 1]; String[] strPropList = checkForCommandsAndTrim(strProp).split(","); for(String prop : strPropList) { JRDesignField field = new JRDesignField(); field.setName(prop.trim()); field.setDescription(prop.trim()); field.setValueClass(String.class); fields.add(field); } } return fields.toArray(new JRField[fields.size()]); }  }
ResourceQueryFieldsProvider implements FieldsProvider { public JRField[] getFields(IReportConnection irConn, JRDataset reportDataset, Map parameters) throws JRException, UnsupportedOperationException { String query = ""; if(reportDataset.getQuery() == null || reportDataset.getQuery().getText() == null || reportDataset.getQuery().getText().length() == 0) { return new JRField[0]; } List<JRField> fields = new ArrayList<JRField>(); query = reportDataset.getQuery().getText(); addPathColumn(fields); if(query.contains("--dsName")) { String[] splitDsNames = query.split("--dsName"); String dsNames = splitDsNames[splitDsNames.length - 1]; String[] dsNameList = checkForCommandsAndTrim(dsNames).split(","); for(String ds : dsNameList) { JRDesignField field = new JRDesignField(); field.setName(ds.trim()); field.setDescription(ds.trim()); field.setValueClass(String.class); fields.add(field); } } if(query.contains("--string")) { String[] splitStrProps = query.split("--string"); String strProp = splitStrProps[splitStrProps.length - 1]; String[] strPropList = checkForCommandsAndTrim(strProp).split(","); for(String prop : strPropList) { JRDesignField field = new JRDesignField(); field.setName(prop.trim()); field.setDescription(prop.trim()); field.setValueClass(String.class); fields.add(field); } } return fields.toArray(new JRField[fields.size()]); }  String designQuery(IReportConnection connection, String arg1, ReportQueryDialog arg2); FieldsProviderEditor getEditorComponent(ReportQueryDialog arg0); JRField[] getFields(IReportConnection irConn, JRDataset reportDataset, Map parameters); boolean hasEditorComponent(); boolean hasQueryDesigner(); boolean supportsAutomaticQueryExecution(); boolean supportsGetFieldsOperation(); }
ResourceQueryFieldsProvider implements FieldsProvider { public JRField[] getFields(IReportConnection irConn, JRDataset reportDataset, Map parameters) throws JRException, UnsupportedOperationException { String query = ""; if(reportDataset.getQuery() == null || reportDataset.getQuery().getText() == null || reportDataset.getQuery().getText().length() == 0) { return new JRField[0]; } List<JRField> fields = new ArrayList<JRField>(); query = reportDataset.getQuery().getText(); addPathColumn(fields); if(query.contains("--dsName")) { String[] splitDsNames = query.split("--dsName"); String dsNames = splitDsNames[splitDsNames.length - 1]; String[] dsNameList = checkForCommandsAndTrim(dsNames).split(","); for(String ds : dsNameList) { JRDesignField field = new JRDesignField(); field.setName(ds.trim()); field.setDescription(ds.trim()); field.setValueClass(String.class); fields.add(field); } } if(query.contains("--string")) { String[] splitStrProps = query.split("--string"); String strProp = splitStrProps[splitStrProps.length - 1]; String[] strPropList = checkForCommandsAndTrim(strProp).split(","); for(String prop : strPropList) { JRDesignField field = new JRDesignField(); field.setName(prop.trim()); field.setDescription(prop.trim()); field.setValueClass(String.class); fields.add(field); } } return fields.toArray(new JRField[fields.size()]); }  String designQuery(IReportConnection connection, String arg1, ReportQueryDialog arg2); FieldsProviderEditor getEditorComponent(ReportQueryDialog arg0); JRField[] getFields(IReportConnection irConn, JRDataset reportDataset, Map parameters); boolean hasEditorComponent(); boolean hasQueryDesigner(); boolean supportsAutomaticQueryExecution(); boolean supportsGetFieldsOperation();  }