]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - eclipse/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/editors/ProcessBuilderPage.java
Improve logging
[gpl/argeo-slc.git] / eclipse / plugins / org.argeo.slc.client.ui / src / main / java / org / argeo / slc / client / ui / editors / ProcessBuilderPage.java
index 6b6fed542111422db7d9b34db36c327b5e374f6b..fc0e4f1c8624fcb26f07eef0b15edfd160020472 100644 (file)
@@ -3,6 +3,8 @@ package org.argeo.slc.client.ui.editors;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.SortedSet;
+import java.util.TreeSet;
 import java.util.UUID;
 
 import javax.jcr.Node;
@@ -12,14 +14,11 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.observation.Event;
-import javax.jcr.observation.EventIterator;
 import javax.jcr.observation.EventListener;
 import javax.jcr.observation.ObservationManager;
 import javax.jcr.query.Query;
 import javax.jcr.query.QueryManager;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.argeo.ArgeoException;
 import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
 import org.argeo.jcr.JcrUtils;
@@ -72,9 +71,11 @@ import org.eclipse.ui.forms.editor.FormPage;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.ui.forms.widgets.ScrolledForm;
 
+/** Definition of the process. */
 public class ProcessBuilderPage extends FormPage implements SlcNames {
        public final static String ID = "processBuilderPage";
-       private final static Log log = LogFactory.getLog(ProcessBuilderPage.class);
+       // private final static Log log =
+       // LogFactory.getLog(ProcessBuilderPage.class);
 
        private Node processNode;
 
@@ -113,8 +114,8 @@ public class ProcessBuilderPage extends FormPage implements SlcNames {
                        getManagedForm().addPart(formPart);
 
                        // observation
-                       statusObserver = new AsyncUiEventListener() {
-                               protected void onEventInUiThread(EventIterator events) {
+                       statusObserver = new AsyncUiEventListener(form.getDisplay()) {
+                               protected void onEventInUiThread(List<Event> events) {
                                        statusChanged();
                                }
                        };
@@ -372,6 +373,7 @@ public class ProcessBuilderPage extends FormPage implements SlcNames {
                        specAttrs: for (NodeIterator nit = specAttrsBase.getNodes(); nit
                                        .hasNext();) {
                                Node specAttrNode = nit.nextNode();
+                               String attrName = specAttrNode.getName();
                                if (!specAttrNode
                                                .isNodeType(SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE))
                                        continue specAttrs;
@@ -379,13 +381,13 @@ public class ProcessBuilderPage extends FormPage implements SlcNames {
                                                .getName());
                                JcrUtils.copy(specAttrNode, realizedAttrNode);
 
-                               // for (PropertyIterator pit = realizedAttrNode.getProperties();
-                               // pit
-                               // .hasNext();) {
-                               // Property p = pit.nextProperty();
-                               // if (!p.isMultiple())
-                               // log.debug(p.getName() + "=" + p.getValue().getString());
-                               // }
+                               // ovveride with flow value
+                               if (flowNode.hasNode(attrName)) {
+                                       // assuming this is a primitive
+                                       realizedAttrNode.setProperty(SLC_VALUE,
+                                                       flowNode.getNode(attrName).getProperty(SLC_VALUE)
+                                                                       .getValue());
+                               }
                        }
 
                        flowsViewer.refresh();
@@ -595,11 +597,18 @@ public class ProcessBuilderPage extends FormPage implements SlcNames {
                                                + SlcTypes.SLC_EXECUTION_FLOW
                                                + "] WHERE ISDESCENDANTNODE(['" + path
                                                + "']) OR ISSAMENODE(['" + path + "'])";
-                               //log.debug(statement);
+                               // log.debug(statement);
                                Query query = qm.createQuery(statement, Query.JCR_SQL2);
+
+                               // order paths
+                               SortedSet<String> paths = new TreeSet<String>();
                                for (NodeIterator nit = query.execute().getNodes(); nit
                                                .hasNext();) {
-                                       addFlow(nit.nextNode().getPath());
+                                       paths.add(nit.nextNode().getPath());
+                               }
+
+                               for (String p : paths) {
+                                       addFlow(p);
                                }
                                return true;
                        } catch (RepositoryException e) {