Package org.drools.task

Examples of org.drools.task.Content


        long contentId = task1.getTaskData().getDocumentContentId();
        assertTrue( contentId != -1 );

        BlockingGetContentResponseHandler getContentResponseHandler = new BlockingGetContentResponseHandler();
        client.getContent(contentId, getContentResponseHandler);
        Content content = getContentResponseHandler.getContent();
        assertEquals("content", new String(content.getContent()));
    }
View Full Code Here


        long contentId = task1.getTaskData().getDocumentContentId();
        assertTrue( contentId != -1 );

        BlockingGetContentResponseHandler getContentResponseHandler = new BlockingGetContentResponseHandler();
        client.getContent(contentId, getContentResponseHandler);
        Content content = getContentResponseHandler.getContent();
        System.out.println(new String(content.getContent()));
        assertEquals(largeContent, new String(content.getContent()));
    }
View Full Code Here

        long contentId = task2.getTaskData().getOutputContentId();
        assertTrue( contentId != -1 );
       
        BlockingGetContentResponseHandler getContentResponseHandler = new BlockingGetContentResponseHandler();
        client.getContent(contentId, getContentResponseHandler);
        Content content = getContentResponseHandler.getContent();
        assertEquals("content", new String(content.getContent()));
    }
View Full Code Here

        long contentId = task2.getTaskData().getFaultContentId();
        assertTrue( contentId != -1 );
       
        BlockingGetContentResponseHandler getContentResponseHandler = new BlockingGetContentResponseHandler();
        client.getContent(contentId, getContentResponseHandler);
        Content content = getContentResponseHandler.getContent();
        assertEquals("content", new String(content.getContent()));
    }
View Full Code Here

        BlockingAddTaskResponseHandler addTaskResponseHandler = new BlockingAddTaskResponseHandler();
        Task task = ( Task eval( new StringReader( string ), vars );
        client.addTask( task, null, addTaskResponseHandler );
        long taskId = addTaskResponseHandler.getTaskId();   
                                       
        Content content = new Content();
        content.setContent( "['subject' : 'My Subject', 'body' : 'My Body']".getBytes() );
        BlockingSetContentResponseHandler setContentResponseHandler  = new BlockingSetContentResponseHandler();
        client.setDocumentContent( taskId, content, setContentResponseHandler );
        long contentId = setContentResponseHandler.getContentId();
        BlockingGetContentResponseHandler  getResponseHandler = new BlockingGetContentResponseHandler();
        client.getContent( contentId, getResponseHandler );
        content = getResponseHandler.getContent();
        assertEquals( "['subject' : 'My Subject', 'body' : 'My Body']", new String( content.getContent() ) );
       
        // emails should not be set yet
        assertEquals(0, getWiser().getMessages().size() );            
        Thread.sleep( 100 );
       
View Full Code Here

        attachment.setName( "file1.txt" );
        attachment.setAccessType( AccessType.Inline );
        attachment.setContentType( "txt" );
       
        byte[] bytes = "Ths is my attachment text1".getBytes();
        Content content = new Content();
        content.setContent( bytes );
       
        BlockingAddAttachmentResponseHandler addAttachmentResponseHandler = new BlockingAddAttachmentResponseHandler();
        client.addAttachment( taskId, attachment, content, addAttachmentResponseHandler);
        assertTrue( addAttachmentResponseHandler.getAttachmentId() != attachment.getId() );
        assertTrue( addAttachmentResponseHandler.getContentId() != attachment.getAttachmentContentId() );
       
        BlockingGetTaskResponseHandler getTaskResponseHandler = new BlockingGetTaskResponseHandler();
        client.getTask( taskId, getTaskResponseHandler );
        Task task1 = getTaskResponseHandler.getTask();
        assertNotSame(task, task1);
        assertFalsetask.equals( task1) );
      
        List<Attachment> attachments1 = task1.getTaskData().getAttachments();
        assertEquals(1, attachments1.size() );
        Attachment returnedAttachment = attachments1.get( 0 );       
        assertEquals( attachedAt, returnedAttachment.getAttachedAt() );
        assertEquals( users.get( "luke" ), returnedAttachment.getAttachedBy() );
        assertEquals( AccessType.Inline, returnedAttachment.getAccessType() );
        assertEquals( "txt", returnedAttachment.getContentType() );
        assertEquals( "file1.txt", returnedAttachment.getName() );       
        assertEquals( bytes.length, returnedAttachment.getSize() );
       
        assertEquals( (long) addAttachmentResponseHandler.getAttachmentId(), (long) returnedAttachment.getId() );
        assertEquals( (long) addAttachmentResponseHandler.getContentId()(long) returnedAttachment.getAttachmentContentId() );       
       
        // Make the same as the returned tasks, so we can test equals
        task.getTaskData().setAttachments( attachments1 );
        task.getTaskData().setStatus( Status.Created );
        assertEquals(task, task1);           
       
        BlockingGetContentResponseHandler  getResponseHandler = new BlockingGetContentResponseHandler();
        client.getContent( returnedAttachment.getAttachmentContentId(), getResponseHandler );
        content = getResponseHandler.getContent();
        assertEquals( "Ths is my attachment text1", new String( content.getContent() ) );
       
        // test we can have multiple attachments
       
        attachment = new Attachment();
        attachedAt = new Date( System.currentTimeMillis() );
        attachment.setAttachedAt( attachedAt);
        attachment.setAttachedBy( users.get( "tony" ) );
        attachment.setName( "file2.txt" );
        attachment.setAccessType( AccessType.Inline );
        attachment.setContentType( "txt" );
       
        bytes = "Ths is my attachment text2".getBytes();
        content = new Content();
        content.setContent( bytes );
       
        addAttachmentResponseHandler = new BlockingAddAttachmentResponseHandler();
        client.addAttachment( taskId, attachment, content, addAttachmentResponseHandler);  
       
        getTaskResponseHandler = new BlockingGetTaskResponseHandler();
        client.getTask( taskId, getTaskResponseHandler );
        task1 = getTaskResponseHandler.getTask();
        assertNotSame(task, task1);
        assertFalsetask.equals( task1) );
      
        List<Attachment> attachments2 = task1.getTaskData().getAttachments();
        assertEquals(2, attachments2.size() );
       
        getResponseHandler = new BlockingGetContentResponseHandler();
        client.getContent( addAttachmentResponseHandler.getContentId(), getResponseHandler );
        content = getResponseHandler.getContent();
        assertEquals( "Ths is my attachment text2", new String( content.getContent() ) );       
       
        // make two collections the same and compare
        attachment.setSize( 26 );
        attachment.setAttachmentContentId( addAttachmentResponseHandler.getContentId() );
        attachments1.add( attachment );
View Full Code Here

        }
       
        em.getTransaction().begin();
        em.persist( task );
        if (contentData != null) {
          Content content = new Content();
          content.setContent(contentData.getContent());
          em.persist( content );
            taskData.setDocumentAccessType( contentData.getAccessType() );
            taskData.setDocumentType( contentData.getType() );
            taskData.setDocumentContentId( content.getId() );
        }
        em.getTransaction().commit();

        long now = System.currentTimeMillis();
        // schedule after it's been persisted, otherwise the id's won't be assigned
View Full Code Here

               
                case Complete : {
                  // set output data
                  if (data != null) {
                    TaskData taskData = task.getTaskData();
                    Content content = new Content();
                    content.setContent( data.getContent() );
                    em.persist( content );
                    taskData.setOutputContentId( content.getId() );
                    taskData.setOutputAccessType( data.getAccessType() );
                    taskData.setOutputType( data.getType() );
                  }

                  // trigger event support
                    service.getEventSupport().fireTaskCompleted( task.getId(),
                                                                 task.getTaskData().getActualOwner().getId() );
                    checkSubTaskStrategy(task);
                    break;
                }
               
                case Fail : {
                  // set fault data
                  if (data != null) {
                    TaskData taskData = task.getTaskData();
                    Content content = new Content();
                    content.setContent( data.getContent() );
                    em.persist( content );
                    taskData.setFaultContentId( content.getId() );
                    taskData.setFaultAccessType( data.getAccessType() );
                    taskData.setFaultType( data.getType() );
                    taskData.setFaultName( ((FaultData) data).getFaultName() );
                  }
View Full Code Here

        em.getTransaction().commit();
    }

    public Content getContent(long contentId) {
        Content content = em.find( Content.class,
                                   contentId );
        return content;
    }
View Full Code Here

                    break;
                }
                case AddAttachmentRequest : {
                    response = CommandName.AddAttachmentResponse;
                    Attachment attachment = (Attachment) cmd.getArguments().get( 1 );
                    Content content = (Content) cmd.getArguments().get( 2 );
                    taskSession.addAttachment( (Long) cmd.getArguments().get( 0 ),
                                               attachment,
                                               content );

                    List args = new ArrayList( 2 );
                    args.add( attachment.getId() );
                    args.add( content.getId() );
                    Command resultsCmnd = new Command( cmd.getId(),
                                                       CommandName.AddAttachmentResponse,
                                                       args );
                    session.write( resultsCmnd );
                    break;
                }
                case DeleteAttachmentRequest : {
                    response = CommandName.DeleteAttachmentResponse;
                    long taskId = (Long) cmd.getArguments().get( 0 );
                    long attachmentId = (Long) cmd.getArguments().get( 1 );
                    long contentId = (Long) cmd.getArguments().get( 2 );
                    taskSession.deleteAttachment( taskId,
                                                  attachmentId,
                                                  contentId );
                    Command resultsCmnd = new Command( cmd.getId(),
                                                       CommandName.DeleteAttachmentResponse,
                                                       Collections.emptyList() );
                    session.write( resultsCmnd );
                    break;
                }
                case SetDocumentContentRequest : {
                    response = CommandName.SetDocumentContentResponse;
                    long taskId = (Long) cmd.getArguments().get( 0 );
                    Content content = (Content) cmd.getArguments().get( 1 );
                    taskSession.setDocumentContent( taskId,
                                                    content );

                    List args = new ArrayList( 1 );
                    args.add( content.getId() );
                    Command resultsCmnd = new Command( cmd.getId(),
                                                       CommandName.SetDocumentContentResponse,
                                                       args );
                    session.write( resultsCmnd );
                    break;
                }
                case GetContentRequest : {
                    response = CommandName.GetContentResponse;
                    long contentId = (Long) cmd.getArguments().get( 0 );
                    Content content = taskSession.getContent( contentId );
                    List args = new ArrayList( 1 );
                    args.add( content );
                    Command resultsCmnd = new Command( cmd.getId(),
                                                       CommandName.GetContentResponse,
                                                       args );
View Full Code Here

TOP

Related Classes of org.drools.task.Content

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.