X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.diagram%2Fsrc%2Forg%2Fsimantics%2Fdiagram%2Fquery%2FFlagTypeFilters.java;fp=bundles%2Forg.simantics.diagram%2Fsrc%2Forg%2Fsimantics%2Fdiagram%2Fquery%2FFlagTypeFilters.java;h=3b185af351ea607961a3e67f1b2cdd05ce4ad5c0;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=7f8815aee285159a8b52d8746117becd2cb45e61;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/query/FlagTypeFilters.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/query/FlagTypeFilters.java index 7f8815aee..3b185af35 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/query/FlagTypeFilters.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/query/FlagTypeFilters.java @@ -1,56 +1,56 @@ -/******************************************************************************* - * 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.diagram.query; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import org.simantics.databoard.Bindings; -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; -import org.simantics.modeling.template2d.ontology.Template2dResource; - -/** - * @author Tuukka Lehtonen - */ -public class FlagTypeFilters extends ResourceRead> { - - public FlagTypeFilters(Resource visual) { - super(visual); - } - - @Override - public List perform(ReadGraph g) throws DatabaseException { - Layer0 L0 = Layer0.getInstance(g); - Template2dResource TEMPLATE2D = Template2dResource.getInstance(g); - - Collection filters = g.syncRequest(new ObjectsWithType(resource, L0.ConsistsOf, TEMPLATE2D.FlagTypeVisual_Filter)); - if (filters.isEmpty()) - return Collections.emptyList(); - - List result = new ArrayList(filters.size()); - for (Resource node : filters) { - String reference = g.getPossibleRelatedValue2(node, TEMPLATE2D.FlagTypeVisual_Filter_HasProperty, Bindings.STRING); - String pattern = g.getPossibleRelatedValue2(node, TEMPLATE2D.FlagTypeVisual_Filter_HasPattern, Bindings.STRING); - Boolean matchRequired = g.getPossibleRelatedValue2(node, TEMPLATE2D.FlagTypeVisual_Filter_matchRequired, Bindings.BOOLEAN); - result.add( new FlagTypeFilter(node, reference, pattern, matchRequired) ); - } - 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.diagram.query; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import org.simantics.databoard.Bindings; +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; +import org.simantics.modeling.template2d.ontology.Template2dResource; + +/** + * @author Tuukka Lehtonen + */ +public class FlagTypeFilters extends ResourceRead> { + + public FlagTypeFilters(Resource visual) { + super(visual); + } + + @Override + public List perform(ReadGraph g) throws DatabaseException { + Layer0 L0 = Layer0.getInstance(g); + Template2dResource TEMPLATE2D = Template2dResource.getInstance(g); + + Collection filters = g.syncRequest(new ObjectsWithType(resource, L0.ConsistsOf, TEMPLATE2D.FlagTypeVisual_Filter)); + if (filters.isEmpty()) + return Collections.emptyList(); + + List result = new ArrayList(filters.size()); + for (Resource node : filters) { + String reference = g.getPossibleRelatedValue2(node, TEMPLATE2D.FlagTypeVisual_Filter_HasProperty, Bindings.STRING); + String pattern = g.getPossibleRelatedValue2(node, TEMPLATE2D.FlagTypeVisual_Filter_HasPattern, Bindings.STRING); + Boolean matchRequired = g.getPossibleRelatedValue2(node, TEMPLATE2D.FlagTypeVisual_Filter_matchRequired, Bindings.BOOLEAN); + result.add( new FlagTypeFilter(node, reference, pattern, matchRequired) ); + } + return result; + } + +}