本文整理汇总了Java中ro.nextreports.engine.queryexec.Query类的典型用法代码示例。如果您正苦于以下问题:Java Query类的具体用法?Java Query怎么用?Java Query使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Query类属于ro.nextreports.engine.queryexec包,在下文中一共展示了Query类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parametersAreDefined
import ro.nextreports.engine.queryexec.Query; //导入依赖的package包/类
/**
* Test if all parameters used in sql are defined
* @param sql sql
* @throws ro.nextreports.engine.util.ParameterNotFoundException if a parameter used in the sql is not defined
*/
public void parametersAreDefined(String sql) throws ParameterNotFoundException {
String[] paramNames;
Query query = new Query(sql);
paramNames = query.getParameterNames();
List<QueryParameter> parameters = getParameters();
for (String paramName : paramNames) {
QueryParameter param = null;
for (QueryParameter p : parameters) {
if (paramName.equals(p.getName())) {
param = p;
}
}
if (param == null) {
throw new ParameterNotFoundException(paramName);
}
}
}
示例2: onDisplay
import ro.nextreports.engine.queryexec.Query; //导入依赖的package包/类
/**
* Called when the panel is set.
*/
@SuppressWarnings("unchecked")
public void onDisplay() {
String sql = ((Query) context.getAttribute(WizardConstants.QUERY)).getText();
try {
allColumns = ReportLayoutUtil.getAllColumnNamesForSql(null, sql);
} catch (Exception e) {
e.printStackTrace();
}
for (String s : allColumns) {
combo.addItem(s);
}
List<String> all = (List<String>)context.getAttribute(WizardConstants.REPORT_COLUMNS);
if (all != null) {
combo.setSelectedItem( all.get(0) );
}
}
示例3: checkSqlHasParametersDefined
import ro.nextreports.engine.queryexec.Query; //导入依赖的package包/类
public void checkSqlHasParametersDefined(String sql, Map<String,QueryParameter> params)
throws Exception {
// create the query object
Query query = new Query(sql);
// get parameter names
String[] paramNames = query.getParameterNames();
// execute query if no parameters
if (paramNames.length == 0) {
return;
}
for (String name : paramNames) {
QueryParameter param = params.get(name);
if (param == null) {
throw new Exception(I18NSupport.getString("run.parameter.not.defined", name));
}
}
}
示例4: createExporter
import ro.nextreports.engine.queryexec.Query; //导入依赖的package包/类
private void createExporter(Query query, Map<String, QueryParameter> parameters,
Map<String, Object> parameterValues, QueryResult qr, OutputStream stream) {
if (TABLE_FORMAT.equals(format)) {
exporter = new ChartTableExporter(qr, chart, language);
((ChartTableExporter)exporter).setShowStrings(true);
} else if (IMAGE_FORMAT.equals(format)) {
if (imagePath == null) {
imagePath = ".";
}
exporter = new JFreeChartExporter(parameterValues, qr, chart, imagePath, imageName, imageWidth, imageHeight, language);
} else {
if (graphicType == HTML5_TYPE) {
exporter = new JsonHTML5Exporter(parameterValues, qr, stream, chart, drillFunction, language);
} else {
// FLASH_TYPE
exporter = new JsonExporter(parameterValues, qr, stream, chart, drillFunction, language);
}
}
}
示例5: parametersAreDefined
import ro.nextreports.engine.queryexec.Query; //导入依赖的package包/类
/**
* Test if all parameters used in the report are defined
*
* @param report report object
* @throws ParameterNotFoundException if a parameter used in the report is not defined
*/
public void parametersAreDefined(Report report) throws ParameterNotFoundException {
String[] paramNames;
String sql = report.getSql();
if (sql == null) {
sql = report.getQuery().toString();
}
Query query = new Query(sql);
paramNames = query.getParameterNames();
List<QueryParameter> parameters = report.getParameters();
for (String paramName : paramNames) {
QueryParameter param = null;
for (QueryParameter p : parameters) {
if (paramName.equals(p.getName())) {
param = p;
}
}
if (param == null) {
throw new ParameterNotFoundException(paramName);
}
}
}
示例6: getUsedParametersMap
import ro.nextreports.engine.queryexec.Query; //导入依赖的package包/类
/**
* Get used parameters map where the key is the parameter name and the value is the parameter
* Not all the report parameters have to be used, some may only be defined for further usage.
* The result will contain also the hidden parameters and all parameters used just inside other parameters.
*
* @param query query object
* @param allParameters parameters map
* @return used parameters map
*/
public static Map<String, QueryParameter> getUsedParametersMap(Query query, Map<String, QueryParameter> allParameters) {
Set<String> paramNames = new HashSet<String>(Arrays.asList(query.getParameterNames()));
for (QueryParameter p : allParameters.values()) {
paramNames.addAll(p.getDependentParameterNames());
}
LinkedHashMap<String, QueryParameter> params = new LinkedHashMap<String, QueryParameter>();
for (String name : allParameters.keySet()) {
boolean found = false;
for (String pName : paramNames) {
if (pName.equals(name)) {
found = true;
break;
}
}
QueryParameter qp = allParameters.get(name);
if (found || qp.isHidden()) {
params.put(name, qp);
}
}
return params;
}
示例7: getOrderedParametersMap
import ro.nextreports.engine.queryexec.Query; //导入依赖的package包/类
/**
* Get ordered parameters map (dependent parameters are after their dependents) where the key is the parameter name and
* the value is the parameter
* The result will contain also the hidden parameters and all parameters used just inside other parameters.
*
* @param query query object
* @param allParameters parameters map
* @return ordered parameters map
*/
public static Map<String, QueryParameter> getOrderedParametersMap(Query query, Map<String, QueryParameter> allParameters) {
Set<String> paramNames = new LinkedHashSet<String>(Arrays.asList(query.getParameterNames()));
for (QueryParameter p : allParameters.values()) {
if (p.getDependentParameterNames().size() > 0) {
paramNames.remove(p.getName());
}
paramNames.addAll(p.getDependentParameterNames());
if (p.getDependentParameterNames().size() > 0) {
paramNames.add(p.getName());
}
}
LinkedHashMap<String, QueryParameter> params = new LinkedHashMap<String, QueryParameter>();
for (String name :paramNames) {
QueryParameter qp = allParameters.get(name);
params.put(name, qp);
}
return params;
}
示例8: allParametersHidden
import ro.nextreports.engine.queryexec.Query; //导入依赖的package包/类
public static boolean allParametersHidden(Chart chart) {
Map<String, QueryParameter> params = ParameterManager.getInstance()
.getUsedParametersMap(new Query(ReportUtil.getSql(chart.getReport())));
// new
// Query(Globals.getMainFrame().getQueryBuilderPanel().getUserSql()));
if (ParameterUtil.allParametersAreHidden(params)) {
return true;
} else {
Show.info(I18NSupport.getString("parameter.hidden.restriction"));
return false;
}
}
示例9: allParametersHaveDefaults
import ro.nextreports.engine.queryexec.Query; //导入依赖的package包/类
public static boolean allParametersHaveDefaults(Chart chart) {
Map<String, QueryParameter> params = ParameterManager.getInstance()
.getUsedParametersMap(new Query(ReportUtil.getSql(chart.getReport())));
// new
// Query(Globals.getMainFrame().getQueryBuilderPanel().getUserSql()));
if (ParameterUtil.allParametersHaveDefaults(params)) {
return true;
} else {
Show.info(I18NSupport.getString("parameter.default.restriction"));
return false;
}
}
示例10: onDisplay
import ro.nextreports.engine.queryexec.Query; //导入依赖的package包/类
/**
* Called when the panel is set.
*/
public void onDisplay() {
String sql = ((Query) context.getAttribute(WizardConstants.QUERY)).getText();
try {
allColumns = ReportLayoutUtil.getAllColumnNamesForSql(null, sql);
} catch (Exception e) {
e.printStackTrace();
}
List<String> source = getSourceColumns();
allColumns.removeAll(source);
panel.setLists(source, allColumns);
}
示例11: onDisplay
import ro.nextreports.engine.queryexec.Query; //导入依赖的package包/类
/**
* Called when the panel is set.
*/
public void onDisplay() {
String sql = ((Query) context.getAttribute(WizardConstants.QUERY)).getText();
try {
allColumns = ReportLayoutUtil.getAllColumnsForSql(null, sql, (DataSource)context.getAttribute(WizardConstants.DATA_SOURCE));
} catch (Exception e) {
e.printStackTrace();
}
xComboBox.setPreferredSize(dim);
yComboBox.setPreferredSize(dim);
xComboBox.removeAllItems();
yComboBox.removeAllItems();
xComboBox.addItem(I18NSupport.getString("chart.column.select"));
yComboBox.addItem(I18NSupport.getString("chart.column.select"));
for (int i=0; i<no; i++) {
more[i].setPreferredSize(dim);
more[i].removeAllItems();
more[i].addItem(I18NSupport.getString("chart.column.select"));
}
for (NameType column : allColumns){
xComboBox.addItem(column.getName());
yComboBox.addItem(column.getName());
for (int i=0; i<no; i++) {
more[i].addItem(column.getName());
}
}
}
示例12: executeQuery
import ro.nextreports.engine.queryexec.Query; //导入依赖的package包/类
/**
* Execute query This method is useful in case you are not interested about
* report layout, but only query and you want to make your own business.
*
* @return QueryResult object
*
* @throws ReportRunnerException
* if Runner object is not correctly configured
* @throws InterruptedException
* if process was interrupted
*/
public QueryResult executeQuery() throws ReportRunnerException, InterruptedException {
if (connection == null) {
throw new ReportRunnerException("Connection is null!");
}
if (report == null) {
throw new ReportRunnerException("Report is null!");
}
String sql = getSql();
// retrieves the report parameters
Map<String, QueryParameter> parameters = getReportParameters();
if (QueryUtil.restrictQueryExecution(sql)) {
throw new ReportRunnerException("You are not allowed to execute queries that modify the database!");
}
if (QueryUtil.isProcedureCall(sql)) {
if (!QueryUtil.isValidProcedureCall(sql, dialect)) {
throw new ReportRunnerException("Invalid procedure call! Must be of form 'call (${P1}, ?)'");
}
}
QueryResult queryResult = null;
try {
Query query = getQuery(sql);
QueryExecutor executor = new QueryExecutor(query, parameters, parameterValues, connection, count, true,
csv);
executor.setMaxRows(0);
executor.setTimeout(queryTimeout);
queryResult = executor.execute();
return queryResult;
} catch (Exception e) {
throw new ReportRunnerException(e);
}
}
示例13: SimpleQueryExecutor
import ro.nextreports.engine.queryexec.Query; //导入依赖的package包/类
public SimpleQueryExecutor(Query query, Connection conn) {
this.query = query;
this.conn = conn;
inputWrapper = new InputWrapper();
resultWrapper = new ResultWrapper();
worker = new Thread(this);
worker.start();
}
示例14: getBatchMailMap
import ro.nextreports.engine.queryexec.Query; //导入依赖的package包/类
public static Map<Serializable, String> getBatchMailMap(String batchDataQuery, StorageService storageservice, DataSource dataSource) throws Exception {
Map<Serializable, String> result = new HashMap<Serializable, String>();
if (batchDataQuery == null) {
return result;
}
Connection connection = null;
QueryResult queryResult = null;
try {
connection = ConnectionUtil.createConnection(storageservice, dataSource);
Query query = new Query(batchDataQuery);
QueryExecutor executor = new QueryExecutor(query, connection);
executor.setMaxRows(0);
executor.setTimeout(storageservice.getSettings().getQueryTimeout());
queryResult = executor.execute();
ResultSet rs = queryResult.getResultSet();
while(rs.next()) {
Serializable batchValue = (Serializable)rs.getObject(1);
String mail = rs.getString(2);
result.put(batchValue, mail);
}
} finally {
ConnectionUtil.closeConnection(connection);
}
return result;
}
示例15: getUsedParametersMap
import ro.nextreports.engine.queryexec.Query; //导入依赖的package包/类
public Map<String, QueryParameter> getUsedParametersMap(Query query) {
return ParameterUtil.getUsedParametersMap(query, parameters);
}