incubator-hise-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wi...@apache.org
Subject svn commit: r963708 - in /incubator/hise/trunk/hise-services/src/main/java/org/apache/hise: engine/jaxws/TaskOperationsImpl.java runtime/TaskLifecycle.java
Date Tue, 13 Jul 2010 13:27:24 GMT
Author: witek
Date: Tue Jul 13 13:27:24 2010
New Revision: 963708

URL: http://svn.apache.org/viewvc?rev=963708&view=rev
Log:
HISE-46 addComment and getComments implemented. Thanks to Pawel Byszewski.

Modified:
    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/TaskLifecycle.java

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=963708&r1=963707&r2=963708&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
Tue Jul 13 13:27:24 2010
@@ -23,6 +23,7 @@ import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
+import java.util.Iterator;
 import java.util.List;
 
 import javax.jws.WebService;
@@ -33,7 +34,11 @@ import javax.xml.ws.WebServiceContext;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hise.dao.Attachment;
+import org.apache.hise.dao.Comment;
 import org.apache.hise.dao.GenericHumanRole;
+import org.apache.hise.dao.Task.Status;
+import org.apache.hise.dao.TaskOrgEntity;
 import org.apache.hise.dao.TaskQuery;
 import org.apache.hise.engine.HISEEngineImpl;
 
@@ -299,7 +304,41 @@ public class TaskOperationsImpl implemen
         t.setCurrentUser(getUserString());
         t.setOutput(((Node) taskData).getFirstChild());
     }
-    
+
+	/**
+	 * Adds comment to a task. Can be performed by: 
+	 * - potential owners 
+	 * - actual owner 
+	 * - business administrators
+	 * 
+	 * @param identifier task's identifier
+	 * @param text comment to add
+	 */
+	public void addComment(String identifier, String text) throws IllegalAccessFault, IllegalStateFault,
IllegalArgumentFault {
+		Task task = Task.load(hiseEngine, new Long(identifier));
+		org.apache.hise.dao.Task taskDto = task.getTaskDto();
+		org.apache.hise.dao.Comment newComment = new Comment(text, taskDto);
+		// PTODO add setAddedBy
+		taskDto.getComments().add(newComment);
+
+	}
+
+	/**
+	 * Gets all comments of a task.
+	 * Can be performed by:
+	 *  - potential owners
+	 *  - actual owner
+	 *  - business administrators
+	 *  
+	 *  @param identifier task's identifier
+	 */
+    public List<TComment> getComments(String identifier) throws IllegalAccessFault,
IllegalStateFault, IllegalArgumentFault {
+        Task task = Task.load(hiseEngine, new Long(identifier));
+        org.apache.hise.dao.Task taskDto = task.getTaskDto();
+        List<TComment> result = convertComments(taskDto);
+        return result;
+    }
+
     // not started
 
     public TTaskQueryResultSet query(String selectClause, String whereClause, String orderByClause,
Integer maxTasks, Integer taskIndexOffset)
@@ -313,25 +352,48 @@ public class TaskOperationsImpl implemen
 
     }
 
-    public void addAttachment(String identifier, String name, String accessType, Object attachment)
throws IllegalAccessFault, IllegalStateFault,
+    public void addAttachment(String identifier, String attachmentName, String accessType,
Object attachment) throws IllegalAccessFault, IllegalStateFault,
             IllegalArgumentFault {
-        // TODO Auto-generated method stub
+        Task task = Task.load(hiseEngine, new Long(identifier));
+        org.apache.hise.dao.Task taskDto = task.getTaskDto();
+        org.apache.hise.dao.Attachment newAttachment= new Attachment();
+        newAttachment.setAccessType(accessType);
+        newAttachment.setName(attachmentName);
+        newAttachment.setAttachedAt(new Date());
+        newAttachment.setTask(taskDto);
+       // newAttachment.setUserName(context.getUserPrincipal().)
+       //String at=attachment.;
+       //String jeden=at;
+        
+        taskDto.getAttachments().add(newAttachment);
 
     }
 
-    public void addComment(String identifier, String text) throws IllegalAccessFault, IllegalStateFault,
IllegalArgumentFault {
-        // TODO Auto-generated method stub
-
-    }
-    
     public void delegate(String identifier, TOrganizationalEntity organizationalEntity) throws
IllegalAccessFault, IllegalStateFault, RecipientNotAllowed,
             IllegalArgumentFault {
-        // TODO Auto-generated method stub
+
 
     }
 
     public void deleteAttachments(String identifier, String attachmentName) throws IllegalAccessFault,
IllegalStateFault, IllegalArgumentFault {
-        // TODO Auto-generated method stub
+        Task task = Task.load(hiseEngine, new Long(identifier));
+        org.apache.hise.dao.Task taskDto = task.getTaskDto();
+        List<Attachment> attachments=taskDto.getAttachments();
+        Iterator<Attachment> attachemntIterator=attachments.iterator();
+        Attachment attachment;
+        while(attachemntIterator.hasNext()){
+        	attachment=attachemntIterator.next();
+        	if(attachment.getName().equals(attachmentName)){
+        		hiseEngine.getHiseDao().remove(attachment);
+        		attachemntIterator.remove();
+        	}
+        }
+//        TODO Attachments provided by
+//        the enclosing context are
+//        not affected by this
+//        operation.
+
+        
 
     }
 
@@ -346,18 +408,37 @@ public class TaskOperationsImpl implemen
     }
 
     public List<TAttachmentInfo> getAttachmentInfos(String identifier) throws IllegalAccessFault,
IllegalStateFault, IllegalArgumentFault {
-        // TODO Auto-generated method stub
-        return null;
+        Task task = Task.load(hiseEngine, new Long(identifier));
+        org.apache.hise.dao.Task taskDto = task.getTaskDto();
+        List<Attachment> attachments=taskDto.getAttachments();
+        List<TAttachmentInfo> result= new ArrayList<TAttachmentInfo>();
+        for(Attachment a: attachments){
+        	TAttachmentInfo info=new TAttachmentInfo();
+        	info.withName(a.getName()).withAttachedAt(a.getAttachedAt()).withAccessType(a.getAccessType());
+        	//TODO
+        		//info.withAttachedBy("A").withContentType(a.getContentType());
+        	result.add(info);
+        }
+        return result;
     }
 
     public List<TAttachment> getAttachments(String identifier, String attachmentName)
throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public List<TComment> getComments(String identifier) throws IllegalAccessFault,
IllegalStateFault, IllegalArgumentFault {
-        // TODO Auto-generated method stub
-        return null;
+        Task task = Task.load(hiseEngine, new Long(identifier));
+        org.apache.hise.dao.Task taskDto = task.getTaskDto();
+        List<Attachment> attachments=taskDto.getAttachments();
+        List<TAttachment> result= new ArrayList<TAttachment>();
+        for(Attachment a: attachments){
+        	if(a.getName().equals(attachmentName)){
+        	TAttachment ta=new TAttachment();
+        	TAttachmentInfo info=new TAttachmentInfo();
+        	info.withName(a.getName()).withAttachedAt(a.getAttachedAt()).withAccessType(a.getAccessType());
+        	//TODO
+        		//info.withAttachedBy("A").withContentType(a.getContentType());
+        	ta.withAttachmentInfo(info).withValue(a.getAttachment());
+        	result.add(ta);
+        	}
+        }
+        return result;
     }
 
     public Object getRendering(Object identifier, QName renderingType) throws IllegalArgumentFault
{
@@ -388,12 +469,26 @@ public class TaskOperationsImpl implemen
     }
 
     public void setPriority(String identifier, BigInteger priority) throws IllegalAccessFault,
IllegalStateFault, IllegalArgumentFault {
-        // TODO Auto-generated method stub
+        Task task = Task.load(hiseEngine, new Long(identifier));
+        org.apache.hise.dao.Task taskDto = task.getTaskDto();
+        taskDto.setPriority(priority.intValue());
+        
 
     }
 
-    public void skip(String identifier) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault,
IllegalOperationFault {
-        // TODO Auto-generated method stub
+    public void skip(String identifier) throws 
+    			IllegalAccessFault, IllegalStateFault, IllegalArgumentFault, 
+    				IllegalOperationFault {
+        Task task = Task.load(hiseEngine, new Long(identifier));
+        org.apache.hise.dao.Task taskDto = task.getTaskDto();
+        if(taskDto.isSkippable()){
+        try {
+			task.setStatus(Status.OBSOLETE);
+		} catch (HiseIllegalStateException e) {
+			 throw new IllegalStateFault("Task is not skipable");	
+		}
+        }
+        
     }
 
     public void getFault(String identifier, Holder<String> faultName, Holder<Object>
faultData) throws IllegalArgumentFault, IllegalStateFault,
@@ -408,8 +503,9 @@ public class TaskOperationsImpl implemen
         return null;
     }
 
-    // Util
-
+    /**
+     * TODO extract converters to external class
+     */
     private TTask convertTask(Long id) {
         Task task = Task.load(hiseEngine, id);
         org.apache.hise.dao.Task taskDto = task.getTaskDto();
@@ -427,10 +523,47 @@ public class TaskOperationsImpl implemen
 
         if (taskDto.getActualOwner() != null) {
             result.setActualOwner(taskDto.getActualOwner());
+        	//result.setActualOwner(new String("ja"));
         }
+        //DEBUG   
+//                TOrganizationalEntity TorgEntity =new TOrganizationalEntity();
+//                if(null!=taskDto.getBusinessAdministrators())
+//                for(TaskOrgEntity e: taskDto.getBusinessAdministrators()){
+//                		TorgEntity.getUsers().getUser().add(e.getName());
+//                }
+        //result.setBusinessAdministrators(TorgEntity);
+             
+        result.setPriority(new BigInteger(new Integer(taskDto.getPriority()).toString()));
+        result.setIsSkipable(taskDto.isSkippable());
+        //////////////
 
         return result;
     }
+    
+    /**
+     * TODO extract converters to external class
+     * @param taskDto
+     * @return
+     */
+	private List<TComment> convertComments(org.apache.hise.dao.Task taskDto) {
+	    List<Comment> comments = taskDto.getComments();
+        List<TComment> result = new ArrayList<TComment>();
+        for(Comment comment : comments){
+         	result.add(convertComment(comment));
+        }
+	    return result;
+    }
+
+	/**
+	 * TODO set addedBy
+	 * @param comment
+	 * @return
+	 */
+	private TComment convertComment(Comment comment) {
+	    TComment tComment=new TComment();
+	    tComment.withText(comment.getContent()).withAddedAt(comment.getDate()).withAddedBy("Unknown");
+	    return tComment;
+    }
 
     /**
      * IoC setter.

Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/TaskLifecycle.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/TaskLifecycle.java?rev=963708&r1=963707&r2=963708&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/TaskLifecycle.java
(original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/TaskLifecycle.java
Tue Jul 13 13:27:24 2010
@@ -45,28 +45,28 @@ public class TaskLifecycle implements Ta
             switch (oldStatus) {
 
             case CREATED:
-                if (newStatus == Status.READY || newStatus == Status.RESERVED) {
+                if (newStatus == Status.READY || newStatus == Status.RESERVED || newStatus
== Status.OBSOLETE) {
                     isOk = true;
                 }
 
                 break;
 
             case READY:
-                if (newStatus == Status.RESERVED || newStatus == Status.IN_PROGRESS || newStatus
== Status.READY || newStatus == Status.SUSPENDED) {
+                if (newStatus == Status.RESERVED || newStatus == Status.IN_PROGRESS || newStatus
== Status.READY || newStatus == Status.SUSPENDED || newStatus == Status.OBSOLETE) {
                     isOk = true;
                 }
 
                 break;
 
             case RESERVED:
-                if (newStatus == Status.IN_PROGRESS || newStatus == Status.READY || newStatus
== Status.SUSPENDED || newStatus == Status.RESERVED) {
+                if (newStatus == Status.IN_PROGRESS || newStatus == Status.READY || newStatus
== Status.SUSPENDED || newStatus == Status.RESERVED || newStatus == Status.OBSOLETE) {
                     isOk = true;
                 }
 
                 break;
 
             case IN_PROGRESS:
-                if (newStatus == Status.COMPLETED || newStatus == Status.FAILED || newStatus
== Status.RESERVED || newStatus == Status.READY || newStatus == Status.SUSPENDED) {
+                if (newStatus == Status.COMPLETED || newStatus == Status.FAILED || newStatus
== Status.RESERVED || newStatus == Status.READY || newStatus == Status.SUSPENDED  || newStatus
== Status.OBSOLETE) {
                     isOk = true;
                 }
 
@@ -76,6 +76,11 @@ public class TaskLifecycle implements Ta
                 if (newStatus == task.getTaskDto().getStatusBeforeSuspend()) {
                     isOk = true;
                 }
+                
+            case OBSOLETE:
+              
+                    isOk = true;
+                
 
                 break;
 



Mime
View raw message