Package org.drools.task

Examples of org.drools.task.Attachment


                    session.write(resultsCmnd);
                    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);
View Full Code Here


   
    public static List<Attachment> readAttachmentList(ObjectInput in) throws IOException, ClassNotFoundException  {
        int size = in.readInt();
        List<Attachment> list = new ArrayList<Attachment>(size);
        for ( int i = 0; i < size; i++ ) {
            Attachment item = new Attachment();
            item.readExternal( in );
            list.add( item );
        }
        return list;
    }     
View Full Code Here

        Task task = ( Task eval( new StringReader( str ), vars );
        client.addTask( task, null, addTaskResponseHandler );
       
        long taskId = addTaskResponseHandler.getTaskId();
       
        Attachment attachment = new Attachment();
        Date attachedAt = new Date( System.currentTimeMillis() );
        attachment.setAttachedAt( attachedAt);
        attachment.setAttachedBy( users.get( "luke" ) );
        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 );
View Full Code Here

        Task task = ( Task eval( new StringReader( str ), vars );
        client.addTask( task, null, addTaskResponseHandler );
       
        long taskId = addTaskResponseHandler.getTaskId();
       
        Attachment attachment = new Attachment();
        Date attachedAt = new Date( System.currentTimeMillis() );
        attachment.setAttachedAt( attachedAt);
        attachment.setAttachedBy( users.get( "luke" ) );
        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 );
View Full Code Here

        Task task = em.find( Task.class,
                             taskId );

        em.getTransaction().begin();
        for ( Iterator<Attachment> it = task.getTaskData().getAttachments().iterator(); it.hasNext(); ) {
            Attachment attachment = it.next();
            if ( attachment.getId() == attachmentId ) {
                it.remove();
                em.remove( attachment ); // need to do this otherwise it just removes the link id, without removing the attachment
                break;
            }
        }
View Full Code Here

                    session.write( resultsCmnd );
                    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 );
View Full Code Here

                    session.write(resultsCmnd);
                    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);
View Full Code Here

   
    public static List<Attachment> readAttachmentList(ObjectInput in) throws IOException, ClassNotFoundException  {
        int size = in.readInt();
        List<Attachment> list = new ArrayList<Attachment>(size);
        for ( int i = 0; i < size; i++ ) {
            Attachment item = new Attachment();
            item.readExternal( in );
            list.add( item );
        }
        return list;
    }     
View Full Code Here

        Task task = ( Task eval( new StringReader( str ), vars );
        client.addTask( task, null, addTaskResponseHandler );
       
        long taskId = addTaskResponseHandler.getTaskId();
       
        Attachment attachment = new Attachment();
        Date attachedAt = new Date( System.currentTimeMillis() );
        attachment.setAttachedAt( attachedAt);
        attachment.setAttachedBy( users.get( "luke" ) );
        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 );
View Full Code Here

        Task task = ( Task eval( new StringReader( str ), vars );
        client.addTask( task, null, addTaskResponseHandler );
       
        long taskId = addTaskResponseHandler.getTaskId();
       
        Attachment attachment = new Attachment();
        Date attachedAt = new Date( System.currentTimeMillis() );
        attachment.setAttachedAt( attachedAt);
        attachment.setAttachedBy( users.get( "luke" ) );
        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 );
View Full Code Here

TOP

Related Classes of org.drools.task.Attachment

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.