コード例 #1
0
  @Override
  public CdoSnapshot createObject(ResultSet resultSet) throws SQLException {
    JsonObject json = new JsonObject();

    json.add(COMMIT_METADATA, assembleCommitMetadata(resultSet));
    json.add(STATE_NAME, jsonConverter.fromJsonToJsonElement(resultSet.getString(SNAPSHOT_STATE)));
    json.add(CHANGED_NAME, assembleChangedPropNames(resultSet));
    json.addProperty(TYPE_NAME, resultSet.getString(SNAPSHOT_TYPE));

    if (providedGlobalId.isPresent()) {
      json.add(GLOBAL_CDO_ID, jsonConverter.toJsonElement(providedGlobalId.get()));
    } else {
      json.add(GLOBAL_CDO_ID, assembleGlobalId(resultSet));
    }

    return jsonConverter.fromJson(json, CdoSnapshot.class);
  }
コード例 #2
0
  private JsonElement assembleCommitMetadata(ResultSet resultSet) throws SQLException {
    JsonObject jsonObject = new JsonObject();
    jsonObject.addProperty("author", resultSet.getString(COMMIT_AUTHOR));
    jsonObject.add(
        "commitDate", jsonConverter.toJsonElement(resultSet.getTimestamp(COMMIT_COMMIT_DATE)));
    jsonObject.addProperty("id", resultSet.getBigDecimal(COMMIT_COMMIT_ID));

    return jsonObject;
  }
コード例 #3
0
  private JsonElement assembleChangedPropNames(ResultSet resultSet) throws SQLException {
    JsonObject jsonObject = new JsonObject();

    String propNamesJSON = resultSet.getString(SNAPSHOT_CHANGED);
    if (propNamesJSON == null || propNamesJSON.isEmpty()) {
      return jsonObject;
    }

    return jsonConverter.fromJsonToJsonElement(propNamesJSON);
  }
コード例 #4
0
  private JsonObject assembleOneGlobalId(String typeName, String localIdJson, String fragment)
      throws SQLException {
    JsonObject json = new JsonObject();
    if (localIdJson != null) {
      json.addProperty("entity", typeName);
      json.add("cdoId", jsonConverter.fromJsonToJsonElement(localIdJson));
    } else {
      json.addProperty("valueObject", typeName);
      json.addProperty("fragment", fragment);
    }

    return json;
  }