1 package org.simantics.db.layer0.util;
3 import org.simantics.databoard.accessor.error.AccessorException;
4 import org.simantics.databoard.binding.Binding;
5 import org.simantics.databoard.type.Datatype;
6 import org.simantics.db.exception.DatabaseException;
7 import org.simantics.db.service.SerialisationSupport;
8 import org.simantics.graph.utils.TGResourceUtil;
9 import org.simantics.graph.utils.TGResourceUtil.LongAdapter;
11 public class ResourceTGValueModifier implements TGValueModifier {
13 final private TGResourceUtil util = new TGResourceUtil();
14 final private SerialisationSupport ss;
16 public ResourceTGValueModifier(SerialisationSupport ss) {
21 public boolean mayNeedModification(Datatype type) {
22 return util.mayHaveResource(type);
26 public Object modify(final DomainProcessorState state, Binding binding, Object value) throws DatabaseException {
30 util.adaptValue( binding, value, new LongAdapter() {
32 public long adapt(long in) {
34 int shortId = ss.getTransientId(in);
35 return state.ids.get(shortId);
36 } catch (DatabaseException e) {
45 } catch (AccessorException e) {
47 throw new DatabaseException(e);