X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.modeling.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fui%2Fsharedontology%2Fwizard%2FSharedOntologyExporter.java;h=226aa840f88af9cf6c91da5f6b5350cafdea64ed;hp=651f55f4ebe4e79f194946fa46b756435bf295ba;hb=fa806341cc06b72051d5e8d709674eb9d5c2bf00;hpb=3b4bf8acfe0a6126ce44c5452ffee4dd9af119e3;ds=sidebyside diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sharedontology/wizard/SharedOntologyExporter.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sharedontology/wizard/SharedOntologyExporter.java index 651f55f4e..226aa840f 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sharedontology/wizard/SharedOntologyExporter.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sharedontology/wizard/SharedOntologyExporter.java @@ -14,6 +14,8 @@ package org.simantics.modeling.ui.sharedontology.wizard; import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; +import java.nio.file.Path; +import java.nio.file.Paths; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.SubMonitor; @@ -23,15 +25,18 @@ import org.simantics.databoard.binding.error.BindingException; import org.simantics.databoard.serialization.SerializationException; import org.simantics.db.common.utils.Logger; import org.simantics.db.exception.DatabaseException; +import org.simantics.graph.refactoring.FixExportedOntology; import org.simantics.modeling.ModelingUtils; import org.simantics.modeling.ModelingUtils.LibraryInfo; import org.simantics.utils.ui.dialogs.ShowMessage; +import org.slf4j.LoggerFactory; /** * @author Antti Villberg */ public class SharedOntologyExporter implements IRunnableWithProgress { + private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(SharedOntologyExporter.class); ExportPlan exportModel; public SharedOntologyExporter(ExportPlan exportModel) { @@ -56,7 +61,7 @@ public class SharedOntologyExporter implements IRunnableWithProgress { void exportModel(SubMonitor mon) throws IOException, DatabaseException, SerializationException, BindingException{ try { - doExport(mon, exportModel.exportLocation, exportModel.model); + doExport(mon, exportModel.exportLocation, exportModel.model, exportModel.tgAndPgraph); } catch (DatabaseException e) { e.printStackTrace(); @@ -69,7 +74,20 @@ public class SharedOntologyExporter implements IRunnableWithProgress { } public static void doExport(IProgressMonitor monitor, File location, final LibraryInfo info) throws DatabaseException, IOException { + doExport(monitor, location, info, false); + } + + public static void doExport(IProgressMonitor monitor, File location, final LibraryInfo info, boolean pgraphAndTg) throws DatabaseException, IOException { ModelingUtils.exportSharedOntology(monitor, Simantics.getSession(), location,Constants.SHARED_LIBRARY_FORMAT, Constants.SHARED_LIBRARY_CURRENT_VERSION, info); + if (pgraphAndTg) { + try { + Path input = Paths.get(location.toURI()); + FixExportedOntology.createTg(input); + FixExportedOntology.createPGraph(input); + } catch (Exception e) { + LOGGER.error("Could not generate TG and Pgraph", e); + } + } } }