diff options
author | Ryan D. Brooks | 2011-09-02 08:05:17 +0000 |
---|---|---|
committer | Ryan D. Brooks | 2011-09-02 08:05:17 +0000 |
commit | 6f85b98166a9650c68413d74a1ca0619fa67d82e (patch) | |
tree | d04d1d485cd3be3aaa43b22ec24d93717fc8d4ee /plugins | |
parent | 657019e3b75401dadfb91ee48150ba9f22decf69 (diff) | |
download | org.eclipse.osee-6f85b98166a9650c68413d74a1ca0619fa67d82e.tar.gz org.eclipse.osee-6f85b98166a9650c68413d74a1ca0619fa67d82e.tar.xz org.eclipse.osee-6f85b98166a9650c68413d74a1ca0619fa67d82e.zip |
bug: Fix export of archived branches
Diffstat (limited to 'plugins')
10 files changed, 174 insertions, 194 deletions
diff --git a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/ExportOptions.java b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/ExportOptions.java index 6c48717a96f..94f8ce169af 100644 --- a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/ExportOptions.java +++ b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/ExportOptions.java @@ -14,8 +14,6 @@ package org.eclipse.osee.framework.branch.management; * @author Roberto E. Escobar */ public enum ExportOptions { - EXCLUDE_BRANCH_IDS, - EXCLUDE_BASELINE_TXS, MIN_TXS, MAX_TXS, COMPRESS; diff --git a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/ExchangeDb.java b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/ExchangeDb.java index 8fe21e77658..fb6548d5a01 100644 --- a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/ExchangeDb.java +++ b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/ExchangeDb.java @@ -10,10 +10,22 @@ *******************************************************************************/ package org.eclipse.osee.framework.branch.management.exchange; +import static org.eclipse.osee.framework.branch.management.exchange.handler.ExportItem.OSEE_ARTIFACT_ACL_DATA; +import static org.eclipse.osee.framework.branch.management.exchange.handler.ExportItem.OSEE_ARTIFACT_DATA; +import static org.eclipse.osee.framework.branch.management.exchange.handler.ExportItem.OSEE_ATTRIBUTE_DATA; +import static org.eclipse.osee.framework.branch.management.exchange.handler.ExportItem.OSEE_BRANCH_ACL_DATA; +import static org.eclipse.osee.framework.branch.management.exchange.handler.ExportItem.OSEE_BRANCH_DATA; +import static org.eclipse.osee.framework.branch.management.exchange.handler.ExportItem.OSEE_CONFLICT_DATA; +import static org.eclipse.osee.framework.branch.management.exchange.handler.ExportItem.OSEE_MERGE_DATA; +import static org.eclipse.osee.framework.branch.management.exchange.handler.ExportItem.OSEE_RELATION_LINK_DATA; +import static org.eclipse.osee.framework.branch.management.exchange.handler.ExportItem.OSEE_TXS_ARCHIVED_DATA; +import static org.eclipse.osee.framework.branch.management.exchange.handler.ExportItem.OSEE_TXS_DATA; +import static org.eclipse.osee.framework.branch.management.exchange.handler.ExportItem.OSEE_TX_DETAILS_DATA; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; +import java.util.Random; import java.util.Set; import org.eclipse.osee.framework.branch.management.ExportOptions; import org.eclipse.osee.framework.branch.management.exchange.export.AbstractExportItem; @@ -26,7 +38,6 @@ import org.eclipse.osee.framework.core.exception.OseeArgumentException; import org.eclipse.osee.framework.core.exception.OseeCoreException; import org.eclipse.osee.framework.database.IOseeDatabaseService; import org.eclipse.osee.framework.database.core.IOseeSequence; -import org.eclipse.osee.framework.jdk.core.type.Pair; import org.eclipse.osee.framework.jdk.core.type.PropertyStore; import org.eclipse.osee.framework.jdk.core.util.Strings; @@ -101,58 +112,74 @@ public final class ExchangeDb { "SELECT last_sequence FROM osee_sequence WHERE sequence_name = '" + IOseeSequence.TRANSACTION_ID_SEQ + "'"; private static final String BRANCH_TABLE_QUERY = - "SELECT br1.* FROM osee_branch br1, osee_join_export_import jex1 WHERE br1.branch_id = jex1.id1 AND jex1.query_id=? ORDER BY br1.branch_id"; + "SELECT br.* FROM osee_join_export_import jex, osee_branch br WHERE jex.query_id=? AND jex.id1=br.branch_id ORDER BY br.branch_id"; private static final String TX_DETAILS_TABLE_QUERY = - "SELECT txd1.TRANSACTION_ID, txd1.TIME, txd1.AUTHOR, txd1.OSEE_COMMENT, txd1.BRANCH_ID, txd1.COMMIT_ART_ID, txd1.TX_TYPE FROM osee_tx_details txd1, osee_join_export_import jex1 WHERE txd1.branch_id = jex1.id1 AND jex1.query_id=? %s ORDER BY txd1.transaction_id"; - - private static final String TXS_ARCHIVE_TABLE_QUERY = - "SELECT txs1.GAMMA_ID, txs1.TRANSACTION_ID, txs1.TX_CURRENT, txs1.MOD_TYPE, txs1.BRANCH_ID FROM osee_txs_archived txs1, osee_tx_details txd1, osee_join_export_import jex1 WHERE txs1.transaction_id = txd1.transaction_id AND txs1.branch_id = jex1.id1 AND jex1.query_id=? %s"; + "SELECT txd.* FROM osee_join_export_import jex, osee_tx_details txd WHERE jex.query_id=? AND jex.id1=txd.branch_id"; private static final String TXS_TABLE_QUERY = - "SELECT txs1.GAMMA_ID, txs1.TRANSACTION_ID, txs1.TX_CURRENT, txs1.MOD_TYPE, txs1.BRANCH_ID FROM osee_txs txs1, osee_tx_details txd1, osee_join_export_import jex1 WHERE txs1.transaction_id = txd1.transaction_id AND txs1.branch_id = jex1.id1 AND jex1.query_id=? %s"; + "SELECT txs.* FROM osee_join_export_import jex, osee_txs txs WHERE jex.query_id=? AND jex.id1=txs.branch_id"; + + private static final String TXS_ARCHIVE_TABLE_QUERY = TXS_TABLE_QUERY.replace("osee_txs", "osee_txs_archived"); private static final String ARTIFACT_TABLE_QUERY = - "SELECT DISTINCT (art1.GAMMA_ID), art1.art_id, art1.GUID, art1.HUMAN_READABLE_ID, art1.ART_TYPE_ID FROM osee_artifact art1, osee_txs txs1, osee_tx_details txd1, osee_join_export_import jex1 WHERE art1.gamma_id = txs1.gamma_id AND txs1.transaction_id = txd1.transaction_id AND txs1.branch_id = jex1.id1 AND jex1.query_id=? %s"; + "SELECT * FROM osee_join_id oji, osee_artifact item WHERE oji.query_id = ? AND oji.id = item.gamma_id"; - private static final String ATTRIBUTE_TABLE_QUERY = - "SELECT DISTINCT (attr1.GAMMA_ID), attr1.ATTR_ID, attr1.ART_ID, attr1.VALUE, attr1.ATTR_TYPE_ID, attr1.URI FROM osee_attribute attr1, osee_txs txs1, osee_tx_details txd1, osee_join_export_import jex1 WHERE attr1.gamma_id = txs1.gamma_id AND txs1.transaction_id = txd1.transaction_id AND txs1.branch_id = jex1.id1 AND jex1.query_id=? %s"; + private static final String ATTRIBUTE_TABLE_QUERY = ARTIFACT_TABLE_QUERY.replace("osee_artifact", "osee_attribute"); - private static final String RELATION_LINK_TABLE_QUERY = - "SELECT DISTINCT (rel1.GAMMA_ID), rel1.REL_LINK_ID, rel1.B_ART_ID, rel1.A_ART_ID, rel1.RATIONALE, rel1.REL_LINK_TYPE_ID FROM osee_relation_link rel1, osee_txs txs1, osee_tx_details txd1, osee_join_export_import jex1 WHERE rel1.gamma_id = txs1.gamma_id AND txs1.transaction_id = txd1.transaction_id AND txs1.branch_id = jex1.id1 AND jex1.query_id=? %s"; + private static final String RELATION_LINK_TABLE_QUERY = ARTIFACT_TABLE_QUERY.replace("osee_artifact", + "osee_relation_link"); private static final String MERGE_TABLE_QUERY = - "SELECT om1.* FROM osee_merge om1, osee_join_export_import jex1 WHERE om1.merge_branch_id = jex1.id1 AND jex1.query_id=? %s"; + "SELECT om.* FROM osee_join_export_import jex, osee_merge om WHERE jex.query_id=? AND jex.id1=om.merge_branch_id ORDER BY om.merge_branch_id"; private static final String CONFLICT_TABLE_QUERY = - "SELECT oc1.* FROM osee_conflict oc1, osee_merge om1, osee_join_export_import jex1 WHERE oc1.merge_branch_id = om1.merge_branch_id AND om1.merge_branch_id = jex1.id1 AND jex1.query_id=? %s"; + "SELECT oc.* FROM osee_join_export_import jex, osee_merge om, osee_conflict oc WHERE jex.query_id=? AND jex.id1=om.merge_branch_id AND om.merge_branch_id=oc.merge_branch_id"; private static final String ARTIFACT_ACL_QUERY = - "SELECT oaa1.* FROM osee_artifact_acl oaa1, osee_join_export_import jex1 WHERE oaa1.branch_id = jex1.id1 AND jex1.query_id=? ORDER BY oaa1.branch_id"; + "SELECT aac.* FROM osee_join_export_import jex, osee_artifact_acl aac WHERE jex.query_id=? AND jex.id1=aac.branch_id ORDER BY aac.branch_id"; private static final String BRANCH_ACL_QUERY = - "SELECT oba1.* FROM osee_branch_acl oba1, osee_join_export_import jex1 WHERE oba1.branch_id = jex1.id1 AND jex1.query_id=? ORDER BY oba1.branch_id"; + "SELECT bac.* FROM osee_join_export_import jex, osee_branch_acl bac WHERE jex.query_id=? AND jex.id1=bac.branch_id ORDER BY bac.branch_id"; + + private final List<AbstractExportItem> items = new ArrayList<AbstractExportItem>(); + private final OseeServices services; + private final PropertyStore options; + private final int exportJoinId; + private int gammaJoinId; + + public ExchangeDb(OseeServices services, PropertyStore options, int exportJoinId) { + this.services = services; + this.options = options; + this.exportJoinId = exportJoinId; + } - static List<AbstractExportItem> createTaskList(OseeServices services) throws OseeCoreException { - List<AbstractExportItem> items = new ArrayList<AbstractExportItem>(); - items.add(new ManifestExportItem(items)); + List<AbstractExportItem> createTaskList() throws OseeCoreException { + this.gammaJoinId = setupGammaJoin(); + + items.add(new ManifestExportItem(items, options)); items.add(new MetadataExportItem(items, services.getDatabaseService().getConnection().getMetaData())); items.add(new OseeTypeModelExportItem(services.getModelingService())); - items.add(new DbTableExportItem(services, ExportItem.OSEE_BRANCH_DATA, BRANCH_TABLE_QUERY)); - items.add(new DbTableExportItem(services, ExportItem.OSEE_TX_DETAILS_DATA, TX_DETAILS_TABLE_QUERY)); - items.add(new DbTableExportItem(services, ExportItem.OSEE_TXS_DATA, TXS_TABLE_QUERY)); - items.add(new DbTableExportItem(services, ExportItem.OSEE_TXS_ARCHIVED_DATA, TXS_ARCHIVE_TABLE_QUERY)); - items.add(new DbTableExportItem(services, ExportItem.OSEE_ARTIFACT_DATA, ARTIFACT_TABLE_QUERY)); - items.add(new DbTableExportItem(services, ExportItem.OSEE_ATTRIBUTE_DATA, ATTRIBUTE_TABLE_QUERY)); - items.add(new DbTableExportItem(services, ExportItem.OSEE_RELATION_LINK_DATA, RELATION_LINK_TABLE_QUERY)); - items.add(new DbTableExportItem(services, ExportItem.OSEE_MERGE_DATA, MERGE_TABLE_QUERY)); - items.add(new DbTableExportItem(services, ExportItem.OSEE_CONFLICT_DATA, CONFLICT_TABLE_QUERY)); - items.add(new DbTableExportItem(services, ExportItem.OSEE_BRANCH_ACL_DATA, BRANCH_ACL_QUERY)); - items.add(new DbTableExportItem(services, ExportItem.OSEE_ARTIFACT_ACL_DATA, ARTIFACT_ACL_QUERY)); - + addExportItem(OSEE_BRANCH_DATA, BRANCH_TABLE_QUERY); + addExportItem(OSEE_TX_DETAILS_DATA, TX_DETAILS_TABLE_QUERY); + addExportItem(OSEE_TXS_DATA, TXS_TABLE_QUERY); + addExportItem(OSEE_TXS_ARCHIVED_DATA, TXS_ARCHIVE_TABLE_QUERY); + addExportItem(OSEE_ARTIFACT_DATA, ARTIFACT_TABLE_QUERY); + addExportItem(OSEE_ATTRIBUTE_DATA, ATTRIBUTE_TABLE_QUERY); + addExportItem(OSEE_RELATION_LINK_DATA, RELATION_LINK_TABLE_QUERY); + addExportItem(OSEE_MERGE_DATA, MERGE_TABLE_QUERY); + addExportItem(OSEE_CONFLICT_DATA, CONFLICT_TABLE_QUERY); + addExportItem(OSEE_BRANCH_ACL_DATA, BRANCH_ACL_QUERY); + addExportItem(OSEE_ARTIFACT_ACL_DATA, ARTIFACT_ACL_QUERY); return items; } + private void addExportItem(ExportItem exportItem, String query) throws OseeCoreException { + StringBuilder modifiedQuery = new StringBuilder(query); + Object[] bindData = prepareQuery(exportItem, modifiedQuery, options, exportJoinId, gammaJoinId); + items.add(new DbTableExportItem(services, exportItem, modifiedQuery.toString(), bindData)); + } + static List<IndexCollector> createCheckList() { List<IndexCollector> items = new ArrayList<IndexCollector>(); items.add(new IndexCollector(ExportItem.OSEE_TXS_DATA, GAMMA_ID, GAMMA_ID_REG_ALIASES)); @@ -179,47 +206,60 @@ public final class ExchangeDb { return translators; } - public static Pair<String, Object[]> getQueryWithOptions(String originalQuery, int queryId, PropertyStore options) throws Exception { - if (originalQuery.contains("%s")) { - if (originalQuery.contains("osee_tx_details") || originalQuery.contains("osee_merge")) { - List<Object> dataArray = new ArrayList<Object>(); - dataArray.add(queryId); - StringBuilder optionString = new StringBuilder(); - if (options.getBoolean(ExportOptions.EXCLUDE_BASELINE_TXS.name()) && originalQuery.contains("txd1")) { - optionString.append(" AND txd1.TX_TYPE = 0"); - } - - long minTxs = getMinTransaction(options); - long maxTxs = getMaxTransaction(options); - - if (minTxs != Long.MIN_VALUE) { - if (originalQuery.contains("om1")) { - optionString.append(" AND om1.commit_transaction_id >= ?"); - dataArray.add(minTxs); - } else if (originalQuery.contains("txs1")) { - optionString.append(" AND txd1.transaction_id >= ?"); - dataArray.add(minTxs); - } - } - - if (maxTxs != Long.MIN_VALUE) { - if (originalQuery.contains("om1")) { - optionString.append(" AND om1.commit_transaction_id <= ?"); - dataArray.add(maxTxs); - } else if (originalQuery.contains("txs1")) { - optionString.append(" AND txd1.transaction_id <= ?"); - dataArray.add(maxTxs); - } - } - if (minTxs > maxTxs) { - throw new OseeArgumentException("Invalid transaction range: min - %d > max - %d", minTxs, maxTxs); - } - - return new Pair<String, Object[]>(String.format(originalQuery, optionString), - dataArray.toArray(new Object[dataArray.size()])); - } + private static void addMaxMinFilter(StringBuilder query, List<Object> bindData, PropertyStore options) throws OseeCoreException { + long minTxs = getMinTransaction(options); + long maxTxs = getMaxTransaction(options); + + if (minTxs > maxTxs) { + throw new OseeArgumentException("Invalid transaction range: min - %d > max - %d", minTxs, maxTxs); + } + + if (minTxs != Long.MIN_VALUE) { + query.append(" AND transaction_id >= ?"); + bindData.add(minTxs); + } + if (maxTxs != Long.MIN_VALUE) { + query.append(" AND transaction_id <= ?"); + bindData.add(maxTxs); + } + } + + private int setupGammaJoin() throws OseeCoreException { + List<Object> bindList = new ArrayList<Object>(); + int gammaJoinId = new Random().nextInt(); + StringBuilder sql = + new StringBuilder( + "INSERT INTO osee_join_id (id, query_id) SELECT DISTINCT(gamma_id), ? FROM osee_join_export_import jex, osee_txs txs WHERE jex.query_id=? AND jex.id1 = txs.branch_id"); + bindList.add(gammaJoinId); + bindList.add(exportJoinId); + addMaxMinFilter(sql, bindList, options); + + sql.append(" UNION SELECT DISTINCT(gamma_id), ? FROM osee_join_export_import jex, osee_txs_archived txs WHERE jex.query_id=? AND jex.id1 = txs.branch_id"); + bindList.add(gammaJoinId); + bindList.add(exportJoinId); + addMaxMinFilter(sql, bindList, options); + + IOseeDatabaseService databaseService = services.getDatabaseService(); + Object[] bindData = bindList.toArray(new Object[bindList.size()]); + System.out.println(databaseService.runPreparedUpdate(sql.toString(), bindData)); + return gammaJoinId; + } + + public static Object[] prepareQuery(ExportItem exportItem, StringBuilder query, PropertyStore options, int exportJoinId, int gammaJionId) throws OseeCoreException { + List<Object> bindData = new ArrayList<Object>(); + + if (exportItem.matches(OSEE_ARTIFACT_DATA, OSEE_ATTRIBUTE_DATA, OSEE_RELATION_LINK_DATA)) { + bindData.add(gammaJionId); + } else { + bindData.add(exportJoinId); } - return new Pair<String, Object[]>(originalQuery, new Object[] {queryId}); + + if (exportItem.matches(OSEE_TX_DETAILS_DATA, OSEE_TXS_DATA, OSEE_TXS_ARCHIVED_DATA)) { + // this can not be accurately applied to osee_merge and osee_conflict because the best you can do is filter a the merge_branch level + addMaxMinFilter(query, bindData, options); + } + + return bindData.toArray(new Object[bindData.size()]); } static Long getMaxTransaction(PropertyStore options) { @@ -238,8 +278,4 @@ public final class ExchangeDb { } return toReturn; } - - private ExchangeDb() { - // utility class - } -} +}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/ExportController.java b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/ExportController.java index 5bae8dc2512..b24c0ca01d5 100644 --- a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/ExportController.java +++ b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/ExportController.java @@ -11,6 +11,7 @@ package org.eclipse.osee.framework.branch.management.exchange; import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; @@ -21,7 +22,6 @@ import java.util.concurrent.Future; import java.util.logging.Level; import org.eclipse.osee.framework.branch.management.ExportOptions; import org.eclipse.osee.framework.branch.management.IExchangeTaskListener; -import org.eclipse.osee.framework.branch.management.exchange.export.AbstractDbExportItem; import org.eclipse.osee.framework.branch.management.exchange.export.AbstractExportItem; import org.eclipse.osee.framework.core.exception.OseeArgumentException; import org.eclipse.osee.framework.core.exception.OseeCoreException; @@ -43,7 +43,7 @@ final class ExportController implements IExchangeTaskListener { private String exportName; private final PropertyStore options; private final List<Integer> branchIds; - private ExportImportJoinQuery joinQuery; + private final ExportImportJoinQuery exportJoinId; private ExecutorService executorService; private final List<String> errorList = new CopyOnWriteArrayList<String>(); private final OseeServices oseeServices; @@ -56,7 +56,7 @@ final class ExportController implements IExchangeTaskListener { this.exportName = exportName; this.options = options; this.branchIds = branchIds; - this.joinQuery = JoinUtility.createExportImportJoinQuery(); + this.exportJoinId = JoinUtility.createExportImportJoinQuery(); } public String getExchangeFileName() { @@ -67,19 +67,12 @@ final class ExportController implements IExchangeTaskListener { this.exportName = value; } - public int getExportQueryId() { - return joinQuery != null ? joinQuery.getQueryId() : -1; - } - private void cleanUp(List<AbstractExportItem> taskList) { for (AbstractExportItem exportItem : taskList) { exportItem.cleanUp(); } try { - if (joinQuery != null) { - joinQuery.delete(); - joinQuery = null; - } + exportJoinId.delete(); } catch (OseeCoreException ex) { onException("Export Clean-Up", ex); } @@ -95,12 +88,11 @@ final class ExportController implements IExchangeTaskListener { return rootDirectory; } - private void setUp(List<AbstractExportItem> taskList, File tempFolder) throws OseeCoreException { - joinQuery = JoinUtility.createExportImportJoinQuery(); + private void setUp() throws OseeCoreException { for (int branchId : branchIds) { - joinQuery.add((long) branchId, -1L); + exportJoinId.add((long) branchId, -1L); } - joinQuery.store(); + exportJoinId.store(); long maxTx = oseeServices.getDatabaseService().runPreparedQueryFetchObject(-1L, ExchangeDb.GET_MAX_TX); long userMaxTx = ExchangeDb.getMaxTransaction(options); @@ -108,16 +100,6 @@ final class ExportController implements IExchangeTaskListener { options.put(ExportOptions.MAX_TXS.name(), Long.toString(maxTx)); } - for (AbstractExportItem exportItem : taskList) { - exportItem.setOptions(options); - exportItem.setWriteLocation(tempFolder); - if (exportItem instanceof AbstractDbExportItem) { - AbstractDbExportItem exportItem2 = (AbstractDbExportItem) exportItem; - exportItem2.setJoinQueryId(joinQuery.getQueryId()); - } - exportItem.addExportListener(this); - } - executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(), ServerThreads.createNewThreadFactory("branch.export.worker")); @@ -125,29 +107,21 @@ final class ExportController implements IExchangeTaskListener { protected void handleTxWork() throws OseeCoreException { long startTime = System.currentTimeMillis(); - List<AbstractExportItem> taskList = ExchangeDb.createTaskList(oseeServices); + setUp(); + ExchangeDb exchangeDb = new ExchangeDb(oseeServices, options, exportJoinId.getQueryId()); + + List<AbstractExportItem> taskList = exchangeDb.createTaskList(); try { File tempFolder = createTempFolder(); - setUp(taskList, tempFolder); + + for (AbstractExportItem exportItem : taskList) { + exportItem.setWriteLocation(tempFolder); + exportItem.addExportListener(this); + } sendTasksToExecutor(taskList, tempFolder); - String zipTargetName = getExchangeFileName() + ZIP_EXTENSION; - if (this.options.getBoolean(ExportOptions.COMPRESS.name())) { - OseeLog.logf(this.getClass(), Level.INFO, "Compressing Branch Export Data - [%s]", zipTargetName); - File zipTarget = new File(tempFolder.getParent(), zipTargetName); - Lib.compressDirectory(tempFolder, zipTarget.getAbsolutePath(), true); - OseeLog.logf(this.getClass(), Level.INFO, "Deleting Branch Export Temp Folder - [%s]", tempFolder); - Lib.deleteDir(tempFolder); - } else { - File target = new File(tempFolder.getParent(), getExchangeFileName()); - if (!target.equals(tempFolder)) { - if (!tempFolder.renameTo(target)) { - OseeLog.logf(this.getClass(), Level.INFO, "Unable to move [%s] to [%s]", - tempFolder.getAbsolutePath(), target.getAbsolutePath()); - } - } - } + finishExport(tempFolder); } catch (Exception ex) { OseeExceptions.wrapAndThrow(ex); } finally { @@ -157,6 +131,25 @@ final class ExportController implements IExchangeTaskListener { branchIds.size() != 1 ? "es" : "", Lib.getElapseString(startTime)); } + private void finishExport(File tempFolder) throws IllegalArgumentException, IOException { + String zipTargetName = getExchangeFileName() + ZIP_EXTENSION; + if (options.getBoolean(ExportOptions.COMPRESS.name())) { + OseeLog.logf(this.getClass(), Level.INFO, "Compressing Branch Export Data - [%s]", zipTargetName); + File zipTarget = new File(tempFolder.getParent(), zipTargetName); + Lib.compressDirectory(tempFolder, zipTarget.getAbsolutePath(), true); + OseeLog.logf(this.getClass(), Level.INFO, "Deleting Branch Export Temp Folder - [%s]", tempFolder); + Lib.deleteDir(tempFolder); + } else { + File target = new File(tempFolder.getParent(), getExchangeFileName()); + if (!target.equals(tempFolder)) { + if (!tempFolder.renameTo(target)) { + OseeLog.logf(this.getClass(), Level.INFO, "Unable to move [%s] to [%s]", tempFolder.getAbsolutePath(), + target.getAbsolutePath()); + } + } + } + } + private void sendTasksToExecutor(List<AbstractExportItem> taskList, final File exportFolder) throws InterruptedException, ExecutionException, OseeCoreException { List<Future<?>> futures = new ArrayList<Future<?>>(); for (AbstractExportItem exportItem : taskList) { diff --git a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/export/AbstractDbExportItem.java b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/export/AbstractDbExportItem.java deleted file mode 100644 index 15833b074aa..00000000000 --- a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/export/AbstractDbExportItem.java +++ /dev/null @@ -1,40 +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.branch.management.exchange.export; - -import org.eclipse.osee.framework.branch.management.exchange.handler.ExportItem; - -/** - * @author Roberto E. Escobar - */ -public abstract class AbstractDbExportItem extends AbstractXmlExportItem { - - private int joinQueryId; - - public AbstractDbExportItem(ExportItem id) { - super(id); - this.joinQueryId = -1; - } - - public void setJoinQueryId(int joinQueryId) { - this.joinQueryId = joinQueryId; - } - - protected int getJoinQueryId() { - return this.joinQueryId; - } - - @Override - public void cleanUp() { - this.joinQueryId = -1; - super.cleanUp(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/export/AbstractExportItem.java b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/export/AbstractExportItem.java index be8de7080d6..150b1726124 100644 --- a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/export/AbstractExportItem.java +++ b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/export/AbstractExportItem.java @@ -16,7 +16,6 @@ import java.util.HashSet; import java.util.Set; import org.eclipse.osee.framework.branch.management.IExchangeTaskListener; import org.eclipse.osee.framework.branch.management.exchange.handler.ExportItem; -import org.eclipse.osee.framework.jdk.core.type.PropertyStore; /** * @author Roberto E. Escobar @@ -27,13 +26,11 @@ public abstract class AbstractExportItem implements Runnable { private final Set<IExchangeTaskListener> exportListeners; private File writeLocation; - private PropertyStore options; private boolean cancel; public AbstractExportItem(ExportItem id) { this.id = id; this.fileName = id.getFileName(); - this.options = null; this.cancel = false; this.exportListeners = Collections.synchronizedSet(new HashSet<IExchangeTaskListener>()); } @@ -66,14 +63,6 @@ public abstract class AbstractExportItem implements Runnable { return writeLocation; } - public void setOptions(PropertyStore options) { - this.options = options; - } - - public PropertyStore getOptions() { - return this.options; - } - public void addExportListener(IExchangeTaskListener exportListener) { if (exportListener != null) { this.exportListeners.add(exportListener); @@ -88,9 +77,6 @@ public abstract class AbstractExportItem implements Runnable { public void cleanUp() { this.setWriteLocation(null); - if (this.options != null) { - this.options.clear(); - } this.exportListeners.clear(); } diff --git a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/export/DbTableExportItem.java b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/export/DbTableExportItem.java index 6444422466c..7b29fe06dcd 100644 --- a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/export/DbTableExportItem.java +++ b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/export/DbTableExportItem.java @@ -20,7 +20,6 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.sql.Timestamp; import java.util.logging.Level; -import org.eclipse.osee.framework.branch.management.exchange.ExchangeDb; import org.eclipse.osee.framework.branch.management.exchange.ExportImportXml; import org.eclipse.osee.framework.branch.management.exchange.OseeServices; import org.eclipse.osee.framework.branch.management.exchange.handler.ExportItem; @@ -30,7 +29,6 @@ import org.eclipse.osee.framework.core.model.AbstractOseeType; import org.eclipse.osee.framework.core.model.cache.AbstractOseeCache; import org.eclipse.osee.framework.core.util.HexUtil; import org.eclipse.osee.framework.database.core.IOseeStatement; -import org.eclipse.osee.framework.jdk.core.type.Pair; import org.eclipse.osee.framework.jdk.core.type.PropertyStore; import org.eclipse.osee.framework.jdk.core.util.Lib; import org.eclipse.osee.framework.jdk.core.util.Strings; @@ -42,19 +40,22 @@ import org.eclipse.osee.framework.resource.management.IResourceLocator; /** * @author Roberto E. Escobar */ -public class DbTableExportItem extends AbstractDbExportItem { - private final String query; +public class DbTableExportItem extends AbstractXmlExportItem { + private final StringBuilder binaryContentBuffer = new StringBuilder(); private final StringBuilder stringContentBuffer = new StringBuilder(); private final StringBuilder oseeCommentBuffer = new StringBuilder(); private final StringBuilder branchNameBuffer = new StringBuilder(); private final StringBuilder rationaleBuffer = new StringBuilder(); private final OseeServices services; + private final String query; + private final Object[] bindData; - public DbTableExportItem(OseeServices services, ExportItem id, String query) { + public DbTableExportItem(OseeServices services, ExportItem id, String query, Object[] bindData) { super(id); this.services = services; this.query = query; + this.bindData = bindData; } protected String exportBinaryDataTo(File tempFolder, String uriTarget) throws OseeCoreException, IOException { @@ -88,8 +89,7 @@ public class DbTableExportItem extends AbstractDbExportItem { protected void doWork(Appendable appendable) throws Exception { IOseeStatement chStmt = services.getDatabaseService().getStatement(); try { - Pair<String, Object[]> sqlData = ExchangeDb.getQueryWithOptions(query, getJoinQueryId(), getOptions()); - chStmt.runPreparedQuery(10000, sqlData.getFirst(), sqlData.getSecond()); + chStmt.runPreparedQuery(10000, query, bindData); while (chStmt.next()) { processData(appendable, chStmt); } diff --git a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/export/ManifestExportItem.java b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/export/ManifestExportItem.java index 232edd59315..2b0b999ace3 100644 --- a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/export/ManifestExportItem.java +++ b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/export/ManifestExportItem.java @@ -18,16 +18,19 @@ import org.eclipse.osee.framework.branch.management.exchange.ExportImportXml; import org.eclipse.osee.framework.branch.management.exchange.handler.ExportItem; import org.eclipse.osee.framework.core.data.OseeCodeVersion; import org.eclipse.osee.framework.database.core.OseeInfo; +import org.eclipse.osee.framework.jdk.core.type.PropertyStore; /** * @author Roberto E. Escobar */ public class ManifestExportItem extends AbstractXmlExportItem { private final List<AbstractExportItem> exportItems; + private final PropertyStore options; - public ManifestExportItem(List<AbstractExportItem> exportItems) { + public ManifestExportItem(List<AbstractExportItem> exportItems, PropertyStore options) { super(ExportItem.EXPORT_MANIFEST); this.exportItems = exportItems; + this.options = options; } private void addEntry(Appendable appendable, String fileName, int priority, String source) throws IOException { @@ -54,13 +57,10 @@ public class ManifestExportItem extends AbstractXmlExportItem { } } ExportImportXml.openPartialXmlNode(appendable, ExportImportXml.OPTIONS); - for (ExportOptions exportOptions : ExportOptions.values()) { - String value = getOptions().get(exportOptions.name()); - if (exportOptions.equals(ExportOptions.EXCLUDE_BASELINE_TXS)) { - value = Boolean.valueOf(value).toString(); - } - ExportImportXml.addXmlAttribute(appendable, exportOptions.name(), value); + for (ExportOptions exportOption : ExportOptions.values()) { + String value = options.get(exportOption.name()); + ExportImportXml.addXmlAttribute(appendable, exportOption.name(), value); } ExportImportXml.closePartialXmlNode(appendable); } -} +}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/handler/ExportItem.java b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/handler/ExportItem.java index fce7acf9dcf..fa0ae832b7d 100644 --- a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/handler/ExportItem.java +++ b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/exchange/handler/ExportItem.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.osee.framework.branch.management.exchange.handler; + /** * @author Ryan D. Brooks */ @@ -56,4 +57,12 @@ public enum ExportItem implements IExportItem { return ordinal(); } + public boolean matches(ExportItem... exportItems) { + for (ExportItem exportItem : exportItems) { + if (this == exportItem) { + return true; + } + } + return false; + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.core.datastore/support/SKYNET.VERSIONING.SCHEMA.xml b/plugins/org.eclipse.osee.framework.core.datastore/support/SKYNET.VERSIONING.SCHEMA.xml index 4afa97aef82..92af25d6d43 100644 --- a/plugins/org.eclipse.osee.framework.core.datastore/support/SKYNET.VERSIONING.SCHEMA.xml +++ b/plugins/org.eclipse.osee.framework.core.datastore/support/SKYNET.VERSIONING.SCHEMA.xml @@ -586,7 +586,7 @@ <Table name="OSEE_JOIN_ID" schema="OSEE" tablespace="osee_data"> <Column id="QUERY_ID" defaultValue="not null" type="INTEGER" /> <Column id="ID" type="INTEGER" /> - <Column id="INSERT_TIME" defaultValue="not null" type="TIMESTAMP" /> + <Column id="INSERT_TIME" type="TIMESTAMP" /> <Index id="OSEE_JOIN_ID__Q_I_IDX" type="UNIQUE" tablespace="osee_index"> <AppliesTo id="QUERY_ID"/> <AppliesTo id="ID"/> diff --git a/plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/BranchManagementCommandProvider.java b/plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/BranchManagementCommandProvider.java index d26a616a3e2..931b878e0b4 100644 --- a/plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/BranchManagementCommandProvider.java +++ b/plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/BranchManagementCommandProvider.java @@ -65,9 +65,7 @@ public class BranchManagementCommandProvider implements CommandProvider { do { arg = ci.nextArgument(); if (Strings.isValid(arg)) { - if (arg.equals("-excludeBaselineTxs")) { - propertyStore.put(ExportOptions.EXCLUDE_BASELINE_TXS.name(), true); - } else if (arg.equals("-includeArchivedBranches")) { + if (arg.equals("-includeArchivedBranches")) { includeArchivedBranches = true; } else if (arg.equals("-compress")) { propertyStore.put(ExportOptions.COMPRESS.name(), true); |