Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmisinco2014-08-25 19:18:30 +0000
committerRoberto E. Escobar2014-10-01 21:03:10 +0000
commit1d03e610cd94d09acbde46b3b4e0de0b86005b73 (patch)
tree977eb3ac956165378e9b2ba414c89002906f033a
parent9ed225bea5f9c40b9b39c1b9cf77d8a8aca35459 (diff)
downloadorg.eclipse.osee-1d03e610cd94d09acbde46b3b4e0de0b86005b73.tar.gz
org.eclipse.osee-1d03e610cd94d09acbde46b3b4e0de0b86005b73.tar.xz
org.eclipse.osee-1d03e610cd94d09acbde46b3b4e0de0b86005b73.zip
refactor[ats_ATS46139]: Remove BranchCache from DeleteBranchCallable
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/BranchDataStore.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsBranchImpl.java5
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/branch/DeleteBranchCallable.java58
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/branch/BranchModule.java14
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CompositeDatastoreTxCallable.java38
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsBranch.java2
6 files changed, 57 insertions, 62 deletions
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/BranchDataStore.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/BranchDataStore.java
index f839adda244..e2ac5026349 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/BranchDataStore.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/BranchDataStore.java
@@ -53,4 +53,6 @@ public interface BranchDataStore {
Callable<Void> archiveUnArchiveBranch(OrcsSession session, IOseeBranch branch, ArchiveOperation op);
+ Callable<Void> deleteBranch(OrcsSession session, IOseeBranch branch);
+
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsBranchImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsBranchImpl.java
index e098570b06e..208be46c649 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsBranchImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsBranchImpl.java
@@ -34,7 +34,6 @@ import org.eclipse.osee.orcs.core.internal.branch.BranchDataFactory;
import org.eclipse.osee.orcs.core.internal.branch.CommitBranchCallable;
import org.eclipse.osee.orcs.core.internal.branch.CompareBranchCallable;
import org.eclipse.osee.orcs.core.internal.branch.CreateBranchCallable;
-import org.eclipse.osee.orcs.core.internal.branch.DeleteBranchCallable;
import org.eclipse.osee.orcs.core.internal.branch.PurgeBranchCallable;
import org.eclipse.osee.orcs.data.ArchiveOperation;
import org.eclipse.osee.orcs.data.ArtifactReadable;
@@ -77,8 +76,8 @@ public class OrcsBranchImpl implements OrcsBranch {
}
@Override
- public Callable<BranchReadable> deleteBranch(IOseeBranch branch) {
- return new DeleteBranchCallable(logger, session, branchStore, branchCache, branch);
+ public Callable<Void> deleteBranch(IOseeBranch branch) {
+ return branchStore.deleteBranch(session, branch);
}
@Override
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/branch/DeleteBranchCallable.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/branch/DeleteBranchCallable.java
deleted file mode 100644
index 8201b22120a..00000000000
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/branch/DeleteBranchCallable.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * 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 org.eclipse.osee.framework.core.data.IOseeBranch;
-import org.eclipse.osee.framework.core.enums.BranchArchivedState;
-import org.eclipse.osee.framework.core.enums.BranchState;
-import org.eclipse.osee.framework.core.model.Branch;
-import org.eclipse.osee.framework.core.model.BranchReadable;
-import org.eclipse.osee.framework.core.model.cache.BranchCache;
-import org.eclipse.osee.framework.jdk.core.util.Conditions;
-import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.core.ds.BranchDataStore;
-
-public class DeleteBranchCallable extends AbstractBranchCallable<BranchReadable> {
-
- private final BranchCache cache;
- private final IOseeBranch toDelete;
-
- public DeleteBranchCallable(Log logger, OrcsSession session, BranchDataStore branchStore, BranchCache cache, IOseeBranch toDelete) {
- super(logger, session, branchStore);
- this.cache = cache;
- this.toDelete = toDelete;
- }
-
- @Override
- protected BranchReadable innerCall() throws Exception {
- Conditions.checkNotNull(cache, "branchCache");
- Conditions.checkNotNull(toDelete, "toDelete");
- Branch branch = cache.get(toDelete);
-
- BranchState originalState = branch.getBranchState();
- BranchArchivedState originalArchivedState = branch.getArchiveState();
- try {
- branch.setBranchState(BranchState.DELETED);
- branch.setArchived(true);
- cache.storeItems(branch);
- } catch (Exception ex) {
- branch.setBranchState(originalState);
- branch.setArchived(originalArchivedState.isArchived());
- throw ex;
- } finally {
- // OseeEventManager.kickBranchEvent(this, new BranchEvent(BranchEventType.Deleting, branch.getUuid()),
- // branch.getId());
- // TODO Event ?
- }
- return branch;
- }
-}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/branch/BranchModule.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/branch/BranchModule.java
index 90b92114216..cd3e8ea8c3c 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/branch/BranchModule.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/branch/BranchModule.java
@@ -35,6 +35,7 @@ import org.eclipse.osee.orcs.data.ArchiveOperation;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.CreateBranchData;
import org.eclipse.osee.orcs.db.internal.IdentityLocator;
+import org.eclipse.osee.orcs.db.internal.callable.AbstractDatastoreTxCallable;
import org.eclipse.osee.orcs.db.internal.callable.ArchiveUnarchiveBranchCallable;
import org.eclipse.osee.orcs.db.internal.callable.BranchCopyTxCallable;
import org.eclipse.osee.orcs.db.internal.callable.ChangeBranchStateCallable;
@@ -42,6 +43,7 @@ import org.eclipse.osee.orcs.db.internal.callable.ChangeBranchTypeCallable;
import org.eclipse.osee.orcs.db.internal.callable.CheckBranchExchangeIntegrityCallable;
import org.eclipse.osee.orcs.db.internal.callable.CommitBranchDatabaseCallable;
import org.eclipse.osee.orcs.db.internal.callable.CompareDatabaseCallable;
+import org.eclipse.osee.orcs.db.internal.callable.CompositeDatastoreTxCallable;
import org.eclipse.osee.orcs.db.internal.callable.CreateBranchDatabaseTxCallable;
import org.eclipse.osee.orcs.db.internal.callable.ExportBranchDatabaseCallable;
import org.eclipse.osee.orcs.db.internal.callable.ImportBranchDatabaseCallable;
@@ -147,6 +149,18 @@ public class BranchModule {
return new ArchiveUnarchiveBranchCallable(logger, session, dbService, branch, op);
}
+ @Override
+ public Callable<Void> deleteBranch(OrcsSession session, IOseeBranch branch) {
+ AbstractDatastoreTxCallable<?> deleteBranch =
+ (AbstractDatastoreTxCallable<?>) changeBranchState(session, branch, BranchState.DELETED);
+ AbstractDatastoreTxCallable<?> archiveBranch =
+ (AbstractDatastoreTxCallable<?>) archiveUnArchiveBranch(session, branch, ArchiveOperation.ARCHIVE);
+ CompositeDatastoreTxCallable composite =
+ new CompositeDatastoreTxCallable(logger, session, dbService,
+ String.format("Delete Branch [%s]", branch), deleteBranch, archiveBranch);
+ return composite;
+ }
+
};
}
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CompositeDatastoreTxCallable.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CompositeDatastoreTxCallable.java
new file mode 100644
index 00000000000..a1a811745c2
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CompositeDatastoreTxCallable.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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.db.internal.callable;
+
+import java.util.List;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+import org.eclipse.osee.framework.database.core.OseeConnection;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.logger.Log;
+import org.eclipse.osee.orcs.OrcsSession;
+import com.google.common.collect.Lists;
+
+public class CompositeDatastoreTxCallable extends AbstractDatastoreTxCallable<Void> {
+
+ private final List<AbstractDatastoreTxCallable<?>> callables;
+
+ public CompositeDatastoreTxCallable(Log logger, OrcsSession session, IOseeDatabaseService dbService, String name, AbstractDatastoreTxCallable<?>... callables) {
+ super(logger, session, dbService, name);
+ this.callables = Lists.newArrayList(callables);
+ }
+
+ @Override
+ protected Void handleTxWork(OseeConnection connection) throws OseeCoreException {
+ for (AbstractDatastoreTxCallable<?> callable : callables) {
+ callable.handleTxWork(connection);
+ }
+ return null;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsBranch.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsBranch.java
index 51f0b5640b2..b05b4e8ddf1 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsBranch.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsBranch.java
@@ -62,7 +62,7 @@ public interface OrcsBranch {
Callable<Void> changeBranchType(IOseeBranch branch, BranchType branchType);
- Callable<BranchReadable> deleteBranch(IOseeBranch branch);
+ Callable<Void> deleteBranch(IOseeBranch branch);
/////////////////////////////////////////////////////////////////////////

Back to the top