Search in sources :

Example 1 with WorkflowDefinition

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

the class KaleoModelUtil method getDefaultValue.

public static String getDefaultValue(Element modelElement, QualifiedName key, Enum<?> defaultValue) {
    String value = null;
    IFile definitionFile = null;
    WorkflowDefinition workflowDefinition = modelElement.nearest(WorkflowDefinition.class);
    if (workflowDefinition == null) {
        workflowDefinition = modelElement.adapt(WorkflowDefinition.class);
    }
    if (workflowDefinition != null) {
        definitionFile = workflowDefinition.adapt(IFile.class);
    }
    if (definitionFile != null) {
        try {
            value = definitionFile.getPersistentProperty(key);
        } catch (CoreException ce) {
        }
    }
    if (value == null) {
        value = getEnumSerializationAnnotation(defaultValue);
    }
    return value;
}
Also used : IFile(org.eclipse.core.resources.IFile) CoreException(org.eclipse.core.runtime.CoreException) WorkflowDefinition(com.liferay.ide.kaleo.core.model.WorkflowDefinition)

Example 2 with WorkflowDefinition

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

the class WorkflowProjectAdapterService method convert.

@Override
public <A> A convert(Object object, Class<A> adapterType) {
    A retval = null;
    if (IProject.class.equals(adapterType)) {
        ISapphirePart sapphirePart = context().find(ISapphirePart.class);
        WorkflowDefinition workflowDefinition = sapphirePart.getLocalModelElement().nearest(WorkflowDefinition.class);
        IFile file = workflowDefinition.adapt(IFile.class);
        if (file != null) {
            retval = adapterType.cast(file.getProject());
        } else {
            // create support project
            WorkflowSupportManager workflowSupportManager = KaleoCore.getDefault().getWorkflowSupportManager();
            IEditorInput editorInput = workflowDefinition.adapt(IEditorInput.class);
            if (editorInput instanceof WorkflowDefinitionEditorInput) {
                WorkflowDefinitionEditorInput workflowInput = (WorkflowDefinitionEditorInput) editorInput;
                WorkflowDefinitionEntry workflowEntry = workflowInput.getWorkflowDefinitionEntry();
                IServer server = workflowEntry.getParent().getParent();
                workflowSupportManager.setCurrentServer(server);
            }
            IJavaProject supportProject = workflowSupportManager.getSupportProject();
            retval = adapterType.cast(supportProject.getProject());
        }
    }
    return retval;
}
Also used : WorkflowDefinitionEditorInput(com.liferay.ide.kaleo.ui.editor.WorkflowDefinitionEditorInput) WorkflowDefinitionEntry(com.liferay.ide.kaleo.ui.navigator.WorkflowDefinitionEntry) IServer(org.eclipse.wst.server.core.IServer) IFile(org.eclipse.core.resources.IFile) IJavaProject(org.eclipse.jdt.core.IJavaProject) WorkflowDefinition(com.liferay.ide.kaleo.core.model.WorkflowDefinition) ISapphirePart(org.eclipse.sapphire.ui.ISapphirePart) WorkflowSupportManager(com.liferay.ide.kaleo.core.WorkflowSupportManager) IEditorInput(org.eclipse.ui.IEditorInput)

Example 3 with WorkflowDefinition

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

the class ForkNodeAddActionHandler method postDiagramNodePartAdded.

@Override
public void postDiagramNodePartAdded(NewNodeOp op, CanTransition newNodeFromWizard, CanTransition newNode) {
    NewForkNodeOp newForkOp = op.nearest(NewForkNodeOp.class);
    NewForkNode newForkNodeFromWizard = newNodeFromWizard.nearest(NewForkNode.class);
    Fork newFork = newNode.nearest(Fork.class);
    WorkflowDefinition workflowDefinition = newFork.nearest(WorkflowDefinition.class);
    if (newForkOp.isAddJoin().content(true)) {
        Join newJoin = workflowDefinition.getJoins().insert();
        String newJoinName = newForkNodeFromWizard.getName().content() + " Join";
        newJoin.setName(newJoinName);
        for (Node connectedNode : op.getConnectedNodes()) {
            for (WorkflowNode diagramNode : workflowDefinition.getDiagramNodes()) {
                Value<String> nodeName = connectedNode.getName();
                if (nodeName.content().equals(diagramNode.getName().content())) {
                    CanTransition canTransition = diagramNode.nearest(CanTransition.class);
                    ElementList<Transition> transitions = canTransition.getTransitions();
                    Transition newTransition = transitions.insert();
                    newTransition.setName(newJoinName);
                    newTransition.setTarget(newJoinName);
                }
            }
        }
    }
}
Also used : Fork(com.liferay.ide.kaleo.core.model.Fork) Node(com.liferay.ide.kaleo.core.model.Node) NewForkNode(com.liferay.ide.kaleo.core.op.NewForkNode) WorkflowNode(com.liferay.ide.kaleo.core.model.WorkflowNode) CanTransition(com.liferay.ide.kaleo.core.model.CanTransition) Transition(com.liferay.ide.kaleo.core.model.Transition) WorkflowDefinition(com.liferay.ide.kaleo.core.model.WorkflowDefinition) Join(com.liferay.ide.kaleo.core.model.Join) CanTransition(com.liferay.ide.kaleo.core.model.CanTransition) NewForkNode(com.liferay.ide.kaleo.core.op.NewForkNode) NewForkNodeOp(com.liferay.ide.kaleo.core.op.NewForkNodeOp) WorkflowNode(com.liferay.ide.kaleo.core.model.WorkflowNode)

Example 4 with WorkflowDefinition

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

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

the class RoleNamePossibleValuesService method _initMetaServiceIfNecessary.

private void _initMetaServiceIfNecessary() {
    WorkflowDefinition definition = _op().nearest(WorkflowDefinition.class);
    if (definition != null) {
        _metaService.initIfNecessary(definition);
    }
    AssignableOp assignableOp = _op().nearest(AssignableOp.class);
    if (assignableOp != null) {
        _metaService.initIfNecessary(assignableOp);
    }
}
Also used : AssignableOp(com.liferay.ide.kaleo.core.op.AssignableOp) WorkflowDefinition(com.liferay.ide.kaleo.core.model.WorkflowDefinition)

Aggregations

WorkflowDefinition (com.liferay.ide.kaleo.core.model.WorkflowDefinition)16 Transition (com.liferay.ide.kaleo.core.model.Transition)6 Node (com.liferay.ide.kaleo.core.model.Node)5 WorkflowNode (com.liferay.ide.kaleo.core.model.WorkflowNode)5 CanTransition (com.liferay.ide.kaleo.core.model.CanTransition)4 Join (com.liferay.ide.kaleo.core.model.Join)4 Fork (com.liferay.ide.kaleo.core.model.Fork)3 State (com.liferay.ide.kaleo.core.model.State)3 Task (com.liferay.ide.kaleo.core.model.Task)3 NewNodeOp (com.liferay.ide.kaleo.core.op.NewNodeOp)3 Value (org.eclipse.sapphire.Value)3 Version (org.eclipse.sapphire.Version)3 Condition (com.liferay.ide.kaleo.core.model.Condition)2 JoinXor (com.liferay.ide.kaleo.core.model.JoinXor)2 AssignableOp (com.liferay.ide.kaleo.core.op.AssignableOp)2 ArrayList (java.util.ArrayList)2 IFile (org.eclipse.core.resources.IFile)2 IProject (org.eclipse.core.resources.IProject)2 Element (org.eclipse.sapphire.Element)2 RootXmlResource (org.eclipse.sapphire.modeling.xml.RootXmlResource)2