summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkwilk2012-01-06 18:57:30 (EST)
committer Roberto E. Escobar2012-01-06 18:57:30 (EST)
commitcf45ea31632f648e78179a394342665c3bfef4a9 (patch)
treea64402ee71d4a3e9688f84495b406ebd29594b17
parent826b838b8f25ee09d2eabc062a44f9895538fc24 (diff)
downloadorg.eclipse.osee-cf45ea31632f648e78179a394342665c3bfef4a9.zip
org.eclipse.osee-cf45ea31632f648e78179a394342665c3bfef4a9.tar.gz
org.eclipse.osee-cf45ea31632f648e78179a394342665c3bfef4a9.tar.bz2
refactor: Add import parameter for artifact import operation factory
-rw-r--r--plugins/org.eclipse.osee.ats.config.demo/src/org/eclipse/osee/ats/config/demo/PopulateDemoActions.java21
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactImportOperationFactory.java38
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactImportOperationParameter.java164
3 files changed, 211 insertions, 12 deletions
diff --git a/plugins/org.eclipse.osee.ats.config.demo/src/org/eclipse/osee/ats/config/demo/PopulateDemoActions.java b/plugins/org.eclipse.osee.ats.config.demo/src/org/eclipse/osee/ats/config/demo/PopulateDemoActions.java
index 1da3f24..2c1fd49 100644
--- a/plugins/org.eclipse.osee.ats.config.demo/src/org/eclipse/osee/ats/config/demo/PopulateDemoActions.java
+++ b/plugins/org.eclipse.osee.ats.config.demo/src/org/eclipse/osee/ats/config/demo/PopulateDemoActions.java
@@ -83,6 +83,7 @@ import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateComposite.TableLo
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItem;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItemAction;
import org.eclipse.osee.framework.ui.skynet.Import.ArtifactImportOperationFactory;
+import org.eclipse.osee.framework.ui.skynet.Import.ArtifactImportOperationParameter;
import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.support.test.util.DemoArtifactTypes;
import org.eclipse.osee.support.test.util.DemoSawBuilds;
@@ -126,13 +127,14 @@ public class PopulateDemoActions extends XNavigateItemAction {
}
private static void validateArtifactCache() throws OseeStateException {
- if (ArtifactCache.getDirtyArtifacts().size() > 0) {
- for (Artifact artifact : ArtifactCache.getDirtyArtifacts()) {
+ final Collection<Artifact> list = ArtifactCache.getDirtyArtifacts();
+ if (!list.isEmpty()) {
+ for (Artifact artifact : list) {
System.err.println(String.format("Artifact [%s] is dirty [%s]", artifact.toStringWithId(),
Artifacts.getDirtyReport(artifact)));
}
throw new OseeStateException("[%d] Dirty Artifacts found after populate (see console for details)",
- ArtifactCache.getDirtyArtifacts().size());
+ list.size());
}
}
@@ -156,7 +158,7 @@ public class PopulateDemoActions extends XNavigateItemAction {
// Import all requirements on SAW_Bld_1 Branch
demoDbImportReqsTx();
- DemoDbUtil.sleep(5000);
+ //DemoDbUtil.sleep(5000);
// Create traceability between System, Subsystem and Software requirements
SkynetTransaction demoDbTraceability =
@@ -164,7 +166,7 @@ public class PopulateDemoActions extends XNavigateItemAction {
demoDbTraceabilityTx(demoDbTraceability, DemoSawBuilds.SAW_Bld_1);
demoDbTraceability.execute();
- DemoDbUtil.sleep(5000);
+ //DemoDbUtil.sleep(5000);
// Create SAW_Bld_2 Child Main Working Branch off SAW_Bld_1
createMainWorkingBranchTx();
@@ -375,8 +377,13 @@ public class PopulateDemoActions extends XNavigateItemAction {
IArtifactExtractor extractor = new WordOutlineExtractor();
extractor.setDelegate(new WordOutlineExtractorDelegate());
- IOperation operation =
- ArtifactImportOperationFactory.createOperation(file, systemReq, null, extractor, artifactResolver, false);
+ ArtifactImportOperationParameter importOptions = new ArtifactImportOperationParameter();
+ importOptions.setSourceFile(file);
+ importOptions.setDestinationArtifact(systemReq);
+ importOptions.setExtractor(extractor);
+ importOptions.setResolver(artifactResolver);
+
+ IOperation operation = ArtifactImportOperationFactory.createOperation(importOptions);
Operations.executeWorkAndCheckStatus(operation);
// Validate that something was imported
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactImportOperationFactory.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactImportOperationFactory.java
index 85b5a36..bef7348 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactImportOperationFactory.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactImportOperationFactory.java
@@ -15,12 +15,14 @@ import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.operation.AbstractOperation;
import org.eclipse.osee.framework.core.operation.CompositeOperation;
import org.eclipse.osee.framework.core.operation.IOperation;
+import org.eclipse.osee.framework.core.operation.NullOperationLogger;
import org.eclipse.osee.framework.core.operation.OperationLogger;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.importing.RoughArtifact;
@@ -46,19 +48,45 @@ public final class ArtifactImportOperationFactory {
super();
}
- public static IOperation createOperation(File sourceFile, Artifact destinationArtifact, OperationLogger logger, IArtifactExtractor extractor, IArtifactImportResolver resolver, boolean stopOnError) throws OseeCoreException {
- SkynetTransaction transaction =
- new SkynetTransaction(destinationArtifact.getBranch(), "Artifact Import Wizard transaction");
+ public static IOperation createOperation(ArtifactImportOperationParameter param) throws OseeCoreException {
+ return completeOperation(param.getSourceFile(), param.getDestinationArtifact(), param.getLogger(),
+ param.getExtractor(), param.getResolver(), param.isStopOnError(), param.getGoverningTransaction(),
+ param.isExecuteTransaction());
+ }
+
+ public static IOperation completeOperation(File sourceFile, Artifact destinationArtifact, OperationLogger logger, IArtifactExtractor extractor, IArtifactImportResolver resolver, boolean stopOnError, SkynetTransaction governingTransaction, boolean executeTransaction) throws OseeCoreException {
+ CheckAndThrow(sourceFile, destinationArtifact, extractor, resolver);
+
RoughArtifactCollector collector = new RoughArtifactCollector(new RoughArtifact(RoughArtifactKind.PRIMARY));
+ if (logger == null) {
+ logger = NullOperationLogger.getSingleton();
+ }
+
+ SkynetTransaction transaction = governingTransaction;
+ if (transaction == null) {
+ executeTransaction = true;
+ transaction =
+ new SkynetTransaction(destinationArtifact.getBranch(),
+ "ArtifactImportOperationFactory: Artifact Import Wizard transaction");
+ }
+
List<IOperation> ops = new ArrayList<IOperation>();
ops.add(new SourceToRoughArtifactOperation(logger, extractor, sourceFile, collector));
ops.add(new RoughToRealArtifactOperation(transaction, destinationArtifact, collector, resolver, false));
ops.add(new ArtifactValidationCheckOperation(destinationArtifact.getDescendants(), stopOnError));
- ops.add(new CompleteArtifactImportOperation(transaction, destinationArtifact));
+ if (executeTransaction) {
+ ops.add(new CompleteArtifactImportOperation(transaction, destinationArtifact));
+ }
return new CompositeOperation("Artifact Import", Activator.PLUGIN_ID, ops);
}
+ private static void CheckAndThrow(Object... objects) {
+ for (Object object : objects) {
+ Assert.isNotNull(object);
+ }
+ }
+
public static IOperation createArtifactAndRoughToRealOperation(File sourceFile, Artifact destinationArtifact, OperationLogger logger, IArtifactExtractor extractor, IArtifactImportResolver resolver, RoughArtifactCollector collector, Collection<IArtifactType> selectionArtifactTypes, boolean stopOnError, boolean deleteUnMatched, boolean runFilterByAttributes) throws OseeCoreException {
List<IOperation> ops = new ArrayList<IOperation>();
ops.add(createArtifactsCompOperation(
@@ -119,4 +147,4 @@ public final class ArtifactImportOperationFactory {
return new CompositeOperation(opName, Activator.PLUGIN_ID, ops);
}
-} \ No newline at end of file
+}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactImportOperationParameter.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactImportOperationParameter.java
new file mode 100644
index 0000000..e693e08
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactImportOperationParameter.java
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.framework.ui.skynet.Import;
+
+import java.io.File;
+import org.eclipse.osee.framework.core.operation.IOperation;
+import org.eclipse.osee.framework.core.operation.OperationLogger;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.importing.parsers.ExcelArtifactExtractor;
+import org.eclipse.osee.framework.skynet.core.importing.parsers.IArtifactExtractor;
+import org.eclipse.osee.framework.skynet.core.importing.parsers.NativeDocumentExtractor;
+import org.eclipse.osee.framework.skynet.core.importing.parsers.WholeWordDocumentExtractor;
+import org.eclipse.osee.framework.skynet.core.importing.resolvers.AttributeBasedArtifactResolver;
+import org.eclipse.osee.framework.skynet.core.importing.resolvers.GuidBasedArtifactResolver;
+import org.eclipse.osee.framework.skynet.core.importing.resolvers.IArtifactImportResolver;
+import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
+
+/**
+ * Encapsulating parameter class for creating Artifact Import {@link IOperation}s <br/>
+ * <br/>
+ * Example:
+ *
+ * <pre>
+ * ...
+ * ArtifactImportOperationParameter <b>importParams</b> = new ArtifactImportOperationParameter();
+ * importParameters.setSourceFile(sourceFile);
+ * importParameters.setDestinationArtifact(destinationFolder);
+ * importParameters.setExtractor(new WholeWordDocumentExtractor());
+ * importParameters.setResolver(resolver);
+ * importParameters.setGoverningTransaction(transaction);
+ * ...
+ * IOperation operation = ArtifactImportOperationFactory.createOperation(<b>importParams</b>);
+ * ...
+ * </pre>
+ */
+public class ArtifactImportOperationParameter {
+ private File sourceFile;
+ private Artifact destinationArtifact;
+ private OperationLogger logger;
+ private IArtifactExtractor extractor;
+ private IArtifactImportResolver resolver;
+ private boolean stopOnError;
+ private SkynetTransaction governingTransaction;
+ private boolean executeTransaction;
+
+ public ArtifactImportOperationParameter() {
+ this(null, null, null, null, null, false, null, false);
+ }
+
+ public ArtifactImportOperationParameter(File sourceFile, Artifact destinationArtifact, OperationLogger logger, IArtifactExtractor extractor, IArtifactImportResolver resolver, boolean stopOnError, SkynetTransaction governingTransaction, boolean executeTransaction) {
+ this.sourceFile = sourceFile;
+ this.destinationArtifact = destinationArtifact;
+ this.logger = logger;
+ this.extractor = extractor;
+ this.resolver = resolver;
+ this.stopOnError = stopOnError;
+ this.governingTransaction = governingTransaction;
+ this.executeTransaction = executeTransaction;
+ }
+
+ public SkynetTransaction getGoverningTransaction() {
+ return governingTransaction;
+ }
+
+ /**
+ * @param governingTransaction transaction governing the import process, if null, operation will create and execute
+ * its own.
+ */
+ public void setGoverningTransaction(SkynetTransaction governingTransaction) {
+ this.governingTransaction = governingTransaction;
+ }
+
+ public boolean isExecuteTransaction() {
+ return executeTransaction;
+ }
+
+ /**
+ * @param executeTransaction manual flag to execute passed in {@link SkynetTransaction}
+ */
+ public void setExecuteTransaction(boolean executeTransaction) {
+ this.executeTransaction = executeTransaction;
+ }
+
+ public File getSourceFile() {
+ return sourceFile;
+ }
+
+ /**
+ * @param sourceFile being imported
+ */
+ public void setSourceFile(File sourceFile) {
+ this.sourceFile = sourceFile;
+ }
+
+ public Artifact getDestinationArtifact() {
+ return destinationArtifact;
+ }
+
+ /**
+ * <pre>
+ * destinationArtifact
+ * |
+ * |- some artifact A from sourceFile
+ * |
+ * `- some artifact B from sourceFile
+ * </pre>
+ *
+ * @param destinationArtifact parent artifact under which all imported artifact will "live"
+ */
+ public void setDestinationArtifact(Artifact destinationArtifact) {
+ this.destinationArtifact = destinationArtifact;
+ }
+
+ public OperationLogger getLogger() {
+ return logger;
+ }
+
+ /**
+ * @param logger used during this operation
+ */
+ public void setLogger(OperationLogger logger) {
+ this.logger = logger;
+ }
+
+ public IArtifactExtractor getExtractor() {
+ return extractor;
+ }
+
+ /**
+ * @param extractor specific artifact extractor {@link ExcelArtifactExtractor}, {@link NativeDocumentExtractor},
+ * {@link WholeWordDocumentExtractor}
+ */
+ public void setExtractor(IArtifactExtractor extractor) {
+ this.extractor = extractor;
+ }
+
+ public IArtifactImportResolver getResolver() {
+ return resolver;
+ }
+
+ /**
+ * @param resolver encapsulated logic helping to resolve artifacts, most common are
+ * {@link AttributeBasedArtifactResolver} or {@link GuidBasedArtifactResolver}
+ */
+ public void setResolver(IArtifactImportResolver resolver) {
+ this.resolver = resolver;
+ }
+
+ public boolean isStopOnError() {
+ return stopOnError;
+ }
+
+ public void setStopOnError(boolean stopOnError) {
+ this.stopOnError = stopOnError;
+ }
+} \ No newline at end of file