diff --git a/docuware-connector-demo/cms/cms.yaml b/docuware-connector-demo/cms/cms.yaml index f36047d..443d38b 100644 --- a/docuware-connector-demo/cms/cms.yaml +++ b/docuware-connector-demo/cms/cms.yaml @@ -9,6 +9,29 @@ 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 @@ -16,3 +39,12 @@ Labels: 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' \ No newline at end of file diff --git a/docuware-connector-demo/dataclasses/com/axonivy/market/docuware/connector/demo/Data.ivyClass b/docuware-connector-demo/dataclasses/com/axonivy/market/docuware/connector/demo/Data.ivyClass index 212e454..991df58 100644 --- a/docuware-connector-demo/dataclasses/com/axonivy/market/docuware/connector/demo/Data.ivyClass +++ b/docuware-connector-demo/dataclasses/com/axonivy/market/docuware/connector/demo/Data.ivyClass @@ -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 #field +cabinetId String #field +organizationId String #field +documentId String #field +documents java.util.List #field diff --git a/docuware-connector-demo/processes/DocuWareDemo.p.json b/docuware-connector-demo/processes/DocuWareDemo.p.json index c32695d..a23995c 100644 --- a/docuware-connector-demo/processes/DocuWareDemo.p.json +++ b/docuware-connector-demo/processes/DocuWareDemo.p.json @@ -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" } @@ -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)", + "call" : { + "params" : [ + { "name" : "fileCabinet", "type" : "com.docuware.dev.schema._public.services.platform.FileCabinet" }, + { "name" : "documents", "type" : "List" } + ], + "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" } } ] } \ No newline at end of file diff --git a/docuware-connector-demo/src/com/axonivy/connector/docuware/connector/demo/enums/ItemType.java b/docuware-connector-demo/src/com/axonivy/connector/docuware/connector/demo/enums/ItemType.java new file mode 100644 index 0000000..667b530 --- /dev/null +++ b/docuware-connector-demo/src/com/axonivy/connector/docuware/connector/demo/enums/ItemType.java @@ -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; + } +} diff --git a/docuware-connector-demo/src/com/axonivy/connector/docuware/connector/demo/managedbean/DocuWareDemoBean.java b/docuware-connector-demo/src/com/axonivy/connector/docuware/connector/demo/managedbean/DocuWareDemoBean.java new file mode 100644 index 0000000..858947a --- /dev/null +++ b/docuware-connector-demo/src/com/axonivy/connector/docuware/connector/demo/managedbean/DocuWareDemoBean.java @@ -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"))); + } + } +} diff --git a/docuware-connector-demo/src/com/axonivy/connector/docuware/connector/demo/DocuWareDemoService.java b/docuware-connector-demo/src/com/axonivy/connector/docuware/connector/demo/service/DocuWareDemoService.java similarity index 97% rename from docuware-connector-demo/src/com/axonivy/connector/docuware/connector/demo/DocuWareDemoService.java rename to docuware-connector-demo/src/com/axonivy/connector/docuware/connector/demo/service/DocuWareDemoService.java index 8961d74..d4d2a1e 100644 --- a/docuware-connector-demo/src/com/axonivy/connector/docuware/connector/demo/DocuWareDemoService.java +++ b/docuware-connector-demo/src/com/axonivy/connector/docuware/connector/demo/service/DocuWareDemoService.java @@ -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; diff --git a/docuware-connector-demo/src_hd/com/axonivy/connector/docuware/connector/demo/DocuWareDemo/DocuWareDemoProcess.p.json b/docuware-connector-demo/src_hd/com/axonivy/connector/docuware/connector/demo/DocuWareDemo/DocuWareDemoProcess.p.json index 49ab826..a740d15 100644 --- a/docuware-connector-demo/src_hd/com/axonivy/connector/docuware/connector/demo/DocuWareDemo/DocuWareDemoProcess.p.json +++ b/docuware-connector-demo/src_hd/com/axonivy/connector/docuware/connector/demo/DocuWareDemo/DocuWareDemoProcess.p.json @@ -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);" ] @@ -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);" ] @@ -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;", diff --git a/docuware-connector-demo/src_hd/com/axonivy/connector/docuware/connector/demo/DocuWareDemoUI/DocuWareDemoUI.rddescriptor b/docuware-connector-demo/src_hd/com/axonivy/connector/docuware/connector/demo/DocuWareDemoUI/DocuWareDemoUI.rddescriptor new file mode 100644 index 0000000..ae605f0 --- /dev/null +++ b/docuware-connector-demo/src_hd/com/axonivy/connector/docuware/connector/demo/DocuWareDemoUI/DocuWareDemoUI.rddescriptor @@ -0,0 +1,7 @@ + + + + viewTechnology + JSF + + diff --git a/docuware-connector-demo/src_hd/com/axonivy/connector/docuware/connector/demo/DocuWareDemoUI/DocuWareDemoUI.xhtml b/docuware-connector-demo/src_hd/com/axonivy/connector/docuware/connector/demo/DocuWareDemoUI/DocuWareDemoUI.xhtml new file mode 100644 index 0000000..9923178 --- /dev/null +++ b/docuware-connector-demo/src_hd/com/axonivy/connector/docuware/connector/demo/DocuWareDemoUI/DocuWareDemoUI.xhtml @@ -0,0 +1,101 @@ + + + + #{ivy.cms.co('/Dialogs/com/axonivy/connector/docuware/connector/demo/DocuWareDemoUI/Title')} + + +

#{ivy.cms.co('/Dialogs/com/axonivy/connector/docuware/connector/demo/DocuWareDemoUI/ContentTitle', + [data.fileCabinet.name])}

+ + + + + + + + + + + + + + + + +
+ + + + + +
+
+
+
+
+ +
+ + + + + +