Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorgan E. Cook2016-01-28 23:48:29 +0000
committerRyan D. Brooks2016-01-28 23:48:29 +0000
commit72e0c4b403a0201dcbaf14449f684de87fce53cf (patch)
tree66836acba1cd22593d57e758873cdd42d66c8c9e /plugins
parent792ea05fc2d69da7a3947f2ccf41126a45a54aef (diff)
downloadorg.eclipse.osee-72e0c4b403a0201dcbaf14449f684de87fce53cf.tar.gz
org.eclipse.osee-72e0c4b403a0201dcbaf14449f684de87fce53cf.tar.xz
org.eclipse.osee-72e0c4b403a0201dcbaf14449f684de87fce53cf.zip
refactor[ats_ATS222537]: Remove custom XML tags
Change-Id: Id01f5530fdbabc96e2196629147463335277332a Signed-off-by: Morgan E. Cook <Morgan.e.cook@boeing.com>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/WordTemplateRendererTest.java18
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreAttributeTypes.java1
-rw-r--r--plugins/org.eclipse.osee.framework.database.init/src/org/eclipse/osee/framework/database/init/internal/SimpleTemplateProviderTask.java7
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/support/OseeTypes_Framework.osee12
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/TisRenderer.java5
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/WholeWordRenderer.java2
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/WordTemplateRenderer.java36
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/AttributeElement.java71
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordRendererUtil.java4
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateProcessor.java377
11 files changed, 281 insertions, 253 deletions
diff --git a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/WordTemplateRendererTest.java b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/WordTemplateRendererTest.java
index 1fb6e72899d..848b34452be 100644
--- a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/WordTemplateRendererTest.java
+++ b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/WordTemplateRendererTest.java
@@ -86,6 +86,13 @@ public class WordTemplateRendererTest {
private static String MASTER_TEMPLATE_STRING_IDONLY;
private static String MASTER_TEMPLATE_STRING_IDANDNAME;
private static String SLAVE_TEMPLATE_STRING;
+
+ private static String RECURSIVE_RENDERER_OPTIONS = "{\"ElementType\" : \"Artifact\", \"OutliningOptions\" : [ {\"Outlining\" : true, \"RecurseChildren\" : true, \"HeadingAttributeType\" : \"Name\", \"ArtifactName\" : \"Default\", \"OutlineNumber\" : \"\" }], \"AttributeOptions\" : [{\"AttrType\" : \"Word Template Content\", \"Label\" : \"\", \"FormatPre\" : \"\", \"FormatPost\" : \"\"}]}";
+ private static String SINGLE_RENDERER_OPTIONS = "{\"ElementType\" : \"Artifact\", \"OutliningOptions\" : [ {\"Outlining\" : true, \"RecurseChildren\" : false, \"HeadingAttributeType\" : \"Name\", \"ArtifactName\" : \"Default\", \"OutlineNumber\" : \"\" }], \"AttributeOptions\" : [{\"AttrType\" : \"Word Template Content\", \"Label\" : \"\", \"FormatPre\" : \"\", \"FormatPost\" : \"\"}]}";
+ private static String SINGLE_ATTRIBUTE_RENDERER_OPTIONS = "{\"ElementType\" : \"Artifact\", \"OutliningOptions\" : [ {\"Outlining\" : true, \"RecurseChildren\" : false, \"HeadingAttributeType\" : \"Name\", \"ArtifactName\" : \"Default\", \"OutlineNumber\" : \"\" }], \"AttributeOptions\" : [{\"AttrType\" : \"*\", \"Label\" : \"\", \"FormatPre\" : \"\", \"FormatPost\" : \"\"}]}";
+ private static String MASTER_RENDERER_OPTIONS = "{\"ElementType\" : \"NestedTemplate\", \"NestedTemplates\" : [{\"OutlineType\" : \"\", \"SectionNumber\" : \"3.2.1\", \"SubDocName\" : \"Communication Subsystem Crew Interface\", \"Key\" : \"Name\", \"Value\" : \"Communication Subsystem Crew Interface\"}, {\"OutlineType\" : \"\", \"SectionNumber\" : \"3.2.2\", \"SubDocName\" : \"Navigation Subsystem Crew Interface\", \"Key\" : \"Name\", \"Value\" : \"Navigation Subsystem Crew Interface\"}, {\"OutlineType\" : \"\", \"SectionNumber\" : \"3.2.3\", \"SubDocName\" : \"Aircraft Systems Management Subsystem Crew Interface\", \"Key\" : \"Name\", \"Value\" : \"Aircraft Systems Management Subsystem Crew Interface\"}]}";
+ private static String MASTER_ID_RENDERER_OPTIONS = "{\"ElementType\" : \"NestedTemplate\", \"NestedTemplates\" : [{\"OutlineType\" : \"\", \"SectionNumber\" : \"3.2.1\", \"SubDocName\" : \"Communication Subsystem Crew Interface\", \"Key\" : \"Id\", \"Value\" : \"249\"}, {\"OutlineType\" : \"\", \"SectionNumber\" : \"3.2.2\", \"SubDocName\" : \"Navigation Subsystem Crew Interface\", \"Key\" : \"Id\", \"Value\" : \"250\"}, {\"OutlineType\" : \"\", \"SectionNumber\" : \"3.2.3\", \"SubDocName\" : \"Aircraft Systems Management Subsystem Crew Interface\", \"Key\" : \"Id\", \"Value\" : \"251\"}]}";
+ private static String SLAVE_RENDERER_OPTIONS = "{\"ElementType\" : \"Artifact\", \"OutliningOptions\" : [{\"Outlining\" : true, \"RecurseChildren\" : true, \"HeadingAttributeType\" : \"Name\", \"ArtifactName\" : \"srsProducer.objects\", \"OutlineNumber\" : \"\" }], \"AttributeOptions\" : [{\"AttrType\" : \"Partition\", \"Label\" : \"<w:r><w:t>Partition:</w:t></w:r>\", \"FormatPre\" : \">x<\", \"FormatPost\" : \"\"}, {\"AttrType\" : \"Development Assurance Level\", \"Label\" : \"<w:r><w:t>Development Assurance Level:</w:t></w:r>\", \"FormatPre\" : \">x<\", \"FormatPost\" : \"\"}, {\"AttrType\" : \"Word Template Content\", \"Label\" : \"\", \"FormatPre\" : \"\", \"FormatPost\" : \"\"}]}";
private IOseeBranch rootBranch;
private IOseeBranch updateBranch;
@@ -377,6 +384,7 @@ public class WordTemplateRendererTest {
String rev = m.group();
contents = contents.replace(rev, "wsp:rsidRDefault=\"TESTING\"");
}
+
Assert.assertTrue("Original Paragram Numbering for Notes is incorrect", contents.contains(
"<w:r><w:t>Notes</w:t></w:r></w:p><w:p wsp:rsidR=\"TESTING\" wsp:rsidRDefault=\"TESTING\"><w:r><w:t> Paragraph Number: 3</w:t></w:r>"));
Assert.assertTrue("Original Paragram Numbering for More Notes is incorrect", contents.contains(
@@ -615,27 +623,33 @@ public class WordTemplateRendererTest {
"org.eclipse.osee.framework.ui.skynet.word PREVIEW PREVIEW_WITH_RECURSE_NO_ATTRIBUTES");
recurseTemplate.addAttributeFromString(CoreAttributeTypes.TemplateMatchCriteria,
"org.eclipse.osee.framework.ui.skynet.render.WordTemplateRenderer PREVIEW PREVIEW_WITH_RECURSE_NO_ATTRIBUTES");
+ recurseTemplate.setSoleAttributeFromString(CoreAttributeTypes.RendererOptions, RECURSIVE_RENDERER_OPTIONS);
singleTemplate = ArtifactTypeManager.addArtifact(CoreArtifactTypes.RendererTemplate, branch, "Single Template");
singleTemplate.setSoleAttributeValue(CoreAttributeTypes.WholeWordContent, SINGLE_TEMPLATE_STRING);
+ singleTemplate.setSoleAttributeValue(CoreAttributeTypes.RendererOptions, SINGLE_RENDERER_OPTIONS);
singleTemplateAttrib =
ArtifactTypeManager.addArtifact(CoreArtifactTypes.RendererTemplate, branch, "Single With Attributes");
singleTemplateAttrib.setSoleAttributeValue(CoreAttributeTypes.WholeWordContent,
SINGLE_TEMPLATE_WITH_ATTRIBUTES_STRING);
+ singleTemplateAttrib.setSoleAttributeValue(CoreAttributeTypes.RendererOptions, SINGLE_ATTRIBUTE_RENDERER_OPTIONS);
masterTemplate =
ArtifactTypeManager.addArtifact(CoreArtifactTypes.RendererTemplate, branch, "srsMaster Template");
masterTemplate.setSoleAttributeFromString(CoreAttributeTypes.WholeWordContent, MASTER_TEMPLATE_STRING);
+ masterTemplate.setSoleAttributeFromString(CoreAttributeTypes.RendererOptions, MASTER_RENDERER_OPTIONS);
masterTemplate_idOnly =
ArtifactTypeManager.addArtifact(CoreArtifactTypes.RendererTemplate, branch, "srsMaster Template ID only");
masterTemplate_idOnly.setSoleAttributeFromString(CoreAttributeTypes.WholeWordContent,
MASTER_TEMPLATE_STRING_IDONLY);
+ masterTemplate_idOnly.setSoleAttributeFromString(CoreAttributeTypes.RendererOptions, MASTER_ID_RENDERER_OPTIONS);
masterTemplate_idAndName =
ArtifactTypeManager.addArtifact(CoreArtifactTypes.RendererTemplate, branch, "srsMaster Template ID and name");
masterTemplate_idAndName.setSoleAttributeFromString(CoreAttributeTypes.WholeWordContent,
MASTER_TEMPLATE_STRING_IDANDNAME);
-
+ masterTemplate_idAndName.setSoleAttributeFromString(CoreAttributeTypes.RendererOptions, MASTER_ID_RENDERER_OPTIONS);
slaveTemplate = ArtifactTypeManager.addArtifact(CoreArtifactTypes.RendererTemplate, branch, "srsSlave Template");
slaveTemplate.setSoleAttributeFromString(CoreAttributeTypes.WholeWordContent, SLAVE_TEMPLATE_STRING);
-
+ slaveTemplate.setSoleAttributeFromString(CoreAttributeTypes.RendererOptions, SLAVE_RENDERER_OPTIONS);
+
folder.addChild(recurseTemplate);
folder.addChild(singleTemplate);
folder.addChild(singleTemplateAttrib);
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreAttributeTypes.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreAttributeTypes.java
index e15422eff4a..0dd50941482 100644
--- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreAttributeTypes.java
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/CoreAttributeTypes.java
@@ -69,6 +69,7 @@ public final class CoreAttributeTypes {
public static final IAttributeType Phone = TokenFactory.createAttributeType(0x1000000000000067L, "Phone");
public static final IAttributeType PublishInline = TokenFactory.createAttributeType(0x1000000000000092L, "PublishInline");
public static final IAttributeType QualificationMethod = TokenFactory.createAttributeType(0x1000000000000089L, "Qualification Method");
+ public static final IAttributeType RendererOptions = TokenFactory.createAttributeType(0x0000000000000388L, "Renderer Options");
public static final IAttributeType RelationOrder = TokenFactory.createAttributeType(0x1000000000000071L, "Relation Order");
public static final IAttributeType Sfha = TokenFactory.createAttributeType(0x10000000000000A4L, "SFHA");
public static final IAttributeType SafetyCriticality = TokenFactory.createAttributeType(0x100000000000008AL, "Safety Criticality");
diff --git a/plugins/org.eclipse.osee.framework.database.init/src/org/eclipse/osee/framework/database/init/internal/SimpleTemplateProviderTask.java b/plugins/org.eclipse.osee.framework.database.init/src/org/eclipse/osee/framework/database/init/internal/SimpleTemplateProviderTask.java
index a1f70a650bb..87e5d1e0220 100644
--- a/plugins/org.eclipse.osee.framework.database.init/src/org/eclipse/osee/framework/database/init/internal/SimpleTemplateProviderTask.java
+++ b/plugins/org.eclipse.osee.framework.database.init/src/org/eclipse/osee/framework/database/init/internal/SimpleTemplateProviderTask.java
@@ -31,6 +31,8 @@ import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
public class SimpleTemplateProviderTask implements IDbInitializationTask {
+ private static String EDIT_RENDERER_OPTIONS = "{\"ElementType\" : \"Artifact\", \"OutliningOptions\" : [ {\"Outlining\" : true, \"RecurseChildren\" : false, \"HeadingAttributeType\" : \"Name\", \"ArtifactName\" : \"Default\", \"OutlineNumber\" : \"\" }], \"AttributeOptions\" : [{\"AttrType\" : \"Word Template Content\", \"Label\" : \"\", \"FormatPre\" : \"\", \"FormatPost\" : \"\"}]}";
+ private static String RECURSIVE_RENDERER_OPTIONS = "{\"ElementType\" : \"Artifact\", \"OutliningOptions\" : [ {\"Outlining\" : true, \"RecurseChildren\" : true, \"HeadingAttributeType\" : \"Name\", \"ArtifactName\" : \"Default\", \"OutlineNumber\" : \"\" }], \"AttributeOptions\" : [{\"AttrType\" : \"*\", \"Label\" : \"\", \"FormatPre\" : \"\", \"FormatPost\" : \"\"}]}";
@Override
public void run() throws OseeCoreException {
try {
@@ -55,6 +57,11 @@ public class SimpleTemplateProviderTask implements IDbInitializationTask {
if (url != null) {
templateArtifact.setName(name);
+ if(name.equals("Word Edit Template")) {
+ templateArtifact.setSoleAttributeFromString(CoreAttributeTypes.RendererOptions, EDIT_RENDERER_OPTIONS);
+ } else if(name.equals("PREVIEW_ALL_RECURSE")) {
+ templateArtifact.setSoleAttributeFromString(CoreAttributeTypes.RendererOptions, RECURSIVE_RENDERER_OPTIONS);
+ }
templateArtifact.setSoleAttributeFromStream(CoreAttributeTypes.WholeWordContent, url.openStream());
for (IConfigurationElement matchCriteriaEl : el.getChildren()) {
String match = matchCriteriaEl.getAttribute("match");
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/support/OseeTypes_Framework.osee b/plugins/org.eclipse.osee.framework.skynet.core/support/OseeTypes_Framework.osee
index efa4ff81be4..73a3b663f72 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/support/OseeTypes_Framework.osee
+++ b/plugins/org.eclipse.osee.framework.skynet.core/support/OseeTypes_Framework.osee
@@ -343,6 +343,7 @@ artifactType "Universal Group" extends "Group Artifact" {
artifactType "Renderer Template" extends "MS Word Whole Document" {
uuid 0x0000000000000009
attribute "Template Match Criteria"
+ attribute "Renderer Options"
}
attributeType "Template Match Criteria" extends StringAttribute {
@@ -355,6 +356,17 @@ attributeType "Template Match Criteria" extends StringAttribute {
mediaType "text/plain"
}
+attributeType "Renderer Options" extends StringAttribute {
+ uuid 0x0000000000000388
+ dataProvider DefaultAttributeDataProvider
+ min 1
+ max 1
+ taggerId DefaultAttributeTaggerProvider
+ defaultValue "{\"ElementType\" : \"Artifact\", \"OutliningOptions\" : [ {\"Outlining\" : true, \"RecurseChildren\" : false, \"HeadingAttributeType\" : \"Name\", \"ArtifactName\" : \"Default\", \"OutlineNumber\" : \"\" }], \"AttributeOptions\" : [{\"AttrType\" : \"*\", \"Label\" : \"\", \"FormatPre\" : \"\", \"FormatPost\" : \"\"}]}"
+ fileExtension "txt"
+ mediaType "application/json"
+}
+
relationType "Default Hierarchical" {
uuid 0x2000000000000154
sideAName "parent"
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF
index 3906205b3df..4d14c9e57a4 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF
@@ -180,6 +180,7 @@ Import-Package: com.google.common.base;version="15.0.0",
org.eclipse.zest.core.widgets,
org.eclipse.zest.layouts,
org.eclipse.zest.layouts.algorithms,
+ org.json,
org.mozilla.javascript,
org.osgi.framework,
org.osgi.service.packageadmin,
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/TisRenderer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/TisRenderer.java
index cffb40b83eb..05795176613 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/TisRenderer.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/TisRenderer.java
@@ -19,6 +19,7 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+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.io.CharBackedInputStream;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
@@ -65,7 +66,7 @@ public class TisRenderer extends WordTemplateRenderer {
@Override
public InputStream getRenderInputStream(PresentationType presentationType, List<Artifact> artifacts) throws OseeCoreException {
- String template;
+ Artifact template;
if (artifacts.isEmpty()) {
// Still need to get a default template with a null artifact list
@@ -80,7 +81,7 @@ public class TisRenderer extends WordTemplateRenderer {
handlers.add(new TISAttributeHandler());
handlers.add(new WordAttributeTypeAttributeHandler());
handlers.add(new BasicTemplateAttributeHandler());
- WordTemplateManager wtm = new WordTemplateManager(template, handlers);
+ WordTemplateManager wtm = new WordTemplateManager(template.getSoleAttributeValue(CoreAttributeTypes.WholeWordContent), handlers);
CharBackedInputStream charBak = null;
try {
charBak = new CharBackedInputStream();
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/WholeWordRenderer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/WholeWordRenderer.java
index ca200a050a9..584cd15b9fa 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/WholeWordRenderer.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/WholeWordRenderer.java
@@ -109,7 +109,7 @@ public class WholeWordRenderer extends WordRenderer {
content = WordMlLinkHandler.link(linkType, artifact, content, unknownGuids);
WordUiUtil.displayUnknownGuids(artifact, unknownGuids);
- String classification = WordRendererUtil.getDataRightsClassification(artifact);
+ String classification = artifact.getSoleAttributeValueAsString(CoreAttributeTypes.DataRightsClassification, "");
if (Strings.isValid(classification)) {
content = addDataRights(content, classification, artifact);
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/WordTemplateRenderer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/WordTemplateRenderer.java
index 2c65c419fc2..ff866213c79 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/WordTemplateRenderer.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/WordTemplateRenderer.java
@@ -32,7 +32,6 @@ import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.operation.IOperation;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.jdk.core.util.xml.Jaxp;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.Attribute;
@@ -61,8 +60,6 @@ import org.w3c.dom.Element;
* @author Jeff C. Phillips
*/
public class WordTemplateRenderer extends WordRenderer implements ITemplateRenderer {
- public static final String DEFAULT_SET_NAME = "Default";
- public static final String ARTIFACT_SCHEMA = "http://eclipse.org/artifact.xsd";
private static final String EMBEDDED_OBJECT_NO = "w:embeddedObjPresent=\"no\"";
private static final String EMBEDDED_OBJECT_YES = "w:embeddedObjPresent=\"yes\"";
private static final String STYLES_END = "</w:styles>";
@@ -89,7 +86,7 @@ public class WordTemplateRenderer extends WordRenderer implements ITemplateRende
public void publish(Artifact masterTemplateArtifact, Artifact slaveTemplateArtifact, List<Artifact> artifacts, Object... options) throws OseeCoreException {
setOptions(options);
- templateProcessor.publishWithExtensionTemplates(masterTemplateArtifact, slaveTemplateArtifact, artifacts);
+ templateProcessor.publishWithNestedTemplates(masterTemplateArtifact, slaveTemplateArtifact, artifacts);
}
/**
@@ -189,14 +186,24 @@ public class WordTemplateRenderer extends WordRenderer implements ITemplateRende
@Override
public InputStream getRenderInputStream(PresentationType presentationType, List<Artifact> artifacts) throws OseeCoreException {
final List<Artifact> notMultiEditableArtifacts = new LinkedList<>();
- String template;
+ Artifact template;
+ String templateContent = "";
+ String templateOptions = "";
if (artifacts.isEmpty()) {
// Still need to get a default template with a null artifact list
template = getTemplate(null, presentationType);
+ if(template != null) {
+ templateContent = template.getSoleAttributeValue(CoreAttributeTypes.WholeWordContent);
+ templateOptions = template.getSoleAttributeValue(CoreAttributeTypes.RendererOptions);
+ }
} else {
Artifact firstArtifact = artifacts.iterator().next();
template = getTemplate(firstArtifact, presentationType);
+ if(template != null) {
+ templateContent = template.getSoleAttributeValue(CoreAttributeTypes.WholeWordContent);
+ templateOptions = template.getSoleAttributeValue(CoreAttributeTypes.RendererOptions);
+ }
if (presentationType == PresentationType.SPECIALIZED_EDIT && artifacts.size() > 1) {
// currently we can't support the editing of multiple artifacts with OLE data
@@ -210,20 +217,20 @@ public class WordTemplateRenderer extends WordRenderer implements ITemplateRende
artifacts.removeAll(notMultiEditableArtifacts);
} else { // support OLE data when appropriate
if (!firstArtifact.getSoleAttributeValue(CoreAttributeTypes.WordOleData, "").equals("")) {
- template = template.replaceAll(EMBEDDED_OBJECT_NO, EMBEDDED_OBJECT_YES);
- template = template.replaceAll(STYLES_END,
+ templateContent = templateContent.replaceAll(EMBEDDED_OBJECT_NO, EMBEDDED_OBJECT_YES);
+ templateContent = templateContent.replaceAll(STYLES_END,
STYLES_END + OLE_START + firstArtifact.getSoleAttributeValue(CoreAttributeTypes.WordOleData,
"") + OLE_END);
}
}
}
- template = WordUtil.removeGUIDFromTemplate(template);
- return templateProcessor.applyTemplate(artifacts, template, null, null, getStringOption("outlineType"),
+ templateContent = WordUtil.removeGUIDFromTemplate(templateContent);
+ return templateProcessor.applyTemplate(artifacts, templateContent, templateOptions, null, null, getStringOption("outlineType"),
presentationType);
}
- protected String getTemplate(Artifact artifact, PresentationType presentationType) throws OseeCoreException {
+ protected Artifact getTemplate(Artifact artifact, PresentationType presentationType) throws OseeCoreException {
// if USE_TEMPLATE_ONCE then only the first two artifacts will use the whole template (since they are diff'd with each other)
// The settings from the template are stored previously and will be used, just not the content of the Word template
boolean useTemplateOnce = getBooleanOption(USE_TEMPLATE_ONCE);
@@ -242,15 +249,16 @@ public class WordTemplateRenderer extends WordRenderer implements ITemplateRende
setOption(SECOND_TIME, true);
}
}
- return template.getSoleAttributeValue(CoreAttributeTypes.WholeWordContent);
- } else if (option == null || option instanceof String || useTemplateOnce && !firstTime) {
+
+ return template;
+ } else if ((option == null || option instanceof String) || (useTemplateOnce && !firstTime)) {
if (useTemplateOnce && !firstTime && !secondTime) {
option = null;
}
Artifact templateArtifact = TemplateManager.getTemplate(this, artifact, presentationType, (String) option);
- return templateArtifact.getSoleAttributeValue(CoreAttributeTypes.WholeWordContent);
+ return templateArtifact;
}
- return Strings.EMPTY_STRING;
+ return null;
}
@Override
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/AttributeElement.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/AttributeElement.java
index 5e13ef27850..d30cb10f655 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/AttributeElement.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/AttributeElement.java
@@ -10,68 +10,51 @@
*******************************************************************************/
package org.eclipse.osee.framework.ui.skynet.render.word;
-import java.util.logging.Level;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.eclipse.osee.framework.logging.OseeLog;
-import org.eclipse.osee.framework.skynet.core.word.WordUtil;
-import org.eclipse.osee.framework.ui.skynet.internal.Activator;
-
/**
* @author Jeff C. Phillips
*/
public class AttributeElement {
- private static final Pattern internalAttributeElementsPattern =
- Pattern.compile("<((\\w+:)?(Label|Outline|Name|Format|Editable))>(.*?)</\\1>",
- Pattern.CASE_INSENSITIVE | Pattern.DOTALL | Pattern.MULTILINE);
- private String outlineNumber;
private String label;
- private String attributeName;
+ private String attributeType;
private String format;
-
- public AttributeElement(String element) {
- Matcher matcher = internalAttributeElementsPattern.matcher(element);
-
- this.outlineNumber = "";
+ private String formatPre;
+ private String formatPost;
+
+ public AttributeElement()
+ {
this.label = "";
- this.attributeName = "";
+ this.attributeType = "";
+ this.formatPre = "";
+ this.formatPost = "";
this.format = "";
-
- while (matcher.find()) {
- String elementType = matcher.group(3);
- String value = matcher.group(4).trim();
- if (elementType.equals("Outline")) {
- value = WordUtil.textOnly(value);
- if (value.length() > 0) {
- outlineNumber = value;
- } else {
- outlineNumber = "1.0";
- }
- } else if (elementType.equals("Label")) {
- label = value;
- } else if (elementType.equals("Name")) {
- attributeName = WordUtil.textOnly(value);
- } else if (elementType.equals("Format")) {
- format = value;
- } else {
- OseeLog.log(Activator.class, Level.WARNING, "Unexpected element read in Attribute:" + elementType);
- }
- }
+ }
+
+ public void setElements(String attributeType, String label, String formatPre, String formatPost)
+ {
+ this.label = label;
+ this.attributeType = attributeType;
+ this.format = formatPre;
+ this.formatPre = formatPre;
+ this.formatPost = formatPost;
}
public String getAttributeName() {
- return attributeName;
+ return attributeType;
}
public String getFormat() {
return format;
}
+
+ public String getFormatPre() {
+ return formatPre;
+ }
+
+ public String getFormatPost() {
+ return formatPost;
+ }
public String getLabel() {
return label;
}
-
- public String getOutlineNumber() {
- return outlineNumber;
- }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordRendererUtil.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordRendererUtil.java
index 72d8b87d8e4..6fbeac776f5 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordRendererUtil.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordRendererUtil.java
@@ -30,8 +30,4 @@ public class WordRendererUtil {
}
return PageOrientation.fromString(pageTypeValue);
}
-
- public static String getDataRightsClassification(Artifact artifact) {
- return artifact.getSoleAttributeValueAsString(CoreAttributeTypes.DataRightsClassification, "");
- }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateProcessor.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateProcessor.java
index 4621265c3ce..b93b62037a9 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateProcessor.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateProcessor.java
@@ -65,6 +65,9 @@ import org.eclipse.osee.framework.ui.skynet.render.WordTemplateRenderer;
import org.eclipse.osee.framework.ui.skynet.util.WordUiUtil;
import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.program.Program;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
/**
* @author Robert A. Fisher
@@ -77,46 +80,54 @@ public class WordTemplateProcessor {
private static final String ARTIFACT = "Artifact";
private static final String EXTENSION_PROCESSOR = "Extension_Processor";
- private static final String KEY = "Key";
+ private static final String NESTED_TEMPLATE = "NestedTemplate";
public static final String PGNUMTYPE_START_1 = "<w:pgNumType [^>]*w:start=\"1\"/>";
-
- private static final Pattern outlineTypePattern = Pattern.compile("<((\\w+:)?(OutlineType))>(.*?)</\\1>",
- Pattern.CASE_INSENSITIVE | Pattern.DOTALL | Pattern.MULTILINE);
- private static final Pattern outlineNumberPattern =
- Pattern.compile("<((\\w+:)?(Number))>(.*?)</\\1>", Pattern.CASE_INSENSITIVE | Pattern.DOTALL | Pattern.MULTILINE);
- private static final Pattern argumentElementsPattern = Pattern.compile("<((\\w+:)?(Argument))>(.*?)</\\1>",
- Pattern.CASE_INSENSITIVE | Pattern.DOTALL | Pattern.MULTILINE);
- private static final Pattern keyValueElementsPattern = Pattern.compile("<((\\w+:)?(Key|Value))>(.*?)</\\1>",
- Pattern.CASE_INSENSITIVE | Pattern.DOTALL | Pattern.MULTILINE);
- private static final Pattern subDocElementsPattern =
- Pattern.compile("<((\\w+:)?(SubDoc))>(.*?)</\\1>", Pattern.CASE_INSENSITIVE | Pattern.DOTALL | Pattern.MULTILINE);
-
- private static final Pattern setNamePattern =
- Pattern.compile("<(\\w+:)?Set_Name>(.*?)</(\\w+:)?Set_Name>", Pattern.DOTALL | Pattern.MULTILINE);
+
private static final Pattern headElementsPattern =
Pattern.compile("<((\\w+:)?(" + ARTIFACT + "|" + EXTENSION_PROCESSOR + "))>(.*?)</\\1>",
Pattern.CASE_INSENSITIVE | Pattern.DOTALL | Pattern.MULTILINE);
- private static final Pattern attributeElementsPattern = Pattern.compile("<((\\w+:)?(Attribute))>(.*?)</\\3>",
+
+ //The following REGEX are to be used once the Whole Word Content xml no longer contains custom xml tags
+ //NOTE: will have to have new tag for extension processor to know where to insert link
+ private static final Pattern headerPattern = Pattern.compile("<\\w+:?wordDocument.*?<\\w+:?body>",
Pattern.CASE_INSENSITIVE | Pattern.DOTALL | Pattern.MULTILINE);
-
- private static final Pattern outlineElementsPattern = Pattern.compile("<((\\w+:)?(Outline))>(.*?)</\\1>",
+ private static final Pattern footerPattern = Pattern.compile("<\\w+:?sectPr.*?<\\/w+:?wordDocument>",
Pattern.CASE_INSENSITIVE | Pattern.DOTALL | Pattern.MULTILINE);
- private static final Pattern internalOutlineElementsPattern =
- Pattern.compile("<((\\w+:)?(HeadingAttribute|RecurseChildren|Number))>(.*?)</\\1>",
- Pattern.CASE_INSENSITIVE | Pattern.DOTALL | Pattern.MULTILINE);
+
private static final Program wordApp = Program.findProgram("doc");
public static final String ATTRIBUTE_NAME = "AttributeName";
public static final String ALL_ATTRIBUTES = "AllAttributes";
public static final String RECURSE_ON_LOAD = "Recurse On Load";
public static final String RECURSE_CHILDREN = "RecurseChildren";
public static final String PUBLISH_AS_DIFF = "Publish As Diff";
-
+
private String slaveTemplate;
+ private String slaveTemplateOptions;
+
+ private String elementType;
+
+ //Outlining Options
+ private IAttributeType headingAttributeType;
private boolean outlining;
private boolean recurseChildren;
private String outlineNumber;
- private IAttributeType headingAttributeType;
+ private String artifactName;
+
+ //Attribute Options
+ private String attributeLabel;
+ private String attributeType;
+ private String formatPre;
+ private String formatPost;
+
+ //Nested Template Options
+ private String outlineType;
+ private String sectionNumber;
+ private String subDocName;
+ private String key;
+ private String value;
+ private int nestedCount;
+
private final List<AttributeElement> attributeElements = new LinkedList<>();
final List<Artifact> nonTemplateArtifacts = new LinkedList<>();
private final Set<String> ignoreAttributeExtensions = new HashSet<>();
@@ -126,10 +137,9 @@ public class WordTemplateProcessor {
private boolean excludeFolders;
private CharSequence paragraphNumber = null;
private final DataRightInput request;
-
private final DataRightProvider provider;
private IArtifactType[] excludeArtifactTypes;
-
+
public WordTemplateProcessor(WordTemplateRenderer renderer, DataRightProvider provider) {
this.renderer = renderer;
this.provider = provider;
@@ -141,24 +151,33 @@ public class WordTemplateProcessor {
* Parse through template to find xml defining artifact sets and replace it with the result of publishing those
* artifacts Only used by Publish SRS
*/
- public void publishWithExtensionTemplates(Artifact masterTemplateArtifact, Artifact slaveTemplateArtifact, List<Artifact> artifacts) throws OseeCoreException {
+ public void publishWithNestedTemplates(Artifact masterTemplateArtifact, Artifact slaveTemplateArtifact, List<Artifact> artifacts) throws OseeCoreException {
+ nestedCount = 0;
String masterTemplate = masterTemplateArtifact.getSoleAttributeValue(CoreAttributeTypes.WholeWordContent, "");
+ String masterTemplateOptions =
+ masterTemplateArtifact.getSoleAttributeValue(CoreAttributeTypes.RendererOptions, "");
slaveTemplate = "";
+ slaveTemplateOptions = "";
isDiff = renderer.getBooleanOption(PUBLISH_AS_DIFF);
renderer.setOption(ITemplateRenderer.TEMPLATE_OPTION, masterTemplateArtifact);
if (slaveTemplateArtifact != null) {
renderer.setOption(ITemplateRenderer.TEMPLATE_OPTION, slaveTemplateArtifact);
slaveTemplate = slaveTemplateArtifact.getSoleAttributeValue(CoreAttributeTypes.WholeWordContent, "");
+ slaveTemplateOptions =
+ slaveTemplateArtifact.getSoleAttributeValueAsString(CoreAttributeTypes.RendererOptions, "");
}
- // Process the settings from the template at the beginning
- Matcher matcher = headElementsPattern.matcher(masterTemplate);
- matcher.find();
- String artifactElement = matcher.group(4);
- artifactElement = artifactElement.replaceAll("<(\\w+:)?Artifact/?>", "");
- artifactElement = artifactElement.replaceAll("<(\\w+:)?Set_Name>.*?</(\\w+:)?Set_Name>", "");
- extractSkynetAttributeReferences(artifactElement);
+ try {
+ attributeElements.clear();
+ JSONObject jsonObject = new JSONObject(masterTemplateOptions);
+ elementType = jsonObject.getString("ElementType");
+ if (elementType.equals(ARTIFACT)) {
+ parseAttributeOptions(masterTemplateOptions);
+ }
+ } catch (JSONException ex) {
+ OseeCoreException.wrapAndThrow(ex);
+ }
// Need to check if all attributes will be published. If so set the AllAttributes option.
// Assumes that all (*) will not be used when other attributes are specified
renderer.setOption(ALL_ATTRIBUTES, false);
@@ -168,11 +187,12 @@ public class WordTemplateProcessor {
renderer.setOption(ALL_ATTRIBUTES, true);
}
}
-
+
excludeArtifactTypes = renderer.getArtifactTypesOption("EXCLUDE ARTIFACT TYPES").toArray(new IArtifactType[0]);
IFile file =
RenderingUtil.getRenderFile(renderer, COMMON, PREVIEW, "/", masterTemplateArtifact.getSafeName(), ".xml");
- AIFile.writeToFile(file, applyTemplate(artifacts, masterTemplate, file.getParent(), null, null, PREVIEW));
+ AIFile.writeToFile(file,
+ applyTemplate(artifacts, masterTemplate, masterTemplateOptions, file.getParent(), null, null, PREVIEW));
if (!renderer.getBooleanOption(IRenderer.NO_DISPLAY) && !isDiff) {
RenderingUtil.ensureFilenameLimit(file);
@@ -188,7 +208,7 @@ public class WordTemplateProcessor {
* @param folder = null when not using an extension template
* @param outlineNumber if null will find based on first artifact
*/
- public InputStream applyTemplate(List<Artifact> artifacts, String template, IContainer folder, String outlineNumber, String outlineType, PresentationType presentationType) throws OseeCoreException {
+ public InputStream applyTemplate(List<Artifact> artifacts, String templateContent, String templateOptions, IContainer folder, String outlineNumber, String outlineType, PresentationType presentationType) throws OseeCoreException {
excludeFolders = renderer.getBooleanOption("Exclude Folders");
WordMLProducer wordMl = null;
CharBackedInputStream charBak = null;
@@ -196,50 +216,147 @@ public class WordTemplateProcessor {
try {
charBak = new CharBackedInputStream();
wordMl = new WordMLProducer(charBak);
+
+ templateContent = templateContent.replaceAll(PGNUMTYPE_START_1, "");
+ this.outlineNumber =
+ outlineNumber == null ? peekAtFirstArtifactToGetParagraphNumber(templateContent, null, artifacts) : outlineNumber;
+ templateContent = wordMl.setHeadingNumbers(this.outlineNumber, templateContent, outlineType);
+
+ Matcher matcher = headElementsPattern.matcher(templateContent);
+
+ int lastEndIndex = 0;
+ while (matcher.find()) {
+ wordMl.addWordMl(templateContent.substring(lastEndIndex, matcher.start()));
+ lastEndIndex = matcher.end();
+
+ JSONObject jsonObject = new JSONObject(templateOptions);
+ elementType = jsonObject.getString("ElementType");
+
+ if (elementType.equals(ARTIFACT)) {
+ parseOutliningOptions(templateOptions);
+ if (artifacts == null) {
+ artifacts = renderer.getArtifactsOption(artifactName);
+ }
+ if (presentationType == PresentationType.SPECIALIZED_EDIT && artifacts.size() == 1) {
+ // for single edit override outlining options
+ outlining = false;
+ }
+ processArtifactSet(templateOptions, artifacts, wordMl, outlineType, presentationType);
+ } else if (elementType.equals(NESTED_TEMPLATE)) {
+ parseNestedTemplateOptions(templateOptions, folder, wordMl, presentationType);
+ } else {
+ throw new OseeArgumentException("Invalid input [%s]", "");
+ }
+ }
+
+ String endOfTemplate = templateContent.substring(lastEndIndex);
+ // Write out the last of the template
+ wordMl.addWordMl(updateFooter(endOfTemplate));
+
+ displayNonTemplateArtifacts(nonTemplateArtifacts,
+ "Only artifacts of type Word Template Content are supported in this case.");
+
} catch (CharacterCodingException ex) {
OseeCoreException.wrapAndThrow(ex);
+ } catch (JSONException ex) {
+ OseeCoreException.wrapAndThrow(ex);
}
- template = template.replaceAll(PGNUMTYPE_START_1, "");
- this.outlineNumber =
- outlineNumber == null ? peekAtFirstArtifactToGetParagraphNumber(template, null, artifacts) : outlineNumber;
- template = wordMl.setHeadingNumbers(this.outlineNumber, template, outlineType);
- Matcher matcher = headElementsPattern.matcher(template);
+ return charBak;
+ }
- int lastEndIndex = 0;
- while (matcher.find()) {
- // Write the part of the template between the elements
- wordMl.addWordMl(template.substring(lastEndIndex, matcher.start()));
+ private void parseNestedTemplateOptions(String templateOptions, IContainer folder, WordMLProducer wordMl, PresentationType presentationType) {
+ try {
+ JSONObject jsonObject = new JSONObject(templateOptions);
+ JSONArray nestedTemplateOptions = jsonObject.getJSONArray("NestedTemplates");
+ JSONObject options = null;
+
+ if (nestedCount < nestedTemplateOptions.length()) {
+ options = nestedTemplateOptions.getJSONObject(nestedCount);
+ nestedCount++;
+ outlineType = options.getString("OutlineType");
+ sectionNumber = options.getString("SectionNumber");
+ subDocName = options.getString("SubDocName");
+ key = options.getString("Key");
+ value = options.getString("Value");
+
+ renderer.setOption(key, value);
+
+ String artifactName = renderer.getStringOption("Name");
+ String artifactId = renderer.getStringOption("Id");
+ Branch branch = renderer.getBranchOption("Branch");
+ List<Artifact> artifacts = null;
+
+ if (Strings.isValid(artifactId)) {
+ artifacts = ArtifactQuery.getArtifactListFromIds(Arrays.asList(Integer.valueOf(artifactId)), branch,
+ EXCLUDE_DELETED);
+ } else if (Strings.isValid(artifactName)) {
+ artifacts = ArtifactQuery.getArtifactListFromName(artifactName, branch, EXCLUDE_DELETED);
+ }
- lastEndIndex = matcher.end();
- String elementType = matcher.group(3);
- String elementValue = matcher.group(4);
+ String subDocFileName = subDocName + ".xml";
- if (elementType.equals(ARTIFACT)) {
- extractOutliningOptions(elementValue);
- if (artifacts == null) {
- // This handles the case where artifacts selected in the template
- Matcher setNameMatcher = setNamePattern.matcher(elementValue);
- setNameMatcher.find();
- artifacts = renderer.getArtifactsOption(WordUtil.textOnly(setNameMatcher.group(2)));
+ if (isDiff) {
+ WordTemplateFileDiffer templateFileDiffer = new WordTemplateFileDiffer(renderer);
+ templateFileDiffer.generateFileDifferences(artifacts, "/results/" + subDocFileName, sectionNumber,
+ outlineType, recurseChildren);
+ } else {
+ IFile file = folder.getFile(new Path(subDocFileName));
+ AIFile.writeToFile(file, applyTemplate(artifacts, slaveTemplate, slaveTemplateOptions, folder,
+ sectionNumber, outlineType, presentationType));
}
- if (presentationType == PresentationType.SPECIALIZED_EDIT && artifacts.size() == 1) {
- // for single edit override outlining options
- outlining = false;
+ wordMl.createHyperLinkDoc(subDocFileName);
+ }
+
+ } catch (JSONException ex) {
+ OseeCoreException.wrapAndThrow(ex);
+ }
+ }
+
+ private void parseAttributeOptions(String templateOptions) {
+ try {
+ attributeElements.clear();
+
+ JSONObject jsonObject = new JSONObject(templateOptions);
+ JSONArray attributeOptions = jsonObject.getJSONArray("AttributeOptions");
+ JSONObject options = null;
+
+ for (int i = 0; i < attributeOptions.length(); i++) {
+ options = attributeOptions.getJSONObject(i);
+ attributeType = options.getString("AttrType");
+ attributeLabel = options.getString("Label");
+ formatPre = options.getString("FormatPre");
+ formatPost = options.getString("FormatPost");
+
+ AttributeElement temp = new AttributeElement();
+
+ if(attributeType.equals("*") || AttributeTypeManager.typeExists(attributeType)) {
+ temp.setElements(attributeType, attributeLabel, formatPre, formatPost);
+ attributeElements.add(temp);
}
- processArtifactSet(elementValue, artifacts, wordMl, outlineType, presentationType);
- } else if (elementType.equals(EXTENSION_PROCESSOR)) {
- processExtensionTemplate(elementValue, folder, wordMl, presentationType, template);
- } else {
- throw new OseeArgumentException("Invalid input [%s]", elementType);
+
}
+ } catch (JSONException ex) {
+ OseeCoreException.wrapAndThrow(ex);
+ }
+ }
+
+ private void parseOutliningOptions(String templateOptions) {
+ try {
+ JSONObject jsonObject = new JSONObject(templateOptions);
+ JSONArray optionsArray = jsonObject.getJSONArray("OutliningOptions");
+ JSONObject options = optionsArray.getJSONObject(0);
+
+ outlining = options.getBoolean("Outlining");
+ recurseChildren = options.getBoolean("RecurseChildren");
+ String headingAttrType = options.getString("HeadingAttributeType");
+ headingAttributeType = AttributeTypeManager.getType(headingAttrType);
+ outlineNumber = options.getString("OutlineNumber");
+ artifactName = options.getString("ArtifactName");
+
+ } catch (JSONException ex) {
+ OseeCoreException.wrapAndThrow(ex);
}
- String endOfTemplate = template.substring(lastEndIndex);
- // Write out the last of the template
- wordMl.addWordMl(updateFooter(endOfTemplate));
- displayNonTemplateArtifacts(nonTemplateArtifacts,
- "Only artifacts of type Word Template Content are supported in this case.");
- return charBak;
}
private String updateFooter(String endOfTemplate) {
@@ -272,16 +389,17 @@ public class WordTemplateProcessor {
return startParagraphNumber;
}
- private void processArtifactSet(String artifactElement, List<Artifact> artifacts, WordMLProducer wordMl, String outlineType, PresentationType presentationType) throws OseeCoreException {
+ private void processArtifactSet(String templateOptions, List<Artifact> artifacts, WordMLProducer wordMl, String outlineType, PresentationType presentationType) throws OseeCoreException {
nonTemplateArtifacts.clear();
if (Strings.isValid(outlineNumber)) {
wordMl.setNextParagraphNumberTo(outlineNumber);
}
+
// Don't extract the settings from the template if already done.
if (attributeElements.isEmpty()) {
- extractSkynetAttributeReferences(getArtifactSetXml(artifactElement));
+ parseAttributeOptions(templateOptions);
}
-
+
if (renderer.getBooleanOption(PUBLISH_AS_DIFF)) {
WordTemplateFileDiffer templateFileDiffer = new WordTemplateFileDiffer(renderer);
templateFileDiffer.generateFileDifferences(artifacts, "/results/", outlineNumber, outlineType,
@@ -301,103 +419,6 @@ public class WordTemplateProcessor {
processedArtifacts.clear();
}
- private void processExtensionTemplate(String elementValue, IContainer folder, WordMLProducer wordMl, PresentationType presentationType, String template) throws OseeCoreException {
- String subdocumentName = null;
- String nextParagraphNumber = null;
- String outlineType = null;
-
- Matcher matcher = outlineNumberPattern.matcher(elementValue);
- if (matcher.find()) {
- nextParagraphNumber = WordUtil.textOnly(matcher.group(4));
- }
-
- matcher = outlineTypePattern.matcher(elementValue);
- if (matcher.find()) {
- outlineType = WordUtil.textOnly(matcher.group(4));
- }
-
- matcher = subDocElementsPattern.matcher(elementValue);
-
- if (matcher.find()) {
- subdocumentName = WordUtil.textOnly(matcher.group(4));
- }
-
- matcher = argumentElementsPattern.matcher(elementValue);
-
- while (matcher.find()) {
- matcher = keyValueElementsPattern.matcher(matcher.group(4));
-
- String key = null;
- while (matcher.find()) {
- String type = WordUtil.textOnly(matcher.group(3));
-
- if (type.equalsIgnoreCase(KEY)) {
- key = WordUtil.textOnly(matcher.group(4));
- } else {
- String value = WordUtil.textOnly(matcher.group(4));
- renderer.setOption(key, value);
- }
- }
- }
-
- String artifactName = renderer.getStringOption("Name");
- String artifactId = renderer.getStringOption("Id");
- Branch branch = renderer.getBranchOption("Branch");
- List<Artifact> artifacts = null;
-
- if (Strings.isValid(artifactId)) {
- artifacts =
- ArtifactQuery.getArtifactListFromIds(Arrays.asList(Integer.valueOf(artifactId)), branch, EXCLUDE_DELETED);
- } else if (Strings.isValid(artifactName)) {
- artifacts = ArtifactQuery.getArtifactListFromName(artifactName, branch, EXCLUDE_DELETED);
- }
-
- String subDocFileName = subdocumentName + ".xml";
-
- if (isDiff) {
- WordTemplateFileDiffer templateFileDiffer = new WordTemplateFileDiffer(renderer);
- templateFileDiffer.generateFileDifferences(artifacts, "/results/" + subDocFileName, nextParagraphNumber,
- outlineType, recurseChildren);
- } else {
- IFile file = folder.getFile(new Path(subDocFileName));
- AIFile.writeToFile(file,
- applyTemplate(artifacts, slaveTemplate, folder, nextParagraphNumber, outlineType, presentationType));
- }
- wordMl.createHyperLinkDoc(subDocFileName);
- }
-
- private void extractOutliningOptions(String artifactElement) throws OseeCoreException {
- Matcher matcher = outlineElementsPattern.matcher(artifactElement);
- if (matcher.find()) {
- matcher = internalOutlineElementsPattern.matcher(matcher.group(4));
- outlining = true;
-
- // Default values for optional/unspecified parameters
- recurseChildren = false;
-
- while (matcher.find()) {
- String elementType = matcher.group(3);
- String value = WordUtil.textOnly(matcher.group(4));
-
- if (elementType.equals("HeadingAttribute")) {
- headingAttributeType = AttributeTypeManager.getType(value);
- } else if (elementType.equals(RECURSE_CHILDREN)) {
- recurseChildren = renderer.getBooleanOption(RECURSE_CHILDREN);
-
- if (!recurseChildren) {
- recurseChildren = Boolean.parseBoolean(value);
- }
- } else if (elementType.equals("Number")) {
- outlineNumber = value;
- }
- }
- } else {
- outlining = false;
- recurseChildren = false;
- headingAttributeType = null;
- }
- }
-
private void processObjectArtifact(Artifact artifact, WordMLProducer wordMl, String outlineType, PresentationType presentationType, DataRightResult data) throws OseeCoreException {
if (!artifact.isAttributeTypeValid(CoreAttributeTypes.WholeWordContent) && !artifact.isAttributeTypeValid(
CoreAttributeTypes.NativeContent)) {
@@ -490,7 +511,7 @@ public class WordTemplateProcessor {
int index = 0;
for (Artifact artifact : allArtifacts) {
- String classification = WordRendererUtil.getDataRightsClassification(artifact);
+ String classification = artifact.getSoleAttributeValueAsString(CoreAttributeTypes.DataRightsClassification, "");
PageOrientation orientation = WordRendererUtil.getPageOrientation(artifact);
request.addData(artifact.getGuid(), classification, orientation, index);
@@ -574,22 +595,6 @@ public class WordTemplateProcessor {
}
}
- private String getArtifactSetXml(String artifactElement) {
- artifactElement = artifactElement.replaceAll("<(\\w+:)?Artifact/?>", "");
- artifactElement = artifactElement.replaceAll("<(\\w+:)?Set_Name>.*?</(\\w+:)?Set_Name>", "");
-
- return artifactElement;
- }
-
- private void extractSkynetAttributeReferences(String artifactElementTemplate) {
- attributeElements.clear();
- Matcher matcher = attributeElementsPattern.matcher(artifactElementTemplate);
-
- while (matcher.find()) {
- attributeElements.add(new AttributeElement(matcher.group(4)));
- }
- }
-
private void loadIgnoreAttributeExtensions() {
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
if (extensionRegistry != null) {

Back to the top