...
- LoginAs and session management using API.
- Upload of a sample Tutorial Application into a designer account.
FormTypeFeed:Initialization of a form with XML data, Attachment and Wet Signature
- List ApplicationsProjects, Forms and Flows Workflows
- Raw and Pop-Up links to use Forms/Flows Workflows
- Edit link to edit Forms/Flows Workflows in design mode
- View Submissions link to list all Form/Flow Workflow Submissions
- TaskFeed: embed task list
- SubmissionFeed: Logout of user account using API
- List of all Form/Flow Workflow submissions
- Link to Edit each submission
- Links to submission XMLs
- Link to submission print PDF
- Links to wet signatures in each submission
- Links to uploaded attachments in each submission
...
The formtypes.jsp checks if the HTTP session contains a FormService instance with a valid user login. If not, then it redirects to the login.jsp page to create a valid user login:
Code Block FormsService service = (FormsService) session.getAttribute ( "frevvo.forms.service" ); if (service == null) { response.sendRedirect("login.jsp"); return; }
It also gets the user information stored in the user.info attribute of the HTTP session. The ApplicationFeed and FormTypeFeed are available only for designer user logins. We will not retrieve the applications and forms if the current logged in user is not a designer, i.e. alui.designer is false:
Code Block AutoLoginUserInfo alui = (AutoLoginUserInfo) session.getAttribute ( "user.info" ); if(!(alui.designer)){ ...
Next it gets the ApplicationFeed for the current logged in user:
Code Block ApplicationFeed af = service.getFeed(service.getFeedURL(ApplicationFeed.class), ApplicationFeed.class);
Now it will check if the Tutorial Application exists in the current logged in designer user account:
Code Block ApplicationEntry TutorialApp = null; String TutorialAppName = "Tutorial Application"; for (ApplicationEntry appEntry :af.getEntries()) { if (TutorialAppName.equals(appEntry.getTitle().getPlainText())){ TutorialApp = appEntry; break; } else { continue; } }
If the Tutorial Application does not exist then it will upload the application to the designer user account. The application zip file that we are uploading is <frevvo-home>\tomcat\webapps\api\apitutorial\Resources\TutorialApplication_v52_app.zip.
Code Block String EmpInfoFromName = "Employee Information"; if(TutorialApp == null){ String filepath=getServletContext().getRealPath("/apitutorial/Resources/TutorialApplication_v52_app.zip"); InputStream appZipStream = new FileInputStream(filepath); MediaStreamSource appMediaSource = new MediaStreamSource(appZipStream,"application/zip"); ApplicationEntry appEntry = af.insert(appMediaSource);
The default deployment state of the Employee Information form in this uploaded application is DEVELOPMENT. We changed the deploy state of the form to PRODUCTION with the code shown below:
Code Block FormTypeFeed ftFeed = appEntry.getFormTypeFeed(); for (FormTypeEntry empform : ftFeed.getEntries()) { if (EmpInfoFromName.equals(empform.getTitle().getPlainText())){ empform.setDeployState(DeployState.PRODUCTION); empform = empform.update(); empform = empform.getSelf(); break; } else { continue; } } }
List Applications / Forms and
...
Workflows
Once the application is uploaded we now list all the Applications/Forms/Flows Workflows in this user account.
We get the updated ApplicationFeed after the Tutorial Application is uploaded. The application feed contains all the applications in this user account:
Code Block af = service.getFeed(service.getFeedURL(ApplicationFeed.class), ApplicationFeed.class);
Then we iterate over each ApplicationEntry in the ApplicationFeed and from each ApplicationEntry we get the FormTypeFeed which contains the forms and flows workflows in that application:
Code Block String[] types = {"FORM", "FLOW"}; for (ApplicationEntry ae : af.getEntries()) { FormTypeFeed ftf = ae.getFormTypeFeed(); …
We iterate over each FormTypeEntry in the FormTypeFeed twice using the types iterator defined above. Once to collect all the forms and the second time to collect all the flows workflows in that application:
Code Block for (String mytype : types){ for (FormTypeEntry fte : ftf.getEntries()) { if(fte.getKind().contentEquals(mytype)){ …
Then we get the Raw Link, Popup Link and Edit link for the forms/flows workflows from the FormTypeEntry:
Code Block //Get Raw Link String RawLink = fte.getFormTypeLink(null).getHref() + formAction; //Get Popup Link String PopUpLink = fte.getFormTypePopupLink(null).getHref() + formAction; //Get Form Edit Link to edit the form in design mode String EditorLink = fte.getFormTypeEditorLink(null).getHref() + formAction;
Next we check if there are any submissions associated with the form/flowworkflow. If yes, then we get the FormTypeID for the form. Then this FormTypeID is appended as the URL parameter to the showSubmissions.jsp page link. The showSubmission.jsp page will use this FormTypeID to list all the form submissions (See SubmissionFeed):
Code Block if(fte.getSubmissionFeed().getEntries().size() > 0) { String formtypeid = fte.getId().split("!")[0]; String SubmissionsLink = "showSubmissions.jsp?formtypeId=" + formtypeid; ...
...
First the showTaskList.jsp checks if the HTTP session contains a FormService instance with a valid user login. If not, then it redirects to login.jsp page to create a valid user login:
Code Block FormsService service = (FormsService) session.getAttribute ( "frevvo.forms.service" ); if (service == null) { response.sendRedirect("login.jsp?targeturl=showTaskList.jsp"); return; }
Then it gets the TaskFeed for current logged in user:
Code Block TaskFeed tFeed = service.getFeed(service.getFeedURL(TaskFeed.class), TaskFeed.class);
Using the Taskfeed we then get the Link to embed the users Task List. We use the URL Parameters container, center, resize and width to fit the task list to the space available in the embedded page.
Code Block Map<String, Object> params = new HashMap<String, Object>(); params.put("container", true); params.put("center", false); params.put("resize", false); params.put("width", "1500px"); String taskListEmbedURL = tFeed.getTaskListEmbedLink(params).getHref();
List Form /
...
Workflow Submissions
Perform and Submit the saved task in the task list to create a form submission. Click on the Forms/Flows Workflows link in the left menu. You should now see a View Submissions link against the Employee Information form:
...
The showSubmissions.jsp checks if the HTTP session contains a FormService instance with a valid user login. If not, then it redirects to login.jsp page to create a valid user login:
Code Block FormsService service = (FormsService) session.getAttribute ( "frevvo.forms.service" ); if (service == null) { response.sendRedirect("login.jsp?targeturl=showSubmissions.jsp"); return; }
It also gets the user information stored in the user.info attribute of the HTTP session. The SubmissionFeed is available only for designer user login. We will not retrieve the submissions if the current logged in user is not a designer, i.e. alui.designer equals false:
Code Block AutoLoginUserInfo alui = (AutoLoginUserInfo) session.getAttribute ( "user.info" ); if(!(alui.designer)){ ...
Now we create SubmissionQuery q that will be used to retrieve the SubmissionFeed:
Code Block SubmissionQuery q = new SubmissionQuery(service.getFeedURL(SubmissionFeed.class));
We get the FormTypeID that is sent as the URL parameter using request.getParameter( "formtypeId" ) and add it to the SubmissionQuery filter:
Note that if the formtypeId is not passed to the showSubmissions.jsp page (for example when you click on the Submissions link in the left menu) the filter will not be set and submissions for all the forms/flows workflows in the logged in users account will be listed.
Code Block String ftId = request.getParameter( "formtypeId" ); if (ftId != null) q.setFilter("$formTypeId eq " + ftId);
Next we get the SubmissionFeed using the SubmissionQuery:
Code Block SubmissionFeed sFeed = service.getFeed(q, SubmissionFeed.class);
We will iterate over all the SubmissionEntries in the SubmissionFeed:
Code Block for (SubmissionEntry entry : sFeed.getEntries()) { ...
We get these details from each SubmissionEntry:
Link to Edit the submission:
Code Block String SubmissionLink = entry.getFormTypePopupLink(null).getHref() + formAction;
Submission Form Name:
Code Block entry.getTitle().getPlainText()
Submission Last Updated Date:
Code Block entry.getUpdated()
We use the doctypes iterator to iterate over four types of documents in entry.getDocumentLinks():
Code Block String[] doctypes = {"text/xml", "frevvo-snapshot", "frevvo-signature-image", "frevvo-attachment"}; for (String doctype : doctypes){ if(entry.getDocumentLinks().size() > 0) { if(entry.getDocumentLinks().get(i).getType().contains(doctype)){ ...
The four iterations over all entry.getDocumentLinks() collect:
Links to the Submission XMLs:
Code Block if(doctype == "text/xml"){ String XmlName = entry.getDocumentLinks().get(i).getType().substring(entry.getDocumentLinks().get(i).getType().lastIndexOf("=") + 1); String XmlLink = entry.getDocumentLinks().get(i).getHref();
Link to the generated Submission PDF:
Code Block }else if(doctype == "frevvo-snapshot"){ String PDFname = entry.getTitle().getPlainText() + ".PDF"; String PDFLink = entry.getDocumentLinks().get(i).getHref();
Links to the Wet Signature images of the submission:
Code Block }else if(doctype == "frevvo-signature-image"){ String SignatureImageName = entry.getDocumentLinks().get(i).getType().substring(entry.getDocumentLinks().get(i).getType().lastIndexOf("=") + 1); String SignatureImageLink = entry.getDocumentLinks().get(i).getHref();
Links to the uploaded attachments in the submission:
Code Block }else if(doctype == "frevvo-attachment"){ String AttachmentName = entry.getDocumentLinks().get(i).getType().substring(entry.getDocumentLinks().get(i).getType().indexOf("filename=")+10, entry.getDocumentLinks().get(i).getType().indexOf(';', entry.getDocumentLinks().get(i).getType().indexOf("filename="))-1); String AttachmentFileLink = entry.getDocumentLinks().get(i).getHref(); } ...
...