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;
}
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;
}
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();
}
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);
}
}
}
}
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, "*");
}
}
Aggregations