Skip to main content
summaryrefslogtreecommitdiffstats
blob: 94aef5b461208918bb3506f14bd733baf6d5890f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*******************************************************************************
 * Copyright (c) 2012 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.orcs.core.internal.transaction;

import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.util.Conditions;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.core.ds.BranchDataStore;
import org.eclipse.osee.orcs.core.internal.SessionContext;
import org.eclipse.osee.orcs.core.internal.proxy.ArtifactProxyFactory;
import org.eclipse.osee.orcs.core.internal.transaction.TxDataManagerImpl.TxDataHandlerFactory;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.transaction.OrcsTransaction;
import org.eclipse.osee.orcs.transaction.TransactionFactory;

/**
 * @author Roberto E. Escobar
 */
public class TransactionFactoryImpl implements TransactionFactory {

   private final Log logger;
   private final SessionContext sessionContext;
   private final BranchDataStore branchDataStore;
   private final ArtifactProxyFactory artifactFactory;
   private final TxDataHandlerFactory handlerF;

   public TransactionFactoryImpl(Log logger, SessionContext sessionContext, BranchDataStore branchDataStore, ArtifactProxyFactory artifactFactory, TxDataHandlerFactory handlerF) {
      this.logger = logger;
      this.sessionContext = sessionContext;
      this.branchDataStore = branchDataStore;
      this.artifactFactory = artifactFactory;
      this.handlerF = handlerF;
   }

   @Override
   public OrcsTransaction createTransaction(IOseeBranch branch, ArtifactReadable author, String comment) throws OseeCoreException {
      Conditions.checkNotNull(branch, "branch");
      Conditions.checkNotNull(author, "author");
      Conditions.checkNotNullOrEmpty(comment, "comment");

      TxDataManager manager = new TxDataManagerImpl(artifactFactory, handlerF);
      OrcsTransactionImpl orcsTxn =
         new OrcsTransactionImpl(logger, sessionContext, branchDataStore, artifactFactory, manager, branch);
      orcsTxn.setComment(comment);
      orcsTxn.setAuthor(author);
      return orcsTxn;
   }
}

Back to the top