use of org.kie.api.task.model.I18NText in project jbpm by kiegroup.
the class AbstractTaskSerializationTest method jaxbI18NTextTest.
@Test
public void jaxbI18NTextTest() throws Exception {
Assume.assumeFalse(getType().equals(TestType.YAML));
I18NTextImpl textImpl = new I18NTextImpl();
textImpl.setId(1605l);
textImpl.setLanguage("es-ES");
textImpl.setText("Quixote");
JaxbI18NText jaxbText = new JaxbI18NText(textImpl);
assertEquals("id", textImpl.getId(), jaxbText.getId());
assertEquals("language", textImpl.getLanguage(), jaxbText.getLanguage());
assertEquals("text", textImpl.getText(), jaxbText.getText());
JaxbI18NText copyJaxbText = testRoundTrip(jaxbText);
Assertions.assertThat(jaxbText).isEqualToComparingFieldByFieldRecursively(copyJaxbText);
List<I18NText> intList = new ArrayList<I18NText>();
intList.add(textImpl);
List<JaxbI18NText> jaxbList = JaxbI18NText.convertListFromInterfaceToJaxbImpl(intList, I18NText.class, JaxbI18NText.class);
jaxbText = jaxbList.get(0);
assertEquals("id", textImpl.getId(), jaxbText.getId());
assertEquals("language", textImpl.getLanguage(), jaxbText.getLanguage());
assertEquals("text", textImpl.getText(), jaxbText.getText());
intList = JaxbI18NText.convertListFromJaxbImplToInterface(jaxbList);
I18NText text = intList.get(0);
assertEquals("id", text.getId(), jaxbText.getId());
assertEquals("language", text.getLanguage(), jaxbText.getLanguage());
assertEquals("text", text.getText(), jaxbText.getText());
}
use of org.kie.api.task.model.I18NText in project jbpm by kiegroup.
the class TaskQueryServiceBaseTest method testModifyTaskName.
@Test
public void testModifyTaskName() {
// JBPM-4148
String taskName = "This is my task name";
String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet') ],businessAdministrators = [ new User('Administrator') ], }),";
str += "name = '" + taskName + "' })";
Task task = TaskFactory.evalTask(new StringReader(str));
List<I18NText> names = new ArrayList<I18NText>();
I18NText text = TaskModelProvider.getFactory().newI18NText();
((InternalI18NText) text).setLanguage("en-UK");
((InternalI18NText) text).setText(taskName);
names.add(text);
((InternalTask) task).setNames(names);
taskService.addTask(task, new HashMap<String, Object>());
List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("Bobba Fet", "en-UK");
assertEquals(1, tasks.size());
assertEquals(taskName, tasks.get(0).getName());
Task newTask = taskService.getTaskById(tasks.get(0).getId());
List<I18NText> updatedNames = new ArrayList<I18NText>();
I18NText updatedName = TaskModelProvider.getFactory().newI18NText();
((InternalI18NText) updatedName).setLanguage(newTask.getNames().get(0).getLanguage());
((InternalI18NText) updatedName).setText("New task name");
updatedNames.add(updatedName);
taskService.setTaskNames(newTask.getId(), updatedNames);
List<TaskSummary> newTasks = taskService.getTasksAssignedAsPotentialOwner("Bobba Fet", "en-UK");
assertEquals(1, newTasks.size());
newTask = taskService.getTaskById(newTasks.get(0).getId());
assertEquals("New task name", newTask.getNames().get(0).getText());
}
use of org.kie.api.task.model.I18NText in project jbpm by kiegroup.
the class TaskInstanceServiceImpl method setTaskNames.
public void setTaskNames(long taskId, List<I18NText> inputTaskNames) {
Task task = persistenceContext.findTask(taskId);
taskEventSupport.fireBeforeTaskUpdated(task, context);
List<I18NText> taskNames = new ArrayList<I18NText>(inputTaskNames.size());
for (I18NText inputText : inputTaskNames) {
I18NText text = TaskModelProvider.getFactory().newI18NText();
((InternalI18NText) text).setLanguage(inputText.getLanguage());
((InternalI18NText) text).setText(inputText.getText());
taskNames.add(text);
}
((InternalTask) task).setNames(taskNames);
((InternalTask) task).setName(taskNames.get(0).getText());
taskEventSupport.fireAfterTaskUpdated(task, context);
}
use of org.kie.api.task.model.I18NText in project jbpm by kiegroup.
the class SetTaskPropertyCommand method execute.
public Void execute(Context cntxt) {
TaskContext context = (TaskContext) cntxt;
TaskInstanceService service = context.getTaskInstanceService();
switch(property) {
case FAULT_PROPERTY:
doCallbackUserOperation(userId, context, true);
service.setFault(taskId, userId, faultData);
break;
case OUTPUT_PROPERTY:
doCallbackUserOperation(userId, context, true);
service.setOutput(taskId, userId, output);
break;
case PRIORITY_PROPERTY:
service.setPriority(taskId, priority);
break;
case TASK_NAMES_PROPERTY:
List<I18NText> names = null;
if (namesOrDescriptions != null) {
names = JaxbI18NText.convertListFromJaxbImplToInterface(namesOrDescriptions);
}
service.setTaskNames(taskId, names);
break;
case EXPIRATION_DATE_PROPERTY:
service.setExpirationDate(taskId, expirationDate);
break;
case DESCRIPTION_PROPERTY:
List<I18NText> descriptions = null;
if (namesOrDescriptions != null) {
descriptions = JaxbI18NText.convertListFromJaxbImplToInterface(namesOrDescriptions);
}
service.setDescriptions(taskId, descriptions);
break;
case SKIPPABLE_PROPERTY:
service.setSkipable(taskId, skippable);
break;
case SUB_TASK_STRATEGY_PROPERTY:
service.setSubTaskStrategy(taskId, subTasksStrategy);
break;
default:
throw new IllegalStateException("Unknown property in " + this.getClass().getSimpleName() + " execute: " + property);
}
return null;
}
use of org.kie.api.task.model.I18NText 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