Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan G. Rader2014-11-04 22:23:51 +0000
committerDonald Dunne2014-11-11 16:52:43 +0000
commitc6c30041e16355759c6c88b106ac3100600ab169 (patch)
tree919db7b1a760f87f1b034f78020a076ea5c202ee
parent8363de34b6993626d2e52d2cf3880f5bc169b4db (diff)
downloadorg.eclipse.osee-c6c30041e16355759c6c88b106ac3100600ab169.tar.gz
org.eclipse.osee-c6c30041e16355759c6c88b106ac3100600ab169.tar.xz
org.eclipse.osee-c6c30041e16355759c6c88b106ac3100600ab169.zip
refinement[ats_ATS124279]: Update Import Trace Units
Change-Id: I4228d25530aef326269ec875a78866d101077c53 Signed-off-by: Ryan G. Rader <ryan.rader@boeing.com>
-rw-r--r--plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/define/ImportTraceUnitsOperationTest.java124
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/DataRightsImporter.java6
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/HierarchyHandler.java131
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/importer/ImportTraceUnitPage.java14
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/importer/ImportTraceUnitWizard.java4
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/ImportTraceUnitsOperation.java8
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceResourceDropOperation.java7
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitFromResourceOperation.java12
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitToArtifactProcessor.java15
9 files changed, 203 insertions, 118 deletions
diff --git a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/define/ImportTraceUnitsOperationTest.java b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/define/ImportTraceUnitsOperationTest.java
index 8fac41cc8c3..bf9f100e605 100644
--- a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/define/ImportTraceUnitsOperationTest.java
+++ b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/define/ImportTraceUnitsOperationTest.java
@@ -18,6 +18,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.osee.client.demo.DemoTraceability;
import org.eclipse.osee.client.test.framework.OseeClientIntegrationRule;
import org.eclipse.osee.client.test.framework.OseeLogMonitorRule;
@@ -32,7 +33,6 @@ import org.eclipse.osee.framework.core.operation.IOperation;
import org.eclipse.osee.framework.core.operation.Operations;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Compare;
-import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
@@ -61,24 +61,43 @@ public final class ImportTraceUnitsOperationTest {
@Rule
public TemporaryFolder tempFolder = new TemporaryFolder();
+ private static final String topLevelFolderName = "topLevelFolder";
+
+ private static final String TEST_ONE_FOLDER_NAME = "abc.ss";
+ private static final String TEST_TWO_FOLDER_NAME = "def.ss";
+ private static final String TEST_THREE_FOLDER_NAME = "ryan.ss";
+ private static final String TEST_FOUR_FOLDER_NAME = "jason.ss";
+ private static final String TEST_FIVE_FOLDER_NAME = "megumi.ss";
private static final String TEST_ONE_FILE = "ImportTraceUnitsTest1.txt";
private static final String TEST_TWO_FILE = "ImportTraceUnitsTest2.txt";
private static final String TEST_THREE_FILE = "ImportTraceUnitsTest3.txt";
private static final String TEST_FOUR_FILE = "ImportTraceUnitsTest4.txt";
private static final String TEST_FIVE_FILE = "ImportTraceUnitsTest5.txt";
+
private static final int RUNS = 3;
+ private final String[] fileNames = {TEST_ONE_FILE, TEST_TWO_FILE, TEST_THREE_FILE, TEST_FOUR_FILE, TEST_FIVE_FILE};
+ private final String[] folderNames = {
+ TEST_ONE_FOLDER_NAME,
+ TEST_TWO_FOLDER_NAME,
+ TEST_THREE_FOLDER_NAME,
+ TEST_FOUR_FOLDER_NAME,
+ TEST_FIVE_FOLDER_NAME};
+
private static final List<String> expectedReqs = Arrays.asList("Robot Object", "Haptic Constraints",
"Robot Interfaces", "Individual robot events", "Collaborative Robot");
private IOseeBranch branch;
private Branch importToBranch;
+ private File testFile;
@Before
public void setup() throws Exception {
- branch = TokenFactory.createBranch( testInfo.getQualifiedTestName());
+ branch = TokenFactory.createBranch(testInfo.getQualifiedTestName());
importToBranch = BranchManager.createWorkingBranch(SAW_Bld_1, branch);
+
+ setupDirectoryStructure();
}
@After
@@ -90,81 +109,80 @@ public final class ImportTraceUnitsOperationTest {
@Test
public void testImportTraceUnitsJob() throws Exception {
- URI mockURI1 = getMockFile(TEST_ONE_FILE, "some text");
- URI mockURI2 = getMockFile(TEST_TWO_FILE, "some text");
ArrayList<Integer> gammas = new ArrayList<Integer>(RUNS);
for (int i = 0; i < RUNS; i++) {
- runOperation(Arrays.asList(mockURI1));
+ runOperation(Arrays.asList(testFile.toURI()));
- Artifact artifact =
- ArtifactQuery.getArtifactFromTypeAndName(CoreArtifactTypes.CodeUnit, TEST_ONE_FILE, importToBranch);
- Assert.assertNotNull(artifact);
+ for (int j = 0; j < fileNames.length; j++) {
+ Artifact artifact =
+ ArtifactQuery.getArtifactFromTypeAndName(CoreArtifactTypes.CodeUnit, fileNames[j], importToBranch);
+ Assert.assertNotNull(artifact);
- Integer gamma = artifact.getGammaId();
- if (!gammas.contains(gamma)) {
- gammas.add(gamma);
- }
+ Integer gamma = artifact.getGammaId();
+ if (!gammas.contains(gamma)) {
+ gammas.add(gamma);
+ }
- Assert.assertEquals("Code Units", artifact.getParent().getName());
+ Assert.assertEquals("Code Units", artifact.getParent().getName());
- List<Artifact> reqArtifacts = artifact.getRelatedArtifacts(CoreRelationTypes.CodeRequirement_Requirement);
- Assert.assertEquals(5, reqArtifacts.size());
+ List<Artifact> reqArtifacts = artifact.getRelatedArtifacts(CoreRelationTypes.CodeRequirement_Requirement);
+ Assert.assertEquals(5, reqArtifacts.size());
- Collection<String> actual = Artifacts.getNames(reqArtifacts);
+ Collection<String> actual = Artifacts.getNames(reqArtifacts);
- Assert.assertFalse(Compare.isDifferent(expectedReqs, actual));
+ Assert.assertFalse(Compare.isDifferent(expectedReqs, actual));
+ }
}
- // make sure multiple artifacts were not created
- Assert.assertEquals(1, gammas.size());
-
- // create a 2nd artifact
- runOperation(Arrays.asList(mockURI2));
- Artifact artifact =
- ArtifactQuery.getArtifactFromTypeAndName(CoreArtifactTypes.CodeUnit, TEST_TWO_FILE, importToBranch);
- Assert.assertNotNull(artifact);
- // make sure a new artifact was created
- Assert.assertFalse(gammas.contains(artifact.getGammaId()));
}
- @Test
- public void testMultipleUris() throws Exception {
- URI mockURI3 = getMockFile(TEST_THREE_FILE, "some text");
- URI mockURI4 = getMockFile(TEST_FOUR_FILE, "some text");
- URI mockURI5 = getMockFile(TEST_FIVE_FILE, "some text");
-
- Iterable<URI> uris = Arrays.asList(mockURI3, mockURI4, mockURI5);
- runOperation(uris);
-
- for (String fileName : Arrays.asList(TEST_THREE_FILE, TEST_FOUR_FILE, TEST_FIVE_FILE)) {
- Artifact artifact =
- ArtifactQuery.getArtifactFromTypeAndName(CoreArtifactTypes.CodeUnit, fileName, importToBranch);
- Assert.assertNotNull(artifact);
- List<Artifact> reqArtifacts = artifact.getRelatedArtifacts(CoreRelationTypes.CodeRequirement_Requirement);
- Assert.assertEquals(5, reqArtifacts.size());
-
- Collection<String> actual = Artifacts.getNames(reqArtifacts);
-
- Assert.assertFalse(Compare.isDifferent(expectedReqs, actual));
+ private void setupDirectoryStructure() throws Exception {
+ File topLevelFolder = new File(tempFolder.getRoot().getAbsolutePath() + IPath.SEPARATOR + topLevelFolderName);
+ if (!topLevelFolder.exists()) {
+ tempFolder.newFolder(topLevelFolderName);
+ }
+ for (String folderName : folderNames) {
+ File tempFile =
+ new File(
+ tempFolder.getRoot().getAbsolutePath() + IPath.SEPARATOR + topLevelFolderName + IPath.SEPARATOR + folderName);
+ if (!tempFile.exists()) {
+ tempFolder.newFolder(topLevelFolderName + IPath.SEPARATOR + folderName);
+ }
+ }
+ for (int i = 0; i < fileNames.length; i++) {
+ File codeUnitFile =
+ new File(
+ tempFolder.getRoot().getAbsolutePath() + IPath.SEPARATOR + topLevelFolderName + IPath.SEPARATOR + folderNames[i] + IPath.SEPARATOR + fileNames[i]);
+ if (!codeUnitFile.exists()) {
+ codeUnitFile.createNewFile();
+ Lib.writeStringToFile("Dummy String", codeUnitFile);
+ }
}
- }
+ testFile = new File(tempFolder.getRoot().getAbsolutePath() + IPath.SEPARATOR + "testFile.txt");
+ if (!testFile.exists()) {
+ testFile.createNewFile();
+ }
- private URI getMockFile(String fileName, String text) throws Exception {
- File testFile = tempFolder.newFile(fileName);
- Lib.writeStringToFile(text, testFile);
- return testFile.toURI();
+ String pathNames = "";
+ for (String folderName : folderNames) {
+ Lib.writeStringToFile(
+ pathNames + tempFolder.getRoot().getAbsolutePath() + IPath.SEPARATOR + topLevelFolderName + IPath.SEPARATOR + folderName + "\n",
+ testFile);
+ pathNames = Lib.fileToString(testFile);
+ }
}
private void runOperation(Iterable<URI> files) throws OseeCoreException {
boolean isRecursive = false;
boolean isPersistChanges = true;
- boolean fileWithMultiPaths = false;
+ boolean fileWithMultiPaths = true;
+ boolean addGuidToSourceFile = false;
IOperation op =
new ImportTraceUnitsOperation("Import Trace Units", importToBranch, files, isRecursive, isPersistChanges,
- fileWithMultiPaths, DemoTraceability.DEMO_TRACE_UNIT_HANDLER_ID);
+ fileWithMultiPaths, addGuidToSourceFile, DemoTraceability.DEMO_TRACE_UNIT_HANDLER_ID);
Operations.executeWorkAndCheckStatus(op);
}
}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/DataRightsImporter.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/DataRightsImporter.java
index 72b7d1ad20a..68e837b8f41 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/DataRightsImporter.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/DataRightsImporter.java
@@ -137,13 +137,13 @@ public class DataRightsImporter extends AbstractBlam {
String dataRightsClassification = row[dataRightsIndex];
String fileName = row[fileNameIndex];
String dataRightsBasis = row[dataRightsBasisIndex];
- if (Strings.isValid(SME)) {
+ if (!Strings.isValid(SME)) {
SME = "Unspecified";
}
- if (Strings.isValid(dataRightsClassification)) {
+ if (!Strings.isValid(dataRightsClassification)) {
dataRightsClassification = "Unspecified";
}
- if (Strings.isValid(dataRightsBasis)) {
+ if (!Strings.isValid(dataRightsBasis)) {
dataRightsBasis = "Unspecified";
}
try {
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/HierarchyHandler.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/HierarchyHandler.java
index a28686de234..cc6420ebc00 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/HierarchyHandler.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/HierarchyHandler.java
@@ -10,12 +10,20 @@
*******************************************************************************/
package org.eclipse.osee.define.traceability;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
-import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.skynet.core.OseeSystemArtifacts;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.eclipse.osee.framework.skynet.core.utility.Requirements;
@@ -23,80 +31,115 @@ import org.eclipse.osee.framework.skynet.core.utility.Requirements;
* @author Roberto E. Escobar
*/
public final class HierarchyHandler {
+ private static final Matcher subsystemMatcher = Pattern.compile("(\\w*)\\.ss").matcher("");
+ private final Map<String, Artifact> folderNameToArtifact = new HashMap<String, Artifact>(50);
+ private final SkynetTransaction transaction;
- public static void addArtifact(SkynetTransaction transaction, Artifact testUnit) throws OseeCoreException {
+ public HierarchyHandler(SkynetTransaction transaction) {
+ this.transaction = transaction;
+ }
+
+ public void addArtifact(Artifact testUnit) throws OseeCoreException {
Artifact folder = null;
+
Branch branch = testUnit.getFullBranch();
if (testUnit.isOfType(CoreArtifactTypes.TestCase)) {
- folder = getOrCreateTestCaseFolder(transaction, branch);
+ folder = getOrCreateTestCaseFolder(branch);
} else if (testUnit.isOfType(CoreArtifactTypes.TestSupport)) {
- folder = getOrCreateTestSupportFolder(transaction, branch);
+ folder = getOrCreateTestSupportFolder(branch);
} else if (testUnit.isOfType(CoreArtifactTypes.CodeUnit)) {
- folder = getOrCreateCodeUnitFolder(transaction, branch);
+ folder = getOrCreateCodeUnitFolder(branch, testUnit.getName());
} else {
- folder = getOrCreateUnknownTestUnitFolder(transaction, branch);
+ folder = getOrCreateUnknownTestUnitFolder(branch);
}
- if (folder != null && !folder.isRelated(CoreRelationTypes.Default_Hierarchical__Child, testUnit)) {
- folder.addChild(testUnit);
- persistHelper(transaction, folder);
- }
+ addChildIfNotRelated(folder, testUnit);
}
- private static Artifact getOrCreateUnknownTestUnitFolder(SkynetTransaction transaction, Branch branch) throws OseeCoreException {
- return getOrCreateTestUnitSubFolder(transaction, branch, "Unknown Test Unit Type");
+ private Artifact getOrCreateUnknownTestUnitFolder(Branch branch) throws OseeCoreException {
+ return getOrCreateTestUnitsFolder(branch, "Unknown Test Unit Type", true);
}
- private static Artifact getOrCreateTestSupportFolder(SkynetTransaction transaction, Branch branch) throws OseeCoreException {
- return getOrCreateTestUnitSubFolder(transaction, branch, Requirements.TEST_SUPPORT_UNITS);
+ private Artifact getOrCreateTestSupportFolder(Branch branch) throws OseeCoreException {
+ return getOrCreateTestUnitsFolder(branch, Requirements.TEST_SUPPORT_UNITS, true);
}
- private static Artifact getOrCreateTestCaseFolder(SkynetTransaction transaction, Branch branch) throws OseeCoreException {
- return getOrCreateTestUnitSubFolder(transaction, branch, "Test Cases");
+ private Artifact getOrCreateTestCaseFolder(Branch branch) throws OseeCoreException {
+ return getOrCreateTestUnitsFolder(branch, "Test Cases", true);
}
- private static Artifact getOrCreateCodeUnitFolder(SkynetTransaction transaction, Branch branch) throws OseeCoreException {
- Artifact codeUnitFolder = getOrCreateFolder(branch, "Code Units");
+ private Artifact getOrCreateCodeUnitFolder(Branch branch, String codeUnitName) throws OseeCoreException {
Artifact root = OseeSystemArtifacts.getDefaultHierarchyRootArtifact(branch);
- if (!root.isRelated(CoreRelationTypes.Default_Hierarchical__Child, codeUnitFolder)) {
- root.addChild(codeUnitFolder);
- persistHelper(transaction, root);
- }
- return codeUnitFolder;
- }
+ Artifact toReturn = getOrCreateFolder(branch, "Code Units", root);
- private static Artifact getOrCreateTestUnitSubFolder(SkynetTransaction transaction, Branch branch, String folderName) throws OseeCoreException {
- Artifact subFolder = getOrCreateFolder(branch, folderName);
- Artifact testUnits = getOrCreateTestUnitsFolder(transaction, branch);
- if (!testUnits.isRelated(CoreRelationTypes.Default_Hierarchical__Child, subFolder)) {
- testUnits.addChild(subFolder);
- persistHelper(transaction, testUnits);
+ String subSystem;
+ subsystemMatcher.reset(codeUnitName);
+ if (subsystemMatcher.find()) {
+ subSystem = subsystemMatcher.group(1);
+ subSystem = subSystem.toUpperCase();
+ toReturn = getOrCreateFolder(branch, subSystem, toReturn);
}
- return subFolder;
+
+ return toReturn;
}
- private static Artifact getOrCreateTestUnitsFolder(SkynetTransaction transaction, Branch branch) throws OseeCoreException {
- Artifact testFolder = getOrCreateFolder(branch, "Test");
- Artifact testUnitFolder = getOrCreateFolder(branch, "Test Units");
+ private Artifact getOrCreateTestUnitsFolder(Branch branch, String subfolderName, boolean includesSubfolder) throws OseeCoreException {
Artifact root = OseeSystemArtifacts.getDefaultHierarchyRootArtifact(branch);
- if (!root.isRelated(CoreRelationTypes.Default_Hierarchical__Child, testFolder)) {
- root.addChild(testFolder);
- persistHelper(transaction, root);
- }
- if (!testFolder.isRelated(CoreRelationTypes.Default_Hierarchical__Child, testUnitFolder)) {
- testFolder.addChild(testUnitFolder);
- persistHelper(transaction, testFolder);
+ Artifact testFolder = getOrCreateFolder(branch, "Test", root);
+ addChildIfNotRelated(root, testFolder);
+ Artifact testUnitFolder = getOrCreateFolder(branch, "Test Units", testFolder);
+ addChildIfNotRelated(testFolder, testUnitFolder);
+
+ if (subfolderName != null && includesSubfolder) {
+ Artifact subFolder = getOrCreateFolder(branch, subfolderName, testFolder);
+ addChildIfNotRelated(testFolder, subFolder);
+ return subFolder;
}
return testUnitFolder;
}
- private static void persistHelper(SkynetTransaction transaction, Artifact toPersist) throws OseeCoreException {
+ private void persistHelper(Artifact toPersist) throws OseeCoreException {
if (transaction != null) {
toPersist.persist(transaction);
}
}
- private static Artifact getOrCreateFolder(Branch branch, String folderName) throws OseeCoreException {
- return OseeSystemArtifacts.getOrCreateArtifact(CoreArtifactTypes.Folder, folderName, branch);
+ private void addChildIfNotRelated(Artifact parentFolder, Artifact childFolder) {
+ Collection<Artifact> toCheck = new LinkedList<Artifact>();
+ if (parentFolder.isOfType(CoreArtifactTypes.RootArtifact)) {
+ toCheck.addAll(parentFolder.getChildren());
+ } else {
+ toCheck.addAll(parentFolder.getDescendants());
+ }
+ if (!toCheck.contains(childFolder)) {
+ parentFolder.addChild(childFolder);
+ persistHelper(parentFolder);
+ }
+ }
+
+ private Artifact getOrCreateFolder(Branch branch, String folderName, Artifact parentFolder) throws OseeCoreException {
+ Artifact toReturn = folderNameToArtifact.get(folderName);
+ if (toReturn == null) {
+ List<Artifact> relatedFolders =
+ ArtifactQuery.getArtifactListFromTypeAndName(CoreArtifactTypes.Folder, folderName, branch);
+ if (relatedFolders.size() == 1) {
+ toReturn = relatedFolders.iterator().next();
+ } else if (relatedFolders.size() > 1) {
+ List<Artifact> descendants = parentFolder.getDescendants();
+ for (Artifact folder : relatedFolders) {
+ if (descendants.contains(folder)) {
+ toReturn = folder;
+ break;
+ }
+ }
+ }
+ if (toReturn == null) {
+ toReturn = ArtifactTypeManager.addArtifact(CoreArtifactTypes.Folder, branch, folderName);
+ addChildIfNotRelated(parentFolder, toReturn);
+ toReturn.persist(transaction);
+ }
+ folderNameToArtifact.put(folderName, toReturn);
+ }
+ return toReturn;
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/importer/ImportTraceUnitPage.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/importer/ImportTraceUnitPage.java
index 6f3819f5c6a..c6e4f56da1a 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/importer/ImportTraceUnitPage.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/importer/ImportTraceUnitPage.java
@@ -80,6 +80,10 @@ public class ImportTraceUnitPage extends WizardDataTransferPage {
private static final String FILE_WITH_PATHS_TOOLTIP =
"Select when using a source file with multiple paths separated with newlines.";
+ private static final String ADD_GUID_TO_SOURCE_FILE_BUTTON = "Add GUID to Source";
+ private static final String ADD_GUID_TO_SOURCE_FILE_TOOLTIP =
+ "When selected, the GUID will be added to the source file. Note: You will need write access to the files to use this selection.";
+
private static final String SELECTED_TRACE_HANDLERS_KEY = "trace.handlers";
private static final String BRANCH_KEY = "branch.selected";
private static final String SOURCE_URI_KEY = "source.uri";
@@ -87,6 +91,7 @@ public class ImportTraceUnitPage extends WizardDataTransferPage {
private static final String IS_ART_PERSIST_ALLOWED_KEY = "is.art.persist.allowed";
private static final String IS_FOLDER_RECURSION_KEY = "is.folder.recurse.allowed";
private static final String IS_FILE_WITH_MULTI_PATHS_KEY = "is.file.with.multi.paths";
+ private static final String IS_ADD_GUID_TO_SOURCE_KEY = "is.add.guid.to.source";
private DirectoryOrFileSelector directoryFileSelector;
private BranchSelectComposite branchSelectComposite;
@@ -94,6 +99,7 @@ public class ImportTraceUnitPage extends WizardDataTransferPage {
private final MutableBoolean isArtifactPersistanceAllowed;
private List<IResource> currentResourceSelection;
private final MutableBoolean isFileContainingMultiplePaths;
+ private final MutableBoolean isAddGuidToSourceFileAllowed;
private final Map<Button, Boolean> traceUnitHandlers;
private final Map<String, Button> optionButtons;
@@ -107,6 +113,7 @@ public class ImportTraceUnitPage extends WizardDataTransferPage {
this.isFolderRecursionAllowed = new MutableBoolean(false);
this.isArtifactPersistanceAllowed = new MutableBoolean(false);
this.isFileContainingMultiplePaths = new MutableBoolean(false);
+ this.isAddGuidToSourceFileAllowed = new MutableBoolean(true);
if (selection != null && selection.size() >= 1) {
currentResourceSelection = new LinkedList<IResource>();
@@ -265,6 +272,8 @@ public class ImportTraceUnitPage extends WizardDataTransferPage {
isFolderRecursionAllowed);
createOptionButton(composite, IS_FILE_WITH_MULTI_PATHS_KEY, FILE_WITH_PATHS_BUTTON, FILE_WITH_PATHS_TOOLTIP,
isFileContainingMultiplePaths);
+ createOptionButton(composite, IS_ADD_GUID_TO_SOURCE_KEY, ADD_GUID_TO_SOURCE_FILE_BUTTON,
+ ADD_GUID_TO_SOURCE_FILE_TOOLTIP, isAddGuidToSourceFileAllowed);
}
private void createOptionButton(Composite parent, String buttonId, String buttonText, String buttonToolTip, final MutableBoolean toModify) {
@@ -353,6 +362,10 @@ public class ImportTraceUnitPage extends WizardDataTransferPage {
return isWidgetAccessible(directoryFileSelector) ? !directoryFileSelector.isDirectorySelected() && isFileContainingMultiplePaths.getValue() : isFileContainingMultiplePaths.getValue();
}
+ public boolean isAddGuidToSourceFileAllowed() {
+ return isAddGuidToSourceFileAllowed.getValue();
+ }
+
public String[] getTraceUnitHandlerIds() {
List<String> selectedIds = new ArrayList<String>();
for (Button button : traceUnitHandlers.keySet()) {
@@ -443,6 +456,7 @@ public class ImportTraceUnitPage extends WizardDataTransferPage {
settings.put(IS_ART_PERSIST_ALLOWED_KEY, isArtifactPersistanceAllowed());
settings.put(IS_FOLDER_RECURSION_KEY, isFolderRecursionAllowed());
settings.put(IS_FILE_WITH_MULTI_PATHS_KEY, isFileContainingMultiplePaths());
+ settings.put(IS_ADD_GUID_TO_SOURCE_KEY, isAddGuidToSourceFileAllowed());
}
}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/importer/ImportTraceUnitWizard.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/importer/ImportTraceUnitWizard.java
index c3f284b89b8..6b7767135d3 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/importer/ImportTraceUnitWizard.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/importer/ImportTraceUnitWizard.java
@@ -44,10 +44,10 @@ public class ImportTraceUnitWizard extends Wizard implements IImportWizard {
Iterable<URI> sources = page.getSourceURI();
String[] traceUnitHandlerIds = page.getTraceUnitHandlerIds();
boolean fileWithMultiPaths = page.isFileContainingMultiplePaths();
-
+ boolean addGuidToSourceFile = page.isAddGuidToSourceFileAllowed();
IOperation op =
new ImportTraceUnitsOperation("Import Trace Units", importToBranch, sources, isRecursive, isPersistChanges,
- fileWithMultiPaths, traceUnitHandlerIds);
+ fileWithMultiPaths, addGuidToSourceFile, traceUnitHandlerIds);
Operations.executeAsJob(op, true);
page.saveWidgetValues();
} catch (Exception ex) {
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/ImportTraceUnitsOperation.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/ImportTraceUnitsOperation.java
index 3e3b3906ff4..78d5230da98 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/ImportTraceUnitsOperation.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/ImportTraceUnitsOperation.java
@@ -28,16 +28,18 @@ public class ImportTraceUnitsOperation extends AbstractOperation {
private final boolean isRecursive;
private final boolean isPersistChanges;
private final boolean fileWithMultiPaths;
+ private final boolean addGuidToSourceFile;
private final Iterable<URI> sources;
private final String[] traceTypeIds;
- public ImportTraceUnitsOperation(String jobName, IOseeBranch importToBranch, Iterable<URI> sources, boolean isRecursive, boolean isPersistChanges, boolean fileWithMultiPaths, String... traceHandlerIds) {
+ public ImportTraceUnitsOperation(String jobName, IOseeBranch importToBranch, Iterable<URI> sources, boolean isRecursive, boolean isPersistChanges, boolean fileWithMultiPaths, boolean addGuidToSourceFile, String... traceHandlerIds) {
super("ImportTraceUnitsOperation", Activator.PLUGIN_ID);
this.importToBranch = importToBranch;
this.sources = sources;
this.isRecursive = isRecursive;
this.isPersistChanges = isPersistChanges;
this.fileWithMultiPaths = fileWithMultiPaths;
+ this.addGuidToSourceFile = addGuidToSourceFile;
if (traceHandlerIds == null) {
traceTypeIds = new String[0];
} else {
@@ -50,10 +52,10 @@ public class ImportTraceUnitsOperation extends AbstractOperation {
protected void doWork(IProgressMonitor monitor) throws OseeCoreException {
if (isPersistChanges) {
TraceUnitFromResourceOperation.importTraceFromTestUnits(monitor, sources, isRecursive, fileWithMultiPaths,
- importToBranch, traceTypeIds);
+ importToBranch, addGuidToSourceFile, traceTypeIds);
} else {
TraceUnitFromResourceOperation.printTraceFromTestUnits(monitor, sources, isRecursive, fileWithMultiPaths,
- traceTypeIds);
+ addGuidToSourceFile, traceTypeIds);
}
}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceResourceDropOperation.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceResourceDropOperation.java
index ef690792ef4..3983381d231 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceResourceDropOperation.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceResourceDropOperation.java
@@ -78,13 +78,14 @@ public class TraceResourceDropOperation extends AbstractOperation {
if (persistChanges) {
transaction = TransactionManager.createTransaction(branch, "TraceResourceDrop");
}
+ HierarchyHandler handler = new HierarchyHandler(transaction);
Map<Artifact, String> nameUpdateRequired = new TreeMap<Artifact, String>();
for (URI resource : resources) {
File file = new File(resource);
if (!file.isDirectory()) {
- processFile(file, transaction, nameUpdateRequired);
+ processFile(file, handler, transaction, nameUpdateRequired);
}
}
@@ -108,7 +109,7 @@ public class TraceResourceDropOperation extends AbstractOperation {
}
}
- private void processFile(File file, SkynetTransaction transaction, Map<Artifact, String> nameUpdateRequired) throws Exception {
+ private void processFile(File file, HierarchyHandler handler, SkynetTransaction transaction, Map<Artifact, String> nameUpdateRequired) throws Exception {
CharBuffer fileBuffer = Lib.fileToCharBuffer(file);
URI fileUri = file.toURI();
IFileStore fileStore = EFS.getStore(fileUri);
@@ -133,7 +134,7 @@ public class TraceResourceDropOperation extends AbstractOperation {
if (testUnitArtifact == null) {
testUnitArtifact = ArtifactTypeManager.addArtifact(CoreArtifactTypes.TestCase, branch, null, tag);
testUnitArtifact.setName(name);
- HierarchyHandler.addArtifact(transaction, testUnitArtifact);
+ handler.addArtifact(testUnitArtifact);
if (tagSource) {
tagger.addSourceTag(fileUri, testUnitArtifact.getGuid());
refreshFile(file.getAbsolutePath());
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitFromResourceOperation.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitFromResourceOperation.java
index 275d2f48033..c89264d19ec 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitFromResourceOperation.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitFromResourceOperation.java
@@ -39,7 +39,7 @@ public class TraceUnitFromResourceOperation {
return TraceUnitExtensionManager.getInstance().getTraceUnitHandlerIds();
}
- private static ResourceToTraceUnit getResourceToTestUnit(Iterable<URI> sources, boolean isRecursive, boolean isFileWithMultiplePaths, String... testUnitTraceIds) throws OseeCoreException {
+ private static ResourceToTraceUnit getResourceToTestUnit(Iterable<URI> sources, boolean isRecursive, boolean isFileWithMultiplePaths, boolean addGuidToSourceFile, String... testUnitTraceIds) throws OseeCoreException {
checkSourceArgument(sources);
checkTraceUnitHandlerIdsArgument(testUnitTraceIds);
@@ -55,9 +55,9 @@ public class TraceUnitFromResourceOperation {
return operation;
}
- public static void printTraceFromTestUnits(IProgressMonitor monitor, Iterable<URI> sources, boolean isRecursive, boolean isFileWithMultiplePaths, String... traceUnitHandlerIds) throws OseeCoreException {
+ public static void printTraceFromTestUnits(IProgressMonitor monitor, Iterable<URI> sources, boolean isRecursive, boolean isFileWithMultiplePaths, boolean addGuidToSourceFile, String... traceUnitHandlerIds) throws OseeCoreException {
ResourceToTraceUnit operation =
- getResourceToTestUnit(sources, isRecursive, isFileWithMultiplePaths, traceUnitHandlerIds);
+ getResourceToTestUnit(sources, isRecursive, isFileWithMultiplePaths, addGuidToSourceFile, traceUnitHandlerIds);
if (monitor == null) {
monitor = new NullProgressMonitor();
}
@@ -65,15 +65,15 @@ public class TraceUnitFromResourceOperation {
operation.execute(monitor);
}
- public static void importTraceFromTestUnits(IProgressMonitor monitor, Iterable<URI> sources, boolean isRecursive, boolean isFileWithMultiplePaths, IOseeBranch importToBranch, String... traceUnitHandlerIds) throws OseeCoreException {
+ public static void importTraceFromTestUnits(IProgressMonitor monitor, Iterable<URI> sources, boolean isRecursive, boolean isFileWithMultiplePaths, IOseeBranch importToBranch, boolean addGuidToSourceFile, String... traceUnitHandlerIds) throws OseeCoreException {
checkBranchArguments(importToBranch);
ResourceToTraceUnit operation =
- getResourceToTestUnit(sources, isRecursive, isFileWithMultiplePaths, traceUnitHandlerIds);
+ getResourceToTestUnit(sources, isRecursive, isFileWithMultiplePaths, addGuidToSourceFile, traceUnitHandlerIds);
if (monitor == null) {
monitor = new NullProgressMonitor();
}
- operation.addTraceProcessor(new TraceUnitToArtifactProcessor(importToBranch));
+ operation.addTraceProcessor(new TraceUnitToArtifactProcessor(importToBranch, addGuidToSourceFile));
operation.execute(monitor);
}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitToArtifactProcessor.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitToArtifactProcessor.java
index 9dea2632fe1..3fb095ffd77 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitToArtifactProcessor.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/traceability/operations/TraceUnitToArtifactProcessor.java
@@ -69,24 +69,28 @@ public class TraceUnitToArtifactProcessor implements ITraceUnitProcessor {
private CodeUnitData codeUnitData;
private TestUnitData testUnitData;
+ private final boolean addGuidToSourceFile;
private final IOseeBranch importIntoBranch;
private SkynetTransaction transaction;
+ private HierarchyHandler handler;
private final HashCollection<TraceUnit, TraceMark> reportTraceNotFound;
private final HashCollection<String, String> unknownRelationError;
private final Set<String> unRelatedUnits;
- public TraceUnitToArtifactProcessor(IOseeBranch importIntoBranch) {
+ public TraceUnitToArtifactProcessor(IOseeBranch importIntoBranch, boolean addGuidToSourceFile) {
this.importIntoBranch = importIntoBranch;
this.reportTraceNotFound = new HashCollection<TraceUnit, TraceMark>(false, HashSet.class);
this.unknownRelationError = new HashCollection<String, String>(false, HashSet.class);
this.unRelatedUnits = new HashSet<String>();
+ this.addGuidToSourceFile = addGuidToSourceFile;
}
@Override
public void clear() {
transaction = null;
+ handler = null;
if (requirementData != null) {
requirementData.reset();
requirementData = null;
@@ -104,6 +108,7 @@ public class TraceUnitToArtifactProcessor implements ITraceUnitProcessor {
@Override
public void initialize(IProgressMonitor monitor) {
transaction = null;
+ handler = null;
requirementData = new RequirementData(importIntoBranch);
if (!monitor.isCanceled()) {
requirementData.initialize(monitor);
@@ -144,6 +149,7 @@ public class TraceUnitToArtifactProcessor implements ITraceUnitProcessor {
public void process(IProgressMonitor monitor, TraceUnit traceUnit) throws OseeCoreException {
if (transaction == null) {
transaction = TransactionManager.createTransaction(importIntoBranch, "Importing Trace Unit(s)");
+ handler = new HierarchyHandler(transaction);
}
boolean hasChange = false;
boolean artifactWasCreated = false;
@@ -162,7 +168,7 @@ public class TraceUnitToArtifactProcessor implements ITraceUnitProcessor {
}
}
if (guid != null) {
- if (!GUID.isValid(guid)) {
+ if (!GUID.isValid(guid) && addGuidToSourceFile) {
try {
guidUtility.removeSourceTag(uriPath);
} catch (IOException ex) {
@@ -188,12 +194,13 @@ public class TraceUnitToArtifactProcessor implements ITraceUnitProcessor {
artifactWasCreated = true;
}
- if (guidUtility != null && !traceUnitArtifact.getGuid().equals(guid)) {
+ if (guidUtility != null && !traceUnitArtifact.getGuid().equals(guid) && addGuidToSourceFile) {
try {
guidUtility.removeSourceTag(traceUnit.getUriPath());
guidUtility.addSourceTag(traceUnit.getUriPath(), traceUnitArtifact.getGuid());
} catch (IOException ex) {
OseeExceptions.wrapAndThrow(ex);
+
}
}
@@ -231,7 +238,7 @@ public class TraceUnitToArtifactProcessor implements ITraceUnitProcessor {
}
if (hasChange || artifactWasCreated) {
- HierarchyHandler.addArtifact(transaction, traceUnitArtifact);
+ handler.addArtifact(traceUnitArtifact);
if (traceUnitArtifact.isOfType(CoreArtifactTypes.TestUnit)) {
TestRunHandler.linkWithTestUnit(transaction, traceUnitArtifact);
}

Back to the top