@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
  public Commit createTerminalByGlobalId(String author, GlobalId removedId) {
    Validate.argumentsAreNotNull(author, removedId);

    Optional<CdoSnapshot> previousSnapshot = javersRepository.getLatest(removedId);
    if (previousSnapshot.isEmpty()) {
      throw new JaversException(
          JaversExceptionCode.CANT_DELETE_OBJECT_NOT_FOUND, removedId.value());
    }

    CommitMetadata commitMetadata = nextCommit(author);

    CdoSnapshot terminalSnapshot =
        snapshotFactory.createTerminal(removedId, previousSnapshot.get(), commitMetadata);

    Diff diff = diffFactory.singleTerminal(removedId, commitMetadata);

    return new Commit(commitMetadata, Lists.asList(terminalSnapshot), diff);
  }
  public CommitId getCommitHeadId() {
    Optional<BigDecimal> maxCommitId = selectMaxCommitId();

    return maxCommitId.isEmpty() ? null : CommitId.valueOf(maxCommitId.get());
  }