]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.common/src/org/simantics/db/common/request/PossibleChild.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.db.common / src / org / simantics / db / common / request / PossibleChild.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.common.request;
13
14 import java.util.Map;
15
16 import org.simantics.db.ReadGraph;
17 import org.simantics.db.Resource;
18 import org.simantics.db.common.uri.UnescapedChildMapOfResource;
19 import org.simantics.db.exception.DatabaseException;
20 import org.simantics.db.request.ReadExt;
21 import org.simantics.db.request.RequestFlags;
22
23 final public class PossibleChild extends BinaryRead<Resource, String, Resource> implements ReadExt {
24
25     public PossibleChild(Resource resource, String name) {
26         super(resource, name);
27     }
28
29     @Override
30     public Resource perform(ReadGraph graph) throws DatabaseException {
31         Map<String, Resource> childMap = graph.syncRequest(new UnescapedChildMapOfResource(parameter));
32         return childMap.get(parameter2);
33     }
34     
35     @Override
36     public String toString() {
37         return "PossibleChild " + parameter + " " + parameter2;
38     }
39
40         @Override
41         public boolean isImmutable(ReadGraph graph) throws DatabaseException {
42                 return graph.isImmutable(parameter);
43         }
44
45         @Override
46         public int getType() {
47                 return RequestFlags.IMMEDIATE_UPDATE;
48         }
49
50 }