Create a navigation service connector

Define a connector

This file should be available from the relative path "WEB-INF\storage<custom><connectors>\education-sample.xml" within the final connectors package.

<connectors>
        <connector name="navigation" label="navigation-connector.label" description="navigation-connector.description" version="1.0" company="Visiativ Software">
                <services>
                        <service>
                        </service>              
                </services>
        </connector>
</connectors>

Associate a runtime class to the service connector

<?xml version="1.0" encoding="UTF-8"?>
<connectors>
        <connector name="navigation" label="navigation-connector.label" description="navigation-connector.description" version="1.0" company="Visiativ Software">
                <services>
                <services>
                        <service name="fooService" label="sample.service.foo.label">
                                <class qualifiedName="com.axemble.education.connectors.sample.DummyServiceConnector" />
                        </service>              
                </services>
        </connector>
</connectors>

Create the runtime class for the service connector

package com.axemble.education.connectors.sample;

import java.util.Map;

import org.w3c.dom.Element;

import com.axemble.vdoc.sdk.connectors.BaseServiceConnector;
import com.axemble.vdoc.sdk.interfaces.IConnectorExecutionStatus;
import com.axemble.vdoc.sdk.interfaces.IContext;

public class DummyServiceConnector extends BaseServiceConnector
{
        private static final long serialVersionUID = 1L;

        @Override
        public int execute( IContext context, int eventType, String eventName, Element customElement )
        {
                // retrieve the parameters
                Map<String, Object> inputs = getServiceDefinition().getValues();

                // add parameters to the local thread to make them available for the next services
                addParameter( "onAbort", "parameterValue" );

                // set the output values
                getServiceOutputs().addOutput( "errorMessage", "labelerrorMessage" );

                return IConnectorExecutionStatus.CONTINUE;
        }
        @Override
        public void beforeCompletion( IContext context, int eventType, String eventName, Element customElement )
        {
                super.beforeCompletion( context, eventType, eventName, customElement );

                LOGGER.error( "[INFO] call beforeCompletion method " );
        }
        @Override
        public void afterCompletion( IContext context, int eventType, String eventName, Element customElement, boolean committed )
        {
                super.afterCompletion( context, eventType, eventName, customElement, committed );

                LOGGER.error( "[INFO] call afterCompletion method with committed value = " + committed );
        }
        @Override
        public void asyncExecute( int eventType, String eventName, Element customElement )
        {
                super.asyncExecute( eventType, eventName, customElement );

                LOGGER.error( "[INFO] call asyncExecute method with committed value = " );
        }
}

Set the configuration of the service connector

<?xml version="1.0" encoding="UTF-8"?>
<connectors>
        <connector name="navigation" label="navigation-connector.label" description="navigation-connector.description" version="1.0" company="Visiativ Software">
                <services>
                        <service name="fooService" label="sample.service.foo.label">
                                <class qualifiedName="com.axemble.education.connectors.sample.DummyServiceConnector" />
                                <icons>
                                                <icon name="small" path="mail/mail.png" />
                                                <icon name="medium" path="" />
                                                <icon name="large" path="" />
                                </icons>
                        <configuration>
                                <class qualifiedName="com.axemble.education.connectors.sample.DummyServiceConnectorEditor" />
                            <section name="cmis">
                                <fields>
                                    <field name="folderName" label="Nom du dossier" ctrl="text" mandatory="true" maxlength="64" defaultValue="" />
                                    <field name="parentFolder" label="Dossier parent" ctrl="com.axemble.vdoc.sdk.document.fields.SelectorField" mandatory="false" />
                                    <field name="fldMailingList" label="treatment.mail.sendMail.mailingList.label" description="treatment.mail.sendMail.mailingList.description" ctrl="selector" mandatory="true" screen="mailingList" method="select" type="all" />
                                </fields>
                            </section>
                        </configuration>
                        <inputs>
                            <input name="folderName" type="java.lang.String" />
                            <input name="parentFolder" type="com.axemble.vdoc.sdk.interfaces.IFolder" />
                            <input name="fldMailingList" type="com.axemble.vdoc.sdk.interfaces.IMailingList" />
                        </inputs>
                        <outputs>
                            <output name="result" type="java.lang.Boolean" />
                            <output name="error" type="java.lang.String" />
                            <output name="errorMessage" type="java.lang.String" />                          
                            <output name="folder" type="com.axemble.vdoc.sdk.interfaces.IFolder" />                         
                            <output name="folders" type="java.util.Collection" collectionType="com.axemble.vdoc.sdk.interfaces.IFolder" />
                        </outputs>                      
                        <entry-points>                                                          
                            <connectors-library familyName="education" />
                        </entry-points>
                        <supported-events>
                                        <front-end-events>
                                                <resource-definition>
                                                        <form>
                                                                <events>
                                                                        <event name="onAfterLoad" default="true" />
                                                                </events>
                                                        </form>
                                                </resource-definition>
                                        </front-end-events>
                                </supported-events>                     
                        </service>              
                </services>
        </connector>
</connectors>

Create the editor class for the service connector

package com.axemble.education.connectors.sample;

import com.axemble.vdoc.sdk.connectors.BaseServiceConnectorEditor;

public class DummyServiceEditor extends BaseServiceConnectorEditor
{

        private static final long serialVersionUID = 1L;

}

Retrieve the parameters from the configuration

By using the getServiceDefinition method you can retrieve the various values from the configuration.

// retrieve all the values from the configuration
Map<String, Object> inputObjects = getServiceDefinition().getValues();

// retrieve a specific value from the configuration by its name
Object inputObject = getServiceDefinition().getValue( "fldDescription" );

Make some result values available to the Studio

By using the addOutput method you can make available some values from the service execution to the Studio.

getServiceOutputs().addOutput( "errorMessage", "labelErrorMessage" );
getServiceOutputs().addOutput( "anyObjectValue", anyObjectValue );

Make some result values available for the next service execution

By using the addParameter method you can make available some values for the service the next service execution.

addParameter( "errorMessage", "labelErrorMessage" );
addParameter( "anyObjectValue", anyObjectValue );

Use the service connector into a form;

Test the service connector using a process document.