summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkwilk2011-04-19 17:14:35 (EDT)
committerRyan D. Brooks2011-04-19 17:14:35 (EDT)
commit62cdeb9af32443a9a28cef8d51648bdc72322329 (patch)
treee9cc263a1dc4f0ced81fe6bc2b9238613b72e206
parent83f8adea77b8dd56c277d37efff4c080e1b45402 (diff)
downloadorg.eclipse.osee-62cdeb9af32443a9a28cef8d51648bdc72322329.zip
org.eclipse.osee-62cdeb9af32443a9a28cef8d51648bdc72322329.tar.gz
org.eclipse.osee-62cdeb9af32443a9a28cef8d51648bdc72322329.tar.bz2
refactor: Refactor for artifact import mechanism
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/io/xml/ExcelSaxHandler.java5
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/io/xml/RowProcessor.java2
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/ArtifactExtractorTest.java2
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/RoughArtifact.java3
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/operations/FilterArtifactTypesByAttributeTypes.java10
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/parsers/ExcelArtifactExtractor.java7
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorerDragAndDrop.java9
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactImportOperationFactory.java3
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactImportPage.java17
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactImportWizard.java65
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactImporter.java80
11 files changed, 123 insertions, 80 deletions
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/io/xml/ExcelSaxHandler.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/io/xml/ExcelSaxHandler.java
index 5f95bee..71c282a 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/io/xml/ExcelSaxHandler.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/io/xml/ExcelSaxHandler.java
@@ -11,8 +11,8 @@
package org.eclipse.osee.framework.jdk.core.util.io.xml;
import java.util.Arrays;
+
import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
/**
* @author Ryan D. Brooks
@@ -28,7 +28,6 @@ public class ExcelSaxHandler extends AbstractSaxHandler {
private boolean rowEmpty;
public ExcelSaxHandler(RowProcessor rowProcessor, boolean firstRowIsHeader, boolean enableMultiTableSupport) {
- super();
this.rowProcessor = rowProcessor;
this.firstRowIsHeader = firstRowIsHeader;
this.multiTable = enableMultiTableSupport;
@@ -40,7 +39,7 @@ public class ExcelSaxHandler extends AbstractSaxHandler {
}
@Override
- public void startElementFound(String uri, String localName, String qName, Attributes attributes) throws SAXException {
+ public void startElementFound(String uri, String localName, String qName, Attributes attributes) throws Exception {
if (localName.equalsIgnoreCase("Row")) {
cellIndex = -1; // so that upon finding the first cell start element the index becomes 0
rowEmpty = true;
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/io/xml/RowProcessor.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/io/xml/RowProcessor.java
index 63eb83c..c89ad1a 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/io/xml/RowProcessor.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/io/xml/RowProcessor.java
@@ -24,7 +24,7 @@ public interface RowProcessor {
public abstract void reachedEndOfWorksheet();
- public abstract void foundStartOfWorksheet(String sheetName);
+ public abstract void foundStartOfWorksheet(String sheetName) throws Exception;
public abstract void detectedRowAndColumnCounts(int rowCount, int columnCount);
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/ArtifactExtractorTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/ArtifactExtractorTest.java
index c75f0d4..c53724f 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/ArtifactExtractorTest.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/ArtifactExtractorTest.java
@@ -204,7 +204,6 @@ public class ArtifactExtractorTest {
private final String expectedData;
public ParseTestData(String message, String sourceData, String expectedData) {
- super();
this.message = message;
this.sourceData = sourceData;
this.expectedData = expectedData;
@@ -234,7 +233,6 @@ public class ArtifactExtractorTest {
private final boolean expected;
public TestData(String message, String file, boolean expected) {
- super();
this.message = message;
this.file = file;
this.expected = expected;
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/RoughArtifact.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/RoughArtifact.java
index f6943e8..5bd4f3f 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/RoughArtifact.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/RoughArtifact.java
@@ -15,7 +15,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
-
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
@@ -94,7 +93,7 @@ public class RoughArtifact {
}
public void addAttribute(String typeName, String value) {
- if (Strings.isValid(typeName) && Strings.isValid(value)) {
+ if (Strings.isValid(typeName, value)) {
if (isEnumeration(typeName)) {
if (isMultipleEnum(typeName, value)) {
attributes.addMultiple(typeName, getEnumValues(value));
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/operations/FilterArtifactTypesByAttributeTypes.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/operations/FilterArtifactTypesByAttributeTypes.java
index adc13fa..fd4b38c 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/operations/FilterArtifactTypesByAttributeTypes.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/operations/FilterArtifactTypesByAttributeTypes.java
@@ -55,12 +55,10 @@ public class FilterArtifactTypesByAttributeTypes extends AbstractOperation {
requiredTypes.add(AttributeTypeManager.getType(name));
}
Branch resolvedBranch = BranchManager.getBranch(branch);
- for (ArtifactType artifactType : ArtifactTypeManager.getValidArtifactTypes(resolvedBranch)) {
- if (!artifactType.isAbstract()) {
- Collection<IAttributeType> attributeTypes = artifactType.getAttributeTypes(resolvedBranch);
- if (Collections.setComplement(requiredTypes, attributeTypes).isEmpty()) {
- selectedArtifactTypes.add(artifactType);
- }
+ for (ArtifactType artifactType : ArtifactTypeManager.getConcreteArtifactTypes(resolvedBranch)) {
+ Collection<IAttributeType> attributeTypes = artifactType.getAttributeTypes(resolvedBranch);
+ if (Collections.setComplement(requiredTypes, attributeTypes).isEmpty()) {
+ selectedArtifactTypes.add(artifactType);
}
}
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/parsers/ExcelArtifactExtractor.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/parsers/ExcelArtifactExtractor.java
index 177e4bb..49e23aa 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/parsers/ExcelArtifactExtractor.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/parsers/ExcelArtifactExtractor.java
@@ -19,6 +19,7 @@ import java.util.Map;
import java.util.logging.Level;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
@@ -133,9 +134,8 @@ public class ExcelArtifactExtractor extends AbstractArtifactExtractor {
}
@Override
- public void foundStartOfWorksheet(String sheetName) {
+ public void foundStartOfWorksheet(String sheetName) throws OseeCoreException {
rowCount = 0;
- try {
if (sheetName.equals("relations")) {
importingRelations = true;
return;
@@ -144,9 +144,6 @@ public class ExcelArtifactExtractor extends AbstractArtifactExtractor {
if (primaryDescriptor == null) {
throw new OseeArgumentException("The sheet [%s] is not a valid artifact type name.", sheetName);
}
- } catch (OseeCoreException ex) {
- throw new IllegalArgumentException("The sheet [%s] is not a valid artifact type name: ", ex);
- }
}
@Override
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorerDragAndDrop.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorerDragAndDrop.java
index 7f9f38b..b755abd 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorerDragAndDrop.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/ArtifactExplorerDragAndDrop.java
@@ -24,6 +24,7 @@ import org.eclipse.osee.framework.skynet.core.artifact.ArtifactData;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.eclipse.osee.framework.ui.plugin.util.Wizards;
import org.eclipse.osee.framework.ui.skynet.Import.ArtifactImportWizard;
+import org.eclipse.osee.framework.ui.skynet.Import.ArtifactImporter;
import org.eclipse.osee.framework.ui.skynet.artifact.ArtifactTransfer;
import org.eclipse.osee.framework.ui.skynet.update.InterArtifactExplorerDropHandler;
import org.eclipse.osee.framework.ui.skynet.util.SkynetDragAndDrop;
@@ -147,14 +148,16 @@ public class ArtifactExplorerDragAndDrop extends SkynetDragAndDrop {
}
}
} else if (FileTransfer.getInstance().isSupportedType(event.currentDataType)) {
+
Object object = FileTransfer.getInstance().nativeToJava(event.currentDataType);
+
if (object instanceof String[]) {
String filename = ((String[]) object)[0];
- ArtifactImportWizard wizard = new ArtifactImportWizard();
- wizard.setImportResourceAndArtifactDestination(new File(filename), parentArtifact);
+ ArtifactImportWizard wizard =
+ new ArtifactImportWizard(new ArtifactImporter(new File(filename), parentArtifact));
- Wizards.initAndOpen(wizard, viewPart);
+ Wizards.initAndOpen(wizard, viewPart, new ArtifactStructuredSelection(parentArtifact));
}
}
}
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 80a26e6..5dc3357 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
@@ -94,6 +94,7 @@ public final class ArtifactImportOperationFactory {
List<IOperation> ops = new ArrayList<IOperation>();
ops.add(new RoughToRealArtifactOperation(transaction, destinationArtifact, collector, resolver,
deleteUnmatchedArtifacts));
+
final List<Artifact> children = new ArrayList<Artifact>();
AbstractOperation operation = new AbstractOperation("Fetch Descendants", SkynetGuiPlugin.PLUGIN_ID) {
@Override
@@ -110,9 +111,11 @@ public final class ArtifactImportOperationFactory {
throw new Exception(String.format(message, arg1, arg2), ex);
}
};
+
ops.add(operation);
ops.add(new ArtifactValidationCheckOperation(children, stopOnError));
ops.add(new CompleteArtifactImportOperation(transaction, destinationArtifact));
+
return new CompositeOperation(opName, SkynetGuiPlugin.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/ArtifactImportPage.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactImportPage.java
index 645fd40..a817df0 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactImportPage.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactImportPage.java
@@ -27,6 +27,7 @@ import org.eclipse.osee.framework.core.model.type.ArtifactType;
import org.eclipse.osee.framework.core.operation.IOperation;
import org.eclipse.osee.framework.core.operation.OperationLogger;
import org.eclipse.osee.framework.core.operation.Operations;
+import org.eclipse.osee.framework.core.util.Conditions;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
@@ -71,7 +72,7 @@ public class ArtifactImportPage extends WizardDataTransferPage {
private static final String PAGE_NAME = "osee.define.wizardPage.artifactImportPage";
private DirectoryOrFileSelector directoryFileSelector;
- private File defaultSourceFile;
+ private final File defaultSourceFile;
private Button updateExistingArtifacts;
private Button updateByGuid;
private Button deleteUnmatchedArtifacts;
@@ -87,7 +88,7 @@ public class ArtifactImportPage extends WizardDataTransferPage {
private static StringBuilder operationReportMessages;
- protected ArtifactImportPage() {
+ protected ArtifactImportPage(ArtifactImporter importer) {
super(PAGE_NAME);
selectedArtifactTypes = new ArrayList<IArtifactType>();
selectionLatch = new SelectionLatch();
@@ -96,6 +97,8 @@ public class ArtifactImportPage extends WizardDataTransferPage {
artifactSelectPanel.setDialogTitle("Select Destination Artifact");
artifactSelectPanel.setDialogMessage("Select a destination artifact. Imported items will be added as children of the selected artifact.");
+ artifactSelectPanel.setDefaultItem(importer.getDestinationArtifact());
+
artifactTypeSelectPanel = new ArtifactTypeSelectPanel();
artifactTypeSelectPanel.setDialogTitle("Import as Artifact Type");
artifactTypeSelectPanel.setDialogMessage("Select what artifact type data should be imported as.");
@@ -113,16 +116,13 @@ public class ArtifactImportPage extends WizardDataTransferPage {
operationReportMessages = new StringBuilder();
+ this.defaultSourceFile = importer.getFile();
}
public RoughArtifactCollector getCollectedArtifacts() {
return collector;
}
- public void setDefaultSourceFile(File resource) {
- defaultSourceFile = resource;
- }
-
public void setDefaultDestinationArtifact(Artifact destinationArtifact) {
artifactSelectPanel.setDefaultItem(destinationArtifact);
}
@@ -369,7 +369,7 @@ public class ArtifactImportPage extends WizardDataTransferPage {
String guid = settings.get("destination.artifact.guid");
String branch = settings.get("destination.branch.guid");
- if (Strings.isValid(guid) && Strings.isValid(branch)) {
+ if (Strings.isValid(guid, branch)) {
try {
Artifact artifact = ArtifactQuery.getArtifactFromId(guid, BranchManager.getBranchByGuid(branch));
artifactSelectPanel.setDefaultItem(artifact);
@@ -502,6 +502,7 @@ public class ArtifactImportPage extends WizardDataTransferPage {
}
return true;
}
+
private static final class SelectionLatch {
protected final SelectionData lastSelected;
protected final SelectionData currentSelected;
@@ -546,7 +547,7 @@ public class ArtifactImportPage extends WizardDataTransferPage {
}
public boolean isValid() {
- return destinationArtifact != null && sourceFile != null && extractor != null && (extractor.isDelegateRequired() ? extractor.hasDelegate() : true);
+ return Conditions.notNull(destinationArtifact, sourceFile, extractor) && (extractor.isDelegateRequired() ? extractor.hasDelegate() : true);
}
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactImportWizard.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactImportWizard.java
index 39b4f6c..a4bc1bd 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactImportWizard.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactImportWizard.java
@@ -10,17 +10,8 @@
*******************************************************************************/
package org.eclipse.osee.framework.ui.skynet.Import;
-import java.io.File;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.osee.framework.core.operation.IOperation;
-import org.eclipse.osee.framework.core.operation.Operations;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.importing.operations.RoughArtifactCollector;
import org.eclipse.osee.framework.skynet.core.importing.resolvers.IArtifactImportResolver;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.ui.IImportWizard;
@@ -30,70 +21,44 @@ import org.eclipse.ui.IWorkbench;
* @author Roberto E. Escobar
*/
public class ArtifactImportWizard extends Wizard implements IImportWizard {
- private File importResource;
- private Artifact defaultDestinationArtifact;
+
private ArtifactImportPage mainPage;
+ private final ArtifactImporter importer;
public ArtifactImportWizard() {
- super();
+ this(new ArtifactImporter());
+ }
+
+ public ArtifactImportWizard(ArtifactImporter importer) {
+ this.importer = importer;
setDialogSettings(SkynetGuiPlugin.getInstance().getDialogSettings());
setWindowTitle("OSEE Artifact Import Wizard");
setNeedsProgressMonitor(true);
setHelpAvailable(true);
}
- public void setImportResourceAndArtifactDestination(File importResource, Artifact defaultDestinationArtifact) {
- Assert.isNotNull(importResource);
- Assert.isNotNull(defaultDestinationArtifact);
-
- this.importResource = importResource;
- this.defaultDestinationArtifact = defaultDestinationArtifact;
- }
-
@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
- if (importResource == null && defaultDestinationArtifact == null) {
- if (selection != null && selection.size() == 1) {
- Object firstElement = selection.getFirstElement();
- if (firstElement instanceof IAdaptable) {
- Object resource = ((IAdaptable) firstElement).getAdapter(IResource.class);
- if (resource instanceof IResource) {
- importResource = ((IResource) resource).getLocation().toFile();
- }
- }
- if (firstElement instanceof Artifact) {
- defaultDestinationArtifact = (Artifact) firstElement;
- }
- }
+ if (selection != null && !selection.isEmpty()) {
+ Object firstElement = selection.getFirstElement();
+ importer.setInputResource(firstElement);
}
}
@Override
public void addPages() {
- mainPage = new ArtifactImportPage();
- mainPage.setDefaultDestinationArtifact(defaultDestinationArtifact);
- mainPage.setDefaultSourceFile(importResource);
+ mainPage = new ArtifactImportPage(importer);
addPage(mainPage);
}
@Override
public boolean performFinish() {
- final Artifact destinationArtifact = mainPage.getDestinationArtifact();
- final boolean isDeleteUnmatchedSelected = mainPage.isDeleteUnmatchedSelected();
- final RoughArtifactCollector roughItems = mainPage.getCollectedArtifacts();
- final IArtifactImportResolver resolver = getResolver();
-
- final String opName = String.format("Importing Artifacts onto: [%s]", destinationArtifact);
- IOperation operation =
- ArtifactImportOperationFactory.createRoughToRealOperation(opName, destinationArtifact, resolver, false,
- roughItems, isDeleteUnmatchedSelected);
- Job job = Operations.executeAsJob(operation, true);
- return job != null;
+ return importer.startImportJob(mainPage.getDestinationArtifact(), mainPage.isDeleteUnmatchedSelected(),
+ mainPage.getCollectedArtifacts(), getResolver());
}
private IArtifactImportResolver getResolver() {
- MatchingStrategy strategy = mainPage.getMatchingStrategy();
- return strategy.getResolver(mainPage.getArtifactType(), mainPage.getNonChangingAttributes(), true,
- mainPage.isDeleteUnmatchedSelected());
+ return mainPage.getMatchingStrategy().getResolver(mainPage.getArtifactType(),
+ mainPage.getNonChangingAttributes(), true, mainPage.isDeleteUnmatchedSelected());
}
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactImporter.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactImporter.java
new file mode 100644
index 0000000..6ce8721
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactImporter.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * 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.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.osee.framework.core.operation.IOperation;
+import org.eclipse.osee.framework.core.operation.Operations;
+import org.eclipse.osee.framework.core.util.Conditions;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.importing.operations.RoughArtifactCollector;
+import org.eclipse.osee.framework.skynet.core.importing.resolvers.IArtifactImportResolver;
+
+/**
+ * Facilitates importing of artifacts with {@link ArtifactImportWizard }. <br/>
+ * Refer to {@link ArtifactImporter.initialized()} to determine if importer has been properly setup.
+ *
+ * @author Karol M Wilk
+ */
+public final class ArtifactImporter {
+
+ private File importResource;
+ private Artifact defaultDestinationArtifact;
+
+ public ArtifactImporter() {
+ this(null, null);
+ }
+
+ public ArtifactImporter(File importResource, Artifact defaultDestinationArtifact) {
+ this.importResource = importResource;
+ this.defaultDestinationArtifact = defaultDestinationArtifact;
+ }
+
+ public boolean initialized() {
+ return Conditions.notNull(importResource, defaultDestinationArtifact);
+ }
+
+ public void setInputResource(Object firstElement) {
+ if (firstElement instanceof IAdaptable) {
+ Object resource = ((IAdaptable) firstElement).getAdapter(IResource.class);
+ if (resource instanceof IResource) {
+ importResource = ((IResource) resource).getLocation().toFile();
+ }
+ }
+ if (firstElement instanceof Artifact) {
+ defaultDestinationArtifact = (Artifact) firstElement;
+ }
+ }
+
+ public Artifact getDestinationArtifact() {
+ return defaultDestinationArtifact;
+ }
+
+ public File getFile() {
+ return importResource;
+ }
+
+ public boolean startImportJob(Artifact finalDestinationArtifact, boolean isDeleteUnmatchedSelected, RoughArtifactCollector roughItems, IArtifactImportResolver resolver) {
+ boolean initialized = initialized();
+ if (initialized) {
+ defaultDestinationArtifact = finalDestinationArtifact;
+
+ final String opName = String.format("Importing Artifacts onto: [%s]", defaultDestinationArtifact);
+ IOperation operation =
+ ArtifactImportOperationFactory.createRoughToRealOperation(opName, defaultDestinationArtifact, resolver,
+ false, roughItems, isDeleteUnmatchedSelected);
+ Operations.executeAsJob(operation, true);
+ }
+ return initialized;
+ }
+}