Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormegumi.telles2017-10-31 21:30:15 +0000
committermegumi.telles2017-11-03 14:42:46 +0000
commit2312c1c61c793cbe2a122ef412903fe9ff8634e3 (patch)
treeaf9061238cd94f43668f32aa290188499389ac8f
parentee57cf9adf2fe6ce65ccaaabce5b3ac93a6b364d (diff)
downloadorg.eclipse.osee-2312c1c61c793cbe2a122ef412903fe9ff8634e3.tar.gz
org.eclipse.osee-2312c1c61c793cbe2a122ef412903fe9ff8634e3.tar.xz
org.eclipse.osee-2312c1c61c793cbe2a122ef412903fe9ff8634e3.zip
feature[ats_TW1895]: Update/Create Publish Check Blams
-rw-r--r--plugins/org.eclipse.osee.define/plugin.xml12
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/FindDuplicateArtifactNames.java139
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/FindErroneousEmbeddedLinksBlam.java74
-rw-r--r--plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/FindMissingOrUnspecifiedAttributes.java80
4 files changed, 290 insertions, 15 deletions
diff --git a/plugins/org.eclipse.osee.define/plugin.xml b/plugins/org.eclipse.osee.define/plugin.xml
index b24e60de919..827b702fa8f 100644
--- a/plugins/org.eclipse.osee.define/plugin.xml
+++ b/plugins/org.eclipse.osee.define/plugin.xml
@@ -291,4 +291,16 @@
className="org.eclipse.osee.define.blam.operation.FindErroneousEmbeddedLinksBlam">
</Operation>
</extension>
+ <extension
+ point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
+ <Operation
+ className="org.eclipse.osee.define.blam.operation.FindDuplicateArtifactNames">
+ </Operation>
+ </extension>
+ <extension
+ point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
+ <Operation
+ className="org.eclipse.osee.define.blam.operation.FindMissingOrUnspecifiedAttributes">
+ </Operation>
+ </extension>
</plugin>
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/FindDuplicateArtifactNames.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/FindDuplicateArtifactNames.java
new file mode 100644
index 00000000000..649275ffa9a
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/FindDuplicateArtifactNames.java
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2017 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.define.blam.operation;
+
+import java.io.File;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.data.ArtifactId;
+import org.eclipse.osee.framework.core.data.BranchId;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.DeletionFlag;
+import org.eclipse.osee.framework.jdk.core.util.io.xml.ExcelXmlWriter;
+import org.eclipse.osee.framework.jdk.core.util.io.xml.ISheetWriter;
+import org.eclipse.osee.framework.plugin.core.util.OseeData;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.skynet.core.utility.ViewIdUtility;
+import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
+import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
+import org.eclipse.osee.framework.ui.skynet.branch.ViewApplicabilityUtil;
+import org.eclipse.osee.framework.ui.skynet.widgets.XCombo;
+import org.eclipse.osee.framework.ui.skynet.widgets.XListDropViewer;
+import org.eclipse.osee.framework.ui.skynet.widgets.XModifiedListener;
+import org.eclipse.osee.framework.ui.skynet.widgets.XWidget;
+import org.eclipse.osee.framework.ui.skynet.widgets.util.SwtXWidgetRenderer;
+import org.eclipse.swt.program.Program;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/**
+ * @author Megumi Telles
+ */
+public class FindDuplicateArtifactNames extends AbstractBlam {
+ private static final String ROOT_ARTIFACTS = "Root Artifacts";
+
+ private XCombo branchViewWidget;
+ private XListDropViewer viewerWidget;
+
+ @Override
+ public String getName() {
+ return "Find Artifacts With Duplicate Names";
+ }
+
+ @Override
+ public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
+ DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss");
+ Date date = new Date();
+ File file = OseeData.getFile("DUP_NAMES_" + dateFormat.format(date) + ".xml");
+ ISheetWriter excelWriter = new ExcelXmlWriter(file);
+
+ List<Artifact> artifacts = variableMap.getArtifacts(ROOT_ARTIFACTS);
+ BranchId branch = artifacts.get(0).getBranch();
+
+ Object view = variableMap.getValue(BRANCH_VIEW);
+ setViewId(view);
+ Set<ArtifactId> findExcludedArtifactsByView = ViewIdUtility.findExcludedArtifactsByView(viewId, branch);
+
+ excelWriter.startSheet("Report", 6);
+ excelWriter.writeRow("Root Artifact", "Subsystem", "Artifact Name", "Artifact Type", "Art Id", "Guid");
+ for (Artifact artifact : artifacts) {
+ List<Artifact> children = artifact.getChildren();
+ for (Artifact child : children) {
+ List<Artifact> artifactListFromName =
+ ArtifactQuery.getArtifactListFromName(child.getName(), branch, DeletionFlag.EXCLUDE_DELETED);
+ if (artifactListFromName != null) {
+ ViewIdUtility.removeExcludedArtifacts(artifactListFromName.iterator(), findExcludedArtifactsByView);
+ }
+ if (artifactListFromName.size() > 1) {
+ for (Artifact art : artifactListFromName) {
+ String subsystem = art.getSoleAttributeValueAsString(CoreAttributeTypes.Subsystem, "");
+ excelWriter.writeRow(artifact.getName(), subsystem, art.getName(), art.getArtifactType().getName(),
+ art.getArtId(), art.getGuid());
+ }
+ }
+ }
+ }
+ excelWriter.endSheet();
+ excelWriter.endWorkbook();
+ Program.launch(file.getAbsolutePath());
+ }
+
+ @Override
+ public void widgetCreated(XWidget xWidget, FormToolkit toolkit, Artifact art, SwtXWidgetRenderer dynamicXWidgetLayout, XModifiedListener xModListener, boolean isEditable) {
+ super.widgetCreated(xWidget, toolkit, art, dynamicXWidgetLayout, xModListener, isEditable);
+ if (xWidget.getLabel().equals(ROOT_ARTIFACTS)) {
+ viewerWidget = (XListDropViewer) xWidget;
+ viewerWidget.addXModifiedListener(new XModifiedListener() {
+
+ @Override
+ public void widgetModified(XWidget widget) {
+ if (branchViewWidget != null) {
+ branchViewWidget.setEditable(true);
+ List<Artifact> arts = viewerWidget.getArtifacts();
+ if (arts != null && !arts.isEmpty()) {
+ BranchId branch = arts.iterator().next().getBranch();
+ if (branch != null && branch.isValid()) {
+ branchViews =
+ ViewApplicabilityUtil.getBranchViews(ViewApplicabilityUtil.getParentBranch(branch));
+ branchViewWidget.setDataStrings(branchViews.values());
+ }
+ }
+ }
+ }
+ });
+ } else if (xWidget.getLabel().equals(BRANCH_VIEW)) {
+ branchViewWidget = (XCombo) xWidget;
+ branchViewWidget.setEditable(false);
+ }
+ }
+
+ @Override
+ public String getXWidgetsXml() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("<xWidgets>");
+ builder.append("<XWidget xwidgetType=\"XListDropViewer\" displayName=\"Root Artifacts\" />");
+ builder.append(BRANCH_VIEW_WIDGET);
+ builder.append("</xWidgets>");
+ return builder.toString();
+ }
+
+ @Override
+ public Collection<String> getCategories() {
+ return Arrays.asList("Define.Publish.Check");
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/FindErroneousEmbeddedLinksBlam.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/FindErroneousEmbeddedLinksBlam.java
index 5eb32b9eb36..178703af328 100644
--- a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/FindErroneousEmbeddedLinksBlam.java
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/FindErroneousEmbeddedLinksBlam.java
@@ -10,18 +10,28 @@
*******************************************************************************/
package org.eclipse.osee.define.blam.operation;
+import java.io.File;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Collections;
+import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.osee.framework.core.data.BranchId;
+import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.jdk.core.type.HashCollection;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.ResultSet;
import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.jdk.core.util.io.xml.ExcelXmlWriter;
+import org.eclipse.osee.framework.jdk.core.util.io.xml.ISheetWriter;
+import org.eclipse.osee.framework.plugin.core.util.OseeData;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.skynet.core.artifact.search.QueryBuilderArtifact;
@@ -29,6 +39,7 @@ import org.eclipse.osee.framework.skynet.core.linking.WordMlLinkHandler;
import org.eclipse.osee.framework.skynet.core.linking.WordMlLinkHandler.MatchRange;
import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
+import org.eclipse.swt.program.Program;
/**
* @author Megumi Telles
@@ -36,16 +47,22 @@ import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
public class FindErroneousEmbeddedLinksBlam extends AbstractBlam {
private static final String BRANCH = "Branch Input";
+ private static final String ARTIFACT_TYPES = "Artifact Types";
@Override
public String getXWidgetsXml() throws OseeCoreException {
- return String.format("<xWidgets><XWidget xwidgetType=\"XBranchSelectWidget\" displayName=\"%s\"/></xWidgets>",
- BRANCH);
+ StringBuilder builder = new StringBuilder();
+ builder.append(
+ String.format("<xWidgets><XWidget xwidgetType=\"XBranchSelectWidget\" displayName=\"%s\"/>", BRANCH));
+ builder.append(String.format(
+ "<XWidget xwidgetType=\"XArtifactTypeMultiChoiceSelect\" displayName=\"Artifact Types\" />", ARTIFACT_TYPES));
+ builder.append("</xWidgets>");
+ return builder.toString();
}
@Override
public String getDescriptionUsage() {
- return "For a given branch, locate all WordTemplateContent attributes and list those artifacts with hyperlinks pointing to itself";
+ return "For a given branch, locate all WordTemplateContent attributes and list those artifacts with invalid hyperlinks";
}
@Override
@@ -55,18 +72,29 @@ public class FindErroneousEmbeddedLinksBlam extends AbstractBlam {
@Override
public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
+ DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss");
+ Date date = new Date();
+ File file = OseeData.getFile("INVALID_LINKS_" + dateFormat.format(date) + ".xml");
+ ISheetWriter excelWriter = new ExcelXmlWriter(file);
+
BranchId branch = variableMap.getBranch(BRANCH);
+ List<IArtifactType> artifactTypes = variableMap.getArtifactTypes(ARTIFACT_TYPES);
+
QueryBuilderArtifact queryBuilder = ArtifactQuery.createQueryBuilder(branch);
queryBuilder.andExists(CoreAttributeTypes.WordTemplateContent);
ResultSet<Artifact> arts = queryBuilder.getResults();
Iterator<Artifact> artIter = arts.iterator();
+
+ excelWriter.startSheet("Invalid Links", 6);
+ excelWriter.writeRow("Type", "Artifact", "Artifact Type", "Guid", "Subsystem", "Invalid Link Guid");
while (artIter.hasNext()) {
Artifact artifact = artIter.next();
- if (artifact.isAttributeTypeValid(CoreAttributeTypes.WordTemplateContent)) {
+ if (artifact.isAttributeTypeValid(CoreAttributeTypes.WordTemplateContent) && //
+ isOfTypes(artifactTypes, artifact)) {
try {
String content = artifact.getSoleAttributeValueAsString(CoreAttributeTypes.WordTemplateContent, "");
if (Strings.isValid(content)) {
- findIncorrectLinks(artifact, content);
+ findIncorrectLinks(artifact, content, excelWriter);
}
} catch (OseeCoreException ex) {
logf("Artifact: [%s]: [%s]", artifact.getName(), ex);
@@ -74,43 +102,59 @@ public class FindErroneousEmbeddedLinksBlam extends AbstractBlam {
}
artIter.remove();
}
+ excelWriter.endSheet();
+ excelWriter.endWorkbook();
+ Program.launch(file.getAbsolutePath());
}
- private void findIncorrectLinks(Artifact artifact, String content) {
+ private boolean isOfTypes(List<IArtifactType> artifactTypes, Artifact artifact) {
+ for (IArtifactType type : artifactTypes) {
+ if (artifact.isOfType(type)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void findIncorrectLinks(Artifact artifact, String content, ISheetWriter excelWriter) throws IOException {
Set<String> unknownGuids = new HashSet<>();
HashCollection<String, MatchRange> links = WordMlLinkHandler.getLinks(content);
if (!links.isEmpty()) {
unknownGuids.addAll(links.keySet());
}
-
+
Iterator<String> guidIter = unknownGuids.iterator();
while (guidIter.hasNext()) {
// Pointing to itself
String linkGuid = guidIter.next();
- logLinksToSelf(artifact, linkGuid);
- logInvalidGuidLink(artifact, linkGuid);
-
+ logLinksToSelf(artifact, linkGuid, excelWriter);
+ logInvalidGuidLink(artifact, linkGuid, excelWriter);
+
guidIter.remove();
}
}
- private void logInvalidGuidLink(Artifact artifact, String linkGuid) {
+ private void logInvalidGuidLink(Artifact artifact, String linkGuid, ISheetWriter excelWriter) throws IOException {
try {
ArtifactQuery.getArtifactFromId(linkGuid, artifact.getBranch());
} catch (Exception e) {
- logf("Warning: this artifact contains an invalid link - Artifact: [%s] Guid: [%s] Invalid Link Guid: [%s]", artifact.getName(), artifact.getGuid(), linkGuid);
+ String subsystem = artifact.getSoleAttributeValueAsString(CoreAttributeTypes.Subsystem, "");
+ excelWriter.writeRow("Invalid", artifact.getName(), artifact.getArtifactType().getName(), artifact.getGuid(),
+ subsystem, linkGuid);
}
}
- private void logLinksToSelf(Artifact artifact, String linkGuid) {
+ private void logLinksToSelf(Artifact artifact, String linkGuid, ISheetWriter excelWriter) throws IOException {
+ String subsystem = artifact.getSoleAttributeValueAsString(CoreAttributeTypes.Subsystem, "");
if (linkGuid.equals(artifact.getGuid())) {
- logf("Warning: this artifact contains a link pointing to itself - Artifact: [%s] Guid: [%s]", artifact.getName(), artifact.getGuid());
+ excelWriter.writeRow("Link to Self", artifact.getName(), artifact.getArtifactType().getName(),
+ artifact.getGuid(), subsystem, linkGuid);
}
}
@Override
public Collection<String> getCategories() {
- return Collections.singletonList("Util");
+ return Collections.singletonList("Define.Publish.Check");
}
}
diff --git a/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/FindMissingOrUnspecifiedAttributes.java b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/FindMissingOrUnspecifiedAttributes.java
new file mode 100644
index 00000000000..8d6133b14b1
--- /dev/null
+++ b/plugins/org.eclipse.osee.define/src/org/eclipse/osee/define/blam/operation/FindMissingOrUnspecifiedAttributes.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2017 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.define.blam.operation;
+
+import java.io.File;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.data.AttributeId;
+import org.eclipse.osee.framework.core.data.BranchId;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.model.type.AttributeType;
+import org.eclipse.osee.framework.jdk.core.util.io.xml.ExcelXmlWriter;
+import org.eclipse.osee.framework.jdk.core.util.io.xml.ISheetWriter;
+import org.eclipse.osee.framework.plugin.core.util.OseeData;
+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.blam.AbstractBlam;
+import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
+import org.eclipse.swt.program.Program;
+
+/**
+ * @author Megumi Telles
+ */
+public class FindMissingOrUnspecifiedAttributes extends AbstractBlam {
+
+ @Override
+ public String getName() {
+ return "Find Artifacts with Unspecified Attributes";
+ }
+
+ @Override
+ public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
+ DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss");
+ Date date = new Date();
+ File file = OseeData.getFile("UNSPECIFIED_" + dateFormat.format(date) + ".xml");
+ ISheetWriter excelWriter = new ExcelXmlWriter(file);
+
+ BranchId branch = variableMap.getBranch("Branch");
+ AttributeType attributeType = variableMap.getAttributeType("Attribute Type");
+
+ // Unspecified
+ List<Artifact> artifacts =
+ ArtifactQuery.getArtifactListFromAttribute(attributeType, AttributeId.UNSPECIFIED, branch);
+ excelWriter.startSheet("Attrs", 6);
+ excelWriter.writeRow("Artifact", "Artifact Type", "Subsystem", "Guid", "Attribute Type", "Attribute Value");
+ for (Artifact art : artifacts) {
+ String subsystem = art.getSoleAttributeValueAsString(CoreAttributeTypes.Subsystem, "");
+ excelWriter.writeRow(art.getName(), art.getArtifactType(), subsystem, art.getGuid(), attributeType,
+ AttributeId.UNSPECIFIED.toString());
+ }
+ excelWriter.endSheet();
+ excelWriter.endWorkbook();
+ Program.launch(file.getAbsolutePath());
+ }
+
+ @Override
+ public String getXWidgetsXml() {
+ return "<xWidgets><XWidget xwidgetType=\"XAttributeTypeMultiChoiceSelect\" displayName=\"Attribute Type\" />" + //
+ "<XWidget xwidgetType=\"XBranchSelectWidget\" displayName=\"Branch\" /></xWidgets>";
+ }
+
+ @Override
+ public Collection<String> getCategories() {
+ return Arrays.asList("Define.Publish.Check");
+ }
+
+}

Back to the top