i
Cases
The model class contains properties with their getter and setter methods, while the service class contains operations to be performed on the model.
For example, when downloading the Java sources of the process, if using the "Request Payment" process, a requestPayment.java file is generated with the model methods and also another requestPaymentService.java file with the available service operations.
Model Class Content
A case model contains:
•Model builder.
•Getter and setter methods of the case properties.
•Getter methods to get the related forms.
•Getter methods to get the activities in progress.
•Getter methods to get the process corresponding to the case.
Getter and setter methods of the case properties
The case model class contains a set of getter and setter methods for the case properties.
Operation |
Description |
Parameters |
---|---|---|
getCdCase() |
Gets the identifier of the case. |
|
setCdCase(casenumber) |
Allows to set the case identifier value. |
String casenumber: Case number |
getCdState() |
Gets the state of the case.
Possible values: ACTIVE - Active CANCELLED Cancelled: ENDEDCASE - Ended: |
|
getDsCase() |
Gets the description of the case. |
|
getDtEnded() |
Gets the end date of the case. |
|
getDtExpiration() |
Gets the expiration date of the case. |
|
getDtInitiated() |
Gets the start date of the case. |
|
getPriority() |
Gets the priority of the case.
Possible values: 1 - Urgent 2 - High 3 - Medium 4 - Low |
|
setLastPressedButton(button) |
Allows to set the last button pressed. |
String button: Name of the last button pressed. |
getLastPressedButton() |
Gets the last button pressed. |
|
get + <Form class name> + Entity() |
Gets an instance of the form class related to the process. |
|
getLsVinculatedForms() |
Gets a list of form instances related to the case. |
|
getVinculatedFormByIdEntity(idEntity) |
Gets a form instance related to the case. |
String idEntity: Identifier of the form instance |
getProcess() |
Gets the process corresponding to the case. |
|
getLsExecutedActivities() |
Gets the executed activities of the case. |
|
getLsCurrentActivities() |
Gets the activities in progress of the case. |
Getter method to get the related forms.
Given a case, the values of the form fields related to it can be used, in the same way as if the activities were executed manually.
The model class has a getter method for each form related to the process, with a “get + <Form class name> + Entity()” structure. Once an instance has been retrieved, it is used in the same way as for forms.
Example
If the "Request Payment" process related to the "Payment" and "Report" forms is modeled, the RequestPayment class has the following methods:
•getPaymentEntity(): Gets an instance of the Payment class that corresponds to the "Payment" form related to the case.
•getReportEntity(): Gets an instance of the Payment class that corresponds to the "Payment" form related to the case.
The case cannot have forms associated with the same class name, even if they belong to different applications.
Getter methods to get the activities in progress
Given a case, the list of its activities in progress can be accessed, using the getLsCurrentActivities() case properties method of the model class, which returns a list of "ExecutedActivity" objects with their methods.
Operation |
Description |
Parameters |
---|---|---|
getCdActivity() |
Gets the code of the activity. |
|
getDsNameActivity() |
Gets the name of the activity. |
|
getCdState() |
Gets the state of the activity.
Possible values: EXEC - In execution CANCELLEDACT - Cancelled: ENDEDACT - Ended: |
|
getPriority() |
Gets the activity priority.
Possible values: 1 - Urgent 2 - High 3 - Medium 4 - Low |
|
getDtEnded() |
Gets the end date of the activity. |
|
getDtExpiration() |
Gets the expiration date of the activity. |
|
getDtInitiated() |
Gets the start date of the activity. |
|
getCdUserExec() |
Gets the code of the user that executed the activity. |
|
getCdUserInit() |
Gets the code of the user that started the activity. |
|
getNuDurationSeconds() |
Gets the duration in seconds of the activity execution. |
|
getTpActivity() |
Gets the state of the activity.
Possible values: TP_GATEWAY - Gateway TP_STANDARD - Standard TP_ABSTRACT - Abstract |
|
getTpParticipant() |
Gets the type of participant for the activity.
Possible values: USER - User ORG_UNIT - Organizational Unit ROLE - Role THING - Userthing
|
|
getLsExecutedActions() |
Gets a list of actions executed by the activity. |
Getter method to get the process corresponding to the case.
The process corresponding to a case can be obtained through the getProccess() method of the model class, which returns an instance of the "Process" class with its methods.
Operation |
Description |
Parameters |
---|---|---|
getCdProcess() |
Gets the code of the process. |
|
getCdVersion() |
Gets the version of the process. |
|
getIdApplication() |
Gets the application identifier of the process. |
|
getCdFirstActivity() |
Gets an Activity object with the first process activity, |
|
getDsComment() |
Gets the comment of the process. |
|
getDsDescription() |
Gets the description of the process. |
|
getDsName() |
Gets the name of the process. |
Service Class Content
The service allows the following operations to be performed on the cases:
Operation |
Description |
Parameters |
---|---|---|
startCase(case)
startCase(case, user)
|
Starts a case, executing the initial activity of the related process.
Returns the code of the created case.
|
Case case: Model of the case to start. Related form fields must have values
Case case: Case model with the values assigned to the related form fields
String user: Code of the user that executes the activity. It must be specified when the participant responsible for the activity is a role |
execute(case)
execute(case, user) |
Executes the current activity of a case.
Returns the state of the updated case. |
Case case: Model of the case with assigned case number
Case case: Model of the case with assigned case number
String user: Code of the user that executes the activity. It must be specified when the participant responsible for the activity is a role |
read(case) |
Reads a case. |
Case case: Model of the case with assigned case number |
Examples of Use
The examples use the “Request Payment” process and each example contains the use of the “RequestPayment” model class and the “RequestPaymentService” service class.
In addition, “Request” and “Report” classes are used, which represent models of forms related to the “Request Payment” process.
The examples detail how to start a case, read it, execute its activities, and finish it.
Process Diagram
1.Starting a case
To start the case, the first activity "Fill Request" is executed. The case moves to the “Evaluate Request” activity under the responsibility of “Afarias” user, configured in the “Authorizer” lane
Executing the “Fill Request” activity performs the “Create” operation on the “Request” form with the values assigned to its fields.
An instance of the "RequestPayment" model class is created, in the "Request" form obtained through the getRequestEntity() method, values are assigned to its fields with the corresponding setter methods. The case is started using the "RequestPaymentService" service class with the startCase(myFirstPaymentCase) method.
RequestPayment myFirstPaymentCase = new RequestPayment(); myFirstPaymentCase.getRequestEntity().setAmount(new Double(200));
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); myFirstPaymentCase.getRequestEntity().setDueDate(new Date(format.parse("2020-06-28").getTime())); myFirstPaymentCase.getRequestEntity().setMessage("This is my first payment request .. i need to buy more coffee !!");
RequestPaymentService myService = new RequestPaymentService(getApiClient()); String cdCase = myService.startCase(myFirstPaymentCase);
|
2.Reading the case
An instance of the “RequestPayment” model class is created, it is assigned a case number generated by the startCase(myFirstPaymentCase) method of the “RequestPaymentService” service class, in the previous example.
The case is read with the read(myFirstPaymentCase) method of the "RequestPaymentSercice" service class and the case number.
RequestPayment myPaymentCase = new RequestPayment(); myPaymentCase.setCdCase(cdCase); myPaymentCase = myService.read(myFirstPaymentCase);
|
3.Activity execution defining modeled buttons
The case is in the “Evaluate Request” activity, which has two modeled buttons. The next activity to be executed depends on the button selected, in this example “Approve” is selected. If no button is specified, the modeled flow is followed as default.
The “Approve” button is assigned to the “Request Payment” model class using the corresponding setter method. The “Evaluate Request” activity is executed with execute(myPaymentCase) method of the “RequestPaymentService” service class.
As a result, the case is in the “Fill Report” activity and its state is “ACTIVE”,
myPaymentCase.setLastPresedButton("Approve"); myService.execute(myPaymentCase);
|
4.Activity execution not defining modeled buttons
The case is in the “Fill Report” activity. This activity execution creates the “Report” form. This form has a field called "request" that is related to the "Request" entity.
The “request” field is completed by means of the corresponding setter method, with the identifier of the “Request” entity related to the case, which is obtained by means of the getRequestEntity() method.
The rest of the fields are completed and the “Fill Report” activity is executed with the execute(myPaymentCase) method of the “RequestPaymentService” service class.
The case is sent to the “Request approved” end event and its state is ended.
Integer requestId = myPaymentCase.getRequestEntity().GetRequestId();
myPaymentCase.getReportEntity().setRequest(requestId.toString()); myPaymentCase.getReportEntity().setPaymentMethod("Credit"); myPaymentCase.getReportEntity().setSummary("Filling the report using the SDK."); myService.execute(myPaymentCase);
|