@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); }
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 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); }
public CommitId getCommitHeadId() { Optional<BigDecimal> maxCommitId = selectMaxCommitId(); return maxCommitId.isEmpty() ? null : CommitId.valueOf(maxCommitId.get()); }
/** never returns empty */ @Override public Optional<Object> getWrappedCdo() { return Optional.of(wrappedCdo); }