| author | Shawn F. Cook | 2011-08-02 16:05:35 (EDT) |
|---|---|---|
| committer | Ryan D. Brooks | 2011-08-02 16:05:35 (EDT) |
| commit | d760f7f97c3373160d59c7cf07dd5d25350f4932 (patch) (side-by-side diff) | |
| tree | b559bc0da1e9d3edc0a454059951541ece343255 | |
| parent | 694def2db13d9e45fe118fd4b8f508471582ca5e (diff) | |
| download | org.eclipse.osee-d760f7f97c3373160d59c7cf07dd5d25350f4932.zip org.eclipse.osee-d760f7f97c3373160d59c7cf07dd5d25350f4932.tar.gz org.eclipse.osee-d760f7f97c3373160d59c7cf07dd5d25350f4932.tar.bz2 | |
refinement[bgz_350331]: Migrate ConsolidateRelations (BLAM) to server side command line
| -rw-r--r-- | plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/operation/ConsolidateRelationsTxOperation.java (renamed from plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ConsolidateRelationsTxOperation.java) | 44 | ||||
| -rw-r--r-- | plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/ServerAdminCommandProvider.java | 10 | ||||
| -rw-r--r-- | plugins/org.eclipse.osee.framework.ui.skynet/plugin.xml | 6 | ||||
| -rw-r--r-- | plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ConsolidateRelations.java | 53 |
4 files changed, 27 insertions, 86 deletions
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ConsolidateRelationsTxOperation.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/operation/ConsolidateRelationsTxOperation.java index 49be47b..645e3c2 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ConsolidateRelationsTxOperation.java +++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/operation/ConsolidateRelationsTxOperation.java @@ -8,13 +8,9 @@ * Contributors: * Boeing - initial API and implementation *******************************************************************************/ -package org.eclipse.osee.framework.ui.skynet.blam.operation; +package org.eclipse.osee.framework.database.operation; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; import java.io.IOException; -import java.io.Writer; import java.util.ArrayList; import java.util.List; import org.eclipse.core.runtime.IProgressMonitor; @@ -23,6 +19,7 @@ import org.eclipse.osee.framework.core.enums.TxChange; import org.eclipse.osee.framework.core.exception.OseeCoreException; import org.eclipse.osee.framework.core.exception.OseeExceptions; import org.eclipse.osee.framework.core.exception.OseeStateException; +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; @@ -30,10 +27,8 @@ import org.eclipse.osee.framework.database.core.ExportImportJoinQuery; import org.eclipse.osee.framework.database.core.IOseeStatement; import org.eclipse.osee.framework.database.core.JoinUtility; import org.eclipse.osee.framework.database.core.OseeConnection; -import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.eclipse.osee.framework.database.internal.Activator; import org.eclipse.osee.framework.jdk.core.util.Strings; -import org.eclipse.osee.framework.plugin.core.util.OseeData; -import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin; /** * @author Ryan D. Brooks @@ -57,7 +52,6 @@ public class ConsolidateRelationsTxOperation extends AbstractDbTxOperation { private final StringBuilder addressingBackup = new StringBuilder(100000); private final List<Object[]> addressingToDelete = new ArrayList<Object[]>(13000); private final List<Object[]> updateAddressingData = new ArrayList<Object[]>(5000); - private Writer backupWriter; private ExportImportJoinQuery gammaJoin; private OseeConnection connection; private int previousRelationTypeId; @@ -76,8 +70,8 @@ public class ConsolidateRelationsTxOperation extends AbstractDbTxOperation { ModificationType netModType; TxChange netTxCurrent; - public ConsolidateRelationsTxOperation(IOseeDatabaseService databaseService) { - super(databaseService, "Consolidate Relations", SkynetGuiPlugin.PLUGIN_ID); + public ConsolidateRelationsTxOperation(IOseeDatabaseService databaseService, OperationLogger logger) { + super(databaseService, "Consolidate Relations", Activator.PLUGIN_ID, logger); } private void init() throws OseeCoreException, IOException { @@ -97,9 +91,6 @@ public class ConsolidateRelationsTxOperation extends AbstractDbTxOperation { chStmt = ConnectionHandler.getStatement(); gammaJoin = JoinUtility.createExportImportJoinQuery(); - File iFile = OseeData.getFile("consolidateRelations_" + Lib.getDateTimeString() + ".csv"); - backupWriter = new BufferedWriter(new FileWriter(iFile)); - counter = 0; } @@ -107,15 +98,17 @@ public class ConsolidateRelationsTxOperation extends AbstractDbTxOperation { protected void doTxWork(IProgressMonitor monitor, OseeConnection connection) throws OseeCoreException { this.connection = connection; try { + log("Consolidating relations:"); init(); findObsoleteRelations(); - System.out.println("gamma join size: " + gammaJoin.size()); + log("gamma join size: " + gammaJoin.size()); determineAffectedAddressing(); updateGammas(); + log("...done."); } catch (IOException ex) { OseeExceptions.wrapAndThrow(ex); } @@ -154,7 +147,7 @@ public class ConsolidateRelationsTxOperation extends AbstractDbTxOperation { } if (materiallyDifferent) { counter++; - System.out.println("rel type: " + previousRelationTypeId + " A art id: " + previousArtifactAId + " B art id: " + previousArtiafctBId); + log("rel type: " + previousRelationTypeId + " A art id: " + previousArtifactAId + " B art id: " + previousArtiafctBId); } } @@ -162,8 +155,8 @@ public class ConsolidateRelationsTxOperation extends AbstractDbTxOperation { gammaJoin.store(); try { - System.out.println("counter: " + counter); - System.out.println("query id: " + gammaJoin.getQueryId()); + log("counter: " + counter); + log("query id: " + gammaJoin.getQueryId()); chStmt.runPreparedQuery(10000, SELECT_RELATION_ADDRESSING, gammaJoin.getQueryId()); while (chStmt.next()) { @@ -244,16 +237,13 @@ public class ConsolidateRelationsTxOperation extends AbstractDbTxOperation { } private void updateGammas() throws OseeCoreException, IOException { - backupWriter.close(); - - System.out.println("Number of txs rows deleted: " + ConnectionHandler.runBatchUpdate(connection, DELETE_TXS, - addressingToDelete)); + log("Number of txs rows deleted: " + ConnectionHandler.runBatchUpdate(connection, DELETE_TXS, addressingToDelete)); - System.out.println("Number of relation rows deleted: " + ConnectionHandler.runBatchUpdate(connection, - DELETE_RELATIONS, relationDeleteData)); + log("Number of relation rows deleted: " + ConnectionHandler.runBatchUpdate(connection, DELETE_RELATIONS, + relationDeleteData)); - System.out.println("Number of txs rows updated: " + ConnectionHandler.runBatchUpdate(connection, - UPDATE_TXS_GAMMAS, updateAddressingData)); + log("Number of txs rows updated: " + ConnectionHandler.runBatchUpdate(connection, UPDATE_TXS_GAMMAS, + updateAddressingData)); } private void writeAddressingBackup(long obsoleteGammaId, int transactionId, long netGammaId, int modType, TxChange txCurrent) throws IOException { @@ -269,7 +259,7 @@ public class ConsolidateRelationsTxOperation extends AbstractDbTxOperation { strB.append(","); strB.append(txCurrent.getValue()); strB.append("\n"); - backupWriter.append(strB); + log(strB.toString()); } private boolean isNextConceptualRelation(int relationTypeId, int artifactAId, int artiafctBId) { 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 d41464e..d414c4b 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 @@ -28,6 +28,7 @@ import org.eclipse.osee.framework.core.operation.OperationLogger; import org.eclipse.osee.framework.core.operation.Operations; import org.eclipse.osee.framework.database.operation.ConsolidateArtifactVersionTxOperation; import org.eclipse.osee.framework.database.operation.ParseWindowsDirectoryListingOperation; +import org.eclipse.osee.framework.database.operation.ConsolidateRelationsTxOperation; import org.eclipse.osee.framework.database.operation.PurgeUnusedBackingDataAndTransactions; import org.eclipse.osee.framework.jdk.core.util.Strings; import org.eclipse.osee.framework.server.admin.internal.Activator; @@ -160,7 +161,15 @@ public class ServerAdminCommandProvider implements CommandProvider { return Operations.executeAsJob(operation, false); } + + public Job _consolidate_relations(CommandInterpreter ci) { + OperationLogger logger = new CommandInterpreterLogger(ci); + + IOperation operation = new ConsolidateRelationsTxOperation(Activator.getOseeDatabaseService(), logger); + return Operations.executeAsJob(operation, false); + } + @Override public String getHelp() { StringBuilder sb = new StringBuilder(); @@ -179,6 +188,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(" consolidate_relations - consolidate rows of relations\n"); sb.append(String.format(" reload_cache %s? - reloads server caches\n", Arrays.deepToString(OseeCacheEnum.values()).replaceAll(",", " | "))); sb.append(String.format(" clear_cache %s? - decaches all objects from the specified caches\n", diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/plugin.xml b/plugins/org.eclipse.osee.framework.ui.skynet/plugin.xml index 68d03bd..204c663 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/plugin.xml +++ b/plugins/org.eclipse.osee.framework.ui.skynet/plugin.xml @@ -1587,12 +1587,6 @@ </Operation> </extension> <extension - point="org.eclipse.osee.framework.ui.skynet.BlamOperation"> - <Operation - className="org.eclipse.osee.framework.ui.skynet.blam.operation.ConsolidateRelations"> - </Operation> - </extension> - <extension point="org.eclipse.ui.startup"> <startup class="org.eclipse.osee.framework.ui.skynet.OseeUiEarlyStartup"></startup> diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ConsolidateRelations.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ConsolidateRelations.java deleted file mode 100644 index bb2353d..0000000 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ConsolidateRelations.java +++ b/dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 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.operation.IOperation; -import org.eclipse.osee.framework.core.operation.Operations; -import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin; -import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam; -import org.eclipse.osee.framework.ui.skynet.blam.VariableMap; - -/** - * @author Ryan D. Brooks - */ -public class ConsolidateRelations extends AbstractBlam { - - @Override - public String getName() { - return "Consolidate Relations"; - } - - @Override - public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception { - IOperation operation = - new ConsolidateRelationsTxOperation(SkynetGuiPlugin.getInstance().getOseeDatabaseService()); - Operations.executeWorkAndCheckStatus(operation, monitor); - } - - @Override - public String getDescriptionUsage() { - return "Consolidate Relations to use a single relation version where possible."; - } - - @Override - public Collection<String> getCategories() { - return Arrays.asList("Admin"); - } - - @Override - public String getXWidgetsXml() { - return AbstractBlam.emptyXWidgetsXml; - } -}
\ No newline at end of file |

