You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hise-commits@incubator.apache.org by wi...@apache.org on 2010/03/19 14:31:00 UTC

svn commit: r925237 - in /incubator/hise/trunk: hise-bundle/src/main/resources/META-INF/spring/ hise-services/src/main/java/org/apache/hise/dao/ hise-services/src/main/java/org/apache/hise/engine/ hise-services/src/main/java/org/apache/hise/engine/jaxw...

Author: witek
Date: Fri Mar 19 14:30:59 2010
New Revision: 925237

URL: http://svn.apache.org/viewvc?rev=925237&view=rev
Log:
Cleanup. Logging,.

Modified:
    incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise-ds.xml
    incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise.xml
    incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/dao/HISEDao.java
    incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/HISEEngineImpl.java
    incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsImpl.java
    incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/Task.java
    incubator/hise/trunk/hise-services/src/test/java/org/apache/hise/TaskOperationsTest.java

Modified: incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise-ds.xml
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise-ds.xml?rev=925237&r1=925236&r2=925237&view=diff
==============================================================================
--- incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise-ds.xml (original)
+++ incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise-ds.xml Fri Mar 19 14:30:59 2010
@@ -20,17 +20,16 @@
 <beans xmlns="http://www.springframework.org/schema/beans" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:util="http://www.springframework.org/schema/util"
-xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
-xmlns:ctx="http://www.springframework.org/schema/context"
+       xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
+       xmlns:ctx="http://www.springframework.org/schema/context"
        
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
     http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
-http://www.springframework.org/schema/osgi-compendium http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd
-    ">
+    http://www.springframework.org/schema/osgi-compendium http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd">
 
-  <osgix:cm-properties id="preProps" persistent-id="org.apache.hise">
+    <osgix:cm-properties id="preProps" persistent-id="org.apache.hise">
         <prop key="openjpa.db">H2</prop>
         <prop key="openjpa.dictionary">org.apache.openjpa.jdbc.sql.H2Dictionary</prop>
         <prop key="openjpa.synchronizeMappings">buildSchema(ForeignKeys=true,SchemaAction='add')</prop>
@@ -46,10 +45,9 @@ http://www.springframework.org/schema/os
         <prop key="db.testOnBorrow">true</prop>
         <prop key="db.testWhileIdle">true</prop>
         <prop key="db.timeBetweenEvictionRunsMillis">5000</prop>
-  </osgix:cm-properties>
-
-  <ctx:property-placeholder properties-ref="preProps" />
+    </osgix:cm-properties>
 
+    <ctx:property-placeholder properties-ref="preProps" />
 
     <bean id="htEntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
         <property name="dataSource" ref="dataSource" />
@@ -75,18 +73,18 @@ http://www.springframework.org/schema/os
     
     <!-- OpenJPA H2 Driver -->
     <bean id="jpaVendorAdapter" class="org.apache.hise.dao.vendor.OpenJpaVendorAdapter">
-    <property name="database" value="${openjpa.db}"/>
-    <property name="databasePlatform" value="${openjpa.dictionary}"/>
-    <property name="generateDdl"    value="${openjpa.generateDdl}" />
-    <property name="showSql"      value="${openjpa.showSql}" />
-    <property name="extProperties">
-      <util:map>
-        <entry key="openjpa.jdbc.SynchronizeMappings" value="${openjpa.synchronizeMappings}"/>
-      </util:map>
-    </property>
-  </bean>
+	    <property name="database" value="${openjpa.db}"/>
+	    <property name="databasePlatform" value="${openjpa.dictionary}"/>
+	    <property name="generateDdl" value="${openjpa.generateDdl}" />
+	    <property name="showSql" value="${openjpa.showSql}" />
+	    <property name="extProperties">
+	      <util:map>
+	        <entry key="openjpa.jdbc.SynchronizeMappings" value="${openjpa.synchronizeMappings}"/>
+	      </util:map>
+	    </property>
+    </bean>
   
-  <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
+    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
         <property name="driverClassName" value="${db.driver}" />
         <property name="url" value="${db.url}"/>
         <property name="username" value="${db.user}" />
@@ -100,7 +98,7 @@ http://www.springframework.org/schema/os
         <!--
         <property name="validationQuery" value="${db.validationQuery}"/>
         -->
-  </bean>
+    </bean>
 <!--
         <property name="validationQueryTimeout" value="${db.validationQueryTimeout}"/>
 -->

Modified: incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise.xml
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise.xml?rev=925237&r1=925236&r2=925237&view=diff
==============================================================================
--- incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise.xml (original)
+++ incubator/hise/trunk/hise-bundle/src/main/resources/META-INF/spring/hise.xml Fri Mar 19 14:30:59 2010
@@ -3,9 +3,21 @@
     ~ Licensed to the Apache Software Foundation (ASF) under one ~ or more contributor license agreements. See the NOTICE file ~ distributed with this work for additional information ~ regarding copyright ownership. The ASF licenses this file ~ to you under the Apache License, Version 2.0 (the ~ "License"); you may not use this file except in compliance ~ with the License. You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, ~ software distributed under the License is distributed on an ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~ KIND, either express or implied. See the License for the ~ specific
     language governing permissions and limitations ~ under the License.
   -->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util" xmlns:http-conf="http://cxf.apache.org/transports/http/configuration" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:cxf="http://cxf.apache.org/core" xmlns:htd="http://www.example.org/WS-HT" xmlns:htda="http://www.example.org/WS-HT/api" xmlns:htdt="http://www.example.org/WS-HT/api/xsd" xmlns:htdaw="http://www.example.org/WS-HT/api/wsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ins="http://www.insurance.example.com/claims" 
-xmlns:osgi="http://www.springframework.org/schema/osgi"
-  xsi:schemaLocation="
+<beans xmlns="http://www.springframework.org/schema/beans" 
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+       xmlns:context="http://www.springframework.org/schema/context" 
+       xmlns:util="http://www.springframework.org/schema/util" 
+       xmlns:http-conf="http://cxf.apache.org/transports/http/configuration" 
+       xmlns:tx="http://www.springframework.org/schema/tx" 
+       xmlns:jaxws="http://cxf.apache.org/jaxws" 
+       xmlns:cxf="http://cxf.apache.org/core" 
+       xmlns:htd="http://www.example.org/WS-HT" 
+       xmlns:htda="http://www.example.org/WS-HT/api" 
+       xmlns:htdt="http://www.example.org/WS-HT/api/xsd" 
+       xmlns:htdaw="http://www.example.org/WS-HT/api/wsdl" 
+       xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
+       xmlns:osgi="http://www.springframework.org/schema/osgi"
+       xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.0.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
@@ -14,8 +26,7 @@ xmlns:osgi="http://www.springframework.o
        http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
        http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
-       http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd
-       ">
+       http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">
 
 <!--
   <import resource="classpath:META-INF/cxf/cxf.xml"/>
@@ -51,7 +62,6 @@ xmlns:osgi="http://www.springframework.o
 
   <osgi:service id="hiseEngineOsgi" ref="hiseEngine" interface="org.apache.hise.api.HISEEngine" />
 
-
   <bean id="hiseUserDetails" class="org.apache.hise.engine.DefaultHISEUserDetails">
     <property name="hiseDao" ref="hiseDao"/>
   </bean>
@@ -75,8 +85,8 @@ xmlns:osgi="http://www.springframework.o
     <property name="entityManagerFactory" ref="htEntityManagerFactory"/>
     <property name="dataSource" ref="dataSource"/>
   </bean>
-  <osgi:service id="transactionManagerOsgi" interface="org.springframework.transaction.PlatformTransactionManager" ref="transactionManager"/>
 
+  <osgi:service id="transactionManagerOsgi" interface="org.springframework.transaction.PlatformTransactionManager" ref="transactionManager"/>
 
   <bean name="taskOperations" class="org.apache.hise.engine.jaxws.TaskOperationsImpl" init-method="init">
     <property name="hiseEngine" ref="hiseEngine"/>

Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/dao/HISEDao.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/dao/HISEDao.java?rev=925237&r1=925236&r2=925237&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/dao/HISEDao.java (original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/dao/HISEDao.java Fri Mar 19 14:30:59 2010
@@ -312,8 +312,8 @@ public class HISEDao extends JpaDaoSuppo
 
     public OrgEntity getOrgEntity(final String name) {
         return (OrgEntity) getJpaTemplate().execute(new JpaCallback() {
-            public Object doInJpa(EntityManager e) throws PersistenceException {
-                Query query = e.createQuery("FROM OrgEntity o WHERE o.name = :name");
+            public Object doInJpa(EntityManager em) throws PersistenceException {
+                Query query = em.createQuery("FROM OrgEntity o WHERE o.name = :name");
                 query.setParameter("name", name);
                 return query.getSingleResult();
             }
@@ -321,20 +321,29 @@ public class HISEDao extends JpaDaoSuppo
     }
     
     public List<Task> getUserTasks(final TaskQuery query) {
-//        TaskOrgEntity to;to.g
+        
+        Validate.notNull(query);
+        
         switch (query.getGenericHumanRole()) {
         case ACTUALOWNER:
             return (List<Task>) getJpaTemplate().executeFind(new JpaCallback() {
                 public Object doInJpa(EntityManager em) throws PersistenceException {
+                    
+                    Validate.notNull(em);
+                    
                     return em.createQuery("select distinct t from Task t where t.actualOwner = :user")
                     .setParameter("user", query.getUser())
                     .setMaxResults(query.getMaxTasks())
                     .getResultList();
                 }
             });
+
         case POTENTIALOWNERS:
             return (List<Task>) getJpaTemplate().executeFind(new JpaCallback() {
                 public Object doInJpa(EntityManager em) throws PersistenceException {
+                    
+                    Validate.notNull(em);
+                    
                     return new JpaQueryBuilder().buildQuery(em, 
                             new Object[] {
                             "select distinct t from Task t, TaskOrgEntity e where e.task = t and (e.name = :user and e.type = :constUser",
@@ -353,7 +362,7 @@ public class HISEDao extends JpaDaoSuppo
                 }
             });
         default:
-            throw new IllegalStateException();
+            throw new IllegalStateException("generic human role not supported");
         }
     }
     

Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/HISEEngineImpl.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/HISEEngineImpl.java?rev=925237&r1=925236&r2=925237&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/HISEEngineImpl.java (original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/HISEEngineImpl.java Fri Mar 19 14:30:59 2010
@@ -42,6 +42,7 @@ import java.util.List;
 import java.util.Map;
 
 public class HISEEngineImpl implements HISEEngine {
+
     private static Log log = LogFactory.getLog(HISEEngineImpl.class);
     
     public final Map<String, QName> tasksMap = new HashMap<String, QName>();
@@ -102,7 +103,7 @@ public class HISEEngineImpl implements H
     }
     
     public TaskDefinition getTaskDefinition(QName taskName) {
-        Validate.notNull(tasks.get(taskName), "" + taskName + " not found");
+        Validate.notNull(tasks.get(taskName), "" + taskName + " not found. Deployed tasks: " + tasks.toString());
         return tasks.get(taskName).taskDefinition;
     }
     

Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsImpl.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsImpl.java?rev=925237&r1=925236&r2=925237&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsImpl.java (original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsImpl.java Fri Mar 19 14:30:59 2010
@@ -25,7 +25,6 @@ import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 
-import javax.annotation.Resource;
 import javax.jws.WebService;
 import javax.xml.datatype.Duration;
 import javax.xml.namespace.QName;
@@ -33,17 +32,20 @@ import javax.xml.ws.Holder;
 import javax.xml.ws.WebServiceContext;
 
 import org.apache.hise.dao.GenericHumanRole;
-import org.apache.hise.dao.OrgEntity;
-import org.apache.hise.dao.TaskOrgEntity;
 import org.apache.hise.dao.TaskQuery;
 import org.apache.hise.engine.HISEEngineImpl;
+
 import org.apache.hise.engine.wsdl.IllegalAccessFault;
 import org.apache.hise.engine.wsdl.IllegalArgumentFault;
 import org.apache.hise.engine.wsdl.IllegalOperationFault;
 import org.apache.hise.engine.wsdl.IllegalStateFault;
+
 import org.apache.hise.engine.wsdl.RecipientNotAllowed;
+
 import org.apache.hise.engine.wsdl.TaskOperations;
+
 import org.apache.hise.lang.xsd.htd.TOrganizationalEntity;
+
 import org.apache.hise.lang.xsd.htda.TAttachment;
 import org.apache.hise.lang.xsd.htda.TAttachmentInfo;
 import org.apache.hise.lang.xsd.htda.TComment;
@@ -51,13 +53,20 @@ import org.apache.hise.lang.xsd.htda.TSt
 import org.apache.hise.lang.xsd.htda.TTask;
 import org.apache.hise.lang.xsd.htda.TTaskAbstract;
 import org.apache.hise.lang.xsd.htda.TTaskQueryResultSet;
+
 import org.apache.hise.lang.xsd.htdt.TTime;
 import org.apache.hise.runtime.Task;
-import org.springframework.beans.BeanUtils;
 import org.springframework.transaction.annotation.Transactional;
 
 /**
- * Implementation of WS-HT API. Operations are executed by end users, i.e. actual or potential owners. The identity of the user is implicitly passed when invoking any of the operations listed in the table below. The participant operations listed below only apply to tasks unless explicitly noted otherwise. The authorization column indicates people of which roles are authorized to perform the operation. Stakeholders of the task are not mentioned explicitly. They have the same authorization rights as business administrators.
+ * Implementation of WS-HT API. Operations are executed by end users, i.e.
+ * actual or potential owners. The identity of the user is implicitly passed
+ * when invoking any of the operations listed in the table below. The
+ * participant operations listed below only apply to tasks unless explicitly
+ * noted otherwise. The authorization column indicates people of which roles are
+ * authorized to perform the operation. Stakeholders of the task are not
+ * mentioned explicitly. They have the same authorization rights as business
+ * administrators.
  * 
  * @author Witek Wołejszo
  * @author Warren Crossing
@@ -70,41 +79,41 @@ public class TaskOperationsImpl implemen
 
     private WebServiceContext context;
 
-    public TaskOperationsImpl()  {
-    }
-    
+    /**
+     * Sets up {@link WebServiceContext} used to lookup authenticated user
+     * performing operations.
+     * 
+     * @throws Exception
+     */
     public void init() throws Exception {
         context = (WebServiceContext) Class.forName("org.apache.cxf.jaxws.context.WebServiceContextImpl").newInstance();
     }
 
+    /**
+     * IoC setter.
+     * 
+     * @param hiseEngine
+     */
     public void setHiseEngine(HISEEngineImpl hiseEngine) {
         this.hiseEngine = hiseEngine;
     }
 
-//    @Resource
-//    public void setContext(WebServiceContext context) {
-//        this.context = context;
-//    }
-
     protected String getUserString() {
         return context.getUserPrincipal().getName();
     }
-    
-    protected String loadUser() {
-//        return hiseEngine.getHiseDao().getOrgEntity(getUserString());
-        return getUserString();
-    }
-    
-    public void claim(String identifier) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault {
-        Task task = Task.load(hiseEngine, Long.valueOf(identifier));
-        task.setCurrentUser(loadUser());
-        task.claim();
-    }
 
-    public List<org.apache.hise.lang.xsd.htda.TTask> getMyTasks(String taskType, String genericHumanRole, String workQueue, List<TStatus> status, String whereClause, String createdOnClause, Integer maxTasks) throws IllegalArgumentFault, IllegalStateFault {
-        List<org.apache.hise.lang.xsd.htda.TTask> l = new ArrayList<org.apache.hise.lang.xsd.htda.TTask>();
-        String user = loadUser();
-        
+    // implementation in progress
+
+    /**
+     * {@inheritDoc}
+     */
+    public List<TTask> getMyTasks(String taskType, String genericHumanRole, String workQueue, List<TStatus> status, String whereClause, String createdOnClause,
+            Integer maxTasks) throws IllegalArgumentFault, IllegalStateFault {
+
+        List<TTask> result = new ArrayList<TTask>();
+
+        String user = getUserString();
+
         TaskQuery query = new TaskQuery();
         query.setUser(user);
         query.setUserGroups(hiseEngine.getHiseUserDetails().getUserGroups(user));
@@ -114,175 +123,138 @@ public class TaskOperationsImpl implemen
         query.setStatus(status);
         query.setWhereClause(whereClause);
         query.setCreatedOnClause(createdOnClause);
-        query.setMaxTasks(maxTasks);
-        
-        List<org.apache.hise.dao.Task> k = hiseEngine.getHiseDao().getUserTasks(query);
-        for (org.apache.hise.dao.Task u : k) {
+
+        if (maxTasks != null) {
+            query.setMaxTasks(maxTasks);
+        }
+
+        List<org.apache.hise.dao.Task> tasks = hiseEngine.getHiseDao().getUserTasks(query);
+        for (org.apache.hise.dao.Task u : tasks) {
             TTask t = convertTask(u.getId());
-            l.add(t);
+            result.add(t);
         }
-        return l;
+
+        return result;
     }
 
-    // private void translateIllegalStateException(HTException xHT) throws IllegalStateFault {
-    // if (xHT instanceof org.apache.hise.lang.faults.HTIllegalStateException) {
-    // IllegalState state = new IllegalState();
-    //
-    // state.setStatus(translateStatusAPI(((org.apache.hise.lang.faults.HTIllegalStateException)xHT).getExceptionInfo()));
-    // throw new IllegalStateFault(xHT.getMessage(), state, xHT);
-    // }
-    // }
-    //
-    // private void translateIllegalAccessException(HTException xHT) throws IllegalAccessFault {
-    // if (xHT instanceof org.apache.hise.lang.faults.HTIllegalAccessException) {
-    // throw new IllegalAccessFault(xHT.getMessage(), ((org.apache.hise.lang.faults.HTIllegalAccessException)xHT).getExceptionInfo(), xHT);
-    // }
-    // }
-    //
-    // private void translateIllegalOperationException(HTException xHT) throws IllegalOperationFault {
-    // if (xHT instanceof org.apache.hise.lang.faults.HTIllegalOperationException) {
-    // throw new IllegalOperationFault(xHT.getMessage(), ((HTIllegalOperationException) xHT).getExceptionInfo(), xHT);
-    // }
-    // }
-    //
-    // private void translateIllegalArgumentException(HTException xHT) throws IllegalArgumentFault {
-    // if (xHT instanceof org.apache.hise.lang.faults.HTIllegalArgumentException) {
-    // throw new IllegalArgumentFault(xHT.getMessage(), ((org.apache.hise.lang.faults.HTIllegalArgumentException) xHT).getExceptionInfo(), xHT);
-    // }
-    // }
-    //
-    // private void translateRecipientNotAllowedException(HTException xHT) throws RecipientNotAllowed {
-    // if (xHT instanceof org.apache.hise.lang.faults.HTRecipientNotAllowedException) {
-    // throw new RecipientNotAllowed(xHT.getMessage(), ((org.apache.hise.lang.faults.HTRecipientNotAllowedException) xHT).getExceptionInfo(), xHT);
-    // }
-    // }
-    //
-    // private Long translateTaskIdentifier(String identifier) throws HTIllegalArgumentException {
-    // if (null == identifier) {
-    // throw new org.apache.hise.lang.faults.HTIllegalArgumentException("Must specific a Task id.","Id");
-    // }
-    //
-    // try {
-    // return Long.valueOf(identifier);
-    // } catch (NumberFormatException xNF) {
-    // throw new HTIllegalArgumentException("Task identifier must be a number.", "Id: " + identifier);
-    // }
-    // }
-
-    // /**
-    // * Translates a single task to TTask.
-    // *
-    // * @param task The input task object.
-    // * @return The Human Task WebService API task object.
-    // */
-    // private org.apache.hise.lang.xsd.htda.TTask translateOneTaskAPI(Task task) {
-    // org.apache.hise.lang.xsd.htda.TTask ttask = new org.apache.hise.lang.xsd.htda.TTask();
-    //
-    // ttask.setId(Long.toString(task.getId()));
-    // ttask.setTaskType("TASK");
-    // ttask.setName(task.getTaskName());
-    // ttask.setStatus(this.translateStatusAPI(task.getStatus()));
-    // ttask.setCreatedOn(task.getCreatedOn());
-    // /*
-    // ttask.setPriority(task.getPriority());
-    // */
-    // //ttask.setTaskInitiator(task.getCreatedBy());
-    // /*ttask.setTaskStakeholders(task.getTaskStakeholders());
-    // ttask.setPotentialOwners(task.getPotentialOwners());
-    // ttask.setBusinessAdministrators(task.getBusinessAdministrators());
-    // ttask.setActualOwner(task.getActualOwner());
-    // ttask.setNotificationRecipients(task.getNotificationRecipients());
-    // */
-    // ttask.setCreatedBy(task.getCreatedBy().toString());
-    // ttask.setActivationTime(task.getActivationTime());
-    // ttask.setExpirationTime(task.getExpirationTime());
-    // ttask.setIsSkipable(task.isSkippable());
-    // /*ttask.setHasPotentialOwners(task.getHasPotentialOwners());
-    // ttask.setStartByExists(task.getStartByExists());
-    // ttask.setCompleteByExists(task.getCompleteByExists());
-    // ttask.setPresentationName(task.getPresentationName());
-    // ttask.setPresentationSubject(task.getPresentationSubject());
-    // ttask.setRenderingMethodExists(task.getRenderingMethodExists());
-    // ttask.setHasOutput(task.getHasOutput());
-    // */
-    //
-    // //TODO implement cjeck
-    // //ttask.setHasFault(null != task.getFault());
-    // ttask.setHasFault(false);
-    //
-    // ttask.setHasAttachments(!task.getAttachments().isEmpty());
-    // //ttask.setHasComments(!task.getComments().isEmpty());
-    //
-    // ttask.setEscalated(task.isEscalated());
-    // return ttask;
-    // }
-
-    // private List<org.apache.hise.lang.xsd.htda.TTask> translateTaskAPI(List<Task> in) {
-    // List<org.apache.hise.lang.xsd.htda.TTask> result = new ArrayList<org.apache.hise.lang.xsd.htda.TTask>();
-    // for (Task task : in) {
-    // result.add(this.translateOneTaskAPI(task));
-    // }
-    // return result;
-    // }
-
-    // private List<Task.Status> translateStatusAPI(List<TStatus> in) {
-    // List<Task.Status> result = new ArrayList<Task.Status>();
-    // for (TStatus status : in) {
-    // result.add(Task.Status.fromValue(in.toString()));
-    // }
-    //
-    // return result;
-    // }
-
-    // private TStatus translateStatusAPI(Task.Status in) {
-    // return TStatus.fromValue(in.toString());
-    // }
-    
-    private TTask convertTask(Long id) {
-        Task task = Task.load(hiseEngine, id);
-        org.apache.hise.dao.Task u = task.getTaskDto();
+    /**
+     * {@inheritDoc}
+     */
+    public Object getInput(String identifier, String part) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
+        Task t = Task.load(hiseEngine, Long.parseLong(identifier));
+        t.setCurrentUser(getUserString());
+        return t.getInput(part);
+    }
 
-        TTask t = new TTask();
-        t.setId("" + u.getId());
-        t.setTaskType(u.isNotification() ? "NOTIFICATION" : "TASK");
-        t.setCreatedOn(u.getCreatedOn());
-        t.setActivationTime(u.getActivationTime());
-        if (u.getActualOwner() != null) t.setActualOwner(u.getActualOwner());
-        t.setCreatedBy(u.getCreatedBy());
-        t.setPresentationName(task.getTaskEvaluator().getPresentationName());
-        t.setPresentationSubject(task.getTaskEvaluator().evalPresentationSubject());
-        t.setName(u.getTaskDefinitionName());
-        t.setStatus(TStatus.valueOf(u.getStatus().toString()));
-        return t;
+    /**
+     * {@inheritDoc}
+     */
+    public Object getOutput(String identifier, String part) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
+        Task t = Task.load(hiseEngine, Long.parseLong(identifier));
+        t.setCurrentUser(getUserString());
+        return t.getOutput(part);
+    }
+
+    public void stop(String identifier) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
+        Task t = Task.load(hiseEngine, Long.parseLong(identifier));
+        t.setCurrentUser(getUserString());
+        t.stop();
+    }
+
+    public void suspend(String identifier) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
+        Task t = Task.load(hiseEngine, Long.parseLong(identifier));
+        t.setCurrentUser(getUserString());
+        t.suspend();
+    }
+
+    public void suspendUntil(String identifier, TTime time) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
+        Task t = Task.load(hiseEngine, Long.parseLong(identifier));
+        t.setCurrentUser(getUserString());
+        Date when = time.getPointOfTime();
+        if (when == null) {
+            Duration when2 = time.getTimePeriod();
+            when = Calendar.getInstance().getTime();
+            when2.addTo(when);
+        }
+
+        t.suspendUntil(when);
+    }
+
+    public void remove(String identifier) throws IllegalAccessFault, IllegalArgumentFault {
+        Task t = Task.load(hiseEngine, Long.parseLong(identifier));
+        t.setCurrentUser(getUserString());
+        t.remove();
+    }
+
+    public void resume(String identifier) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
+        // OrgEntity user = loadUser();
+        Task t = Task.load(hiseEngine, Long.parseLong(identifier));
+        t.setCurrentUser(getUserString());
+        t.resume();
     }
 
     public org.apache.hise.lang.xsd.htda.TTask getTaskInfo(String identifier) throws IllegalArgumentFault {
         return convertTask(hiseEngine.getHiseDao().find(org.apache.hise.dao.Task.class, Long.parseLong(identifier)).getId());
     }
 
-    public TTaskQueryResultSet query(String selectClause, String whereClause, String orderByClause, Integer maxTasks, Integer taskIndexOffset) throws IllegalArgumentFault, IllegalStateFault {
-        // TODO Auto-generated method stub
-        return null;
+    public void claim(String identifier) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault {
+        Task task = Task.load(hiseEngine, Long.valueOf(identifier));
+        task.setCurrentUser(getUserString());
+        task.claim();
+    }
+
+    public void fail(String identifier, String faultName, Object faultData) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault,
+            IllegalOperationFault {
+        Task t = Task.load(hiseEngine, Long.parseLong(identifier));
+        t.setCurrentUser(getUserString());
+        t.fail();
+    }
+
+    public void forward(String identifier, TOrganizationalEntity organizationalEntity) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
+        Task t = Task.load(hiseEngine, Long.parseLong(identifier));
+        t.setCurrentUser(getUserString());
+        t.forward(organizationalEntity);
+    }
+
+    public String getTaskDescription(String identifier, String contentType) throws IllegalArgumentFault {
+        Task t = Task.load(hiseEngine, Long.parseLong(identifier));
+        t.setCurrentUser(getUserString());
+        return t.getTaskEvaluator().evalPresentationDescription();
     }
 
     public void release(String identifier) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault {
         Task t = Task.load(hiseEngine, Long.parseLong(identifier));
-        t.setCurrentUser(loadUser());
+        t.setCurrentUser(getUserString());
         t.release();
     }
 
     public void start(String identifier) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault {
         Task t = Task.load(hiseEngine, Long.parseLong(identifier));
-        t.setCurrentUser(loadUser());
+        t.setCurrentUser(getUserString());
         t.start();
     }
 
+    public void complete(String identifier, Object taskData) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
+        Task t = Task.load(hiseEngine, Long.parseLong(identifier));
+        t.setCurrentUser(getUserString());
+        t.complete();
+    }
+    
+    // not started
+
+    public TTaskQueryResultSet query(String selectClause, String whereClause, String orderByClause, Integer maxTasks, Integer taskIndexOffset)
+            throws IllegalArgumentFault, IllegalStateFault {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
     public void activate(String identifier) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
         // TODO Auto-generated method stub
 
     }
 
-    public void addAttachment(String identifier, String name, String accessType, Object attachment) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
+    public void addAttachment(String identifier, String name, String accessType, Object attachment) throws IllegalAccessFault, IllegalStateFault,
+            IllegalArgumentFault {
         // TODO Auto-generated method stub
 
     }
@@ -291,14 +263,9 @@ public class TaskOperationsImpl implemen
         // TODO Auto-generated method stub
 
     }
-
-    public void complete(String identifier, Object taskData) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
-        Task t = Task.load(hiseEngine, Long.parseLong(identifier));
-        t.setCurrentUser(loadUser());
-        t.complete();
-    }
-
-    public void delegate(String identifier, TOrganizationalEntity organizationalEntity) throws IllegalAccessFault, IllegalStateFault, RecipientNotAllowed, IllegalArgumentFault {
+    
+    public void delegate(String identifier, TOrganizationalEntity organizationalEntity) throws IllegalAccessFault, IllegalStateFault, RecipientNotAllowed,
+            IllegalArgumentFault {
         // TODO Auto-generated method stub
 
     }
@@ -318,18 +285,6 @@ public class TaskOperationsImpl implemen
 
     }
 
-    public void fail(String identifier, String faultName, Object faultData) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault, IllegalOperationFault {
-        Task t = Task.load(hiseEngine, Long.parseLong(identifier));
-        t.setCurrentUser(loadUser());
-        t.fail();
-    }
-
-    public void forward(String identifier, TOrganizationalEntity organizationalEntity) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
-        Task t = Task.load(hiseEngine, Long.parseLong(identifier));
-        t.setCurrentUser(loadUser());
-        t.forward(organizationalEntity);
-    }
-
     public List<TAttachmentInfo> getAttachmentInfos(String identifier) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
         // TODO Auto-generated method stub
         return null;
@@ -345,27 +300,6 @@ public class TaskOperationsImpl implemen
         return null;
     }
 
-    public void getFault(String identifier, Holder<String> faultName, Holder<Object> faultData) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault, IllegalOperationFault {
-        // TODO Auto-generated method stub
-
-    }
-
-    public Object getInput(String identifier, String part) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
-        Task t = Task.load(hiseEngine, Long.parseLong(identifier));
-        t.setCurrentUser(getUserString());
-        return t.getInput(part);
-    }
-
-    public List<TTaskAbstract> getMyTaskAbstracts(String taskType, String genericHumanRole, String workQueue, List<TStatus> status, String whereClause, String createdOnClause, Integer maxTasks) throws IllegalStateFault, IllegalArgumentFault {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Object getOutput(String identifier, String part) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
     public Object getRendering(Object identifier, QName renderingType) throws IllegalArgumentFault {
         // TODO Auto-generated method stub
         return null;
@@ -376,36 +310,19 @@ public class TaskOperationsImpl implemen
         return null;
     }
 
-    public String getTaskDescription(String identifier, String contentType) throws IllegalArgumentFault {
-        Task t = Task.load(hiseEngine, Long.parseLong(identifier));
-        t.setCurrentUser(getUserString());
-        return t.getTaskEvaluator().evalPresentationDescription();
-    }
-
     public void nominate(String identifier, TOrganizationalEntity organizationalEntity) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
         // TODO Auto-generated method stub
 
     }
 
-    public void remove(String identifier) throws IllegalAccessFault, IllegalArgumentFault {
-        Task t = Task.load(hiseEngine, Long.parseLong(identifier));
-        t.setCurrentUser(getUserString());
-        t.remove();
-    }
-
-    public void resume(String identifier) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
-//        OrgEntity user = loadUser();
-        Task t = Task.load(hiseEngine, Long.parseLong(identifier));
-        t.setCurrentUser(getUserString());
-        t.resume();
-    }
-
-    public void setFault(String identifier, String faultName, Object faultData) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault, IllegalOperationFault {
+    public void setFault(String identifier, String faultName, Object faultData) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault,
+            IllegalOperationFault {
         // TODO Auto-generated method stub
 
     }
 
-    public void setGenericHumanRole(String identifier, String genericHumanRole, TOrganizationalEntity organizationalEntity) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
+    public void setGenericHumanRole(String identifier, String genericHumanRole, TOrganizationalEntity organizationalEntity) throws IllegalAccessFault,
+            IllegalStateFault, IllegalArgumentFault {
         // TODO Auto-generated method stub
 
     }
@@ -424,29 +341,39 @@ public class TaskOperationsImpl implemen
         // TODO Auto-generated method stub
     }
 
-    public void stop(String identifier) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
-        Task t = Task.load(hiseEngine, Long.parseLong(identifier));
-        t.setCurrentUser(getUserString());
-        t.stop();
+    public void getFault(String identifier, Holder<String> faultName, Holder<Object> faultData) throws IllegalArgumentFault, IllegalStateFault,
+            IllegalOperationFault, IllegalAccessFault {
+        // TODO Auto-generated method stub
+
     }
 
-    public void suspend(String identifier) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
-        Task t = Task.load(hiseEngine, Long.parseLong(identifier));
-        t.setCurrentUser(getUserString());
-        t.suspend();
+    public List<TTaskAbstract> getMyTaskAbstracts(String taskType, String genericHumanRole, String workQueue, List<TStatus> status, String whereClause,
+            String createdOnClause, Integer maxTasks) throws IllegalArgumentFault, IllegalStateFault {
+        // TODO Auto-generated method stub
+        return null;
     }
 
-    public void suspendUntil(String identifier, TTime time) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
-        Task t = Task.load(hiseEngine, Long.parseLong(identifier));
-        t.setCurrentUser(getUserString());
-        Date when = time.getPointOfTime();
-        if (when == null) {
-            Duration when2 = time.getTimePeriod();
-            when = Calendar.getInstance().getTime();
-            when2.addTo(when);
+    // Util
+
+    private TTask convertTask(Long id) {
+        Task task = Task.load(hiseEngine, id);
+        org.apache.hise.dao.Task taskDto = task.getTaskDto();
+
+        TTask result = new TTask();
+        result.setId(taskDto.getId().toString());
+        result.setTaskType(taskDto.isNotification() ? "NOTIFICATION" : "TASK");
+        result.setCreatedOn(taskDto.getCreatedOn());
+        result.setActivationTime(taskDto.getActivationTime());
+        if (taskDto.getActualOwner() != null) {
+            result.setActualOwner(taskDto.getActualOwner());
         }
-        
-        t.suspendUntil(when);
+        result.setCreatedBy(taskDto.getCreatedBy());
+        result.setPresentationName(task.getTaskEvaluator().getPresentationName());
+        result.setPresentationSubject(task.getTaskEvaluator().evalPresentationSubject());
+        result.setName(taskDto.getTaskDefinitionName());
+        result.setStatus(TStatus.fromValue(taskDto.getStatus().toString()));
+
+        return result;
     }
 
 }
\ No newline at end of file

Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/Task.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/Task.java?rev=925237&r1=925236&r2=925237&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/Task.java (original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/Task.java Fri Mar 19 14:30:59 2010
@@ -60,6 +60,7 @@ public class Task {
     private HISEEngineImpl hiseEngine;
 
     private org.apache.hise.dao.Task taskDto;
+
     private TaskDefinition taskDefinition;
 
     private TaskEvaluator taskEvaluator;
@@ -95,6 +96,10 @@ public class Task {
         return currentUser;
     }
 
+    /**
+     * TODO throw an exception if current user is not TASK_ADMINISTRATOR
+     * @param currentUser
+     */
     public void setCurrentUser(String currentUser) {
         this.currentUser = currentUser;
     }
@@ -104,8 +109,10 @@ public class Task {
     }
 
     private Task(HISEEngineImpl engine, boolean notification) {
+        
+        Validate.notNull(engine);
+        
         this.hiseEngine = engine;
-        Validate.notNull(hiseEngine);
 
         taskStateListeners = new ArrayList<TaskStateListener>();
         if (!notification) {
@@ -163,30 +170,32 @@ public class Task {
     }
     
     public static Task create(HISEEngineImpl engine, TaskDefinition taskDefinition, String createdBy, Node requestXml, Node requestHeader) {
+
         Task t = new Task(engine, false);
         Validate.notNull(taskDefinition);
         Validate.isTrue(!taskDefinition.isNotification());
+        
         t.taskDefinition = taskDefinition;
-        org.apache.hise.dao.Task u = new org.apache.hise.dao.Task();
-        u.setTaskDefinitionKey(taskDefinition.getTaskName().toString());
-        u.setCreatedBy(createdBy);
-        u.setStatus(null);
-        u.getInput().put("request", new Message("request", DOMUtils.domToString(requestXml)));
-        u.getInput().put("requestHeader", new Message("requestHeader", DOMUtils.domToString(requestHeader)));
-        u.setCreatedOn(new Date());
-        u.setActivationTime(new Date());
-        u.setEscalated(false);
-        u.setNotification(false);
-        engine.getHiseDao().persist(u);
-        t.taskDto = u;
+        org.apache.hise.dao.Task taskDto = new org.apache.hise.dao.Task();
+        taskDto.setTaskDefinitionKey(taskDefinition.getTaskName().toString());
+        taskDto.setCreatedBy(createdBy);
+        taskDto.setStatus(null);
+        taskDto.getInput().put("request", new Message("request", DOMUtils.domToString(requestXml)));
+        taskDto.getInput().put("requestHeader", new Message("requestHeader", DOMUtils.domToString(requestHeader)));
+        taskDto.setCreatedOn(new Date());
+        taskDto.setActivationTime(new Date());
+        taskDto.setEscalated(false);
+        taskDto.setNotification(false);
+        
+        engine.getHiseDao().persist(taskDto);
+        t.taskDto = taskDto;
         t.setStatus(Status.CREATED);
 
-        u.setPeopleAssignments(t.getTaskEvaluator().evaluatePeopleAssignments());
+        taskDto.setPeopleAssignments(t.getTaskEvaluator().evaluatePeopleAssignments());
         
         t.setStatus(Status.READY);
         t.tryNominateOwner();
-        
-        
+
         return t;
 
         // recalculatePresentationParameters();
@@ -1094,14 +1103,6 @@ public class Task {
     // }
 
     
-    public void handleTimer() {
-        
-    }
-    
-    public Date calculateWakeupTime() {
-        return null;
-    }
-    
     public void remove() {
         Validate.isTrue(taskDto.isNotification());
         hiseEngine.getHiseDao().remove(taskDto);
@@ -1110,4 +1111,8 @@ public class Task {
     public Node getInput(String part) {
         return DOMUtils.parse(taskDto.getInput().get(part).getMessage()).getDocumentElement();
     }
+    
+    public Node getOutput(String part) {
+        return DOMUtils.parse(taskDto.getOutput().get(part).getMessage()).getDocumentElement();
+    }
 }

Modified: incubator/hise/trunk/hise-services/src/test/java/org/apache/hise/TaskOperationsTest.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/test/java/org/apache/hise/TaskOperationsTest.java?rev=925237&r1=925236&r2=925237&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/test/java/org/apache/hise/TaskOperationsTest.java (original)
+++ incubator/hise/trunk/hise-services/src/test/java/org/apache/hise/TaskOperationsTest.java Fri Mar 19 14:30:59 2010
@@ -28,7 +28,9 @@ public class TaskOperationsTest {
 
     @Ignore
     public void testGetMyTasks() throws Exception {
+        
         TaskOperationsImpl ti = new MockTaskOperationsImpl();
+        
         HISEEngineImpl he = new HISEEngineImpl();
         he.setHiseUserDetails(new HISEUserDetails() {
             public String getUserPassword(String user) {