コード例 #1
0
ファイル: CommitFactory.java プロジェクト: fjalier/javers
  public Commit createTerminal(String author, Object removed) {
    Validate.argumentsAreNotNull(author, removed);

    Cdo removedCdo = liveGraphFactory.createCdo(removed);

    return createTerminalByGlobalId(author, removedCdo.getGlobalId());
  }
コード例 #2
0
ファイル: CdoWrapper.java プロジェクト: ZupIT/javers
  public CdoWrapper(Object wrappedCdo, GlobalId globalId, ManagedType managedType) {
    super(globalId, managedType);
    argumentsAreNotNull(wrappedCdo, managedType);
    argumentCheck(
        managedType.isInstance(wrappedCdo), "wrappedCdo is not an instance of given managedClass");

    this.wrappedCdo = wrappedCdo;
  }
コード例 #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
ファイル: 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);
  }
コード例 #5
0
ファイル: Commit.java プロジェクト: ZupIT/javers
 Commit(CommitMetadata commitMetadata, List<CdoSnapshot> snapshots, Diff diff) {
   Validate.argumentsAreNotNull(commitMetadata, snapshots, diff);
   this.commitMetadata = commitMetadata;
   this.snapshots = snapshots;
   this.diff = diff;
 }
コード例 #6
0
ファイル: ManagedClassFactory.java プロジェクト: shoon/javers
 ManagedClassFactory(
     PropertyScanner propertyScanner, ClassAnnotationsScanner classAnnotationsScanner) {
   Validate.argumentsAreNotNull(propertyScanner);
   this.propertyScanner = propertyScanner;
   this.classAnnotationsScanner = classAnnotationsScanner;
 }