Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid W. Miller2018-08-21 21:22:56 -0400
committerDavid W. Miller2018-08-29 14:17:18 -0400
commit1170faba3d7c71d940be8bb42a438afae5b27e45 (patch)
tree319c67e7fbaea8a551e547feef212b9f35b83d79
parente015a71247cf09a9754eac9eeec631e9e1f4a076 (diff)
downloadorg.eclipse.osee-1170faba3d7c71d940be8bb42a438afae5b27e45.tar.gz
org.eclipse.osee-1170faba3d7c71d940be8bb42a438afae5b27e45.tar.xz
org.eclipse.osee-1170faba3d7c71d940be8bb42a438afae5b27e45.zip
refinement[ats_TW9739]: Add types for Doors import
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreArtifactTypes.java3
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/plugin.xml5
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/RoughArtifact.java10
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/parsers/DoorsWordOutlineExtractor.java127
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/resolvers/NewArtifactImportResolver.java37
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactResolverFactory.java2
6 files changed, 36 insertions, 148 deletions
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreArtifactTypes.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreArtifactTypes.java
index 5f711a577b..a5467984d9 100644
--- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreArtifactTypes.java
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreArtifactTypes.java
@@ -97,6 +97,9 @@ public final class CoreArtifactTypes {
public static final IArtifactType User = TokenFactory.createArtifactType(5, "User");
public static final IArtifactType UserGroup = TokenFactory.createArtifactType(7, "User Group");
public static final IArtifactType XViewerGlobalCustomization = TokenFactory.createArtifactType(55, "XViewer Global Customization");
+
+ public static final IArtifactType DocumentDescriptionMSWord = TokenFactory.createArtifactType(806, "Document Description - MS Word");
+ public static final IArtifactType DesignDescriptionMSWord = TokenFactory.createArtifactType(807, "Design Description - MS Word");
// @formatter:on
private CoreArtifactTypes() {
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/plugin.xml b/plugins/org.eclipse.osee.framework.skynet.core/plugin.xml
index c24165b48b..222eed1547 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/plugin.xml
+++ b/plugins/org.eclipse.osee.framework.skynet.core/plugin.xml
@@ -257,11 +257,6 @@
classname="org.eclipse.osee.framework.skynet.core.importing.parsers.WordOutlineExtractorDelegate">
</ArtifactExtractorDelegate>
</extension>
- <extension
- point="org.eclipse.osee.framework.skynet.core.ArtifactExtractorDelegate">
- <ArtifactExtractorDelegate
- classname="org.eclipse.osee.framework.skynet.core.importing.parsers.DoorsWordOutlineExtractor"/>
- </extension>
<extension
point="org.eclipse.osee.framework.skynet.core.ArtifactCheck">
<ArtifactCheck
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 f417f14862..9952203b61 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
@@ -14,6 +14,7 @@ import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Set;
+import org.eclipse.osee.framework.core.data.ArtifactTypeId;
import org.eclipse.osee.framework.core.data.AttributeTypeToken;
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
@@ -37,6 +38,7 @@ public class RoughArtifact {
private final RoughAttributeSet attributes;
private final Collection<RoughArtifact> children;
private IArtifactType primaryArtifactType;
+ private ArtifactTypeId type = ArtifactTypeId.SENTINEL;
public RoughArtifact(RoughArtifactKind roughArtifactKind, String name) {
this.attributes = new RoughAttributeSet();
@@ -213,4 +215,12 @@ public class RoughArtifact {
this.primaryArtifactType = primaryArtifactType;
}
+ public ArtifactTypeId getType() {
+ return type;
+ }
+
+ public void setType(ArtifactTypeId type) {
+ this.type = type;
+ }
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/parsers/DoorsWordOutlineExtractor.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/parsers/DoorsWordOutlineExtractor.java
deleted file mode 100644
index f715146e14..0000000000
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/parsers/DoorsWordOutlineExtractor.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2018 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.skynet.core.importing.parsers;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.framework.skynet.core.importing.RoughArtifact;
-import org.eclipse.osee.framework.skynet.core.importing.RoughArtifactKind;
-import org.eclipse.osee.framework.skynet.core.importing.operations.RoughArtifactCollector;
-
-/**
- * @author David W. Miller
- */
-/**
- * This is a special word outline extractor that handles documents generated by Doors. It is looking for tags, wrapped
- * in {}, that define the scope and type of the artifact that is being created during the import process.
- */
-public class DoorsWordOutlineExtractor extends WordOutlineExtractorDelegate {
- private static final Pattern reqnamePattern = Pattern.compile("(\\{[^}]+\\})(.*?</w:p>)");
- private static final Pattern outlinePattern = Pattern.compile("(\\{[^}]+\\})");
- private static final Pattern doorsIdPattern = Pattern.compile("\\{[^-]+\\-([^}]+)\\}");
- private int lastReqNumber = 1;
-
- @Override
- protected void addChildRoughArtifact(String content, RoughArtifactCollector collector) {
- StringBuilder newName = new StringBuilder();
- StringBuilder newContent = new StringBuilder();
- if (needsNewArt(content, newName, newContent)) {
- setContent(); // finishes the previous rough artifact
- String number = String.format("%s.0.%d", lastHeaderNumber.toString(), lastReqNumber++);
-
- String name = newName.toString();
- if (name.contains("<w")) { // remove invalid tags from names
- name = name.replaceAll("<[^>]+>", "");
- }
- roughArtifact = new RoughArtifact(getRoughArtifactType(name));
- roughArtifact.setName(name);
-
- if (collector != null) {
- collector.addRoughArtifact(roughArtifact);
- }
- if (Strings.isValid(number)) {
- roughArtifact.setSectionNumber(number);
- roughArtifact.addAttribute(CoreAttributeTypes.ParagraphNumber, number);
- }
- Matcher match = doorsIdPattern.matcher(name);
- if (match.find()) {
- String toSet = match.group(1);
- roughArtifact.addAttribute(CoreAttributeTypes.StaticId, toSet);
- }
- roughArtifact.addAttribute(CoreAttributeTypes.PublishInline, "True");
- wordFormattedContent.append(newContent.toString());
- previousNamedArtifact = roughArtifact;
- } else {
- wordFormattedContent.append(content);
- }
- }
-
- private RoughArtifactKind getRoughArtifactType(String newName) {
- RoughArtifactKind toReturn = RoughArtifactKind.PRIMARY;
- if (newName.contains("Doc Dsc")) {
- toReturn = RoughArtifactKind.TERTIARY;
- } else if (newName.contains("Dsg Dsc")) {
- toReturn = RoughArtifactKind.QUATERNARY;
- }
- return toReturn;
- }
-
- @Override
- public void processHeadingText(RoughArtifact roughArtifact, String headingText) throws OseeCoreException {
- roughArtifact.setRoughArtifactKind(RoughArtifactKind.SECONDARY);
- Matcher match = outlinePattern.matcher(headingText);
- if (match.find()) {
- roughArtifact.setName(headingText.substring(0, match.start(1)).trim());
- Matcher matchId = doorsIdPattern.matcher(headingText);
- if (matchId.find()) {
- roughArtifact.addAttribute(CoreAttributeTypes.StaticId, matchId.group(1));
- }
- return;
- }
- roughArtifact.setName(headingText.trim());
- }
-
- @Override
- protected boolean checkSectionNumber(String sectionNumber) {
- if (sectionNumber.contains(".0.")) {
- return true; // special case of numbering requirements below a section number
- }
- return false;
- }
-
- @Override
- public void resetReqNumber() {
- lastReqNumber = 1;
- }
-
- @Override
- public String getName() {
- return "Doors Word Outline";
- }
-
- private boolean needsNewArt(String content, StringBuilder newName, StringBuilder newContent) {
- if (content.contains("####")) {
- return false; // special case for match in description
- }
- Matcher match = reqnamePattern.matcher(content);
- if (match.find()) {
- String begin = content.substring(0, match.start(1));
- newName.append(content.substring(match.start(1), match.start(2)));
- String endString = content.substring(match.start(2), match.end(2));
- newContent.append(begin + endString);
- return true; // only finds the first one
- }
- return false;
- }
-}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/resolvers/NewArtifactImportResolver.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/resolvers/NewArtifactImportResolver.java
index 89c99cb2ab..aa77ae1b4d 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/resolvers/NewArtifactImportResolver.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/importing/resolvers/NewArtifactImportResolver.java
@@ -11,6 +11,7 @@
package org.eclipse.osee.framework.skynet.core.importing.resolvers;
import java.util.logging.Level;
+import org.eclipse.osee.framework.core.data.ArtifactTypeId;
import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
@@ -54,7 +55,7 @@ public class NewArtifactImportResolver implements IArtifactImportResolver {
@Override
public Artifact resolve(final RoughArtifact roughArtifact, final BranchId branch, Artifact realParent, Artifact root) throws OseeCoreException {
- IArtifactType artifactType = getArtifactType(roughArtifact.getRoughArtifactKind());
+ ArtifactTypeId artifactType = getArtifactType(roughArtifact);
OseeLog.logf(NewArtifactImportResolver.class, Level.INFO, "New artifact: [%s]. Attributes: [%s]", roughArtifact,
roughArtifact.getAttributes());
@@ -64,20 +65,26 @@ public class NewArtifactImportResolver implements IArtifactImportResolver {
return realArtifact;
}
- private IArtifactType getArtifactType(RoughArtifactKind kind) throws OseeCoreException {
- switch (kind) {
- case PRIMARY:
- return primaryArtifactType;
- case SECONDARY:
- return secondaryArtifactType;
- case TERTIARY:
- return tertiaryArtifactType;
- case QUATERNARY:
- return quaternaryArtifactType;
- case CONTAINER:
- return CoreArtifactTypes.Folder;
- default:
- throw new OseeCoreException("Unknown Artifact Kind " + kind);
+ private ArtifactTypeId getArtifactType(RoughArtifact art) throws OseeCoreException {
+ ArtifactTypeId type = art.getType();
+ if (!type.equals(ArtifactTypeId.SENTINEL)) {
+ return type;
+ } else {
+ RoughArtifactKind kind = art.getRoughArtifactKind();
+ switch (kind) {
+ case PRIMARY:
+ return primaryArtifactType;
+ case SECONDARY:
+ return secondaryArtifactType;
+ case TERTIARY:
+ return tertiaryArtifactType;
+ case QUATERNARY:
+ return quaternaryArtifactType;
+ case CONTAINER:
+ return CoreArtifactTypes.Folder;
+ default:
+ throw new OseeCoreException("Unknown Artifact Kind " + kind);
+ }
}
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactResolverFactory.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactResolverFactory.java
index cdb9f94e71..ca2dbeaf38 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactResolverFactory.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/Import/ArtifactResolverFactory.java
@@ -50,7 +50,7 @@ public final class ArtifactResolverFactory {
public static IArtifactImportResolver createAlwaysNewArtifacts(IArtifactType primaryArtifactType, IArtifactType secondaryArtifactType) {
IRoughArtifactTranslator translator = new RoughArtifactTranslatorImpl();
return new NewArtifactImportResolver(translator, primaryArtifactType, secondaryArtifactType,
- CoreArtifactTypes.Design, CoreArtifactTypes.SubsystemDesign);
+ CoreArtifactTypes.DocumentDescriptionMSWord, CoreArtifactTypes.DesignDescriptionMSWord);
}
public static IArtifactImportResolver createResolver(ArtifactCreationStrategy strategy, IArtifactType primaryArtifactType, Collection<AttributeTypeToken> nonChangingAttributes, boolean createNewIfNotExist, boolean deleteUnmatchedArtifacts) {

Back to the top