Conga Product Documentation

Welcome to the new doc site. Some of your old bookmarks will no longer work. Please use the search bar to find your desired topic.

Show Page Sections

External Java Class

Reminder:

  • JavaClass allows to implement business rules using a call to an external java class
  • JavaClass can be used to compute any field in the quote header, any column and total cell of the quote spreadsheet
  • On column/total cell computation rules: Java class cannot be used to update (via the API) the quote spreadsheet data
  • JavaClass can be used to define the domain of values of any field in the quote header, any column and total cell of the quote spreadsheet

Information:

The association with the JavaClass is made through the full path of the java class (package + class), therefore each java class must have a unique name within a given quote model.

A standard JavaClass ExtractInformationGrid deployed in the

package com.accesscommerce.cart.runtime.computations allows to retrieve, in a spreadsheet column mapped with an extension field of type BINARY, the content of a Sales Information Grid (SIG) attached to a sales breakdown line which is object to the creation of a quote line or subline.

The table below details the service parameters:

PARAMETER NAME EXPLANATION
Java Class Full name of Java class (package + class) The specified class must implement the "AbstractJavaComputation" interface

Java class type: Protocol/Example

List of values

The Java class must implement the "AbstractJavaComputation" interface which has a public method: String[][] getLVA(ModelCompilation modelC,String lvaName,String languageId,CartController controller Tuple[] parameters)

</**

* Returns a LVA.

* LVA is:

* ID1=VALUE1_FR or VALUE1_US

* ID2=VALUE2_FR or VALUE2_US

* @param modelC The model compilation

* @param lvaName The LVA name

* @param languageId The language id

* @param controller The cart controller

* @param parameters The array of parameters

* @return String[][] with codes and values

* @throws CartException

*/

public String[][] getLVA(ModelCompilation modelC, String lvaName, String languageId, CartController controller, Tuple[]

parameters) throws CartException {

String[][] result = new String[2][2];

result[0][0] = "ID1";

result[1][0] = "ID1";

if (languageId.equals("FR")) {

result[0][1] = "VALUE1_FR";

result[1][1] = "VALUE1_FR";

}

else {

result[0][1] = "VALUE1_US";

result[1][1] = "VALUE1_US";

}

return result;

}

Computation with dependencies

The Java class must implement the "AbstractJavaComputation" interface which has a public method: getDependencies

package com.accesscommerce.cart.runtime.computations;

import java.util.Vector;

import com.accesscommerce.cart.CartController;

import com.accesscommerce.cart.CartDataObject;

import com.accesscommerce.cart.CartException;

import com.accesscommerce.cart.DataEntry;

import com.accesscommerce.cart.model.Tuple;

import com.accesscommerce.cart.model.compile.ModelCompilation;

import cic.CICTools;

/*** This class is one java class computation.

* @author [email protected]

* @version 13-10-2012

*/

public class ExempleJavaClass implements AbstractJavaComputation

{

/*** Constructor */

public ExempleJavaClass() {}

/*** Get dependencies.

* The action is field3 = (field1 + field2).

* So field3 depends on field1 and field2.

* @return The vector of dependencies

*/

public Vector getDependencies()

{

Vector result = new Vector();

result.add("field1");

result.add("field2");

return result;

}

Computation without dependence The Java class must implement the "AbstractJavaComputation" interface which has a public method: execute

/*** WARNING: If the calculation has no dependence,

* Vector getDependencies() public method has to send back an empty vector.

*

* Execute the action end returns the result.

* The action is field3 = (field1 + field2).

*

* @param modelC The model compilation

* @param lineId line id if the computation concerns a cell, else -1

* @param fieldName The field name

* @param columnName The column name

* @param data The cart data object

* @param parameters The array of parameters

*

* @return The new value

* @throws CartException

*/

public String execute(ModelCompilation modelC,int lineId,String fieldName,String columnName,CartDataObject

data,Tuple[] parameters) throws CartException

{

String value1 = data.getFieldByFullName("field1").getValue();

String value2 = data.getFieldByFullName("field2").getValue();

return ""+ (CICTools.parseInt(value1)+CICTools.parseInt(value2));

}