Java Code Examples for org.drools.core.process.instance.impl.WorkItemImpl#setId()
The following examples show how to use
org.drools.core.process.instance.impl.WorkItemImpl#setId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProtobufProcessMarshaller.java From kogito-runtimes with Apache License 2.0 | 6 votes |
public static WorkItem readWorkItem(MarshallerReaderContext context, JBPMMessages.WorkItem _workItem, boolean includeVariables) throws IOException { WorkItemImpl workItem = new WorkItemImpl(); workItem.setId( _workItem.getId() ); workItem.setProcessInstanceId( _workItem.getProcessInstancesId() ); workItem.setName( _workItem.getName() ); workItem.setState( _workItem.getState() ); workItem.setDeploymentId(_workItem.getDeploymentId()); workItem.setNodeId(_workItem.getNodeId()); workItem.setNodeInstanceId(_workItem.getNodeInstanceId()); if ( includeVariables ) { for ( JBPMMessages.Variable _variable : _workItem.getVariableList() ) { try { Object value = unmarshallVariableValue( context, _variable ); workItem.setParameter( _variable.getName(), value ); } catch ( ClassNotFoundException e ) { throw new IllegalArgumentException( "Could not reload parameter " + _variable.getName() + " for work item " + _workItem ); } } } return workItem; }
Example 2
Source File: FTPUploadWorkItemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test public void testFTPUploadInvalidParams() throws Exception { TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); workItem.setId(123L); FTPUploadWorkItemHandler handler = new FTPUploadWorkItemHandler(); handler.setLogThrownException(true); handler.setFTPClient(client); handler.setConnection(connection); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(0, manager.getResults().size()); }
Example 3
Source File: AbstractProtobufProcessInstanceMarshaller.java From kogito-runtimes with Apache License 2.0 | 5 votes |
public static WorkItem readWorkItem(MarshallerReaderContext context, JBPMMessages.WorkItem _workItem) throws IOException { WorkItemImpl workItem = new WorkItemImpl(); workItem.setId( _workItem.getId() ); workItem.setProcessInstanceId( _workItem.getProcessInstancesId() ); workItem.setName( _workItem.getName() ); workItem.setState( _workItem.getState() ); workItem.setDeploymentId(_workItem.getDeploymentId()); workItem.setNodeId(_workItem.getNodeId()); workItem.setNodeInstanceId(_workItem.getNodeInstanceId()); workItem.setPhaseId(_workItem.getPhaseId()); workItem.setPhaseStatus(_workItem.getPhaseStatus()); workItem.setStartDate(new Date(_workItem.getStartDate())); if (_workItem.getCompleteDate() > 0) { workItem.setCompleteDate(new Date(_workItem.getCompleteDate())); } for ( JBPMMessages.Variable _variable : _workItem.getVariableList() ) { try { Object value = ProtobufProcessMarshaller.unmarshallVariableValue( context, _variable ); workItem.setParameter( _variable.getName(), value ); } catch ( ClassNotFoundException e ) { throw new IllegalArgumentException(e); } } return workItem; }
Example 4
Source File: ArchiveWorkitemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 5 votes |
@Test public void testWithTempFile() throws Exception { TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); workItem.setId(123L); File tempFile = tempFolder.newFile("tempFile1.txt"); FileUtils.writeStringToFile(tempFile, "temp file content", "UTF-8"); File tempFileTwo = tempFolder.newFile("tempFile2.txt"); FileUtils.writeStringToFile(tempFileTwo, "temp file2 content", "UTF-8"); List<java.io.File> filesList = new ArrayList<>(); filesList.add(tempFile); filesList.add(tempFileTwo); workItem.setParameter("Archive", "testfile.txt"); workItem.setParameter("Files", filesList); ArchiveWorkItemHandler archiveWorkItemHandler = new ArchiveWorkItemHandler(); archiveWorkItemHandler.setLogThrownException(true); archiveWorkItemHandler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(1, manager.getResults().size()); assertTrue(manager.getResults().containsKey(workItem.getId())); }
Example 5
Source File: InputMarshaller.java From kogito-runtimes with Apache License 2.0 | 4 votes |
public static WorkItem readWorkItem( MarshallerReaderContext context ) throws IOException { ObjectInputStream stream = context.stream; WorkItemImpl workItem = new WorkItemImpl(); workItem.setId( stream.readUTF() ); workItem.setProcessInstanceId( stream.readUTF() ); workItem.setName( stream.readUTF() ); workItem.setState( stream.readInt() ); //WorkItem Paramaters int nbVariables = stream.readInt(); if (nbVariables > 0) { for (int i = 0; i < nbVariables; i++) { String name = stream.readUTF(); try { int index = stream.readInt(); ObjectMarshallingStrategy strategy = null; // Old way of retrieving strategy objects if (index >= 0) { strategy = context.resolverStrategyFactory.getStrategy( index ); if (strategy == null) { throw new IllegalStateException( "No strategy of with index " + index + " available." ); } } // New way else if (index == -2) { String strategyClassName = stream.readUTF(); // fix for backwards compatibility (5.x -> 6.x) if ("org.drools.marshalling.impl.SerializablePlaceholderResolverStrategy".equals(strategyClassName)) { strategyClassName = "org.drools.core.marshalling.impl.SerializablePlaceholderResolverStrategy"; } strategy = context.resolverStrategyFactory.getStrategyObject( strategyClassName ); if (strategy == null) { throw new IllegalStateException( "No strategy of type " + strategyClassName + " available." ); } } else { throw new IllegalStateException( "Wrong index of strategy field read: " + index + "!"); } Object value = strategy.read( stream ); workItem.setParameter( name, value ); } catch (ClassNotFoundException e) { throw new IllegalArgumentException( "Could not reload variable " + name ); } } } return workItem; }
Example 6
Source File: FTPUploadWorkItemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 4 votes |
@Test public void testFTPUpload() throws Exception { doNothing().when(client).connect("abc", 123); when(client.getReplyCode()).thenReturn(200); when(client.login(anyString(), anyString())).thenReturn(true); when(client.setFileType(anyInt())).thenReturn(true); when(client.storeFile(anyString(), anyObject())).thenReturn(true); when(client.logout()).thenReturn(true); when(connection.getHost()).thenReturn("abc"); when(connection.getPort()).thenReturn("123"); File tempFile = tempFolder.newFile("tempFile1.txt"); FileUtils.writeStringToFile(tempFile, "temp file content", "UTF-8"); TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); workItem.setId(123L); workItem.setParameter("File", tempFile); workItem.setParameter("User", "someuser"); workItem.setParameter("Password", "somepassword"); FTPUploadWorkItemHandler handler = new FTPUploadWorkItemHandler(); handler.setLogThrownException(true); handler.setFTPClient(client); handler.setConnection(connection); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(1, manager.getResults().size()); assertTrue(manager.getResults().containsKey(workItem.getId())); }