| /** |
| ******************************************************************************** |
| * Copyright (c) 2015 Timing-Architects Embedded Systems GmbH and others. |
| * |
| * This program and the accompanying materials are made |
| * available under the terms of the Eclipse Public License 2.0 |
| * which is available at https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Timing-Architects Embedded Systems GmbH - initial API and implementation |
| ******************************************************************************** |
| */ |
| |
| package org.eclipse.app4mc.amalthea._import.btf; |
| |
| import java.lang.reflect.InvocationTargetException; |
| import java.sql.Connection; |
| import java.sql.SQLException; |
| |
| import org.eclipse.core.runtime.IProgressMonitor; |
| import org.eclipse.core.runtime.SubMonitor; |
| import org.eclipse.jface.operation.IRunnableWithProgress; |
| |
| |
| public class ImportTransformation implements IRunnableWithProgress { |
| |
| private final String btfFile; |
| private final String atdbFile; |
| |
| public ImportTransformation(final String source, final String target) { |
| if (source.endsWith(".btf") && target.endsWith(".atdb")) { |
| this.btfFile = source; |
| this.atdbFile = target; |
| } else { |
| this.btfFile = ""; |
| this.atdbFile = ""; |
| } |
| } |
| |
| @Override |
| public void run(final IProgressMonitor progressMonitor) throws InvocationTargetException { |
| try { |
| if (!this.btfFile.isEmpty() && !this.atdbFile.isEmpty()) { |
| final SubMonitor subMon = SubMonitor.convert(progressMonitor, "Converting BTF trace to ATDB...", 100); |
| final SubMonitor createATDBMonitor = subMon.split(1); |
| createATDBMonitor.beginTask("Creating empty ATDB...", 1); |
| final ATDBBuilder atdbBuilder = new ATDBBuilder(this.atdbFile) |
| .createBasicDBStructure().createBasicViews() |
| .createOptionalAndTemporaryTables(true).createOptionalViews(); |
| createATDBMonitor.done(); |
| |
| final SubMonitor btfImportMonitor = subMon.split(69); |
| final Connection con = atdbBuilder.getCurrentConnection(); |
| final BTFImporter btfImporter = new BTFImporter(con, this.btfFile); |
| btfImporter.run(btfImportMonitor); |
| btfImportMonitor.done(); |
| |
| final SubMonitor metricCalcMonitor = subMon.split(30); |
| atdbBuilder.autoPopulateEntityFilteredTraceEventTables(); |
| final ATDBMetricCalculator metricCalc = new ATDBMetricCalculator(con); |
| metricCalc.run(metricCalcMonitor); |
| atdbBuilder.closeATDB(); |
| metricCalcMonitor.done(); |
| } |
| } catch (SQLException e) { |
| throw new InvocationTargetException(e); |
| } finally { |
| progressMonitor.done(); |
| } |
| } |
| } |