1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.structural2.modelingRules;
14 import java.util.Collection;
17 import org.simantics.db.ReadGraph;
18 import org.simantics.db.Resource;
19 import org.simantics.db.exception.DatabaseException;
21 public class SimpleModelingRules extends AbstractModelingRules {
23 private Resource connectionType;
24 private Resource attachmentRelation;
26 public SimpleModelingRules(Resource connectionType, Resource attachmentRelation) {
27 this.connectionType = connectionType;
28 this.attachmentRelation = attachmentRelation;
31 IAttachmentRelationMap attachmentRelations = new IAttachmentRelationMap() {
33 public Resource get(ReadGraph g, CPTerminal cp) throws DatabaseException {
34 return attachmentRelation;
39 public ConnectionJudgement judgeConnection(ReadGraph g,
40 Collection<IConnectionPoint> connectionPoints)
41 throws DatabaseException {
42 ConnectionJudgement judgement = new ConnectionJudgement(connectionType);
43 judgement.attachmentRelations = attachmentRelations;
48 public Resource computeConnectionType(ReadGraph g, Collection<IConnectionPoint> connectionPoints)
49 throws DatabaseException {
50 return connectionType;
54 public IAttachmentRelationMap getAttachmentRelations(ReadGraph g,
55 Resource connection) {
56 return attachmentRelations;
60 public Set<CPTerminal> resolveTerminals(ReadGraph g,
61 Collection<IConnectionPoint> connectionPoints)
62 throws DatabaseException {
63 throw new UnsupportedOperationException("Simple Modelling Rules do not process actual connection points");