import org.simantics.Simantics;
import org.simantics.db.ReadGraph;
import org.simantics.db.Resource;
+import org.simantics.db.common.request.IndexRoot;
import org.simantics.db.common.request.ReadRequest;
import org.simantics.db.exception.DatabaseException;
import org.simantics.district.imports.DistrictImportUtils;
@Override
public void run(ReadGraph graph) throws DatabaseException {
+ Resource indexRoot = graph.sync(new IndexRoot(model.getParentDiagram()));
if (model.isVertexImport())
- componentMappings = Functions.getVertexMappings(graph, model.getParentDiagram());
+ componentMappings = Functions.getVertexMappings(graph, indexRoot);
else
- componentMappings = Functions.getEdgeMappings(graph, model.getParentDiagram());
+ componentMappings = Functions.getEdgeMappings(graph, indexRoot);
}
});
} catch (DatabaseException e) {
return baseMappingModifier(graph, element, DistrictNetworkResource.getInstance(graph).HasMapping, mappingType, context);
}
- public static Map<String, Resource> getVertexMappings(ReadGraph graph, Resource resource) throws DatabaseException {
- Map<String, Resource> second = getNetworkMappingsByType(graph, resource , DistrictNetworkResource.getInstance(graph).Mapping_VertexMapping);
+ public static Map<String, Resource> getVertexMappings(ReadGraph graph, Resource indexRoot) throws DatabaseException {
+ Map<String, Resource> second = getNetworkMappingsByType(graph, indexRoot, DistrictNetworkResource.getInstance(graph).Mapping_VertexMapping);
return second;
}
- public static Map<String, Resource> getEdgeMappings(ReadGraph graph, Resource resource) throws DatabaseException {
- Map<String, Resource> second = getNetworkMappingsByType(graph, resource , DistrictNetworkResource.getInstance(graph).Mapping_EdgeMapping);
+ public static Map<String, Resource> getEdgeMappings(ReadGraph graph, Resource indexRoot) throws DatabaseException {
+ Map<String, Resource> second = getNetworkMappingsByType(graph, indexRoot, DistrictNetworkResource.getInstance(graph).Mapping_EdgeMapping);
return second;
}
public static Map<String, Resource> getCRSs(ReadGraph graph, Resource resource) throws DatabaseException {
- Map<String, Resource> result = getNetworkMappingsByType(graph, resource, DistrictNetworkResource.getInstance(graph).SpatialRefSystem);
+ Map<String, Resource> result = getNetworkMappingsByType(graph, graph.sync(new IndexRoot(resource)), DistrictNetworkResource.getInstance(graph).SpatialRefSystem);
return result;
}
- public static Map<String, Resource> getNetworkMappingsByType(ReadGraph graph, Resource element, Resource mappingType) throws DatabaseException {
- Resource indexRoot = graph.sync(new IndexRoot(element));
+ public static Map<String, Resource> getNetworkMappingsByType(ReadGraph graph, Resource indexRoot, Resource mappingType) throws DatabaseException {
List<Resource> mappings = QueryIndexUtils.searchByType(graph, indexRoot, mappingType);
Map<String, Resource> result = new HashMap<>(mappings.size());
Layer0 L0 = Layer0.getInstance(graph);
@Override
public void run(ReadGraph graph) throws DatabaseException {
-
- vertexMappings = getVertexMappings(graph, configuration);
- edgeMappings = getEdgeMappings(graph, configuration);
+ Resource indexRoot = graph.sync(new IndexRoot(configuration));
+ vertexMappings = getVertexMappings(graph, indexRoot);
+ edgeMappings = getEdgeMappings(graph, indexRoot);
composites = getComposites(graph, configuration);