本文整理汇总了Java中net.sf.jasperreports.data.DataAdapterService类的典型用法代码示例。如果您正苦于以下问题:Java DataAdapterService类的具体用法?Java DataAdapterService怎么用?Java DataAdapterService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataAdapterService类属于net.sf.jasperreports.data包,在下文中一共展示了DataAdapterService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFields
import net.sf.jasperreports.data.DataAdapterService; //导入依赖的package包/类
@Override
public List<JRDesignField> getFields(DataAdapterService con, JasperReportsConfiguration jConfig, JRDataset jDataset) throws JRException, UnsupportedOperationException {
Throwable t = null;
ArrayList<JRDesignField> fields = new ArrayList<JRDesignField>();
try {
String fileName = getDataAdapter().getFileName();
Document doc = JRXmlUtils.parse(new URL(fileName), XMLUtils.isNamespaceAware(getDataAdapter(), jConfig.getJasperDesign()));
fields.addAll(getFieldsFromDocument(doc, jConfig, jDataset));
} catch (IOException e) {
t = e;
}
if (t != null) {
UIUtils.showError(t);
}
return fields;
}
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:18,代码来源:RemoteXMLDataAdapterDescriptor.java
示例2: getFields
import net.sf.jasperreports.data.DataAdapterService; //导入依赖的package包/类
@Override
public List<JRDesignField> getFields(DataAdapterService con, JasperReportsConfiguration jConfig, JRDataset jDataset) throws JRException, UnsupportedOperationException {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("REPORT_PARAMETERS_MAP", new HashMap<String, Object>());
try {
//Here there is the password of the connection
con.contributeParameters(parameters);
} catch (JRException e) {
e.printStackTrace();
}
ParameterUtil.setParameters(jConfig, jDataset, parameters);
parameters.put(JRParameter.REPORT_MAX_COUNT, 2);
Map<String,? extends JRValueParameter> tmpMap = ParameterUtil.convertMap(parameters, jDataset);
JRXmlaQueryExecuter qe = new JRXmlaQueryExecuter(jConfig, jDataset, tmpMap);
JROlapResult result = qe.getResult();
return OlapFieldsProviderSupport.getFieldsFromResult(result);
}
示例3: getFields
import net.sf.jasperreports.data.DataAdapterService; //导入依赖的package包/类
@Override
public List<JRDesignField> getFields(DataAdapterService con, JasperReportsConfiguration jConfig, JRDataset jDataset) throws JRException, UnsupportedOperationException {
Map<String, Object> parameters = new HashMap<String, Object>();
con.contributeParameters(parameters);
ParameterUtil.setParameters(jConfig, jDataset, parameters);
parameters.put(JRParameter.REPORT_MAX_COUNT, 0);
// JasperReports query executer instances require
// REPORT_PARAMETERS_MAP parameter to be defined and not null
Map<String, JRValueParameter> tmpMap = ParameterUtil.convertMap(parameters, jDataset);
tmpMap.put(JRParameter.REPORT_PARAMETERS_MAP, new SimpleValueParameter(new HashMap<String, JRValueParameter>()));
JRMondrianQueryExecuter qe = new JRMondrianQueryExecuter(jConfig, jDataset, tmpMap);
qe.createDatasource();
JRMondrianResult result = new JRMondrianResult(qe.getResult());
return OlapFieldsProviderSupport.getFieldsFromResult(result);
}
示例4: dataAdapterQualification
import net.sf.jasperreports.data.DataAdapterService; //导入依赖的package包/类
protected String dataAdapterQualification(JRDataset dataset, DataAdapter dataAdapter)
{
ParameterContributorContext contributorContext = new ParameterContributorContext(context,
dataset, Collections.<String, Object>emptyMap());
DataAdapterServiceUtil serviceUtil = DataAdapterServiceUtil.getInstance(contributorContext);
DataAdapterService service = serviceUtil.getService(dataAdapter);
return service instanceof Designated ? ((Designated) service).getDesignation() : null;
}
示例5: getConnection
import net.sf.jasperreports.data.DataAdapterService; //导入依赖的package包/类
public Connection getConnection(final DataAdapterService das, boolean readCurrentSchema) {
schema = null;
SchemaUtil.close(connection);
Map<String, Object> parameters = new HashMap<String, Object>();
try {
if (das != null)
das.contributeParameters(parameters);
} catch (JRException e1) {
updateUI(root);
designer.showError(e1);
}
connection = (Connection) parameters.get(JRParameter.REPORT_CONNECTION);
if (connection == null)
return connection;
// TODO implement some compatibility, getSchema() available since 1.7
if (readCurrentSchema)
schema = SchemaUtil.getSchemaPath(connection);
try {
identifierQuote = connection.getMetaData().getIdentifierQuoteString();
designer.doRefreshRoots(false);
System.out.println("JDBC Quotes: " + connection.getMetaData().getIdentifierQuoteString());
System.out.println("getExtraNameCharacters: " + connection.getMetaData().getExtraNameCharacters());
System.out.println("storesLowerCaseIdentifiers: " + connection.getMetaData().storesLowerCaseIdentifiers());
System.out.println("storesLowerCaseQuotedIdentifiers: " + connection.getMetaData().storesLowerCaseQuotedIdentifiers());
System.out.println("storesMixedCaseIdentifiers: " + connection.getMetaData().storesMixedCaseIdentifiers());
System.out.println("storesMixedCaseQuotedIdentifiers: " + connection.getMetaData().storesMixedCaseQuotedIdentifiers());
System.out.println("storesUpperCaseIdentifiers: " + connection.getMetaData().storesUpperCaseIdentifiers());
System.out.println("storesUpperCaseQuotedIdentifiers: " + connection.getMetaData().storesUpperCaseQuotedIdentifiers());
System.out.println("supportsMixedCaseIdentifiers: " + connection.getMetaData().supportsMixedCaseIdentifiers());
System.out.println("supportsMixedCaseQuotedIdentifiers: " + connection.getMetaData().supportsMixedCaseQuotedIdentifiers());
} catch (SQLException e) {
e.printStackTrace();
}
return connection;
}
示例6: getFields
import net.sf.jasperreports.data.DataAdapterService; //导入依赖的package包/类
public List<JRDesignField> getFields(DataAdapterService con, JasperReportsConfiguration jConfig, JRDataset reportDataset) throws JRException, UnsupportedOperationException {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("REPORT_PARAMETERS_MAP", new HashMap<String, Object>());
con.contributeParameters(parameters);
ParameterUtil.setParameters(jConfig, reportDataset, parameters);
parameters.put(JRParameter.REPORT_MAX_COUNT, 2);
ExcelDataSource ds = null;
ExcelDataAdapter da = (ExcelDataAdapter) ((AbstractDataAdapterService) con).getDataAdapter();
if (da.isQueryExecuterMode()) {
ExcelQueryExecuter qe = (ExcelQueryExecuter) new ExcelQueryExecuterFactory().createQueryExecuter(jConfig, reportDataset, ParameterUtil.convertMap(parameters, reportDataset));
ds = (ExcelDataSource) qe.createDatasource();
} else {
ds = (ExcelDataSource) parameters.get(JRParameter.REPORT_DATA_SOURCE);
}
if (ds != null) {
ds.setUseFirstRowAsHeader(da.isUseFirstRowAsHeader());
ds.next();
Map<String, Integer> map = ds.getColumnNames();
List<JRDesignField> columns = new ArrayList<JRDesignField>(map.keySet().size());
for (String key : map.keySet()) {
JRDesignField field = new JRDesignField();
field.setName(StringUtils.xmlEncode(key, null));
field.setValueClass(String.class);
columns.add(field);
}
return columns;
}
return null;
}
示例7: getExcelColumns
import net.sf.jasperreports.data.DataAdapterService; //导入依赖的package包/类
/**
* This method will populate the data model with the Excel columns This also
* checks the button "Skip the first line " and enables the delete button
*
* @throws Exception
*/
private void getExcelColumns() throws Exception {
if (textFileName.getText().length() > 0) {
DataAdapterDescriptor da = getDataAdapter();
if (jConfig == null)
jConfig = JasperReportsConfiguration.getDefaultJRConfig();
DataAdapterService das = DataAdapterServiceUtil.getInstance(jConfig).getService(da.getDataAdapter());
((AbstractDataAdapterService) das).getDataAdapter();
jConfig.setJasperDesign(new JasperDesign());
// The get fields method call once a next on the data adapter to get the
// first line and from that is read the
// fields name. But is useFirstRowAsHeader flag is set to false than the
// next call will skip the first line
// that is the only one read to get the fields, so it will return an empty
// set of column names. For this
// reason this flag must be force to true if the data adapter is used to
// get the column names
XlsDataAdapter xlsAdapter = (XlsDataAdapter) da.getDataAdapter();
boolean useRowHeader = xlsAdapter.isUseFirstRowAsHeader();
xlsAdapter.setUseFirstRowAsHeader(true);
List<JRDesignField> fields = ((IFieldsProvider) da).getFields(das, jConfig, new JRDesignDataset(jConfig, false));
xlsAdapter.setUseFirstRowAsHeader(useRowHeader);
rows.clear();
int columnIndex = 0;
for (JRDesignField f : fields) {
rows.add(new String[] { f.getName(), String.valueOf(columnIndex++) });
}
tableViewer.setInput(rows);
tableViewer.refresh();
setTableSelection(-1);
btnDelete.setEnabled(true);
}
}
示例8: getExcelColumns
import net.sf.jasperreports.data.DataAdapterService; //导入依赖的package包/类
/**
* This method will populate the data model with the Excel columns This also
* checks the button "Skip the first line " and enables the delete button
*
* @throws Exception
*/
private void getExcelColumns() throws Exception {
if (textFileName.getText().length() > 0) {
DataAdapterDescriptor da = getDataAdapter();
if (jConfig == null)
jConfig = JasperReportsConfiguration.getDefaultJRConfig();
DataAdapterService das = DataAdapterServiceUtil.getInstance(jConfig).getService(da.getDataAdapter());
jConfig.setJasperDesign(new JasperDesign());
//The get fields method call once a next on the data adapter to get the first line and from that is read the
//fields name. But is useFirstRowAsHeader flag is set to false than the next call will skip the first line
//that is the only one read to get the fields, so it will return an empty set of column names. For this
//reason this flag must be force to true if the data adapter is used to get the column names
XlsxDataAdapter xlsAdapter = (XlsxDataAdapter)da.getDataAdapter();
boolean useRowHeader = xlsAdapter.isUseFirstRowAsHeader();
xlsAdapter.setUseFirstRowAsHeader(true);
List<JRDesignField> fields = ((IFieldsProvider) da).getFields(das, jConfig, new JRDesignDataset(jConfig, false));
xlsAdapter.setUseFirstRowAsHeader(useRowHeader);
rows.clear();
int columnIndex = 0;
for (JRDesignField f : fields) {
rows.add(new String[] { f.getName(), String.valueOf(columnIndex++) });
}
tableViewer.setInput(rows);
tableViewer.refresh();
setTableSelection(-1);
btnDelete.setEnabled(true);
}
}
示例9: getExcelColumns
import net.sf.jasperreports.data.DataAdapterService; //导入依赖的package包/类
/**
* This method will populate the data model with the Excel columns This also
* checks the button "Skip the first line " and enables the delete button
*
* @throws Exception
*/
private void getExcelColumns() throws Exception {
if (textFileName.getText().length() > 0) {
DataAdapterDescriptor da = getDataAdapter();
if (jConfig == null)
jConfig = JasperReportsConfiguration.getDefaultJRConfig();
DataAdapterService das = DataAdapterServiceUtil.getInstance(jConfig).getService(da.getDataAdapter());
((AbstractDataAdapterService) das).getDataAdapter();
jConfig.setJasperDesign(new JasperDesign());
//The get fields method call once a next on the data adapter to get the first line and from that is read the
//fields name. But is useFirstRowAsHeader flag is set to false than the next call will skip the first line
//that is the only one read to get the fields, so it will return an empty set of column names. For this
//reason this flag must be force to true if the data adapter is used to get the column names
XlsDataAdapter xlsAdapter = (XlsDataAdapter)da.getDataAdapter();
boolean useRowHeader = xlsAdapter.isUseFirstRowAsHeader();
xlsAdapter.setUseFirstRowAsHeader(true);
List<JRDesignField> fields = ((IFieldsProvider) da).getFields(das, jConfig, new JRDesignDataset(jConfig, false));
xlsAdapter.setUseFirstRowAsHeader(useRowHeader);
rows.clear();
int columnIndex = 0;
for (JRDesignField f : fields) {
rows.add(new String[] { f.getName(), String.valueOf(columnIndex++) });
}
tableViewer.setInput(rows);
tableViewer.refresh();
setTableSelection(-1);
btnDelete.setEnabled(true);
}
}
示例10: getFields
import net.sf.jasperreports.data.DataAdapterService; //导入依赖的package包/类
public List<JRDesignField> getFields(DataAdapterService con, JasperReportsConfiguration jConfig, JRDataset reportDataset) throws JRException, UnsupportedOperationException {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("REPORT_PARAMETERS_MAP", new HashMap<String, Object>());
con.contributeParameters(parameters);
ParameterUtil.setParameters(jConfig, reportDataset, parameters);
parameters.put(JRParameter.REPORT_MAX_COUNT, 2);
JRXlsDataSource ds = null;
XlsDataAdapter da = (XlsDataAdapter) ((AbstractDataAdapterService) con).getDataAdapter();
if (da.isQueryExecuterMode()) {
JRXlsQueryExecuter qe = (JRXlsQueryExecuter) new JRXlsQueryExecuterFactory().createQueryExecuter(jConfig, reportDataset, ParameterUtil.convertMap(parameters, reportDataset));
ds = (JRXlsDataSource) qe.createDatasource();
} else {
ds = (JRXlsDataSource) parameters.get(JRParameter.REPORT_DATA_SOURCE);
}
if (ds != null) {
ds.setUseFirstRowAsHeader(da.isUseFirstRowAsHeader());
ds.next();
Map<String, Integer> map = ds.getColumnNames();
List<JRDesignField> columns = new ArrayList<JRDesignField>(map.keySet().size());
for (String key : map.keySet()) {
JRDesignField field = new JRDesignField();
field.setName(StringUtils.xmlEncode(key, null));
field.setValueClass(String.class);
columns.add(field);
}
return columns;
}
return null;
}
示例11: getFields
import net.sf.jasperreports.data.DataAdapterService; //导入依赖的package包/类
@Override
public List<JRDesignField> getFields(DataAdapterService con, JasperReportsConfiguration jConfig, JRDataset jDataset) throws JRException, UnsupportedOperationException {
setRecursiveRetrieval(jConfig);
ArrayList<JRDesignField> fields = new ArrayList<JRDesignField>();
String fileName = getDataAdapter().getFileName();
File in = new File(fileName);
Document doc = JRXmlUtils.parse(in, XMLUtils.isNamespaceAware(getDataAdapter(), jConfig.getJasperDesign()));
fields.addAll(getFieldsFromDocument(doc, jConfig, jDataset));
return fields;
}
示例12: getFields
import net.sf.jasperreports.data.DataAdapterService; //导入依赖的package包/类
public List<JRDesignField> getFields(DataAdapterService con, JasperReportsConfiguration jConfig, JRDataset reportDataset) throws JRException, UnsupportedOperationException {
jrdsp = ((DataSourceProviderDataAdapterService) con).getProvider();
if (jrdsp != null) {
JasperReport jr = null;
try {
IFile file = (IFile) jConfig.get(FileUtils.KEY_FILE);
if (file != null && file.exists()) {
JasperReportCompiler compiler = new JasperReportCompiler();
jr = compiler.compileReport(jConfig, file);
}
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
JRField[] aray = jrdsp.getFields(jr);
if (aray != null) {
List<JRDesignField> fields = new ArrayList<JRDesignField>();
for (JRField f : aray) {
if (f instanceof JRDesignField)
fields.add((JRDesignField) f);
else {
JRDesignField jdf = new JRDesignField();
jdf.setName(StringUtils.xmlEncode(f.getName(), null));
jdf.setValueClassName(f.getValueClassName());
jdf.setDescription(StringUtils.xmlEncode(f.getDescription(), null));
fields.add(jdf);
}
}
return fields;
}
}
return new ArrayList<JRDesignField>();
}
示例13: getFields
import net.sf.jasperreports.data.DataAdapterService; //导入依赖的package包/类
public List<JRDesignField> getFields(DataAdapterService con, JasperReportsConfiguration jConfig, JRDataset dataset) throws JRException, UnsupportedOperationException {
Map<String, Object> parameters = new HashMap<String, Object>();
con.contributeParameters(parameters);
ParameterUtil.setParameters(jConfig, dataset, parameters);
parameters.put(JRParameter.REPORT_MAX_COUNT, 0);
return com.jaspersoft.mongodb.MongoDbFieldsProvider.getInstance().getFields(jConfig, dataset, parameters, (MongoDbConnection) parameters.get(JRParameter.REPORT_CONNECTION));
}
示例14: getFields
import net.sf.jasperreports.data.DataAdapterService; //导入依赖的package包/类
public List<JRDesignField> getFields(DataAdapterService dataAdapterService, JasperReportsConfiguration jasperReportsConfiguration, JRDataset dataset) throws JRException,
UnsupportedOperationException {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put(JRParameter.REPORT_MAX_COUNT, 0);
dataAdapterService.contributeParameters(parameters);
ParameterUtil.setParameters(jasperReportsConfiguration, dataset, parameters);
return com.jaspersoft.connectors.cassandra.CassandraFieldsProvider.getFields(
jasperReportsConfiguration, (JSCassandraConnection) parameters.get(JRParameter.REPORT_CONNECTION), dataset, parameters);
}
示例15: doGetFields
import net.sf.jasperreports.data.DataAdapterService; //导入依赖的package包/类
@Override
protected void doGetFields(IProgressMonitor monitor) {
final DataAdapterDescriptor da = dscombo.getSelected();
if (da != null && da instanceof IFieldsProvider && ((IFieldsProvider) da).supportsGetFieldsOperation(jConfig)) {
qStatus.showInfo("");
monitor.beginTask(Messages.DataQueryAdapters_jobname, -1);
ClassLoader oldClassloader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(jConfig.getClassLoader());
DataAdapterService das = DataAdapterServiceUtil.getInstance(jConfig).getService(da.getDataAdapter());
try {
final List<JRDesignField> fields = ((IFieldsProvider) da).getFields(das, jConfig, newdataset);
if (fields != null) {
monitor.setTaskName("Setting Fields");
Display.getDefault().syncExec(new Runnable() {
public void run() {
setFields(fields);
}
});
monitor.setTaskName("Fields set");
}
} catch (Exception e) {
if (e.getCause() != null)
qStatus.showError(e.getCause().getMessage(), e);
else
qStatus.showError(e);
} finally {
Thread.currentThread().setContextClassLoader(oldClassloader);
das.dispose();
monitor.done();
}
}
}