X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Fmigration%2FOntologiesFromLibrary.java;h=774c6465a3a327e0da60b73c97a9a645291b6554;hb=ccb253462b54a0e036f0906ec8ac11a9021a968c;hp=1b88cbb656f09a48278fce200a30deed750ffd55;hpb=43ddca759254b8e38029c1041d91cbdd7890c9b5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/migration/OntologiesFromLibrary.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/migration/OntologiesFromLibrary.java index 1b88cbb65..774c6465a 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/migration/OntologiesFromLibrary.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/migration/OntologiesFromLibrary.java @@ -1,43 +1,52 @@ -/******************************************************************************* - * Copyright (c) 2012 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: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.db.layer0.migration; - -import java.util.ArrayList; -import java.util.List; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.common.request.ObjectsWithType; -import org.simantics.db.common.request.ResourceRead; -import org.simantics.db.exception.DatabaseException; -import org.simantics.layer0.Layer0; - -public class OntologiesFromLibrary extends ResourceRead> { - - public OntologiesFromLibrary(Resource library) { - super(library); - } - - @Override - public List perform(ReadGraph graph) throws DatabaseException { - Layer0 L0 = Layer0.getInstance(graph); - ArrayList result = new ArrayList(); - for(Resource r : graph.syncRequest(new ObjectsWithType(resource, L0.ConsistsOf, L0.Library))) { - if(graph.isInstanceOf(r, L0.Ontology)) - result.add(r); - else - result.addAll(graph.syncRequest(new OntologiesFromLibrary(r))); - } - return result; - } - -} +/******************************************************************************* + * Copyright (c) 2012 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: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.db.layer0.migration; + +import java.util.ArrayList; +import java.util.List; + +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.request.ObjectsWithType; +import org.simantics.db.common.request.ResourceRead; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.request.RequestFlags; +import org.simantics.layer0.Layer0; + +public class OntologiesFromLibrary extends ResourceRead> { + + public OntologiesFromLibrary(Resource library) { + super(library); + } + + @Override + public List perform(ReadGraph graph) throws DatabaseException { + Layer0 L0 = Layer0.getInstance(graph); + ArrayList result = new ArrayList(); + for(Resource r : graph.syncRequest(new ObjectsWithType(resource, L0.ConsistsOf, L0.Library))) { + if(graph.isInstanceOf(r, L0.IndexRoot)) { + if(graph.isInstanceOf(r, L0.Ontology)) { + result.add(r); + } + } else { + result.addAll(graph.syncRequest(new OntologiesFromLibrary(r))); + } + } + return result; + } + + @Override + public int getType() { + return RequestFlags.IMMEDIATE_UPDATE; + } + +}