private void parseJDBCStoreTable(XMLExtendedStreamReader reader, ModelNode table)
      throws XMLStreamException {
    for (int i = 0; i < reader.getAttributeCount(); i++) {
      String value = reader.getAttributeValue(i);
      Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case PREFIX:
          {
            CommonAttributes.PREFIX.parseAndSetParameter(value, table, reader);
            break;
          }
        case FETCH_SIZE:
          {
            CommonAttributes.FETCH_SIZE.parseAndSetParameter(value, table, reader);
            break;
          }
        case BATCH_SIZE:
          {
            CommonAttributes.BATCH_SIZE.parseAndSetParameter(value, table, reader);
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedAttribute(reader, i);
          }
      }
    }

    while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
      Element element = Element.forName(reader.getLocalName());
      switch (element) {
        case ID_COLUMN:
          {
            this.parseJDBCStoreColumn(reader, table.get(ModelKeys.ID_COLUMN).setEmptyObject());
            break;
          }
        case DATA_COLUMN:
          {
            this.parseJDBCStoreColumn(reader, table.get(ModelKeys.DATA_COLUMN).setEmptyObject());
            break;
          }
        case TIMESTAMP_COLUMN:
          {
            this.parseJDBCStoreColumn(
                reader, table.get(ModelKeys.TIMESTAMP_COLUMN).setEmptyObject());
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedElement(reader);
          }
      }
    }
  }
Example #2
0
  private void setTableProperties(
      Properties properties,
      OperationContext context,
      ModelNode table,
      String propertySuffix,
      String tableNamePrefixProperty,
      String defaultTableNamePrefix)
      throws OperationFailedException {

    final int batchSize = CommonAttributes.BATCH_SIZE.resolveModelAttribute(context, table).asInt();
    final int fetchSize = CommonAttributes.FETCH_SIZE.resolveModelAttribute(context, table).asInt();
    ModelNode resolvedValue = null;
    final String prefixString =
        ((resolvedValue = CommonAttributes.PREFIX.resolveModelAttribute(context, table))
                .isDefined())
            ? resolvedValue.asString()
            : defaultTableNamePrefix;

    properties.setProperty("batchSize", Integer.toString(batchSize));
    properties.setProperty("fetchSize", Integer.toString(fetchSize));
    properties.setProperty(tableNamePrefixProperty, prefixString);
    properties.setProperty(
        "idColumnName" + propertySuffix,
        this.getColumnProperty(table, ModelKeys.ID_COLUMN, ModelKeys.NAME, "id"));
    properties.setProperty(
        "idColumnType" + propertySuffix,
        this.getColumnProperty(table, ModelKeys.ID_COLUMN, ModelKeys.TYPE, "VARCHAR"));
    properties.setProperty(
        "dataColumnName" + propertySuffix,
        this.getColumnProperty(table, ModelKeys.DATA_COLUMN, ModelKeys.NAME, "datum"));
    properties.setProperty(
        "dataColumnType" + propertySuffix,
        this.getColumnProperty(table, ModelKeys.DATA_COLUMN, ModelKeys.TYPE, "BINARY"));
    properties.setProperty(
        "timestampColumnName" + propertySuffix,
        this.getColumnProperty(table, ModelKeys.TIMESTAMP_COLUMN, ModelKeys.NAME, "version"));
    properties.setProperty(
        "timestampColumnType" + propertySuffix,
        this.getColumnProperty(table, ModelKeys.TIMESTAMP_COLUMN, ModelKeys.TYPE, "BIGINT"));
  }