diff options
author | Roberto E. Escobar | 2013-08-13 22:19:20 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2013-08-26 20:52:35 +0000 |
commit | c894a50639e6c7aa0f273f77a2b9544b7742d6f8 (patch) | |
tree | 8c69787209ee7fd6fcb0c72758e205c7906c54d6 /plugins/org.eclipse.osee.orcs.core | |
parent | 08c8dd55e650ca6559eb0a2ab196f3999fdf8a20 (diff) | |
download | org.eclipse.osee-c894a50639e6c7aa0f273f77a2b9544b7742d6f8.tar.gz org.eclipse.osee-c894a50639e6c7aa0f273f77a2b9544b7742d6f8.tar.xz org.eclipse.osee-c894a50639e6c7aa0f273f77a2b9544b7742d6f8.zip |
refactor: Clean-up ORCS datastore module startup
Change-Id: I1d459f4ef6567ae2b668cbfc88609dd0b9ecaa2c
Diffstat (limited to 'plugins/org.eclipse.osee.orcs.core')
12 files changed, 111 insertions, 79 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 ff299d093d4..9da3291cc48 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 @@ -11,17 +11,15 @@ package org.eclipse.osee.orcs.core.ds; import java.net.URI; -import java.util.Collection; import java.util.List; import java.util.concurrent.Callable; import org.eclipse.osee.framework.core.data.IOseeBranch; -import org.eclipse.osee.framework.core.data.ITransaction; import org.eclipse.osee.framework.core.model.Branch; import org.eclipse.osee.framework.core.model.TransactionRecord; import org.eclipse.osee.framework.core.model.change.ChangeItem; import org.eclipse.osee.framework.jdk.core.type.PropertyStore; -import org.eclipse.osee.orcs.OrcsTypes; import org.eclipse.osee.orcs.OrcsSession; +import org.eclipse.osee.orcs.OrcsTypes; import org.eclipse.osee.orcs.data.ArtifactReadable; import org.eclipse.osee.orcs.data.CreateBranchData; @@ -46,10 +44,4 @@ public interface BranchDataStore { Callable<URI> checkBranchExchangeIntegrity(OrcsSession session, URI fileToCheck); - Callable<TransactionResult> commitTransaction(OrcsSession session, TransactionData transaction); - - Callable<?> purgeTransactions(OrcsSession session, Collection<? extends ITransaction> transactions); - - // Temp - Callable<String> createUnsubscribeTx(ArtifactReadable userArtifact, ArtifactReadable groupArtifact); } diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DataModule.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DataModule.java index a4564f80208..0cfc4895fef 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DataModule.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DataModule.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.osee.orcs.core.ds; - /** * @author Roberto E. Escobar */ @@ -20,4 +19,12 @@ public interface DataModule { DataLoaderFactory getDataLoaderFactory(); + QueryEngine getQueryEngine(); + + BranchDataStore getBranchDataStore(); + + TxDataStore getTxDataStore(); + + DataStoreAdmin getDataStoreAdmin(); + } diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsDataStore.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsDataStore.java index c637c43f536..c71fdcb5a36 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsDataStore.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsDataStore.java @@ -16,16 +16,12 @@ import org.eclipse.osee.orcs.data.AttributeTypes; /** * @author Roberto E. Escobar */ -public interface OrcsDataStore extends OrcsTypesDataStore { +public interface OrcsDataStore { - BranchDataStore getBranchDataStore(); - - DataStoreAdmin getDataStoreAdmin(); + OrcsTypesDataStore getTypesDataStore(); DataModule createDataModule(ArtifactTypes artifactTypes, AttributeTypes attributeTypes); - QueryEngine getQueryEngine(); - QueryEngineIndexer getQueryEngineIndexer(); } diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsVisitorAdapter.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsVisitorAdapter.java new file mode 100644 index 00000000000..4091c8811ab --- /dev/null +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsVisitorAdapter.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2013 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.ds; + +import org.eclipse.osee.framework.core.exception.OseeCoreException; + +/** + * @author Roberto E. Escobar + */ +public class OrcsVisitorAdapter implements OrcsVisitor { + + @SuppressWarnings("unused") + @Override + public void visit(ArtifactData data) throws OseeCoreException { + // + } + + @SuppressWarnings("unused") + @Override + public void visit(AttributeData data) throws OseeCoreException { + // + } + + @SuppressWarnings("unused") + @Override + public void visit(RelationData data) throws OseeCoreException { + // + } + +}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/TransactionData.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/TransactionData.java index dea04453ce5..c72bb219d1a 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/TransactionData.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/TransactionData.java @@ -14,7 +14,7 @@ import java.util.List; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.orcs.data.ArtifactReadable; -public interface TransactionData { +public interface TransactionData extends OrcsVisitable { IOseeBranch getBranch(); @@ -23,4 +23,5 @@ public interface TransactionData { String getComment(); List<ArtifactTransactionData> getTxData(); + }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/TxDataStore.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/TxDataStore.java new file mode 100644 index 00000000000..f60034ecdae --- /dev/null +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/TxDataStore.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2013 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.ds; + +import java.util.Collection; +import java.util.concurrent.Callable; +import org.eclipse.osee.framework.core.data.ITransaction; +import org.eclipse.osee.orcs.OrcsSession; +import org.eclipse.osee.orcs.data.ArtifactReadable; + +/** + * @author Roberto E. Escobar + */ +public interface TxDataStore { + + Callable<TransactionResult> commitTransaction(OrcsSession session, TransactionData transaction); + + Callable<Integer> purgeTransactions(OrcsSession session, Collection<? extends ITransaction> transactions); + + Callable<String> createUnsubscribeTx(ArtifactReadable userArtifact, ArtifactReadable groupArtifact); + +} diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java index bd5370f3154..9d2bbaf3b62 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java @@ -80,6 +80,7 @@ public class OrcsApiImpl implements OrcsApi { private TxDataHandlerFactoryImpl txUpdateFactory; private OrcsTypesModule typesModule; private OrcsSession systemSession; + private DataModule module; public void setLogger(Log logger) { this.logger = logger; @@ -128,12 +129,12 @@ public class OrcsApiImpl implements OrcsApi { } }; - typesModule = new OrcsTypesModule(logger, dataStore, hierarchyProvider); + typesModule = new OrcsTypesModule(logger, dataStore.getTypesDataStore(), hierarchyProvider); typesModule.start(getSystemSession()); OrcsTypes orcsTypes = typesModule.createOrcsTypes(getSystemSession()); - DataModule module = dataStore.createDataModule(orcsTypes.getArtifactTypes(), orcsTypes.getAttributeTypes()); + module = dataStore.createDataModule(orcsTypes.getArtifactTypes(), orcsTypes.getAttributeTypes()); RelationFactory relationFactory = new RelationFactory(orcsTypes.getRelationTypes()); @@ -155,7 +156,7 @@ public class OrcsApiImpl implements OrcsApi { loaderFactory = new ArtifactLoaderFactoryImpl(module.getDataLoaderFactory(), builderFactory); queryModule = - new QueryModule(logger, dataStore.getQueryEngine(), loaderFactory, module.getDataLoaderFactory(), + new QueryModule(logger, module.getQueryEngine(), loaderFactory, module.getDataLoaderFactory(), orcsTypes.getArtifactTypes(), orcsTypes.getAttributeTypes()); indexerModule = new IndexerModule(logger, preferences, executorAdmin, dataStore.getQueryEngineIndexer()); @@ -212,20 +213,20 @@ public class OrcsApiImpl implements OrcsApi { return new FutureTask<ArtifactReadable>(callable); } }; - return new OrcsBranchImpl(logger, session, dataStore.getBranchDataStore(), cacheService.getBranchCache(), + return new OrcsBranchImpl(logger, session, module.getBranchDataStore(), cacheService.getBranchCache(), cacheService.getTransactionCache(), systemUser, getOrcsTypes(context)); } @Override public TransactionFactory getTransactionFactory(ApplicationContext context) { OrcsSession session = getSession(context); - return new TransactionFactoryImpl(logger, session, dataStore.getBranchDataStore(), proxyFactory, txUpdateFactory); + return new TransactionFactoryImpl(logger, session, module.getTxDataStore(), proxyFactory, txUpdateFactory); } @Override public OrcsAdmin getAdminOps(ApplicationContext context) { OrcsSession session = getSession(context); - return new OrcsAdminImpl(logger, session, dataStore.getDataStoreAdmin()); + return new OrcsAdminImpl(logger, session, module.getDataStoreAdmin()); } @Override diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/OrcsTransactionImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/OrcsTransactionImpl.java index 609e6086aaa..98fc122e034 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/OrcsTransactionImpl.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/OrcsTransactionImpl.java @@ -26,9 +26,9 @@ import org.eclipse.osee.framework.core.util.Conditions; import org.eclipse.osee.logger.Log; import org.eclipse.osee.orcs.OrcsSession; import org.eclipse.osee.orcs.core.ds.ArtifactTransactionData; -import org.eclipse.osee.orcs.core.ds.BranchDataStore; import org.eclipse.osee.orcs.core.ds.TransactionData; import org.eclipse.osee.orcs.core.ds.TransactionResult; +import org.eclipse.osee.orcs.core.ds.TxDataStore; import org.eclipse.osee.orcs.core.internal.proxy.ArtifactProxyFactory; import org.eclipse.osee.orcs.data.ArtifactReadable; import org.eclipse.osee.orcs.data.ArtifactWriteable; @@ -42,7 +42,7 @@ public class OrcsTransactionImpl implements OrcsTransaction { @SuppressWarnings("unused") private final Log logger; private final OrcsSession session; - private final BranchDataStore dataStore; + private final TxDataStore txDataStore; private final ArtifactProxyFactory factory; private final IOseeBranch branch; @@ -53,11 +53,11 @@ public class OrcsTransactionImpl implements OrcsTransaction { private volatile boolean isCommitInProgress; - public OrcsTransactionImpl(Log logger, OrcsSession session, BranchDataStore dataStore, ArtifactProxyFactory factory, TxDataManager manager, IOseeBranch branch) { + public OrcsTransactionImpl(Log logger, OrcsSession session, TxDataStore txDataStore, ArtifactProxyFactory factory, TxDataManager manager, IOseeBranch branch) { super(); this.logger = logger; this.session = session; - this.dataStore = dataStore; + this.txDataStore = txDataStore; this.factory = factory; this.manager = manager; this.branch = branch; @@ -108,7 +108,7 @@ public class OrcsTransactionImpl implements OrcsTransaction { private Callable<TransactionResult> createCommit() throws OseeCoreException { List<ArtifactTransactionData> changes = manager.getChanges(); TransactionData data = new TransactionDataImpl(getBranch(), getAuthor(), getComment(), changes); - return dataStore.commitTransaction(session, data); + return txDataStore.commitTransaction(session, data); } @Override diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionDataImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionDataImpl.java index 8c77c696729..4271fa91639 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionDataImpl.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionDataImpl.java @@ -12,7 +12,9 @@ package org.eclipse.osee.orcs.core.internal.transaction; import java.util.List; import org.eclipse.osee.framework.core.data.IOseeBranch; +import org.eclipse.osee.framework.core.exception.OseeCoreException; import org.eclipse.osee.orcs.core.ds.ArtifactTransactionData; +import org.eclipse.osee.orcs.core.ds.OrcsVisitor; import org.eclipse.osee.orcs.core.ds.TransactionData; import org.eclipse.osee.orcs.data.ArtifactReadable; @@ -54,4 +56,10 @@ public class TransactionDataImpl implements TransactionData { return data; } + @Override + public void accept(OrcsVisitor visitor) throws OseeCoreException { + for (ArtifactTransactionData data : getTxData()) { + data.accept(visitor); + } + } } diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionFactoryImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionFactoryImpl.java index aac7a75ad6c..72f8dd6d574 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionFactoryImpl.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionFactoryImpl.java @@ -18,7 +18,7 @@ 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.OrcsSession; -import org.eclipse.osee.orcs.core.ds.BranchDataStore; +import org.eclipse.osee.orcs.core.ds.TxDataStore; 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; @@ -32,14 +32,14 @@ public class TransactionFactoryImpl implements TransactionFactory { private final Log logger; private final OrcsSession session; - private final BranchDataStore branchDataStore; + private final TxDataStore txDataStore; private final ArtifactProxyFactory artifactFactory; private final TxDataHandlerFactory handlerF; - public TransactionFactoryImpl(Log logger, OrcsSession session, BranchDataStore branchDataStore, ArtifactProxyFactory artifactFactory, TxDataHandlerFactory handlerF) { + public TransactionFactoryImpl(Log logger, OrcsSession session, TxDataStore txDataStore, ArtifactProxyFactory artifactFactory, TxDataHandlerFactory handlerF) { this.logger = logger; this.session = session; - this.branchDataStore = branchDataStore; + this.txDataStore = txDataStore; this.artifactFactory = artifactFactory; this.handlerF = handlerF; } @@ -52,7 +52,7 @@ public class TransactionFactoryImpl implements TransactionFactory { TxDataManager manager = new TxDataManagerImpl(artifactFactory, handlerF); OrcsTransactionImpl orcsTxn = - new OrcsTransactionImpl(logger, session, branchDataStore, artifactFactory, manager, branch); + new OrcsTransactionImpl(logger, session, txDataStore, artifactFactory, manager, branch); orcsTxn.setComment(comment); orcsTxn.setAuthor(author); return orcsTxn; @@ -60,11 +60,11 @@ public class TransactionFactoryImpl implements TransactionFactory { @Override public Callable<String> createUnsubscribeTx(ArtifactReadable userArtifact, ArtifactReadable groupArtifact) { - return branchDataStore.createUnsubscribeTx(userArtifact, groupArtifact); + return txDataStore.createUnsubscribeTx(userArtifact, groupArtifact); } @Override - public Callable<?> purgeTransaction(Collection<? extends ITransaction> transactions) { - return branchDataStore.purgeTransactions(session, transactions); + public Callable<Integer> purgeTransaction(Collection<? extends ITransaction> transactions) { + return txDataStore.purgeTransactions(session, transactions); } } diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/handler/NoOpOrcsVisitor.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/handler/NoOpOrcsVisitor.java deleted file mode 100644 index 0c17668ae59..00000000000 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/handler/NoOpOrcsVisitor.java +++ /dev/null @@ -1,42 +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.transaction.handler; - -import org.eclipse.osee.orcs.core.ds.ArtifactData; -import org.eclipse.osee.orcs.core.ds.AttributeData; -import org.eclipse.osee.orcs.core.ds.OrcsVisitor; -import org.eclipse.osee.orcs.core.ds.RelationData; - -/** - * @author Roberto E. Escobar - */ -public class NoOpOrcsVisitor implements OrcsVisitor { - - public NoOpOrcsVisitor() { - super(); - } - - @Override - public void visit(ArtifactData newData) { - // Do Nothing - } - - @Override - public void visit(AttributeData newData) { - // Do Nothing - } - - @Override - public void visit(RelationData data) { - // Do Nothing - } - -} diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/handler/TxDataHandlerFactoryImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/handler/TxDataHandlerFactoryImpl.java index 4231ba30484..b6455eee1ba 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/handler/TxDataHandlerFactoryImpl.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/handler/TxDataHandlerFactoryImpl.java @@ -15,6 +15,7 @@ import java.util.Map; import org.eclipse.osee.orcs.core.ds.ArtifactTransactionData; import org.eclipse.osee.orcs.core.ds.DataFactory; import org.eclipse.osee.orcs.core.ds.OrcsVisitor; +import org.eclipse.osee.orcs.core.ds.OrcsVisitorAdapter; import org.eclipse.osee.orcs.core.internal.artifact.ArtifactVisitor; import org.eclipse.osee.orcs.core.internal.transaction.TxDataManagerImpl.TxDataHandlerFactory; import org.eclipse.osee.orcs.data.ArtifactWriteable; @@ -39,6 +40,6 @@ public class TxDataHandlerFactoryImpl implements TxDataHandlerFactory { @Override public OrcsVisitor createOnSuccessHandler(Map<String, ArtifactWriteable> writeableArtifacts) { // Do Nothing on success; - return new NoOpOrcsVisitor(); + return new OrcsVisitorAdapter(); } } |