当前位置: 首页>>代码示例>>Java>>正文


Java IdName.setId方法代码示例

本文整理汇总了Java中ro.nextreports.engine.queryexec.IdName.setId方法的典型用法代码示例。如果您正苦于以下问题:Java IdName.setId方法的具体用法?Java IdName.setId怎么用?Java IdName.setId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ro.nextreports.engine.queryexec.IdName的用法示例。


在下文中一共展示了IdName.setId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getValues

import ro.nextreports.engine.queryexec.IdName; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static List<IdName> getValues(String select, Connection con) throws Exception {
    List values = new ArrayList();
    Dialect dialect;

    DatabaseMetaData dbmd = con.getMetaData();
    String dbName = dbmd.getDatabaseProductName();
    String dbVersion = dbmd.getDatabaseProductVersion();
    dialect = DialectFactory.determineDialect(dbName, dbVersion);

    ResultSet rs = null;
    Statement stmt = null;
    try {
        stmt = con.createStatement();
        rs = stmt.executeQuery(select);
        ResultSetMetaData rsmd = rs.getMetaData();
        String type = rsmd.getColumnTypeName(1);
        int precision = rsmd.getPrecision(1);
        int scale = rsmd.getScale(1);
        int typeCode = dialect.getJdbcType(type, precision, scale);
        while (rs.next()) {
            Serializable s;
            switch (typeCode) {
                case Types.INTEGER:
                    s = rs.getInt(1);
                    break;
                case Types.DOUBLE:
                    s = rs.getDouble(1);
                    break;
                case Types.DATE:
                    s = rs.getDate(1);
                    break;
                case Types.VARCHAR:
                    s = rs.getString(1);
                    break;
                default:
                    s = rs.getString(1);
                    break;
            }
            IdName in = new IdName();
            in.setId(s);
            in.setName(rs.getString(2));
            values.add(in);                
        }
    } finally {
        ConnectionUtil.closeResultSet(rs);
        ConnectionUtil.closeStatement(stmt);
    }
    return values;
}
 
开发者ID:nextreports,项目名称:nextreports-server,代码行数:51,代码来源:ConnectionUtil.java

示例2: createRuntimeModel

import ro.nextreports.engine.queryexec.IdName; //导入方法依赖的package包/类
private static ReportRuntimeParameterModel createRuntimeModel(DataSource dataSource, Map<String, Object> parameterValues,
                                                              QueryParameter parameter, DataSourceService dataSourceService, Map<String, Boolean> dynamicMap) {

    String parameterName = parameter.getName();
    ArrayList<IdName> values = new ArrayList<IdName>();
    boolean isMultipleSelection = parameter.getSelection().equalsIgnoreCase(QueryParameter.MULTIPLE_SELECTION);

    NextRuntimeParameterModel runtimeModel = new NextRuntimeParameterModel(parameterName, getParameterName(parameter), isMultipleSelection);

    if ((parameter.getSource() != null) && (parameter.getSource().trim().length() > 0)
            && !parameter.isDependent()) {
        try {
            values.addAll(dataSourceService.getParameterValues(dataSource, parameter));                    
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    runtimeModel.setParameterValues(values);

    Object parameterValue = parameterValues.get(parameterName);            
    if (QueryParameter.MULTIPLE_SELECTION.equals(parameter.getSelection())) {            	
        if (parameterValue == null) {
            runtimeModel.setValueList(new ArrayList<Object>());
        } else {
            ArrayList<Object> list = new ArrayList<Object>();
            Object[] array = (Object[]) parameterValue;
            for (Object obj : array) {
            	// take care for static default values (when parameter has a source of values)
            	// this should be IdName instead of their class inside Pallette
            	if ((parameter.getSource() != null) && !(obj instanceof IdName)) {
            		IdName in  = new IdName();
                    in.setId((Serializable)obj);
                    in.setName((Serializable)obj);
                    obj = in;
            	}
            	list.add(obj);
            }                    
            runtimeModel.setValueList(list);                                        
        }
    } else {
        runtimeModel.setRawValue(parameterValue);
    }

    runtimeModel.setMandatory(parameter.isMandatory());
    
    Boolean dynamic = dynamicMap.get(parameterName);
    if (dynamic == null) {
    	dynamic = Boolean.FALSE;
    }            
    runtimeModel.setDynamic(dynamic);            

    return runtimeModel;
}
 
开发者ID:nextreports,项目名称:nextreports-server,代码行数:55,代码来源:ChartUtil.java


注:本文中的ro.nextreports.engine.queryexec.IdName.setId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。