summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn F. Cook2011-08-02 16:05:39 (EDT)
committer Ryan D. Brooks2011-08-02 16:05:39 (EDT)
commita75fa5b6a515a19ae050b72a1d53ce1abc8b40c8 (patch)
tree9954703c59c080aca59a1e8e00187561b598ea32
parentd24f7321717fdd9b86a82724d03f5b0731720ca3 (diff)
downloadorg.eclipse.osee-a75fa5b6a515a19ae050b72a1d53ce1abc8b40c8.zip
org.eclipse.osee-a75fa5b6a515a19ae050b72a1d53ce1abc8b40c8.tar.gz
org.eclipse.osee-a75fa5b6a515a19ae050b72a1d53ce1abc8b40c8.tar.bz2
refinement[bgz_350331]: Migrate PurgeAttributeType to server side command line
Deleted the BLAM: PurgeAttributeType. Deleted unreferenced method: AttributeTypeManager.purgeAttributeType(). Removed reference to deleted BLAM from org.eclipse.osee.framework.ui.skynet/plugin.xml.
-rw-r--r--plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/PurgeAttributeType.java80
-rw-r--r--plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/ServerAdminCommandProvider.java18
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/AttributeTypeManager.java29
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/plugin.xml8
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/PurgeAttributeType.java54
5 files changed, 98 insertions, 91 deletions
diff --git a/plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/PurgeAttributeType.java b/plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/PurgeAttributeType.java
new file mode 100644
index 0000000..4db7415
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/PurgeAttributeType.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2011 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.server.admin;
+
+import java.util.LinkedList;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.exception.OseeArgumentException;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.operation.OperationLogger;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+import org.eclipse.osee.framework.database.core.AbstractDbTxOperation;
+import org.eclipse.osee.framework.database.core.ConnectionHandler;
+import org.eclipse.osee.framework.database.core.OseeConnection;
+import org.eclipse.osee.framework.server.admin.internal.Activator;
+
+/**
+ * Purges given attribute types.<br/>
+ * <p>
+ * Tables involved:
+ * <li>osee_artifact_type_attributes</li>
+ * <li>osee_attribute</li>
+ * <li>osee_attribute_type</li>
+ * </p>
+ * <br/>
+ *
+ * @author Ryan D. Brooks
+ * @author Shawn F. Cook
+ */
+public class PurgeAttributeType extends AbstractDbTxOperation {
+ private static final String DELETE_ARTIFACT_ATTRIBUTE =
+ "delete from osee_artifact_type_attributes where attr_type_id = ?";
+ private static final String COUNT_ATTRIBUTE_OCCURRENCE =
+ "select count(1) FROM osee_attribute where attr_type_id = ?";
+ private static final String DELETE_ATTRIBUTE_TYPE = "delete from osee_attribute_type where attr_type_id = ?";
+
+ private final LinkedList<String> attributeTypeIds;
+
+ public PurgeAttributeType(IOseeDatabaseService databaseService, OperationLogger logger, String... typesToPurge) {
+ super(databaseService, "Purge Attribute Type", Activator.PLUGIN_ID, logger);
+
+ this.attributeTypeIds = new LinkedList<String>();
+ for (String att : typesToPurge) {
+ this.attributeTypeIds.add(att);
+ }
+ }
+
+ @Override
+ protected void doTxWork(IProgressMonitor monitor, OseeConnection connection) throws OseeCoreException {
+
+ log();
+ log("Purging Attribute Types...");
+
+ for (String attributeTypeId : attributeTypeIds) {
+ log(" Purging " + attributeTypeId);
+ purgeAttributeType(attributeTypeId, connection);
+ }
+
+ log("...done.");
+ }
+
+ private static void purgeAttributeType(final String attributeTypeId, OseeConnection connection) throws OseeCoreException {
+ int attributeCount = ConnectionHandler.runPreparedQueryFetchInt(0, COUNT_ATTRIBUTE_OCCURRENCE, attributeTypeId);
+ if (attributeCount != 0) {
+ throw new OseeArgumentException(
+ "Can not delete attribute type [%s] because there are %d existing attributes of this type.",
+ attributeTypeId, attributeCount);
+ }
+
+ ConnectionHandler.runPreparedUpdate(connection, DELETE_ARTIFACT_ATTRIBUTE, attributeTypeId);
+ ConnectionHandler.runPreparedUpdate(connection, DELETE_ATTRIBUTE_TYPE, attributeTypeId);
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/ServerAdminCommandProvider.java b/plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/ServerAdminCommandProvider.java
index f92abb0..2b73bdd 100644
--- a/plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/ServerAdminCommandProvider.java
+++ b/plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/ServerAdminCommandProvider.java
@@ -215,6 +215,23 @@ public class ServerAdminCommandProvider implements CommandProvider {
return Operations.executeAsJob(operation, false);
}
+ public Job _purge_attribute_type(CommandInterpreter ci) {
+ OperationLogger logger = new CommandInterpreterLogger(ci);
+
+ //to be purged
+ final Collection<String> attributeTypes = new ArrayList<String>();
+
+ for (String arg = ci.nextArgument(); Strings.isValid(arg); arg = ci.nextArgument()) {
+ attributeTypes.add(arg);
+ }
+
+ IOperation operation =
+ new PurgeAttributeType(Activator.getOseeDatabaseService(), logger,
+ attributeTypes.toArray(new String[attributeTypes.size()]));
+
+ return Operations.executeAsJob(operation, false);
+ }
+
@Override
public String getHelp() {
StringBuilder sb = new StringBuilder();
@@ -233,6 +250,7 @@ public class ServerAdminCommandProvider implements CommandProvider {
sb.append(" schedule <delay seconds> <iterations> <command> - runs the command after the specified delay and repeat given number of times\n");
sb.append(" purge_relation_type -force excute the operation, relationType1 ...\n");
sb.append(" parse_dir - converts the given file into a formatted CSV file\n");
+ sb.append(" purge_attribute_type <attr ids> - deletes specified rows from osee_artifact_type_attributes and osee_attribute_type\n");
sb.append(" prune_workspace [preserve_file_pattern] workspace_path purge_file_pattern - delete files that are found in workspace_path and whose filenames match purge_file_pattern. Any filename that matches the optional preserve_file_pattern are not deleted\n");
sb.append(" find_invalid_utf8 - finds invalid UTF8 chars in table osee_attribute\n");
sb.append(" consolidate_relations - consolidate rows of relations\n");
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/AttributeTypeManager.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/AttributeTypeManager.java
index 84a3165..71c5124 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/AttributeTypeManager.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/AttributeTypeManager.java
@@ -24,9 +24,6 @@ import org.eclipse.osee.framework.core.model.cache.AbstractOseeCache;
import org.eclipse.osee.framework.core.model.cache.BranchCache;
import org.eclipse.osee.framework.core.model.type.ArtifactType;
import org.eclipse.osee.framework.core.model.type.AttributeType;
-import org.eclipse.osee.framework.database.core.ConnectionHandler;
-import org.eclipse.osee.framework.database.core.DbTransaction;
-import org.eclipse.osee.framework.database.core.OseeConnection;
import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager;
import org.eclipse.osee.framework.skynet.core.artifact.Attribute;
@@ -135,32 +132,6 @@ public class AttributeTypeManager {
return getEnumerationValues(getType(attributeName));
}
- private static final String DELETE_VALID_ATTRIBUTE =
- "delete from osee_artifact_type_attributes where attr_type_id = ?";
- private static final String COUNT_ATTRIBUTE_OCCURRENCE =
- "select count(1) FROM osee_attribute where attr_type_id = ?";
- private static final String DELETE_ATTRIBUTE_TYPE = "delete from osee_attribute_type where attr_type_id = ?";
-
- public static void purgeAttributeType(final AttributeType attributeType) throws OseeCoreException {
- int attributeCount =
- ConnectionHandler.runPreparedQueryFetchInt(0, COUNT_ATTRIBUTE_OCCURRENCE, attributeType.getId());
- if (attributeCount != 0) {
- throw new OseeArgumentException(
- "Can not delete attribute type [%s] because there are %d existing attributes of this type.", attributeType,
- attributeCount);
- }
-
- DbTransaction dbTransaction = new DbTransaction() {
- @Override
- protected void handleTxWork(OseeConnection connection) throws OseeCoreException {
- int attributeTypeId = attributeType.getId();
- ConnectionHandler.runPreparedUpdate(connection, DELETE_VALID_ATTRIBUTE, attributeTypeId);
- ConnectionHandler.runPreparedUpdate(connection, DELETE_ATTRIBUTE_TYPE, attributeTypeId);
- }
- };
- dbTransaction.execute();
- }
-
public static void persist() throws OseeCoreException {
getCache().storeAllModified();
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/plugin.xml b/plugins/org.eclipse.osee.framework.ui.skynet/plugin.xml
index 76872b5..976ead2 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/plugin.xml
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/plugin.xml
@@ -1434,14 +1434,6 @@
</Operation>
</extension>
<extension
- id="PurgeAttributeType"
- name="PurgeAttributeType"
- point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
- <Operation
- className="org.eclipse.osee.framework.ui.skynet.blam.operation.PurgeAttributeType">
- </Operation>
- </extension>
- <extension
id="PurgeDeletedAttributes"
name="Purge Deleted Attributes"
point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/PurgeAttributeType.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/PurgeAttributeType.java
deleted file mode 100644
index b6e343a..0000000
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/PurgeAttributeType.java
+++ /dev/null
@@ -1,54 +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.blam.operation;
-
-import java.util.Arrays;
-import java.util.Collection;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.core.model.type.AttributeType;
-import org.eclipse.osee.framework.skynet.core.attribute.AttributeTypeManager;
-import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
-import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
-
-/**
- * @author Ryan D. Brooks
- */
-public class PurgeAttributeType extends AbstractBlam {
- @Override
- public String getName() {
- return "Purge Attribute Type";
- }
-
- @Override
- public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
- Collection<AttributeType> purgeAttributeTypes =
- variableMap.getCollection(AttributeType.class, "Attribute Type(s) to purge");
-
- for (AttributeType attributeType : purgeAttributeTypes) {
- AttributeTypeManager.purgeAttributeType(attributeType);
- }
- }
-
- @Override
- public String getXWidgetsXml() {
- return "<xWidgets><XWidget xwidgetType=\"XAttributeTypeMultiChoiceSelect\" displayName=\"Attribute Type(s) to purge\" multiSelect=\"true\" /></xWidgets>";
- }
-
- @Override
- public String getDescriptionUsage() {
- return "Purge an attribute type.";
- }
-
- @Override
- public Collection<String> getCategories() {
- return Arrays.asList("Admin");
- }
-} \ No newline at end of file