Search in sources :

Example 11 with Scriptable

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

the class CurrentAssignmentsDerviedValueService method compute.

@Override
protected String compute() {
    StringBuilder data = new StringBuilder();
    Assignable assignable = context(Assignable.class);
    ElementHandle<User> assignableUser = assignable.getUser();
    User user = assignableUser.content(false);
    ElementList<Role> roles = assignable.getRoles();
    ElementHandle<Scriptable> scripteAssignment = assignable.getScriptedAssignment();
    Scriptable scriptable = scripteAssignment.content(false);
    ElementList<ResourceAction> resourceActions = assignable.getResourceActions();
    if (user != null) {
        Value<Integer> userId = user.getUserId();
        Value<String> userScreenName = user.getScreenName();
        Value<String> userEmailAddress = user.getEmailAddress();
        if (userId.content() != null) {
            data.append(userId.content() + ", ");
        } else if (userScreenName.content() != null) {
            data.append(userScreenName.content() + ", ");
        } else if (userEmailAddress.content() != null) {
            data.append(userEmailAddress.content() + ", ");
        } else {
            data.append("User: Asset Creator");
        }
    }
    if (ListUtil.isNotEmpty(roles)) {
        data.append("Roles: ");
        for (Role role : roles) {
            Value<Integer> roleId = role.getRoleId();
            Value<String> roleName = role.getName();
            if (roleId.content() != null) {
                data.append(roleId.content() + ", ");
            } else {
                data.append(roleName.text() + ", ");
            }
        }
    }
    if (scriptable != null) {
        Value<String> script = scriptable.getScript();
        Value<ScriptLanguageType> scriptLanguageType = scriptable.getScriptLanguage();
        if (script.content() != null) {
            data.append("Script language: " + scriptLanguageType.content());
        }
    }
    if (ListUtil.isNotEmpty(resourceActions)) {
        data.append("Resource actions: ");
        for (ResourceAction resourceAction : resourceActions) {
            Value<String> reAction = resourceAction.getResourceAction();
            if (reAction.content() != null) {
                data.append(reAction.content() + ", ");
            }
        }
    }
    String dataInfo = data.toString();
    return dataInfo.replaceAll(", $", "");
}
Also used : User(com.liferay.ide.kaleo.core.model.User) ScriptLanguageType(com.liferay.ide.kaleo.core.model.ScriptLanguageType) Scriptable(com.liferay.ide.kaleo.core.model.Scriptable) Role(com.liferay.ide.kaleo.core.model.Role) Assignable(com.liferay.ide.kaleo.core.model.Assignable) ResourceAction(com.liferay.ide.kaleo.core.model.ResourceAction)

Aggregations

Scriptable (com.liferay.ide.kaleo.core.model.Scriptable)11 ScriptLanguageType (com.liferay.ide.kaleo.core.model.ScriptLanguageType)5 ResourceAction (com.liferay.ide.kaleo.core.model.ResourceAction)3 Role (com.liferay.ide.kaleo.core.model.Role)3 User (com.liferay.ide.kaleo.core.model.User)3 Assignable (com.liferay.ide.kaleo.core.model.Assignable)2 Task (com.liferay.ide.kaleo.core.model.Task)2 IKaleoEditorHelper (com.liferay.ide.kaleo.ui.IKaleoEditorHelper)2 Element (org.eclipse.sapphire.Element)2 Action (com.liferay.ide.kaleo.core.model.Action)1 RoleName (com.liferay.ide.kaleo.core.model.RoleName)1 RoleType (com.liferay.ide.kaleo.core.model.RoleType)1 WorkflowDefinition (com.liferay.ide.kaleo.core.model.WorkflowDefinition)1 WorkflowNode (com.liferay.ide.kaleo.core.model.WorkflowNode)1 ChangeTaskAssignmentsOp (com.liferay.ide.kaleo.core.op.ChangeTaskAssignmentsOp)1 Field (java.lang.reflect.Field)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 ElementHandle (org.eclipse.sapphire.ElementHandle)1 Event (org.eclipse.sapphire.Event)1 FilteredListener (org.eclipse.sapphire.FilteredListener)1