import org.simantics.db.common.request.WriteResultRequest;\r
import org.simantics.db.common.utils.NameUtils;\r
import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.exception.ServiceException;\r
import org.simantics.db.layer0.util.SessionGarbageCollection;\r
import org.simantics.db.request.Read;\r
import org.simantics.interop.mapping.data.GraphNode;\r
\r
\r
\r
- private void applyGenerations(WriteGraph graph, Collection<GraphNode<Identifiable>> nodes, IProgressMonitor monitor) throws Exception {\r
+ protected void applyGenerations(WriteGraph graph, Collection<GraphNode<Identifiable>> nodes, IProgressMonitor monitor) throws Exception {\r
\r
int size = nodes.size();\r
int count = 0;\r
for (GraphNode<Identifiable> n : nodes) {\r
\r
MapList<Integer,GenerationRule> priRules = n.getHint(MappingHints.KEY_GENERATION_RULES);\r
- List<GenerationRule> rules = priRules.getValues(stage);\r
- for (GenerationRule r : rules) {\r
- r.generate(graph, n);\r
+ if (priRules != null) {\r
+ List<GenerationRule> rules = priRules.getValues(stage);\r
+ for (GenerationRule r : rules) {\r
+ r.generate(graph, n);\r
+ }\r
}\r
\r
monitor.subTask("Generating objects, stage " + stage + " : ("+ (++count) + "/" + size + ")");\r
}\r
}\r
\r
- private void applyConnections(WriteGraph g, Collection<GraphNode<Identifiable>> nodes, IProgressMonitor monitor) throws Exception {\r
+ protected void applyConnections(WriteGraph g, Collection<GraphNode<Identifiable>> nodes, IProgressMonitor monitor) throws Exception {\r
int size = nodes.size();\r
int count = 0;\r
\r
return res.toString();\r
}\r
\r
- public class WriteWrapper extends WriteGraphProxy {\r
- \r
- \r
- private Collection<Resource> createdResources = new ArrayList<Resource>();\r
- \r
- public WriteWrapper(WriteGraph graph) {\r
- super(graph);\r
- }\r
- \r
- public Collection<Resource> getCreatedResources() {\r
- return createdResources;\r
- }\r
- \r
- public void clearCreated() {\r
- createdResources = new ArrayList<Resource>();\r
- }\r
- \r
- @Override\r
- public Resource newResource() throws ServiceException {\r
- Resource res = graph.newResource();\r
- createdResources.add(res);\r
- return res;\r
- }\r
- \r
- @Override\r
- public Resource newResource(long clusterId) throws ServiceException {\r
- Resource res = graph.newResource(clusterId);\r
- createdResources.add(res);\r
- return res;\r
- }\r
- \r
- \r
- }\r
+\r
\r
- private void initializeRules(Session session, VirtualGraph vg, final Resource model ) throws DatabaseException{\r
+ protected void initializeRules(Session session, VirtualGraph vg, final Resource model ) throws DatabaseException{\r
session.syncRequest(new WriteRequest(vg) {\r
@Override\r
public void perform(WriteGraph g) throws DatabaseException {\r
\r
}\r
\r
- private void collect(ReadGraph g) throws DatabaseException {\r
+ protected void collect(ReadGraph g) throws DatabaseException {\r
if (vg != null)\r
return;\r
SessionGarbageCollection.gc(g, 0, -1);\r
\r
int collect = 0;\r
\r
- private void collect2(ReadGraph g) throws DatabaseException {\r
+ protected void collect2(ReadGraph g) throws DatabaseException {\r
if (vg != null)\r
return;\r
\r
}\r
}\r
\r
- private void applyModifications(Session session, final Collection<GraphNode<Identifiable>> nodes, final IProgressMonitor monitor) throws Exception {\r
+ protected void applyModifications(Session session, final Collection<GraphNode<Identifiable>> nodes, final IProgressMonitor monitor) throws Exception {\r
\r
\r
\r
});\r
}\r
\r
- private void applyGenerations(Session session, VirtualGraph vg, Collection<GraphNode<Identifiable>> nodes, IProgressMonitor monitor) throws Exception {\r
+ protected void applyGenerations(Session session, VirtualGraph vg, Collection<GraphNode<Identifiable>> nodes, IProgressMonitor monitor) throws Exception {\r
\r
int size = nodes.size();\r
int count = 0;\r
}\r
}\r
\r
- private void applyConnections(Session session, VirtualGraph vg, Collection<GraphNode<Identifiable>> nodes, IProgressMonitor monitor) throws Exception {\r
+ protected void applyConnections(Session session, VirtualGraph vg, Collection<GraphNode<Identifiable>> nodes, IProgressMonitor monitor) throws Exception {\r
int size = nodes.size();\r
int count = 0;\r
\r
});\r
}\r
\r
- private void applyModifications(ReadGraph g, GraphNode<Identifiable> n, Pair<IdentificationRule, ModificationRule> modRule, Collection<GraphNode<Identifiable>> ruleModified) throws Exception {\r
+ protected void applyModifications(ReadGraph g, GraphNode<Identifiable> n, Pair<IdentificationRule, ModificationRule> modRule, Collection<GraphNode<Identifiable>> ruleModified) throws Exception {\r
if (!n.isDisposed() && modRule.first.matches(g, n)) { // we have to check \r
Collection<GraphNode<Identifiable>> perRule = new ArrayList<GraphNode<Identifiable>>();\r
perRule.add(n);\r
}\r
}\r
\r
- private void applyConnections(WriteGraph g, GraphNode<Identifiable> node) throws Exception {\r
+ protected void applyConnections(WriteGraph g, GraphNode<Identifiable> node) throws Exception {\r
for (Link<Identifiable> link : node.getLinks()) {\r
if (link.isMain()) {\r
\r