Search in sources :

Example 1 with RoleType

use of com.liferay.ide.kaleo.core.model.RoleType in project liferay-ide by liferay.

the class KaleoModelUtil method changeTaskAssignments.

public static void changeTaskAssignments(Task task, AssignableOp op) {
    if ((task == null) || (op == null)) {
        return;
    }
    ElementHandle<User> user = task.getUser();
    user.clear();
    ElementHandle<Scriptable> scripteAssignment = task.getScriptedAssignment();
    scripteAssignment.clear();
    ElementList<ResourceAction> resourceAction = task.getResourceActions();
    resourceAction.clear();
    ElementList<Role> taskRole = task.getRoles();
    taskRole.clear();
    switch(op.getAssignmentType().content(true)) {
        case CREATOR:
            user.content(true);
            break;
        case USER:
            User content = user.content(true);
            content.copy(op.getImpliedUser());
            break;
        case ROLE:
            final Role newRole = taskRole.insert();
            newRole.copy(op.getImpliedRole());
            break;
        case ROLE_TYPE:
            for (Role role : op.getRoles()) {
                Role newRoleType = taskRole.insert();
                newRoleType.copy(role);
                Value<RoleType> roleType = role.getRoleType();
                newRoleType.setRoleType(roleType.content(true));
                Value<Boolean> autoCreate = role.getAutoCreate();
                if (autoCreate.content() != null) {
                    newRoleType.setAutoCreate(autoCreate.content());
                }
            }
            break;
        case SCRIPTED_ASSIGNMENT:
            Scriptable scriptable = scripteAssignment.content(true);
            Scriptable impliedScriptable = op.getImpliedScriptable();
            Value<ScriptLanguageType> scriptLanguageType = impliedScriptable.getScriptLanguage();
            scriptable.setScriptLanguage(scriptLanguageType.content(true));
            scriptable.setScript("/*specify script assignment */");
            break;
        case RESOURCE_ACTIONS:
            for (ResourceAction ra : op.getResourceActions()) {
                ResourceAction newResourceAction = resourceAction.insert();
                newResourceAction.copy(ra);
            }
            break;
    }
}
Also used : User(com.liferay.ide.kaleo.core.model.User) RoleType(com.liferay.ide.kaleo.core.model.RoleType) ScriptLanguageType(com.liferay.ide.kaleo.core.model.ScriptLanguageType) Scriptable(com.liferay.ide.kaleo.core.model.Scriptable) Role(com.liferay.ide.kaleo.core.model.Role) ResourceAction(com.liferay.ide.kaleo.core.model.ResourceAction)

Aggregations

ResourceAction (com.liferay.ide.kaleo.core.model.ResourceAction)1 Role (com.liferay.ide.kaleo.core.model.Role)1 RoleType (com.liferay.ide.kaleo.core.model.RoleType)1 ScriptLanguageType (com.liferay.ide.kaleo.core.model.ScriptLanguageType)1 Scriptable (com.liferay.ide.kaleo.core.model.Scriptable)1 User (com.liferay.ide.kaleo.core.model.User)1