Search in sources :

Example 1 with Version

use of org.eclipse.sapphire.Version in project liferay-ide by liferay.

the class EmailAddressValidationService method _getSchemaVersion.

private Version _getSchemaVersion() {
    Version schemaVersion = new Version(KaleoCore.DEFAULT_KALEO_VERSION);
    if (context(WorkflowDefinition.class) != null) {
        WorkflowDefinition workflowDefinition = context(WorkflowDefinition.class);
        Value<Version> version = workflowDefinition.getSchemaVersion();
        schemaVersion = version.content();
    } else if (context(NewNodeOp.class) != null) {
        NewNodeOp newNodeOp = context(NewNodeOp.class);
        ElementHandle<WorkflowDefinition> workflowDef = newNodeOp.getWorkflowDefinition();
        WorkflowDefinition workflowDefinition = workflowDef.content();
        Value<Version> version = workflowDefinition.getSchemaVersion();
        schemaVersion = version.content();
    } else if (context(NewWorkflowDefinitionOp.class) != null) {
        NewWorkflowDefinitionOp newWorkflowDenitionOp = context(NewWorkflowDefinitionOp.class);
        ReferenceValue<String, IProject> opProject = newWorkflowDenitionOp.getProject();
        IProject project = opProject.target();
        ILiferayProject liferayProj = LiferayCore.create(project);
        ILiferayPortal portal = liferayProj.adapt(ILiferayPortal.class);
        if (portal != null) {
            schemaVersion = new Version(portal.getVersion());
        }
    }
    return schemaVersion;
}
Also used : Version(org.eclipse.sapphire.Version) ILiferayProject(com.liferay.ide.core.ILiferayProject) NewNodeOp(com.liferay.ide.kaleo.core.op.NewNodeOp) ReferenceValue(org.eclipse.sapphire.ReferenceValue) Value(org.eclipse.sapphire.Value) WorkflowDefinition(com.liferay.ide.kaleo.core.model.WorkflowDefinition) ElementHandle(org.eclipse.sapphire.ElementHandle) NewWorkflowDefinitionOp(com.liferay.ide.kaleo.core.op.NewWorkflowDefinitionOp) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) IProject(org.eclipse.core.resources.IProject)

Example 2 with Version

use of org.eclipse.sapphire.Version in project liferay-ide by liferay.

the class EmailAddressValidationService method initValidationService.

@Override
protected void initValidationService() {
    super.initValidationService();
    Version schemaVersion = _getSchemaVersion();
    _shouldValidate = schemaVersion.compareTo(new Version("6.2")) >= 0;
}
Also used : Version(org.eclipse.sapphire.Version)

Example 3 with Version

use of org.eclipse.sapphire.Version in project liferay-ide by liferay.

the class NotificationTransportValuesService method compute.

@Override
protected void compute(Set<String> values) {
    values.add("email");
    values.add("im");
    values.add("private-message");
    Value<Version> schemaVersion = context(WorkflowDefinition.class).getSchemaVersion();
    final Version version = schemaVersion.content();
    if (_v62.compareTo(version) <= 0) {
        values.add("user-notification");
    }
}
Also used : Version(org.eclipse.sapphire.Version) WorkflowDefinition(com.liferay.ide.kaleo.core.model.WorkflowDefinition)

Example 4 with Version

use of org.eclipse.sapphire.Version in project liferay-ide by liferay.

the class TransitionReferenceService method compute.

@Override
public Node compute() {
    String reference = context(Value.class).text();
    if (reference != null) {
        WorkflowDefinition workflow = context(WorkflowDefinition.class);
        List<Node> nodes = new ArrayList<>();
        if (workflow != null) {
            nodes.addAll(workflow.getTasks());
            nodes.addAll(workflow.getStates());
            nodes.addAll(workflow.getConditions());
            nodes.addAll(workflow.getForks());
            nodes.addAll(workflow.getJoins());
            Value<Version> schemaVersion = workflow.getSchemaVersion();
            Version version = schemaVersion.content();
            if (version.compareTo(new Version("6.2")) >= 0) {
                nodes.addAll(workflow.getJoinXors());
            }
            for (Node node : nodes) {
                if (reference.equals(node.getName().content())) {
                    return node;
                }
            }
        }
    }
    return null;
}
Also used : Version(org.eclipse.sapphire.Version) Node(com.liferay.ide.kaleo.core.model.Node) Value(org.eclipse.sapphire.Value) ArrayList(java.util.ArrayList) WorkflowDefinition(com.liferay.ide.kaleo.core.model.WorkflowDefinition)

Example 5 with Version

use of org.eclipse.sapphire.Version in project liferay-ide by liferay.

the class TransitionPossibleValuesService method compute.

@Override
protected void compute(Set<String> values) {
    /*
		 * if we are a task return states and tasks, if we are a state, find
		 * tasks.
		 */
    Element modelElement = context(Element.class);
    WorkflowDefinition workflow = modelElement.nearest(WorkflowDefinition.class);
    if (workflow == null) {
        workflow = modelElement.adapt(WorkflowDefinition.class);
    }
    if (workflow != null) {
        addNodeNames(values, workflow.getTasks());
        addNodeNames(values, workflow.getStates());
        addNodeNames(values, workflow.getConditions());
        addNodeNames(values, workflow.getForks());
        addNodeNames(values, workflow.getJoins());
        Value<Version> schemaVersion = workflow.getSchemaVersion();
        Version version = schemaVersion.content();
        if (version.compareTo(new Version("6.2")) >= 0) {
            addNodeNames(values, workflow.getJoinXors());
        }
    }
}
Also used : Version(org.eclipse.sapphire.Version) Element(org.eclipse.sapphire.Element) WorkflowDefinition(com.liferay.ide.kaleo.core.model.WorkflowDefinition)

Aggregations

Version (org.eclipse.sapphire.Version)5 WorkflowDefinition (com.liferay.ide.kaleo.core.model.WorkflowDefinition)4 Value (org.eclipse.sapphire.Value)2 ILiferayPortal (com.liferay.ide.core.ILiferayPortal)1 ILiferayProject (com.liferay.ide.core.ILiferayProject)1 Node (com.liferay.ide.kaleo.core.model.Node)1 NewNodeOp (com.liferay.ide.kaleo.core.op.NewNodeOp)1 NewWorkflowDefinitionOp (com.liferay.ide.kaleo.core.op.NewWorkflowDefinitionOp)1 ArrayList (java.util.ArrayList)1 IProject (org.eclipse.core.resources.IProject)1 Element (org.eclipse.sapphire.Element)1 ElementHandle (org.eclipse.sapphire.ElementHandle)1 ReferenceValue (org.eclipse.sapphire.ReferenceValue)1