Search in sources :

Example 1 with Assignable

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

the class ChangeTaskAssignmentsActionHandler method run.

@Override
protected Object run(Presentation context) {
    Task task = _task(context);
    ChangeTaskAssignmentsOp op = ChangeTaskAssignmentsOp.TYPE.instantiate();
    for (WorkflowNode node : task.nearest(WorkflowDefinition.class).getDiagramNodes()) {
        Assignable assignable = node.nearest(Assignable.class);
        if (assignable != null) {
            for (Role role : assignable.getRoles()) {
                String name = role.getName().content(false);
                if (!isNullOrEmpty(name)) {
                    ElementList<RoleName> roleName = op.getRoleNames();
                    roleName.insert().setName(name);
                }
            }
        }
    }
    User existingUser = task.getUser().content(false);
    ElementList<Role> existingRoles = task.getRoles();
    ElementList<ResourceAction> existingActions = task.getResourceActions();
    Scriptable scriptedAssignment = task.getScriptedAssignment().content(false);
    if (existingUser != null) {
        op.getImpliedUser().copy(existingUser);
    } else if (ListUtil.isNotEmpty(existingRoles)) {
        op.getImpliedRole().copy(existingRoles.get(0));
        for (Role role : existingRoles) {
            Role newRole = op.getRoles().insert();
            newRole.copy(role);
            Boolean autoCreate = role.getAutoCreate().content(false);
            if (autoCreate != null) {
                newRole.setAutoCreate(role.getAutoCreate().content());
            }
        }
    } else if (ListUtil.isNotEmpty(existingActions)) {
        for (ResourceAction action : existingActions) {
            ElementList<ResourceAction> resourceActions = op.getResourceActions();
            ResourceAction resourceAction = resourceActions.insert();
            resourceAction.copy(action);
        }
    } else if (scriptedAssignment != null) {
        ElementHandle<Scriptable> scriptable = op.getScriptedAssignment();
        Scriptable content = scriptable.content(true);
        content.copy(scriptedAssignment);
    }
    DefinitionLoader loader = DefinitionLoader.context(NewWorkflowDefinitionWizard.class);
    DefinitionLoader loaderSdef = loader.sdef("WorkflowDefinitionWizards");
    SapphireWizard<ChangeTaskAssignmentsOp> wizard = new SapphireWizard<>(op, loaderSdef.wizard("changeTaskAssignmentsWizard"));
    int returnCode = new WizardDialog(((SwtPresentation) context).shell(), wizard).open();
    if (returnCode == IDialogConstants.OK_ID) {
        KaleoModelUtil.changeTaskAssignments(_task(context), op);
    }
    return null;
}
Also used : SapphireWizard(org.eclipse.sapphire.ui.forms.swt.SapphireWizard) Task(com.liferay.ide.kaleo.core.model.Task) User(com.liferay.ide.kaleo.core.model.User) WorkflowDefinition(com.liferay.ide.kaleo.core.model.WorkflowDefinition) Scriptable(com.liferay.ide.kaleo.core.model.Scriptable) WorkflowNode(com.liferay.ide.kaleo.core.model.WorkflowNode) Role(com.liferay.ide.kaleo.core.model.Role) RoleName(com.liferay.ide.kaleo.core.model.RoleName) DefinitionLoader(org.eclipse.sapphire.ui.def.DefinitionLoader) ElementHandle(org.eclipse.sapphire.ElementHandle) SwtPresentation(org.eclipse.sapphire.ui.forms.swt.SwtPresentation) WizardDialog(org.eclipse.jface.wizard.WizardDialog) ChangeTaskAssignmentsOp(com.liferay.ide.kaleo.core.op.ChangeTaskAssignmentsOp) Assignable(com.liferay.ide.kaleo.core.model.Assignable) ResourceAction(com.liferay.ide.kaleo.core.model.ResourceAction)

Example 2 with Assignable

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

the class CurrentAssignmentsCondition method evaluate.

@Override
protected boolean evaluate() {
    boolean retval = false;
    Assignable assignable = _op();
    boolean hasUser = false;
    if (assignable.getUser().content(false) != null) {
        hasUser = true;
    }
    boolean hasScript = false;
    if (assignable.getScriptedAssignment().content(false) != null) {
        hasScript = true;
    }
    boolean hasRoles = false;
    if (assignable.getRoles().size() > 0) {
        hasRoles = true;
    }
    boolean hasResourceActions = false;
    if (assignable.getResourceActions().size() > 0) {
        hasResourceActions = true;
    }
    if (hasUser) {
        retval = "user".equals(_parameter) || "creator".equals(_parameter);
    } else if (hasScript) {
        retval = "script".equals(_parameter);
    } else if (hasRoles) {
        retval = "role".equals(_parameter) || "roles".equals(_parameter);
    } else if (hasResourceActions) {
        retval = "resources".equals(_parameter);
    }
    return retval;
}
Also used : Assignable(com.liferay.ide.kaleo.core.model.Assignable)

Example 3 with Assignable

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

the class CurrentAssignmentsCondition method initCondition.

@Override
protected void initCondition(ISapphirePart part, String parameter) {
    super.initCondition(part, parameter);
    _parameter = parameter;
    Assignable assignable = _op();
    Listener assignmentTypeListener = new FilteredListener<PropertyContentEvent>() {

        @Override
        public void handleTypedEvent(PropertyContentEvent event) {
            updateConditionState();
        }
    };
    assignable.attach(assignmentTypeListener, "*");
    updateConditionState();
}
Also used : FilteredListener(org.eclipse.sapphire.FilteredListener) PropertyContentEvent(org.eclipse.sapphire.PropertyContentEvent) FilteredListener(org.eclipse.sapphire.FilteredListener) Listener(org.eclipse.sapphire.Listener) Assignable(com.liferay.ide.kaleo.core.model.Assignable)

Example 4 with Assignable

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

the class RoleNamePossibleValuesMetaService method initIfNecessary.

protected void initIfNecessary(Object object) {
    if (object instanceof WorkflowDefinition) {
        for (WorkflowNode node : ((WorkflowDefinition) object).getDiagramNodes()) {
            Assignable assignable = node.nearest(Assignable.class);
            if (assignable != null) {
                for (Role role : assignable.getRoles()) {
                    Value<String> roleName = role.getName();
                    String name = roleName.content(false);
                    if (!CoreUtil.isNullOrEmpty(name)) {
                        _originalRoleNames.add(name);
                    }
                }
            }
        }
    } else if (object instanceof AssignableOp) {
        ElementList<RoleName> roleNames = ((AssignableOp) object).getRoleNames();
        for (RoleName roleName : roleNames) {
            Value<String> nameValue = roleName.getName();
            String name = nameValue.content(false);
            if (!CoreUtil.isNullOrEmpty(name)) {
                _originalRoleNames.add(name);
            }
        }
    }
}
Also used : Role(com.liferay.ide.kaleo.core.model.Role) AssignableOp(com.liferay.ide.kaleo.core.op.AssignableOp) RoleName(com.liferay.ide.kaleo.core.model.RoleName) Value(org.eclipse.sapphire.Value) WorkflowDefinition(com.liferay.ide.kaleo.core.model.WorkflowDefinition) ElementList(org.eclipse.sapphire.ElementList) WorkflowNode(com.liferay.ide.kaleo.core.model.WorkflowNode) Assignable(com.liferay.ide.kaleo.core.model.Assignable)

Example 5 with Assignable

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

the class TaskValidationService method initValidationService.

@Override
protected void initValidationService() {
    Assignable assignable = assignable();
    if (assignable != null) {
        _listener = new FilteredListener<PropertyContentEvent>() {

            @Override
            protected void handleTypedEvent(PropertyContentEvent event) {
                refresh();
            }
        };
        assignable.attach(_listener, "*");
    }
}
Also used : PropertyContentEvent(org.eclipse.sapphire.PropertyContentEvent) Assignable(com.liferay.ide.kaleo.core.model.Assignable)

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