Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmisinco2014-07-30 15:40:24 +0000
committerRoberto E. Escobar2014-09-29 22:54:53 +0000
commit1a83cc0f605870cd5d1481b637942a831c239998 (patch)
treecba573aaa7b9913d43d48b93766781c8f866036e
parent3e5aa7bc94b3620376ca01e5332b10c5f525ded3 (diff)
downloadorg.eclipse.osee-1a83cc0f605870cd5d1481b637942a831c239998.tar.gz
org.eclipse.osee-1a83cc0f605870cd5d1481b637942a831c239998.tar.xz
org.eclipse.osee-1a83cc0f605870cd5d1481b637942a831c239998.zip
feature[ats_ATS81639]: Add data rights footer during publishing
-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.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/WordTemplateRenderer.java4
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/ArtifactDataRightsProvider.java73
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateProcessor.java32
4 files changed, 108 insertions, 2 deletions
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 2d51792b634..38b19675c4f 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
@@ -36,6 +36,7 @@ public final class CoreAttributeTypes {
public static final IAttributeType Country = TokenFactory.createAttributeType(0x1000000000000060L, "Country");
public static final IAttributeType CrewInterfaceRequirement = TokenFactory.createAttributeType(0x1000000000000082L, "Crew Interface Requirement");
public static final IAttributeType Csci = TokenFactory.createAttributeType(0x10000000000000A0L, "CSCI");
+ public static final IAttributeType DataRightsClassification = TokenFactory.createAttributeType(0x1000000000000155L, "Data Rights Classification");
public static final IAttributeType DefaultMailServer = TokenFactory.createAttributeType(0x1000000000000057L, "osee.config.Default Mail Server");
public static final IAttributeType DefaultGroup = TokenFactory.createAttributeType(0x100000000000006EL, "Default Group");
public static final IAttributeType Description = TokenFactory.createAttributeType(0x1000000000000072L, "Description");
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 78ea41fd1b3..50585ee499d 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
@@ -38,6 +38,7 @@ import org.eclipse.osee.framework.skynet.core.types.IArtifact;
import org.eclipse.osee.framework.skynet.core.word.WordUtil;
import org.eclipse.osee.framework.ui.skynet.render.compare.IComparator;
import org.eclipse.osee.framework.ui.skynet.render.compare.WordTemplateCompare;
+import org.eclipse.osee.framework.ui.skynet.render.word.ArtifactDataRightsProvider;
import org.eclipse.osee.framework.ui.skynet.render.word.AttributeElement;
import org.eclipse.osee.framework.ui.skynet.render.word.Producer;
import org.eclipse.osee.framework.ui.skynet.render.word.WordMLProducer;
@@ -65,7 +66,8 @@ public class WordTemplateRenderer extends WordRenderer implements ITemplateRende
public static final String FIRST_TIME = "FirstTime";
public static final String SECOND_TIME = "SecondTime";
- private final WordTemplateProcessor templateProcessor = new WordTemplateProcessor(this);
+ private final WordTemplateProcessor templateProcessor = new WordTemplateProcessor(this,
+ new ArtifactDataRightsProvider());
private final IComparator comparator;
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/ArtifactDataRightsProvider.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/ArtifactDataRightsProvider.java
new file mode 100644
index 00000000000..6098347e188
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/ArtifactDataRightsProvider.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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.ui.skynet.render.word;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.eclipse.osee.framework.core.data.IArtifactToken;
+import org.eclipse.osee.framework.core.data.TokenFactory;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.ui.skynet.render.word.WordTemplateProcessor.DataRightsProvider;
+
+/**
+ * @author John Misinco
+ */
+public class ArtifactDataRightsProvider implements DataRightsProvider {
+
+ private static final String NEW_PAGE_TEMPLATE =
+ "<w:p><w:pPr><w:spacing w:after=\"0\"/><w:sectPr>%s</w:sectPr></w:pPr></w:p>";
+ private static final String SAME_PAGE_TEMPLATE = "<w:sectPr>%s</w:sectPr>";
+ private static final String GENERIC_FOOTER =
+ "<w:ftr w:type=\"odd\"><w:p><w:pPr><w:pStyle w:val=\"Footer\"/></w:pPr><w:r><w:t>%s</w:t></w:r></w:p></w:ftr>";
+ private static final IArtifactToken MAPPING_ARTIFACT = TokenFactory.createArtifactToken("AOkJ_kFNbEXCS7UjmfwA",
+ "DataRightsFooters", CoreArtifactTypes.GeneralData);
+
+ private Map<String, String> dataRightsToFooters;
+
+ @Override
+ public String getDataClassificationFooter(String classification, boolean createNewPageFooter) {
+ if (dataRightsToFooters == null) {
+ initialize();
+ }
+
+ String footer = null;
+ if (!Strings.isValid(classification)) {
+ footer = String.format(GENERIC_FOOTER, "DATA RIGHTS CLASSIFICATION MISSING");
+ } else {
+ footer = dataRightsToFooters.get(classification);
+ if (!Strings.isValid(footer)) {
+ String text = String.format("FOOTER NOT DEFINED FOR [%s]", classification);
+ footer = String.format(GENERIC_FOOTER, text);
+ }
+ }
+ return createNewPageFooter ? String.format(NEW_PAGE_TEMPLATE, footer) : String.format(SAME_PAGE_TEMPLATE, footer);
+ }
+
+ private void initialize() {
+ dataRightsToFooters = new HashMap<String, String>();
+ Artifact art =
+ ArtifactQuery.getOrCreate(MAPPING_ARTIFACT.getGuid(), MAPPING_ARTIFACT.getArtifactType(), CoreBranches.COMMON);
+ List<String> footers = art.getAttributesToStringList(CoreAttributeTypes.GeneralStringData);
+ for (String footer : footers) {
+ String[] enumToFooter = footer.split("\\n", 2);
+ if (enumToFooter.length == 2) {
+ dataRightsToFooters.put(enumToFooter[0].trim(), enumToFooter[1].trim());
+ }
+ }
+ }
+
+}
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 e436fb8168f..0c23ebcf04a 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
@@ -118,8 +118,18 @@ public class WordTemplateProcessor {
private boolean excludeFolders;
private CharSequence paragraphNumber = null;
- public WordTemplateProcessor(WordTemplateRenderer renderer) {
+ private String previousClassification = null;
+ private boolean firstArtifact = true;
+ private boolean dataRightsDetected = false;
+ private final DataRightsProvider dataRightsProvider;
+
+ public static interface DataRightsProvider {
+ String getDataClassificationFooter(String classification, boolean createNewPageFooter);
+ }
+
+ public WordTemplateProcessor(WordTemplateRenderer renderer, DataRightsProvider dataRightsProvider) {
this.renderer = renderer;
+ this.dataRightsProvider = dataRightsProvider;
loadIgnoreAttributeExtensions();
}
@@ -263,6 +273,10 @@ public class WordTemplateProcessor {
for (Artifact artifact : artifacts) {
processObjectArtifact(artifact, wordMl, outlineType, presentationType, artifacts.size() > 1);
}
+ if (dataRightsDetected) {
+ String footer = dataRightsProvider.getDataClassificationFooter(previousClassification, false);
+ wordMl.addWordMl(footer);
+ }
}
// maintain a list of artifacts that have been processed so we do not
// have duplicates.
@@ -377,7 +391,13 @@ public class WordTemplateProcessor {
boolean templateOnly = renderer.getBooleanOption("TEMPLATE ONLY");
boolean includeUUIDs = renderer.getBooleanOption("INCLUDE UUIDS");
+ String dataRights = "";
+
if (!ignoreArtifact) {
+
+ dataRights = artifact.getSoleAttributeValueAsString(CoreAttributeTypes.DataRightsClassification, "");
+ dataRightsDetected = dataRightsDetected || Strings.isValid(dataRights);
+
handleLandscapeArtifactSectionBreak(artifact, wordMl, multipleArtifacts);
if (outlining && !templateOnly) {
@@ -393,6 +413,15 @@ public class WordTemplateProcessor {
headingText = headingText.concat(" [MERGED]");
}
+ if (!firstArtifact && !dataRights.equals(previousClassification)) {
+ String footer = dataRightsProvider.getDataClassificationFooter(previousClassification, true);
+ wordMl.addWordMl(footer);
+ } else if (dataRightsDetected && !Strings.isValid(dataRights)) {
+ String footer = dataRightsProvider.getDataClassificationFooter(dataRights, true);
+ wordMl.addWordMl(footer);
+ }
+ firstArtifact = false;
+
if (!publishInline && !templateOnly) {
paragraphNumber = wordMl.startOutlineSubSection("Times New Roman", headingText, outlineType);
startedSection = true;
@@ -419,6 +448,7 @@ public class WordTemplateProcessor {
}
processAttributes(artifact, wordMl, presentationType, multipleArtifacts, publishInline);
+ previousClassification = dataRights;
}
// Check for option that may have been set from Publish with Diff BLAM to recurse
if ((recurseChildren && !renderer.getBooleanOption(RECURSE_ON_LOAD)) || (renderer.getBooleanOption(RECURSE_ON_LOAD) && !renderer.getBooleanOption("Orig Publish As Diff"))) {

Back to the top