1 /*******************************************************************************
2 * Copyright (c) 2012 Association for Decentralized Information Management in
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.modeling.adapters;
14 import org.simantics.db.AsyncReadGraph;
15 import org.simantics.db.Resource;
16 import org.simantics.db.Statement;
17 import org.simantics.db.layer0.adapter.impl.TypeSubgraphExtent;
18 import org.simantics.db.procedure.AsyncProcedure;
19 import org.simantics.modeling.ModelingResources;
20 import org.simantics.operation.Layer0X;
22 public class MappingSubgraphExtent extends TypeSubgraphExtent {
24 final private Classifier classifier = new Classifier() {
27 public void classify(AsyncReadGraph graph, Statement statement, ExtentStatus objectExtent,
30 if(!ExtentStatus.INTERNAL.equals(objectExtent)) return;
32 Resource predicate = statement.getPredicate();
34 Layer0X L0X = graph.getService(Layer0X.class);
35 ModelingResources mr = graph.getService(ModelingResources.class);
37 if(mr.DiagramConnectionToConnection.equalsResource(predicate)) callback.statement(statement, true);
38 else if(mr.DiagramToComposite.equalsResource(predicate)) callback.statement(statement, true);
39 else if(L0X.HasTrigger.equalsResource(predicate)) callback.statement(statement, true);
40 else if(mr.ElementToComponent.equalsResource(predicate)) callback.statement(statement, true);
41 else if(mr.CompositeToDiagram.equalsResource(predicate)) callback.statement(statement, true);
42 else if(mr.ComponentToElement.equalsResource(predicate)) callback.statement(statement, true);
43 else if(mr.ConnectionToDiagramConnection.equalsResource(predicate)) callback.statement(statement, true);
50 public void accept(AsyncReadGraph graph, Resource resource,
51 AsyncProcedure<Classifier> procedure, Callback callback) {
52 procedure.execute(graph, classifier);