示例#1
0
 /**
  * Adjusts the field list so that only the selected fields are read.
  *
  * @param readFunction
  */
 private void setFieldList(JCoFunction readFunction) {
   int length = 0;
   JCoTable fields = readFunction.getTableParameterList().getTable("FIELDS"); // $NON-NLS-1$
   fields.clear();
   if (selectedFields.isEmpty()) {
     for (final ITableField field : structure.getFieldList()) {
       length += field.getLength();
       fields.appendRow();
       fields.setValue("FIELDNAME", field.getFieldName()); // $NON-NLS-1$
     }
   } else {
     for (final String field : selectedFields) {
       try {
         length += structure.getField(field).getLength();
         fields.appendRow();
         fields.setValue("FIELDNAME", field); // $NON-NLS-1$
       } catch (FieldNotFoundException e) {
         throw new IllegalArgumentException(
             MessageFormat.format(Messages.TableReader_UnknownField, field), e);
       }
     }
   }
   if (length > 512) {
     throw new IllegalArgumentException(Messages.TableReader_ResultTooLong);
   }
 }
 @Override
 public void run(
     VariantTableContent content,
     Resource resource,
     IProgressMonitor monitor,
     Map<String, VCObject> seenObjects,
     List<Option> options)
     throws Exception {
   VariantTable table = content.getTable();
   JCoFunction deletefunc = maintainEntries(content, monitor, options, true);
   executeTransaction(monitor, "DELETE " + table.getName(), deletefunc);
   JCoFunction createfunc = maintainEntries(content, monitor, options, false);
   JCoTable entries = createfunc.getTableParameterList().getTable("VAR_TAB_ENTRIES");
   EList<Row> rows = content.getRows();
   List<VariantTableArgument> arguments = table.getArguments();
   for (Row row : rows) {
     for (VariantTableArgument arg : arguments) {
       String cstic = arg.getCharacteristic().getName();
       int index = arguments.indexOf(arg);
       entries.appendRow();
       Literal literal = row.getValues().get(index);
       entries.setValue("VTCHARACT", cstic);
       entries.setValue("VTLINENO", "" + rows.indexOf(row));
       entries.setValue("VTVALUE", getValue(literal));
     }
   }
   executeTransaction(monitor, "CREATE/CHANGE " + table.getName(), createfunc);
 }
示例#3
0
 /**
  * Transfers the contents of a typed list to a {@link JCoTable}.
  *
  * @param source
  * @param destination
  */
 public static void toTable(List<TransportShortText> source, JCoTable destination) {
   destination.deleteAllRows();
   for (TransportShortText entry : source) {
     destination.appendRow();
     entry.toStructure(destination);
   }
 }
示例#4
0
  /**
   * Executes RFC_READ_TABLE with a set of selection criteria specified as strings.
   *
   * @param selectionCriteria
   * @return the contents read
   * @throws JCoException
   */
  public ITableContents read(String... selectionCriteria) throws JCoException {
    JCoFunction readFunction = template.getFunction();
    readFunction.getImportParameterList().setValue("QUERY_TABLE", tableName); // $NON-NLS-1$

    JCoTable options = readFunction.getTableParameterList().getTable("OPTIONS"); // $NON-NLS-1$
    options.clear();
    if (selectionCriteria != null) {
      for (final String criterion : selectionCriteria) {
        if (criterion.length() > 72) {
          throw new IllegalArgumentException(Messages.TableReader_SelectionCriteriaTooLong);
        }
        options.appendRow();
        options.setValue("TEXT", criterion); // $NON-NLS-1$
      }
    }

    setFieldList(readFunction);
    readFunction.execute(destination);
    return new TableContents(
        tableName,
        readFunction.getTableParameterList().getTable("FIELDS"), // $NON-NLS-1$
        readFunction.getTableParameterList().getTable("DATA")); // $NON-NLS-1$
  }