diff options
author | kwilk | 2012-07-26 06:51:57 +0000 |
---|---|---|
committer | kwilk | 2012-07-27 21:07:40 +0000 |
commit | 4f9877fe6485d5a842567311d787bf94fc588f92 (patch) | |
tree | ddb4271a2990a851918acf4a1890bbe8f7f2d25d | |
parent | df05fb4b1a8c5af1b112221bde7470e5f625342a (diff) | |
download | org.eclipse.osee-4f9877fe6485d5a842567311d787bf94fc588f92.tar.gz org.eclipse.osee-4f9877fe6485d5a842567311d787bf94fc588f92.tar.xz org.eclipse.osee-4f9877fe6485d5a842567311d787bf94fc588f92.zip |
feature[ats_72MWE]: Importer improvement to handle more paragraph numbers
5 files changed, 61 insertions, 27 deletions
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/OutlineResolutionAndNumberTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/OutlineResolutionAndNumberTest.java index 126b9e9eeff..ab5b51ffdab 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/OutlineResolutionAndNumberTest.java +++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/OutlineResolutionAndNumberTest.java @@ -18,8 +18,6 @@ import org.junit.Assert; import org.junit.Test; /** - * Asserting true in general means GUI should be called for user to make decision; false - opposite - * * @author Karol M. Wilk */ public final class OutlineResolutionAndNumberTest { @@ -77,44 +75,68 @@ public final class OutlineResolutionAndNumberTest { public void testNextSetGeneration() { Set<String> nextPossibleSet = outlineResolution.generateNextSet(new ReqNumbering(LAST_OUTLINE_NUMBER)); Set<String> expected = - new HashSet<String>(Arrays.asList("3.2", "3.1.2", "3.1.1.3", "3.1.1.2.2", "3.1.1.2.1.8", "4.", "4.0", + new HashSet<String>(Arrays.asList("3.2", "3.1.2", "3.1.1.3", "3.1.1.2.2", "3.1.1.2.1.8", "4.0", "3.1.1.2.1.7.1", "3.1.1.2.1.7.0.1")); - Assert.assertEquals(expected, nextPossibleSet); + addDotEndingSet(expected); + expected.removeAll(nextPossibleSet); + Assert.assertTrue(expected.isEmpty()); } + /** + * <p> + * Generate next numbers with ending "." by default. + * + * <pre> + * input(current number) output(generated set) + * 1. -> [1.1, 1.1., 1.0.1., 1.0.1, 2.0, 2.0.] + * 3. -> [3.0.1, 3.0.1., 3.1, 3.1., 4.0, 4.0.] + * </pre> + * + * </p> + */ @Test public void testNextSetGeneration_NonZeroBased() { Set<String> nextPossibleSet = outlineResolution.generateNextSet(new ReqNumbering("1.")); - Set<String> expected = new HashSet<String>(Arrays.asList("2.", "2.0", "1.1", "1.0.1")); - Assert.assertEquals(expected, nextPossibleSet); + Set<String> expected = new HashSet<String>(Arrays.asList("2.0", "1.1", "1.0.1")); + addDotEndingSet(expected); + expected.removeAll(nextPossibleSet); + Assert.assertTrue(expected.isEmpty()); } @Test public void testNextSetGeneration_ZeroBased() { Set<String> nextPossibleSet = outlineResolution.generateNextSet(new ReqNumbering("1.0")); - Set<String> expected = new HashSet<String>(Arrays.asList("2.", "2.0", "1.1", "1.0.1")); - Assert.assertEquals(expected, nextPossibleSet); + Set<String> expected = new HashSet<String>(Arrays.asList("2.0", "1.1", "1.0.1")); + addDotEndingSet(expected); + expected.removeAll(nextPossibleSet); + Assert.assertTrue(expected.isEmpty()); } @Test public void testNextSetGeneration_ZeroExtendedBased() { Set<String> nextPossibleSet = outlineResolution.generateNextSet(new ReqNumbering("1.0.1")); - Set<String> expected = new HashSet<String>(Arrays.asList("2.", "2.0", "1.1", "1.0.2")); - Assert.assertEquals(expected, nextPossibleSet); + Set<String> expected = new HashSet<String>(Arrays.asList("2.0", "1.1", "1.0.2")); + addDotEndingSet(expected); + expected.removeAll(nextPossibleSet); + Assert.assertTrue(expected.isEmpty()); } @Test public void testNextSetGeneration_DoubleDigitZeroBased() { Set<String> nextPossibleSet = outlineResolution.generateNextSet(new ReqNumbering("1.0.10")); - Set<String> expected = new HashSet<String>(Arrays.asList("2.", "2.0", "1.1", "1.0.11", "1.0.10.1", "1.0.10.0.1")); - Assert.assertEquals(expected, nextPossibleSet); + Set<String> expected = new HashSet<String>(Arrays.asList("2.0", "1.1", "1.0.11", "1.0.10.1", "1.0.10.0.1")); + addDotEndingSet(expected); + expected.removeAll(nextPossibleSet); + Assert.assertTrue(expected.isEmpty()); } @Test public void testNextSetGeneration_DoubleDigitHigherBased() { Set<String> nextPossibleSet = outlineResolution.generateNextSet(new ReqNumbering("1.23")); - Set<String> expected = new HashSet<String>(Arrays.asList("2.", "2.0", "1.24", "1.23.1", "1.23.0.1")); - Assert.assertEquals(expected, nextPossibleSet); + Set<String> expected = new HashSet<String>(Arrays.asList("2.0", "1.24", "1.23.1", "1.23.0.1")); + addDotEndingSet(expected); + expected.removeAll(nextPossibleSet); + Assert.assertTrue(expected.isEmpty()); } @Test @@ -132,4 +154,12 @@ public final class OutlineResolutionAndNumberTest { larger_NotGenerated_CorrectInvalid = outlineResolution.isInvalidOutlineNumber("1.23.1.0.0.0.1", "1.23"); Assert.assertFalse(larger_NotGenerated_CorrectInvalid); } + + private void addDotEndingSet(Set<String> inputSet) { + Set<String> dotEnding = new HashSet<String>(inputSet.size()); + for (String item : inputSet) { + dotEnding.add(item + "."); + } + inputSet.addAll(dotEnding); + } } 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 20a913246dc..79a629ddd0f 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,7 +19,6 @@ 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; @@ -47,7 +46,6 @@ import org.xml.sax.helpers.XMLReaderFactory; public class ExcelArtifactExtractor extends AbstractArtifactExtractor { private static final Pattern guidPattern = Pattern.compile("(\\d*);(.*)"); - private static final Pattern paragraphNumberPattern = Pattern.compile("\\d{1}+"); @Override public String getDescription() { @@ -199,9 +197,6 @@ public class ExcelArtifactExtractor extends AbstractArtifactExtractor { if (Strings.isValid(rowValue)) { switch (rowType) { case PARAGRAPH_NO: - if (paragraphNumberPattern.matcher(rowValue).matches()) { - rowValue = String.format("%s.0", rowValue); //forcing \\d.0 format - } roughArtifact.setSectionNumber(rowValue); roughArtifact.addAttribute(CoreAttributeTypes.ParagraphNumber, rowValue); break; diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/parsers/OutlineResolution.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/parsers/OutlineResolution.java index 972dbca2763..3ddab707d3b 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/parsers/OutlineResolution.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/parsers/OutlineResolution.java @@ -61,7 +61,8 @@ public final class OutlineResolution { if (invalid) { switch (last.compareTo(current)) { case -1: //just test upper bound of last, assuming last is last correct paragraph no - invalid = !generateNextSet(last).contains(current.getNumberString()); + Set<String> nextUp = generateNextSet(last); + invalid = !nextUp.contains(current.getNumberString()); //and if the current is generally larger but has not been generated, due to sequence of from: // $current.n.k, st "n -> oo, k -> oo", "n, k in Z", "oo is infinity" if (invalid) { @@ -105,7 +106,7 @@ public final class OutlineResolution { if (i == 0) { nextParagraphs.add(incDigit + ".0"); - nextParagraphs.add(incDigit + "."); + nextParagraphs.add(Integer.toString(incDigit)); } else { StringBuilder nextNew = new StringBuilder(digits.length * 2); for (int j = 0; j < i; j++) { @@ -115,6 +116,13 @@ public final class OutlineResolution { } } + + Set<String> dotEnding = new HashSet<String>(nextParagraphs.size()); + for (String next : nextParagraphs) { + dotEnding.add(next + "."); + } + nextParagraphs.addAll(dotEnding); + return nextParagraphs; } diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/parsers/WordOutlineExtractorDelegate.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/parsers/WordOutlineExtractorDelegate.java index b70989e1aae..88c8f413d75 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/parsers/WordOutlineExtractorDelegate.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/parsers/WordOutlineExtractorDelegate.java @@ -29,8 +29,8 @@ import org.eclipse.osee.framework.skynet.core.word.WordUtil; */ public class WordOutlineExtractorDelegate implements IArtifactExtractorDelegate { private static final String WORD_OUTLINE_PARSER_NAME = "Word Outline"; - // Node: <w:t>1.1.1 or Text</w:t> - private static final Pattern WT_ELEMENT_REGEX = Pattern.compile("<w:t>(.*?)</w:t>"); + // Node: <w:t>1.1.1 or Text</w:t> or <w:t xml:preserve="x">1.1.1 or Text</w:t> + private static final Pattern WT_ELEMENT_REGEX = Pattern.compile("<w:t.*?>(.*?)</w:t>", Pattern.DOTALL); // Node: <wx:t wx:val="1.1.1 "/> private static final Pattern LIST_ITEM_REGEX = Pattern.compile("<wx:t wx:val=\"([0-9.]+\\s*)\".*/>"); private static final Pattern OUTLINE_NUMBER_REGEX = Pattern.compile("((?>\\d+\\.)+\\d*(?>-\\d+)*)\\s*"); @@ -107,6 +107,9 @@ public class WordOutlineExtractorDelegate implements IArtifactExtractorDelegate possibleTableOfContents = false; } + /** + * Core of processing different WordML content "chunks". + */ @Override public final void processContent(OperationLogger logger, RoughArtifactCollector collector, boolean forceBody, boolean forcePrimaryType, String headerNumber, String listIdentifier, String paragraphStyle, String content, boolean isParagraph) throws OseeCoreException { if (Strings.isValid(content) && initalized) { @@ -246,8 +249,6 @@ public class WordOutlineExtractorDelegate implements IArtifactExtractorDelegate /** * Specializes in extraction of "1.0 scope" type of outline number and names. Outline name can also be spread out * over multiple {@code <w:t> } elements.<br/> - * - * @note Paragraph numbering must be zero based. "1.0 SCOPE" instead of "1. SCOPE" */ private void specializedOutlineNumberTitleExtract(String paragraph, StringBuilder outlineNumberStorage, StringBuilder outlineTitleStorage, String paragraphStyle) { StringBuilder wtStorage = new StringBuilder(paragraph.length()); diff --git a/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/importer/ArtifactImportWizardTest.java b/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/importer/ArtifactImportWizardTest.java index bd72cb4a356..01cba393874 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/importer/ArtifactImportWizardTest.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/importer/ArtifactImportWizardTest.java @@ -86,8 +86,8 @@ public final class ArtifactImportWizardTest { // copy imported paragraph over... because they will be matched on guid... Map<String, String> answerParagraphNumbers = new HashMap<String, String>(); - answerParagraphNumbers.put("B", "3.0"); - answerParagraphNumbers.put("D", "2.0"); + answerParagraphNumbers.put("B", "3"); + answerParagraphNumbers.put("D", "2"); int numberOfDescendants = myRootArtifact.getDescendants().size(); |