コード例 #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
ファイル: CommitFactory.java プロジェクト: fjalier/javers
  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);
  }
コード例 #3
0
ファイル: CommitFactory.java プロジェクト: fjalier/javers
  public Commit create(String author, Object currentVersion) {
    Validate.argumentsAreNotNull(author, currentVersion);

    CommitMetadata commitMetadata = nextCommit(author);

    LiveGraph currentGraph = liveGraphFactory.createLiveGraph(currentVersion);
    ShadowGraph latestShadowGraph = graphSnapshotFacade.createLatestShadow(currentGraph);

    // capture current state
    List<CdoSnapshot> snapshots =
        graphSnapshotFacade.createGraphSnapshot(currentGraph, latestShadowGraph, commitMetadata);

    // do diff
    Diff diff = diffFactory.create(latestShadowGraph, currentGraph, Optional.of(commitMetadata));

    return new Commit(commitMetadata, snapshots, diff);
  }
コード例 #4
0
  public CommitId getCommitHeadId() {
    Optional<BigDecimal> maxCommitId = selectMaxCommitId();

    return maxCommitId.isEmpty() ? null : CommitId.valueOf(maxCommitId.get());
  }
コード例 #5
0
ファイル: CdoWrapper.java プロジェクト: ZupIT/javers
 /** never returns empty */
 @Override
 public Optional<Object> getWrappedCdo() {
   return Optional.of(wrappedCdo);
 }