Merge "Save cluster sets only when creating DB snapshots"
[simantics/platform.git] / bundles / org.simantics.db.procore / src / fi / vtt / simantics / procore / internal / TransferableGraphSupportImpl.java
1 package fi.vtt.simantics.procore.internal;
2
3 import java.io.InputStream;
4
5 import org.simantics.db.ReadGraph;
6 import org.simantics.db.Resource;
7 import org.simantics.db.VirtualGraph;
8 import org.simantics.db.WriteOnlyGraph;
9 import org.simantics.db.exception.DatabaseException;
10 import org.simantics.db.impl.graph.WriteGraphImpl;
11 import org.simantics.db.service.ByteReader;
12 import org.simantics.db.service.TransferableGraphSupport;
13
14 public class TransferableGraphSupportImpl implements TransferableGraphSupport {
15         
16         final private SessionImplSocket session;
17         
18         TransferableGraphSupportImpl(SessionImplSocket session) {
19                 this.session = session;
20         }
21
22         @Override
23         public InputStream getValueStream(ReadGraph graph, Resource resource) {
24         return session.getValueStream(null, resource);
25         }
26         
27         @Override
28         public byte[] getValue(ReadGraph graph, Resource resource) {
29                 return session.getValue(null, resource);
30         }
31         
32         @Override
33         public void setValue(WriteOnlyGraph graph, Resource resource, VirtualGraph provider, byte[] raw) throws DatabaseException {
34                 
35             WriteGraphImpl impl = (WriteGraphImpl)graph;
36             VirtualGraph vg = session.getProvider(provider);
37             impl.writeSupport.claimValue(vg, resource, raw);
38                 
39         }
40         
41         @Override
42         public void setValue(WriteOnlyGraph graph, Resource resource, VirtualGraph provider, ByteReader reader, int amount)
43                 throws DatabaseException {
44             
45         WriteGraphImpl impl = (WriteGraphImpl)graph;
46         VirtualGraph vg = session.getProvider(provider);
47         impl.writeSupport.claimValue(vg, resource, reader, amount);
48             
49         }
50
51 }