Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2012-11-14 22:46:09 +0000
committerRoberto E. Escobar2012-11-14 22:46:09 +0000
commit45eff165b34ae3fd70d085214653474551496c7c (patch)
tree2f5e575027618671a7fa9abff854ddd09b9070df
parent311028ac2ae680fd1872b8d4cb84ce5f589bb462 (diff)
downloadorg.eclipse.osee-45eff165b34ae3fd70d085214653474551496c7c.tar.gz
org.eclipse.osee-45eff165b34ae3fd70d085214653474551496c7c.tar.xz
org.eclipse.osee-45eff165b34ae3fd70d085214653474551496c7c.zip
feature[ats_TL5SF]: Remove unused db init type gen class
-rw-r--r--plugins/org.eclipse.osee.framework.database.init/src/org/eclipse/osee/framework/database/init/SkynetTypesEnumGenerator.java262
-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/GenerateTypeEnumAction.java169
3 files changed, 0 insertions, 432 deletions
diff --git a/plugins/org.eclipse.osee.framework.database.init/src/org/eclipse/osee/framework/database/init/SkynetTypesEnumGenerator.java b/plugins/org.eclipse.osee.framework.database.init/src/org/eclipse/osee/framework/database/init/SkynetTypesEnumGenerator.java
deleted file mode 100644
index 4f66f843b38..00000000000
--- a/plugins/org.eclipse.osee.framework.database.init/src/org/eclipse/osee/framework/database/init/SkynetTypesEnumGenerator.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 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.database.init;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.TreeSet;
-import java.util.regex.Pattern;
-import org.eclipse.osee.framework.jdk.core.util.io.xml.ExcelSaxHandler;
-import org.eclipse.osee.framework.jdk.core.util.io.xml.RowProcessor;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.XMLReaderFactory;
-
-public class SkynetTypesEnumGenerator implements RowProcessor {
- private static final Pattern nonJavaCharP = Pattern.compile("[^a-zA-Z_0-9]");
-
- private static final String relationImports =
- "import java.sql.SQLException;\n" + "import org.eclipse.osee.framework.skynet.core.artifact.Branch;\n" + "import org.eclipse.osee.framework.skynet.core.relation.IRelationEnumeration;\n" + "import org.eclipse.osee.framework.skynet.core.relation.RelationLink;\n" + "import org.eclipse.osee.framework.skynet.core.relation.RelationPersistenceManager;\n" + "import org.eclipse.osee.framework.skynet.core.relation.RelationSide;\n" + "import org.eclipse.osee.framework.skynet.core.relation.RelationType;\n" + "import org.eclipse.osee.framework.skynet.core.relation.RelationTypeManager;\n\n";
-
- private static final String relationEnumCode =
- " private boolean sideA;\n" + "\n" + " private String typeName;\n" + "\n" + " private CLASSNAME_PLACEHOLDER(boolean sideA, String typeName) {\n" + " this.sideA = sideA;\n" + " this.typeName = typeName;\n" + " RelationPersistenceManager.sideHash.put(typeName, sideA, this);\n" + " }\n" + " \n" + " public static IRelationEnumeration getRelationSide(String relationType, String relationSide, Branch branch) throws SQLException {\n" + " RelationType desc = RelationTypeManager.getType(relationType);\n" + " boolean isSideA = (desc.getSideAName().equals(relationSide));\n" + " return RelationPersistenceManager.sideHash.get(relationType, isSideA);\n" + " }\n" + "\n" + " /**\n" + " * @return Returns the sideName.\n" + " */\n" + " public boolean isSideA() {\n" + " return sideA;\n" + " }\n" + "\n" + " public String getSideName(Branch branch) throws SQLException {\n" + " if (isSideA())\n" + " return getRelationType().getSideAName();\n" + " else\n" + " return getRelationType().getSideBName();\n" + " }\n" + "\n" + " /**\n" + " * @return Returns the typeName.\n" + " */\n" + " public String getName() {\n" + " return typeName;\n" + " }\n" + "\n" + " public RelationType getRelationType() throws SQLException {\n" + " return RelationTypeManager.getType(typeName);\n" + " }\n" + " \n" + " public RelationSide getSide() { \n" + " return sideA ? RelationSide.SIDE_A : RelationSide.SIDE_B;\n" + "}\n\n" + " public String getSideName() throws SQLException {\n" + " if (isSideA()) {\n" + " return getRelationType().getSideAName();\n" + " } else {\n" + " return getRelationType().getSideBName();\n}\n}\n";
-
- private enum Table {
- ARTIFACT_TYPE_TABLE,
- ATTRIBUTE_TYPE_TABLE,
- ATTRIBUTE_MAP_TABLE,
- RELATION_TYPE_TABLE,
- RELATION_SIDE_TABLE
- }
-
- private static final String description = "Setup artifact, attribute, and relation type data";
-
- private final ExcelSaxHandler excelHandler;
-
- private Table currentTable;
-
- private Iterator<Table> tableIterator;
-
- private boolean done;
-
- private final XMLReader xmlReader;
-
- private final TreeSet<String> artifacts;
-
- private final TreeSet<String> attributes;
-
- private final TreeSet<String> relations;
-
- private String sheetName;
-
- private File destinationDir;
-
- private static final String skynetTypeCode =
- " private String name;\n private CLASSNAME_PLACEHOLDER(String name){ this.name = name; }\n public String getName(){ return this.name;}\n";
-
- public SkynetTypesEnumGenerator() throws SAXException {
-
- excelHandler = new ExcelSaxHandler(this, true, true);
-
- xmlReader = XMLReaderFactory.createXMLReader();
- xmlReader.setContentHandler(excelHandler);
-
- artifacts = new TreeSet<String>();
- attributes = new TreeSet<String>();
- relations = new TreeSet<String>();
- }
-
- public void extractTypesFromSheet(File importFile, File destinationDir) throws IOException, SAXException {
- done = false;
- tableIterator = Arrays.asList(Table.values()).iterator();
- xmlReader.parse(new InputSource(new FileInputStream(importFile)));
-
- this.destinationDir =
- destinationDir != null && destinationDir.isDirectory() ? destinationDir : importFile.getParentFile();
- }
-
- public void finish() throws IOException {
- BufferedWriter out;
- //relation enum gen
- String relClassName = this.sheetName + "_RELATIONS";
- out = new BufferedWriter(new FileWriter(new File(destinationDir, relClassName + ".java")));
- out.append("\n\n");
- out.append(relationImports);
- out.append("public enum ");
- out.append(relClassName);
- out.append(" implements IRelationEnumeration {\n");
- Iterator<String> it = relations.iterator();
- while (it.hasNext()) {
- out.append(" ");
- out.append(it.next());
- if (it.hasNext()) {
- out.append(",\n");
- }
- }
- out.append(";\n");
- out.append(relationEnumCode.replace("CLASSNAME_PLACEHOLDER", relClassName));
- out.append("}");
- out.close();
- //attribute enum gen
- String attrClassName = this.sheetName + "_ATTRIBUTES";
- out = new BufferedWriter(new FileWriter(new File(destinationDir, attrClassName + ".java")));
- out.append("\n\nimport org.eclipse.osee.framework.skynet.core.ISkynetType;\n\npublic enum ");
- out.append(attrClassName);
- out.append(" implements ISkynetType {\n");
- it = attributes.iterator();
- while (it.hasNext()) {
- out.append(" ");
- out.append(it.next());
- if (it.hasNext()) {
- out.append(",\n");
- }
- }
- out.append(";\n\n");
- out.append(skynetTypeCode.replace("CLASSNAME_PLACEHOLDER", attrClassName));
- out.append("}");
- out.close();
- //artifact enum gen
- String artClassName = this.sheetName + "_ARTIFACTS";
- out = new BufferedWriter(new FileWriter(new File(destinationDir, artClassName + ".java")));
- out.append("\n\nimport org.eclipse.osee.framework.skynet.core.ISkynetType;\n\npublic enum ");
- out.append(artClassName);
- out.append(" implements ISkynetType {\n");
- it = artifacts.iterator();
- while (it.hasNext()) {
- out.append(" ");
- out.append(it.next());
- if (it.hasNext()) {
- out.append(",\n");
- }
- }
- out.append(";\n\n");
- out.append(skynetTypeCode.replace("CLASSNAME_PLACEHOLDER", artClassName));
- out.append("}");
- out.close();
- }
-
- public static String getDescription() {
- return description;
- }
-
- @Override
- public void processHeaderRow(String[] headerRow) {
- if (done) {
- return;
- }
- if (tableIterator.hasNext()) {
- currentTable = tableIterator.next();
- } else {
- throw new IllegalArgumentException(
- "Encountered row past end of last expected table: " + Arrays.deepToString(headerRow));
- }
- }
-
- /**
- * import Artifacts
- */
- @Override
- public void processRow(String[] row) {
- if (done) {
- return;
- }
- switch (currentTable) {
- case ARTIFACT_TYPE_TABLE:
- addArtifactType(row);
- break;
- case ATTRIBUTE_TYPE_TABLE:
- addAttributeType(row);
- break;
- case RELATION_TYPE_TABLE:
- addRelationType(row);
- break;
- default:
- break;
- }
- }
-
- private void addAttributeType(String[] row) {
- // String attrBaseType = row[0];
- // String attrProviderType = row[1];
- String attributeName = row[2];
- int index = attributeName.lastIndexOf(".");
- if (index != -1 && index + 1 < attributeName.length()) {
- attributeName = attributeName.substring(index + 1, attributeName.length());
- }
- // String fileTypeExtension = row[3];
- // String defaultValue = row[4];
- // String validityXml = row[5];
- // int minOccurrence = getQuantity(row[6]);
- // int maxOccurrence = getQuantity(row[7]);
- // String tipText = row[8];
-
- // if (fileTypeExtension == null) {
- // fileTypeExtension = "";
- // }
-
- attributes.add(nonJavaCharP.matcher(attributeName).replaceAll("_").toUpperCase() + "(\"" + attributeName + "\")");
- }
-
- private void addRelationType(String[] row) {
-
- String relationTypeName = row[0];
- String sideAName = row[1];
- // String A2BPhrase = row[2];
- String sideBName = row[3];
- // String B2APhrase = row[4];
- // String shortName = row[5];
- generateRelationSideEnum(relationTypeName, sideAName, sideBName);
- }
-
- private void generateRelationSideEnum(String relationTypeName, String sideAName, String sideBName) {
- sideAName = nonJavaCharP.matcher(sideAName).replaceAll("_").toUpperCase();
- sideBName = nonJavaCharP.matcher(sideBName).replaceAll("_").toUpperCase();
- String enumPrefix = nonJavaCharP.matcher(relationTypeName).replaceAll("_").toUpperCase();
- relations.add(String.format("%s__%s(true, \"%s\"),\n %s__%s(false, \"%s\")", enumPrefix, sideAName,
- relationTypeName, enumPrefix, sideBName, relationTypeName));
- }
-
- private void addArtifactType(String[] row) {
- // String factoryClassName = row[0];
- String artifactTypeName = row[1];
- // String superTypeName = row[2];
-
- artifacts.add(nonJavaCharP.matcher(artifactTypeName).replaceAll("_").toUpperCase() + "(\"" + artifactTypeName + "\")");
- }
-
- @Override
- public void processEmptyRow() {
- }
-
- @Override
- public void processCommentRow(String[] row) {
- }
-
- @Override
- public void reachedEndOfWorksheet() {
- done = true;
- }
-
- @Override
- public void detectedRowAndColumnCounts(int rowCount, int columnCount) {
- }
-
- @Override
- public void foundStartOfWorksheet(String sheetName) {
- this.sheetName = nonJavaCharP.matcher(sheetName).replaceAll("_").toUpperCase();
- }
-}
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 b3b4d9d6bcb..3efd6fa26eb 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
@@ -68,7 +68,6 @@ Import-Package: com.google.common.collect,
org.eclipse.osee.framework.core.util,
org.eclipse.osee.framework.database,
org.eclipse.osee.framework.database.core,
- org.eclipse.osee.framework.database.init,
org.eclipse.osee.framework.database.operation,
org.eclipse.osee.framework.jdk.core.text.change,
org.eclipse.osee.framework.jdk.core.text.rules,
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/GenerateTypeEnumAction.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/GenerateTypeEnumAction.java
deleted file mode 100644
index e462a4aec1f..00000000000
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/GenerateTypeEnumAction.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 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;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTreeViewer;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jface.window.Window;
-import org.eclipse.osee.framework.database.init.SkynetTypesEnumGenerator;
-import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-import org.eclipse.osee.framework.ui.ws.AWorkspace;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.IActionDelegate;
-import org.eclipse.ui.dialogs.CheckedTreeSelectionDialog;
-import org.eclipse.ui.model.WorkbenchContentProvider;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-
-public class GenerateTypeEnumAction implements IActionDelegate {
-
- public GenerateTypeEnumAction() {
- super();
- }
-
- @Override
- public void run(IAction action) {
- try {
- StructuredSelection sel = AWorkspace.getSelection();
- Iterator<?> i = sel.iterator();
- File selection = null;
- while (i.hasNext()) {
- Object obj = i.next();
- if (obj instanceof IResource) {
- IResource resource = (IResource) obj;
- selection = resource.getLocation().toFile();
- if (selection != null) {
-
- Object destinationObj = getFolderToStoreAutoGenFilesIn(resource);
- if (destinationObj instanceof IContainer) {
- IContainer destinationFolder = (IContainer) destinationObj;
- File storeAt = destinationFolder.getLocation().toFile();
- SkynetTypesEnumGenerator gen = new SkynetTypesEnumGenerator();
- gen.extractTypesFromSheet(selection, storeAt);
- gen.finish();
-
- destinationFolder.refreshLocal(IResource.DEPTH_INFINITE, null);
- }
- }
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private Object getFolderToStoreAutoGenFilesIn(IResource resource) {
- CheckedTreeSelectionDialog resourceDialog =
- new ResourceSelectionTree(AWorkbench.getActiveShell(), new WorkbenchLabelProvider(),
- new WorkbenchContentProvider());
-
- resourceDialog.setInput(resource.getWorkspace().getRoot());
- resourceDialog.addFilter(new ViewerFilter() {
-
- @Override
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- IResource resource = null;
- if (element instanceof IContainer) {
- IContainer container = (IContainer) element;
- String name = container.getName();
- if (name.startsWith(".") == false && name.equals("bin") == false) {
- resource = container;
- }
- }
- if (resource != null) {
- return true;
- }
- return false;
- }
- });
- resourceDialog.setMessage("Select where Auto-Generated classes should be stored.");
- resourceDialog.setTitle("Select Destination");
- resourceDialog.setEmptyListMessage("No Projects Available");
- IContainer container = resource.getParent();
- resourceDialog.setInitialSelection(container);
- List<Object> expand = new ArrayList<Object>();
- expand.add(container);
- if (container.getParent() != null) {
- expand.add(container.getParent());
- }
- resourceDialog.setExpandedElements(expand.toArray(new Object[expand.size()]));
- int result = resourceDialog.open();
- return result != Window.CANCEL ? resourceDialog.getFirstResult() : null;
- }
-
- @Override
- public void selectionChanged(IAction action, ISelection selection) {
- // do nothing
- }
-
- private final class ResourceSelectionTree extends CheckedTreeSelectionDialog {
-
- public ResourceSelectionTree(Shell parent, ILabelProvider labelProvider, ITreeContentProvider contentProvider) {
- super(parent, labelProvider, contentProvider);
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- applyDialogFont(composite);
-
- Label messageLabel = createMessageArea(composite);
- CheckboxTreeViewer treeViewer = createTreeViewer(composite);
- GridData data = new GridData(GridData.FILL_BOTH);
- data.widthHint = convertWidthInCharsToPixels(80);
- data.heightHint = convertHeightInCharsToPixels(16);
- Tree treeWidget = treeViewer.getTree();
- treeViewer.addCheckStateListener(new ICheckStateListener() {
-
- @Override
- public void checkStateChanged(CheckStateChangedEvent event) {
- boolean wasChecked = event.getChecked();
- getTreeViewer().setAllChecked(false);
- event.getCheckable().setChecked(event.getElement(), wasChecked);
- }
-
- });
- treeWidget.setLayoutData(data);
- treeWidget.setFont(parent.getFont());
- messageLabel.setEnabled(true);
- treeWidget.setEnabled(true);
- return composite;
- }
- };
-}

Back to the top