use of org.jbpm.persistence.scripts.oldentities.TaskImpl in project jbpm by kiegroup.
the class TestPersistenceContext method createSomeTask.
public void createSomeTask() {
testIsInitialized();
TaskImpl task = new TaskImpl();
InternalI18NText name = (InternalI18NText) TaskModelProvider.getFactory().newI18NText();
name.setText("Some Task");
List<I18NText> names = new ArrayList<I18NText>();
names.add(name);
task.setNames(names);
InternalTaskData taskData = (InternalTaskData) TaskModelProvider.getFactory().newTaskData();
taskData.setWorkItemId(12);
taskData.setProcessInstanceId(1);
taskData.setProcessId("someprocess");
taskData.setDeploymentId("org.jbpm.test:someprocess:1.0");
taskData.setProcessSessionId(1);
task.setTaskData(taskData);
InternalPeopleAssignments peopleAssignments = (InternalPeopleAssignments) TaskModelProvider.getFactory().newPeopleAssignments();
peopleAssignments.setPotentialOwners(new ArrayList<OrganizationalEntity>());
peopleAssignments.setBusinessAdministrators(new ArrayList<OrganizationalEntity>());
peopleAssignments.setExcludedOwners(new ArrayList<OrganizationalEntity>());
peopleAssignments.setRecipients(new ArrayList<OrganizationalEntity>());
peopleAssignments.setTaskStakeholders(new ArrayList<OrganizationalEntity>());
InternalOrganizationalEntity jdoe = (InternalOrganizationalEntity) TaskModelProvider.getFactory().newUser();
jdoe.setId("jdoe");
peopleAssignments.getPotentialOwners().add(jdoe);
peopleAssignments.getBusinessAdministrators().add(jdoe);
task.setPeopleAssignments(peopleAssignments);
final boolean txOwner = transactionManager.begin();
try {
EntityManager em = entityManagerFactory.createEntityManager();
em.persist(jdoe);
em.persist(task);
transactionManager.commit(txOwner);
} catch (Exception ex) {
ex.printStackTrace();
transactionManager.rollback(txOwner);
throw new RuntimeException(ex.getMessage(), ex);
}
}
Aggregations