Search in sources :

Example 6 with I18NText

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());
}
Also used : I18NText(org.kie.api.task.model.I18NText) JaxbI18NText(org.jbpm.services.task.impl.model.xml.JaxbI18NText) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) JaxbI18NText(org.jbpm.services.task.impl.model.xml.JaxbI18NText) I18NTextImpl(org.jbpm.services.task.impl.model.I18NTextImpl) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 7 with I18NText

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());
}
Also used : Task(org.kie.api.task.model.Task) InternalTask(org.kie.internal.task.api.model.InternalTask) I18NText(org.kie.api.task.model.I18NText) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) InternalTask(org.kie.internal.task.api.model.InternalTask) StringReader(java.io.StringReader) ArrayList(java.util.ArrayList) TaskSummary(org.kie.api.task.model.TaskSummary) Test(org.junit.Test)

Example 8 with I18NText

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);
}
Also used : Task(org.kie.api.task.model.Task) InternalTask(org.kie.internal.task.api.model.InternalTask) I18NText(org.kie.api.task.model.I18NText) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) InternalTask(org.kie.internal.task.api.model.InternalTask) ArrayList(java.util.ArrayList)

Example 9 with I18NText

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;
}
Also used : I18NText(org.kie.api.task.model.I18NText) JaxbI18NText(org.jbpm.services.task.impl.model.xml.JaxbI18NText) TaskInstanceService(org.kie.internal.task.api.TaskInstanceService)

Example 10 with I18NText

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);
    }
}
Also used : I18NText(org.kie.api.task.model.I18NText) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) InternalOrganizationalEntity(org.kie.internal.task.api.model.InternalOrganizationalEntity) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) TaskImpl(org.jbpm.persistence.scripts.oldentities.TaskImpl) ArrayList(java.util.ArrayList) InternalTaskData(org.kie.internal.task.api.model.InternalTaskData) InternalOrganizationalEntity(org.kie.internal.task.api.model.InternalOrganizationalEntity) SQLException(java.sql.SQLException) ParseException(java.text.ParseException) IOException(java.io.IOException) InternalPeopleAssignments(org.kie.internal.task.api.model.InternalPeopleAssignments) EntityManager(javax.persistence.EntityManager)

Aggregations

I18NText (org.kie.api.task.model.I18NText)24 ArrayList (java.util.ArrayList)22 InternalI18NText (org.kie.internal.task.api.model.InternalI18NText)19 Task (org.kie.api.task.model.Task)8 InternalTask (org.kie.internal.task.api.model.InternalTask)8 Test (org.junit.Test)6 I18NTextImpl (org.jbpm.services.task.impl.model.I18NTextImpl)5 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)4 OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)4 User (org.kie.api.task.model.User)4 InternalOrganizationalEntity (org.kie.internal.task.api.model.InternalOrganizationalEntity)4 InternalTaskData (org.kie.internal.task.api.model.InternalTaskData)4 StringReader (java.io.StringReader)3 Date (java.util.Date)3 HashMap (java.util.HashMap)3 JaxbI18NText (org.jbpm.services.task.impl.model.xml.JaxbI18NText)3 InternalTaskService (org.kie.internal.task.api.InternalTaskService)3 UserTaskService (org.jbpm.services.api.UserTaskService)2 UserTaskInstanceDesc (org.jbpm.services.api.model.UserTaskInstanceDesc)2 TaskFluent (org.jbpm.services.task.utils.TaskFluent)2