summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkwilk2011-04-18 16:07:41 (EDT)
committerRyan D. Brooks2011-04-18 16:07:41 (EDT)
commit3c5018f5d82f7053c94a237c26babf6bb91208da (patch)
treec899bef3578c31b2b5d18e292ae6a3eff468e5f4
parent2a92bc7de8e3143e7b5f55814b86b02b6e833c07 (diff)
downloadorg.eclipse.osee-3c5018f5d82f7053c94a237c26babf6bb91208da.zip
org.eclipse.osee-3c5018f5d82f7053c94a237c26babf6bb91208da.tar.gz
org.eclipse.osee-3c5018f5d82f7053c94a237c26babf6bb91208da.tar.bz2
feature: Support for 0 based, - delimited paragraph numbers
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/ReqNumberingTest.java47
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/ReqNumbering.java25
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/parsers/ExcelArtifactExtractor.java18
3 files changed, 65 insertions, 25 deletions
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/ReqNumberingTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/ReqNumberingTest.java
index babf038..b3ea1de 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/ReqNumberingTest.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/ReqNumberingTest.java
@@ -12,8 +12,12 @@ package org.eclipse.osee.framework.skynet.core.importing;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
import org.apache.commons.lang.StringUtils;
+import org.eclipse.osee.framework.skynet.core.importing.ReqNumbering;
+import org.junit.Assert;
import org.junit.Test;
/**
@@ -38,6 +42,24 @@ public class ReqNumberingTest {
}
@Test
+ public void testIsChild_ZeroBasedParagraphNumber() {
+ String parent = "1.3.4";
+ String child = "1.3.4.0-6";
+ ReqNumbering reqParent = new ReqNumbering(parent);
+ ReqNumbering reqChild = new ReqNumbering(child);
+ assertTrue(reqParent.isChild(reqChild));
+ }
+
+ @Test
+ public void testIsNotChild_ZeroBasedParagraphNumber() {
+ String parent = "1.3.4";
+ String child = "1.3.5.0-5";
+ ReqNumbering reqParent = new ReqNumbering(parent);
+ ReqNumbering reqChild = new ReqNumbering(child);
+ assertFalse(reqParent.isChild(reqChild));
+ }
+
+ @Test
public void testIsNotChild() {
String parent = "1.3.4";
String child = "1.3.4.6";
@@ -48,17 +70,16 @@ public class ReqNumberingTest {
@Test
public void testCompare() {
- ReqNumbering[] sequence =
- {
- new ReqNumbering("1"),
- new ReqNumbering("1.3"),
- new ReqNumbering("1.3.1.1.1.1.1.1"),
- new ReqNumbering("2.4"),
- new ReqNumbering("3")};
- for (int i = 0; i <= 2; i++) {
- assertTrue(sequence[i].compareTo(sequence[i + 1]) < 0);
- assertTrue(sequence[i + 1].compareTo(sequence[i]) > 0);
- assertTrue(sequence[i].compareTo(sequence[i]) == 0);
- }
+ List<ReqNumbering> referenceList =
+ Arrays.asList(new ReqNumbering("1"), new ReqNumbering("1.3"), new ReqNumbering("1.3.1.1.1.1.1.1"),
+ new ReqNumbering("2.4"), new ReqNumbering("2.4.0.1"), new ReqNumbering("3"));
+
+ List<ReqNumbering> sampleList =
+ Arrays.asList(new ReqNumbering("3"), new ReqNumbering("2.4.0-1"), new ReqNumbering("2.4"), new ReqNumbering(
+ "1.3.1.1.1.1.1.1"), new ReqNumbering("1.3"), new ReqNumbering("1"));
+
+ Collections.sort(sampleList);
+
+ Assert.assertEquals(referenceList, sampleList);
}
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/ReqNumbering.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/ReqNumbering.java
index a2adb72..6943ece 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/ReqNumbering.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/ReqNumbering.java
@@ -14,11 +14,21 @@ package org.eclipse.osee.framework.skynet.core.importing;
* @author Robert A. Fisher
*/
public class ReqNumbering implements Comparable<ReqNumbering> {
+ private static final int ZERO_BASED_NUMBERING = 2;
+ private static final int ONE_BASED_NUMBERING = 1;
+
private final String number;
private final String[] values;
+ /**
+ * Requirement Numbering
+ *
+ * @note When a number with a separator - is used, i.e. 1.2-1. All - are replaced with . at construction.
+ * @param number
+ */
public ReqNumbering(String number) {
- this.number = number;
+ //When additional separators are used (- instead of .)
+ this.number = number.replace("-", ".");
values = tokenize();
}
@@ -31,8 +41,17 @@ public class ReqNumbering implements Comparable<ReqNumbering> {
*/
public boolean isChild(ReqNumbering numbering) {
String[] numberVals = numbering.values;
- if (values.length + 1 != numberVals.length) {
- return false;
+
+ switch (numberVals.length - values.length) {
+ case ZERO_BASED_NUMBERING:
+ if (!numberVals[numberVals.length - 2].equals("0")) {
+ return false;
+ }
+ break;
+ case ONE_BASED_NUMBERING:
+ break;
+ default:
+ return false;
}
for (int i = 0; i < values.length; i++) {
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 2b7fc49..41320f4 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
@@ -135,14 +135,14 @@ public class ExcelArtifactExtractor extends AbstractArtifactExtractor {
public void foundStartOfWorksheet(String sheetName) {
rowCount = 0;
try {
- if (sheetName.equals("relations")) {
- importingRelations = true;
- return;
- }
- primaryDescriptor = ArtifactTypeManager.getType(sheetName);
- if (primaryDescriptor == null) {
- throw new OseeArgumentException("The sheet [%s] is not a valid artifact type name.", sheetName);
- }
+ if (sheetName.equals("relations")) {
+ importingRelations = true;
+ return;
+ }
+ primaryDescriptor = ArtifactTypeManager.getType(sheetName);
+ 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);
}
@@ -228,7 +228,7 @@ public class ExcelArtifactExtractor extends AbstractArtifactExtractor {
}
collector.addRoughArtifact(roughArtifact);
- relationHelper.put(primaryDescriptor.getName(), Integer.valueOf(rowCount), roughArtifact);
+ relationHelper.put(primaryDescriptor.getName(), rowCount, roughArtifact);
}
}