]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.structural2/src/org/simantics/structural2/internal/queries/RelatedConnectionsOfConnectionJoin.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.structural2 / src / org / simantics / structural2 / internal / queries / RelatedConnectionsOfConnectionJoin.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.structural2.internal.queries;
13
14 import java.util.Collection;
15 import java.util.Collections;
16 import java.util.Set;
17
18 import org.simantics.db.ReadGraph;
19 import org.simantics.db.Resource;
20 import org.simantics.db.common.request.BinaryRead;
21 import org.simantics.db.exception.DatabaseException;
22 import org.simantics.structural2.queries.ConnectionSet;
23
24 /**
25  * Returns all connections that are reachable from the given ConnectionJoin
26  * excluding the provided excluded connections
27  * 
28  * @author Hannu Niemistö
29  */
30 public class RelatedConnectionsOfConnectionJoin extends BinaryRead<Resource, Collection<Resource>, Set<Resource>>{
31
32     public RelatedConnectionsOfConnectionJoin(Resource join) {
33         super(join, Collections.<Resource>emptySet());
34     }
35
36     public RelatedConnectionsOfConnectionJoin(Resource join, Collection<Resource> excludedConnections) {
37         super(join, excludedConnections);
38     }
39
40     @Override
41     public Set<Resource> perform(ReadGraph g) throws DatabaseException {
42         ConnectionSet connectionSet = new ConnectionSet(g);
43         connectionSet.excludeConnections(parameter2);
44         connectionSet.addJoin(g, parameter);
45         return connectionSet.getConnections();
46     }
47
48 }