]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/migration/MigratedImportResult.java
Index query fixes after commit 4e7fd7de
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / migration / MigratedImportResult.java
1 /*******************************************************************************
2  * Copyright (c) 2017 Association for Decentralized Information Management in
3  * Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     Semantum Oy - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.db.layer0.migration;
13
14 import java.util.Collection;
15
16 import org.simantics.db.Resource;
17 import org.simantics.db.exception.AssumptionException;
18 import org.simantics.db.exception.DatabaseException;
19 import org.simantics.graph.db.ImportResult;
20
21 /**
22  * @author Tuukka Lehtonen
23  * @since 1.28.0
24  */
25 public class MigratedImportResult {
26
27         /**
28          * The root resources created by the import process.
29          */
30         public final Collection<Resource> roots;
31
32         public final ImportResult tgResult;
33
34         public MigratedImportResult(Collection<Resource> roots, ImportResult tgResult) {
35                 this.roots = roots;
36                 this.tgResult = tgResult;
37         }
38
39         public Resource singleRoot() throws DatabaseException {
40                 int s = roots.size();
41                 if (s != 1)
42                         throw new AssumptionException("No single imported root found, roots are: " + roots);
43                 return roots.iterator().next();
44         }
45
46         public boolean hasMissingExternals() {
47                 return tgResult != null ? tgResult.hasMissingExternals() : false;
48         }
49
50 }