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 theG2Config
interface 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 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.void
clearLastException()
Clears the information about the last error the system received.int
close(long configHandle)
Closes the in-memory configuration associated with the specified config handle and cleans up system resources.int
create(Result<Long> configHandle)
Creates a new in-memory configuration using the default template and sets the specifiedResult
parameter with the value of the configuration handle for working with it.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.int
destroy()
Uninitializes the G2 config API and cleans up system resources.String
getLastException()
Returns a string about the last error the system received.int
getLastExceptionCode()
Returns the exception code of the last error the system received.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.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 specifiedStringBuffer
describing the data sources from the configuration.int
load(String jsonConfig, Result<Long> configHandle)
Creates a new in-memory configuration using the specified JSON text and sets the specifiedResult
parameter with the value of the configuration handle for working with it.int
save(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:
init
in 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 specifiedResult
parameter 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 specifiedResult
parameter 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:
save
in interfaceG2Config
- Parameters:
configHandle
- The configuration handle to export the JSON text from.response
- TheStringBuffer
to 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 specifiedStringBuffer
describing 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:
listDataSources
in interfaceG2Config
- Parameters:
configHandle
- The config handle identifying the in-memory configuration to close.response
- TheStringBuffer
to 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:
addDataSource
in interfaceG2Config
- Parameters:
configHandle
- The config handle identifying the in-memory configuration to close.inputJson
- The JSON text describing the data source to create.response
- TheStringBuffer
to 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:
deleteDataSource
in 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:
getLastException
in 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:
getLastExceptionCode
in interfaceG2Fallible
- Returns:
- An error code
-
clearLastException
public void clearLastException()
Clears the information about the last error the system received.- Specified by:
clearLastException
in interfaceG2Fallible
-
-