X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Frequest%2FVariableIndexRoot.java;h=7d2a8d9858c2ee6b7eccfaacf3202c71bea2e7df;hb=33b30297f751e06e9abac260d31313e2f833fedc;hp=e076d5e4370373550383d32011c56597cc7fbba1;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/VariableIndexRoot.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/VariableIndexRoot.java index e076d5e43..7d2a8d985 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/VariableIndexRoot.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/VariableIndexRoot.java @@ -1,42 +1,42 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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.request; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.common.request.UnaryRead; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.variable.Variable; -import org.simantics.layer0.Layer0; - -public class VariableIndexRoot extends UnaryRead { - - public VariableIndexRoot(Variable variable) { - super(variable); - } - - @Override - public Resource perform(ReadGraph graph) throws DatabaseException { - - Layer0 L0 = Layer0.getInstance(graph); - Resource r = parameter.getPossibleRepresents(graph); - if(r != null) { - if(graph.isInstanceOf(r, L0.IndexRoot)) return r; - } - - Variable parent = parameter.getParent(graph); - if(parent != null) return graph.sync(new VariableIndexRoot(parent)); - else return null; - - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 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.request; + +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.request.UnaryRead; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.variable.Variable; +import org.simantics.layer0.Layer0; + +public class VariableIndexRoot extends UnaryRead { + + public VariableIndexRoot(Variable variable) { + super(variable); + } + + @Override + public Resource perform(ReadGraph graph) throws DatabaseException { + + Layer0 L0 = Layer0.getInstance(graph); + Resource r = parameter.getPossibleRepresents(graph); + if(r != null) { + if(graph.isInstanceOf(r, L0.IndexRoot)) return r; + } + + Variable parent = parameter.getParent(graph); + if(parent != null) return graph.sync(new VariableIndexRoot(parent)); + else return null; + + } + +}