diff options
Diffstat (limited to 'plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/branch/CommitBranchCallable.java')
-rw-r--r-- | plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/branch/CommitBranchCallable.java | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/branch/CommitBranchCallable.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/branch/CommitBranchCallable.java new file mode 100644 index 00000000000..92ee3747669 --- /dev/null +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/branch/CommitBranchCallable.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * 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.branch; + +import java.util.concurrent.Callable; +import org.eclipse.osee.framework.core.data.IOseeBranch; +import org.eclipse.osee.framework.core.model.Branch; +import org.eclipse.osee.framework.core.model.TransactionRecord; +import org.eclipse.osee.framework.core.model.cache.BranchCache; +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.data.ReadableArtifact; + +public class CommitBranchCallable extends AbstractBranchCallable<TransactionRecord> { + + private final BranchCache branchCache; + private final ReadableArtifact committer; + private final IOseeBranch source; + private final IOseeBranch destination; + + public CommitBranchCallable(Log logger, SessionContext sessionContext, BranchDataStore branchStore, BranchCache branchCache, ReadableArtifact committer, IOseeBranch source, IOseeBranch destination) { + super(logger, sessionContext, branchStore); + this.branchCache = branchCache; + this.committer = committer; + this.source = source; + this.destination = destination; + } + + private BranchCache getBranchCache() { + return branchCache; + } + + @Override + protected TransactionRecord innerCall() throws Exception { + Conditions.checkNotNull(branchCache, "branchCache"); + Conditions.checkNotNull(source, "sourceBranch"); + Conditions.checkNotNull(destination, "destinationBranch"); + + Branch sourceBranch = getBranchCache().get(source); + Branch destinationBranch = getBranchCache().get(destination); + + Conditions.checkNotNull(sourceBranch, "sourceBranch"); + Conditions.checkNotNull(destinationBranch, "destinationBranch"); + + Callable<TransactionRecord> commitBranchCallable = + getBranchStore().commitBranch(getSessionContext().getSessionId(), committer, sourceBranch, destinationBranch); + return callAndCheckForCancel(commitBranchCallable); + } +} |