Package com.senzing.g2.engine
Class G2ConfigMgrJNI
- java.lang.Object
-
- com.senzing.g2.engine.G2ConfigMgrJNI
-
- All Implemented Interfaces:
G2ConfigMgr
,G2Fallible
public class G2ConfigMgrJNI extends Object implements G2ConfigMgr
Implements theG2Config
interface to call the native implementations of the functions.
-
-
Constructor Summary
Constructors Constructor Description G2ConfigMgrJNI()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
addConfig(String configStr, String configComments, Result<Long> configID)
Adds the configuration described by the specified JSON to the repository with the specified comments and returns the ID of the config in the specifiedResult
object.void
clearLastException()
Clears the information about the last error the system received.int
destroy()
Uninitializes the G2 config manager API.int
getConfig(long configID, StringBuffer response)
Gets the configuration with the specified config ID and writes the JSON text of configuration to the specifiedStringBuffer
.int
getConfigList(StringBuffer response)
Gets the list of saved configuration IDs with their comments and timestamps and writes the JSON text describing the configurations to the specifiedStringBuffer
.int
getDefaultConfigID(Result<Long> configID)
Gets the configuration ID of the default configuration for the repository and sets the value in the specifiedResult
object.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 manager API with the specified module name, init parameters and flag indicating verbose logging.int
replaceDefaultConfigID(long oldConfigID, long newConfigID)
Replaces the current configuration ID of the repository with the specified new configuration ID providing the current configuration ID of the repository is equal to the specified old configuration ID.int
setDefaultConfigID(long configID)
Sets the default configuration for the repository to the specified configuration ID.
-
-
-
Method Detail
-
init
public int init(String moduleName, String iniParams, boolean verboseLogging)
Initializes the G2 config manager API with the specified module name, init parameters and flag indicating verbose logging.- Specified by:
init
in interfaceG2ConfigMgr
- Parameters:
moduleName
- A short name given to this instance of the config manager API.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 manager API.- Specified by:
destroy
in interfaceG2ConfigMgr
- Returns:
- Zero (0) on success and non-zero on failure.
-
addConfig
public int addConfig(String configStr, String configComments, Result<Long> configID)
Adds the configuration described by the specified JSON to the repository with the specified comments and returns the ID of the config in the specifiedResult
object.- Specified by:
addConfig
in interfaceG2ConfigMgr
- Parameters:
configStr
- The JSON text describing the configuration.configComments
- The comments for the configuration.configID
- The configuration ID for the registered config.- Returns:
- Zero (0) on success and non-zero on failure.
-
getConfig
public int getConfig(long configID, StringBuffer response)
Gets the configuration with the specified config ID and writes the JSON text of configuration to the specifiedStringBuffer
.- Specified by:
getConfig
in interfaceG2ConfigMgr
- Parameters:
configID
- The configuration ID of the configuration to retrieve.response
- TheStringBuffer
to write the JSON text of the configuration to.- Returns:
- Zero (0) on success and non-zero on failure.
-
getConfigList
public int getConfigList(StringBuffer response)
Gets the list of saved configuration IDs with their comments and timestamps and writes the JSON text describing the configurations to the specifiedStringBuffer
. The format of the response is:{ "CONFIGS": [ { "CONFIG_ID": 12345678912345, "SYS_CREATE_DT": "2021-03-25 18:35:00.743", "CONFIG_COMMENTS": "Added EMPLOYEES data source." }, { "CONFIG_ID": 23456789123456, "SYS_CREATE_DT": "2021-02-08 23:27:09.876", "CONFIG_COMMENTS": "Added CUSTOMERS data source." }, { "CONFIG_ID": 34567891234567, "SYS_CREATE_DT": "2021-02-08 23:27:05.212", "CONFIG_COMMENTS": "Initial Config" }, . . . ] }
- Specified by:
getConfigList
in interfaceG2ConfigMgr
- Parameters:
response
- TheStringBuffer
to write the JSON text of the configuration list to.- Returns:
- Zero (0) on success and non-zero on failure.
-
setDefaultConfigID
public int setDefaultConfigID(long configID)
Sets the default configuration for the repository to the specified configuration ID.- Specified by:
setDefaultConfigID
in interfaceG2ConfigMgr
- Parameters:
configID
- The configuration ID to set as the default configuration.- Returns:
- Zero (0) on success and non-zero on failure.
-
getDefaultConfigID
public int getDefaultConfigID(Result<Long> configID)
Gets the configuration ID of the default configuration for the repository and sets the value in the specifiedResult
object.- Specified by:
getDefaultConfigID
in interfaceG2ConfigMgr
- Parameters:
configID
- TheResult
object on which to set the default configuration ID.- Returns:
- Zero (0) on success and non-zero on failure.
-
replaceDefaultConfigID
public int replaceDefaultConfigID(long oldConfigID, long newConfigID)
Replaces the current configuration ID of the repository with the specified new configuration ID providing the current configuration ID of the repository is equal to the specified old configuration ID. If the current configuration ID is not the same as the specified old configuration ID then this method fails to replace the default configuration ID with the new value.- Specified by:
replaceDefaultConfigID
in interfaceG2ConfigMgr
- Parameters:
oldConfigID
- The configuration ID that is believed to be the current default configuration ID.newConfigID
- The new configuration ID for the repository.- 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
-
-