String task = "Importing model into database";
monitor.subTask(task);
- ImportResult ir = TransferableGraphs.importGraph1(session, tgs, advisor, new TGImportMonitor(monitor, task));
+ ImportResult ir;
+ if (properties.containsKey(MigrationStateKeys.FAIL_ON_MISSING)) {
+ ir = TransferableGraphs.importGraph1(session, null, tgs, advisor, new TGImportMonitor(monitor, task),(Boolean)properties.get(MigrationStateKeys.FAIL_ON_MISSING));
+ } else {
+ ir = TransferableGraphs.importGraph1(session, tgs, advisor, new TGImportMonitor(monitor, task));
+ }
+
monitor.subTask("");
setProperty(MigrationStateKeys.IMPORT_RESULT, ir);
* is asked for the first time.
*/
public final static String DATABASE_REVISION_AFTER_TG_IMPORT = "revisionAfterTgImport";
+
+ /**
+ * Allows setting behaviour for missing entities.
+ * Essentially the same thing as "org.simantics.tg.import.failOnMissingEntities" system property
+ * Note: using this will override system wide property.
+ */
+ public final static String FAIL_ON_MISSING = "failOnMissing";
}
Resource ConsistsOf;
Resource PartOf;
Resource HasName;
- Resource NameOf;
+ Resource NameOf;
+
+ boolean failOnMissing;
public StreamingTransferableGraphImportProcess(Session session, VirtualGraph vg, TransferableGraphSource tg, IImportAdvisor2 advisor) {
this(session, vg, tg, advisor, null);
}
-
+
public StreamingTransferableGraphImportProcess(Session session, VirtualGraph vg, TransferableGraphSource tg, IImportAdvisor2 advisor, TGStatusMonitor monitor) {
+ this(session, vg, tg, advisor, monitor, failOnMissingEntities());
+ }
+
+ public StreamingTransferableGraphImportProcess(Session session, VirtualGraph vg, TransferableGraphSource tg, IImportAdvisor2 advisor, TGStatusMonitor monitor, boolean failOnMissing) {
this.tg = tg;
this.vg = vg;
this.advisor = advisor;
this.monitor = monitor;
+ this.failOnMissing = failOnMissing;
}
private int updatePercentage(int percentage, int done, int total) {
}
}
- if (!missingExternals.isEmpty() && failOnMissingEntities())
+ if (!missingExternals.isEmpty() && failOnMissing)
throw new MissingDependencyException(this);
}
- private boolean failOnMissingEntities() {
+ private static boolean failOnMissingEntities() {
return "true".equalsIgnoreCase(
System.getProperty(
"org.simantics.tg.import.failOnMissingEntities",
}
public static ImportResult importGraph1(Session session, VirtualGraph vg, final TransferableGraphSource tg, IImportAdvisor advisor_, TGStatusMonitor monitor) throws DatabaseException {
+ return importGraph1(session, vg, tg, advisor_, monitor, null);
+ }
+
+ public static ImportResult importGraph1(Session session, VirtualGraph vg, final TransferableGraphSource tg, IImportAdvisor advisor_, TGStatusMonitor monitor, Boolean failOnMissing) throws DatabaseException {
final IImportAdvisor2 advisor = (advisor_ instanceof IImportAdvisor2) ? ((IImportAdvisor2)advisor_) : new WrapperAdvisor(advisor_);
- final StreamingTransferableGraphImportProcess process = new StreamingTransferableGraphImportProcess(session, vg, tg, advisor, monitor);
+ final StreamingTransferableGraphImportProcess process = failOnMissing == null ? new StreamingTransferableGraphImportProcess(session, vg, tg, advisor, monitor)
+ : new StreamingTransferableGraphImportProcess(session, vg, tg, advisor, monitor, failOnMissing);
session.syncRequest(new ReadRequest() {
@Override
public void run(ReadGraph graph) throws DatabaseException {