Package com.senzing.g2.engine
Class G2ConfigJNI
- java.lang.Object
-
- com.senzing.g2.engine.G2ConfigJNI
-
- All Implemented Interfaces:
G2Config,G2Fallible
public class G2ConfigJNI extends Object implements G2Config
Implements theG2Configinterface to call the native implementations of the functions.
-
-
Constructor Summary
Constructors Constructor Description G2ConfigJNI()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intaddDataSource(long configHandle, String inputJson, StringBuffer response)Adds a data source described by the specified JSON to the in-memory configuration associated with the specified config handle.voidclearLastException()Clears the information about the last error the system received.intclose(long configHandle)Closes the in-memory configuration associated with the specified config handle and cleans up system resources.intcreate(Result<Long> configHandle)Creates a new in-memory configuration using the default template and sets the specifiedResultparameter with the value of the configuration handle for working with it.intdeleteDataSource(long configHandle, String inputJson)Deletes the data source described by the specified JSON from the in-memory configuration associated with the specified config handle.intdestroy()Uninitializes the G2 config API and cleans up system resources.StringgetLastException()Returns a string about the last error the system received.intgetLastExceptionCode()Returns the exception code of the last error the system received.intinit(String moduleName, String iniParams, boolean verboseLogging)Initializes the G2 config API with the specified module name, init parameters and flag indicating verbose logging.intlistDataSources(long configHandle, StringBuffer response)Extracts the data sources from the in-memory configuration associated with the specified config handle and writes JSON text to the specifiedStringBufferdescribing the data sources from the configuration.intload(String jsonConfig, Result<Long> configHandle)Creates a new in-memory configuration using the specified JSON text and sets the specifiedResultparameter with the value of the configuration handle for working with it.intsave(long configHandle, StringBuffer response)Writes the JSON text for the configuration associated with the specified configuration handle to the specifiedStringBuffer.
-
-
-
Method Detail
-
init
public int init(String moduleName, String iniParams, boolean verboseLogging)
Initializes the G2 config API with the specified module name, init parameters and flag indicating verbose logging.- Specified by:
initin interfaceG2Config- Parameters:
moduleName- A short name given to this instance of the diagnostic object.iniParams- A JSON string containing configuration parameters.verboseLogging- Enable diagnostic logging which will print a massive amount of information to stdout.- Returns:
- Zero (0) on success and non-zero on failure.
-
destroy
public int destroy()
Uninitializes the G2 config API and cleans up system resources.
-
create
public int create(Result<Long> configHandle)
Creates a new in-memory configuration using the default template and sets the specifiedResultparameter with the value of the configuration handle for working with it.
-
load
public int load(String jsonConfig, Result<Long> configHandle)
Creates a new in-memory configuration using the specified JSON text and sets the specifiedResultparameter with the value of the configuration handle for working with it.
-
save
public int save(long configHandle, StringBuffer response)Writes the JSON text for the configuration associated with the specified configuration handle to the specifiedStringBuffer.- Specified by:
savein interfaceG2Config- Parameters:
configHandle- The configuration handle to export the JSON text from.response- TheStringBufferto write the JSON text to.- Returns:
- Zero (0) on success and non-zero on failure.
-
close
public int close(long configHandle)
Closes the in-memory configuration associated with the specified config handle and cleans up system resources. After calling this method, the configuration handle can no longer be used and becomes invalid.
-
listDataSources
public int listDataSources(long configHandle, StringBuffer response)Extracts the data sources from the in-memory configuration associated with the specified config handle and writes JSON text to the specifiedStringBufferdescribing the data sources from the configuration. The format of the JSON response is as follows:{ "DATA_SOURCES": [ { "DSRC_ID": 1, "DSRC_CODE": "TEST" }, { "DSRC_ID": 2, "DSRC_CODE": "SEARCH" } ] }- Specified by:
listDataSourcesin interfaceG2Config- Parameters:
configHandle- The config handle identifying the in-memory configuration to close.response- TheStringBufferto write the JSON response to.- Returns:
- Zero (0) on success and non-zero on failure.
-
addDataSource
public int addDataSource(long configHandle, String inputJson, StringBuffer response)Adds a data source described by the specified JSON to the in-memory configuration associated with the specified config handle. The response JSON is written to the specifiedStringBuffer. The input JSON has the following format:{ "DSRC_CODE": "CUSTOMERS" }Optionally, you can specify the data source ID:{ "DSRC_CODE": "CUSTOMERS", "DSRC_ID": 410 }The response JSON provides the data source ID of the created data source, which is especially useful if the data source ID was not specified in the input:
{ "DSRC_ID": 410 }- Specified by:
addDataSourcein interfaceG2Config- Parameters:
configHandle- The config handle identifying the in-memory configuration to close.inputJson- The JSON text describing the data source to create.response- TheStringBufferto write the JSON response to.- Returns:
- Zero (0) on success and non-zero on failure.
-
deleteDataSource
public int deleteDataSource(long configHandle, String inputJson)Deletes the data source described by the specified JSON from the in-memory configuration associated with the specified config handle. The input JSON has the following format:{ "DSRC_CODE": "CUSTOMERS" }- Specified by:
deleteDataSourcein interfaceG2Config- Parameters:
configHandle- The config handle identifying the in-memory configuration to close.inputJson- The JSON text describing the data source to delete.- Returns:
- Zero (0) on success and non-zero on failure.
-
getLastException
public String getLastException()
Returns a string about the last error the system received. This is most commonly called after an API function returns an error code (non-zero or NULL)- Specified by:
getLastExceptionin interfaceG2Fallible- Returns:
- An error message
-
getLastExceptionCode
public int getLastExceptionCode()
Returns the exception code of the last error the system received. This is most commonly called after an API function returns an error code (non-zero or NULL)- Specified by:
getLastExceptionCodein interfaceG2Fallible- Returns:
- An error code
-
clearLastException
public void clearLastException()
Clears the information about the last error the system received.- Specified by:
clearLastExceptionin interfaceG2Fallible
-
-