--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2017 Association for Decentralized Information Management in
+ * Industry THTH ry.
+ * 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:
+ * Semantum Oy - initial API and implementation
+ *******************************************************************************/
+package org.simantics.db.common.primitiverequest;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.common.request.ResourceRead;
+import org.simantics.db.exception.ServiceException;
+import org.simantics.layer0.Layer0;
+
+/**
+ * @author Tuukka Lehtonen
+ * @since 1.31.0
+ */
+public final class IsExternalEntity extends ResourceRead<Boolean> {
+
+ public IsExternalEntity(Resource resource) {
+ super(resource);
+ }
+
+ @Override
+ public Boolean perform(ReadGraph graph) throws ServiceException {
+ return graph.isInstanceOf(resource, Layer0.getInstance(graph).ExternalEntity);
+ }
+
+}
/**
* @author Tuukka Lehtonen
- * @author Teemu Mätäsniemi
+ * @author Teemu Mätäsniemi
* @author Antti Villberg
*/
public class ModelExportWizard extends Wizard implements IExportWizard {
Deque<String> recentExportPaths;
boolean overwrite;
+ boolean includeDependencies;
- ExportPlan exportModel;
+ ExportPlan exportModel;
private boolean readPreferences() {
IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, Activator.PLUGIN_ID);
String recentPathsPref = store.getString(Preferences.RECENT_SHARED_LIBRARY_EXPORT_LOCATIONS);
recentExportPaths = Preferences.decodePaths(recentPathsPref);
overwrite = store.getBoolean(Preferences.SHARED_LIBRARY_EXPORT_OVERWRITE);
+ includeDependencies = store.getBoolean(Preferences.EXPORT_INCLUDE_DEPENDENCIES);
return true;
}
store.putValue(Preferences.RECENT_SHARED_LIBRARY_EXPORT_LOCATIONS, Preferences.encodePaths(recentExportPaths));
store.setValue(Preferences.SHARED_LIBRARY_EXPORT_OVERWRITE, exportModel.overwrite);
+ store.setValue(Preferences.EXPORT_INCLUDE_DEPENDENCIES, exportModel.includeDependencies);
if (store.needsSaving())
store.save();
exportModel.project = project;
exportModel.selection = selection;
exportModel.overwrite = overwrite;
+ exportModel.includeDependencies = includeDependencies;
}
@Override
importModel = new ImportPlan(ctx, recentImportPaths);
importModel.project = project;
importModel.selection = selection.getFirstElement();
+ importModel.includeDependencies = store.getBoolean(Preferences.IMPORT_INCLUDE_DEPENDENCIES);
return true;
}
IPersistentPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, Activator.PLUGIN_ID);
store.putValue(Preferences.RECENT_SHARED_LIBRARY_IMPORT_LOCATIONS, Preferences.encodePaths(importModel.recentLocations));
+ store.setValue(Preferences.IMPORT_INCLUDE_DEPENDENCIES, importModel.includeDependencies);
if (store.needsSaving())
store.save();
import org.simantics.databoard.container.FormatHandler;
import org.simantics.db.Resource;
import org.simantics.db.Session;
+import org.simantics.db.common.primitiverequest.IsExternalEntity;
import org.simantics.db.common.primitiverequest.PossibleResource;
import org.simantics.db.layer0.adapter.impl.DefaultPasteImportAdvisor;
import org.simantics.db.layer0.migration.MigratedImportResult;
if (libraryDependenciesBean != null) {
for (ModelDependency dependency : libraryDependenciesBean.dependencies) {
Resource existing = session.sync(new PossibleResource(dependency.uri));
- if (existing == null) {
+ boolean isExternalEntity = existing != null && session.syncRequest(new IsExternalEntity(existing));
+ if (existing == null || isExternalEntity) {
MigrationUtils.importSharedOntology(session, dependency.tg, false);
}
}
public static final String RECENT_SHARED_LIBRARY_IMPORT_LOCATIONS = "RECENT_SHARED_LIBRARY_IMPORT_LOCATIONS";
public static final String RECENT_SHARED_LIBRARY_EXPORT_LOCATIONS = "RECENT_SHARED_LIBRARY_EXPORT_LOCATIONS";
public static final String SHARED_LIBRARY_EXPORT_OVERWRITE = "SHARED_LIBRARY_EXPORT_OVERWRITE";
+ public static final String EXPORT_INCLUDE_DEPENDENCIES = "EXPORT_INCLUDE_DEPENDENCIES";
+ public static final String IMPORT_INCLUDE_DEPENDENCIES = "IMPORT_INCLUDE_DEPENDENCIES";
private static final String TAG_PATH = "path";
private static final String ATTR_NAME = "name";