From: Bruno Sinou Date: Fri, 1 Oct 2010 08:44:29 +0000 (+0000) Subject: First draft of ProcessDetail Implementation X-Git-Tag: argeo-slc-2.1.7~1149 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=545ef79e8a522b784a70dd09f71e43266dba4312;p=gpl%2Fargeo-slc.git First draft of ProcessDetail Implementation git-svn-id: https://svn.argeo.org/slc/trunk@3813 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/aspects/ContentProviderAspect.java b/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/aspects/ContentProviderAspect.java index 0cd9c28d7..f92d9d571 100644 --- a/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/aspects/ContentProviderAspect.java +++ b/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/aspects/ContentProviderAspect.java @@ -3,6 +3,7 @@ package org.argeo.slc.client.aspects; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; import org.hibernate.LockMode; import org.hibernate.SessionFactory; @@ -23,20 +24,27 @@ public class ContentProviderAspect { private SessionFactory sessionFactory; + // We select here only getters from classes of the contentprovider package + // that need to get data from hibernate + + // PointCuts + @Pointcut("(execution (* org.argeo.slc.client.contentprovider.ProcessListTableLabelProvider.get*(..)) && args(o,..))" + + " || (execution (* org.argeo.slc.client.contentprovider.ProcessDetailContentProvider.get*(..)) && args(o,..))") + void contentProviderGetterWrapper(Object o) { + } + // Advices - @Around("execution (* org.argeo.slc.client.contentprovider.*.get*(Object, int))") - public Object aroundGetVariable(ProceedingJoinPoint thisJoinPoint) + @Around("contentProviderGetterWrapper(o)") + public Object aroundGetWrapper(ProceedingJoinPoint thisJoinPoint, Object o) throws Throwable { - Object o = thisJoinPoint.getArgs()[0]; - // TODO : find a mean to handle session & manager with txManager // in order to not have to re-begin a transaction here. sessionFactory.getCurrentSession().beginTransaction(); - + // reassociate a transient instance with a session (LockMode.NONE). sessionFactory.getCurrentSession().lock(o, LockMode.NONE); - + Object result = thisJoinPoint.proceed(); sessionFactory.getCurrentSession().getTransaction().commit(); return result; diff --git a/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/contentprovider/ProcessDetailContentProvider.java b/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/contentprovider/ProcessDetailContentProvider.java new file mode 100644 index 000000000..da2a793ee --- /dev/null +++ b/eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/contentprovider/ProcessDetailContentProvider.java @@ -0,0 +1,275 @@ +package org.argeo.slc.client.contentprovider; + +import java.util.List; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.argeo.slc.process.RealizedFlow; +import org.argeo.slc.process.SlcExecution; +import org.argeo.slc.process.SlcExecutionStep; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.Viewer; + +/** + * Basic tree view of the chosen process details + */ +public class ProcessDetailContentProvider implements ITreeContentProvider { + private final static Log log = LogFactory + .getLog(ProcessDetailContentProvider.class); + + private SlcExecution slcExecution; + + // private List slcAgents; + + public Object[] getChildren(Object parent) { + if (parent instanceof SlcExecution) { + slcExecution = (SlcExecution) parent; + + List steps = slcExecution.getSteps(); + List realizedFlows = slcExecution.getRealizedFlows(); + + for (int i = 0; i < steps.size(); i++) { + log.debug("step[" + i + "] : " + steps.get(i).getType()); + } + for (int i = 0; i < realizedFlows.size(); i++) { + log.debug("step[" + i + "] : " + + realizedFlows.get(i).toString()); + } + + log.debug(" Realized flows : "); + return steps.toArray(); + } + // if (parent instanceof ExecutionModuleNode) { + // ExecutionModuleNode executionModuleNode = (ExecutionModuleNode) + // parent; + // ExecutionModuleDescriptor emd = + // executionModuleNode.getDescriptor(); + // emd = executionModuleNode.getAgentNode().getAgent() + // .getExecutionModuleDescriptor(emd.getName(), + // emd.getVersion()); + // executionModuleNode.cacheDescriptor(emd); + // // for (String flowName : + // executionModuleNode.getFlowDescriptors() + // // .keySet()) { + // // executionModuleNode.addChild(new FlowNode(flowName, + // // executionModuleNode)); + // // } + // return executionModuleNode.getChildren(); + // } else if (parent instanceof AgentNode) { + // AgentNode agentNode = (AgentNode) parent; + // + // if (log.isTraceEnabled()) + // log.trace("Scan agent " + agentNode); + // + // agentNode.clearChildren(); + // for (ExecutionModuleDescriptor desc : agentNode.getAgent() + // .listExecutionModuleDescriptors()) { + // agentNode.addChild(new ExecutionModuleNode(agentNode, desc)); + // } + // + // return agentNode.getChildren(); + // } else if (parent instanceof TreeParent) { + // return ((TreeParent) parent).getChildren(); + // } else if (parent instanceof FlowNode) { + // return new Object[0]; + // } else { + // List agentNodes = new ArrayList(); + // for (SlcAgent slcAgent : slcAgents) { + // agentNodes.add(new AgentNode(slcAgent)); + // } + // return agentNodes.toArray(); + // } + return null; + } + + public Object getParent(Object node) { + // if (node instanceof TreeObject) { + // return ((TreeObject) node).getParent(); + // } + return null; + } + + public boolean hasChildren(Object parent) { + // if (parent instanceof TreeParent && ((TreeParent) parent).isLoaded()) + // { + // return ((TreeParent) parent).hasChildren(); + // } else if (parent instanceof AgentNode) { + // return true; + // } else if (parent instanceof ExecutionModuleNode) { + // return true; + // } + return false; + } + + public void inputChanged(Viewer v, Object oldInput, Object newInput) { + } + + public void dispose() { + } + + public Object[] getElements(Object parent) { + if (parent instanceof SlcExecution) { + slcExecution = (SlcExecution) parent; + + List steps = slcExecution.getSteps(); + List realizedFlows = slcExecution.getRealizedFlows(); + + for (int i = 0; i < steps.size(); i++) { + log.debug("step[" + i + "] : " + steps.get(i).getType()); + } + for (int i = 0; i < realizedFlows.size(); i++) { + log.debug("step[" + i + "] : " + + realizedFlows.get(i).toString()); + } + + log.debug(" Realized flows : "); + return steps.toArray(); + } + // return getChildren(parent); + return null; + } + + // public class AgentNode extends TreeParent { + // private final SlcAgent agent; + // + // public AgentNode(SlcAgent agent) { + // super(agent.toString()); + // this.agent = agent; + // } + + // public SlcAgent getAgent() { + // return agent; + // } + // } + + // public class ExecutionModuleNode extends TreeParent { + // private final AgentNode agentNode; + // private ExecutionModuleDescriptor descriptor; + // private Map flowDescriptors; + // + // public ExecutionModuleNode(AgentNode agentNode, + // ExecutionModuleDescriptor descriptor) { + // super(descriptor.toString()); + // this.agentNode = agentNode; + // this.descriptor = descriptor; + // + // } + // + // public AgentNode getAgentNode() { + // return agentNode; + // } + // + // public ExecutionModuleDescriptor getDescriptor() { + // return descriptor; + // } + // Object o = thisJoinPoint.getArgs()[0]; + + // public void cacheDescriptor(ExecutionModuleDescriptor descriptor) { + // this.descriptor = descriptor; + // + // SortedMap folderNodes = new TreeMap(); + // + // flowDescriptors = new HashMap(); + // for (ExecutionFlowDescriptor fd : descriptor.getExecutionFlows()) { + // // if (log.isTraceEnabled()) + // // log.trace("fd.path=" + fd.getPath() + ", fd.name=" + // // + fd.getName()); + // + // // find path and label + // String path; + // String label; + // int lastSlash = fd.getName().lastIndexOf('/'); + // if ((fd.getPath() == null || fd.getPath().trim().equals("")) + // && lastSlash >= 0) { + // path = fd.getName().substring(0, lastSlash); + // label = fd.getName().substring(lastSlash + 1); + // } else { + // path = fd.getPath(); + // label = fd.getName(); + // } + // // if (log.isTraceEnabled()) + // // log.trace("path=" + path + ", label=" + label); + // + // if (path == null || path.trim().equals("") + // || path.trim().equals("/")) { + // // directChildren.put(name, new FlowNode(name, this)); + // addChild(new FlowNode(label, fd.getName(), this)); + // } else { + // FolderNode folderNode = mkdirs(this, path, folderNodes); + // folderNode + // .addChild(new FlowNode(label, fd.getName(), this)); + // } + // + // flowDescriptors.put(fd.getName(), fd); + // } + // // TODO: make it readonly + // } + // + // protected FolderNode mkdirs(TreeParent root, String path, + // SortedMap folderNodes) { + // // Normalize + // if (path.charAt(0) != '/') + // path = '/' + path; + // if (path.charAt(path.length() - 1) == '/') + // path = path.substring(0, path.length() - 1); + // + // if (folderNodes.containsKey(path)) + // return folderNodes.get(path); + // + // int lastIndx = path.lastIndexOf('/'); + // String folderName; + // String parentPath; + // if (lastIndx >= 0) { + // folderName = path.substring(lastIndx + 1); + // parentPath = path.substring(0, lastIndx); + // } else { + // folderName = path; + // parentPath = ""; + // } + // + // TreeParent parent; + // if (parentPath.equals("")) + // parent = root; + // else + // parent = mkdirs(root, parentPath, folderNodes); + // FolderNode newFolder = new FolderNode(folderName); + // parent.addChild(newFolder); + // folderNodes.put(path, newFolder); + // return newFolder; + // } + // + // public Map getFlowDescriptors() { + // return flowDescriptors; + // } + // + // } + // + // public class FlowNode extends TreeObject { + // private final String flowName; + // private final ExecutionModuleNode executionModuleNode; + // + // public FlowNode(String label, String flowName, + // ExecutionModuleNode executionModuleNode) { + // super(label); + // this.flowName = flowName; + // this.executionModuleNode = executionModuleNode; + // } + // + // public String getFlowName() { + // return flowName; + // } + // + // public ExecutionModuleNode getExecutionModuleNode() { + // return executionModuleNode; + // } + // + // } + // + // public class FolderNode extends TreeParent { + // public FolderNode(String name) { + // super(name); + // } + // + // } +} diff --git a/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/spring/core.xml b/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/spring/core.xml index 43b6e0f1e..62f8cbbd4 100644 --- a/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/spring/core.xml +++ b/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/spring/core.xml @@ -6,10 +6,14 @@ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd "> + + diff --git a/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/spring/osgi.xml b/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/spring/osgi.xml index 1427a591a..97e6e5474 100644 --- a/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/spring/osgi.xml +++ b/eclipse/plugins/org.argeo.slc.client.hibernate/META-INF/spring/osgi.xml @@ -20,7 +20,7 @@ - + + + + on DB used implementation. We use bean-name reference because interface is + not enough to choose between various been with same interface --> + + + diff --git a/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/views.xml b/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/views.xml index 9b65ea05c..5ad45642a 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/views.xml +++ b/eclipse/plugins/org.argeo.slc.client.ui/META-INF/spring/views.xml @@ -22,6 +22,17 @@ + + + + + + + + diff --git a/eclipse/plugins/org.argeo.slc.client.ui/plugin.xml b/eclipse/plugins/org.argeo.slc.client.ui/plugin.xml index 3ca7dafa8..4c822efc5 100644 --- a/eclipse/plugins/org.argeo.slc.client.ui/plugin.xml +++ b/eclipse/plugins/org.argeo.slc.client.ui/plugin.xml @@ -23,6 +23,13 @@ name="Process List" restorable="true"> + + - + + + + @@ -63,7 +78,7 @@ id="slcMenu" label="SLC"> @@ -75,7 +90,7 @@ parameters = new ArrayList(); + + // get the parameter + IParameter iparam = cmd + .getParameter("org.argeo.slc.client.commands.processUuid"); + Parameterization params = new Parameterization(iparam, + se.getUuid()); // "testUUID");// + parameters.add(params); + + // build the parameterized command + ParameterizedCommand pc = new ParameterizedCommand(cmd, + parameters.toArray(new Parameterization[parameters + .size()])); + + // execute the command + handlerService = (IHandlerService) window + .getService(IHandlerService.class); + handlerService.executeCommand(pc, null); + + } catch (Exception e) { + e.printStackTrace(); + throw new SlcException("Problem while rendering result. " + + e.getMessage()); + } + } + } + } + // IoC public void setSlcExecutionDao(SlcExecutionDao slcExecutionDao) { this.slcExecutionDao = slcExecutionDao;