Skip to content

Commit

Permalink
MARP-1454 Introduce new UI demo (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndkhanh-axonivy authored Dec 4, 2024
1 parent cfd9dad commit fc63c0a
Show file tree
Hide file tree
Showing 20 changed files with 900 additions and 11 deletions.
32 changes: 32 additions & 0 deletions docuware-connector-demo/cms/cms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,42 @@ Dialogs:
Title: DocuWare Demo
UploadMessageFailed: Upload doc to Docuware failed
UploadMessageOK: Upload doc to Docuware successful
DocuWareDemoUI:
Title: DocuWare Demo UI
ContentTitle: 'Documents in {0}'
DocumentTable:
IdHeaderText: Id
ContentTypeHeaderText: Content Type
TitleHeaderText: Title
ActionColumn:
HeaderText: Action
ViewDocumentBtnTitle: View Document
EditPropertiesBtnTitle: Edit Properties
DeleteDocumentBtnTitle: Delete Document
PropertyTable:
IndexHeaderText: Index
FieldNameHeaderText: Field Name
UpdateValueHeaderText: Update Value
Dialog:
DeleteHeader: Delete Document
DeleteMessage: Are you sure you want to delete this document?
ViewHeader: Document Preview
EditHeader: Edit Document Properties
SuccessEditMessage: Update completed successfully!
FailedEditMessage: Update unsuccessful!
Labels:
CabinetId: 'Cabinet Id: {0}'
Close: Close
FileCabinets: File Cabinets
Organizations: Organizations
Result: Result
Upload: Upload
NoRecordsFound: No records found. Please try a different search.
Cancel: Cancel
Save: Save
Success: Success
Failed: Failed
'YES':
name: 'Yes'
'NO':
name: 'No'
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ dialog com.docuware.dev.schema._public.services.platform.Dialog #field
error ch.ivyteam.ivy.bpm.error.BpmError #field
configuration com.axonivy.connector.docuware.connector.DocuWareEndpointConfiguration #field
properties List<com.axonivy.connector.docuware.connector.DocuWareProperty> #field
cabinetId String #field
organizationId String #field
documentId String #field
documents java.util.List<com.docuware.dev.schema._public.services.platform.Document> #field
164 changes: 163 additions & 1 deletion docuware-connector-demo/processes/DocuWareDemo.p.json
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@
{ "name" : "configuration", "type" : "com.axonivy.connector.docuware.connector.DocuWareEndpointConfiguration" }
],
"map" : {
"param.file" : "com.axonivy.connector.docuware.connector.demo.DocuWareDemoService.exportFromCMS(\"/Files/uploadSample\", \"pdf\")",
"param.file" : "com.axonivy.connector.docuware.connector.demo.service.DocuWareDemoService.exportFromCMS(\"/Files/uploadSample\", \"pdf\")",
"param.indexFields" : "in.properties",
"param.configuration.fileCabinetId" : "in.configuration.fileCabinetId"
}
Expand Down Expand Up @@ -974,5 +974,167 @@
"visual" : {
"at" : { "x" : 1312, "y" : 768 }
}
}, {
"id" : "f51",
"type" : "RequestStart",
"name" : "viewAndEditDocument.ivp",
"config" : {
"callSignature" : "viewAndEditDocument",
"input" : {
"map" : {
"out.cabinetId" : "ivy.var.docuwareConnector_filecabinetid",
"out.organizationId" : "ivy.var.docuwareConnector_organization"
}
},
"outLink" : "viewAndEditDocument.ivp",
"startDescription" : "UI for viewing or editing document",
"startName" : "DocuWare View/Edit Document",
"case" : { }
},
"visual" : {
"at" : { "x" : 80, "y" : 880 }
},
"connect" : { "id" : "f91", "to" : "f84" }
}, {
"id" : "f69",
"type" : "TaskEnd",
"visual" : {
"at" : { "x" : 1120, "y" : 880 }
}
}, {
"id" : "f74",
"type" : "RestClientCall",
"name" : [
"Load",
"Organizations"
],
"config" : {
"path" : "/Organizations",
"clientId" : "02d1eec1-32e9-4316-afc3-793448486203",
"clientErrorCode" : "ivy:error:rest:client",
"statusErrorCode" : "ivy:error:rest:client",
"responseMapping" : {
"out.organizationId" : "result.getOrganization().get(0).getId()"
},
"resultType" : "com.docuware.dev.schema._public.services.platform.Organizations"
},
"visual" : {
"at" : { "x" : 280, "y" : 880 }
},
"connect" : { "id" : "f98", "to" : "f81" }
}, {
"id" : "f81",
"type" : "RestClientCall",
"name" : "Get FileCabinets By Org",
"config" : {
"path" : "/FileCabinets",
"clientId" : "02d1eec1-32e9-4316-afc3-793448486203",
"clientErrorCode" : "ivy:error:rest:client",
"queryParams" : {
"orgid" : "in.organizationId"
},
"statusErrorCode" : "ivy:error:rest:client",
"responseMapping" : {
"out.cabinetId" : "result.getFileCabinet().get(0).getId()"
},
"resultType" : "com.docuware.dev.schema._public.services.platform.FileCabinets"
},
"visual" : {
"at" : { "x" : 456, "y" : 880 }
},
"connect" : { "id" : "f92", "to" : "f83" }
}, {
"id" : "f83",
"type" : "RestClientCall",
"name" : [
"Query",
"Documents"
],
"config" : {
"path" : "/FileCabinets/{FileCabinetId}/Documents",
"clientId" : "02d1eec1-32e9-4316-afc3-793448486203",
"clientErrorCode" : "ivy:error:rest:client",
"queryParams" : {
"q" : "",
"fields" : "",
"sortOrder" : ""
},
"statusErrorCode" : "ivy:error:rest:client",
"responseMapping" : {
"out.documents" : "result.items.getItem()"
},
"templateParams" : {
"FileCabinetId" : "in.cabinetId"
},
"resultType" : "com.docuware.dev.schema._public.services.platform.DocumentsQueryResult"
},
"visual" : {
"at" : { "x" : 632, "y" : 880 }
},
"connect" : { "id" : "f93", "to" : "f89" }
}, {
"id" : "f84",
"type" : "Alternative",
"name" : "Check variables exist",
"visual" : {
"at" : { "x" : 160, "y" : 880 },
"labelOffset" : { "x" : 16, "y" : -16 }
},
"connect" : [
{ "id" : "f97", "to" : "f83", "via" : [ { "x" : 160, "y" : 816 }, { "x" : 640, "y" : 816 } ], "label" : {
"name" : "Already has cabinetId",
"segment" : 0.5,
"offset" : { "x" : 241, "y" : -26 }
}, "condition" : "org.apache.commons.lang3.StringUtils.isNotBlank(in.cabinetId)" },
{ "id" : "f90", "to" : "f81", "via" : [ { "x" : 160, "y" : 944 }, { "x" : 456, "y" : 944 } ], "label" : {
"name" : "Already has organizationId",
"segment" : 0.5,
"offset" : { "x" : 145, "y" : 30 }
}, "condition" : "org.apache.commons.lang3.StringUtils.isNotBlank(in.organizationId)" },
{ "id" : "f96", "to" : "f74" }
]
}, {
"id" : "f87",
"type" : "DialogCall",
"name" : "DocuWareDemoUI",
"config" : {
"dialogId" : "com.axonivy.connector.docuware.connector.demo.DocuWareDemoUI",
"startMethod" : "start(com.docuware.dev.schema._public.services.platform.FileCabinet,List<com.docuware.dev.schema._public.services.platform.Document>)",
"call" : {
"params" : [
{ "name" : "fileCabinet", "type" : "com.docuware.dev.schema._public.services.platform.FileCabinet" },
{ "name" : "documents", "type" : "List<com.docuware.dev.schema._public.services.platform.Document>" }
],
"map" : {
"param.fileCabinet" : "in.cabinet",
"param.documents" : "in.documents"
}
}
},
"visual" : {
"at" : { "x" : 984, "y" : 880 }
},
"connect" : { "id" : "f100", "to" : "f69" }
}, {
"id" : "f89",
"type" : "RestClientCall",
"name" : "Read Cabinet",
"config" : {
"path" : "/FileCabinets/{FileCabinetId}",
"clientId" : "02d1eec1-32e9-4316-afc3-793448486203",
"clientErrorCode" : "ivy:error:rest:client",
"statusErrorCode" : "ivy:error:rest:client",
"responseMapping" : {
"out.cabinet" : "result"
},
"templateParams" : {
"FileCabinetId" : "in.cabinetId"
},
"resultType" : "com.docuware.dev.schema._public.services.platform.FileCabinet"
},
"visual" : {
"at" : { "x" : 808, "y" : 880 }
},
"connect" : { "id" : "f101", "to" : "f87" }
} ]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.axonivy.connector.docuware.connector.demo.enums;

public enum ItemType {
DECIMAL("Decimal"), STRING("String"), INT("Int");

private final String value;

private ItemType(String value) {
this.value = value;
}

public String getValue() {
return value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.axonivy.connector.docuware.connector.demo.managedbean;

import java.io.Serializable;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;

import com.axonivy.connector.docuware.connector.DocuWareProperty;
import com.axonivy.connector.docuware.connector.demo.enums.ItemType;

import ch.ivyteam.ivy.environment.Ivy;

@ManagedBean
@ViewScoped
public class DocuWareDemoBean implements Serializable {

private static final long serialVersionUID = 4548574141754643263L;

private String documentUrl;
private final String DOCUMENT_URL_FORMAT = "https://%s/DocuWare/Platform/WebClient/Client/Document?did=%s&fc=%s";

public void buildDocumentUrl(String documentId, String fileCabinetId) {
String host = Ivy.var().get("docuwareConnector.host");
this.documentUrl = String.format(DOCUMENT_URL_FORMAT, host, documentId, fileCabinetId);
}

public String getDocumentUrl() {
return documentUrl;
}

public boolean isFieldNameTypeNumber(DocuWareProperty field) {
return field.getItemElementName().equals(ItemType.DECIMAL.getValue())
|| field.getItemElementName().equals(ItemType.INT.getValue());
}

public boolean isFieldNameTypeString(DocuWareProperty field) {
return field.getItemElementName().equals(ItemType.STRING.getValue());
}

public void updateGrowlMessageForEditAction(boolean isUpdateSuccess) {
if (isUpdateSuccess) {
FacesContext.getCurrentInstance().addMessage(null,
new FacesMessage(FacesMessage.SEVERITY_INFO, Ivy.cms().co("/Labels/Success"), Ivy.cms().co(
"/Dialogs/com/axonivy/connector/docuware/connector/demo/DocuWareDemoUI/Dialog/SuccessEditMessage")));
} else {
FacesContext.getCurrentInstance().addMessage(null,
new FacesMessage(FacesMessage.SEVERITY_ERROR, Ivy.cms().co("/Labels/Failed"), Ivy.cms().co(
"/Dialogs/com/axonivy/connector/docuware/connector/demo/DocuWareDemoUI/Dialog/FailedEditMessage")));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.axonivy.connector.docuware.connector.demo;
package com.axonivy.connector.docuware.connector.demo.service;

import java.io.FileOutputStream;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
},
"resultType" : "com.docuware.dev.schema._public.services.platform.Organizations",
"responseCode" : [
"import com.axonivy.connector.docuware.connector.demo.DocuWareDemoService;",
"import com.axonivy.connector.docuware.connector.demo.service.DocuWareDemoService;",
"",
"out.result = DocuWareDemoService.get().getLog(response, result);"
]
Expand Down Expand Up @@ -148,7 +148,7 @@
},
"resultType" : "com.docuware.dev.schema._public.services.platform.FileCabinets",
"responseCode" : [
"import com.axonivy.connector.docuware.connector.demo.DocuWareDemoService;",
"import com.axonivy.connector.docuware.connector.demo.service.DocuWareDemoService;",
"",
"out.result = DocuWareDemoService.get().getLog(response, result);"
]
Expand Down Expand Up @@ -177,7 +177,7 @@
"import org.apache.http.HttpStatus;",
"import javax.faces.application.FacesMessage;",
"import javax.faces.context.FacesContext;",
"import com.axonivy.connector.docuware.connector.demo.DocuWareDemoService;",
"import com.axonivy.connector.docuware.connector.demo.service.DocuWareDemoService;",
"",
"out.result = DocuWareDemoService.get().getLog(response, result);",
"FacesMessage message;",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<richDialogDescriptor>
<property>
<name>viewTechnology</name>
<value>JSF</value>
</property>
</richDialogDescriptor>
Loading

0 comments on commit fc63c0a

Please sign in to comment.