/
Design Time Integration with the Data API

Design Time Integration with the Data API

This tutorial will walk you through a few API scenarios focusing on the design-time integration such as creating new forms, listing and managing projects, launching the designer for a workflow, downloading schemas, projects, forms and workflows, download the XSD for a form/workflow, uploading custom XSDs, using forms and workflows.

In v9.1 and later frevvo's "Applications" are known as "Projects." The API objects and methods still use the word Application.

On this page:


What are we going to build?

Nothing. We have pre-created a simple application that shows the different usages of the API using an interactive command-line approach. Think of this app as the command-line version of the web-based frevvo UI but stripped of all the irrelevant details, libraries, etc., so you can inspect the different API usages as simply as possible using live code with sources included.

Although this approach makes it a bit harder to piece together a given API usage since it will be comprised of a set of different paths through the sources, we believe it will provide a better learning tool since you will be able to inspect the sources, which will be running sources, or even debug the app if needed, after all this is an API we are talking about. We have also chosen an interactive command-line application format so that we would be able to reduce the code footprint to a bare minimum increasing the clarity needed to understand it. Besides, this tutorial should be the guide through the different API usages that may not be obvious by simply inspecting the source code.

Downloading the command-line client

The client is packaged as an executable Java JAR that includes all of the required dependencies and you can download the binaries from here and the sources from here.

Running the command-line client

Assuming that you have a Java Runtime Environment (JRE (update 21+) or JDK versions 1.6, 1.7), you can run the client as follows, replacing 'com.frevvo.forms.cli.jar' with the current jar filename, e.g. 'forms-cli-10.1.2.jar'. 

java -jar com.frevvo.forms.cli.jar

This should show you usage information:

usage: com.frevvo.forms.cli.Main
-s,--server <arg> serverl url (e.g. http://localhost:8082)
-t,--tenant <arg> tenant (optional, e.g. doe.com)

If you want to connect to a frevvo install running on localhost you can do as follows, replacing 'forms-cli.jar' with the current jar filename.

java -jar forms-cli.jar com.frevvo.forms.cli.Main -s http://localhost:8082

And you should see the command line prompt:

localhost:8082> 

This means that you are up and running, but not yet connected. First, you need to log in to a frevvo account. Be sure to create at least one tenant and one user for the tenant before you try to log in. See Connect to a Server and Log In below for instructions.

How are the sources organized?

The key concept you need to know to understand the sources is the Shell. Each feed and entry described in the previous diagram will have a corresponding Shell class (with the exception of FormTypeTemplateFeed/Entry) that is used to plug into the command line interface the different commands available. The commands available in the app at any given point in time are defined based on what Shell is active. When you issue commands in the prompt, you may remain in the same Shell or navigate the Shell tree and change the active Shell. Changing the active Shell changes the available commands at the prompt.

Some commands are not specific to a given shell but are common across all shells. They are:

  • ?list - This command will print out a list of all the currently available commands with a brief description and the number of arguments it expects if it expects any.
  • exit - This is how exit the current shell and 'back up' and return to the previous one (some commands you execute may activate a new shell). Exiting from the last shell will exit the app.

Here are the shells you can find in this app (all located in the '''com.frevvo.forms.cli.shell.*''' package):

  • com.frevvo.forms.cli.shell.ApplicationEntryShell
  • com.frevvo.forms.cli.shell.ApplicationFeedShell
  • com.frevvo.forms.cli.shell.ControlTypeEntryShell
  • com.frevvo.forms.cli.shell.ControlTypeFeedShell
  • com.frevvo.forms.cli.shell.DocumentTypeFeedShell
  • com.frevvo.forms.cli.shell.DocumentTypeEntryShell
  • com.frevvo.forms.cli.shell.FormTypeEntryShell
  • com.frevvo.forms.cli.shell.FormTypeFeedShell
  • com.frevvo.forms.cli.shell.SchemaEntryShell
  • com.frevvo.forms.cli.shell.SchemaFeedShell
  • com.frevvo.forms.cli.shell.SubmissionEntryShell
  • com.frevvo.forms.cli.shell.SubmissionFeedShell
  • com.frevvo.forms.cli.shell.TaskEntryShell
  • com.frevvo.forms.cli.shell.TaskFeedShell
  • com.frevvo.forms.cli.shell.ThemeEntryShell
  • com.frevvo.forms.cli.shell.ThemeFeedShell
  • com.frevvo.forms.cli.shell.UserEntryShell
  • com.frevvo.forms.cli.shell.UserFeedShell
  • com.frevvo.forms.cli.shell.FormInstanceShell

The FormInstanceShell has no corresponding feed/entry in the Data API. It is used to provide a context for commands that interact with a form instance (e.g. submitting a form, resetting a form, etc)

If you inspect the sources for each of these classes you will notice some methods are annotated with a special Command metadata: this is where we specify what is the command's name in the command prompt and its description (used by ?print described above).

Now let's move on to some usage scenarios.

Usage Scenarios

The following topics show how to log in to the frevvo server and use the command line API to interact with the server, projects, forms and workflows.

Connect to a Server and Log In

The example below shows how to log in to a local frevvo server. In this example, the login user name is david, the name of the tenant is monahan.com, and the user password is david (e.g., login david@monahan.com david).

To login, you must first create a tenant on the server (other than the default d tenant). You should also create a user with the role frevvo.Designer who can create projects.

Directory of D:\frevvo v4.1.4

08/05/2011 08:59a <DIR> .
08/05/2011 08:59a <DIR> ..
08/05/2011 08:59a 3,044,609 com.frevvo.forms.cli.jar
07/12/2011 09:20a <DIR> frevvo
        1 File(s) 3,044,609 bytes
        3 Dir(s) 7,803,990,016 bytes free

D:\frevvo v4.1.4>java -jar com.frevvo.forms.cli.jar

usage: com.frevvo.forms.cli.Main
-s,--server <arg> serverl url (e.g. http://localhost:8082)
-t,--tenant tenant (optional, e.g. doe.com)

D:\frevvo v4.1.4>java -jar com.frevvo.forms.cli.jar -s http://localhost:8082

localhost:8082> ?list
Name     Abbr     ArgNum     Descr
login     l         1        login(username:String) : String
login     l         2        login(username:String, password:String) : String
login-as  la        2        loginAs(username:String, tenantAdmin:String) : String
login-as  la        3        loginAs(username:String, tenantAdmin:String, tenantAdminPassword:String) : String
print     p         0         print() : String
localhost:8082> login david@monahan.com david
----------------------------------------------------------------------------------------
        ID  | david
        URL | http://localhost:8082/frevvo/web/tn/monahan.com/api/user/david
    UPDATED | 2011-08-05T09:52:45.510-04:00
       NAME | david
DESCRIPTION | null
----------------------------------------------------------------------------------------

After you've logged in, use ?list to display commands you can use in the server. For example, you can use apps to work with the projects on the server.

localhost:8082/david@monahan.com> ?list

Name     Abbr     ArgNum     Descr
apps                0        SELECT apps for this user (e.g. 'apps')
subs                0        SELECT subs for this user (e.g. 'subs') you
tasks               0        SELECT tasks for this user (e.g. 'tasks')
themes              0        SELECT themes for this user (e.g. 'themes')
link      l         1        OPEN a link in the browser (e.g. 'link {link#}')
descr     d         1        UPDATE this entry's description (e.g. 'descr {newDescription}')
links     l         0        SHOW all entry links (e.g. 'links')
links     li        1        SHOW feed links for given rel attr (e.g. 'links {relAttr}')
name      n         1        UPDATE this entry's name (e.g. 'name {newName}')
print     p         0        PRINT this entry (e.g. 'print')
delete    d         0        DELETE this entry (e.g. 'delete')
refresh   r         0        REFRESH this entry (e.g. 'refresh')

The frevvo UI displays the projects belonging to the user david@monahan.com on the projects home page.

The apps command displays a list of the projects in the tenant on the server — DTM July 2011'and DTM August 2011 in this example.

localhost:8082/david@monahan.com> apps
----------------------------------------------------------------------------------------
URL ! http://localhost:8082/frevvo/web/tn/monahan.com/api/apps
    # | NAME                                   | DESCRIPTION
1 | DTM July 2011                              | Group of test forms created by DTM.
2 | DTM August 2011                            | Forms started in August.
----------------------------------------------------------------------------------------

Now that you're in apps (../monahan.com/api/apps), use the ?list command to see what you can do.

localhost:8082/david@monahan.com/apps> ?list
Name    Abbr     ArgNum     Descr
up                 1        UPLOAD an application (e.g. 'up /var/contacts_apps.zip')
down               0        DOWNLOAD ALL applications into temp folder (e.g.: 'download')
link     l         1        OPEN a link in the browser (e.g. 'openLink {link#}')
links    li        1        SHOW feed links for given rel attr (e.g. 'links {relAttr}')
links    l         0        SHOW all feed links (e.g. 'links')
next     n         0        NEXT feed page (e.g. 'next')
prev     p         0        PREVIOUS feed page (e.g. 'previous')
print    pr        0        PRINT current feed (e.g.: 'print')
delete   d         1        DELETE an entry (e.g. 'delete {entry#}')
create   c         1        CREATE a new entry (e.g.: 'create {name}')
refresh  r         0        REFRESH current feed (e.g.: 'refresh')
select   s         1        SELECT an entry (e.g.: 'entry {entry#}')

Downloading and Uploading Projects

You can use the apps > down and up commands to download projects to a local drive and upload them to the frevvo server.

Download

In the frevvo UI, you can download projects individually, and select the destination directory.

In this example, down downloads all the projects in the tenant to a directory on the local machine. Since down takes no arguments, the target directory depends on your local machine settings.

To download a single project, you must first select it. See the Downloading and Uploading a Form/Workflow topic for instructions for selecting a project.

localhost:8082/david@monahan.com/apps> down

Downloaded 2 application(s):
        Downloaded application DTM July 2011: C:\DOCUME~1\esposito\LOCALS~1\Temp\DTMJuly2011_8805120088410548632_app.zip
        Downloaded application DTM August 2011: C:\DOCUME~1\esposito\LOCALS~1\Temp\DTMAugust2011_7848214203496988467_app.zip

Source Code Example

Java Docs

Upload

In the frevvo UI, you can upload projects from the projects page.

In this example, up uploads a single project into the tenant. Note that we moved the ZIP files we downloaded in the previous step to a different directory before using up.

localhost:8082/david@monahan.com/apps> up d:\downloads\DTMAugust2011_7848214203496988467_app.zip
-----------------------------------------------------------------------------------------
                ID | _5Crikb-LEeCP198_WwQSNw!david
               URL | http://localhost:8082/frevvo/web/tn/monahan.com/api/app/_5Crikb-LEeCP198_WwQSNw!david
           UPDATED | 2011-08-05T15:48:41.218-04:00   
              NAME | DTM August 2011
       DESCRIPTION | Forms started in August.
-----------------------------------------------------------------------------------------
localhost:8082/david@monahan.com/apps/DTM August 2011>

After the upload, the command prompt now includes the name of the uploaded project (''../apps/DTM August 2011''). Use the ?list command to see what you can do with the project.

Source Code Example 

Java Docs

Downloading and Uploading a Form/Workflow

You can use the forms > down and up commands to download forms and workflows to a local drive and upload them to the frevvo server.

Before you can use the commands, you have to select the project whose forms you want to work with. In this example, we use the apps command to list the projects in the tenant, and then select to select the project we want (e.g., select 1 — select the first project in the list).

localhost:8082/david@monahan.com> apps
-----------------------------------------------------------------------------------------
URL ! http://localhost:8082/frevvo/web/tn/monahan.com/api/apps
    # | NAME                                 | DESCRIPTION
    1 | DTM July 2011                        | Group of test forms created by DTM.
    2                                        | DTM August 2011 | Forms started in August.
-----------------------------------------------------------------------------------------
localhost:8082/david@monahan.com/apps> ?list

Name     Abbr    ArgNum     Descr
up                  1       UPLOAD an application (e.g. 'up /var/contacts_apps.zip')
...
...
...
select    s         1       SELECT an entry (e.g.: 'entry {entry#}')
localhost:8082/david@monahan.com/apps> select 1
-----------------------------------------------------------------------------------------
                     ID | _W0jPga4rEeCMGZK99v93jw!david
                    URL | http://localhost:8082/frevvo/web/tn/monahan.com/api/app/_W0jPga4rEeCMGZK99v93jw!david
                UPDATED | 2011-08-08T09:00:41.319-04:00
                   NAME | DTM July 2011
            DESCRIPTION | Group of test forms created by DTM.
-----------------------------------------------------------------------------------------
localhost:8082/david@monahan.com/apps/DTM July 2011>

The command prompt now includes the selected project — DTM July 2011'. Use the forms command to see a list of the forms and workflows in the project, and then use ?list to see what you can do with them.

localhost:8082/david@monahan.com/apps/DTM July 2011> forms
-----------------------------------------------------------------------------------------
URL ! http://localhost:8082/frevvo/web/tn/monahan.com/api/formtypes
    # | UPDATED                    | KIND | READONLY | VISIBILITY   | NAME
    1 | 2011-07-25T14:31:47.118    | FORM | false    | PUBLICTENANT | Address Book
    2 | 2011-07-15T10:51:30.137    | FORM | false    | PUBLICTENANT | TitleDepartment
    3 | 2011-07-18T17:04:13.255    | FORM | false    | PUBLICTENANT | Dinner Selections
    4 | 2011-07-25T16:24:51.003    | FLOW | false    | PRIVATE      | Flow 42
-----------------------------------------------------------------------------------------
localhost:8082/david@monahan.com/apps/DTM July 2011/forms> ?list
Name     Abbr     ArgNum     Descr
up                  1        UPLOAD an application (e.g. 'upload /var/contacts_apps.zip')
down                0        DOWNLOAD ALL forms into temp folder (e.g.: 'down')
link      l         1        OPEN a link in the browser (e.g. 'openLink {link#}')
links     li        1        SHOW feed links for given rel attr (e.g. 'links {relAttr}')
links     l         0        SHOW all feed links (e.g. 'links')
next      n         0        NEXT feed page (e.g. 'next')
prev      p         0        PREVIOUS feed page (e.g. 'previous')
print     pr        0        PRINT current feed (e.g.: 'print')
delete    d         1        DELETE an entry (e.g. 'delete {entry#}')
create    c         1        CREATE a new entry (e.g.: 'create {name}')
refresh   r         0        REFRESH current feed (e.g.: 'refresh')
select    s         1        SELECT an entry (e.g.: 'entry {entry#}')

Download

As with downloading projects, in the frevvo UI, you can download individual forms and workflows and select the destination directory when you're editing a project on the projects home page.

In this example, down downloads all the forms and workflows in the tenant to a directory on the local machine. You can't choose which forms to download, and since down takes no arguments, the target directory depends on your local machine settings. Since the command downloads

localhost:8082/david@monahan.com/apps/DTM July 2011/forms> down

Downloaded 4 formtypes(s):
        Downloaded formtype AddressBook : C:\DOCUME~1\esposito\LOCALS~1\Temp\AddressBook_4797270872242921600_form.zip
        Downloaded formtype TitleDepartment : C:\DOCUME~1\esposito\LOCALS~1\Temp\TitleDepartment_3726241829360563162_form.zip
        Downloaded formtype DinnerSelections : C:\DOCUME~1\esposito\LOCALS~1\Temp\DinnerSelections_2704862938519552036_form.zip
        Downloaded formtype Flow42 : C:\DOCUME~1\esposito\LOCALS~1\Temp\Flow42_105859113596495447_form.zip

localhost:8082/david@monahan.com/apps/DTM July 2011/forms> 

Source Code Example

Java Docs

Upload

As with uploading projects, in the frevvo UI, you can upload forms and workflows from the projects page when you're editing a project.

In this example, up uploads a single form — the ''TitleDepartment'' form — into the tenant. Note that we moved the ZIP files we downloaded in the previous step to a different directory before using '''up'''.

localhost:8082/david@monahan.com/apps/DTM July 2011/forms> up d:\downloads\TitleDepartment_3726241829360563162_form.zip
-----------------------------------------------------------------------------------------
                              ID | _hEahgK5GEeCMGZK99v93jw!_W0jPga4rEeCMGZK99v93jw!david
                             URL | http://localhost:8082/frevvo/web/tn/monahan.com/api/formtype/_hEahgK5GEeCMGZK99v93jw!_W0jPga4rEeC MGZK99v93jw!david
                         UPDATED | 2011-08-08T11:29:18.522
                            NAME | TitleDepartment
                     DESCRIPTION | Edit the form to change this description.
                            KIND | FORM
                        READONLY | false
                      VISIBILITY | PUBLICTENANT
-----------------------------------------------------------------------------------------
localhost:8082/david@monahan.com/apps/DTM July 2011/forms/TitleDepartment>

After the upload, the command prompt now includes the name of the uploaded form (''../forms/TitleDepartment'').

Source Code Example

Java Doc

Creating a Form/Workflow

You can use the forms> create command to create a new form or a workflow. You first select the project to which you want to add the new form, list its forms, and then create the form.


localhost:8082/david@monahan.com> apps
-----------------------------------------------------------------------------------------
URL ! http://localhost:8082/frevvo/web/tn/monahan.com/api/apps
    # | NAME                                 | DESCRIPTION
    1 | DTM July 2011                        | Group of test forms created by DTM.
    2 | DTM August 2011                      | Forms started in August.
-----------------------------------------------------------------------------------------
localhost:8082/david@monahan.com/apps> select 2
-----------------------------------------------------------------------------------------
            ID | _5Crikb-LEeCP198_WwQSNw!david
           URL | http://localhost:8082/frevvo/web/tn/monahan.com/api/app/_5Crikb-LEeCP198_WwQSNw!david
       UPDATED | 2011-08-10T10:22:56.851-04:00
          NAME | DTM August 2011
   DESCRIPTION | Forms started in August.
-----------------------------------------------------------------------------------------
localhost:8082/david@monahan.com/apps/DTM August 2011> forms
-----------------------------------------------------------------------------------------
URL ! http://localhost:8082/frevvo/web/tn/monahan.com/api/formtypes
    # | UPDATED                 | KIND | READONLY | VISIBILITY | NAME
    1 | 2011-08-05T13:54:58.628 | FORM | false    | PRIVATE    | Contact Form
    2 | 2011-08-09T15:29:47.477 | FORM | false    | PRIVATE    | NewForm
    3 | 2011-08-09T15:56:23.552 | FORM | false    | PRIVATE    | LodgingMeals
-----------------------------------------------------------------------------------------
localhost:8082/david@monahan.com/apps/DTM August 2011/forms> create 'TestForm'
-----------------------------------------------------------------------------------------
            ID | _X9B3YMNcEeCRfoJ9kSWZ1Q!_5Crikb-LEeCP198_WwQSNw!david
           URL | http://localhost:8082/frevvo/web/tn/monahan.com/api/formtype/_X9B3YMNcEeCRfoJ9kSWZ1Q!_5Crikb-LEeC P198_WwQSNw!david
       UPDATED | 2011-08-10T10:23:53.442
          NAME | TestForm
   DESCRIPTION | Edit the form to change this description.
          KIND | FORM
      READONLY | false
    VISIBILITY | PRIVATE
-----------------------------------------------------------------------------------------
localhost:8082/david@monahan.com/apps/DTM August 2011/forms/TestForm>

The command prompt includes the new form name (''../forms/TestForm>''), so you can Downloading and Uploading a Form/Workflow from the command line at this point.

Source Code Example