]> saetta.ns0.it Git - libzakgflow/commitdiff
Started flow until task.
authorAndrea Zagli <azagli@libero.it>
Wed, 16 Mar 2016 15:42:03 +0000 (16:42 +0100)
committerAndrea Zagli <azagli@libero.it>
Wed, 16 Mar 2016 15:42:03 +0000 (16:42 +0100)
src/instance.c

index 98eb07406e791e43a5148f3bcd5d1b41c5d30cdf..e638d0d7973e1ae6cb27c8929d7a8f0421a18442 100644 (file)
@@ -35,6 +35,8 @@
 static void zak_gflow_instance_class_init (ZakGFlowInstanceClass *class);
 static void zak_gflow_instance_init (ZakGFlowInstance *zak_gflow_instance);
 
+static void zak_gflow_instance_next (ZakGFlowInstance *instance, const gchar *node_id, GNode *cur_node);
+
 static void zak_gflow_instance_set_property (GObject *object,
                                guint property_id,
                                const GValue *value,
@@ -75,6 +77,56 @@ zak_gflow_instance_init (ZakGFlowInstance *zak_gflow_instance)
        priv->nodes_history = g_node_new (NULL);
 }
 
+static void
+zak_gflow_instance_next (ZakGFlowInstance *instance, const gchar *node_id, GNode *cur_node)
+{
+       xmlNode *cur;
+
+       GNode *_cur_node;
+
+       xmlNodeSet *xnodeset;
+
+       ZakGFlowInstancePrivate *priv;
+
+       priv = zak_gflow_instance_get_instance_private (instance);
+
+       cur = g_hash_table_lookup (priv->ht_nodes, node_id);
+       if (cur != NULL)
+               {
+                       _cur_node = g_node_insert_data (cur_node, -1, cur);
+                       if (xmlStrcmp (cur->name, (const xmlChar *)"startEvent") == 0)
+                               {
+                                       g_message ("%s: %s", cur->name, (gchar *)xmlGetProp (cur, (const xmlChar *)"name"));
+
+                                       xnodeset = zak_gflow_commons_xml_search (priv->xpcontext, cur, (const xmlChar *)"child::bpmn:outgoing");
+                                       if (xnodeset != NULL
+                                               && xnodeset->nodeNr > 0)
+                                               {
+                                                       zak_gflow_instance_next (instance, (const gchar *)xmlNodeGetContent (xnodeset->nodeTab[0]), _cur_node);
+                                               }
+                               }
+                       else if (xmlStrcmp (cur->name, (const xmlChar *)"sequenceFlow") == 0)
+                               {
+                                       g_message ("%s: %s (targetRef %s)", cur->name, (gchar *)xmlGetProp (cur, (const xmlChar *)"name"), (gchar *)xmlGetProp (cur, (const xmlChar *)"targetRef"));
+
+                                       zak_gflow_instance_next (instance, (const gchar *)xmlGetProp (cur, (const xmlChar *)"targetRef"), _cur_node);
+                               }
+                       else if (xmlStrcmp (cur->name, (const xmlChar *)"task") == 0
+                                        || xmlStrcmp (cur->name, (const xmlChar *)"userTask") == 0)
+                               {
+                                       g_message ("%s", cur->name);
+                               }
+                       else
+                               {
+                                       g_message ("Node %s not implemented.", cur->name);
+                               }
+               }
+       else
+               {
+                       g_warning ("Node not found: %s.", node_id);
+               }
+}
+
 /*+
  * zak_gflow_instance_new:
  * @ht_nodes:
@@ -87,11 +139,6 @@ ZakGFlowInstance
        ZakGFlowInstance *instance;
        ZakGFlowInstancePrivate *priv;
 
-       xmlNode *cur;
-       GNode *cur_node;
-
-       xmlNodeSet *xnodeset;
-
        g_return_val_if_fail (xpcontext != NULL, NULL);
        g_return_val_if_fail (ht_nodes != NULL, NULL);
        g_return_val_if_fail (node_id != NULL, NULL);
@@ -103,35 +150,7 @@ ZakGFlowInstance
        priv->xpcontext = xpcontext;
        priv->ht_nodes = g_hash_table_ref (ht_nodes);
 
-       cur = g_hash_table_lookup (priv->ht_nodes, node_id);
-       if (cur == NULL)
-               {
-                       g_warning ("No first/start node found/setted.");
-               }
-       else
-               {
-                       cur_node = g_node_insert_data (priv->nodes_history, -1, cur);
-                       if (xmlStrcmp (cur->name, (const xmlChar *)"startEvent") == 0)
-                               {
-                                       g_message ("%s: %s", cur->name, (gchar *)xmlGetProp (cur, (const xmlChar *)"name"));
-
-                                       xnodeset = zak_gflow_commons_xml_search (priv->xpcontext, cur, (const xmlChar *)"child::bpmn:outgoing");
-                                       if (xnodeset != NULL
-                                               && xnodeset->nodeNr > 0)
-                                               {
-                                                       cur = g_hash_table_lookup (priv->ht_nodes, xmlNodeGetContent (xnodeset->nodeTab[0]));
-                                                       if (cur != NULL)
-                                                               {
-                                                                       cur_node = g_node_insert_data (cur_node, -1, cur);
-                                                                       g_message ("\tnext: %s %s", cur->name, (gchar *)xmlGetProp (cur, (const xmlChar *)"id"));
-                                                               }
-                                                       else
-                                                               {
-                                                                       g_message ("\tnext: no next found");
-                                                               }
-                                               }
-                               }
-               }
+       zak_gflow_instance_next (instance, node_id, priv->nodes_history);
 
        return instance;
 }