]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/adapter/impl/AbstractRemover.java
Fixed index query regression in L0.Entity instance queries
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / adapter / impl / AbstractRemover.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.layer0.adapter.impl;
13
14 import java.util.Map;
15
16 import org.simantics.db.ReadGraph;
17 import org.simantics.db.Resource;
18 import org.simantics.db.WriteGraph;
19 import org.simantics.db.exception.DatabaseException;
20 import org.simantics.db.layer0.adapter.Remover;
21
22 /**
23  * @author Tuukka Lehtonen
24  */
25 public abstract class AbstractRemover implements Remover {
26
27     protected final Resource resource;
28
29     public AbstractRemover(Resource resource) {
30         this.resource = resource;
31     }
32
33     protected String consultPossibleCanRemove(ReadGraph graph, Resource r, Map<Object, Object> aux) throws DatabaseException {
34         Remover remover = graph.getPossibleAdapter(r, Remover.class);
35         if (remover != null) {
36             return remover.canRemove(graph, aux);
37         }
38         return null;
39     }
40
41     protected boolean consultPossibleRemover(WriteGraph graph, Resource r) throws DatabaseException {
42         Remover remover = graph.getPossibleAdapter(r, Remover.class);
43         if (remover != null) {
44             remover.remove(graph);
45             return true;
46         }
47         return false;
48     }
49
50     @Override
51     public String canRemove(ReadGraph graph, Map<Object, Object> aux) throws DatabaseException {
52         return null;
53     }
54
55 }