X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fsubscription%2FSubscriptionItemsQuery.java;h=5f8c373d66647f9fafed1d67d6c2e54a27599a44;hb=refs%2Fchanges%2F38%2F238%2F2;hp=70d0a7c8ca939512d9bd77d2fd6f4eacfa7d1b36;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/subscription/SubscriptionItemsQuery.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/subscription/SubscriptionItemsQuery.java index 70d0a7c8c..5f8c373d6 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/subscription/SubscriptionItemsQuery.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/subscription/SubscriptionItemsQuery.java @@ -1,57 +1,57 @@ -/******************************************************************************* - * Copyright (c) 2007, 2011 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.modeling.subscription; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.common.request.UniqueRead; -import org.simantics.db.exception.DatabaseException; -import org.simantics.layer0.Layer0; -import org.simantics.modeling.ModelingResources; - - -/** - * This query returns all subscription items for a collection of subscriptions. - */ -public class SubscriptionItemsQuery extends UniqueRead> { - - Collection resources; - - public SubscriptionItemsQuery(Collection resources) { - super(); - this.resources = resources; - } - - @Override - public Set perform(ReadGraph graph) throws DatabaseException { - - Set result = new HashSet(); - ModelingResources MOD = ModelingResources.getInstance(graph); - Layer0 L0 = Layer0.getInstance(graph); - - for (Resource r : resources) { - if ( graph.isInstanceOf(r, MOD.Subscription_Item)) result.add(r); - else if ( graph.isInstanceOf(r, MOD.Subscription)) { - for (Resource rr : graph.getObjects(r, L0.ConsistsOf)) { - if ( graph.isInstanceOf(rr, MOD.Subscription_Item)) result.add(rr); - } - } - } - - return result; - - } -} +/******************************************************************************* + * Copyright (c) 2007, 2011 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.modeling.subscription; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.request.UniqueRead; +import org.simantics.db.exception.DatabaseException; +import org.simantics.layer0.Layer0; +import org.simantics.modeling.ModelingResources; + + +/** + * This query returns all subscription items for a collection of subscriptions. + */ +public class SubscriptionItemsQuery extends UniqueRead> { + + Collection resources; + + public SubscriptionItemsQuery(Collection resources) { + super(); + this.resources = resources; + } + + @Override + public Set perform(ReadGraph graph) throws DatabaseException { + + Set result = new HashSet(); + ModelingResources MOD = ModelingResources.getInstance(graph); + Layer0 L0 = Layer0.getInstance(graph); + + for (Resource r : resources) { + if ( graph.isInstanceOf(r, MOD.Subscription_Item)) result.add(r); + else if ( graph.isInstanceOf(r, MOD.Subscription)) { + for (Resource rr : graph.getObjects(r, L0.ConsistsOf)) { + if ( graph.isInstanceOf(rr, MOD.Subscription_Item)) result.add(rr); + } + } + } + + return result; + + } +}