X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Fmigration%2FMigratedImportResult.java;fp=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Fmigration%2FMigratedImportResult.java;h=1981ae45eed04a29a8c264a03129902a8f3302ea;hb=9acebe9584f8f2a78f0322b6e0e24438e7ceb984;hp=0000000000000000000000000000000000000000;hpb=081bf7e08a67c0af23c5846e163be39bb19f12cb;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/migration/MigratedImportResult.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/migration/MigratedImportResult.java new file mode 100644 index 000000000..1981ae45e --- /dev/null +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/migration/MigratedImportResult.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * 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.layer0.migration; + +import java.util.Collection; + +import org.simantics.db.Resource; +import org.simantics.db.exception.AssumptionException; +import org.simantics.db.exception.DatabaseException; +import org.simantics.graph.db.ImportResult; + +/** + * @author Tuukka Lehtonen + * @since 1.28.0 + */ +public class MigratedImportResult { + + /** + * The root resources created by the import process. + */ + public final Collection roots; + + public final ImportResult tgResult; + + public MigratedImportResult(Collection roots, ImportResult tgResult) { + this.roots = roots; + this.tgResult = tgResult; + } + + public Resource singleRoot() throws DatabaseException { + int s = roots.size(); + if (s != 1) + throw new AssumptionException("No single imported root found, roots are: " + roots); + return roots.iterator().next(); + } + + public boolean hasMissingExternals() { + return tgResult != null ? tgResult.hasMissingExternals() : false; + } + +}