X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.db.common%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fcommon%2Frequest%2FTransientResourceRead.java;h=117a1a27fb3d0e2fba3acab9ef9a57f7280858c2;hp=83c318b601cf67676596e80a3d3f7d1d66c61adf;hb=refs%2Fchanges%2F38%2F238%2F2;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/TransientResourceRead.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/TransientResourceRead.java index 83c318b60..117a1a27f 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/request/TransientResourceRead.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/request/TransientResourceRead.java @@ -1,55 +1,55 @@ -/******************************************************************************* - * 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.common.request; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.request.ReadExt; -import org.simantics.db.service.QueryControl; - -abstract public class TransientResourceRead extends BinaryRead implements ReadExt { - - protected static final Object WITH_PARENT = new Object(); - - public TransientResourceRead(ReadGraph graph, Resource parameter) throws DatabaseException { - this(graph, graph.getService(QueryControl.class), parameter); - } - - public TransientResourceRead(ReadGraph graph, QueryControl qc, Resource parameter) throws DatabaseException { - super(resolveFirstParameter(graph, qc), parameter); - } - - final private static Object resolveFirstParameter(ReadGraph graph, QueryControl qc) throws DatabaseException { - if(qc.hasParentRequest(graph)) return WITH_PARENT; - else return graph.getModificationCounter(); - } - - @Override - final public R perform(ReadGraph _graph) throws DatabaseException { - if(parameter == WITH_PARENT) { - return perform(_graph, parameter2); - } else { - QueryControl qc = _graph.getService(QueryControl.class); - ReadGraph graph = qc.getIndependentGraph(_graph); - return perform(graph, parameter2); - } - } - - abstract public R perform(ReadGraph graph, Resource parameter) throws DatabaseException; - - @Override - public boolean isImmutable(ReadGraph graph) throws DatabaseException { - return graph.isImmutable(parameter2); - } - -} +/******************************************************************************* + * 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.common.request; + +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.request.ReadExt; +import org.simantics.db.service.QueryControl; + +abstract public class TransientResourceRead extends BinaryRead implements ReadExt { + + protected static final Object WITH_PARENT = new Object(); + + public TransientResourceRead(ReadGraph graph, Resource parameter) throws DatabaseException { + this(graph, graph.getService(QueryControl.class), parameter); + } + + public TransientResourceRead(ReadGraph graph, QueryControl qc, Resource parameter) throws DatabaseException { + super(resolveFirstParameter(graph, qc), parameter); + } + + final private static Object resolveFirstParameter(ReadGraph graph, QueryControl qc) throws DatabaseException { + if(qc.hasParentRequest(graph)) return WITH_PARENT; + else return graph.getModificationCounter(); + } + + @Override + final public R perform(ReadGraph _graph) throws DatabaseException { + if(parameter == WITH_PARENT) { + return perform(_graph, parameter2); + } else { + QueryControl qc = _graph.getService(QueryControl.class); + ReadGraph graph = qc.getIndependentGraph(_graph); + return perform(graph, parameter2); + } + } + + abstract public R perform(ReadGraph graph, Resource parameter) throws DatabaseException; + + @Override + public boolean isImmutable(ReadGraph graph) throws DatabaseException { + return graph.isImmutable(parameter2); + } + +}