Search in sources :

Example 6 with Assignable

use of com.liferay.ide.kaleo.core.model.Assignable 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

Assignable (com.liferay.ide.kaleo.core.model.Assignable)6 Role (com.liferay.ide.kaleo.core.model.Role)3 ResourceAction (com.liferay.ide.kaleo.core.model.ResourceAction)2 RoleName (com.liferay.ide.kaleo.core.model.RoleName)2 Scriptable (com.liferay.ide.kaleo.core.model.Scriptable)2 User (com.liferay.ide.kaleo.core.model.User)2 WorkflowDefinition (com.liferay.ide.kaleo.core.model.WorkflowDefinition)2 WorkflowNode (com.liferay.ide.kaleo.core.model.WorkflowNode)2 PropertyContentEvent (org.eclipse.sapphire.PropertyContentEvent)2 ScriptLanguageType (com.liferay.ide.kaleo.core.model.ScriptLanguageType)1 Task (com.liferay.ide.kaleo.core.model.Task)1 AssignableOp (com.liferay.ide.kaleo.core.op.AssignableOp)1 ChangeTaskAssignmentsOp (com.liferay.ide.kaleo.core.op.ChangeTaskAssignmentsOp)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 ElementHandle (org.eclipse.sapphire.ElementHandle)1 ElementList (org.eclipse.sapphire.ElementList)1 FilteredListener (org.eclipse.sapphire.FilteredListener)1 Listener (org.eclipse.sapphire.Listener)1 Value (org.eclipse.sapphire.Value)1 DefinitionLoader (org.eclipse.sapphire.ui.def.DefinitionLoader)1