Search in sources :

Example 1 with I18NText

use of org.kie.api.task.model.I18NText in project jbpm by kiegroup.

the class DefaultChecklistManager method setTaskName.

private void setTaskName(InternalTask task, String name) {
    List<I18NText> names = new ArrayList<I18NText>();
    I18NText text = TaskModelProvider.getFactory().newI18NText();
    ((InternalI18NText) text).setLanguage("en-UK");
    ((InternalI18NText) text).setText(name);
    names.add(text);
    task.setNames(names);
    List<I18NText> subjects = new ArrayList<I18NText>();
    text = TaskModelProvider.getFactory().newI18NText();
    ((InternalI18NText) text).setLanguage("en-UK");
    ((InternalI18NText) text).setText(name);
    subjects.add(text);
    task.setSubjects(subjects);
}
Also used : I18NText(org.kie.api.task.model.I18NText) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) ArrayList(java.util.ArrayList)

Example 2 with I18NText

use of org.kie.api.task.model.I18NText in project jbpm by kiegroup.

the class DefaultChecklistManager method updateTaskDescription.

public void updateTaskDescription(long taskId, String description) {
    RuntimeEngine runtime = getRuntime();
    List<I18NText> descriptions = new ArrayList<I18NText>();
    I18NText text = TaskModelProvider.getFactory().newI18NText();
    ((InternalI18NText) text).setLanguage("en-UK");
    ((InternalI18NText) text).setText(description);
    descriptions.add(text);
    ((InternalTaskService) runtime.getTaskService()).setDescriptions(taskId, descriptions);
    manager.disposeRuntimeEngine(runtime);
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) I18NText(org.kie.api.task.model.I18NText) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) ArrayList(java.util.ArrayList) InternalTaskService(org.kie.internal.task.api.InternalTaskService)

Example 3 with I18NText

use of org.kie.api.task.model.I18NText in project jbpm by kiegroup.

the class DefaultChecklistManager method updateTaskName.

public void updateTaskName(long taskId, String name) {
    RuntimeEngine runtime = getRuntime();
    List<I18NText> names = new ArrayList<I18NText>();
    I18NText text = TaskModelProvider.getFactory().newI18NText();
    ((InternalI18NText) text).setLanguage("en-UK");
    ((InternalI18NText) text).setText(name);
    names.add(text);
    ((InternalTaskService) runtime.getTaskService()).setTaskNames(taskId, names);
    manager.disposeRuntimeEngine(runtime);
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) I18NText(org.kie.api.task.model.I18NText) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) ArrayList(java.util.ArrayList) InternalTaskService(org.kie.internal.task.api.InternalTaskService)

Example 4 with I18NText

use of org.kie.api.task.model.I18NText in project jbpm by kiegroup.

the class UserTaskServiceImpl method setName.

@Override
public void setName(String deploymentId, Long taskId, String name) {
    UserTaskInstanceDesc task = dataService.getTaskById(taskId);
    validateTask(deploymentId, taskId, task);
    RuntimeManager manager = getRuntimeManager(task);
    if (manager == null) {
        logger.warn("Cannot find runtime manager for task {}", taskId);
        return;
    }
    RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(task.getProcessInstanceId()));
    try {
        InternalI18NText text = (InternalI18NText) TaskModelProvider.getFactory().newI18NText();
        text.setLanguage("en-UK");
        text.setText(name);
        List<I18NText> names = new ArrayList<I18NText>();
        names.add(text);
        TaskService taskService = engine.getTaskService();
        // perform actual operation
        ((InternalTaskService) taskService).setTaskNames(taskId, names);
    } finally {
        disposeRuntimeEngine(manager, engine);
    }
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) I18NText(org.kie.api.task.model.I18NText) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) InternalTaskService(org.kie.internal.task.api.InternalTaskService) UserTaskService(org.jbpm.services.api.UserTaskService) TaskService(org.kie.api.task.TaskService) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) ArrayList(java.util.ArrayList) InternalTaskService(org.kie.internal.task.api.InternalTaskService) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc)

Example 5 with I18NText

use of org.kie.api.task.model.I18NText in project jbpm by kiegroup.

the class UserTaskAdminServiceImpl method buildEmailNotification.

@Override
public EmailNotification buildEmailNotification(String subjectStr, List<OrganizationalEntity> recipients, String bodyStr, String fromStr, String replyToStr) {
    EmailNotification emailNotification = TaskModelProvider.getFactory().newEmialNotification();
    Map<Language, EmailNotificationHeader> emailHeaders = new HashMap<Language, EmailNotificationHeader>();
    List<I18NText> subjects = new ArrayList<I18NText>();
    List<I18NText> names = new ArrayList<I18NText>();
    String locale = "en-UK";
    EmailNotificationHeader emailHeader = TaskModelProvider.getFactory().newEmailNotificationHeader();
    emailHeader.setBody(bodyStr);
    emailHeader.setFrom(fromStr);
    emailHeader.setReplyTo(replyToStr);
    emailHeader.setLanguage(locale);
    emailHeader.setSubject(subjectStr);
    Language lang = TaskModelProvider.getFactory().newLanguage();
    lang.setMapkey(locale);
    emailHeaders.put(lang, emailHeader);
    I18NText subject = TaskModelProvider.getFactory().newI18NText();
    ((InternalI18NText) subject).setLanguage(locale);
    ((InternalI18NText) subject).setText(emailHeader.getSubject());
    ;
    subjects.add(subject);
    names.add(subject);
    emailNotification.setEmailHeaders(emailHeaders);
    emailNotification.setNames(names);
    emailNotification.setRecipients(new ArrayList<>(recipients));
    emailNotification.setSubjects(subjects);
    return emailNotification;
}
Also used : I18NText(org.kie.api.task.model.I18NText) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) Language(org.kie.internal.task.api.model.Language) EmailNotificationHeader(org.kie.internal.task.api.model.EmailNotificationHeader) HashMap(java.util.HashMap) InternalI18NText(org.kie.internal.task.api.model.InternalI18NText) ArrayList(java.util.ArrayList) EmailNotification(org.kie.internal.task.api.model.EmailNotification)

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