package org.simantics.graph.compiler.internal.procedures; import java.util.Collection; import org.simantics.databoard.Bindings; import org.simantics.databoard.binding.Binding; import org.simantics.databoard.type.Datatype; import org.simantics.graph.compiler.internal.ltk.Problem; import org.simantics.graph.compiler.internal.store.PreValueStore; import org.simantics.graph.query.IDataTypeQuery; import org.simantics.graph.query.IGraph; import org.simantics.graph.query.Paths; import org.simantics.graph.store.GraphStore; import org.simantics.graph.store.StatementStore; import org.simantics.graph.store.ValueStore; import gnu.trove.list.array.TIntArrayList; import gnu.trove.map.hash.TIntObjectHashMap; public class ConvertPreValues implements Runnable { IGraph cg; GraphStore store; Collection problems; public ConvertPreValues(IGraph cg, GraphStore store, Collection problems) { this.cg = cg; this.store = store; this.problems = problems; } @Override public void run() { PreValueStore preValues = store.getStore(PreValueStore.class); preValues.convertPreValues(store.values, new IDataTypeQuery() { Paths paths = cg.getPaths(); StatementStore statements = store.statements; ValueStore values = store.values; int HasDatatype = store.identities.createPathToId(paths.HasDatatype); int InstanceOf = store.identities.createPathToId(paths.InstanceOf); @Override public Binding getDataType(int id) { TIntArrayList objects = statements.getObjects(id, HasDatatype); if(objects.isEmpty()) { objects = statements.getObjects(id, InstanceOf); for(int i=0;i typeBindingCache = new TIntObjectHashMap(); private Binding getDatatypeForType(int type) { if(typeBindingCache.containsKey(type)) return typeBindingCache.get(type); else { Datatype dt = cg.getAssertedDatatype(store.idToRes(type)); Binding binding = dt == null ? null : Bindings.getBinding(dt); typeBindingCache.put(type, binding); return binding; } } }, problems); } }