]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.impl/src/org/simantics/db/impl/exception/ManyObjectsForFunctionalRelationExceptionImpl.java
Fail safe import fixes made by Antti
[simantics/platform.git] / bundles / org.simantics.db.impl / src / org / simantics / db / impl / exception / ManyObjectsForFunctionalRelationExceptionImpl.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.db.impl.exception;
13
14 import org.simantics.databoard.Bindings;
15 import org.simantics.db.Resource;
16 import org.simantics.db.exception.DatabaseException;
17 import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;
18 import org.simantics.db.impl.ResourceImpl;
19 import org.simantics.db.impl.graph.ReadGraphImpl;
20 import org.simantics.db.impl.support.ResourceSupport;
21 import org.simantics.layer0.Layer0;
22
23 public class ManyObjectsForFunctionalRelationExceptionImpl extends ManyObjectsForFunctionalRelationException {
24
25     private static final long serialVersionUID = 804263533707864050L;
26     
27     static String name(ReadGraphImpl graph, int subject) throws DatabaseException {
28                 Layer0 b = Layer0.getInstance(graph);
29         ResourceSupport support = graph.getService(ResourceSupport.class);
30         Resource r = new ResourceImpl(support, subject);
31         String name = graph.getPossibleRelatedValue(r, b.HasName, Bindings.STRING);
32         return name;
33     }
34     
35     public ManyObjectsForFunctionalRelationExceptionImpl(ReadGraphImpl graph, ManyObjectsForFunctionalRelationException source) throws DatabaseException {
36         super("subject='" + name(graph, source.getIndex(0)) + "'");
37     }
38
39 }