示例#1
0
 private void manageFilterOnDomainValues(
     StringBuffer buffer,
     String fieldName,
     IDataSetTableDescriptor tableDescriptor,
     IDataStoreFilter filter) {
   if (filter != null) {
     String filterColumnName = tableDescriptor.getColumnName(fieldName);
     if (filterColumnName == null) {
       throw new SpagoBIRuntimeException("Field name [" + fieldName + "] not found");
     }
     String columnName = tableDescriptor.getColumnName(fieldName);
     Class clazz = tableDescriptor.getColumnType(fieldName);
     String value = getFilterValue(filter.getValue(), clazz);
     IConditionalOperator conditionalOperator =
         (IConditionalOperator) SQLStatementConditionalOperators.getOperator(filter.getOperator());
     String temp = conditionalOperator.apply(columnName, new String[] {value});
     buffer.append(" WHERE " + temp);
   }
 }
示例#2
0
 public IDataStore getDomainValues(
     String fieldName, Integer start, Integer limit, IDataStoreFilter filter) {
   IDataStore toReturn = null;
   try {
     String tableName = this.getTemporaryTableName();
     logger.debug("Temporary table name : [" + tableName + "]");
     if (tableName == null) {
       logger.error("Temporary table name not set, cannot proceed!!");
       throw new SpagoBIEngineRuntimeException("Temporary table name not set");
     }
     IDataSource dataSource = this.getDataSourceForPersistence();
     if (dataSource == null) {
       logger.error("Datasource for persistence not set, cannot proceed!!");
       throw new SpagoBIEngineRuntimeException("Datasource for persistence not set");
     }
     String signature = this.getSignature();
     IDataSetTableDescriptor tableDescriptor = null;
     if (signature.equals(TemporaryTableManager.getLastDataSetSignature(tableName))) {
       // signature matches: no need to create a TemporaryTable
       tableDescriptor = TemporaryTableManager.getLastDataSetTableDescriptor(tableName);
     } else {
       tableDescriptor = this.persist(tableName, dataSource);
       TemporaryTableManager.setLastDataSetTableDescriptor(tableName, tableDescriptor);
       TemporaryTableManager.setLastDataSetSignature(tableName, signature);
     }
     String filterColumnName = tableDescriptor.getColumnName(fieldName);
     StringBuffer buffer =
         new StringBuffer("Select DISTINCT " + filterColumnName + " FROM " + tableName);
     manageFilterOnDomainValues(buffer, fieldName, tableDescriptor, filter);
     String sqlStatement = buffer.toString();
     toReturn = TemporaryTableManager.queryTemporaryTable(sqlStatement, dataSource, start, limit);
     toReturn.getMetaData().changeFieldAlias(0, fieldName);
   } catch (Exception e) {
     logger.error("Error loading the domain values for the field " + fieldName, e);
     throw new SpagoBIEngineRuntimeException(
         "Error loading the domain values for the field " + fieldName, e);
   }
   return toReturn;
 }