diff --git a/.github/workflows/go-proxy-pull.yaml b/.github/workflows/go-proxy-pull.yaml index 95c8c95..3eea416 100644 --- a/.github/workflows/go-proxy-pull.yaml +++ b/.github/workflows/go-proxy-pull.yaml @@ -16,4 +16,4 @@ jobs: - name: pull new module version uses: andrewslotin/go-proxy-pull-action@v1.1.0 with: - import_path: github.com/senzing-garage/g2-sdk-go-mock + import_path: github.com/senzing-garage/sz-sdk-go-mock diff --git a/.project b/.project index 4b27622..e4dcba6 100644 --- a/.project +++ b/.project @@ -1,4 +1,4 @@ - g2-sdk-go-mock + sz-sdk-go-mock diff --git a/CHANGELOG.md b/CHANGELOG.md index 2993fc9..8c99bdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - +## [0.7.0] - 2024-04-26 + +### Changed in 0.7.0 + +- + ## [0.6.0] - 2024-02-27 ### Changed in 0.6.0 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8928667..18effdd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -83,7 +83,7 @@ The variables are used throughout the installation procedure. ```console export GIT_ACCOUNT=senzing -export GIT_REPOSITORY=g2-sdk-go-mock +export GIT_REPOSITORY=sz-sdk-go-mock ``` Synthesize environment variables. diff --git a/Makefile b/Makefile index 9cca799..814c2c2 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# Makefile for g2-sdk-go-mock. +# Makefile for sz-sdk-go-mock. # Detect the operating system and architecture. diff --git a/README.md b/README.md index 5206d98..30f322f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# g2-sdk-go-mock +# sz-sdk-go-mock If you are beginning your journey with [Senzing](https://senzing.com/), @@ -12,7 +12,7 @@ Although this GitHub repository may help you understand an approach to using Sen it's not considered to be "production ready" and is not considered to be part of the Senzing product. Heck, it may not even be appropriate for your application of Senzing! -## :warning: WARNING: g2-sdk-go-mock is still in development :warning: _ +## :warning: WARNING: sz-sdk-go-mock is still in development :warning: _ At the moment, this is "work-in-progress" with Semantic Versions of `0.n.x`. Although it can be reviewed and commented on, @@ -20,34 +20,34 @@ the recommendation is not to use it yet. ## Synopsis -The Senzing `g2-sdk-go-mock` packages provide mock +The Senzing `sz-sdk-go-mock` packages provide mock [Go](https://go.dev/) objects representing the Software Development Kit that wraps the Senzing C SDK APIs. -[![Go Reference](https://pkg.go.dev/badge/github.com/senzing-garage/g2-sdk-go-mock.svg)](https://pkg.go.dev/github.com/senzing-garage/g2-sdk-go-mock) -[![Go Report Card](https://goreportcard.com/badge/github.com/senzing-garage/g2-sdk-go-mock)](https://goreportcard.com/report/github.com/senzing-garage/g2-sdk-go-mock) -[![License](https://img.shields.io/badge/License-Apache2-brightgreen.svg)](https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/LICENSE) +[![Go Reference](https://pkg.go.dev/badge/github.com/senzing-garage/sz-sdk-go-mock.svg)](https://pkg.go.dev/github.com/senzing-garage/sz-sdk-go-mock) +[![Go Report Card](https://goreportcard.com/badge/github.com/senzing-garage/sz-sdk-go-mock)](https://goreportcard.com/report/github.com/senzing-garage/sz-sdk-go-mock) +[![License](https://img.shields.io/badge/License-Apache2-brightgreen.svg)](https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/LICENSE) -[![gosec.yaml](https://github.com/senzing-garage/g2-sdk-go-mock/actions/workflows/gosec.yaml/badge.svg)](https://github.com/senzing-garage/g2-sdk-go-mock/actions/workflows/gosec.yaml) -[![go-test-linux.yaml](https://github.com/senzing-garage/g2-sdk-go-mock/actions/workflows/go-test-linux.yaml/badge.svg)](https://github.com/senzing-garage/g2-sdk-go-mock/actions/workflows/go-test-linux.yaml) -[![go-test-darwin.yaml](https://github.com/senzing-garage/g2-sdk-go-mock/actions/workflows/go-test-darwin.yaml/badge.svg)](https://github.com/senzing-garage/g2-sdk-go-mock/actions/workflows/go-test-darwin.yaml) -[![go-test-windows.yaml](https://github.com/senzing-garage/g2-sdk-go-mock/actions/workflows/go-test-windows.yaml/badge.svg)](https://github.com/senzing-garage/g2-sdk-go-mock/actions/workflows/go-test-windows.yaml) +[![gosec.yaml](https://github.com/senzing-garage/sz-sdk-go-mock/actions/workflows/gosec.yaml/badge.svg)](https://github.com/senzing-garage/sz-sdk-go-mock/actions/workflows/gosec.yaml) +[![go-test-linux.yaml](https://github.com/senzing-garage/sz-sdk-go-mock/actions/workflows/go-test-linux.yaml/badge.svg)](https://github.com/senzing-garage/sz-sdk-go-mock/actions/workflows/go-test-linux.yaml) +[![go-test-darwin.yaml](https://github.com/senzing-garage/sz-sdk-go-mock/actions/workflows/go-test-darwin.yaml/badge.svg)](https://github.com/senzing-garage/sz-sdk-go-mock/actions/workflows/go-test-darwin.yaml) +[![go-test-windows.yaml](https://github.com/senzing-garage/sz-sdk-go-mock/actions/workflows/go-test-windows.yaml/badge.svg)](https://github.com/senzing-garage/sz-sdk-go-mock/actions/workflows/go-test-windows.yaml) ## Overview -The Senzing `g2-sdk-go-mock` packages enable Go programs to simulate calling Senzing library functions. -The `g2-sdk-go-mock` implementation of the -[g2-sdk-go](https://github.com/senzing-garage/g2-sdk-go) +The Senzing `sz-sdk-go-mock` packages enable Go programs to simulate calling Senzing library functions. +The `sz-sdk-go-mock` implementation of the +[sz-sdk-go](https://github.com/senzing-garage/sz-sdk-go) interface does not require the Senzing C libraries to be installed. Other implementations of the -[g2-sdk-go](https://github.com/senzing-garage/g2-sdk-go) +[sz-sdk-go](https://github.com/senzing-garage/sz-sdk-go) interface include: -- [g2-sdk-go-base](https://github.com/senzing-garage/g2-sdk-go-base) - for +- [sz-sdk-go-base](https://github.com/senzing-garage/sz-sdk-go-base) - for calling Senzing Go SDK APIs natively -- [g2-sdk-go-grpc](https://github.com/senzing-garage/g2-sdk-go-grpc) - for +- [sz-sdk-go-grpc](https://github.com/senzing-garage/sz-sdk-go-grpc) - for calling Senzing SDK APIs over [gRPC](https://grpc.io/) - [go-sdk-abstract-factory](https://github.com/senzing-garage/go-sdk-abstract-factory) - An [abstract factory pattern](https://en.wikipedia.org/wiki/Abstract_factory_pattern) @@ -62,4 +62,4 @@ interface include: 1. [Development](docs/development.md) 1. [Errors](docs/errors.md) 1. [Examples](docs/examples.md) -1. [Package reference](https://pkg.go.dev/github.com/senzing-garage/g2-sdk-go-mock) +1. [Package reference](https://pkg.go.dev/github.com/senzing-garage/sz-sdk-go-mock) diff --git a/docs/README.md b/docs/README.md index e71e4e6..cd8ccfb 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1 +1 @@ -# g2-sdk-go-mock +# sz-sdk-go-mock diff --git a/docs/development.md b/docs/development.md index 9569297..280f8ce 100644 --- a/docs/development.md +++ b/docs/development.md @@ -1,4 +1,4 @@ -# g2-sdk-go-mock development +# sz-sdk-go-mock development ## Install Go @@ -13,7 +13,7 @@ The following instructions build the example `main.go` program. ```console export GIT_ACCOUNT=senzing - export GIT_REPOSITORY=g2-sdk-go-mock + export GIT_REPOSITORY=sz-sdk-go-mock export GIT_ACCOUNT_DIR=~/${GIT_ACCOUNT}.git export GIT_REPOSITORY_DIR="${GIT_ACCOUNT_DIR}/${GIT_REPOSITORY}" diff --git a/docs/errors.md b/docs/errors.md index 75ac0ba..a0f96bd 100644 --- a/docs/errors.md +++ b/docs/errors.md @@ -1,4 +1,4 @@ -# g2-sdk-go-mock errors +# sz-sdk-go-mock errors ## Error prefixes @@ -9,10 +9,10 @@ Error identifiers are in the format `senzing-PPPPnnnn` where: Prefixes: -1. `6031` - g2config -1. `6032` - g2configmgr -1. `6033` - g2diagnostic -1. `6034` - g2engine -1. `6035` - g2hasher -1. `6036` - g2product -1. `6037` - g2ssadm +1. `6031` - szconfig +1. `6032` - szconfigmanager +1. `6033` - szdiagnostic +1. `6034` - szengine +1. `6035` - szhasher +1. `6036` - szproduct +1. `6037` - szssadm diff --git a/docs/examples.md b/docs/examples.md index d43134c..204086e 100644 --- a/docs/examples.md +++ b/docs/examples.md @@ -1 +1 @@ -# g2-sdk-go-mock examples +# sz-sdk-go-mock examples diff --git a/g2config/doc.go b/g2config/doc.go deleted file mode 100644 index 14f6319..0000000 --- a/g2config/doc.go +++ /dev/null @@ -1,4 +0,0 @@ -/* -The g2config package is used make G2Config requests to a mock object. -*/ -package g2config diff --git a/g2config/g2config_examples_test.go b/g2config/g2config_examples_test.go deleted file mode 100644 index e1cab64..0000000 --- a/g2config/g2config_examples_test.go +++ /dev/null @@ -1,182 +0,0 @@ -//go:build linux - -package g2config - -import ( - "context" - "fmt" - - "github.com/senzing-garage/go-logging/logging" -) - -// ---------------------------------------------------------------------------- -// Examples for godoc documentation -// ---------------------------------------------------------------------------- - -func ExampleG2config_SetObserverOrigin() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2config/g2config_examples_test.go - ctx := context.TODO() - g2config := getG2Config(ctx) - origin := "Machine: nn; Task: UnitTest" - g2config.SetObserverOrigin(ctx, origin) - // Output: -} - -func ExampleG2config_GetObserverOrigin() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2config/g2config_examples_test.go - ctx := context.TODO() - g2config := getG2Config(ctx) - origin := "Machine: nn; Task: UnitTest" - g2config.SetObserverOrigin(ctx, origin) - result := g2config.GetObserverOrigin(ctx) - fmt.Println(result) - // Output: Machine: nn; Task: UnitTest -} - -func ExampleG2config_AddDataSource() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2config/g2config_examples_test.go - ctx := context.TODO() - g2config := getG2Config(ctx) - configHandle, err := g2config.Create(ctx) - if err != nil { - fmt.Println(err) - } - inputJson := `{"DSRC_CODE": "GO_TEST"}` - result, err := g2config.AddDataSource(ctx, configHandle, inputJson) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"DSRC_ID":1001} -} - -func ExampleG2config_Close() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2config/g2config_examples_test.go - ctx := context.TODO() - g2config := getG2Config(ctx) - configHandle, err := g2config.Create(ctx) - if err != nil { - fmt.Println(err) - } - err = g2config.Close(ctx, configHandle) - if err != nil { - fmt.Println(err) - } - // Output: -} - -func ExampleG2config_Create() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2config/g2config_examples_test.go - ctx := context.TODO() - g2config := getG2Config(ctx) - configHandle, err := g2config.Create(ctx) - if err != nil { - fmt.Println(err) - } - fmt.Println(configHandle > 0) // Dummy output. - // Output: true -} - -func ExampleG2config_DeleteDataSource() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2config/g2config_examples_test.go - ctx := context.TODO() - g2config := getG2Config(ctx) - configHandle, err := g2config.Create(ctx) - if err != nil { - fmt.Println(err) - } - inputJson := `{"DSRC_CODE": "TEST"}` - err = g2config.DeleteDataSource(ctx, configHandle, inputJson) - if err != nil { - fmt.Println(err) - } - // Output: -} - -func ExampleG2config_ListDataSources() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2config/g2config_examples_test.go - ctx := context.TODO() - g2config := getG2Config(ctx) - configHandle, err := g2config.Create(ctx) - if err != nil { - fmt.Println(err) - } - result, err := g2config.ListDataSources(ctx, configHandle) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"DATA_SOURCES":[{"DSRC_ID":1,"DSRC_CODE":"TEST"},{"DSRC_ID":2,"DSRC_CODE":"SEARCH"}]} -} - -func ExampleG2config_Load() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2config/g2config_examples_test.go - ctx := context.TODO() - g2config := getG2Config(ctx) - mockConfigHandle, err := g2config.Create(ctx) - if err != nil { - fmt.Println(err) - } - jsonConfig, err := g2config.Save(ctx, mockConfigHandle) - if err != nil { - fmt.Println(err) - } - configHandle, err := g2config.Load(ctx, jsonConfig) - if err != nil { - fmt.Println(err) - } - fmt.Println(configHandle == 0) // Dummy output. - // Output: true -} - -func ExampleG2config_Save() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2config/g2config_examples_test.go - ctx := context.TODO() - g2config := getG2Config(ctx) - configHandle, err := g2config.Create(ctx) - if err != nil { - fmt.Println(err) - } - jsonConfig, err := g2config.Save(ctx, configHandle) - if err != nil { - fmt.Println(err) - } - fmt.Println(truncate(jsonConfig, 207)) - // Output: {"G2_CONFIG":{"CFG_ATTR":[{"ATTR_ID":1001,"ATTR_CODE":"DATA_SOURCE","ATTR_CLASS":"OBSERVATION","FTYPE_CODE":null,"FELEM_CODE":null,"FELEM_REQ":"Yes","DEFAULT_VALUE":null,"ADVANCED":"Yes","INTERNAL":"No"},... -} - -func ExampleG2config_SetLogLevel() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2config/g2config_examples_test.go - ctx := context.TODO() - g2config := getG2Config(ctx) - err := g2config.SetLogLevel(ctx, logging.LevelInfoName) - if err != nil { - fmt.Println(err) - } - // Output: -} - -func ExampleG2config_Init() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2config/g2config_examples_test.go - ctx := context.TODO() - g2config := getG2Config(ctx) - moduleName := "Test module name" - iniParams := "{}" - verboseLogging := int64(0) - err := g2config.Init(ctx, moduleName, iniParams, verboseLogging) - if err != nil { - // This should produce a "senzing-60114002" error. - } - // Output: -} - -func ExampleG2config_Destroy() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2config/g2config_examples_test.go - ctx := context.TODO() - g2config := getG2Config(ctx) - err := g2config.Destroy(ctx) - if err != nil { - // This should produce a "senzing-60114001" error. - } - // Output: -} diff --git a/g2config/g2config_test.go b/g2config/g2config_test.go deleted file mode 100644 index 018c8d5..0000000 --- a/g2config/g2config_test.go +++ /dev/null @@ -1,267 +0,0 @@ -package g2config - -import ( - "context" - "fmt" - "os" - "testing" - - truncator "github.com/aquilax/truncate" - "github.com/senzing-garage/g2-sdk-go/g2api" - "github.com/stretchr/testify/assert" -) - -const ( - defaultTruncation = 76 - printResults = false -) - -var ( - g2configSingleton *G2config -) - -// ---------------------------------------------------------------------------- -// Internal functions -// ---------------------------------------------------------------------------- - -func getTestObject(ctx context.Context, test *testing.T) *G2config { - return getG2Config(ctx) -} - -func getG2Config(ctx context.Context) *G2config { - if g2configSingleton == nil { - g2configSingleton = &G2config{ - AddDataSourceResult: `{"DSRC_ID":1001}`, - CreateResult: 1, - ListDataSourcesResult: `{"DATA_SOURCES":[{"DSRC_ID":1,"DSRC_CODE":"TEST"},{"DSRC_ID":2,"DSRC_CODE":"SEARCH"}]}`, - SaveResult: `{"G2_CONFIG":{"CFG_ATTR":[{"ATTR_ID":1001,"ATTR_CODE":"DATA_SOURCE","ATTR_CLASS":"OBSERVATION","FTYPE_CODE":null,"FELEM_CODE":null,"FELEM_REQ":"Yes","DEFAULT_VALUE":null,"ADVANCED":"Yes","INTERNAL":"No"},{"ATTR_ID":1002,"ATTR_CODE":"ROUTE_CODE",`, - } - } - return g2configSingleton -} - -func truncate(aString string, length int) string { - return truncator.Truncate(aString, length, "...", truncator.PositionEnd) -} - -func printResult(test *testing.T, title string, result interface{}) { - if printResults { - test.Logf("%s: %v", title, truncate(fmt.Sprintf("%v", result), defaultTruncation)) - } -} - -func printActual(test *testing.T, actual interface{}) { - printResult(test, "Actual", actual) -} - -func testError(test *testing.T, ctx context.Context, g2config g2api.G2config, err error) { - if err != nil { - test.Log("Error:", err.Error()) - assert.FailNow(test, err.Error()) - } -} - -// ---------------------------------------------------------------------------- -// Test harness -// ---------------------------------------------------------------------------- - -func TestMain(m *testing.M) { - err := setup() - if err != nil { - fmt.Print(err) - os.Exit(1) - } - code := m.Run() - err = teardown() - if err != nil { - fmt.Print(err) - } - os.Exit(code) -} - -func getIniParams() (string, error) { - return "{}", nil -} - -func setup() error { - var err error = nil - return err -} - -func teardown() error { - var err error = nil - return err -} - -// ---------------------------------------------------------------------------- -// Test interface functions -// ---------------------------------------------------------------------------- - -func TestG2config_SetObserverOrigin(test *testing.T) { - ctx := context.TODO() - g2config := getTestObject(ctx, test) - origin := "Machine: nn; Task: UnitTest" - g2config.SetObserverOrigin(ctx, origin) -} - -func TestG2config_GetObserverOrigin(test *testing.T) { - ctx := context.TODO() - g2config := getTestObject(ctx, test) - origin := "Machine: nn; Task: UnitTest" - g2config.SetObserverOrigin(ctx, origin) - actual := g2config.GetObserverOrigin(ctx) - assert.Equal(test, origin, actual) -} - -func TestG2config_AddDataSource(test *testing.T) { - ctx := context.TODO() - g2config := getTestObject(ctx, test) - configHandle, err := g2config.Create(ctx) - testError(test, ctx, g2config, err) - inputJson := `{"DSRC_CODE": "GO_TEST"}` - actual, err := g2config.AddDataSource(ctx, configHandle, inputJson) - testError(test, ctx, g2config, err) - printActual(test, actual) - err = g2config.Close(ctx, configHandle) - testError(test, ctx, g2config, err) -} - -func TestG2config_AddDataSource_WithLoad(test *testing.T) { - ctx := context.TODO() - g2config := getTestObject(ctx, test) - configHandle, err := g2config.Create(ctx) - testError(test, ctx, g2config, err) - jsonConfig, err := g2config.Save(ctx, configHandle) - testError(test, ctx, g2config, err) - err = g2config.Close(ctx, configHandle) - testError(test, ctx, g2config, err) - configHandle2, err := g2config.Load(ctx, jsonConfig) - testError(test, ctx, g2config, err) - inputJson := `{"DSRC_CODE": "GO_TEST"}` - actual, err := g2config.AddDataSource(ctx, configHandle2, inputJson) - testError(test, ctx, g2config, err) - printActual(test, actual) - err = g2config.Close(ctx, configHandle2) - testError(test, ctx, g2config, err) -} - -func TestG2config_Close(test *testing.T) { - ctx := context.TODO() - g2config := getTestObject(ctx, test) - configHandle, err := g2config.Create(ctx) - testError(test, ctx, g2config, err) - err = g2config.Close(ctx, configHandle) - testError(test, ctx, g2config, err) -} - -func TestG2config_Create(test *testing.T) { - ctx := context.TODO() - g2config := getTestObject(ctx, test) - actual, err := g2config.Create(ctx) - testError(test, ctx, g2config, err) - printActual(test, actual) -} - -func TestG2config_DeleteDataSource(test *testing.T) { - ctx := context.TODO() - g2config := getTestObject(ctx, test) - configHandle, err := g2config.Create(ctx) - testError(test, ctx, g2config, err) - actual, err := g2config.ListDataSources(ctx, configHandle) - testError(test, ctx, g2config, err) - printResult(test, "Original", actual) - inputJson := `{"DSRC_CODE": "GO_TEST"}` - _, err = g2config.AddDataSource(ctx, configHandle, inputJson) - testError(test, ctx, g2config, err) - actual, err = g2config.ListDataSources(ctx, configHandle) - testError(test, ctx, g2config, err) - printResult(test, " Add", actual) - err = g2config.DeleteDataSource(ctx, configHandle, inputJson) - testError(test, ctx, g2config, err) - actual, err = g2config.ListDataSources(ctx, configHandle) - testError(test, ctx, g2config, err) - printResult(test, " Delete", actual) - err = g2config.Close(ctx, configHandle) - testError(test, ctx, g2config, err) -} - -func TestG2config_DeleteDataSource_WithLoad(test *testing.T) { - ctx := context.TODO() - g2config := getTestObject(ctx, test) - configHandle, err := g2config.Create(ctx) - testError(test, ctx, g2config, err) - actual, err := g2config.ListDataSources(ctx, configHandle) - testError(test, ctx, g2config, err) - printResult(test, "Original", actual) - inputJson := `{"DSRC_CODE": "GO_TEST"}` - _, err = g2config.AddDataSource(ctx, configHandle, inputJson) - testError(test, ctx, g2config, err) - actual, err = g2config.ListDataSources(ctx, configHandle) - testError(test, ctx, g2config, err) - printResult(test, " Add", actual) - jsonConfig, err := g2config.Save(ctx, configHandle) - testError(test, ctx, g2config, err) - err = g2config.Close(ctx, configHandle) - testError(test, ctx, g2config, err) - configHandle2, err := g2config.Load(ctx, jsonConfig) - testError(test, ctx, g2config, err) - err = g2config.DeleteDataSource(ctx, configHandle2, inputJson) - testError(test, ctx, g2config, err) - actual, err = g2config.ListDataSources(ctx, configHandle2) - testError(test, ctx, g2config, err) - printResult(test, " Delete", actual) - err = g2config.Close(ctx, configHandle2) - testError(test, ctx, g2config, err) -} - -func TestG2config_ListDataSources(test *testing.T) { - ctx := context.TODO() - g2config := getTestObject(ctx, test) - configHandle, err := g2config.Create(ctx) - testError(test, ctx, g2config, err) - actual, err := g2config.ListDataSources(ctx, configHandle) - testError(test, ctx, g2config, err) - printActual(test, actual) - err = g2config.Close(ctx, configHandle) - testError(test, ctx, g2config, err) -} - -func TestG2config_Load(test *testing.T) { - ctx := context.TODO() - g2config := getTestObject(ctx, test) - configHandle, err := g2config.Create(ctx) - testError(test, ctx, g2config, err) - jsonConfig, err := g2config.Save(ctx, configHandle) - testError(test, ctx, g2config, err) - actual, err := g2config.Load(ctx, jsonConfig) - testError(test, ctx, g2config, err) - printActual(test, actual) -} - -func TestG2config_Save(test *testing.T) { - ctx := context.TODO() - g2config := getTestObject(ctx, test) - configHandle, err := g2config.Create(ctx) - testError(test, ctx, g2config, err) - actual, err := g2config.Save(ctx, configHandle) - testError(test, ctx, g2config, err) - printActual(test, actual) -} - -func TestG2config_Init(test *testing.T) { - ctx := context.TODO() - g2config := getTestObject(ctx, test) - moduleName := "Test module name" - verboseLogging := int64(0) - iniParams, err := getIniParams() - testError(test, ctx, g2config, err) - err = g2config.Init(ctx, moduleName, iniParams, verboseLogging) - testError(test, ctx, g2config, err) -} - -func TestG2config_Destroy(test *testing.T) { - ctx := context.TODO() - g2config := getTestObject(ctx, test) - err := g2config.Destroy(ctx) - testError(test, ctx, g2config, err) -} diff --git a/g2configmgr/doc.go b/g2configmgr/doc.go deleted file mode 100644 index 75b2bee..0000000 --- a/g2configmgr/doc.go +++ /dev/null @@ -1,4 +0,0 @@ -/* -The g2configmgr package is used make G2Configmgr requests to a mock object. -*/ -package g2configmgr diff --git a/g2configmgr/g2configmgr_examples_test.go b/g2configmgr/g2configmgr_examples_test.go deleted file mode 100644 index 119a1a5..0000000 --- a/g2configmgr/g2configmgr_examples_test.go +++ /dev/null @@ -1,152 +0,0 @@ -//go:build linux - -package g2configmgr - -import ( - "context" - "fmt" - - "github.com/senzing-garage/go-logging/logging" -) - -// ---------------------------------------------------------------------------- -// Examples for godoc documentation -// ---------------------------------------------------------------------------- - -func ExampleG2configmgr_SetObserverOrigin() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2configmgr/g2configmgr_examples_test.go - ctx := context.TODO() - g2configmgr := getG2Configmgr(ctx) - origin := "Machine: nn; Task: UnitTest" - g2configmgr.SetObserverOrigin(ctx, origin) - // Output: -} - -func ExampleG2configmgr_GetObserverOrigin() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2config/g2configmgr_test.go - ctx := context.TODO() - g2configmgr := getG2Configmgr(ctx) - origin := "Machine: nn; Task: UnitTest" - g2configmgr.SetObserverOrigin(ctx, origin) - result := g2configmgr.GetObserverOrigin(ctx) - fmt.Println(result) - // Output: Machine: nn; Task: UnitTest -} - -func ExampleG2configmgr_AddConfig() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2configmgr/g2configmgr_examples_test.go - ctx := context.TODO() - g2configmgr := getG2Configmgr(ctx) - configStr := `` - configComments := "Example configuration" - configID, err := g2configmgr.AddConfig(ctx, configStr, configComments) - if err != nil { - fmt.Println(err) - } - fmt.Println(configID > 0) // Dummy output. - // Output: true -} - -func ExampleG2configmgr_GetConfig() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2configmgr/g2configmgr_examples_test.go - ctx := context.TODO() - g2configmgr := getG2Configmgr(ctx) - configID, err := g2configmgr.GetDefaultConfigID(ctx) - if err != nil { - fmt.Println(err) - } - configStr, err := g2configmgr.GetConfig(ctx, configID) - if err != nil { - fmt.Println(err) - } - fmt.Println(truncate(configStr, defaultTruncation)) - // Output: {"G2_CONFIG":{"CFG_ATTR":[{"ATTR_ID":1001,"ATTR_CODE":"DATA_SOURCE","ATTR... -} - -func ExampleG2configmgr_GetConfigList() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2configmgr/g2configmgr_examples_test.go - ctx := context.TODO() - g2configmgr := getG2Configmgr(ctx) - jsonConfigList, err := g2configmgr.GetConfigList(ctx) - if err != nil { - fmt.Println(err) - } - fmt.Println(truncate(jsonConfigList, 28)) - // Output: {"CONFIGS":[{"CONFIG_ID":... -} - -func ExampleG2configmgr_GetDefaultConfigID() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2configmgr/g2configmgr_examples_test.go - ctx := context.TODO() - g2configmgr := getG2Configmgr(ctx) - configID, err := g2configmgr.GetDefaultConfigID(ctx) - if err != nil { - fmt.Println(err) - } - fmt.Println(configID > 0) // Dummy output. - // Output: true -} - -func ExampleG2configmgr_ReplaceDefaultConfigID() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2configmgr/g2configmgr_examples_test.go - ctx := context.TODO() - g2configmgr := getG2Configmgr(ctx) - oldConfigID := int64(1) - newConfigID := int64(2) - err := g2configmgr.ReplaceDefaultConfigID(ctx, oldConfigID, newConfigID) - if err != nil { - fmt.Println(err) - } - // Output: -} - -func ExampleG2configmgr_SetDefaultConfigID() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2configmgr/g2configmgr_examples_test.go - ctx := context.TODO() - g2configmgr := getG2Configmgr(ctx) - configID, err := g2configmgr.GetDefaultConfigID(ctx) // For example purposes only. Normally would use output from GetConfigList() - if err != nil { - fmt.Println(err) - } - err = g2configmgr.SetDefaultConfigID(ctx, configID) - if err != nil { - fmt.Println(err) - } - // Output: -} - -func ExampleG2configmgr_SetLogLevel() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2configmgr/g2configmgr_examples_test.go - ctx := context.TODO() - g2configmgr := getG2Configmgr(ctx) - err := g2configmgr.SetLogLevel(ctx, logging.LevelInfoName) - if err != nil { - fmt.Println(err) - } - // Output: -} - -func ExampleG2configmgr_Init() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2configmgr/g2configmgr_examples_test.go - ctx := context.TODO() - g2configmgr := &G2configmgr{} - moduleName := "Test module name" - iniParams := "{}" - verboseLogging := int64(0) - err := g2configmgr.Init(ctx, moduleName, iniParams, verboseLogging) - if err != nil { - // This should produce a "senzing-60124002" error. - } - // Output: -} - -func ExampleG2configmgr_Destroy() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2configmgr/g2configmgr_examples_test.go - ctx := context.TODO() - g2configmgr := getG2Configmgr(ctx) - err := g2configmgr.Destroy(ctx) - if err != nil { - // This should produce a "senzing-60124001" error. - } - // Output: -} diff --git a/g2configmgr/g2configmgr_test.go b/g2configmgr/g2configmgr_test.go deleted file mode 100644 index 415832a..0000000 --- a/g2configmgr/g2configmgr_test.go +++ /dev/null @@ -1,201 +0,0 @@ -package g2configmgr - -import ( - "context" - "fmt" - "os" - "testing" - "time" - - truncator "github.com/aquilax/truncate" - "github.com/senzing-garage/g2-sdk-go/g2api" - "github.com/stretchr/testify/assert" -) - -const ( - defaultTruncation = 76 - printResults = false -) - -var ( - g2configmgrSingleton *G2configmgr -) - -// ---------------------------------------------------------------------------- -// Internal functions -// ---------------------------------------------------------------------------- - -func getTestObject(ctx context.Context, test *testing.T) *G2configmgr { - return getG2Configmgr(ctx) -} - -func getG2Configmgr(ctx context.Context) *G2configmgr { - if g2configmgrSingleton == nil { - g2configmgrSingleton = &G2configmgr{ - AddConfigResult: 1, - GetConfigResult: `{"G2_CONFIG":{"CFG_ATTR":[{"ATTR_ID":1001,"ATTR_CODE":"DATA_SOURCE","ATTR_CLASS":"OBSERVATION","FTYPE_CODE":null,"FELEM_CODE":null,"FELEM_REQ":"Yes","DEFAULT_VALUE":null,"ADVANCED":"Yes","INTERNAL":"No"},{"ATTR_ID":1002,"ATTR_CODE":"ROUTE_CODE","ATTR_CLASS":"OBSERVATION","FTYPE_CODE":null,"FELEM_CODE":null,"FELEM_REQ":"No","DEFAULT_VALUE":null,"ADVANCED":"Yes","INTERNAL":"No"},{"ATTR_ID":1003,"ATTR_CODE":"RECORD_ID","ATTR_CLASS":"OBSERVATION","FTYPE_CODE":null,"FELEM_CODE":null,"FELEM_REQ":"No","DEFAULT_VALUE":null,"ADVANCED":"No","INTERNAL":"No"},{"ATTR_ID":1004,"ATTR_CODE":"ENTITY_TYPE","ATTR_CLASS":"OBSERVATION","FTYPE_CODE":null,`, - GetConfigListResult: `{"CONFIGS":[{"CONFIG_ID":41320074,"CONFIG_COMMENTS":"Example configuration","SYS_CREATE_DT":"2023-02-16 21:43:10.171"},{"CONFIG_ID":1111755672,"CONFIG_COMMENTS":"g2configmgr_test at 2023-02-16 21:43:10.154619801 +0000 UTC","SYS_CREATE_DT":"2023-02-16 21:43:10.159"},{"CONFIG_ID":3680541328,"CONFIG_COMMENTS":"Created by g2diagnostic_test at 2023-02-16 21:43:07.294747409 +0000 UTC","SYS_CREATE_DT":"2023-02-16 21:43:07.755"}]}`, - GetDefaultConfigIDResult: 1, - } - } - return g2configmgrSingleton -} - -func truncate(aString string, length int) string { - return truncator.Truncate(aString, length, "...", truncator.PositionEnd) -} - -func printResult(test *testing.T, title string, result interface{}) { - if printResults { - test.Logf("%s: %v", title, truncate(fmt.Sprintf("%v", result), defaultTruncation)) - } -} - -func printActual(test *testing.T, actual interface{}) { - printResult(test, "Actual", actual) -} - -func testError(test *testing.T, ctx context.Context, g2configmgr g2api.G2configmgr, err error) { - if err != nil { - test.Log("Error:", err.Error()) - assert.FailNow(test, err.Error()) - } -} - -// ---------------------------------------------------------------------------- -// Test harness -// ---------------------------------------------------------------------------- - -func TestMain(m *testing.M) { - err := setup() - if err != nil { - fmt.Print(err) - os.Exit(1) - } - code := m.Run() - err = teardown() - if err != nil { - fmt.Print(err) - } - os.Exit(code) -} - -func setup() error { - var err error = nil - return err -} - -func teardown() error { - var err error = nil - return err -} - -// ---------------------------------------------------------------------------- -// Test interface functions -// ---------------------------------------------------------------------------- - -func TestG2configmgr_SetObserverOrigin(test *testing.T) { - ctx := context.TODO() - g2configmgr := getTestObject(ctx, test) - origin := "Machine: nn; Task: UnitTest" - g2configmgr.SetObserverOrigin(ctx, origin) -} - -func TestG2configmgr_GetObserverOrigin(test *testing.T) { - ctx := context.TODO() - g2configmgr := getTestObject(ctx, test) - origin := "Machine: nn; Task: UnitTest" - g2configmgr.SetObserverOrigin(ctx, origin) - actual := g2configmgr.GetObserverOrigin(ctx) - assert.Equal(test, origin, actual) -} - -func TestG2configmgr_AddConfig(test *testing.T) { - ctx := context.TODO() - g2configmgr := getTestObject(ctx, test) - now := time.Now() - configStr := `` - configComments := fmt.Sprintf("g2configmgr_test at %s", now.UTC()) - actual, err := g2configmgr.AddConfig(ctx, configStr, configComments) - testError(test, ctx, g2configmgr, err) - printActual(test, actual) -} - -func TestG2configmgr_GetConfig(test *testing.T) { - ctx := context.TODO() - g2configmgr := getTestObject(ctx, test) - configID, err1 := g2configmgr.GetDefaultConfigID(ctx) - if err1 != nil { - test.Log("Error:", err1.Error()) - assert.FailNow(test, "g2configmgr.GetDefaultConfigID()") - } - actual, err := g2configmgr.GetConfig(ctx, configID) - testError(test, ctx, g2configmgr, err) - printActual(test, actual) -} - -func TestG2configmgr_GetConfigList(test *testing.T) { - ctx := context.TODO() - g2configmgr := getTestObject(ctx, test) - actual, err := g2configmgr.GetConfigList(ctx) - testError(test, ctx, g2configmgr, err) - printActual(test, actual) -} - -func TestG2configmgr_GetDefaultConfigID(test *testing.T) { - ctx := context.TODO() - g2configmgr := getTestObject(ctx, test) - actual, err := g2configmgr.GetDefaultConfigID(ctx) - testError(test, ctx, g2configmgr, err) - printActual(test, actual) -} - -func TestG2configmgr_ReplaceDefaultConfigID(test *testing.T) { - ctx := context.TODO() - g2configmgr := getTestObject(ctx, test) - oldConfigID, err1 := g2configmgr.GetDefaultConfigID(ctx) - if err1 != nil { - test.Log("Error:", err1.Error()) - assert.FailNow(test, "g2configmgr.GetDefaultConfigID()") - } - - // FIXME: This is kind of a cheater. - - newConfigID, err2 := g2configmgr.GetDefaultConfigID(ctx) - if err2 != nil { - test.Log("Error:", err2.Error()) - assert.FailNow(test, "g2configmgr.GetDefaultConfigID()-2") - } - - err := g2configmgr.ReplaceDefaultConfigID(ctx, oldConfigID, newConfigID) - testError(test, ctx, g2configmgr, err) -} - -func TestG2configmgr_SetDefaultConfigID(test *testing.T) { - ctx := context.TODO() - g2configmgr := getTestObject(ctx, test) - configID, err1 := g2configmgr.GetDefaultConfigID(ctx) - if err1 != nil { - test.Log("Error:", err1.Error()) - assert.FailNow(test, "g2configmgr.GetDefaultConfigID()") - } - err := g2configmgr.SetDefaultConfigID(ctx, configID) - testError(test, ctx, g2configmgr, err) -} - -func TestG2configmgr_Init(test *testing.T) { - ctx := context.TODO() - g2configmgr := getTestObject(ctx, test) - moduleName := "Test module name" - verboseLogging := int64(0) - iniParams := "{}" - err := g2configmgr.Init(ctx, moduleName, iniParams, verboseLogging) - testError(test, ctx, g2configmgr, err) -} - -func TestG2configmgr_Destroy(test *testing.T) { - ctx := context.TODO() - g2configmgr := getTestObject(ctx, test) - err := g2configmgr.Destroy(ctx) - testError(test, ctx, g2configmgr, err) -} diff --git a/g2diagnostic/doc.go b/g2diagnostic/doc.go deleted file mode 100644 index cc8087b..0000000 --- a/g2diagnostic/doc.go +++ /dev/null @@ -1,4 +0,0 @@ -/* -The g2diagnostic package is used make G2Diagnostic requests to a mock object. -*/ -package g2diagnostic diff --git a/g2diagnostic/g2diagnostic_examples_test.go b/g2diagnostic/g2diagnostic_examples_test.go deleted file mode 100644 index f279897..0000000 --- a/g2diagnostic/g2diagnostic_examples_test.go +++ /dev/null @@ -1,108 +0,0 @@ -//go:build linux - -package g2diagnostic - -import ( - "context" - "fmt" -) - -// ---------------------------------------------------------------------------- -// Examples for godoc documentation -// ---------------------------------------------------------------------------- - -func ExampleG2diagnostic_SetObserverOrigin() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2diagnostic/g2diagnostic_examples_test.go - ctx := context.TODO() - g2diagnostic := getG2Diagnostic(ctx) - origin := "Machine: nn; Task: UnitTest" - g2diagnostic.SetObserverOrigin(ctx, origin) - // Output: -} - -func ExampleG2diagnostic_GetObserverOrigin() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2config/g2diagnostic_test.go - ctx := context.TODO() - g2diagnostic := getG2Diagnostic(ctx) - origin := "Machine: nn; Task: UnitTest" - g2diagnostic.SetObserverOrigin(ctx, origin) - result := g2diagnostic.GetObserverOrigin(ctx) - fmt.Println(result) - // Output: Machine: nn; Task: UnitTest -} - -func ExampleG2diagnostic_CheckDBPerf() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2diagnostic/g2diagnostic_examples_test.go - ctx := context.TODO() - g2diagnostic := getG2Diagnostic(ctx) - secondsToRun := 1 - result, err := g2diagnostic.CheckDBPerf(ctx, secondsToRun) - if err != nil { - fmt.Println(err) - } - fmt.Println(truncate(result, 25)) - // Output: {"numRecordsInserted":... -} - -// func ExampleG2diagnostic_SetLogLevel() { -// // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2diagnostic/g2diagnostic_examples_test.go -// g2diagnostic := &G2diagnosticClient{} -// ctx := context.TODO() -// err := g2diagnostic.SetLogLevel(ctx, logger.LevelInfo) -// if err != nil { -// fmt.Println(err) -// } -// // Output: -// } - -func ExampleG2diagnostic_Init() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2diagnostic/g2diagnostic_examples_test.go - ctx := context.TODO() - g2diagnostic := &G2diagnostic{} - moduleName := "Test module name" - iniParams := "{}" - verboseLogging := int64(0) - err := g2diagnostic.Init(ctx, moduleName, iniParams, verboseLogging) - if err != nil { - // This should produce a "senzing-60134002" error. - } - // Output: -} - -func ExampleG2diagnostic_InitWithConfigID() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2diagnostic/g2diagnostic_examples_test.go - ctx := context.TODO() - g2diagnostic := &G2diagnostic{} - moduleName := "Test module name" - iniParams := "{}" - initConfigID := int64(1) - verboseLogging := int64(0) - err := g2diagnostic.InitWithConfigID(ctx, moduleName, iniParams, initConfigID, verboseLogging) - if err != nil { - // This should produce a "senzing-60134003" error. - } - // Output: -} - -func ExampleG2diagnostic_Reinit() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2diagnostic/g2diagnostic_examples_test.go - ctx := context.TODO() - g2diagnostic := getG2Diagnostic(ctx) - initConfigID := int64(1) - err := g2diagnostic.Reinit(ctx, initConfigID) - if err != nil { - fmt.Println(err) - } - // Output: -} - -func ExampleG2diagnostic_Destroy() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2diagnostic/g2diagnostic_examples_test.go - ctx := context.TODO() - g2diagnostic := getG2Diagnostic(ctx) - err := g2diagnostic.Destroy(ctx) - if err != nil { - // This should produce a "senzing-60134001" error. - } - // Output: -} diff --git a/g2diagnostic/g2diagnostic_test.go b/g2diagnostic/g2diagnostic_test.go deleted file mode 100644 index 61f129d..0000000 --- a/g2diagnostic/g2diagnostic_test.go +++ /dev/null @@ -1,159 +0,0 @@ -package g2diagnostic - -import ( - "context" - "fmt" - "os" - "testing" - - truncator "github.com/aquilax/truncate" - "github.com/senzing-garage/g2-sdk-go/g2api" - "github.com/stretchr/testify/assert" -) - -const ( - defaultTruncation = 76 - printResults = false -) - -var ( - g2diagnosticSingleton *G2diagnostic -) - -// ---------------------------------------------------------------------------- -// Internal functions -// ---------------------------------------------------------------------------- - -func getTestObject(ctx context.Context, test *testing.T) g2api.G2diagnostic { - return getG2Diagnostic(ctx) -} - -func getG2Diagnostic(ctx context.Context) *G2diagnostic { - if g2diagnosticSingleton == nil { - g2diagnosticSingleton = &G2diagnostic{ - CheckDBPerfResult: `{"numRecordsInserted":76667,"insertTime":1000}`, - } - } - return g2diagnosticSingleton -} - -func truncate(aString string, length int) string { - return truncator.Truncate(aString, length, "...", truncator.PositionEnd) -} - -func printResult(test *testing.T, title string, result interface{}) { - if printResults { - test.Logf("%s: %v", title, truncate(fmt.Sprintf("%v", result), defaultTruncation)) - } -} - -func printActual(test *testing.T, actual interface{}) { - printResult(test, "Actual", actual) -} - -func testError(test *testing.T, ctx context.Context, g2diagnostic g2api.G2diagnostic, err error) { - if err != nil { - test.Log("Error:", err.Error()) - assert.FailNow(test, err.Error()) - } -} - -func testErrorNoFail(test *testing.T, ctx context.Context, g2diagnostic g2api.G2diagnostic, err error) { - if err != nil { - test.Log("Error:", err.Error()) - } -} - -// ---------------------------------------------------------------------------- -// Test harness -// ---------------------------------------------------------------------------- - -func TestMain(m *testing.M) { - err := setup() - if err != nil { - fmt.Print(err) - os.Exit(1) - } - code := m.Run() - err = teardown() - if err != nil { - fmt.Print(err) - } - os.Exit(code) -} - -func setup() error { - var err error = nil - return err -} - -func teardown() error { - var err error = nil - return err -} - -// ---------------------------------------------------------------------------- -// Test interface functions -// ---------------------------------------------------------------------------- - -func TestG2diagnostic_SetObserverOrigin(test *testing.T) { - ctx := context.TODO() - g2diagnostic := getTestObject(ctx, test) - origin := "Machine: nn; Task: UnitTest" - g2diagnostic.SetObserverOrigin(ctx, origin) -} - -func TestG2diagnostic_GetObserverOrigin(test *testing.T) { - ctx := context.TODO() - g2diagnostic := getTestObject(ctx, test) - origin := "Machine: nn; Task: UnitTest" - g2diagnostic.SetObserverOrigin(ctx, origin) - actual := g2diagnostic.GetObserverOrigin(ctx) - assert.Equal(test, origin, actual) -} - -func TestG2diagnostic_CheckDBPerf(test *testing.T) { - ctx := context.TODO() - g2diagnostic := getTestObject(ctx, test) - secondsToRun := 1 - actual, err := g2diagnostic.CheckDBPerf(ctx, secondsToRun) - testError(test, ctx, g2diagnostic, err) - printActual(test, actual) -} - -func TestG2diagnostic_Init(test *testing.T) { - ctx := context.TODO() - g2diagnostic := &G2diagnostic{} - moduleName := "Test module name" - iniParams := "{}" - verboseLogging := int64(0) - err := g2diagnostic.Init(ctx, moduleName, iniParams, verboseLogging) - testError(test, ctx, g2diagnostic, err) -} - -func TestG2diagnostic_InitWithConfigID(test *testing.T) { - ctx := context.TODO() - g2diagnostic := &G2diagnostic{} - moduleName := "Test module name" - initConfigID := int64(1) - iniParams := "{}" - verboseLogging := int64(0) - err := g2diagnostic.InitWithConfigID(ctx, moduleName, iniParams, initConfigID, verboseLogging) - testError(test, ctx, g2diagnostic, err) -} - -func TestG2diagnostic_Reinit(test *testing.T) { - ctx := context.TODO() - g2diagnostic := getTestObject(ctx, test) - initConfigID := int64(1) - err := g2diagnostic.Reinit(ctx, initConfigID) - testErrorNoFail(test, ctx, g2diagnostic, err) -} - -func TestG2diagnostic_Destroy(test *testing.T) { - ctx := context.TODO() - g2diagnostic := getTestObject(ctx, test) - err := g2diagnostic.Destroy(ctx) - testError(test, ctx, g2diagnostic, err) - g2diagnosticSingleton = nil -} diff --git a/g2engine/doc.go b/g2engine/doc.go deleted file mode 100644 index faaee63..0000000 --- a/g2engine/doc.go +++ /dev/null @@ -1,4 +0,0 @@ -/* -The g2engine package is used make G2Engine requests to a mock object. -*/ -package g2engine diff --git a/g2engine/g2engine_examples_test.go b/g2engine/g2engine_examples_test.go deleted file mode 100644 index 1a4b42d..0000000 --- a/g2engine/g2engine_examples_test.go +++ /dev/null @@ -1,1015 +0,0 @@ -//go:build linux - -package g2engine - -import ( - "context" - "fmt" - - "github.com/senzing-garage/go-common/truthset" - "github.com/senzing-garage/go-logging/logging" -) - -// ---------------------------------------------------------------------------- -// Examples for godoc documentation -// ---------------------------------------------------------------------------- - -func ExampleG2engine_SetObserverOrigin() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - origin := "Machine: nn; Task: UnitTest" - g2engine.SetObserverOrigin(ctx, origin) - // Output: -} - -func ExampleG2engine_GetObserverOrigin() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2config/g2engine_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - origin := "Machine: nn; Task: UnitTest" - g2engine.SetObserverOrigin(ctx, origin) - result := g2engine.GetObserverOrigin(ctx) - fmt.Println(result) - // Output: Machine: nn; Task: UnitTest -} - -func ExampleG2engine_AddRecord() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - dataSourceCode := "CUSTOMERS" - recordID := "1001" - jsonData := `{"DATA_SOURCE": "CUSTOMERS", "RECORD_ID": "1001", "RECORD_TYPE": "PERSON", "PRIMARY_NAME_LAST": "Smith", "PRIMARY_NAME_FIRST": "Robert", "DATE_OF_BIRTH": "12/11/1978", "ADDR_TYPE": "MAILING", "ADDR_LINE1": "123 Main Street, Las Vegas NV 89132", "PHONE_TYPE": "HOME", "PHONE_NUMBER": "702-919-1300", "EMAIL_ADDRESS": "bsmith@work.com", "DATE": "1/2/18", "STATUS": "Active", "AMOUNT": "100"}` - loadID := "G2Engine_test" - err := g2engine.AddRecord(ctx, dataSourceCode, recordID, jsonData, loadID) - if err != nil { - fmt.Println(err) - } - // Output: -} - -func ExampleG2engine_AddRecord_secondRecord() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - dataSourceCode := "CUSTOMERS" - recordID := "1002" - jsonData := `{"DATA_SOURCE": "CUSTOMERS", "RECORD_ID": "1002", "RECORD_TYPE": "PERSON", "PRIMARY_NAME_LAST": "Smith", "PRIMARY_NAME_FIRST": "Bob", "DATE_OF_BIRTH": "11/12/1978", "ADDR_TYPE": "HOME", "ADDR_LINE1": "1515 Adela Lane", "ADDR_CITY": "Las Vegas", "ADDR_STATE": "NV", "ADDR_POSTAL_CODE": "89111", "PHONE_TYPE": "MOBILE", "PHONE_NUMBER": "702-919-1300", "DATE": "3/10/17", "STATUS": "Inactive", "AMOUNT": "200"}` - loadID := "G2Engine_test" - err := g2engine.AddRecord(ctx, dataSourceCode, recordID, jsonData, loadID) - if err != nil { - fmt.Println(err) - } - // Output: -} - -func ExampleG2engine_AddRecordWithInfo() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - dataSourceCode := "CUSTOMERS" - recordID := "1003" - jsonData := `{"DATA_SOURCE": "CUSTOMERS", "RECORD_ID": "1003", "RECORD_TYPE": "PERSON", "PRIMARY_NAME_LAST": "Smith", "PRIMARY_NAME_FIRST": "Bob", "PRIMARY_NAME_MIDDLE": "J", "DATE_OF_BIRTH": "12/11/1978", "EMAIL_ADDRESS": "bsmith@work.com", "DATE": "4/9/16", "STATUS": "Inactive", "AMOUNT": "300"}` - loadID := "G2Engine_test" - flags := int64(0) - result, err := g2engine.AddRecordWithInfo(ctx, dataSourceCode, recordID, jsonData, loadID, flags) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1003","AFFECTED_ENTITIES":[{"ENTITY_ID":1}],"INTERESTING_ENTITIES":{"ENTITIES":[]}} -} - -func ExampleG2engine_CloseExport() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - flags := int64(0) - responseHandle, err := g2engine.ExportJSONEntityReport(ctx, flags) - if err != nil { - fmt.Println(err) - } - g2engine.CloseExport(ctx, responseHandle) - // Output: -} - -func ExampleG2engine_CountRedoRecords() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - result, err := g2engine.CountRedoRecords(ctx) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: 1 -} - -func ExampleG2engine_ExportConfig() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - result, err := g2engine.ExportConfig(ctx) - if err != nil { - fmt.Println(err) - } - fmt.Println(truncate(result, 42)) - // Output: {"G2_CONFIG":{"CFG_ETYPE":[{"ETYPE_ID":... -} - -func ExampleG2engine_ExportConfigAndConfigID() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - _, configId, err := g2engine.ExportConfigAndConfigID(ctx) - if err != nil { - fmt.Println(err) - } - fmt.Println(configId > 0) // Dummy output. - // Output: true -} - -func ExampleG2engine_ExportCSVEntityReport() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - csvColumnList := "" - flags := int64(0) - responseHandle, err := g2engine.ExportCSVEntityReport(ctx, csvColumnList, flags) - if err != nil { - fmt.Println(err) - } - fmt.Println(responseHandle > 0) // Dummy output. - // Output: true -} - -func ExampleG2engine_ExportCSVEntityReportIterator() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - csvColumnList := "" - flags := int64(0) - for result := range g2engine.ExportCSVEntityReportIterator(ctx, csvColumnList, flags) { - if result.Error != nil { - fmt.Println(result.Error) - break - } - fmt.Println(result.Value) - } - // Output: -} - -func ExampleG2engine_ExportJSONEntityReport() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - flags := int64(0) - responseHandle, err := g2engine.ExportJSONEntityReport(ctx, flags) - if err != nil { - fmt.Println(err) - } - fmt.Println(responseHandle > 0) // Dummy output. - // Output: true -} - -func ExampleG2engine_ExportJSONEntityReportIterator() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - flags := int64(0) - for result := range g2engine.ExportJSONEntityReportIterator(ctx, flags) { - if result.Error != nil { - fmt.Println(result.Error) - break - } - fmt.Println(result.Value) - } - // Output: -} - -func ExampleG2engine_FetchNext() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - flags := int64(0) - responseHandle, err := g2engine.ExportJSONEntityReport(ctx, flags) - if err != nil { - fmt.Println(err) - } - defer func() { - err = g2engine.CloseExport(ctx, responseHandle) - }() - - jsonEntityReport := "" - for { - jsonEntityReportFragment, err := g2engine.FetchNext(ctx, responseHandle) - if err != nil { - fmt.Println(err) - } - if len(jsonEntityReportFragment) == 0 { - break - } - jsonEntityReport += jsonEntityReportFragment - } - - fmt.Println(len(jsonEntityReport) >= 0) // Dummy output. - // Output: true -} - -func ExampleG2engine_FindInterestingEntitiesByEntityID() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - entityID := getEntityIdForRecord("CUSTOMERS", "1001") - flags := int64(0) - result, err := g2engine.FindInterestingEntitiesByEntityID(ctx, entityID, flags) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"INTERESTING_ENTITIES":{"ENTITIES":[]}} -} - -func ExampleG2engine_FindInterestingEntitiesByRecordID() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - dataSourceCode := "CUSTOMERS" - recordID := "1001" - flags := int64(0) - result, err := g2engine.FindInterestingEntitiesByRecordID(ctx, dataSourceCode, recordID, flags) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"INTERESTING_ENTITIES":{"ENTITIES":[]}} -} - -func ExampleG2engine_FindNetworkByEntityID() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - entityList := `{"ENTITIES": [{"ENTITY_ID": ` + getEntityIdStringForRecord("CUSTOMERS", "1001") + `}, {"ENTITY_ID": ` + getEntityIdStringForRecord("CUSTOMERS", "1002") + `}]}` - maxDegree := int64(2) - buildOutDegree := int64(1) - maxEntities := int64(10) - result, err := g2engine.FindNetworkByEntityID(ctx, entityList, maxDegree, buildOutDegree, maxEntities) - if err != nil { - fmt.Println(err) - } - fmt.Println(truncate(result, 175)) - // Output: {"ENTITY_PATHS":[],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"Robert Smith","RECORD_SUMMARY":[{"DATA_SOURCE":"CUSTOMERS","RECORD_COUNT":3,"FIRST_SEEN_DT":... -} - -func ExampleG2engine_FindNetworkByEntityID_V2() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - entityList := `{"ENTITIES": [{"ENTITY_ID": ` + getEntityIdStringForRecord("CUSTOMERS", "1001") + `}, {"ENTITY_ID": ` + getEntityIdStringForRecord("CUSTOMERS", "1002") + `}]}` - maxDegree := int64(2) - buildOutDegree := int64(1) - maxEntities := int64(10) - flags := int64(0) - result, err := g2engine.FindNetworkByEntityID_V2(ctx, entityList, maxDegree, buildOutDegree, maxEntities, flags) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"ENTITY_PATHS":[],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1}}]} -} - -func ExampleG2engine_FindNetworkByRecordID() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - recordList := `{"RECORDS": [{"DATA_SOURCE": "CUSTOMERS", "RECORD_ID": "1001"}, {"DATA_SOURCE": "CUSTOMERS", "RECORD_ID": "1002"}]}` - maxDegree := int64(1) - buildOutDegree := int64(2) - maxEntities := int64(10) - result, err := g2engine.FindNetworkByRecordID(ctx, recordList, maxDegree, buildOutDegree, maxEntities) - if err != nil { - fmt.Println(err) - } - fmt.Println(truncate(result, 175)) - // Output: {"ENTITY_PATHS":[],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"Robert Smith","RECORD_SUMMARY":[{"DATA_SOURCE":"CUSTOMERS","RECORD_COUNT":3,"FIRST_SEEN_DT":... -} - -func ExampleG2engine_FindNetworkByRecordID_V2() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - recordList := `{"RECORDS": [{"DATA_SOURCE": "CUSTOMERS", "RECORD_ID": "1001"}, {"DATA_SOURCE": "CUSTOMERS", "RECORD_ID": "1002"}]}` - maxDegree := int64(1) - buildOutDegree := int64(2) - maxEntities := int64(10) - flags := int64(0) - result, err := g2engine.FindNetworkByRecordID_V2(ctx, recordList, maxDegree, buildOutDegree, maxEntities, flags) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"ENTITY_PATHS":[],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1}}]} -} - -func ExampleG2engine_FindPathByEntityID() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - entityID1 := getEntityIdForRecord("CUSTOMERS", "1001") - entityID2 := getEntityIdForRecord("CUSTOMERS", "1002") - maxDegree := int64(1) - result, err := g2engine.FindPathByEntityID(ctx, entityID1, entityID2, maxDegree) - if err != nil { - fmt.Println(err) - } - fmt.Println(truncate(result, 107)) - // Output: {"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[1]}],"ENTITIES":[{"RESOLVED_ENTITY":... -} - -func ExampleG2engine_FindPathByEntityID_V2() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - entityID1 := getEntityIdForRecord("CUSTOMERS", "1001") - entityID2 := getEntityIdForRecord("CUSTOMERS", "1002") - maxDegree := int64(1) - flags := int64(0) - result, err := g2engine.FindPathByEntityID_V2(ctx, entityID1, entityID2, maxDegree, flags) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[1]}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1}}]} -} - -func ExampleG2engine_FindPathByRecordID() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - dataSourceCode1 := "CUSTOMERS" - recordID1 := "1001" - dataSourceCode2 := "CUSTOMERS" - recordID2 := "1002" - maxDegree := int64(1) - result, err := g2engine.FindPathByRecordID(ctx, dataSourceCode1, recordID1, dataSourceCode2, recordID2, maxDegree) - if err != nil { - fmt.Println(err) - } - fmt.Println(truncate(result, 87)) - // Output: {"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[1]}],"ENTITIES":... -} - -func ExampleG2engine_FindPathByRecordID_V2() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - dataSourceCode1 := "CUSTOMERS" - recordID1 := "1001" - dataSourceCode2 := "CUSTOMERS" - recordID2 := "1002" - maxDegree := int64(1) - flags := int64(0) - result, err := g2engine.FindPathByRecordID_V2(ctx, dataSourceCode1, recordID1, dataSourceCode2, recordID2, maxDegree, flags) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[1]}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1}}]} -} - -func ExampleG2engine_FindPathExcludingByEntityID() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - entityID1 := getEntityIdForRecord("CUSTOMERS", "1001") - entityID2 := getEntityIdForRecord("CUSTOMERS", "1002") - maxDegree := int64(1) - excludedEntities := `{"ENTITIES": [{"ENTITY_ID": ` + getEntityIdStringForRecord("CUSTOMERS", "1003") + `}]}` - result, err := g2engine.FindPathExcludingByEntityID(ctx, entityID1, entityID2, maxDegree, excludedEntities) - if err != nil { - fmt.Println(err) - } - fmt.Println(truncate(result, 107)) - // Output: {"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[1]}],"ENTITIES":[{"RESOLVED_ENTITY":... -} - -func ExampleG2engine_FindPathExcludingByEntityID_V2() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - entityID1 := getEntityIdForRecord("CUSTOMERS", "1001") - entityID2 := getEntityIdForRecord("CUSTOMERS", "1002") - maxDegree := int64(1) - excludedEntities := `{"ENTITIES": [{"ENTITY_ID": ` + getEntityIdStringForRecord("CUSTOMERS", "1003") + `}]}` - flags := int64(0) - result, err := g2engine.FindPathExcludingByEntityID_V2(ctx, entityID1, entityID2, maxDegree, excludedEntities, flags) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[1]}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1}}]} -} - -func ExampleG2engine_FindPathExcludingByRecordID() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - dataSourceCode1 := "CUSTOMERS" - recordID1 := "1001" - dataSourceCode2 := "CUSTOMERS" - recordID2 := "1002" - maxDegree := int64(1) - excludedRecords := `{"RECORDS": [{ "DATA_SOURCE": "CUSTOMERS", "RECORD_ID": "1003"}]}` - result, err := g2engine.FindPathExcludingByRecordID(ctx, dataSourceCode1, recordID1, dataSourceCode2, recordID2, maxDegree, excludedRecords) - if err != nil { - fmt.Println(err) - } - fmt.Println(truncate(result, 107)) - // Output: {"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[1]}],"ENTITIES":[{"RESOLVED_ENTITY":... -} - -func ExampleG2engine_FindPathExcludingByRecordID_V2() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - dataSourceCode1 := "CUSTOMERS" - recordID1 := "1001" - dataSourceCode2 := "CUSTOMERS" - recordID2 := "1002" - maxDegree := int64(1) - excludedRecords := `{"RECORDS": [{ "DATA_SOURCE": "CUSTOMERS", "RECORD_ID": "1003"}]}` - flags := int64(0) - result, err := g2engine.FindPathExcludingByRecordID_V2(ctx, dataSourceCode1, recordID1, dataSourceCode2, recordID2, maxDegree, excludedRecords, flags) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[1]}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1}}]} -} - -func ExampleG2engine_FindPathIncludingSourceByEntityID() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - entityID1 := getEntityIdForRecord("CUSTOMERS", "1001") - entityID2 := getEntityIdForRecord("CUSTOMERS", "1002") - maxDegree := int64(1) - excludedEntities := `{"ENTITIES": [{"ENTITY_ID": ` + getEntityIdStringForRecord("CUSTOMERS", "1003") + `}]}` - requiredDsrcs := `{"DATA_SOURCES": ["CUSTOMERS"]}` - result, err := g2engine.FindPathIncludingSourceByEntityID(ctx, entityID1, entityID2, maxDegree, excludedEntities, requiredDsrcs) - if err != nil { - fmt.Println(err) - } - fmt.Println(truncate(result, 106)) - // Output: {"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[]}],"ENTITIES":[{"RESOLVED_ENTITY":... -} - -func ExampleG2engine_FindPathIncludingSourceByEntityID_V2() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - entityID1 := getEntityIdForRecord("CUSTOMERS", "1001") - entityID2 := getEntityIdForRecord("CUSTOMERS", "1002") - maxDegree := int64(1) - excludedEntities := `{"ENTITIES": [{"ENTITY_ID": ` + getEntityIdStringForRecord("CUSTOMERS", "1003") + `}]}` - requiredDsrcs := `{"DATA_SOURCES": ["CUSTOMERS"]}` - flags := int64(0) - result, err := g2engine.FindPathIncludingSourceByEntityID_V2(ctx, entityID1, entityID2, maxDegree, excludedEntities, requiredDsrcs, flags) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[]}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1}}]} -} - -func ExampleG2engine_FindPathIncludingSourceByRecordID() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - dataSourceCode1 := "CUSTOMERS" - recordID1 := "1001" - dataSourceCode2 := "CUSTOMERS" - recordID2 := "1002" - maxDegree := int64(1) - excludedEntities := `{"ENTITIES": [{"ENTITY_ID": ` + getEntityIdStringForRecord("CUSTOMERS", "1003") + `}]}` - requiredDsrcs := `{"DATA_SOURCES": ["CUSTOMERS"]}` - result, err := g2engine.FindPathIncludingSourceByRecordID(ctx, dataSourceCode1, recordID1, dataSourceCode2, recordID2, maxDegree, excludedEntities, requiredDsrcs) - if err != nil { - fmt.Println(err) - } - fmt.Println(truncate(result, 119)) - // Output: {"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[]}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":... -} - -func ExampleG2engine_FindPathIncludingSourceByRecordID_V2() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - dataSourceCode1 := "CUSTOMERS" - recordID1 := "1001" - dataSourceCode2 := "CUSTOMERS" - recordID2 := "1002" - maxDegree := int64(1) - excludedEntities := `{"ENTITIES": [{"ENTITY_ID": ` + getEntityIdStringForRecord("CUSTOMERS", "1003") + `}]}` - requiredDsrcs := `{"DATA_SOURCES": ["CUSTOMERS"]}` - flags := int64(0) - result, err := g2engine.FindPathIncludingSourceByRecordID_V2(ctx, dataSourceCode1, recordID1, dataSourceCode2, recordID2, maxDegree, excludedEntities, requiredDsrcs, flags) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[]}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1}}]} -} - -func ExampleG2engine_GetActiveConfigID() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - result, err := g2engine.GetActiveConfigID(ctx) - if err != nil { - fmt.Println(err) - } - fmt.Println(result > 0) // Dummy output. - // Output: true -} - -func ExampleG2engine_GetEntityByEntityID() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - entityID := getEntityIdForRecord("CUSTOMERS", "1001") - result, err := g2engine.GetEntityByEntityID(ctx, entityID) - if err != nil { - fmt.Println(err) - } - fmt.Println(truncate(result, 51)) - // Output: {"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":... -} - -func ExampleG2engine_GetEntityByEntityID_V2() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - entityID := getEntityIdForRecord("CUSTOMERS", "1001") - flags := int64(0) - result, err := g2engine.GetEntityByEntityID_V2(ctx, entityID, flags) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"RESOLVED_ENTITY":{"ENTITY_ID":1}} -} - -func ExampleG2engine_GetEntityByRecordID() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - dataSourceCode := "CUSTOMERS" - recordID := "1001" - result, err := g2engine.GetEntityByRecordID(ctx, dataSourceCode, recordID) - if err != nil { - fmt.Println(err) - } - fmt.Println(truncate(result, 35)) - // Output: {"RESOLVED_ENTITY":{"ENTITY_ID":... -} - -func ExampleG2engine_GetEntityByRecordID_V2() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - dataSourceCode := "CUSTOMERS" - recordID := "1001" - flags := int64(0) - result, err := g2engine.GetEntityByRecordID_V2(ctx, dataSourceCode, recordID, flags) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"RESOLVED_ENTITY":{"ENTITY_ID":1}} -} - -func ExampleG2engine_GetRecord() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - dataSourceCode := "CUSTOMERS" - recordID := "1001" - result, err := g2engine.GetRecord(ctx, dataSourceCode, recordID) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001","JSON_DATA":{"RECORD_TYPE":"PERSON","PRIMARY_NAME_LAST":"Smith","PRIMARY_NAME_FIRST":"Robert","DATE_OF_BIRTH":"12/11/1978","ADDR_TYPE":"MAILING","ADDR_LINE1":"123 Main Street, Las Vegas NV 89132","PHONE_TYPE":"HOME","PHONE_NUMBER":"702-919-1300","EMAIL_ADDRESS":"bsmith@work.com","DATE":"1/2/18","STATUS":"Active","AMOUNT":"100","DATA_SOURCE":"CUSTOMERS","ENTITY_TYPE":"GENERIC","DSRC_ACTION":"A","RECORD_ID":"1001"}} -} - -func ExampleG2engine_GetRecord_V2() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - dataSourceCode := "CUSTOMERS" - recordID := "1001" - flags := int64(0) - result, err := g2engine.GetRecord_V2(ctx, dataSourceCode, recordID, flags) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001"} -} - -func ExampleG2engine_GetRedoRecord() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - result, err := g2engine.GetRedoRecord(ctx) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"REASON":"deferred delete","DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001","ENTITY_TYPE":"GENERIC","DSRC_ACTION":"X"} -} - -func ExampleG2engine_GetRepositoryLastModifiedTime() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - result, err := g2engine.GetRepositoryLastModifiedTime(ctx) - if err != nil { - fmt.Println(err) - } - fmt.Println(result > 0) // Dummy output. - // Output: true -} - -func ExampleG2engine_GetVirtualEntityByRecordID() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - recordList := `{"RECORDS": [{"DATA_SOURCE": "CUSTOMERS","RECORD_ID": "1001"},{"DATA_SOURCE": "CUSTOMERS","RECORD_ID": "1002"}]}` - result, err := g2engine.GetVirtualEntityByRecordID(ctx, recordList) - if err != nil { - fmt.Println(err) - } - fmt.Println(truncate(result, 51)) - // Output: {"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":... -} - -func ExampleG2engine_GetVirtualEntityByRecordID_V2() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - recordList := `{"RECORDS": [{"DATA_SOURCE": "CUSTOMERS","RECORD_ID": "1001"},{"DATA_SOURCE": "CUSTOMERS","RECORD_ID": "1002"}]}` - flags := int64(0) - result, err := g2engine.GetVirtualEntityByRecordID_V2(ctx, recordList, flags) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"RESOLVED_ENTITY":{"ENTITY_ID":1}} -} - -func ExampleG2engine_HowEntityByEntityID() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - entityID := getEntityIdForRecord("CUSTOMERS", "1001") - result, err := g2engine.HowEntityByEntityID(ctx, entityID) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"HOW_RESULTS":{"RESOLUTION_STEPS":[{"STEP":1,"VIRTUAL_ENTITY_1":{"VIRTUAL_ENTITY_ID":"V1","MEMBER_RECORDS":[{"INTERNAL_ID":1,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001"}]}]},"VIRTUAL_ENTITY_2":{"VIRTUAL_ENTITY_ID":"V2","MEMBER_RECORDS":[{"INTERNAL_ID":2,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1002"}]}]},"INBOUND_VIRTUAL_ENTITY_ID":"V2","RESULT_VIRTUAL_ENTITY_ID":"V1-S1","MATCH_INFO":{"MATCH_KEY":"+NAME+DOB+PHONE","ERRULE_CODE":"CNAME_CFF_CEXCL","FEATURE_SCORES":{"ADDRESS":[{"INBOUND_FEAT_ID":20,"INBOUND_FEAT":"1515 Adela Lane Las Vegas NV 89111","INBOUND_FEAT_USAGE_TYPE":"HOME","CANDIDATE_FEAT_ID":3,"CANDIDATE_FEAT":"123 Main Street, Las Vegas NV 89132","CANDIDATE_FEAT_USAGE_TYPE":"MAILING","FULL_SCORE":42,"SCORE_BUCKET":"NO_CHANCE","SCORE_BEHAVIOR":"FF"}],"DOB":[{"INBOUND_FEAT_ID":19,"INBOUND_FEAT":"11/12/1978","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":2,"CANDIDATE_FEAT":"12/11/1978","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":95,"SCORE_BUCKET":"CLOSE","SCORE_BEHAVIOR":"FMES"}],"NAME":[{"INBOUND_FEAT_ID":18,"INBOUND_FEAT":"Bob Smith","INBOUND_FEAT_USAGE_TYPE":"PRIMARY","CANDIDATE_FEAT_ID":1,"CANDIDATE_FEAT":"Robert Smith","CANDIDATE_FEAT_USAGE_TYPE":"PRIMARY","GNR_FN":97,"GNR_SN":100,"GNR_GN":95,"GENERATION_MATCH":-1,"GNR_ON":-1,"SCORE_BUCKET":"CLOSE","SCORE_BEHAVIOR":"NAME"}],"PHONE":[{"INBOUND_FEAT_ID":4,"INBOUND_FEAT":"702-919-1300","INBOUND_FEAT_USAGE_TYPE":"MOBILE","CANDIDATE_FEAT_ID":4,"CANDIDATE_FEAT":"702-919-1300","CANDIDATE_FEAT_USAGE_TYPE":"HOME","FULL_SCORE":100,"SCORE_BUCKET":"SAME","SCORE_BEHAVIOR":"FF"}],"RECORD_TYPE":[{"INBOUND_FEAT_ID":16,"INBOUND_FEAT":"PERSON","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":16,"CANDIDATE_FEAT":"PERSON","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":100,"SCORE_BUCKET":"SAME","SCORE_BEHAVIOR":"FVME"}]}}},{"STEP":2,"VIRTUAL_ENTITY_1":{"VIRTUAL_ENTITY_ID":"V1-S1","MEMBER_RECORDS":[{"INTERNAL_ID":1,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001"}]},{"INTERNAL_ID":2,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1002"}]}]},"VIRTUAL_ENTITY_2":{"VIRTUAL_ENTITY_ID":"V100001","MEMBER_RECORDS":[{"INTERNAL_ID":100001,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1003"}]}]},"INBOUND_VIRTUAL_ENTITY_ID":"V1-S1","RESULT_VIRTUAL_ENTITY_ID":"V1-S2","MATCH_INFO":{"MATCH_KEY":"+NAME+DOB+EMAIL","ERRULE_CODE":"SF1_PNAME_CSTAB","FEATURE_SCORES":{"DOB":[{"INBOUND_FEAT_ID":2,"INBOUND_FEAT":"12/11/1978","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":2,"CANDIDATE_FEAT":"12/11/1978","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":100,"SCORE_BUCKET":"SAME","SCORE_BEHAVIOR":"FMES"}],"EMAIL":[{"INBOUND_FEAT_ID":5,"INBOUND_FEAT":"bsmith@work.com","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":5,"CANDIDATE_FEAT":"bsmith@work.com","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":100,"SCORE_BUCKET":"SAME","SCORE_BEHAVIOR":"F1"}],"NAME":[{"INBOUND_FEAT_ID":18,"INBOUND_FEAT":"Bob Smith","INBOUND_FEAT_USAGE_TYPE":"PRIMARY","CANDIDATE_FEAT_ID":32,"CANDIDATE_FEAT":"Bob J Smith","CANDIDATE_FEAT_USAGE_TYPE":"PRIMARY","GNR_FN":93,"GNR_SN":100,"GNR_GN":93,"GENERATION_MATCH":-1,"GNR_ON":-1,"SCORE_BUCKET":"CLOSE","SCORE_BEHAVIOR":"NAME"},{"INBOUND_FEAT_ID":1,"INBOUND_FEAT":"Robert Smith","INBOUND_FEAT_USAGE_TYPE":"PRIMARY","CANDIDATE_FEAT_ID":32,"CANDIDATE_FEAT":"Bob J Smith","CANDIDATE_FEAT_USAGE_TYPE":"PRIMARY","GNR_FN":90,"GNR_SN":100,"GNR_GN":88,"GENERATION_MATCH":-1,"GNR_ON":-1,"SCORE_BUCKET":"CLOSE","SCORE_BEHAVIOR":"NAME"}],"RECORD_TYPE":[{"INBOUND_FEAT_ID":16,"INBOUND_FEAT":"PERSON","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":16,"CANDIDATE_FEAT":"PERSON","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":100,"SCORE_BUCKET":"SAME","SCORE_BEHAVIOR":"FVME"}]}}}],"FINAL_STATE":{"NEED_REEVALUATION":0,"VIRTUAL_ENTITIES":[{"VIRTUAL_ENTITY_ID":"V1-S2","MEMBER_RECORDS":[{"INTERNAL_ID":1,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001"}]},{"INTERNAL_ID":2,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1002"}]},{"INTERNAL_ID":100001,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1003"}]}]}]}}} -} - -func ExampleG2engine_HowEntityByEntityID_V2() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - entityID := getEntityIdForRecord("CUSTOMERS", "1001") - flags := int64(0) - result, err := g2engine.HowEntityByEntityID_V2(ctx, entityID, flags) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"HOW_RESULTS":{"RESOLUTION_STEPS":[{"STEP":1,"VIRTUAL_ENTITY_1":{"VIRTUAL_ENTITY_ID":"V1","MEMBER_RECORDS":[{"INTERNAL_ID":1,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001"}]}]},"VIRTUAL_ENTITY_2":{"VIRTUAL_ENTITY_ID":"V2","MEMBER_RECORDS":[{"INTERNAL_ID":2,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1002"}]}]},"INBOUND_VIRTUAL_ENTITY_ID":"V2","RESULT_VIRTUAL_ENTITY_ID":"V1-S1","MATCH_INFO":{"MATCH_KEY":"+NAME+DOB+PHONE","ERRULE_CODE":"CNAME_CFF_CEXCL"}},{"STEP":2,"VIRTUAL_ENTITY_1":{"VIRTUAL_ENTITY_ID":"V1-S1","MEMBER_RECORDS":[{"INTERNAL_ID":1,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001"}]},{"INTERNAL_ID":2,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1002"}]}]},"VIRTUAL_ENTITY_2":{"VIRTUAL_ENTITY_ID":"V100001","MEMBER_RECORDS":[{"INTERNAL_ID":100001,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1003"}]}]},"INBOUND_VIRTUAL_ENTITY_ID":"V1-S1","RESULT_VIRTUAL_ENTITY_ID":"V1-S2","MATCH_INFO":{"MATCH_KEY":"+NAME+DOB+EMAIL","ERRULE_CODE":"SF1_PNAME_CSTAB"}}],"FINAL_STATE":{"NEED_REEVALUATION":0,"VIRTUAL_ENTITIES":[{"VIRTUAL_ENTITY_ID":"V1-S2","MEMBER_RECORDS":[{"INTERNAL_ID":1,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001"}]},{"INTERNAL_ID":2,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1002"}]},{"INTERNAL_ID":100001,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1003"}]}]}]}}} -} - -func ExampleG2engine_PrimeEngine() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - err := g2engine.PrimeEngine(ctx) - if err != nil { - fmt.Println(err) - } - // Output: -} - -func ExampleG2engine_SearchByAttributes() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - jsonData := `{"NAMES": [{"NAME_TYPE": "PRIMARY", "NAME_LAST": "Smith"}], "EMAIL_ADDRESS": "bsmith@work.com"}` - result, err := g2engine.SearchByAttributes(ctx, jsonData) - if err != nil { - fmt.Println(err) - } - fmt.Println(truncate(result, 1962)) - // Output: {"RESOLVED_ENTITIES":[{"MATCH_INFO":{"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PNAME+EMAIL","ERRULE_CODE":"SF1","FEATURE_SCORES":{"EMAIL":[{"INBOUND_FEAT":"bsmith@work.com","CANDIDATE_FEAT":"bsmith@work.com","FULL_SCORE":100}],"NAME":[{"INBOUND_FEAT":"Smith","CANDIDATE_FEAT":"Bob J Smith","GNR_FN":83,"GNR_SN":100,"GNR_GN":40,"GENERATION_MATCH":-1,"GNR_ON":-1},{"INBOUND_FEAT":"Smith","CANDIDATE_FEAT":"Robert Smith","GNR_FN":88,"GNR_SN":100,"GNR_GN":40,"GENERATION_MATCH":-1,"GNR_ON":-1}]}},"ENTITY":{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"Robert Smith","FEATURES":{"ADDRESS":[{"FEAT_DESC":"1515 Adela Lane Las Vegas NV 89111","LIB_FEAT_ID":20,"USAGE_TYPE":"HOME","FEAT_DESC_VALUES":[{"FEAT_DESC":"1515 Adela Lane Las Vegas NV 89111","LIB_FEAT_ID":20}]},{"FEAT_DESC":"123 Main Street, Las Vegas NV 89132","LIB_FEAT_ID":3,"USAGE_TYPE":"MAILING","FEAT_DESC_VALUES":[{"FEAT_DESC":"123 Main Street, Las Vegas NV 89132","LIB_FEAT_ID":3}]}],"DOB":[{"FEAT_DESC":"12/11/1978","LIB_FEAT_ID":2,"FEAT_DESC_VALUES":[{"FEAT_DESC":"12/11/1978","LIB_FEAT_ID":2},{"FEAT_DESC":"11/12/1978","LIB_FEAT_ID":19}]}],"EMAIL":[{"FEAT_DESC":"bsmith@work.com","LIB_FEAT_ID":5,"FEAT_DESC_VALUES":[{"FEAT_DESC":"bsmith@work.com","LIB_FEAT_ID":5}]}],"NAME":[{"FEAT_DESC":"Robert Smith","LIB_FEAT_ID":1,"USAGE_TYPE":"PRIMARY","FEAT_DESC_VALUES":[{"FEAT_DESC":"Robert Smith","LIB_FEAT_ID":1},{"FEAT_DESC":"Bob J Smith","LIB_FEAT_ID":32},{"FEAT_DESC":"Bob Smith","LIB_FEAT_ID":18}]}],"PHONE":[{"FEAT_DESC":"702-919-1300","LIB_FEAT_ID":4,"USAGE_TYPE":"HOME","FEAT_DESC_VALUES":[{"FEAT_DESC":"702-919-1300","LIB_FEAT_ID":4}]},{"FEAT_DESC":"702-919-1300","LIB_FEAT_ID":4,"USAGE_TYPE":"MOBILE","FEAT_DESC_VALUES":[{"FEAT_DESC":"702-919-1300","LIB_FEAT_ID":4}]}],"RECORD_TYPE":[{"FEAT_DESC":"PERSON","LIB_FEAT_ID":16,"FEAT_DESC_VALUES":[{"FEAT_DESC":"PERSON","LIB_FEAT_ID":16}]}]},"RECORD_SUMMARY":[{"DATA_SOURCE":"CUSTOMERS","RECORD_COUNT":3,"FIRST_SEEN_DT":... -} - -func ExampleG2engine_SearchByAttributes_V2() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - jsonData := `{"NAMES": [{"NAME_TYPE": "PRIMARY", "NAME_LAST": "Smith"}], "EMAIL_ADDRESS": "bsmith@work.com"}` - flags := int64(0) - result, err := g2engine.SearchByAttributes_V2(ctx, jsonData, flags) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"RESOLVED_ENTITIES":[{"MATCH_INFO":{"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PNAME+EMAIL","ERRULE_CODE":"SF1"},"ENTITY":{"RESOLVED_ENTITY":{"ENTITY_ID":1}}}]} -} - -func ExampleG2engine_SetLogLevel() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - err := g2engine.SetLogLevel(ctx, logging.LevelInfoName) - if err != nil { - fmt.Println(err) - } - // Output: -} - -func ExampleG2engine_Stats() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - result, err := g2engine.Stats(ctx) - if err != nil { - fmt.Println(err) - } - fmt.Println(truncate(result, 138)) - // Output: { "workload": { "loadedRecords": 5, "addedRecords": 5, "deletedRecords": 1, "reevaluations": 0, "repairedEntities": 0, "duration":... -} - -func ExampleG2engine_WhyEntities() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - entityID1 := getEntityId(truthset.CustomerRecords["1001"]) - entityID2 := getEntityId(truthset.CustomerRecords["1002"]) - result, err := g2engine.WhyEntities(ctx, entityID1, entityID2) - if err != nil { - fmt.Println(err) - } - fmt.Println(truncate(result, 74)) - // Output: {"WHY_RESULTS":[{"ENTITY_ID":1,"ENTITY_ID_2":1,"MATCH_INFO":{"WHY_KEY":... -} - -func ExampleG2engine_WhyEntities_V2() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - entityID1 := getEntityId(truthset.CustomerRecords["1001"]) - entityID2 := getEntityId(truthset.CustomerRecords["1002"]) - flags := int64(0) - result, err := g2engine.WhyEntities_V2(ctx, entityID1, entityID2, flags) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"WHY_RESULTS":[{"ENTITY_ID":1,"ENTITY_ID_2":1,"MATCH_INFO":{"WHY_KEY":"+NAME+DOB+ADDRESS+PHONE+EMAIL","WHY_ERRULE_CODE":"SF1_SNAME_CFF_CSTAB","MATCH_LEVEL_CODE":"RESOLVED"}}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1}}]} -} - -func ExampleG2engine_WhyRecords() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - dataSourceCode1 := "CUSTOMERS" - recordID1 := "1001" - dataSourceCode2 := "CUSTOMERS" - recordID2 := "1002" - result, err := g2engine.WhyRecords(ctx, dataSourceCode1, recordID1, dataSourceCode2, recordID2) - if err != nil { - fmt.Println(err) - } - fmt.Println(truncate(result, 115)) - // Output: {"WHY_RESULTS":[{"INTERNAL_ID":1,"ENTITY_ID":1,"FOCUS_RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001"}],... -} - -func ExampleG2engine_WhyRecords_V2() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - dataSourceCode1 := "CUSTOMERS" - recordID1 := "1001" - dataSourceCode2 := "CUSTOMERS" - recordID2 := "1002" - flags := int64(0) - result, err := g2engine.WhyRecords_V2(ctx, dataSourceCode1, recordID1, dataSourceCode2, recordID2, flags) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"WHY_RESULTS":[{"INTERNAL_ID":1,"ENTITY_ID":1,"FOCUS_RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001"}],"INTERNAL_ID_2":2,"ENTITY_ID_2":1,"FOCUS_RECORDS_2":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1002"}],"MATCH_INFO":{"WHY_KEY":"+NAME+DOB+PHONE","WHY_ERRULE_CODE":"CNAME_CFF_CEXCL","MATCH_LEVEL_CODE":"RESOLVED"}}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1}}]} -} - -// func ExampleG2engine_ProcessRedoRecord() { -// // For more information, visit https://github.com/senzing-garage/g2-sdk-go-base/blob/main/g2engine/g2engine_test.go -// ctx := context.TODO() -// g2engine := getG2Engine(ctx) -// result, err := g2engine.ProcessRedoRecord(ctx) -// if err != nil { -// fmt.Println(err) -// } -// fmt.Println(result) -// // Output: -// } - -// func ExampleG2engine_ProcessRedoRecordWithInfo() { -// // For more information, visit https://github.com/senzing-garage/g2-sdk-go-base/blob/main/g2engine/g2engine_test.go -// ctx := context.TODO() -// g2engine := getG2Engine(ctx) -// flags := int64(0) -// _, result, err := g2engine.ProcessRedoRecordWithInfo(ctx, flags) -// if err != nil { -// fmt.Println(err) -// } -// fmt.Println(result) -// // Output: -// } - -func ExampleG2engine_ReevaluateEntity() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - entityID := getEntityIdForRecord("CUSTOMERS", "1001") - flags := int64(0) - err := g2engine.ReevaluateEntity(ctx, entityID, flags) - if err != nil { - fmt.Println(err) - } - // Output: -} -func ExampleG2engine_ReevaluateEntityWithInfo() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - entityID := getEntityIdForRecord("CUSTOMERS", "1001") - flags := int64(0) - result, err := g2engine.ReevaluateEntityWithInfo(ctx, entityID, flags) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001","AFFECTED_ENTITIES":[{"ENTITY_ID":1}],"INTERESTING_ENTITIES":{"ENTITIES":[]}} -} - -func ExampleG2engine_ReevaluateRecord() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - dataSourceCode := "CUSTOMERS" - recordID := "1001" - flags := int64(0) - err := g2engine.ReevaluateRecord(ctx, dataSourceCode, recordID, flags) - if err != nil { - fmt.Println(err) - } - // Output: -} - -func ExampleG2engine_ReevaluateRecordWithInfo() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - dataSourceCode := "CUSTOMERS" - recordID := "1001" - flags := int64(0) - result, err := g2engine.ReevaluateRecordWithInfo(ctx, dataSourceCode, recordID, flags) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001","AFFECTED_ENTITIES":[{"ENTITY_ID":1}],"INTERESTING_ENTITIES":{"ENTITIES":[]}} -} - -func ExampleG2engine_ReplaceRecord() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - dataSourceCode := "CUSTOMERS" - recordID := "1001" - jsonData := `{"DATA_SOURCE": "CUSTOMERS", "RECORD_ID": "1001", "RECORD_TYPE": "PERSON", "PRIMARY_NAME_LAST": "Smith", "PRIMARY_NAME_FIRST": "Robert", "DATE_OF_BIRTH": "12/11/1978", "ADDR_TYPE": "MAILING", "ADDR_LINE1": "123 Main Street, Las Vegas NV 89132", "PHONE_TYPE": "HOME", "PHONE_NUMBER": "702-919-1300", "EMAIL_ADDRESS": "bsmith@work.com", "DATE": "1/2/18", "STATUS": "Active", "AMOUNT": "100"}` - loadID := "G2Engine_test" - err := g2engine.ReplaceRecord(ctx, dataSourceCode, recordID, jsonData, loadID) - if err != nil { - fmt.Println(err) - } - // Output: -} - -func ExampleG2engine_ReplaceRecordWithInfo() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - dataSourceCode := "CUSTOMERS" - recordID := "1001" - jsonData := `{"DATA_SOURCE": "CUSTOMERS", "RECORD_ID": "1001", "RECORD_TYPE": "PERSON", "PRIMARY_NAME_LAST": "Smith", "PRIMARY_NAME_FIRST": "Robert", "DATE_OF_BIRTH": "12/11/1978", "ADDR_TYPE": "MAILING", "ADDR_LINE1": "123 Main Street, Las Vegas NV 89132", "PHONE_TYPE": "HOME", "PHONE_NUMBER": "702-919-1300", "EMAIL_ADDRESS": "bsmith@work.com", "DATE": "1/2/18", "STATUS": "Active", "AMOUNT": "100"}` - loadID := "G2Engine_test" - flags := int64(0) - result, err := g2engine.ReplaceRecordWithInfo(ctx, dataSourceCode, recordID, jsonData, loadID, flags) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001","AFFECTED_ENTITIES":[],"INTERESTING_ENTITIES":{"ENTITIES":[]}} -} - -func ExampleG2engine_DeleteRecord() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - dataSourceCode := "CUSTOMERS" - recordID := "1003" - loadID := "G2Engine_test" - err := g2engine.DeleteRecord(ctx, dataSourceCode, recordID, loadID) - if err != nil { - fmt.Println(err) - } - // Output: -} - -func ExampleG2engine_DeleteRecordWithInfo() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - dataSourceCode := "CUSTOMERS" - recordID := "1003" - loadID := "G2Engine_test" - flags := int64(0) - result, err := g2engine.DeleteRecordWithInfo(ctx, dataSourceCode, recordID, loadID, flags) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1003","AFFECTED_ENTITIES":[],"INTERESTING_ENTITIES":{"ENTITIES":[]}} -} - -func ExampleG2engine_Init() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - moduleName := "Test module name" - iniParams := "{}" - verboseLogging := int64(0) - err := g2engine.Init(ctx, moduleName, iniParams, verboseLogging) - if err != nil { - // This should produce a "senzing-60144002" error. - } - // Output: -} - -func ExampleG2engine_InitWithConfigID() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - moduleName := "Test module name" - iniParams := "{}" - initConfigID := int64(1) - verboseLogging := int64(0) - err := g2engine.InitWithConfigID(ctx, moduleName, iniParams, initConfigID, verboseLogging) - if err != nil { - // This should produce a "senzing-60144003" error. - } - // Output: -} - -func ExampleG2engine_Reinit() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - initConfigID, _ := g2engine.GetActiveConfigID(ctx) // Example initConfigID. - err := g2engine.Reinit(ctx, initConfigID) - if err != nil { - fmt.Println(err) - } - // Output: -} - -func ExampleG2engine_Destroy() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2engine/g2engine_examples_test.go - ctx := context.TODO() - g2engine := getG2Engine(ctx) - err := g2engine.Destroy(ctx) - if err != nil { - // This should produce a "senzing-60164001" error. - } - // Output: -} diff --git a/g2engine/g2engine_test.go b/g2engine/g2engine_test.go deleted file mode 100644 index d4287eb..0000000 --- a/g2engine/g2engine_test.go +++ /dev/null @@ -1,946 +0,0 @@ -package g2engine - -import ( - "context" - "encoding/json" - "fmt" - "os" - "strconv" - "strings" - "testing" - - truncator "github.com/aquilax/truncate" - "github.com/senzing-garage/g2-sdk-go/g2api" - "github.com/senzing-garage/go-common/record" - "github.com/senzing-garage/go-common/testfixtures" - "github.com/senzing-garage/go-common/truthset" - "github.com/stretchr/testify/assert" -) - -const ( - defaultTruncation = 76 - loadId = "G2Engine_test" - moduleName = "Engine Test Module" - printResults = false - verboseLogging = 0 -) - -type GetEntityByRecordIDResponse struct { - ResolvedEntity struct { - EntityId int64 `json:"ENTITY_ID"` - } `json:"RESOLVED_ENTITY"` -} - -var ( - g2engineSingleton *G2engine - senzingConfigId int64 = 0 -) - -// ---------------------------------------------------------------------------- -// Internal functions -// ---------------------------------------------------------------------------- - -func getTestObject(ctx context.Context, test *testing.T) *G2engine { - return getG2Engine(ctx) -} - -func getG2Engine(ctx context.Context) *G2engine { - if g2engineSingleton == nil { - g2engineSingleton = &G2engine{ - AddRecordWithInfoResult: `{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1003","AFFECTED_ENTITIES":[{"ENTITY_ID":1}],"INTERESTING_ENTITIES":{"ENTITIES":[]}}`, - CountRedoRecordsResult: int64(1), - DeleteRecordWithInfoResult: `{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1003","AFFECTED_ENTITIES":[],"INTERESTING_ENTITIES":{"ENTITIES":[]}}`, - ExportConfigResult: `{"G2_CONFIG":{"CFG_ETYPE":[{"ETYPE_ID":...`, - ExportConfigAndConfigIDResultConfig: ``, - ExportConfigAndConfigIDResultConfigID: int64(1), - ExportCSVEntityReportResult: 1, - ExportJSONEntityReportResult: 1, - FetchNextResult: ``, - FindInterestingEntitiesByEntityIDResult: `{"INTERESTING_ENTITIES":{"ENTITIES":[]}}`, - FindInterestingEntitiesByRecordIDResult: `{"INTERESTING_ENTITIES":{"ENTITIES":[]}}`, - FindNetworkByEntityID_V2Result: `{"ENTITY_PATHS":[],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1}}]}`, - FindNetworkByEntityIDResult: `{"ENTITY_PATHS":[],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"Robert Smith","RECORD_SUMMARY":[{"DATA_SOURCE":"CUSTOMERS","RECORD_COUNT":3,"FIRST_SEEN_DT":...`, - FindNetworkByRecordID_V2Result: `{"ENTITY_PATHS":[],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1}}]}`, - FindNetworkByRecordIDResult: `{"ENTITY_PATHS":[],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"Robert Smith","RECORD_SUMMARY":[{"DATA_SOURCE":"CUSTOMERS","RECORD_COUNT":3,"FIRST_SEEN_DT":...`, - FindPathByEntityID_V2Result: `{"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[1]}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1}}]}`, - FindPathByEntityIDResult: `{"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[1]}],"ENTITIES":[{"RESOLVED_ENTITY":...`, - FindPathByRecordID_V2Result: `{"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[1]}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1}}]}`, - FindPathByRecordIDResult: `{"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[1]}],"ENTITIES":...`, - FindPathExcludingByEntityID_V2Result: `{"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[1]}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1}}]}`, - FindPathExcludingByEntityIDResult: `{"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[1]}],"ENTITIES":[{"RESOLVED_ENTITY":...`, - FindPathExcludingByRecordID_V2Result: `{"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[1]}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1}}]}`, - FindPathExcludingByRecordIDResult: `{"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[1]}],"ENTITIES":[{"RESOLVED_ENTITY":...`, - FindPathIncludingSourceByEntityID_V2Result: `{"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[]}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1}}]}`, - FindPathIncludingSourceByEntityIDResult: `{"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[]}],"ENTITIES":[{"RESOLVED_ENTITY":...`, - FindPathIncludingSourceByRecordID_V2Result: `{"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[]}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1}}]}`, - FindPathIncludingSourceByRecordIDResult: `{"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[]}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1}}]}`, - GetActiveConfigIDResult: int64(1), - GetEntityByEntityID_V2Result: `{"RESOLVED_ENTITY":{"ENTITY_ID":1}}`, - GetEntityByEntityIDResult: `{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":...`, - GetEntityByRecordID_V2Result: `{"RESOLVED_ENTITY":{"ENTITY_ID":1}}`, - GetEntityByRecordIDResult: `{"RESOLVED_ENTITY":{"ENTITY_ID":...`, - GetRecord_V2Result: `{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001"}`, - GetRecordResult: `{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001","JSON_DATA":{"RECORD_TYPE":"PERSON","PRIMARY_NAME_LAST":"Smith","PRIMARY_NAME_FIRST":"Robert","DATE_OF_BIRTH":"12/11/1978","ADDR_TYPE":"MAILING","ADDR_LINE1":"123 Main Street, Las Vegas NV 89132","PHONE_TYPE":"HOME","PHONE_NUMBER":"702-919-1300","EMAIL_ADDRESS":"bsmith@work.com","DATE":"1/2/18","STATUS":"Active","AMOUNT":"100","DATA_SOURCE":"CUSTOMERS","ENTITY_TYPE":"GENERIC","DSRC_ACTION":"A","RECORD_ID":"1001"}}`, - GetRedoRecordResult: `{"REASON":"deferred delete","DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001","ENTITY_TYPE":"GENERIC","DSRC_ACTION":"X"}`, - GetRepositoryLastModifiedTimeResult: int64(1), - GetVirtualEntityByRecordID_V2Result: `{"RESOLVED_ENTITY":{"ENTITY_ID":1}}`, - GetVirtualEntityByRecordIDResult: `{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":...`, - HowEntityByEntityID_V2Result: `{"HOW_RESULTS":{"RESOLUTION_STEPS":[{"STEP":1,"VIRTUAL_ENTITY_1":{"VIRTUAL_ENTITY_ID":"V1","MEMBER_RECORDS":[{"INTERNAL_ID":1,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001"}]}]},"VIRTUAL_ENTITY_2":{"VIRTUAL_ENTITY_ID":"V2","MEMBER_RECORDS":[{"INTERNAL_ID":2,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1002"}]}]},"INBOUND_VIRTUAL_ENTITY_ID":"V2","RESULT_VIRTUAL_ENTITY_ID":"V1-S1","MATCH_INFO":{"MATCH_KEY":"+NAME+DOB+PHONE","ERRULE_CODE":"CNAME_CFF_CEXCL"}},{"STEP":2,"VIRTUAL_ENTITY_1":{"VIRTUAL_ENTITY_ID":"V1-S1","MEMBER_RECORDS":[{"INTERNAL_ID":1,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001"}]},{"INTERNAL_ID":2,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1002"}]}]},"VIRTUAL_ENTITY_2":{"VIRTUAL_ENTITY_ID":"V100001","MEMBER_RECORDS":[{"INTERNAL_ID":100001,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1003"}]}]},"INBOUND_VIRTUAL_ENTITY_ID":"V1-S1","RESULT_VIRTUAL_ENTITY_ID":"V1-S2","MATCH_INFO":{"MATCH_KEY":"+NAME+DOB+EMAIL","ERRULE_CODE":"SF1_PNAME_CSTAB"}}],"FINAL_STATE":{"NEED_REEVALUATION":0,"VIRTUAL_ENTITIES":[{"VIRTUAL_ENTITY_ID":"V1-S2","MEMBER_RECORDS":[{"INTERNAL_ID":1,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001"}]},{"INTERNAL_ID":2,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1002"}]},{"INTERNAL_ID":100001,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1003"}]}]}]}}}`, - HowEntityByEntityIDResult: `{"HOW_RESULTS":{"RESOLUTION_STEPS":[{"STEP":1,"VIRTUAL_ENTITY_1":{"VIRTUAL_ENTITY_ID":"V1","MEMBER_RECORDS":[{"INTERNAL_ID":1,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001"}]}]},"VIRTUAL_ENTITY_2":{"VIRTUAL_ENTITY_ID":"V2","MEMBER_RECORDS":[{"INTERNAL_ID":2,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1002"}]}]},"INBOUND_VIRTUAL_ENTITY_ID":"V2","RESULT_VIRTUAL_ENTITY_ID":"V1-S1","MATCH_INFO":{"MATCH_KEY":"+NAME+DOB+PHONE","ERRULE_CODE":"CNAME_CFF_CEXCL","FEATURE_SCORES":{"ADDRESS":[{"INBOUND_FEAT_ID":20,"INBOUND_FEAT":"1515 Adela Lane Las Vegas NV 89111","INBOUND_FEAT_USAGE_TYPE":"HOME","CANDIDATE_FEAT_ID":3,"CANDIDATE_FEAT":"123 Main Street, Las Vegas NV 89132","CANDIDATE_FEAT_USAGE_TYPE":"MAILING","FULL_SCORE":42,"SCORE_BUCKET":"NO_CHANCE","SCORE_BEHAVIOR":"FF"}],"DOB":[{"INBOUND_FEAT_ID":19,"INBOUND_FEAT":"11/12/1978","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":2,"CANDIDATE_FEAT":"12/11/1978","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":95,"SCORE_BUCKET":"CLOSE","SCORE_BEHAVIOR":"FMES"}],"NAME":[{"INBOUND_FEAT_ID":18,"INBOUND_FEAT":"Bob Smith","INBOUND_FEAT_USAGE_TYPE":"PRIMARY","CANDIDATE_FEAT_ID":1,"CANDIDATE_FEAT":"Robert Smith","CANDIDATE_FEAT_USAGE_TYPE":"PRIMARY","GNR_FN":97,"GNR_SN":100,"GNR_GN":95,"GENERATION_MATCH":-1,"GNR_ON":-1,"SCORE_BUCKET":"CLOSE","SCORE_BEHAVIOR":"NAME"}],"PHONE":[{"INBOUND_FEAT_ID":4,"INBOUND_FEAT":"702-919-1300","INBOUND_FEAT_USAGE_TYPE":"MOBILE","CANDIDATE_FEAT_ID":4,"CANDIDATE_FEAT":"702-919-1300","CANDIDATE_FEAT_USAGE_TYPE":"HOME","FULL_SCORE":100,"SCORE_BUCKET":"SAME","SCORE_BEHAVIOR":"FF"}],"RECORD_TYPE":[{"INBOUND_FEAT_ID":16,"INBOUND_FEAT":"PERSON","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":16,"CANDIDATE_FEAT":"PERSON","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":100,"SCORE_BUCKET":"SAME","SCORE_BEHAVIOR":"FVME"}]}}},{"STEP":2,"VIRTUAL_ENTITY_1":{"VIRTUAL_ENTITY_ID":"V1-S1","MEMBER_RECORDS":[{"INTERNAL_ID":1,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001"}]},{"INTERNAL_ID":2,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1002"}]}]},"VIRTUAL_ENTITY_2":{"VIRTUAL_ENTITY_ID":"V100001","MEMBER_RECORDS":[{"INTERNAL_ID":100001,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1003"}]}]},"INBOUND_VIRTUAL_ENTITY_ID":"V1-S1","RESULT_VIRTUAL_ENTITY_ID":"V1-S2","MATCH_INFO":{"MATCH_KEY":"+NAME+DOB+EMAIL","ERRULE_CODE":"SF1_PNAME_CSTAB","FEATURE_SCORES":{"DOB":[{"INBOUND_FEAT_ID":2,"INBOUND_FEAT":"12/11/1978","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":2,"CANDIDATE_FEAT":"12/11/1978","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":100,"SCORE_BUCKET":"SAME","SCORE_BEHAVIOR":"FMES"}],"EMAIL":[{"INBOUND_FEAT_ID":5,"INBOUND_FEAT":"bsmith@work.com","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":5,"CANDIDATE_FEAT":"bsmith@work.com","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":100,"SCORE_BUCKET":"SAME","SCORE_BEHAVIOR":"F1"}],"NAME":[{"INBOUND_FEAT_ID":18,"INBOUND_FEAT":"Bob Smith","INBOUND_FEAT_USAGE_TYPE":"PRIMARY","CANDIDATE_FEAT_ID":32,"CANDIDATE_FEAT":"Bob J Smith","CANDIDATE_FEAT_USAGE_TYPE":"PRIMARY","GNR_FN":93,"GNR_SN":100,"GNR_GN":93,"GENERATION_MATCH":-1,"GNR_ON":-1,"SCORE_BUCKET":"CLOSE","SCORE_BEHAVIOR":"NAME"},{"INBOUND_FEAT_ID":1,"INBOUND_FEAT":"Robert Smith","INBOUND_FEAT_USAGE_TYPE":"PRIMARY","CANDIDATE_FEAT_ID":32,"CANDIDATE_FEAT":"Bob J Smith","CANDIDATE_FEAT_USAGE_TYPE":"PRIMARY","GNR_FN":90,"GNR_SN":100,"GNR_GN":88,"GENERATION_MATCH":-1,"GNR_ON":-1,"SCORE_BUCKET":"CLOSE","SCORE_BEHAVIOR":"NAME"}],"RECORD_TYPE":[{"INBOUND_FEAT_ID":16,"INBOUND_FEAT":"PERSON","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":16,"CANDIDATE_FEAT":"PERSON","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":100,"SCORE_BUCKET":"SAME","SCORE_BEHAVIOR":"FVME"}]}}}],"FINAL_STATE":{"NEED_REEVALUATION":0,"VIRTUAL_ENTITIES":[{"VIRTUAL_ENTITY_ID":"V1-S2","MEMBER_RECORDS":[{"INTERNAL_ID":1,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001"}]},{"INTERNAL_ID":2,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1002"}]},{"INTERNAL_ID":100001,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1003"}]}]}]}}}`, - ProcessRedoRecordResult: ``, - ProcessRedoRecordWithInfoResult: `{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001","AFFECTED_ENTITIES":[],"INTERESTING_ENTITIES":{"ENTITIES":[]}}`, - ProcessRedoRecordWithInfoResultWithInfo: ``, - ReevaluateEntityWithInfoResult: `{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001","AFFECTED_ENTITIES":[{"ENTITY_ID":1}],"INTERESTING_ENTITIES":{"ENTITIES":[]}}`, - ReevaluateRecordWithInfoResult: `{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001","AFFECTED_ENTITIES":[{"ENTITY_ID":1}],"INTERESTING_ENTITIES":{"ENTITIES":[]}}`, - ReplaceRecordWithInfoResult: `{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001","AFFECTED_ENTITIES":[],"INTERESTING_ENTITIES":{"ENTITIES":[]}}`, - SearchByAttributes_V2Result: `{"RESOLVED_ENTITIES":[{"MATCH_INFO":{"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PNAME+EMAIL","ERRULE_CODE":"SF1"},"ENTITY":{"RESOLVED_ENTITY":{"ENTITY_ID":1}}}]}`, - SearchByAttributesResult: `{"RESOLVED_ENTITIES":[{"MATCH_INFO":{"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PNAME+EMAIL","ERRULE_CODE":"SF1","FEATURE_SCORES":{"EMAIL":[{"INBOUND_FEAT":"bsmith@work.com","CANDIDATE_FEAT":"bsmith@work.com","FULL_SCORE":100}],"NAME":[{"INBOUND_FEAT":"Smith","CANDIDATE_FEAT":"Bob J Smith","GNR_FN":83,"GNR_SN":100,"GNR_GN":40,"GENERATION_MATCH":-1,"GNR_ON":-1},{"INBOUND_FEAT":"Smith","CANDIDATE_FEAT":"Robert Smith","GNR_FN":88,"GNR_SN":100,"GNR_GN":40,"GENERATION_MATCH":-1,"GNR_ON":-1}]}},"ENTITY":{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"Robert Smith","FEATURES":{"ADDRESS":[{"FEAT_DESC":"1515 Adela Lane Las Vegas NV 89111","LIB_FEAT_ID":20,"USAGE_TYPE":"HOME","FEAT_DESC_VALUES":[{"FEAT_DESC":"1515 Adela Lane Las Vegas NV 89111","LIB_FEAT_ID":20}]},{"FEAT_DESC":"123 Main Street, Las Vegas NV 89132","LIB_FEAT_ID":3,"USAGE_TYPE":"MAILING","FEAT_DESC_VALUES":[{"FEAT_DESC":"123 Main Street, Las Vegas NV 89132","LIB_FEAT_ID":3}]}],"DOB":[{"FEAT_DESC":"12/11/1978","LIB_FEAT_ID":2,"FEAT_DESC_VALUES":[{"FEAT_DESC":"12/11/1978","LIB_FEAT_ID":2},{"FEAT_DESC":"11/12/1978","LIB_FEAT_ID":19}]}],"EMAIL":[{"FEAT_DESC":"bsmith@work.com","LIB_FEAT_ID":5,"FEAT_DESC_VALUES":[{"FEAT_DESC":"bsmith@work.com","LIB_FEAT_ID":5}]}],"NAME":[{"FEAT_DESC":"Robert Smith","LIB_FEAT_ID":1,"USAGE_TYPE":"PRIMARY","FEAT_DESC_VALUES":[{"FEAT_DESC":"Robert Smith","LIB_FEAT_ID":1},{"FEAT_DESC":"Bob J Smith","LIB_FEAT_ID":32},{"FEAT_DESC":"Bob Smith","LIB_FEAT_ID":18}]}],"PHONE":[{"FEAT_DESC":"702-919-1300","LIB_FEAT_ID":4,"USAGE_TYPE":"HOME","FEAT_DESC_VALUES":[{"FEAT_DESC":"702-919-1300","LIB_FEAT_ID":4}]},{"FEAT_DESC":"702-919-1300","LIB_FEAT_ID":4,"USAGE_TYPE":"MOBILE","FEAT_DESC_VALUES":[{"FEAT_DESC":"702-919-1300","LIB_FEAT_ID":4}]}],"RECORD_TYPE":[{"FEAT_DESC":"PERSON","LIB_FEAT_ID":16,"FEAT_DESC_VALUES":[{"FEAT_DESC":"PERSON","LIB_FEAT_ID":16}]}]},"RECORD_SUMMARY":[{"DATA_SOURCE":"CUSTOMERS","RECORD_COUNT":3,"FIRST_SEEN_DT":...`, - StatsResult: `{ "workload": { "loadedRecords": 5, "addedRecords": 5, "deletedRecords": 1, "reevaluations": 0, "repairedEntities": 0, "duration":...`, - WhyEntities_V2Result: `{"WHY_RESULTS":[{"ENTITY_ID":1,"ENTITY_ID_2":1,"MATCH_INFO":{"WHY_KEY":"+NAME+DOB+ADDRESS+PHONE+EMAIL","WHY_ERRULE_CODE":"SF1_SNAME_CFF_CSTAB","MATCH_LEVEL_CODE":"RESOLVED"}}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1}}]}`, - WhyEntitiesResult: `{"WHY_RESULTS":[{"ENTITY_ID":1,"ENTITY_ID_2":1,"MATCH_INFO":{"WHY_KEY":...`, - WhyRecords_V2Result: `{"WHY_RESULTS":[{"INTERNAL_ID":1,"ENTITY_ID":1,"FOCUS_RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001"}],"INTERNAL_ID_2":2,"ENTITY_ID_2":1,"FOCUS_RECORDS_2":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1002"}],"MATCH_INFO":{"WHY_KEY":"+NAME+DOB+PHONE","WHY_ERRULE_CODE":"CNAME_CFF_CEXCL","MATCH_LEVEL_CODE":"RESOLVED"}}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1}}]}`, - WhyRecordsResult: `{"WHY_RESULTS":[{"INTERNAL_ID":1,"ENTITY_ID":1,"FOCUS_RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001"}],"INTERNAL_ID_2":2,"ENTITY_ID_2":1,"FOCUS_RECORDS_2":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1002"}],"MATCH_INFO":{"WHY_KEY":"+NAME+DOB+PHONE","WHY_ERRULE_CODE":"CNAME_CFF_CEXCL","MATCH_LEVEL_CODE":"RESOLVED"}}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1}}]}`, - } - } - return g2engineSingleton -} - -func getEntityIdForRecord(datasource string, id string) int64 { - ctx := context.TODO() - var result int64 = 0 - g2engine := getG2Engine(ctx) - response, err := g2engine.GetEntityByRecordID(ctx, datasource, id) - if err != nil { - return result - } - getEntityByRecordIDResponse := &GetEntityByRecordIDResponse{} - err = json.Unmarshal([]byte(response), &getEntityByRecordIDResponse) - if err != nil { - return result - } - return getEntityByRecordIDResponse.ResolvedEntity.EntityId -} - -func getEntityIdStringForRecord(datasource string, id string) string { - entityId := getEntityIdForRecord(datasource, id) - return strconv.FormatInt(entityId, 10) -} - -func getEntityId(record record.Record) int64 { - return getEntityIdForRecord(record.DataSource, record.Id) -} - -func getEntityIdString(record record.Record) string { - entityId := getEntityId(record) - return strconv.FormatInt(entityId, 10) -} - -func truncate(aString string, length int) string { - return truncator.Truncate(aString, length, "...", truncator.PositionEnd) -} - -func printResult(test *testing.T, title string, result interface{}) { - if printResults { - test.Logf("%s: %v", title, truncate(fmt.Sprintf("%v", result), defaultTruncation)) - } -} - -func printActual(test *testing.T, actual interface{}) { - printResult(test, "Actual", actual) -} - -func testError(test *testing.T, ctx context.Context, g2engine g2api.G2engine, err error) { - if err != nil { - test.Log("Error:", err.Error()) - assert.FailNow(test, err.Error()) - } -} - -func testErrorNoFail(test *testing.T, ctx context.Context, g2engine g2api.G2engine, err error) { - if err != nil { - test.Log("Error:", err.Error()) - } -} - -// ---------------------------------------------------------------------------- -// Test harness -// ---------------------------------------------------------------------------- - -func TestMain(m *testing.M) { - err := setup() - if err != nil { - fmt.Print(err) - os.Exit(1) - } - code := m.Run() - err = teardown() - if err != nil { - fmt.Print(err) - } - os.Exit(code) -} - -func getIniParams() (string, error) { - return "{}", nil -} - -func setup() error { - var err error = nil - return err -} - -func teardown() error { - var err error = nil - return err -} - -// ---------------------------------------------------------------------------- -// Test interface functions -// ---------------------------------------------------------------------------- - -func TestG2engine_SetObserverOrigin(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - origin := "Machine: nn; Task: UnitTest" - g2engine.SetObserverOrigin(ctx, origin) -} - -func TestG2engine_GetObserverOrigin(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - origin := "Machine: nn; Task: UnitTest" - g2engine.SetObserverOrigin(ctx, origin) - actual := g2engine.GetObserverOrigin(ctx) - assert.Equal(test, origin, actual) -} - -func TestG2engine_AddRecord(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - record1 := truthset.CustomerRecords["1001"] - record2 := truthset.CustomerRecords["1002"] - err := g2engine.AddRecord(ctx, record1.DataSource, record1.Id, record1.Json, loadId) - testError(test, ctx, g2engine, err) - err = g2engine.AddRecord(ctx, record2.DataSource, record2.Id, record2.Json, loadId) - testError(test, ctx, g2engine, err) -} - -func TestG2engine_AddRecordWithInfo(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - record := truthset.CustomerRecords["1003"] - flags := int64(0) - actual, err := g2engine.AddRecordWithInfo(ctx, record.DataSource, record.Id, record.Json, loadId, flags) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_CountRedoRecords(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - actual, err := g2engine.CountRedoRecords(ctx) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -// FAIL: -// func TestG2engine_ExportJSONEntityReport(test *testing.T) { -// ctx := context.TODO() -// g2engine := getTestObject(ctx, test) -// flags := int64(0) -// aHandle, err := g2engine.ExportJSONEntityReport(ctx, flags) -// testError(test, ctx, g2engine, err) -// anEntity, err := g2engine.FetchNext(ctx, aHandle) -// testError(test, ctx, g2engine, err) -// printResult(test, "Entity", anEntity) -// err = g2engine.CloseExport(ctx, aHandle) -// testError(test, ctx, g2engine, err) -// } - -func TestG2engine_ExportConfigAndConfigID(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - actualConfig, actualConfigId, err := g2engine.ExportConfigAndConfigID(ctx) - testError(test, ctx, g2engine, err) - printResult(test, "Actual Config", actualConfig) - printResult(test, "Actual Config ID", actualConfigId) -} - -func TestG2engine_ExportConfig(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - actual, err := g2engine.ExportConfig(ctx) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_ExportCSVEntityReport(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - expected := []string{} - csvColumnList := "" - flags := int64(-1) - aHandle, err := g2engine.ExportCSVEntityReport(ctx, csvColumnList, flags) - defer func() { - err := g2engine.CloseExport(ctx, aHandle) - testError(test, ctx, g2engine, err) - }() - testError(test, ctx, g2engine, err) - actualCount := 0 - for { - actual, err := g2engine.FetchNext(ctx, aHandle) - testError(test, ctx, g2engine, err) - if len(actual) == 0 { - break - } - assert.Equal(test, expected[actualCount], strings.TrimSpace(actual)) - actualCount += 1 - } - assert.Equal(test, len(expected), actualCount) -} - -func TestG2engine_ExportCSVEntityReportIterator(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - expected := []string{} - csvColumnList := "" - flags := int64(-1) - actualCount := 0 - for actual := range g2engine.ExportCSVEntityReportIterator(ctx, csvColumnList, flags) { - testError(test, ctx, g2engine, actual.Error) - assert.Equal(test, expected[actualCount], strings.TrimSpace(actual.Value)) - actualCount += 1 - } - assert.Equal(test, len(expected), actualCount) -} - -func TestG2engine_ExportJSONEntityReport(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - aRecord := testfixtures.FixtureRecords["65536-periods"] - err := g2engine.AddRecord(ctx, aRecord.DataSource, aRecord.Id, aRecord.Json, loadId) - testError(test, ctx, g2engine, err) - defer g2engine.DeleteRecord(ctx, aRecord.DataSource, aRecord.Id, loadId) - flags := int64(-1) - aHandle, err := g2engine.ExportJSONEntityReport(ctx, flags) - defer func() { - err := g2engine.CloseExport(ctx, aHandle) - testError(test, ctx, g2engine, err) - }() - testError(test, ctx, g2engine, err) - jsonEntityReport := "" - for { - jsonEntityReportFragment, err := g2engine.FetchNext(ctx, aHandle) - testError(test, ctx, g2engine, err) - if len(jsonEntityReportFragment) == 0 { - break - } - jsonEntityReport += jsonEntityReportFragment - } - testError(test, ctx, g2engine, err) - assert.True(test, len(jsonEntityReport) == 0) -} - -func TestG2engine_ExportJSONEntityReportIterator(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - flags := int64(-1) - actualCount := 0 - for actual := range g2engine.ExportJSONEntityReportIterator(ctx, flags) { - testError(test, ctx, g2engine, actual.Error) - printActual(test, actual.Value) - actualCount += 1 - } - assert.Equal(test, 0, actualCount) -} - -func TestG2engine_FindInterestingEntitiesByEntityID(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - entityID := getEntityId(truthset.CustomerRecords["1001"]) - flags := int64(0) - actual, err := g2engine.FindInterestingEntitiesByEntityID(ctx, entityID, flags) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_FindInterestingEntitiesByRecordID(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - record := truthset.CustomerRecords["1001"] - flags := int64(0) - actual, err := g2engine.FindInterestingEntitiesByRecordID(ctx, record.DataSource, record.Id, flags) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_FindNetworkByEntityID(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - record1 := truthset.CustomerRecords["1001"] - record2 := truthset.CustomerRecords["1002"] - entityList := `{"ENTITIES": [{"ENTITY_ID": ` + getEntityIdString(record1) + `}, {"ENTITY_ID": ` + getEntityIdString(record2) + `}]}` - maxDegree := int64(2) - buildOutDegree := int64(1) - maxEntities := int64(10) - actual, err := g2engine.FindNetworkByEntityID(ctx, entityList, maxDegree, buildOutDegree, maxEntities) - testErrorNoFail(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_FindNetworkByEntityID_V2(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - record1 := truthset.CustomerRecords["1001"] - record2 := truthset.CustomerRecords["1002"] - entityList := `{"ENTITIES": [{"ENTITY_ID": ` + getEntityIdString(record1) + `}, {"ENTITY_ID": ` + getEntityIdString(record2) + `}]}` - maxDegree := int64(2) - buildOutDegree := int64(1) - maxEntities := int64(10) - var flags int64 = int64(0) - actual, err := g2engine.FindNetworkByEntityID_V2(ctx, entityList, maxDegree, buildOutDegree, maxEntities, flags) - testErrorNoFail(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_FindNetworkByRecordID(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - record1 := truthset.CustomerRecords["1001"] - record2 := truthset.CustomerRecords["1002"] - record3 := truthset.CustomerRecords["1003"] - recordList := `{"RECORDS": [{"DATA_SOURCE": "` + record1.DataSource + `", "RECORD_ID": "` + record1.Id + `"}, {"DATA_SOURCE": "` + record2.DataSource + `", "RECORD_ID": "` + record2.Id + `"}, {"DATA_SOURCE": "` + record3.DataSource + `", "RECORD_ID": "` + record3.Id + `"}]}` - maxDegree := int64(1) - buildOutDegree := int64(2) - maxEntities := int64(10) - actual, err := g2engine.FindNetworkByRecordID(ctx, recordList, maxDegree, buildOutDegree, maxEntities) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_FindNetworkByRecordID_V2(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - record1 := truthset.CustomerRecords["1001"] - record2 := truthset.CustomerRecords["1002"] - record3 := truthset.CustomerRecords["1003"] - recordList := `{"RECORDS": [{"DATA_SOURCE": "` + record1.DataSource + `", "RECORD_ID": "` + record1.Id + `"}, {"DATA_SOURCE": "` + record2.DataSource + `", "RECORD_ID": "` + record2.Id + `"}, {"DATA_SOURCE": "` + record3.DataSource + `", "RECORD_ID": "` + record3.Id + `"}]}` - maxDegree := int64(1) - buildOutDegree := int64(2) - maxEntities := int64(10) - flags := int64(0) - actual, err := g2engine.FindNetworkByRecordID_V2(ctx, recordList, maxDegree, buildOutDegree, maxEntities, flags) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_FindPathByEntityID(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - entityID1 := getEntityId(truthset.CustomerRecords["1001"]) - entityID2 := getEntityId(truthset.CustomerRecords["1002"]) - maxDegree := int64(1) - actual, err := g2engine.FindPathByEntityID(ctx, entityID1, entityID2, maxDegree) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_FindPathByEntityID_V2(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - entityID1 := getEntityId(truthset.CustomerRecords["1001"]) - entityID2 := getEntityId(truthset.CustomerRecords["1002"]) - maxDegree := int64(1) - flags := int64(0) - actual, err := g2engine.FindPathByEntityID_V2(ctx, entityID1, entityID2, maxDegree, flags) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_FindPathByRecordID(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - record1 := truthset.CustomerRecords["1001"] - record2 := truthset.CustomerRecords["1002"] - maxDegree := int64(1) - actual, err := g2engine.FindPathByRecordID(ctx, record1.DataSource, record1.Id, record2.DataSource, record2.Id, maxDegree) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_FindPathByRecordID_V2(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - record1 := truthset.CustomerRecords["1001"] - record2 := truthset.CustomerRecords["1002"] - maxDegree := int64(1) - flags := int64(0) - actual, err := g2engine.FindPathByRecordID_V2(ctx, record1.DataSource, record1.Id, record2.DataSource, record2.Id, maxDegree, flags) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_FindPathExcludingByEntityID(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - record1 := truthset.CustomerRecords["1001"] - entityID1 := getEntityId(record1) - entityID2 := getEntityId(truthset.CustomerRecords["1002"]) - maxDegree := int64(1) - excludedEntities := `{"ENTITIES": [{"ENTITY_ID": ` + getEntityIdString(record1) + `}]}` - actual, err := g2engine.FindPathExcludingByEntityID(ctx, entityID1, entityID2, maxDegree, excludedEntities) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_FindPathExcludingByEntityID_V2(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - record1 := truthset.CustomerRecords["1001"] - entityID1 := getEntityId(record1) - entityID2 := getEntityId(truthset.CustomerRecords["1002"]) - maxDegree := int64(1) - excludedEntities := `{"ENTITIES": [{"ENTITY_ID": ` + getEntityIdString(record1) + `}]}` - flags := int64(0) - actual, err := g2engine.FindPathExcludingByEntityID_V2(ctx, entityID1, entityID2, maxDegree, excludedEntities, flags) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_FindPathExcludingByRecordID(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - record1 := truthset.CustomerRecords["1001"] - record2 := truthset.CustomerRecords["1002"] - maxDegree := int64(1) - excludedRecords := `{"RECORDS": [{ "DATA_SOURCE": "` + record1.DataSource + `", "RECORD_ID": "` + record1.Id + `"}]}` - actual, err := g2engine.FindPathExcludingByRecordID(ctx, record1.DataSource, record1.Id, record2.DataSource, record2.Id, maxDegree, excludedRecords) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_FindPathExcludingByRecordID_V2(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - record1 := truthset.CustomerRecords["1001"] - record2 := truthset.CustomerRecords["1002"] - maxDegree := int64(1) - excludedRecords := `{"RECORDS": [{ "DATA_SOURCE": "` + record1.DataSource + `", "RECORD_ID": "` + record1.Id + `"}]}` - flags := int64(0) - actual, err := g2engine.FindPathExcludingByRecordID_V2(ctx, record1.DataSource, record1.Id, record2.DataSource, record2.Id, maxDegree, excludedRecords, flags) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_FindPathIncludingSourceByEntityID(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - record1 := truthset.CustomerRecords["1001"] - entityID1 := getEntityId(record1) - entityID2 := getEntityId(truthset.CustomerRecords["1002"]) - maxDegree := int64(1) - excludedEntities := `{"ENTITIES": [{"ENTITY_ID": ` + getEntityIdString(record1) + `}]}` - requiredDsrcs := `{"DATA_SOURCES": ["` + record1.DataSource + `"]}` - actual, err := g2engine.FindPathIncludingSourceByEntityID(ctx, entityID1, entityID2, maxDegree, excludedEntities, requiredDsrcs) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_FindPathIncludingSourceByEntityID_V2(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - record1 := truthset.CustomerRecords["1001"] - entityID1 := getEntityId(record1) - entityID2 := getEntityId(truthset.CustomerRecords["1002"]) - maxDegree := int64(1) - excludedEntities := `{"ENTITIES": [{"ENTITY_ID": ` + getEntityIdString(record1) + `}]}` - requiredDsrcs := `{"DATA_SOURCES": ["` + record1.DataSource + `"]}` - flags := int64(0) - actual, err := g2engine.FindPathIncludingSourceByEntityID_V2(ctx, entityID1, entityID2, maxDegree, excludedEntities, requiredDsrcs, flags) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_FindPathIncludingSourceByRecordID(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - record1 := truthset.CustomerRecords["1001"] - record2 := truthset.CustomerRecords["1002"] - maxDegree := int64(1) - excludedEntities := `{"ENTITIES": [{"ENTITY_ID": ` + getEntityIdString(record1) + `}]}` - requiredDsrcs := `{"DATA_SOURCES": ["` + record1.DataSource + `"]}` - actual, err := g2engine.FindPathIncludingSourceByRecordID(ctx, record1.DataSource, record1.Id, record2.DataSource, record2.Id, maxDegree, excludedEntities, requiredDsrcs) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_FindPathIncludingSourceByRecordID_V2(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - record1 := truthset.CustomerRecords["1001"] - record2 := truthset.CustomerRecords["1002"] - maxDegree := int64(1) - excludedEntities := `{"ENTITIES": [{"ENTITY_ID": ` + getEntityIdString(record1) + `}]}` - requiredDsrcs := `{"DATA_SOURCES": ["` + record1.DataSource + `"]}` - flags := int64(0) - actual, err := g2engine.FindPathIncludingSourceByRecordID_V2(ctx, record1.DataSource, record1.Id, record2.DataSource, record2.Id, maxDegree, excludedEntities, requiredDsrcs, flags) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_GetActiveConfigID(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - actual, err := g2engine.GetActiveConfigID(ctx) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_GetEntityByEntityID(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - entityID := getEntityId(truthset.CustomerRecords["1001"]) - actual, err := g2engine.GetEntityByEntityID(ctx, entityID) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_GetEntityByEntityID_V2(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - entityID := getEntityId(truthset.CustomerRecords["1001"]) - flags := int64(0) - actual, err := g2engine.GetEntityByEntityID_V2(ctx, entityID, flags) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_GetEntityByRecordID(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - record := truthset.CustomerRecords["1001"] - actual, err := g2engine.GetEntityByRecordID(ctx, record.DataSource, record.Id) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_GetEntityByRecordID_V2(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - record := truthset.CustomerRecords["1001"] - flags := int64(0) - actual, err := g2engine.GetEntityByRecordID_V2(ctx, record.DataSource, record.Id, flags) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_GetRecord(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - record := truthset.CustomerRecords["1001"] - actual, err := g2engine.GetRecord(ctx, record.DataSource, record.Id) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_GetRecord_V2(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - record := truthset.CustomerRecords["1001"] - flags := int64(0) - actual, err := g2engine.GetRecord_V2(ctx, record.DataSource, record.Id, flags) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_GetRedoRecord(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - actual, err := g2engine.GetRedoRecord(ctx) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_GetRepositoryLastModifiedTime(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - actual, err := g2engine.GetRepositoryLastModifiedTime(ctx) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_GetVirtualEntityByRecordID(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - record1 := truthset.CustomerRecords["1001"] - record2 := truthset.CustomerRecords["1002"] - recordList := `{"RECORDS": [{"DATA_SOURCE": "` + record1.DataSource + `", "RECORD_ID": "` + record1.Id + `"}, {"DATA_SOURCE": "` + record2.DataSource + `", "RECORD_ID": "` + record2.Id + `"}]}` - actual, err := g2engine.GetVirtualEntityByRecordID(ctx, recordList) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_GetVirtualEntityByRecordID_V2(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - record1 := truthset.CustomerRecords["1001"] - record2 := truthset.CustomerRecords["1002"] - recordList := `{"RECORDS": [{"DATA_SOURCE": "` + record1.DataSource + `", "RECORD_ID": "` + record1.Id + `"}, {"DATA_SOURCE": "` + record2.DataSource + `", "RECORD_ID": "` + record2.Id + `"}]}` - flags := int64(0) - actual, err := g2engine.GetVirtualEntityByRecordID_V2(ctx, recordList, flags) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_HowEntityByEntityID(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - entityID := getEntityId(truthset.CustomerRecords["1001"]) - actual, err := g2engine.HowEntityByEntityID(ctx, entityID) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_HowEntityByEntityID_V2(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - entityID := getEntityId(truthset.CustomerRecords["1001"]) - flags := int64(0) - actual, err := g2engine.HowEntityByEntityID_V2(ctx, entityID, flags) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_PrimeEngine(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - err := g2engine.PrimeEngine(ctx) - testError(test, ctx, g2engine, err) -} - -// func TestG2engine_ProcessRedoRecord(test *testing.T) { -// ctx := context.TODO() -// g2engine := getTestObject(ctx, test) -// actual, err := g2engine.ProcessRedoRecord(ctx) -// testError(test, ctx, g2engine, err) -// printActual(test, actual) -// } - -// func TestG2engine_ProcessRedoRecordWithInfo(test *testing.T) { -// ctx := context.TODO() -// g2engine := getTestObject(ctx, test) -// flags := int64(0) -// actual, actualInfo, err := g2engine.ProcessRedoRecordWithInfo(ctx, flags) -// testError(test, ctx, g2engine, err) -// printActual(test, actual) -// printResult(test, "Actual Info", actualInfo) -// } - -func TestG2engine_ReevaluateEntity(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - entityID := getEntityId(truthset.CustomerRecords["1001"]) - flags := int64(0) - err := g2engine.ReevaluateEntity(ctx, entityID, flags) - testError(test, ctx, g2engine, err) -} - -func TestG2engine_ReevaluateEntityWithInfo(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - entityID := getEntityId(truthset.CustomerRecords["1001"]) - flags := int64(0) - actual, err := g2engine.ReevaluateEntityWithInfo(ctx, entityID, flags) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_ReevaluateRecord(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - record := truthset.CustomerRecords["1001"] - flags := int64(0) - err := g2engine.ReevaluateRecord(ctx, record.DataSource, record.Id, flags) - testError(test, ctx, g2engine, err) -} - -func TestG2engine_ReevaluateRecordWithInfo(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - record := truthset.CustomerRecords["1001"] - flags := int64(0) - actual, err := g2engine.ReevaluateRecordWithInfo(ctx, record.DataSource, record.Id, flags) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_ReplaceRecord(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - dataSourceCode := "CUSTOMERS" - recordID := "1001" - jsonData := `{"SOCIAL_HANDLE": "flavorh", "DATE_OF_BIRTH": "4/8/1984", "ADDR_STATE": "LA", "ADDR_POSTAL_CODE": "71232", "SSN_NUMBER": "053-39-3251", "ENTITY_TYPE": "CUSTOMERS", "GENDER": "F", "srccode": "MDMPER", "CC_ACCOUNT_NUMBER": "5534202208773608", "RECORD_ID": "1001", "DSRC_ACTION": "A", "ADDR_CITY": "Delhi", "DRIVERS_LICENSE_STATE": "DE", "PHONE_NUMBER": "225-671-0796", "NAME_LAST": "JOHNSON", "entityid": "284430058", "ADDR_LINE1": "772 Armstrong RD"}` - loadID := "CUSTOMERS" - err := g2engine.ReplaceRecord(ctx, dataSourceCode, recordID, jsonData, loadID) - testError(test, ctx, g2engine, err) - - record := truthset.CustomerRecords["1001"] - err = g2engine.ReplaceRecord(ctx, record.DataSource, record.Id, record.Json, loadID) - testError(test, ctx, g2engine, err) -} - -// FIXME: Remove after GDEV-3576 is fixed -func TestG2engine_ReplaceRecordWithInfo(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - dataSourceCode := "CUSTOMERS" - recordID := "1001" - jsonData := `{"SOCIAL_HANDLE": "flavorh", "DATE_OF_BIRTH": "4/8/1985", "ADDR_STATE": "LA", "ADDR_POSTAL_CODE": "71232", "SSN_NUMBER": "053-39-3251", "ENTITY_TYPE": "CUSTOMERS", "GENDER": "F", "srccode": "MDMPER", "CC_ACCOUNT_NUMBER": "5534202208773608", "RECORD_ID": "1001", "DSRC_ACTION": "A", "ADDR_CITY": "Delhi", "DRIVERS_LICENSE_STATE": "DE", "PHONE_NUMBER": "225-671-0796", "NAME_LAST": "JOHNSON", "entityid": "284430058", "ADDR_LINE1": "772 Armstrong RD"}` - loadID := "CUSTOMERS" - flags := int64(0) - actual, err := g2engine.ReplaceRecordWithInfo(ctx, dataSourceCode, recordID, jsonData, loadID, flags) - testError(test, ctx, g2engine, err) - printActual(test, actual) - record := truthset.CustomerRecords["1001"] - err = g2engine.ReplaceRecord(ctx, record.DataSource, record.Id, record.Json, loadID) - testError(test, ctx, g2engine, err) -} - -func TestG2engine_SearchByAttributes(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - jsonData := `{"NAMES": [{"NAME_TYPE": "PRIMARY", "NAME_LAST": "JOHNSON"}], "SSN_NUMBER": "053-39-3251"}` - actual, err := g2engine.SearchByAttributes(ctx, jsonData) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_SearchByAttributes_V2(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - jsonData := `{"NAMES": [{"NAME_TYPE": "PRIMARY", "NAME_LAST": "JOHNSON"}], "SSN_NUMBER": "053-39-3251"}` - flags := int64(0) - actual, err := g2engine.SearchByAttributes_V2(ctx, jsonData, flags) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_Stats(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - actual, err := g2engine.Stats(ctx) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_WhyEntities(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - entityID1 := getEntityId(truthset.CustomerRecords["1001"]) - entityID2 := getEntityId(truthset.CustomerRecords["1002"]) - actual, err := g2engine.WhyEntities(ctx, entityID1, entityID2) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_WhyEntities_V2(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - entityID1 := getEntityId(truthset.CustomerRecords["1001"]) - entityID2 := getEntityId(truthset.CustomerRecords["1002"]) - flags := int64(0) - actual, err := g2engine.WhyEntities_V2(ctx, entityID1, entityID2, flags) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_WhyRecords(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - record1 := truthset.CustomerRecords["1001"] - record2 := truthset.CustomerRecords["1002"] - actual, err := g2engine.WhyRecords(ctx, record1.DataSource, record1.Id, record2.DataSource, record2.Id) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_WhyRecords_V2(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - record1 := truthset.CustomerRecords["1001"] - record2 := truthset.CustomerRecords["1002"] - flags := int64(0) - actual, err := g2engine.WhyRecords_V2(ctx, record1.DataSource, record1.Id, record2.DataSource, record2.Id, flags) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_Init(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - iniParams, err := getIniParams() - testError(test, ctx, g2engine, err) - err = g2engine.Init(ctx, moduleName, iniParams, verboseLogging) - testError(test, ctx, g2engine, err) -} - -func TestG2engine_InitWithConfigID(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - var initConfigID int64 = senzingConfigId - iniParams, err := getIniParams() - testError(test, ctx, g2engine, err) - err = g2engine.InitWithConfigID(ctx, moduleName, iniParams, initConfigID, verboseLogging) - testError(test, ctx, g2engine, err) -} - -func TestG2engine_Reinit(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - initConfigID, err := g2engine.GetActiveConfigID(ctx) - testError(test, ctx, g2engine, err) - err = g2engine.Reinit(ctx, initConfigID) - testError(test, ctx, g2engine, err) - printActual(test, initConfigID) -} - -func TestG2engine_DeleteRecord(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - - // first create and add the record to be deleted - record, err := record.NewRecord(`{"DATA_SOURCE": "TEST", "RECORD_ID": "DELETE_TEST", "NAME_FULL": "GONNA B. DELETED"}`) - testError(test, ctx, g2engine, err) - - err = g2engine.AddRecord(ctx, record.DataSource, record.Id, record.Json, loadId) - testError(test, ctx, g2engine, err) - - // now delete the record - err = g2engine.DeleteRecord(ctx, record.DataSource, record.Id, loadId) - testError(test, ctx, g2engine, err) -} - -func TestG2engine_DeleteRecordWithInfo(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - - // first create and add the record to be deleted - record, err := record.NewRecord(`{"DATA_SOURCE": "TEST", "RECORD_ID": "DELETE_TEST", "NAME_FULL": "DELETE W. INFO"}`) - testError(test, ctx, g2engine, err) - - err = g2engine.AddRecord(ctx, record.DataSource, record.Id, record.Json, loadId) - testError(test, ctx, g2engine, err) - - // now delete the record - flags := int64(0) - actual, err := g2engine.DeleteRecordWithInfo(ctx, record.DataSource, record.Id, record.Json, flags) - testError(test, ctx, g2engine, err) - printActual(test, actual) -} - -func TestG2engine_Destroy(test *testing.T) { - ctx := context.TODO() - g2engine := getTestObject(ctx, test) - err := g2engine.Destroy(ctx) - testError(test, ctx, g2engine, err) -} diff --git a/g2product/doc.go b/g2product/doc.go deleted file mode 100644 index dc96924..0000000 --- a/g2product/doc.go +++ /dev/null @@ -1,4 +0,0 @@ -/* -The g2product package is used make G2Product requests to a mock object. -*/ -package g2product diff --git a/g2product/g2product_examples_test.go b/g2product/g2product_examples_test.go deleted file mode 100644 index 44d49f9..0000000 --- a/g2product/g2product_examples_test.go +++ /dev/null @@ -1,94 +0,0 @@ -//go:build linux - -package g2product - -import ( - "context" - "fmt" - - "github.com/senzing-garage/go-logging/logging" -) - -// ---------------------------------------------------------------------------- -// Examples for godoc documentation -// ---------------------------------------------------------------------------- - -func ExampleG2product_SetObserverOrigin() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2product/g2product_examples_test.go - ctx := context.TODO() - g2product := getG2Product(ctx) - origin := "Machine: nn; Task: UnitTest" - g2product.SetObserverOrigin(ctx, origin) - // Output: -} - -func ExampleG2product_GetObserverOrigin() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2config/g2product_test.go - ctx := context.TODO() - g2product := getG2Product(ctx) - origin := "Machine: nn; Task: UnitTest" - g2product.SetObserverOrigin(ctx, origin) - result := g2product.GetObserverOrigin(ctx) - fmt.Println(result) - // Output: Machine: nn; Task: UnitTest -} - -func ExampleG2product_Init() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2product/g2product_examples_test.go - ctx := context.TODO() - g2product := getG2Product(ctx) - moduleName := "Test module name" - iniParams := "{}" - verboseLogging := int64(0) - err := g2product.Init(ctx, moduleName, iniParams, verboseLogging) - if err != nil { - // This should produce a "senzing-60164002" error. - } - // Output: -} - -func ExampleG2product_License() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2product/g2product_examples_test.go - ctx := context.TODO() - g2product := getG2Product(ctx) - result, err := g2product.License(ctx) - if err != nil { - fmt.Println(err) - } - fmt.Println(result) - // Output: {"customer":"Senzing Public Test License","contract":"EVALUATION - support@senzing.com","issueDate":"2022-11-29","licenseType":"EVAL (Solely for non-productive use)","licenseLevel":"STANDARD","billing":"MONTHLY","expireDate":"2023-11-29","recordLimit":50000} -} - -func ExampleG2product_SetLogLevel() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2product/g2product_examples_test.go - ctx := context.TODO() - g2product := getG2Product(ctx) - err := g2product.SetLogLevel(ctx, logging.LevelInfoName) - if err != nil { - fmt.Println(err) - } - // Output: -} - -func ExampleG2product_Version() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2product/g2product_examples_test.go - ctx := context.TODO() - g2product := getG2Product(ctx) - result, err := g2product.Version(ctx) - if err != nil { - fmt.Println(err) - } - fmt.Println(truncate(result, 43)) - // Output: {"PRODUCT_NAME":"Senzing API","VERSION":... -} - -func ExampleG2product_Destroy() { - // For more information, visit https://github.com/senzing-garage/g2-sdk-go-mock/blob/main/g2product/g2product_examples_test.go - ctx := context.TODO() - g2product := getG2Product(ctx) - err := g2product.Destroy(ctx) - if err != nil { - // This should produce a "senzing-60164001" error. - } - // Output: -} diff --git a/g2product/g2product_test.go b/g2product/g2product_test.go deleted file mode 100644 index 2193eaf..0000000 --- a/g2product/g2product_test.go +++ /dev/null @@ -1,147 +0,0 @@ -package g2product - -import ( - "context" - "fmt" - "os" - "testing" - - truncator "github.com/aquilax/truncate" - "github.com/senzing-garage/g2-sdk-go/g2api" - "github.com/stretchr/testify/assert" -) - -const ( - defaultTruncation = 76 - printResults = false -) - -var ( - g2productSingleton *G2product -) - -// ---------------------------------------------------------------------------- -// Internal functions -// ---------------------------------------------------------------------------- - -func getTestObject(ctx context.Context, test *testing.T) *G2product { - return getG2Product(ctx) -} - -func getG2Product(ctx context.Context) *G2product { - if g2productSingleton == nil { - g2productSingleton = &G2product{ - LicenseResult: `{"customer":"Senzing Public Test License","contract":"EVALUATION - support@senzing.com","issueDate":"2022-11-29","licenseType":"EVAL (Solely for non-productive use)","licenseLevel":"STANDARD","billing":"MONTHLY","expireDate":"2023-11-29","recordLimit":50000}`, - VersionResult: `{"PRODUCT_NAME":"Senzing API","VERSION":"3.5.0","BUILD_VERSION":"3.5.0.23041","BUILD_DATE":"2023-02-09","BUILD_NUMBER":"2023_02_09__23_01","COMPATIBILITY_VERSION":{"CONFIG_VERSION":"10"},"SCHEMA_VERSION":{"ENGINE_SCHEMA_VERSION":"3.5","MINIMUM_REQUIRED_SCHEMA_VERSION":"3.0","MAXIMUM_REQUIRED_SCHEMA_VERSION":"3.99"}}`, - } - } - return g2productSingleton -} - -func truncate(aString string, length int) string { - return truncator.Truncate(aString, length, "...", truncator.PositionEnd) -} - -func printResult(test *testing.T, title string, result interface{}) { - if printResults { - test.Logf("%s: %v", title, truncate(fmt.Sprintf("%v", result), defaultTruncation)) - } -} - -func printActual(test *testing.T, actual interface{}) { - printResult(test, "Actual", actual) -} - -func testError(test *testing.T, ctx context.Context, g2product g2api.G2product, err error) { - if err != nil { - test.Log("Error:", err.Error()) - assert.FailNow(test, err.Error()) - } -} - -func testErrorNoFail(test *testing.T, ctx context.Context, g2product g2api.G2product, err error) { - if err != nil { - test.Log("Error:", err.Error()) - } -} - -// ---------------------------------------------------------------------------- -// Test harness -// ---------------------------------------------------------------------------- - -func TestMain(m *testing.M) { - err := setup() - if err != nil { - fmt.Print(err) - os.Exit(1) - } - code := m.Run() - err = teardown() - if err != nil { - fmt.Print(err) - } - os.Exit(code) -} - -func setup() error { - var err error = nil - return err -} - -func teardown() error { - var err error = nil - return err -} - -// ---------------------------------------------------------------------------- -// Test interface functions -// ---------------------------------------------------------------------------- - -func TestG2product_SetObserverOrigin(test *testing.T) { - ctx := context.TODO() - g2product := getTestObject(ctx, test) - origin := "Machine: nn; Task: UnitTest" - g2product.SetObserverOrigin(ctx, origin) -} - -func TestG2product_GetObserverOrigin(test *testing.T) { - ctx := context.TODO() - g2product := getTestObject(ctx, test) - origin := "Machine: nn; Task: UnitTest" - g2product.SetObserverOrigin(ctx, origin) - actual := g2product.GetObserverOrigin(ctx) - assert.Equal(test, origin, actual) -} - -func TestG2product_Init(test *testing.T) { - ctx := context.TODO() - g2product := getG2Product(ctx) - moduleName := "Test module name" - iniParams := "{}" - verboseLogging := int64(0) - err := g2product.Init(ctx, moduleName, iniParams, verboseLogging) - testError(test, ctx, g2product, err) -} - -func TestG2product_License(test *testing.T) { - ctx := context.TODO() - g2product := getTestObject(ctx, test) - actual, err := g2product.License(ctx) - testError(test, ctx, g2product, err) - printActual(test, actual) -} - -func TestG2product_Version(test *testing.T) { - ctx := context.TODO() - g2product := getTestObject(ctx, test) - actual, err := g2product.Version(ctx) - testError(test, ctx, g2product, err) - printActual(test, actual) -} - -func TestG2product_Destroy(test *testing.T) { - ctx := context.TODO() - g2product := getTestObject(ctx, test) - err := g2product.Destroy(ctx) - testError(test, ctx, g2product, err) -} diff --git a/go.mod b/go.mod index 83a6c2f..ec7d959 100644 --- a/go.mod +++ b/go.mod @@ -1,19 +1,19 @@ -module github.com/senzing-garage/g2-sdk-go-mock +module github.com/senzing-garage/sz-sdk-go-mock go 1.21 require ( github.com/aquilax/truncate v1.0.0 - github.com/senzing-garage/g2-sdk-go v0.10.0 - github.com/senzing-garage/go-common v0.4.0 + github.com/senzing-garage/go-helpers v0.5.1 github.com/senzing-garage/go-logging v1.4.1 github.com/senzing-garage/go-observing v0.3.1 + github.com/senzing-garage/sz-sdk-go v0.12.1 github.com/stretchr/testify v1.9.0 ) require ( - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/senzing-garage/go-messaging v1.4.1 // indirect golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f // indirect golang.org/x/net v0.24.0 // indirect diff --git a/go.sum b/go.sum index 644cd2a..3476eda 100644 --- a/go.sum +++ b/go.sum @@ -1,27 +1,27 @@ github.com/aquilax/truncate v1.0.0 h1:UgIGS8U/aZ4JyOJ2h3xcF5cSQ06+gGBnjxH2RUHJe0U= github.com/aquilax/truncate v1.0.0/go.mod h1:BeMESIDMlvlS3bmg4BVvBbbZUNwWtS8uzYPAKXwwhLw= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= -github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= -github.com/senzing-garage/g2-sdk-go v0.10.0 h1:OlHR6Vd1UGqjHNv1T7R1kuCWubJ7NNvynUbd8AEVDpU= -github.com/senzing-garage/g2-sdk-go v0.10.0/go.mod h1:o433ZuKItfmc+DIACE2oAQ6Wnn0CJeoNDRa891HxTvQ= -github.com/senzing-garage/go-common v0.4.0 h1:/6/5yNY80udkbOzSAX0Vvx2+0kD9JF7fhqNUlRj2Vho= -github.com/senzing-garage/go-common v0.4.0/go.mod h1:f2EIjPzAcULG8eKUVebIUNS2qgMVcJRgmQY9fpBDF9E= +github.com/senzing-garage/go-helpers v0.5.1 h1:ezVW5oAHihfG2QVpe/Ooyz8q9UPrCuDdg+W43wk9phY= +github.com/senzing-garage/go-helpers v0.5.1/go.mod h1:Gx66fvdAqt4YVf1KVCjzK2Rmr/C7qe5zaZW4VQ3goyM= github.com/senzing-garage/go-logging v1.4.1 h1:ubNspaf0r4Q29XeNW58q0oPGLq4c1pdf9FciQLw6hpc= github.com/senzing-garage/go-logging v1.4.1/go.mod h1:TW1w0UE9fQpy9odkx1jJQeffW+OTdrqEyxhtWKGW1n4= github.com/senzing-garage/go-messaging v1.4.1 h1:ZdFcemh1iACP+HJWGS5/QLaUSD7PUYVXhzW7Zbju9f0= github.com/senzing-garage/go-messaging v1.4.1/go.mod h1:7tEicOa0baYz0lh0w1BJEiQ6ry1FIQl/67JAWwFpcRY= github.com/senzing-garage/go-observing v0.3.1 h1:EGqe+Uix8VNQ9HCwm5xZkAF0hGoHaC1URAaT/5FW37A= github.com/senzing-garage/go-observing v0.3.1/go.mod h1:x60vlRIR0ZdJrHDuK82nzmQG4sN0G6oqdLE9vQl9pVc= +github.com/senzing-garage/sz-sdk-go v0.12.1 h1:W+4rotdlN6O/eGWNITrCz+LZ30YQ9Pog1Id0XtWPo9c= +github.com/senzing-garage/sz-sdk-go v0.12.1/go.mod h1:K+tiyY6W5FnUrzBZXIg5x7cWbZKpO/6rzpkCoKhcK6o= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f h1:99ci1mjWVBWwJiEKYY6jWa4d2nTQVIEhZIptnrVb1XY= @@ -39,7 +39,7 @@ google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDom google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/main.go b/main.go index efcaf64..66611c5 100644 --- a/main.go +++ b/main.go @@ -8,15 +8,13 @@ import ( "math/big" "time" - "github.com/senzing-garage/g2-sdk-go-mock/g2config" - "github.com/senzing-garage/g2-sdk-go-mock/g2configmgr" - "github.com/senzing-garage/g2-sdk-go-mock/g2diagnostic" - "github.com/senzing-garage/g2-sdk-go-mock/g2engine" - "github.com/senzing-garage/g2-sdk-go-mock/g2product" - "github.com/senzing-garage/g2-sdk-go/g2api" - "github.com/senzing-garage/go-common/truthset" + "github.com/senzing-garage/go-helpers/truthset" "github.com/senzing-garage/go-logging/logging" - "github.com/senzing-garage/go-observing/observer" + "github.com/senzing-garage/sz-sdk-go-mock/szconfig" + "github.com/senzing-garage/sz-sdk-go-mock/szconfigmanager" + "github.com/senzing-garage/sz-sdk-go-mock/szengine" + "github.com/senzing-garage/sz-sdk-go-mock/szproduct" + "github.com/senzing-garage/sz-sdk-go/sz" ) // ---------------------------------------------------------------------------- @@ -50,98 +48,89 @@ var logger logging.LoggingInterface // Internal methods // ---------------------------------------------------------------------------- -func getG2config(ctx context.Context) (g2api.G2config, error) { - result := g2config.G2config{} - moduleName := "Test module name" - verboseLogging := int64(0) // 0 for no Senzing logging; 1 for logging - iniParams := `{}` - err := result.Init(ctx, moduleName, iniParams, verboseLogging) +func getSzConfig(ctx context.Context) (sz.SzConfig, error) { + result := szconfig.Szconfig{} + instanceName := "Test name" + settings := "{}" + verboseLogging := sz.SZ_NO_LOGGING + err := result.Initialize(ctx, instanceName, settings, verboseLogging) return &result, err } -func getG2configmgr(ctx context.Context) (g2api.G2configmgr, error) { - result := g2configmgr.G2configmgr{} - moduleName := "Test module name" - verboseLogging := int64(0) - iniParams := `{}` - err := result.Init(ctx, moduleName, iniParams, verboseLogging) +func getSzConfigManager(ctx context.Context) (sz.SzConfigManager, error) { + result := szconfigmanager.Szconfigmanager{} + instanceName := "Test name" + settings := "{}" + verboseLogging := sz.SZ_NO_LOGGING + err := result.Initialize(ctx, instanceName, settings, verboseLogging) return &result, err } -func getG2diagnostic(ctx context.Context) (g2api.G2diagnostic, error) { - result := g2diagnostic.G2diagnostic{} - moduleName := "Test module name" - verboseLogging := int64(0) - iniParams := `{}` - err := result.Init(ctx, moduleName, iniParams, verboseLogging) +func getSzEngine(ctx context.Context) (sz.SzEngine, error) { + result := szengine.Szengine{} + instanceName := "Test name" + settings := "{}" + verboseLogging := sz.SZ_NO_LOGGING + configId := sz.SZ_INITIALIZE_WITH_DEFAULT_CONFIGURATION + err := result.Initialize(ctx, instanceName, settings, configId, verboseLogging) return &result, err } -func getG2engine(ctx context.Context) (g2api.G2engine, error) { - result := g2engine.G2engine{} - moduleName := "Test module name" - verboseLogging := int64(0) - iniParams := `{}` - err := result.Init(ctx, moduleName, iniParams, verboseLogging) - return &result, err -} - -func getG2product(ctx context.Context) (g2api.G2product, error) { - result := g2product.G2product{} - moduleName := "Test module name" - verboseLogging := int64(0) - iniParams := `{}` - err := result.Init(ctx, moduleName, iniParams, verboseLogging) +func getSzProduct(ctx context.Context) (sz.SzProduct, error) { + result := szproduct.Szproduct{} + instanceName := "Test name" + settings := "{}" + verboseLogging := sz.SZ_NO_LOGGING + err := result.Initialize(ctx, instanceName, settings, verboseLogging) return &result, err } func getLogger(ctx context.Context) (logging.LoggingInterface, error) { - + _ = ctx logger, err := logging.NewSenzingLogger("my-unique-%04d", Messages) if err != nil { fmt.Println(err) } - return logger, err } -func demonstrateConfigFunctions(ctx context.Context, g2Config g2api.G2config, g2Configmgr g2api.G2configmgr) error { +func demonstrateConfigFunctions(ctx context.Context, szConfig sz.SzConfig, szConfigManager sz.SzConfigManager) error { now := time.Now() - // Using G2Config: Create a default configuration in memory. + // Using SzConfig: Create a default configuration in memory. - configHandle, err := g2Config.Create(ctx) + configHandle, err := szConfig.CreateConfig(ctx) if err != nil { return logger.NewError(5100, err) } - // Using G2Config: Add data source to in-memory configuration. + // Using SzConfig: Add data source to in-memory configuration. for _, testDataSource := range truthset.TruthsetDataSources { - _, err := g2Config.AddDataSource(ctx, configHandle, testDataSource.Json) + _, err := szConfig.AddDataSource(ctx, configHandle, testDataSource.Json) if err != nil { return logger.NewError(5101, err) } } - // Using G2Config: Persist configuration to a string. + // Using SzConfig: Persist configuration to a string. - configStr, err := g2Config.Save(ctx, configHandle) + configStr, err := szConfig.ExportConfig(ctx, configHandle) if err != nil { return logger.NewError(5102, err) } - // Using G2Configmgr: Persist configuration string to database. + // Using SzConfigManager: Persist configuration string to database. - configComments := fmt.Sprintf("Created by g2diagnostic_test at %s", now.UTC()) - configID, err := g2Configmgr.AddConfig(ctx, configStr, configComments) + configComments := fmt.Sprintf("Created by main at %s", now.UTC()) + configID, err := szConfigManager.AddConfig(ctx, configStr, configComments) if err != nil { return logger.NewError(5103, err) } - // Using G2Configmgr: Set new configuration as the default. + // Using SzConfigManager: Set new configuration as the default. - err = g2Configmgr.SetDefaultConfigID(ctx, configID) + err = szConfigManager.SetDefaultConfigId(ctx, configID) if err != nil { return logger.NewError(5104, err) } @@ -149,39 +138,38 @@ func demonstrateConfigFunctions(ctx context.Context, g2Config g2api.G2config, g2 return err } -func demonstrateAddRecord(ctx context.Context, g2Engine g2api.G2engine) (string, error) { +func demonstrateAddRecord(ctx context.Context, szEngine sz.SzEngine) (string, error) { dataSourceCode := "TEST" randomNumber, err := rand.Int(rand.Reader, big.NewInt(1000000000)) if err != nil { panic(err) } - recordID := randomNumber.String() - jsonData := fmt.Sprintf( + recordId := randomNumber.String() + recordDefinition := fmt.Sprintf( "%s%s%s", `{"SOCIAL_HANDLE": "flavorh", "DATE_OF_BIRTH": "4/8/1983", "ADDR_STATE": "LA", "ADDR_POSTAL_CODE": "71232", "SSN_NUMBER": "053-39-3251", "ENTITY_TYPE": "TEST", "GENDER": "F", "srccode": "MDMPER", "CC_ACCOUNT_NUMBER": "5534202208773608", "RECORD_ID": "`, - recordID, + recordId, `", "DSRC_ACTION": "A", "ADDR_CITY": "Delhi", "DRIVERS_LICENSE_STATE": "DE", "PHONE_NUMBER": "225-671-0796", "NAME_LAST": "SEAMAN", "entityid": "284430058", "ADDR_LINE1": "772 Armstrong RD"}`) - loadID := dataSourceCode - var flags int64 = 0 + var flags int64 = sz.SZ_NO_FLAGS - // Using G2Engine: Add record and return "withInfo". + // Using SzEngine: Add record and return "withInfo". - return g2Engine.AddRecordWithInfo(ctx, dataSourceCode, recordID, jsonData, loadID, flags) + return szEngine.AddRecord(ctx, dataSourceCode, recordId, recordDefinition, flags) } -func demonstrateAdditionalFunctions(ctx context.Context, g2Diagnostic g2api.G2diagnostic, g2Engine g2api.G2engine, g2Product g2api.G2product) error { +func demonstrateAdditionalFunctions(ctx context.Context, szEngine sz.SzEngine, szProduct sz.SzProduct) error { - // Using G2Engine: Add records with information returned. + // Using SzEngine: Add records with information returned. - withInfo, err := demonstrateAddRecord(ctx, g2Engine) + withInfo, err := demonstrateAddRecord(ctx, szEngine) if err != nil { failOnError(5302, err) } logger.Log(2003, withInfo) - // Using G2Product: Show license metadata. + // Using SzProduct: Show license metadata. - license, err := g2Product.License(ctx) + license, err := szProduct.GetLicense(ctx) if err != nil { failOnError(5303, err) } @@ -190,36 +178,6 @@ func demonstrateAdditionalFunctions(ctx context.Context, g2Diagnostic g2api.G2di return err } -func destroyObjects(ctx context.Context, g2Config g2api.G2config, g2Configmgr g2api.G2configmgr, g2Diagnostic g2api.G2diagnostic, g2Engine g2api.G2engine, g2Product g2api.G2product) error { - - err := g2Config.Destroy(ctx) - if err != nil { - failOnError(5401, err) - } - - err = g2Configmgr.Destroy(ctx) - if err != nil { - failOnError(5402, err) - } - - err = g2Diagnostic.Destroy(ctx) - if err != nil { - failOnError(5403, err) - } - - err = g2Engine.Destroy(ctx) - if err != nil { - failOnError(5404, err) - } - - err = g2Product.Destroy(ctx) - if err != nil { - failOnError(5405, err) - } - - return err -} - func failOnError(msgId int, err error) { logger.Log(msgId, err) panic(err.Error()) @@ -252,81 +210,47 @@ func main() { fmt.Printf("\n-------------------------------------------------------------------------------\n\n") logger.Log(2001, "Just a test of logging", programmMetadataMap) - // Create observers. - - observer1 := &observer.ObserverNull{ - Id: "Observer 1", - } - // Get Senzing objects for installing a Senzing Engine configuration. - g2Config, err := getG2config(ctx) + szConfig, err := getSzConfig(ctx) if err != nil { failOnError(5001, err) } - err = g2Config.RegisterObserver(ctx, observer1) - if err != nil { - panic(err) - } + defer szConfig.Destroy(ctx) - g2Configmgr, err := getG2configmgr(ctx) + szConfigManager, err := getSzConfigManager(ctx) if err != nil { failOnError(5005, err) } - err = g2Configmgr.RegisterObserver(ctx, observer1) - if err != nil { - panic(err) - } + defer szConfigManager.Destroy(ctx) // Persist the Senzing configuration to the Senzing repository. - err = demonstrateConfigFunctions(ctx, g2Config, g2Configmgr) + err = demonstrateConfigFunctions(ctx, szConfig, szConfigManager) if err != nil { failOnError(5008, err) } // Now that a Senzing configuration is installed, get the remainder of the Senzing objects. - g2Diagnostic, err := getG2diagnostic(ctx) - if err != nil { - failOnError(5009, err) - } - err = g2Diagnostic.RegisterObserver(ctx, observer1) - if err != nil { - panic(err) - } - - g2Engine, err := getG2engine(ctx) + szEngine, err := getSzEngine(ctx) if err != nil { failOnError(5010, err) } - err = g2Engine.RegisterObserver(ctx, observer1) - if err != nil { - panic(err) - } + defer szEngine.Destroy(ctx) - g2Product, err := getG2product(ctx) + szProduct, err := getSzProduct(ctx) if err != nil { failOnError(5011, err) } - err = g2Product.RegisterObserver(ctx, observer1) - if err != nil { - panic(err) - } + defer szProduct.Destroy(ctx) // Demonstrate tests. - err = demonstrateAdditionalFunctions(ctx, g2Diagnostic, g2Engine, g2Product) + err = demonstrateAdditionalFunctions(ctx, szEngine, szProduct) if err != nil { failOnError(5015, err) } - // Destroy Senzing objects. - - err = destroyObjects(ctx, g2Config, g2Configmgr, g2Diagnostic, g2Engine, g2Product) - if err != nil { - failOnError(5016, err) - } - fmt.Printf("\n-------------------------------------------------------------------------------\n\n") } diff --git a/szabstractfactory/doc.go b/szabstractfactory/doc.go new file mode 100644 index 0000000..133d3fb --- /dev/null +++ b/szabstractfactory/doc.go @@ -0,0 +1,4 @@ +/* +The szabstractfactory package implements an Abstract Factory Pattern for Sz object creation. +*/ +package szabstractfactory diff --git a/szabstractfactory/main.go b/szabstractfactory/main.go new file mode 100644 index 0000000..74c5a8c --- /dev/null +++ b/szabstractfactory/main.go @@ -0,0 +1,8 @@ +package szabstractfactory + +// ---------------------------------------------------------------------------- +// Constants +// ---------------------------------------------------------------------------- + +// Identfier of the szabstractfactory package found messages having the format "senzing-6030xxxx". +const ComponentId = 6030 diff --git a/szabstractfactory/szabstractfactory.go b/szabstractfactory/szabstractfactory.go new file mode 100644 index 0000000..8346b34 --- /dev/null +++ b/szabstractfactory/szabstractfactory.go @@ -0,0 +1,100 @@ +package szabstractfactory + +import ( + "context" + + "github.com/senzing-garage/sz-sdk-go-mock/szconfig" + "github.com/senzing-garage/sz-sdk-go-mock/szconfigmanager" + "github.com/senzing-garage/sz-sdk-go-mock/szdiagnostic" + "github.com/senzing-garage/sz-sdk-go-mock/szengine" + "github.com/senzing-garage/sz-sdk-go-mock/szproduct" + "github.com/senzing-garage/sz-sdk-go/sz" +) + +// Szconfig is the default implementation of the Szconfig interface. +type Szabstractfactory struct { +} + +// ---------------------------------------------------------------------------- +// Interface methods +// ---------------------------------------------------------------------------- + +/* +TODO: Write description for CreateSzConfig +The CreateSzConfig method... + +Input + - ctx: A context to control lifecycle. + +Output + - An sz.SzConfig object. + See the example output. +*/ +func (factory *Szabstractfactory) CreateSzConfig(ctx context.Context) (sz.SzConfig, error) { + result := &szconfig.Szconfig{} + return result, nil +} + +/* +TODO: Write description for CreateSzConfigManager +The CreateSzConfigManager method... + +Input + - ctx: A context to control lifecycle. + +Output + - An sz.CreateConfigManager object. + See the example output. +*/ +func (factory *Szabstractfactory) CreateSzConfigManager(ctx context.Context) (sz.SzConfigManager, error) { + result := &szconfigmanager.Szconfigmanager{} + return result, nil +} + +/* +TODO: Write description for CreateSzDiagnostic +The CreateSzDiagnostic method... + +Input + - ctx: A context to control lifecycle. + +Output + - An sz.SzDiagnostic object. + See the example output. +*/ +func (factory *Szabstractfactory) CreateSzDiagnostic(ctx context.Context) (sz.SzDiagnostic, error) { + result := &szdiagnostic.Szdiagnostic{} + return result, nil +} + +/* +TODO: Write description for CreateSzEngine +The CreateSzEngine method... + +Input + - ctx: A context to control lifecycle. + +Output + - An sz.SzEngine object. + See the example output. +*/ +func (factory *Szabstractfactory) CreateSzEngine(ctx context.Context) (sz.SzEngine, error) { + result := &szengine.Szengine{} + return result, nil +} + +/* +TODO: Write description for CreateSzProduct +The CreateSzProduct method... + +Input + - ctx: A context to control lifecycle. + +Output + - An sz.SzProduct object. + See the example output. +*/ +func (factory *Szabstractfactory) CreateSzProduct(ctx context.Context) (sz.SzProduct, error) { + result := &szproduct.Szproduct{} + return result, nil +} diff --git a/szabstractfactory/szabstractfactory_examples_test.go b/szabstractfactory/szabstractfactory_examples_test.go new file mode 100644 index 0000000..e10e9fb --- /dev/null +++ b/szabstractfactory/szabstractfactory_examples_test.go @@ -0,0 +1,72 @@ +//go:build linux + +package szabstractfactory + +import ( + "context" + "fmt" +) + +// ---------------------------------------------------------------------------- +// Interface functions - Examples for godoc documentation +// ---------------------------------------------------------------------------- + +func ExampleSzAbstractFactory_CreateSzConfig() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-core/blob/main/szabstractfactory/szabstractfactory_examples_test.go + ctx := context.TODO() + szAbstractFactory := getSzAbstractFactory(ctx) + szConfig, err := szAbstractFactory.CreateSzConfig(ctx) + if err != nil { + fmt.Println(err) + } + defer szConfig.Destroy(ctx) + // Output: +} + +func ExampleSzAbstractFactory_CreateSzConfigManager() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-core/blob/main/szabstractfactory/szabstractfactory_examples_test.go + ctx := context.TODO() + szAbstractFactory := getSzAbstractFactory(ctx) + szConfigManager, err := szAbstractFactory.CreateSzConfigManager(ctx) + if err != nil { + fmt.Println(err) + } + defer szConfigManager.Destroy(ctx) + // Output: +} + +func ExampleSzAbstractFactory_CreateSzDiagnostic() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-core/blob/main/szabstractfactory/szabstractfactory_examples_test.go + ctx := context.TODO() + szAbstractFactory := getSzAbstractFactory(ctx) + szDiagnostic, err := szAbstractFactory.CreateSzDiagnostic(ctx) + if err != nil { + fmt.Println(err) + } + defer szDiagnostic.Destroy(ctx) + // Output: +} + +func ExampleSzAbstractFactory_CreateSzEngine() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-core/blob/main/szabstractfactory/szabstractfactory_examples_test.go + ctx := context.TODO() + szAbstractFactory := getSzAbstractFactory(ctx) + szEngine, err := szAbstractFactory.CreateSzEngine(ctx) + if err != nil { + fmt.Println(err) + } + defer szEngine.Destroy(ctx) + // Output: +} + +func ExampleSzAbstractFactory_CreateSzProduct() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-core/blob/main/szabstractfactory/szabstractfactory_examples_test.go + ctx := context.TODO() + szAbstractFactory := getSzAbstractFactory(ctx) + szProduct, err := szAbstractFactory.CreateSzProduct(ctx) + if err != nil { + fmt.Println(err) + } + defer szProduct.Destroy(ctx) + // Output: +} diff --git a/szabstractfactory/szabstractfactory_test.go b/szabstractfactory/szabstractfactory_test.go new file mode 100644 index 0000000..af8a256 --- /dev/null +++ b/szabstractfactory/szabstractfactory_test.go @@ -0,0 +1,145 @@ +package szabstractfactory + +import ( + "context" + "fmt" + "os" + "testing" + + truncator "github.com/aquilax/truncate" + "github.com/senzing-garage/sz-sdk-go/sz" + "github.com/stretchr/testify/assert" +) + +const ( + defaultTruncation = 76 + instanceName = "SzAbstractFactory Test" + printResults = false + verboseLogging = sz.SZ_NO_LOGGING +) + +// ---------------------------------------------------------------------------- +// Interface functions - test +// ---------------------------------------------------------------------------- + +func TestSzAbstractFactory_CreateSzConfig(test *testing.T) { + ctx := context.TODO() + szAbstractFactory := getTestObject(ctx, test) + szConfig, err := szAbstractFactory.CreateSzConfig(ctx) + testError(test, ctx, szAbstractFactory, err) + defer szConfig.Destroy(ctx) + configHandle, err := szConfig.CreateConfig(ctx) + testError(test, ctx, szAbstractFactory, err) + dataSources, err := szConfig.GetDataSources(ctx, configHandle) + testError(test, ctx, szAbstractFactory, err) + printActual(test, dataSources) +} + +func TestSzAbstractFactory_CreateSzConfigManager(test *testing.T) { + ctx := context.TODO() + szAbstractFactory := getTestObject(ctx, test) + szConfigManager, err := szAbstractFactory.CreateSzConfigManager(ctx) + testError(test, ctx, szAbstractFactory, err) + defer szConfigManager.Destroy(ctx) + configList, err := szConfigManager.GetConfigList(ctx) + testError(test, ctx, szAbstractFactory, err) + printActual(test, configList) +} + +func TestSzAbstractFactory_CreateSzDiagnostic(test *testing.T) { + ctx := context.TODO() + szAbstractFactory := getTestObject(ctx, test) + szDiagnostic, err := szAbstractFactory.CreateSzDiagnostic(ctx) + testError(test, ctx, szAbstractFactory, err) + defer szDiagnostic.Destroy(ctx) + result, err := szDiagnostic.CheckDatastorePerformance(ctx, 1) + testError(test, ctx, szAbstractFactory, err) + printActual(test, result) +} + +func TestSzAbstractFactory_CreateSzEngine(test *testing.T) { + ctx := context.TODO() + szAbstractFactory := getTestObject(ctx, test) + szEngine, err := szAbstractFactory.CreateSzEngine(ctx) + testError(test, ctx, szAbstractFactory, err) + defer szEngine.Destroy(ctx) + stats, err := szEngine.GetStats(ctx) + testError(test, ctx, szAbstractFactory, err) + printActual(test, stats) +} + +func TestSzAbstractFactory_CreateSzProduct(test *testing.T) { + ctx := context.TODO() + szAbstractFactory := getTestObject(ctx, test) + szProduct, err := szAbstractFactory.CreateSzProduct(ctx) + testError(test, ctx, szAbstractFactory, err) + defer szProduct.Destroy(ctx) + version, err := szProduct.GetVersion(ctx) + testError(test, ctx, szAbstractFactory, err) + printActual(test, version) +} + +// ---------------------------------------------------------------------------- +// Internal functions +// ---------------------------------------------------------------------------- + +func getSzAbstractFactory(ctx context.Context) sz.SzAbstractFactory { + _ = ctx + result := &Szabstractfactory{} + return result +} + +func getTestObject(ctx context.Context, test *testing.T) sz.SzAbstractFactory { + _ = test + return getSzAbstractFactory(ctx) +} + +func printActual(test *testing.T, actual interface{}) { + printResult(test, "Actual", actual) +} + +func printResult(test *testing.T, title string, result interface{}) { + if printResults { + test.Logf("%s: %v", title, truncate(fmt.Sprintf("%v", result), defaultTruncation)) + } +} + +func testError(test *testing.T, ctx context.Context, szAbstractFactory sz.SzAbstractFactory, err error) { + _ = ctx + _ = szAbstractFactory + if err != nil { + test.Log("Error:", err.Error()) + assert.FailNow(test, err.Error()) + } +} + +func truncate(aString string, length int) string { + return truncator.Truncate(aString, length, "...", truncator.PositionEnd) +} + +// ---------------------------------------------------------------------------- +// Test harness +// ---------------------------------------------------------------------------- + +func TestMain(m *testing.M) { + err := setup() + if err != nil { + fmt.Print(err) + os.Exit(1) + } + code := m.Run() + err = teardown() + if err != nil { + fmt.Print(err) + } + os.Exit(code) +} + +func setup() error { + var err error = nil + return err +} + +func teardown() error { + return nil +} diff --git a/szconfig/doc.go b/szconfig/doc.go new file mode 100644 index 0000000..6f86574 --- /dev/null +++ b/szconfig/doc.go @@ -0,0 +1,4 @@ +/* +The szconfig package is used make SzConfig requests to a mock object. +*/ +package szconfig diff --git a/g2config/main.go b/szconfig/main.go similarity index 73% rename from g2config/main.go rename to szconfig/main.go index 0ddceca..f2c8844 100644 --- a/g2config/main.go +++ b/szconfig/main.go @@ -1,8 +1,8 @@ -package g2config +package szconfig // ---------------------------------------------------------------------------- // Constants // ---------------------------------------------------------------------------- -// Identfier of the g2config package found messages having the format "senzing-6031xxxx". +// Identfier of the szconfig package found messages having the format "senzing-6031xxxx". const ComponentId = 6031 diff --git a/g2config/g2config.go b/szconfig/szconfig.go similarity index 69% rename from g2config/g2config.go rename to szconfig/szconfig.go index 77e046d..d985afc 100644 --- a/g2config/g2config.go +++ b/szconfig/szconfig.go @@ -1,71 +1,34 @@ /* - * - */ - -// Package g2config implements a client for the service. -package g2config +Package szconfig implements a client for the service. +*/ +package szconfig import ( "context" "strconv" "time" - g2configapi "github.com/senzing-garage/g2-sdk-go/g2config" "github.com/senzing-garage/go-logging/logging" "github.com/senzing-garage/go-observing/notifier" "github.com/senzing-garage/go-observing/observer" "github.com/senzing-garage/go-observing/subject" + "github.com/senzing-garage/sz-sdk-go/szconfig" ) -// ---------------------------------------------------------------------------- -// Types -// ---------------------------------------------------------------------------- - -type G2config struct { - AddDataSourceResult string - CreateResult uintptr - isTrace bool - ListDataSourcesResult string - LoadResult uintptr - logger logging.LoggingInterface - observerOrigin string - observers subject.Subject - SaveResult string -} - -// ---------------------------------------------------------------------------- -// Internal methods -// ---------------------------------------------------------------------------- - -// --- Logging ---------------------------------------------------------------- - -// Get the Logger singleton. -func (client *G2config) getLogger() logging.LoggingInterface { - var err error = nil - if client.logger == nil { - options := []interface{}{ - &logging.OptionCallerSkip{Value: 4}, - } - client.logger, err = logging.NewSenzingSdkLogger(ComponentId, g2configapi.IdMessages, options...) - if err != nil { - panic(err) - } - } - return client.logger -} - -// Trace method entry. -func (client *G2config) traceEntry(errorNumber int, details ...interface{}) { - client.getLogger().Log(errorNumber, details...) -} - -// Trace method exit. -func (client *G2config) traceExit(errorNumber int, details ...interface{}) { - client.getLogger().Log(errorNumber, details...) +type Szconfig struct { + AddDataSourceResult string + CreateConfigResult uintptr + isTrace bool + GetDataSourcesResult string + ImportConfigResult uintptr + logger logging.LoggingInterface + observerOrigin string + observers subject.Subject + ExportConfigResult string } // ---------------------------------------------------------------------------- -// Interface methods +// sz-sdk-go.SzConfig interface methods // ---------------------------------------------------------------------------- /* @@ -75,26 +38,26 @@ The configHandle is created by the Create() method. Input - ctx: A context to control lifecycle. - configHandle: An identifier of an in-memory configuration. - - inputJson: A JSON document in the format `{"DSRC_CODE": "NAME_OF_DATASOURCE"}`. + - dataSourceCode: A JSON document in the format `{"DSRC_CODE": "NAME_OF_DATASOURCE"}`. Output - A string containing a JSON document listing the newly created data source. See the example output. */ -func (client *G2config) AddDataSource(ctx context.Context, configHandle uintptr, inputJson string) (string, error) { +func (client *Szconfig) AddDataSource(ctx context.Context, configHandle uintptr, dataSourceCode string) (string, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(1, configHandle, inputJson) + client.traceEntry(1, configHandle, dataSourceCode) defer func() { - client.traceExit(2, configHandle, inputJson, client.AddDataSourceResult, err, time.Since(entryTime)) + client.traceExit(2, configHandle, dataSourceCode, client.AddDataSourceResult, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{ - "inputJson": inputJson, - "return": client.AddDataSourceResult, + "dataSourceCode": dataSourceCode, + "return": client.AddDataSourceResult, } notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8001, err, details) }() @@ -103,14 +66,14 @@ func (client *G2config) AddDataSource(ctx context.Context, configHandle uintptr, } /* -The Close method cleans up the Senzing G2Config object pointed to by the handle. +The CloseConfig method cleans up the Senzing G2Config object pointed to by the handle. The handle was created by the Create() method. Input - ctx: A context to control lifecycle. - configHandle: An identifier of an in-memory configuration. */ -func (client *G2config) Close(ctx context.Context, configHandle uintptr) error { +func (client *Szconfig) CloseConfig(ctx context.Context, configHandle uintptr) error { var err error = nil if client.isTrace { entryTime := time.Now() @@ -127,7 +90,7 @@ func (client *G2config) Close(ctx context.Context, configHandle uintptr) error { } /* -The Create method creates an in-memory Senzing configuration from the g2config.json +The CreateConfig method creates an in-memory Senzing configuration from the g2config.json template configuration file located in the PIPELINE.RESOURCEPATH path. A handle is returned to identify the in-memory configuration. The handle is used by the AddDataSource(), ListDataSources(), DeleteDataSource(), and Save() methods. @@ -139,12 +102,12 @@ Input Output - A Pointer to an in-memory Senzing configuration. */ -func (client *G2config) Create(ctx context.Context) (uintptr, error) { +func (client *Szconfig) CreateConfig(ctx context.Context) (uintptr, error) { var err error = nil if client.isTrace { entryTime := time.Now() client.traceEntry(7) - defer func() { client.traceExit(8, client.CreateResult, err, time.Since(entryTime)) }() + defer func() { client.traceExit(8, client.CreateConfigResult, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { @@ -152,7 +115,7 @@ func (client *G2config) Create(ctx context.Context) (uintptr, error) { notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8003, err, details) }() } - return client.CreateResult, err + return client.CreateConfigResult, err } /* @@ -162,19 +125,19 @@ The configHandle is created by the Create() method. Input - ctx: A context to control lifecycle. - configHandle: An identifier of an in-memory configuration. - - inputJson: A JSON document in the format `{"DSRC_CODE": "NAME_OF_DATASOURCE"}`. + - dataSourceCode: The datasource name (e.g. "TEST_DATASOURCE"). */ -func (client *G2config) DeleteDataSource(ctx context.Context, configHandle uintptr, inputJson string) error { +func (client *Szconfig) DeleteDataSource(ctx context.Context, configHandle uintptr, dataSourceCode string) error { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(9, configHandle, inputJson) - defer func() { client.traceExit(10, configHandle, inputJson, err, time.Since(entryTime)) }() + client.traceEntry(9, configHandle, dataSourceCode) + defer func() { client.traceExit(10, configHandle, dataSourceCode, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{ - "inputJson": inputJson, + "dataSourceCode": dataSourceCode, } notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8004, err, details) }() @@ -183,13 +146,13 @@ func (client *G2config) DeleteDataSource(ctx context.Context, configHandle uintp } /* -The Destroy method will destroy and perform cleanup for the Senzing G2Config object. +The Destroy method will destroy and perform cleanup for the Senzing Szconfig object. It should be called after all other calls are complete. Input - ctx: A context to control lifecycle. */ -func (client *G2config) Destroy(ctx context.Context) error { +func (client *Szconfig) Destroy(ctx context.Context) error { var err error = nil if client.isTrace { entryTime := time.Now() @@ -206,181 +169,185 @@ func (client *G2config) Destroy(ctx context.Context) error { } /* -The GetObserverOrigin method returns the "origin" value of past Observer messages. +The ExportConfig method creates a JSON string representation of the Senzing Szconfig object. +The configHandle is created by the Create() method. Input - ctx: A context to control lifecycle. + - configHandle: An identifier of an in-memory configuration. Output - - The value sent in the Observer's "origin" key/value pair. -*/ -func (client *G2config) GetObserverOrigin(ctx context.Context) string { - return client.observerOrigin -} - -/* -The GetSdkId method returns the identifier of this particular Software Development Kit (SDK). -It is handy when working with multiple implementations of the same G2configInterface. -For this implementation, "mock" is returned. - -Input - - ctx: A context to control lifecycle. + - A string containing a JSON Document representation of the Senzing Szconfig object. + See the example output. */ -func (client *G2config) GetSdkId(ctx context.Context) string { +func (client *Szconfig) ExportConfig(ctx context.Context, configHandle uintptr) (string, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(31) - defer func() { client.traceExit(32, err, time.Since(entryTime)) }() + client.traceEntry(23, configHandle) + defer func() { client.traceExit(24, configHandle, client.ExportConfigResult, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{} - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8010, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8009, err, details) }() } - return "mock" + return client.ExportConfigResult, err } /* -The Init method initializes the Senzing G2Config object. -It must be called prior to any other calls. +The GetDataSources method returns a JSON document of data sources. +The configHandle is created by the Create() method. Input - ctx: A context to control lifecycle. - - moduleName: A name for the auditing node, to help identify it within system logs. - - iniParams: A JSON string containing configuration parameters. - - verboseLogging: A flag to enable deeper logging of the G2 processing. 0 for no Senzing logging; 1 for logging. + - configHandle: An identifier of an in-memory configuration. + +Output + - A string containing a JSON document listing all of the data sources. + See the example output. */ -func (client *G2config) Init(ctx context.Context, moduleName string, iniParams string, verboseLogging int64) error { +func (client *Szconfig) GetDataSources(ctx context.Context, configHandle uintptr) (string, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(17, moduleName, iniParams, verboseLogging) - defer func() { client.traceExit(18, moduleName, iniParams, verboseLogging, err, time.Since(entryTime)) }() + client.traceEntry(19, configHandle) + defer func() { client.traceExit(20, configHandle, client.GetDataSourcesResult, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { - details := map[string]string{ - "iniParams": iniParams, - "moduleName": moduleName, - "verboseLogging": strconv.FormatInt(verboseLogging, 10), - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8006, err, details) + details := map[string]string{} + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8007, err, details) }() } - return err + return client.GetDataSourcesResult, err } /* -The ListDataSources method returns a JSON document of data sources. -The configHandle is created by the Create() method. +The ImportConfig method initializes the in-memory Senzing G2Config object from a JSON string. Input - ctx: A context to control lifecycle. - - configHandle: An identifier of an in-memory configuration. + - configDefinition: A JSON document containing the Senzing configuration. Output - - A string containing a JSON document listing all of the data sources. - See the example output. + - An identifier of an in-memory configuration. */ -func (client *G2config) ListDataSources(ctx context.Context, configHandle uintptr) (string, error) { +func (client *Szconfig) ImportConfig(ctx context.Context, configDefinition string) (uintptr, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(19, configHandle) - defer func() { client.traceExit(20, configHandle, client.ListDataSourcesResult, err, time.Since(entryTime)) }() + client.traceEntry(21, configDefinition) + defer func() { client.traceExit(22, configDefinition, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{} - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8007, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8008, err, details) }() } - return client.ListDataSourcesResult, err + return client.ImportConfigResult, err } +// ---------------------------------------------------------------------------- +// Public non-interface methods +// ---------------------------------------------------------------------------- + /* -The Load method initializes the in-memory Senzing G2Config object from a JSON string. +The GetObserverOrigin method returns the "origin" value of past Observer messages. Input - ctx: A context to control lifecycle. - - jsonConfig: A JSON document containing the Senzing configuration. Output - - An identifier of an in-memory configuration. + - The value sent in the Observer's "origin" key/value pair. +*/ +func (client *Szconfig) GetObserverOrigin(ctx context.Context) string { + return client.observerOrigin +} + +/* +The GetSdkId method returns the identifier of this particular Software Development Kit (SDK). +It is handy when working with multiple implementations of the same SzConfig interface. +For this implementation, "mock" is returned. + +Input + - ctx: A context to control lifecycle. */ -func (client *G2config) Load(ctx context.Context, jsonConfig string) (uintptr, error) { +func (client *Szconfig) GetSdkId(ctx context.Context) string { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(21, jsonConfig) - defer func() { client.traceExit(22, jsonConfig, err, time.Since(entryTime)) }() + client.traceEntry(31) + defer func() { client.traceExit(32, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{} - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8008, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8010, err, details) }() } - return client.LoadResult, err + return "mock" } /* -The RegisterObserver method adds the observer to the list of observers notified. +The Initialize method initializes the Senzing Szconfig object. +It must be called prior to any other calls. Input - ctx: A context to control lifecycle. - - observer: The observer to be added. + - instanceName: A name for the auditing node, to help identify it within system logs. + - settings: A JSON string containing configuration parameters. + - verboseLogging: A flag to enable deeper logging of the G2 processing. 0 for no Senzing logging; 1 for logging. */ -func (client *G2config) RegisterObserver(ctx context.Context, observer observer.Observer) error { +func (client *Szconfig) Initialize(ctx context.Context, instanceName string, settings string, verboseLogging int64) error { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(27, observer.GetObserverId(ctx)) - defer func() { client.traceExit(28, observer.GetObserverId(ctx), err, time.Since(entryTime)) }() + client.traceEntry(17, instanceName, settings, verboseLogging) + defer func() { client.traceExit(18, instanceName, settings, verboseLogging, err, time.Since(entryTime)) }() } - if client.observers == nil { - client.observers = &subject.SubjectImpl{} - } - err = client.observers.RegisterObserver(ctx, observer) if client.observers != nil { go func() { details := map[string]string{ - "observerID": observer.GetObserverId(ctx), + "instancename": instanceName, + "settings": settings, + "verboseLogging": strconv.FormatInt(verboseLogging, 10), } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8011, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8006, err, details) }() } return err } /* -The Save method creates a JSON string representation of the Senzing G2Config object. -The configHandle is created by the Create() method. +The RegisterObserver method adds the observer to the list of observers notified. Input - ctx: A context to control lifecycle. - - configHandle: An identifier of an in-memory configuration. - -Output - - A string containing a JSON Document representation of the Senzing G2Config object. - See the example output. + - observer: The observer to be added. */ -func (client *G2config) Save(ctx context.Context, configHandle uintptr) (string, error) { +func (client *Szconfig) RegisterObserver(ctx context.Context, observer observer.Observer) error { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(23, configHandle) - defer func() { client.traceExit(24, configHandle, client.SaveResult, err, time.Since(entryTime)) }() + client.traceEntry(27, observer.GetObserverId(ctx)) + defer func() { client.traceExit(28, observer.GetObserverId(ctx), err, time.Since(entryTime)) }() + } + if client.observers == nil { + client.observers = &subject.SubjectImpl{} } + err = client.observers.RegisterObserver(ctx, observer) if client.observers != nil { go func() { - details := map[string]string{} - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8009, err, details) + details := map[string]string{ + "observerId": observer.GetObserverId(ctx), + } + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8011, err, details) }() } - return client.SaveResult, err + return err } /* @@ -388,9 +355,9 @@ The SetLogLevel method sets the level of logging. Input - ctx: A context to control lifecycle. - - logLevel: The desired log level. TRACE, DEBUG, INFO, WARN, ERROR, FATAL or PANIC. + - logLevelName: The desired log level. TRACE, DEBUG, INFO, WARN, ERROR, FATAL or PANIC. */ -func (client *G2config) SetLogLevel(ctx context.Context, logLevelName string) error { +func (client *Szconfig) SetLogLevel(ctx context.Context, logLevelName string) error { var err error = nil if client.isTrace { entryTime := time.Now() @@ -417,7 +384,7 @@ Input - ctx: A context to control lifecycle. - origin: The value sent in the Observer's "origin" key/value pair. */ -func (client *G2config) SetObserverOrigin(ctx context.Context, origin string) { +func (client *Szconfig) SetObserverOrigin(ctx context.Context, origin string) { client.observerOrigin = origin } @@ -428,7 +395,7 @@ Input - ctx: A context to control lifecycle. - observer: The observer to be added. */ -func (client *G2config) UnregisterObserver(ctx context.Context, observer observer.Observer) error { +func (client *Szconfig) UnregisterObserver(ctx context.Context, observer observer.Observer) error { var err error = nil if client.isTrace { entryTime := time.Now() @@ -441,7 +408,7 @@ func (client *G2config) UnregisterObserver(ctx context.Context, observer observe // In client.notify, each observer will get notified in a goroutine. // Then client.observers may be set to nil, but observer goroutines will be OK. details := map[string]string{ - "observerID": observer.GetObserverId(ctx), + "observerId": observer.GetObserverId(ctx), } notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8013, err, details) } @@ -451,3 +418,34 @@ func (client *G2config) UnregisterObserver(ctx context.Context, observer observe } return err } + +// ---------------------------------------------------------------------------- +// Internal methods +// ---------------------------------------------------------------------------- + +// --- Logging ---------------------------------------------------------------- + +// Get the Logger singleton. +func (client *Szconfig) getLogger() logging.LoggingInterface { + var err error = nil + if client.logger == nil { + options := []interface{}{ + &logging.OptionCallerSkip{Value: 4}, + } + client.logger, err = logging.NewSenzingSdkLogger(ComponentId, szconfig.IdMessages, options...) + if err != nil { + panic(err) + } + } + return client.logger +} + +// Trace method entry. +func (client *Szconfig) traceEntry(errorNumber int, details ...interface{}) { + client.getLogger().Log(errorNumber, details...) +} + +// Trace method exit. +func (client *Szconfig) traceExit(errorNumber int, details ...interface{}) { + client.getLogger().Log(errorNumber, details...) +} diff --git a/szconfig/szconfig_examples_test.go b/szconfig/szconfig_examples_test.go new file mode 100644 index 0000000..be4f339 --- /dev/null +++ b/szconfig/szconfig_examples_test.go @@ -0,0 +1,194 @@ +//go:build linux + +package szconfig + +import ( + "context" + "fmt" + + "github.com/senzing-garage/go-logging/logging" + "github.com/senzing-garage/sz-sdk-go/sz" +) + +// ---------------------------------------------------------------------------- +// Interface functions - Examples for godoc documentation +// ---------------------------------------------------------------------------- + +func ExampleSzconfig_AddDataSource() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szconfig/szconfig_examples_test.go + ctx := context.TODO() + szConfig := getSzConfig(ctx) + configHandle, err := szConfig.CreateConfig(ctx) + if err != nil { + fmt.Println(err) + } + dataSourceCode := "GO_TEST" + result, err := szConfig.AddDataSource(ctx, configHandle, dataSourceCode) + if err != nil { + fmt.Println(err) + } + fmt.Println(result) + // Output: {"DSRC_ID":1001} +} + +func ExampleSzconfig_CloseConfig() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szconfig/szconfig_examples_test.go + ctx := context.TODO() + szConfig := getSzConfig(ctx) + configHandle, err := szConfig.CreateConfig(ctx) + if err != nil { + fmt.Println(err) + } + err = szConfig.CloseConfig(ctx, configHandle) + if err != nil { + fmt.Println(err) + } + // Output: +} + +func ExampleSzconfig_CreateConfig() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szconfig/szconfig_examples_test.go + ctx := context.TODO() + szConfig := getSzConfig(ctx) + configHandle, err := szConfig.CreateConfig(ctx) + if err != nil { + fmt.Println(err) + } + fmt.Println(configHandle > 0) // Dummy output. + // Output: true +} + +func ExampleSzconfig_DeleteDataSource() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szconfig/szconfig_examples_test.go + ctx := context.TODO() + szConfig := getSzConfig(ctx) + configHandle, err := szConfig.CreateConfig(ctx) + if err != nil { + fmt.Println(err) + } + dataSourceCode := "TEST" + err = szConfig.DeleteDataSource(ctx, configHandle, dataSourceCode) + if err != nil { + fmt.Println(err) + } + // Output: +} + +func ExampleSzconfig_ExportConfig() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szconfig/szconfig_examples_test.go + ctx := context.TODO() + szConfig := getSzConfig(ctx) + configHandle, err := szConfig.CreateConfig(ctx) + if err != nil { + fmt.Println(err) + } + configDefinition, err := szConfig.ExportConfig(ctx, configHandle) + if err != nil { + fmt.Println(err) + } + fmt.Println(truncate(configDefinition, 207)) + // Output: {"G2_CONFIG":{"CFG_ATTR":[{"ATTR_ID":1001,"ATTR_CODE":"DATA_SOURCE","ATTR_CLASS":"OBSERVATION","FTYPE_CODE":null,"FELEM_CODE":null,"FELEM_REQ":"Yes","DEFAULT_VALUE":null,"INTERNAL":"No"},{"ATTR_ID":1003,"... +} + +func ExampleSzconfig_GetDataSources() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szconfig/szconfig_examples_test.go + ctx := context.TODO() + szConfig := getSzConfig(ctx) + configHandle, err := szConfig.CreateConfig(ctx) + if err != nil { + fmt.Println(err) + } + result, err := szConfig.GetDataSources(ctx, configHandle) + if err != nil { + fmt.Println(err) + } + fmt.Println(result) + // Output: {"DATA_SOURCES":[{"DSRC_ID":1,"DSRC_CODE":"TEST"},{"DSRC_ID":2,"DSRC_CODE":"SEARCH"}]} +} + +func ExampleSzconfig_ImportConfig() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szconfig/szconfig_examples_test.go + ctx := context.TODO() + szConfig := getSzConfig(ctx) + mockConfigHandle, err := szConfig.CreateConfig(ctx) + if err != nil { + fmt.Println(err) + } + configDefinition, err := szConfig.ExportConfig(ctx, mockConfigHandle) + if err != nil { + fmt.Println(err) + } + configHandle, err := szConfig.ImportConfig(ctx, configDefinition) + if err != nil { + fmt.Println(err) + } + fmt.Println(configHandle > 0) // Dummy output. + // Output: true +} + +// ---------------------------------------------------------------------------- +// Logging and observing +// ---------------------------------------------------------------------------- + +func ExampleSzconfig_SetLogLevel() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szconfig/szconfig_examples_test.go + ctx := context.TODO() + szConfig := getSzConfig(ctx) + err := szConfig.SetLogLevel(ctx, logging.LevelInfoName) + if err != nil { + fmt.Println(err) + } + // Output: +} + +func ExampleSzconfig_SetObserverOrigin() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szconfig/szconfig_examples_test.go + ctx := context.TODO() + szConfig := getSzConfig(ctx) + origin := "Machine: nn; Task: UnitTest" + szConfig.SetObserverOrigin(ctx, origin) + // Output: +} + +func ExampleSzconfig_GetObserverOrigin() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szconfig/szconfig_examples_test.go + ctx := context.TODO() + szConfig := getSzConfig(ctx) + origin := "Machine: nn; Task: UnitTest" + szConfig.SetObserverOrigin(ctx, origin) + result := szConfig.GetObserverOrigin(ctx) + fmt.Println(result) + // Output: Machine: nn; Task: UnitTest +} + +// ---------------------------------------------------------------------------- +// Object creation / destruction +// ---------------------------------------------------------------------------- + +func ExampleSzconfig_Initialize() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szconfig/szconfig_examples_test.go + ctx := context.TODO() + szConfig := getSzConfig(ctx) + instanceName := "Test name" + settings, err := getSettings() + if err != nil { + fmt.Println(err) + } + verboseLogging := sz.SZ_NO_LOGGING + err = szConfig.Initialize(ctx, instanceName, settings, verboseLogging) + if err != nil { + fmt.Println(err) + } + // Output: +} + +func ExampleSzconfig_Destroy() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szconfig/szconfig_examples_test.go + ctx := context.TODO() + szConfig := getSzConfig(ctx) + err := szConfig.Destroy(ctx) + if err != nil { + fmt.Println(err) + } + // Output: +} diff --git a/szconfig/szconfig_test.go b/szconfig/szconfig_test.go new file mode 100644 index 0000000..56e4c8f --- /dev/null +++ b/szconfig/szconfig_test.go @@ -0,0 +1,294 @@ +package szconfig + +import ( + "context" + "fmt" + "os" + "testing" + + truncator "github.com/aquilax/truncate" + "github.com/senzing-garage/sz-sdk-go/sz" + "github.com/stretchr/testify/assert" +) + +const ( + defaultTruncation = 76 + printResults = false +) + +var ( + szConfigSingleton *Szconfig +) + +// ---------------------------------------------------------------------------- +// Interface functions - test +// ---------------------------------------------------------------------------- + +func TestSzconfig_AddDataSource(test *testing.T) { + ctx := context.TODO() + szConfig := getTestObject(ctx, test) + configHandle, err := szConfig.CreateConfig(ctx) + testError(test, err) + dataSourceCode := "GO_TEST" + actual, err := szConfig.AddDataSource(ctx, configHandle, dataSourceCode) + testError(test, err) + printActual(test, actual) + err = szConfig.CloseConfig(ctx, configHandle) + testError(test, err) +} + +func TestSzconfig_AddDataSource_withLoad(test *testing.T) { + ctx := context.TODO() + szConfig := getTestObject(ctx, test) + configHandle, err := szConfig.CreateConfig(ctx) + testError(test, err) + configDefinition, err := szConfig.ExportConfig(ctx, configHandle) + testError(test, err) + err = szConfig.CloseConfig(ctx, configHandle) + testError(test, err) + configHandle2, err := szConfig.ImportConfig(ctx, configDefinition) + testError(test, err) + dataSourceCode := "GO_TEST" + actual, err := szConfig.AddDataSource(ctx, configHandle2, dataSourceCode) + testError(test, err) + printActual(test, actual) + err = szConfig.CloseConfig(ctx, configHandle2) + testError(test, err) +} + +func TestSzconfig_CloseConfig(test *testing.T) { + ctx := context.TODO() + szConfig := getTestObject(ctx, test) + configHandle, err := szConfig.CreateConfig(ctx) + testError(test, err) + err = szConfig.CloseConfig(ctx, configHandle) + testError(test, err) +} + +func TestSzconfig_CreateConfig(test *testing.T) { + ctx := context.TODO() + szConfig := getTestObject(ctx, test) + actual, err := szConfig.CreateConfig(ctx) + testError(test, err) + printActual(test, actual) +} + +func TestSzconfig_DeleteDataSource(test *testing.T) { + ctx := context.TODO() + szConfig := getTestObject(ctx, test) + configHandle, err := szConfig.CreateConfig(ctx) + testError(test, err) + actual, err := szConfig.GetDataSources(ctx, configHandle) + testError(test, err) + printResult(test, "Original", actual) + dataSourceCode := "GO_TEST" + _, err = szConfig.AddDataSource(ctx, configHandle, dataSourceCode) + testError(test, err) + actual, err = szConfig.GetDataSources(ctx, configHandle) + testError(test, err) + printResult(test, " Add", actual) + err = szConfig.DeleteDataSource(ctx, configHandle, dataSourceCode) + testError(test, err) + actual, err = szConfig.GetDataSources(ctx, configHandle) + testError(test, err) + printResult(test, " Delete", actual) + err = szConfig.CloseConfig(ctx, configHandle) + testError(test, err) +} + +func TestSzconfig_DeleteDataSource_withLoad(test *testing.T) { + ctx := context.TODO() + szConfig := getTestObject(ctx, test) + configHandle, err := szConfig.CreateConfig(ctx) + testError(test, err) + actual, err := szConfig.GetDataSources(ctx, configHandle) + testError(test, err) + printResult(test, "Original", actual) + dataSourceCode := "GO_TEST" + _, err = szConfig.AddDataSource(ctx, configHandle, dataSourceCode) + testError(test, err) + actual, err = szConfig.GetDataSources(ctx, configHandle) + testError(test, err) + printResult(test, " Add", actual) + configDefinition, err := szConfig.ExportConfig(ctx, configHandle) + testError(test, err) + err = szConfig.CloseConfig(ctx, configHandle) + testError(test, err) + configHandle2, err := szConfig.ImportConfig(ctx, configDefinition) + testError(test, err) + err = szConfig.DeleteDataSource(ctx, configHandle2, dataSourceCode) + testError(test, err) + actual, err = szConfig.GetDataSources(ctx, configHandle2) + testError(test, err) + printResult(test, " Delete", actual) + err = szConfig.CloseConfig(ctx, configHandle2) + testError(test, err) +} + +func TestSzconfig_ExportConfig(test *testing.T) { + ctx := context.TODO() + szConfig := getTestObject(ctx, test) + configHandle, err := szConfig.CreateConfig(ctx) + testError(test, err) + actual, err := szConfig.ExportConfig(ctx, configHandle) + testError(test, err) + printActual(test, actual) +} + +func TestSzconfig_GetDataSources(test *testing.T) { + ctx := context.TODO() + szConfig := getTestObject(ctx, test) + configHandle, err := szConfig.CreateConfig(ctx) + testError(test, err) + actual, err := szConfig.GetDataSources(ctx, configHandle) + testError(test, err) + printActual(test, actual) + err = szConfig.CloseConfig(ctx, configHandle) + testError(test, err) +} + +func TestSzconfig_ImportConfig(test *testing.T) { + ctx := context.TODO() + szConfig := getTestObject(ctx, test) + configHandle, err := szConfig.CreateConfig(ctx) + testError(test, err) + configDefinition, err := szConfig.ExportConfig(ctx, configHandle) + testError(test, err) + actual, err := szConfig.ImportConfig(ctx, configDefinition) + testError(test, err) + printActual(test, actual) +} + +// ---------------------------------------------------------------------------- +// Logging and observing +// ---------------------------------------------------------------------------- + +func TestSzconfig_SetObserverOrigin(test *testing.T) { + ctx := context.TODO() + szConfig := getTestObject(ctx, test) + origin := "Machine: nn; Task: UnitTest" + szConfig.SetObserverOrigin(ctx, origin) +} + +func TestSzconfig_GetObserverOrigin(test *testing.T) { + ctx := context.TODO() + szConfig := getTestObject(ctx, test) + origin := "Machine: nn; Task: UnitTest" + szConfig.SetObserverOrigin(ctx, origin) + actual := szConfig.GetObserverOrigin(ctx) + assert.Equal(test, origin, actual) +} + +// ---------------------------------------------------------------------------- +// Object creation / destruction +// ---------------------------------------------------------------------------- + +func TestSzconfig_AsInterface(test *testing.T) { + ctx := context.TODO() + szConfig := getSzConfigAsInterface(ctx) + configHandle, err := szConfig.CreateConfig(ctx) + testError(test, err) + actual, err := szConfig.GetDataSources(ctx, configHandle) + testError(test, err) + printActual(test, actual) + err = szConfig.CloseConfig(ctx, configHandle) + testError(test, err) +} + +func TestSzconfig_Initialize(test *testing.T) { + ctx := context.TODO() + szConfig := getTestObject(ctx, test) + instanceName := "Test name" + verboseLogging := sz.SZ_NO_LOGGING + settings, err := getSettings() + testError(test, err) + err = szConfig.Initialize(ctx, instanceName, settings, verboseLogging) + testError(test, err) +} + +func TestSzconfig_Destroy(test *testing.T) { + ctx := context.TODO() + szConfig := getTestObject(ctx, test) + err := szConfig.Destroy(ctx) + testError(test, err) +} + +// ---------------------------------------------------------------------------- +// Internal functions +// ---------------------------------------------------------------------------- + +func getSettings() (string, error) { + return "{}", nil +} + +func getSzConfig(ctx context.Context) *Szconfig { + _ = ctx + if szConfigSingleton == nil { + szConfigSingleton = &Szconfig{ + AddDataSourceResult: `{"DSRC_ID":1001}`, + CreateConfigResult: 1, + ExportConfigResult: `{"G2_CONFIG":{"CFG_ATTR":[{"ATTR_ID":1001,"ATTR_CODE":"DATA_SOURCE","ATTR_CLASS":"OBSERVATION","FTYPE_CODE":null,"FELEM_CODE":null,"FELEM_REQ":"Yes","DEFAULT_VALUE":null,"INTERNAL":"No"},{"ATTR_ID":1003,"ATTR_CODE":"RECORD_ID","ATTR_CLASS":"OBSERVATION","FTYPE_CODE":null,"FELEM_CODE":null,"FELEM_REQ":"No","DEFAULT_VALUE":null,"INTERNAL":"No"},{"ATTR_ID":1007,"ATTR_CODE":"DSRC_ACTION","ATTR_CLASS":"OBSERVATION","FTYPE_CODE":null,"FELEM_CODE":null,"FELEM_REQ":"Yes","DEFAULT_VALUE":null,"INTERNAL":"No"},{"ATTR_ID":1101,"ATTR_CODE":"NAME_TYPE","ATTR_CLASS":"NAME","FTYPE_CODE":"NAME","FELEM_CODE":"USAGE_TYPE","FELEM_REQ":"No","DEFAULT_VALUE":null,"INTERNAL":"No"},{"ATTR_ID":1102,"ATTR_CODE":"NAME_FULL","ATTR_CLASS":"NAME","FTYPE_CODE":"NAME","FELEM_CODE":"FULL_NAME","FELEM_REQ":"Any","DEFAULT_VALUE":null,"INTERNAL":"No"},{"ATTR_ID":1103,"ATTR_CODE":"NAME_ORG","ATTR_CLASS":"NAME","FTYPE_CODE":"NAME","FELEM_CODE":"ORG_NAME","FELEM_REQ":"Any","DEFAULT_VALUE":null,"INTERNAL":"No"},{"ATTR_ID":1104,"ATTR_CODE":"NAME_LAST","ATTR_CLASS":"NAME","FTYPE_CODE":"NAME","FELEM_CODE":"SUR_NAME","FELEM_REQ":"Any","DEFAULT_VALUE":null,"INTERNAL":"No"},{"ATTR_ID":1105,"ATTR_CODE":"NAME_FIRST","ATTR_CLASS":"NAME","FTYPE_CODE":"NAME","FELEM_CODE":"GIVEN_NAME","FELEM_REQ":"Any","DEFAULT_VALUE":null,"INTERNAL":"No"},{"ATTR_ID":1106,"ATTR_CODE":"NAME_MIDDLE",`, + GetDataSourcesResult: `{"DATA_SOURCES":[{"DSRC_ID":1,"DSRC_CODE":"TEST"},{"DSRC_ID":2,"DSRC_CODE":"SEARCH"}]}`, + ImportConfigResult: 1, + } + } + return szConfigSingleton +} + +func getSzConfigAsInterface(ctx context.Context) sz.SzConfig { + return getSzConfig(ctx) +} + +func getTestObject(ctx context.Context, test *testing.T) *Szconfig { + _ = test + return getSzConfig(ctx) +} + +func printActual(test *testing.T, actual interface{}) { + printResult(test, "Actual", actual) +} + +func printResult(test *testing.T, title string, result interface{}) { + if printResults { + test.Logf("%s: %v", title, truncate(fmt.Sprintf("%v", result), defaultTruncation)) + } +} + +func testError(test *testing.T, err error) { + if err != nil { + test.Log("Error:", err.Error()) + assert.FailNow(test, err.Error()) + } +} + +func truncate(aString string, length int) string { + return truncator.Truncate(aString, length, "...", truncator.PositionEnd) +} + +// ---------------------------------------------------------------------------- +// Test harness +// ---------------------------------------------------------------------------- + +func TestMain(m *testing.M) { + err := setup() + if err != nil { + fmt.Print(err) + os.Exit(1) + } + code := m.Run() + err = teardown() + if err != nil { + fmt.Print(err) + } + os.Exit(code) +} + +func setup() error { + var err error = nil + return err +} + +func teardown() error { + var err error = nil + return err +} diff --git a/szconfigmanager/doc.go b/szconfigmanager/doc.go new file mode 100644 index 0000000..ca9f265 --- /dev/null +++ b/szconfigmanager/doc.go @@ -0,0 +1,4 @@ +/* +The szconfigmanager package is used make G2Configmgr requests to a mock object. +*/ +package szconfigmanager diff --git a/g2configmgr/main.go b/szconfigmanager/main.go similarity index 62% rename from g2configmgr/main.go rename to szconfigmanager/main.go index 30df28f..000c084 100644 --- a/g2configmgr/main.go +++ b/szconfigmanager/main.go @@ -1,8 +1,8 @@ -package g2configmgr +package szconfigmanager // ---------------------------------------------------------------------------- // Constants // ---------------------------------------------------------------------------- -// Identfier of the g2configmgr package found messages having the format "senzing-6032xxxx". +// Identfier of the szconfigmanager package found messages having the format "senzing-6032xxxx". const ComponentId = 6032 diff --git a/g2configmgr/g2configmgr.go b/szconfigmanager/szconfigmanager.go similarity index 69% rename from g2configmgr/g2configmgr.go rename to szconfigmanager/szconfigmanager.go index 2e038a1..15be2c7 100644 --- a/g2configmgr/g2configmgr.go +++ b/szconfigmanager/szconfigmanager.go @@ -1,31 +1,25 @@ /* - * - */ - -// Package g2configmgrclient implements a client for the service. -package g2configmgr +Package szconfigmanager implements a client for the service. +*/ +package szconfigmanager import ( "context" "strconv" "time" - g2configmgrapi "github.com/senzing-garage/g2-sdk-go/g2configmgr" "github.com/senzing-garage/go-logging/logging" "github.com/senzing-garage/go-observing/notifier" "github.com/senzing-garage/go-observing/observer" "github.com/senzing-garage/go-observing/subject" + "github.com/senzing-garage/sz-sdk-go/szconfigmanager" ) -// ---------------------------------------------------------------------------- -// Types -// ---------------------------------------------------------------------------- - -type G2configmgr struct { +type Szconfigmanager struct { AddConfigResult int64 GetConfigListResult string GetConfigResult string - GetDefaultConfigIDResult int64 + GetDefaultConfigIdResult int64 isTrace bool logger logging.LoggingInterface observerOrigin string @@ -33,38 +27,7 @@ type G2configmgr struct { } // ---------------------------------------------------------------------------- -// Internal methods -// ---------------------------------------------------------------------------- - -// --- Logging ---------------------------------------------------------------- - -// Get the Logger singleton. -func (client *G2configmgr) getLogger() logging.LoggingInterface { - var err error = nil - if client.logger == nil { - options := []interface{}{ - &logging.OptionCallerSkip{Value: 4}, - } - client.logger, err = logging.NewSenzingSdkLogger(ComponentId, g2configmgrapi.IdMessages, options...) - if err != nil { - panic(err) - } - } - return client.logger -} - -// Trace method entry. -func (client *G2configmgr) traceEntry(errorNumber int, details ...interface{}) { - client.getLogger().Log(errorNumber, details...) -} - -// Trace method exit. -func (client *G2configmgr) traceExit(errorNumber int, details ...interface{}) { - client.getLogger().Log(errorNumber, details...) -} - -// ---------------------------------------------------------------------------- -// Interface methods +// sz-sdk-go.SzConfigManager interface methods // ---------------------------------------------------------------------------- /* @@ -72,25 +35,25 @@ The AddConfig method adds a Senzing configuration JSON document to the Senzing d Input - ctx: A context to control lifecycle. - - configStr: The Senzing configuration JSON document. - - configComments: A free-form string of comments describing the configuration document. + - configDefinition: The Senzing configuration JSON document. + - configComment: A free-form string describing the configuration document. Output - A configuration identifier. */ -func (client *G2configmgr) AddConfig(ctx context.Context, configStr string, configComments string) (int64, error) { +func (client *Szconfigmanager) AddConfig(ctx context.Context, configDefinition string, configComment string) (int64, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(1, configStr, configComments) + client.traceEntry(1, configDefinition, configComment) defer func() { - client.traceExit(2, configStr, configComments, client.AddConfigResult, err, time.Since(entryTime)) + client.traceExit(2, configDefinition, configComment, client.AddConfigResult, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{ - "configComments": configComments, + "configComment": configComment, } notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8001, err, details) }() @@ -105,7 +68,7 @@ It should be called after all other calls are complete. Input - ctx: A context to control lifecycle. */ -func (client *G2configmgr) Destroy(ctx context.Context) error { +func (client *Szconfigmanager) Destroy(ctx context.Context) error { var err error = nil if client.isTrace { entryTime := time.Now() @@ -126,18 +89,18 @@ The GetConfig method retrieves a specific Senzing configuration JSON document fr Input - ctx: A context to control lifecycle. - - configID: The configuration identifier of the desired Senzing Engine configuration JSON document to retrieve. + - configId: The configuration identifier of the desired Senzing Engine configuration JSON document to retrieve. Output - A JSON document containing the Senzing configuration. See the example output. */ -func (client *G2configmgr) GetConfig(ctx context.Context, configID int64) (string, error) { +func (client *Szconfigmanager) GetConfig(ctx context.Context, configId int64) (string, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(7, configID) - defer func() { client.traceExit(8, configID, client.GetConfigResult, err, time.Since(entryTime)) }() + client.traceEntry(7, configId) + defer func() { client.traceExit(8, configId, client.GetConfigResult, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { @@ -158,7 +121,7 @@ Output - A JSON document containing Senzing configurations. See the example output. */ -func (client *G2configmgr) GetConfigList(ctx context.Context) (string, error) { +func (client *Szconfigmanager) GetConfigList(ctx context.Context) (string, error) { var err error = nil if client.isTrace { entryTime := time.Now() @@ -175,7 +138,7 @@ func (client *G2configmgr) GetConfigList(ctx context.Context) (string, error) { } /* -The GetDefaultConfigID method retrieves from the Senzing database the configuration identifier of the default Senzing configuration. +The GetDefaultConfigId method retrieves from the Senzing database the configuration identifier of the default Senzing configuration. Input - ctx: A context to control lifecycle. @@ -183,12 +146,12 @@ Input Output - A configuration identifier which identifies the current configuration in use. */ -func (client *G2configmgr) GetDefaultConfigID(ctx context.Context) (int64, error) { +func (client *Szconfigmanager) GetDefaultConfigId(ctx context.Context) (int64, error) { var err error = nil if client.isTrace { entryTime := time.Now() client.traceEntry(11) - defer func() { client.traceExit(12, client.GetDefaultConfigIDResult, err, time.Since(entryTime)) }() + defer func() { client.traceExit(12, client.GetDefaultConfigIdResult, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { @@ -196,155 +159,159 @@ func (client *G2configmgr) GetDefaultConfigID(ctx context.Context) (int64, error notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8005, err, details) }() } - return client.GetDefaultConfigIDResult, err -} - -/* -The GetObserverOrigin method returns the "origin" value of past Observer messages. - -Input - - ctx: A context to control lifecycle. - -Output - - The value sent in the Observer's "origin" key/value pair. -*/ -func (client *G2configmgr) GetObserverOrigin(ctx context.Context) string { - return client.observerOrigin + return client.GetDefaultConfigIdResult, err } /* -The GetSdkId method returns the identifier of this particular Software Development Kit (SDK). -It is handy when working with multiple implementations of the same G2configmgrInterface. -For this implementation, "mock" is returned. +The ReplaceDefaultConfigId method replaces the old configuration identifier with a new configuration identifier in the Senzing database. +It is like a "compare-and-swap" instruction to serialize concurrent editing of configuration. +If currentDefaultConfigId is no longer the "old configuration identifier", the operation will fail. +To simply set the default configuration ID, use SetDefaultConfigId(). Input - ctx: A context to control lifecycle. + - currentDefaultConfigId: The configuration identifier to replace. + - newDefaultConfigId: The configuration identifier to use as the default. */ -func (client *G2configmgr) GetSdkId(ctx context.Context) string { +func (client *Szconfigmanager) ReplaceDefaultConfigId(ctx context.Context, currentDefaultConfigId int64, newDefaultConfigId int64) error { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(29) - defer func() { client.traceExit(30, err, time.Since(entryTime)) }() + client.traceEntry(19, currentDefaultConfigId, newDefaultConfigId) + defer func() { client.traceExit(20, currentDefaultConfigId, newDefaultConfigId, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { - details := map[string]string{} - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8010, err, details) + details := map[string]string{ + "newDefaultConfigId": strconv.FormatInt(newDefaultConfigId, 10), + } + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8007, err, details) }() } - return "mock" + return err } /* -The Init method initializes the Senzing G2ConfigMgr object. -It must be called prior to any other calls. +The SetDefaultConfigId method replaces the sets a new configuration identifier in the Senzing database. +To serialize modifying of the configuration identifier, see ReplaceDefaultConfigId(). Input - ctx: A context to control lifecycle. - - moduleName: A name for the auditing node, to help identify it within system logs. - - iniParams: A JSON string containing configuration parameters. - - verboseLogging: A flag to enable deeper logging of the G2 processing. 0 for no Senzing logging; 1 for logging. + - configId: The configuration identifier of the Senzing Engine configuration to use as the default. */ -func (client *G2configmgr) Init(ctx context.Context, moduleName string, iniParams string, verboseLogging int64) error { +func (client *Szconfigmanager) SetDefaultConfigId(ctx context.Context, configId int64) error { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(17, moduleName, iniParams, verboseLogging) - defer func() { client.traceExit(18, moduleName, iniParams, verboseLogging, err, time.Since(entryTime)) }() + client.traceEntry(21, configId) + defer func() { client.traceExit(22, configId, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{ - "iniParams": iniParams, - "moduleName": moduleName, - "verboseLogging": strconv.FormatInt(verboseLogging, 10), + "configId": strconv.FormatInt(configId, 10), } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8006, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8008, err, details) }() } return err } +// ---------------------------------------------------------------------------- +// Public non-interface methods +// ---------------------------------------------------------------------------- + /* -The RegisterObserver method adds the observer to the list of observers notified. +The GetObserverOrigin method returns the "origin" value of past Observer messages. Input - ctx: A context to control lifecycle. - - observer: The observer to be added. + +Output + - The value sent in the Observer's "origin" key/value pair. */ -func (client *G2configmgr) RegisterObserver(ctx context.Context, observer observer.Observer) error { +func (client *Szconfigmanager) GetObserverOrigin(ctx context.Context) string { + return client.observerOrigin +} + +/* +The GetSdkId method returns the identifier of this particular Software Development Kit (SDK). +It is handy when working with multiple implementations of the same SzConfigManager interface. +For this implementation, "mock" is returned. + +Input + - ctx: A context to control lifecycle. +*/ +func (client *Szconfigmanager) GetSdkId(ctx context.Context) string { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(25, observer.GetObserverId(ctx)) - defer func() { client.traceExit(26, observer.GetObserverId(ctx), err, time.Since(entryTime)) }() - } - if client.observers == nil { - client.observers = &subject.SubjectImpl{} + client.traceEntry(29) + defer func() { client.traceExit(30, err, time.Since(entryTime)) }() } - err = client.observers.RegisterObserver(ctx, observer) if client.observers != nil { go func() { - details := map[string]string{ - "observerID": observer.GetObserverId(ctx), - } + details := map[string]string{} notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8010, err, details) }() } - return err + return "mock" } /* -The ReplaceDefaultConfigID method replaces the old configuration identifier with a new configuration identifier in the Senzing database. -It is like a "compare-and-swap" instruction to serialize concurrent editing of configuration. -If oldConfigID is no longer the "old configuration identifier", the operation will fail. -To simply set the default configuration ID, use SetDefaultConfigID(). +The Initialize method initializes the Senzing G2ConfigMgr object. +It must be called prior to any other calls. Input - ctx: A context to control lifecycle. - - oldConfigID: The configuration identifier to replace. - - newConfigID: The configuration identifier to use as the default. + - instanceName: A name for the auditing node, to help identify it within system logs. + - settings: A JSON string containing configuration parameters. + - verboseLogging: A flag to enable deeper logging of the G2 processing. 0 for no Senzing logging; 1 for logging. */ -func (client *G2configmgr) ReplaceDefaultConfigID(ctx context.Context, oldConfigID int64, newConfigID int64) error { +func (client *Szconfigmanager) Initialize(ctx context.Context, instanceName string, settings string, verboseLogging int64) error { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(19, oldConfigID, newConfigID) - defer func() { client.traceExit(20, oldConfigID, newConfigID, err, time.Since(entryTime)) }() + client.traceEntry(17, instanceName, settings, verboseLogging) + defer func() { client.traceExit(18, instanceName, settings, verboseLogging, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{ - "newConfigID": strconv.FormatInt(newConfigID, 10), + "instanceName": instanceName, + "settings": settings, + "verboseLogging": strconv.FormatInt(verboseLogging, 10), } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8007, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8006, err, details) }() } return err } /* -The SetDefaultConfigID method replaces the sets a new configuration identifier in the Senzing database. -To serialize modifying of the configuration identifier, see ReplaceDefaultConfigID(). +The RegisterObserver method adds the observer to the list of observers notified. Input - ctx: A context to control lifecycle. - - configID: The configuration identifier of the Senzing Engine configuration to use as the default. + - observer: The observer to be added. */ -func (client *G2configmgr) SetDefaultConfigID(ctx context.Context, configID int64) error { +func (client *Szconfigmanager) RegisterObserver(ctx context.Context, observer observer.Observer) error { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(21, configID) - defer func() { client.traceExit(22, configID, err, time.Since(entryTime)) }() + client.traceEntry(25, observer.GetObserverId(ctx)) + defer func() { client.traceExit(26, observer.GetObserverId(ctx), err, time.Since(entryTime)) }() } + if client.observers == nil { + client.observers = &subject.SubjectImpl{} + } + err = client.observers.RegisterObserver(ctx, observer) if client.observers != nil { go func() { details := map[string]string{ - "configID": strconv.FormatInt(configID, 10), + "observerId": observer.GetObserverId(ctx), } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8008, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8010, err, details) }() } return err @@ -355,9 +322,9 @@ The SetLogLevel method sets the level of logging. Input - ctx: A context to control lifecycle. - - logLevel: The desired log level. TRACE, DEBUG, INFO, WARN, ERROR, FATAL or PANIC. + - logLevelName: The desired log level. TRACE, DEBUG, INFO, WARN, ERROR, FATAL or PANIC. */ -func (client *G2configmgr) SetLogLevel(ctx context.Context, logLevelName string) error { +func (client *Szconfigmanager) SetLogLevel(ctx context.Context, logLevelName string) error { var err error = nil if client.isTrace { entryTime := time.Now() @@ -369,7 +336,7 @@ func (client *G2configmgr) SetLogLevel(ctx context.Context, logLevelName string) if client.observers != nil { go func() { details := map[string]string{ - "logLevel": logLevelName, + "logLevelName": logLevelName, } notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8011, err, details) }() @@ -384,7 +351,7 @@ Input - ctx: A context to control lifecycle. - origin: The value sent in the Observer's "origin" key/value pair. */ -func (client *G2configmgr) SetObserverOrigin(ctx context.Context, origin string) { +func (client *Szconfigmanager) SetObserverOrigin(ctx context.Context, origin string) { client.observerOrigin = origin } @@ -395,7 +362,7 @@ Input - ctx: A context to control lifecycle. - observer: The observer to be added. */ -func (client *G2configmgr) UnregisterObserver(ctx context.Context, observer observer.Observer) error { +func (client *Szconfigmanager) UnregisterObserver(ctx context.Context, observer observer.Observer) error { var err error = nil if client.isTrace { entryTime := time.Now() @@ -408,7 +375,7 @@ func (client *G2configmgr) UnregisterObserver(ctx context.Context, observer obse // In client.notify, each observer will get notified in a goroutine. // Then client.observers may be set to nil, but observer goroutines will be OK. details := map[string]string{ - "observerID": observer.GetObserverId(ctx), + "observerId": observer.GetObserverId(ctx), } notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8012, err, details) } @@ -418,3 +385,34 @@ func (client *G2configmgr) UnregisterObserver(ctx context.Context, observer obse } return err } + +// ---------------------------------------------------------------------------- +// Internal methods +// ---------------------------------------------------------------------------- + +// --- Logging ---------------------------------------------------------------- + +// Get the Logger singleton. +func (client *Szconfigmanager) getLogger() logging.LoggingInterface { + var err error = nil + if client.logger == nil { + options := []interface{}{ + &logging.OptionCallerSkip{Value: 4}, + } + client.logger, err = logging.NewSenzingSdkLogger(ComponentId, szconfigmanager.IdMessages, options...) + if err != nil { + panic(err) + } + } + return client.logger +} + +// Trace method entry. +func (client *Szconfigmanager) traceEntry(errorNumber int, details ...interface{}) { + client.getLogger().Log(errorNumber, details...) +} + +// Trace method exit. +func (client *Szconfigmanager) traceExit(errorNumber int, details ...interface{}) { + client.getLogger().Log(errorNumber, details...) +} diff --git a/szconfigmanager/szconfigmanager_examples_test.go b/szconfigmanager/szconfigmanager_examples_test.go new file mode 100644 index 0000000..dbc8d60 --- /dev/null +++ b/szconfigmanager/szconfigmanager_examples_test.go @@ -0,0 +1,191 @@ +//go:build linux + +package szconfigmanager + +import ( + "context" + "fmt" + + "github.com/senzing-garage/go-logging/logging" + "github.com/senzing-garage/sz-sdk-go/sz" +) + +// ---------------------------------------------------------------------------- +// Interface functions - Examples for godoc documentation +// ---------------------------------------------------------------------------- + +func ExampleSzconfigmanager_AddConfig() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szconfigmanager/szconfigmanager_examples_test.go + ctx := context.TODO() + szConfig := getSzConfig(ctx) + configHandle, err := szConfig.CreateConfig(ctx) + if err != nil { + text := err.Error() + fmt.Println(text[len(text)-40:]) + } + configDefinition, err := szConfig.ExportConfig(ctx, configHandle) + if err != nil { + text := err.Error() + fmt.Println(text[len(text)-40:]) + } + szConfigManager := getSzConfigManager(ctx) + configComment := "Example configuration" + configId, err := szConfigManager.AddConfig(ctx, configDefinition, configComment) + if err != nil { + text := err.Error() + fmt.Println(text[len(text)-40:]) + } + fmt.Println(configId > 0) // Dummy output. + // Output: true +} + +func ExampleSzconfigmanager_GetConfig() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szconfigmanager/szconfigmanager_examples_test.go + ctx := context.TODO() + szConfigManager := getSzConfigManager(ctx) + configId, err := szConfigManager.GetDefaultConfigId(ctx) + if err != nil { + fmt.Println(err) + } + configDefinition, err := szConfigManager.GetConfig(ctx, configId) + if err != nil { + fmt.Println(err) + } + fmt.Println(truncate(configDefinition, defaultTruncation)) + // Output: {"G2_CONFIG":{"CFG_ATTR":[{"ATTR_ID":1001,"ATTR_CODE":"DATA_SOURCE","ATTR... +} + +func ExampleSzconfigmanager_GetConfigList() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szconfigmanager/szconfigmanager_examples_test.go + ctx := context.TODO() + szConfigManager := getSzConfigManager(ctx) + configList, err := szConfigManager.GetConfigList(ctx) + if err != nil { + fmt.Println(err) + } + fmt.Println(truncate(configList, 28)) + // Output: {"CONFIGS":[{"CONFIG_ID":... +} + +func ExampleSzconfigmanager_GetDefaultConfigId() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szconfigmanager/szconfigmanager_examples_test.go + ctx := context.TODO() + szConfigManager := getSzConfigManager(ctx) + configId, err := szConfigManager.GetDefaultConfigId(ctx) + if err != nil { + fmt.Println(err) + } + fmt.Println(configId > 0) // Dummy output. + // Output: true +} + +func ExampleSzconfigmanager_ReplaceDefaultConfigId() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szconfigmanager/szconfigmanager_examples_test.go + ctx := context.TODO() + szConfig := getSzConfig(ctx) + configHandle, err := szConfig.CreateConfig(ctx) + if err != nil { + fmt.Println(err) + } + configDefinition, err := szConfig.ExportConfig(ctx, configHandle) + if err != nil { + fmt.Println(err) + } + szConfigManager := getSzConfigManager(ctx) + currentDefaultConfigId, err := szConfigManager.GetDefaultConfigId(ctx) + if err != nil { + fmt.Println(err) + } + configComment := "Example configuration" + newDefaultConfigId, err := szConfigManager.AddConfig(ctx, configDefinition, configComment) + if err != nil { + fmt.Println(err) + } + err = szConfigManager.ReplaceDefaultConfigId(ctx, currentDefaultConfigId, newDefaultConfigId) + if err != nil { + fmt.Println(err) + } + // Output: +} + +func ExampleSzconfigmanager_SetDefaultConfigId() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szconfigmanager/szconfigmanager_examples_test.go + ctx := context.TODO() + szConfigManager := getSzConfigManager(ctx) + configId, err := szConfigManager.GetDefaultConfigId(ctx) // For example purposes only. Normally would use output from GetConfigList() + if err != nil { + fmt.Println(err) + } + err = szConfigManager.SetDefaultConfigId(ctx, configId) + if err != nil { + fmt.Println(err) + } + // Output: +} + +// ---------------------------------------------------------------------------- +// Logging and observing +// ---------------------------------------------------------------------------- + +func ExampleSzconfigmanager_SetLogLevel() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szconfigmanager/szconfigmanager_examples_test.go + ctx := context.TODO() + szConfigManager := getSzConfigManager(ctx) + err := szConfigManager.SetLogLevel(ctx, logging.LevelInfoName) + if err != nil { + fmt.Println(err) + } + // Output: +} + +func ExampleSzconfigmanager_SetObserverOrigin() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szconfigmanager/szconfigmanager_examples_test.go + ctx := context.TODO() + szConfigManager := getSzConfigManager(ctx) + origin := "Machine: nn; Task: UnitTest" + szConfigManager.SetObserverOrigin(ctx, origin) + // Output: +} + +func ExampleSzconfigmanager_GetObserverOrigin() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szconfigmanager/szconfigmanager_test.go + ctx := context.TODO() + szConfigManager := getSzConfigManager(ctx) + origin := "Machine: nn; Task: UnitTest" + szConfigManager.SetObserverOrigin(ctx, origin) + result := szConfigManager.GetObserverOrigin(ctx) + fmt.Println(result) + // Output: Machine: nn; Task: UnitTest +} + +// ---------------------------------------------------------------------------- +// Object creation / destruction +// ---------------------------------------------------------------------------- + +func ExampleSzconfigmanager_Initialize() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szconfigmanager/szconfigmanager_examples_test.go + ctx := context.TODO() + szConfigManager := &Szconfigmanager{} + instanceName := "Test name" + settings, err := getSettings() + if err != nil { + fmt.Println(err) + } + verboseLogging := sz.SZ_NO_LOGGING + err = szConfigManager.Initialize(ctx, instanceName, settings, verboseLogging) + if err != nil { + fmt.Println(err) + } + // Output: +} + +func ExampleSzconfigmanager_Destroy() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szconfigmanager/szconfigmanager_examples_test.go + ctx := context.TODO() + szConfigManager := getSzConfigManager(ctx) + err := szConfigManager.Destroy(ctx) + if err != nil { + fmt.Println(err) + } + // Output: +} diff --git a/szconfigmanager/szconfigmanager_test.go b/szconfigmanager/szconfigmanager_test.go new file mode 100644 index 0000000..96f113a --- /dev/null +++ b/szconfigmanager/szconfigmanager_test.go @@ -0,0 +1,271 @@ +package szconfigmanager + +import ( + "context" + "fmt" + "os" + "strconv" + "testing" + "time" + + truncator "github.com/aquilax/truncate" + "github.com/senzing-garage/sz-sdk-go-mock/szconfig" + "github.com/senzing-garage/sz-sdk-go/sz" + "github.com/senzing-garage/sz-sdk-go/szerror" + + "github.com/stretchr/testify/assert" +) + +const ( + defaultTruncation = 76 + printResults = false +) + +var ( + szConfigSingleton *szconfig.Szconfig + szConfigManagerSingleton *Szconfigmanager +) + +// ---------------------------------------------------------------------------- +// Interface functions - test +// ---------------------------------------------------------------------------- + +func TestSzconfigmanager_AddConfig(test *testing.T) { + ctx := context.TODO() + szConfigManager := getTestObject(ctx, test) + now := time.Now() + szConfig := getSzConfig(ctx) + configHandle, err1 := szConfig.CreateConfig(ctx) + if err1 != nil { + test.Log("Error:", err1.Error()) + assert.FailNow(test, "szConfig.CreateConfig()") + } + dataSourceCode := "GO_TEST_" + strconv.FormatInt(now.Unix(), 10) + _, err2 := szConfig.AddDataSource(ctx, configHandle, dataSourceCode) + if err2 != nil { + test.Log("Error:", err2.Error()) + assert.FailNow(test, "szConfig.AddDataSource()") + } + configDefinition, err3 := szConfig.ExportConfig(ctx, configHandle) + if err3 != nil { + test.Log("Error:", err2.Error()) + assert.FailNow(test, configDefinition) + } + configComment := fmt.Sprintf("szconfigmanager_test at %s", now.UTC()) + actual, err := szConfigManager.AddConfig(ctx, configDefinition, configComment) + testError(test, err) + printActual(test, actual) +} + +func TestSzconfigmanager_GetConfig(test *testing.T) { + ctx := context.TODO() + szConfigManager := getTestObject(ctx, test) + configId, err1 := szConfigManager.GetDefaultConfigId(ctx) + if err1 != nil { + test.Log("Error:", err1.Error()) + assert.FailNow(test, "szConfigManager.GetDefaultConfigId()") + } + actual, err := szConfigManager.GetConfig(ctx, configId) + testError(test, err) + printActual(test, actual) +} + +func TestSzconfigmanager_GetConfigList(test *testing.T) { + ctx := context.TODO() + szConfigManager := getTestObject(ctx, test) + actual, err := szConfigManager.GetConfigList(ctx) + testError(test, err) + printActual(test, actual) +} + +func TestSzconfigmanager_GetDefaultConfigId(test *testing.T) { + ctx := context.TODO() + szConfigManager := getTestObject(ctx, test) + actual, err := szConfigManager.GetDefaultConfigId(ctx) + testError(test, err) + printActual(test, actual) +} + +func TestSzconfigmanager_ReplaceDefaultConfigId(test *testing.T) { + ctx := context.TODO() + szConfigManager := getTestObject(ctx, test) + currentDefaultConfigId, err1 := szConfigManager.GetDefaultConfigId(ctx) + if err1 != nil { + test.Log("Error:", err1.Error()) + assert.FailNow(test, "szConfigManager.GetDefaultConfigId()") + } + + // TODO: This is kind of a cheater. + + newDefaultConfigId, err2 := szConfigManager.GetDefaultConfigId(ctx) + if err2 != nil { + test.Log("Error:", err2.Error()) + assert.FailNow(test, "szConfigManager.GetDefaultConfigId()-2") + } + + err := szConfigManager.ReplaceDefaultConfigId(ctx, currentDefaultConfigId, newDefaultConfigId) + testError(test, err) +} + +func TestSzconfigmanager_SetDefaultConfigId(test *testing.T) { + ctx := context.TODO() + szConfigManager := getTestObject(ctx, test) + configId, err1 := szConfigManager.GetDefaultConfigId(ctx) + if err1 != nil { + test.Log("Error:", err1.Error()) + assert.FailNow(test, "szConfigManager.GetDefaultConfigId()") + } + err := szConfigManager.SetDefaultConfigId(ctx, configId) + testError(test, err) +} + +// ---------------------------------------------------------------------------- +// Logging and observing +// ---------------------------------------------------------------------------- + +func TestSzconfigmanager_SetObserverOrigin(test *testing.T) { + ctx := context.TODO() + szConfigManager := getTestObject(ctx, test) + origin := "Machine: nn; Task: UnitTest" + szConfigManager.SetObserverOrigin(ctx, origin) +} + +func TestSzconfigmanager_GetObserverOrigin(test *testing.T) { + ctx := context.TODO() + szConfigManager := getTestObject(ctx, test) + origin := "Machine: nn; Task: UnitTest" + szConfigManager.SetObserverOrigin(ctx, origin) + actual := szConfigManager.GetObserverOrigin(ctx) + assert.Equal(test, origin, actual) +} + +// ---------------------------------------------------------------------------- +// Object creation / destruction +// ---------------------------------------------------------------------------- + +func TestSzconfigmanager_AsInterface(test *testing.T) { + ctx := context.TODO() + szConfigManager := getSzConfigManagerAsInterface(ctx) + actual, err := szConfigManager.GetConfigList(ctx) + testError(test, err) + printActual(test, actual) +} + +func TestSzconfigmanager_Initialize(test *testing.T) { + ctx := context.TODO() + szConfigManager := getTestObject(ctx, test) + instanceName := "Test name" + verboseLogging := sz.SZ_NO_LOGGING + settings, err := getSettings() + testError(test, err) + err = szConfigManager.Initialize(ctx, instanceName, settings, verboseLogging) + testError(test, err) +} + +func TestSzconfigmanager_Destroy(test *testing.T) { + ctx := context.TODO() + szConfigManager := getTestObject(ctx, test) + err := szConfigManager.Destroy(ctx) + testError(test, err) +} + +// ---------------------------------------------------------------------------- +// Internal functions +// ---------------------------------------------------------------------------- + +func getSettings() (string, error) { + return "{}", nil +} + +func getSzConfig(ctx context.Context) *szconfig.Szconfig { + _ = ctx + if szConfigSingleton == nil { + szConfigSingleton = &szconfig.Szconfig{ + AddDataSourceResult: `{"DSRC_ID":1001}`, + CreateConfigResult: 1, + GetDataSourcesResult: `{"DATA_SOURCES":[{"DSRC_ID":1,"DSRC_CODE":"TEST"},{"DSRC_ID":2,"DSRC_CODE":"SEARCH"}]}`, + ExportConfigResult: `{"G2_CONFIG":{"CFG_ATTR":[{"ATTR_ID":1001,"ATTR_CODE":"DATA_SOURCE","ATTR_CLASS":"OBSERVATION","FTYPE_CODE":null,"FELEM_CODE":null,"FELEM_REQ":"Yes","DEFAULT_VALUE":null,"ADVANCED":"Yes","INTERNAL":"No"},{"ATTR_ID":1002,"ATTR_CODE":"ROUTE_CODE",`, + } + } + return szConfigSingleton +} + +func getSzConfigManager(ctx context.Context) *Szconfigmanager { + _ = ctx + if szConfigManagerSingleton == nil { + szConfigManagerSingleton = &Szconfigmanager{ + AddConfigResult: 1, + GetConfigResult: `{"G2_CONFIG":{"CFG_ATTR":[{"ATTR_ID":1001,"ATTR_CODE":"DATA_SOURCE","ATTR_CLASS":"OBSERVATION","FTYPE_CODE":null,"FELEM_CODE":null,"FELEM_REQ":"Yes","DEFAULT_VALUE":null,"ADVANCED":"Yes","INTERNAL":"No"},{"ATTR_ID":1002,"ATTR_CODE":"ROUTE_CODE","ATTR_CLASS":"OBSERVATION","FTYPE_CODE":null,"FELEM_CODE":null,"FELEM_REQ":"No","DEFAULT_VALUE":null,"ADVANCED":"Yes","INTERNAL":"No"},{"ATTR_ID":1003,"ATTR_CODE":"RECORD_ID","ATTR_CLASS":"OBSERVATION","FTYPE_CODE":null,"FELEM_CODE":null,"FELEM_REQ":"No","DEFAULT_VALUE":null,"ADVANCED":"No","INTERNAL":"No"},{"ATTR_ID":1004,"ATTR_CODE":"ENTITY_TYPE","ATTR_CLASS":"OBSERVATION","FTYPE_CODE":null,`, + GetConfigListResult: `{"CONFIGS":[{"CONFIG_ID":41320074,"CONFIG_COMMENTS":"Example configuration","SYS_CREATE_DT":"2023-02-16 21:43:10.171"},{"CONFIG_ID":1111755672,"CONFIG_COMMENTS":"g2configmgr_test at 2023-02-16 21:43:10.154619801 +0000 UTC","SYS_CREATE_DT":"2023-02-16 21:43:10.159"},{"CONFIG_ID":3680541328,"CONFIG_COMMENTS":"Created by g2diagnostic_test at 2023-02-16 21:43:07.294747409 +0000 UTC","SYS_CREATE_DT":"2023-02-16 21:43:07.755"}]}`, + GetDefaultConfigIdResult: 1, + } + } + return szConfigManagerSingleton +} + +func getSzConfigManagerAsInterface(ctx context.Context) sz.SzConfigManager { + return getSzConfigManager(ctx) +} + +func getTestObject(ctx context.Context, test *testing.T) *Szconfigmanager { + _ = test + return getSzConfigManager(ctx) +} + +func printActual(test *testing.T, actual interface{}) { + printResult(test, "Actual", actual) +} + +func printResult(test *testing.T, title string, result interface{}) { + if printResults { + test.Logf("%s: %v", title, truncate(fmt.Sprintf("%v", result), defaultTruncation)) + } +} + +func testError(test *testing.T, err error) { + if err != nil { + test.Log("Error:", err.Error()) + assert.FailNow(test, err.Error()) + } +} + +func truncate(aString string, length int) string { + return truncator.Truncate(aString, length, "...", truncator.PositionEnd) +} + +// ---------------------------------------------------------------------------- +// Test harness +// ---------------------------------------------------------------------------- + +func TestMain(m *testing.M) { + err := setup() + if err != nil { + if szerror.Is(err, szerror.SzUnrecoverable) { + fmt.Printf("\nUnrecoverable error detected. \n\n") + } + if szerror.Is(err, szerror.SzRetryable) { + fmt.Printf("\nRetryable error detected. \n\n") + } + if szerror.Is(err, szerror.SzBadInput) { + fmt.Printf("\nBad user input error detected. \n\n") + } + fmt.Print(err) + os.Exit(1) + } + code := m.Run() + err = teardown() + if err != nil { + fmt.Print(err) + } + os.Exit(code) +} + +func setup() error { + var err error = nil + return err +} + +func teardown() error { + var err error = nil + return err +} diff --git a/szdiagnostic/doc.go b/szdiagnostic/doc.go new file mode 100644 index 0000000..af394a8 --- /dev/null +++ b/szdiagnostic/doc.go @@ -0,0 +1,4 @@ +/* +The szdiagnostic package is used make SzDiagnostic requests to a mock object. +*/ +package szdiagnostic diff --git a/g2diagnostic/main.go b/szdiagnostic/main.go similarity index 73% rename from g2diagnostic/main.go rename to szdiagnostic/main.go index 83d404b..2255b1c 100644 --- a/g2diagnostic/main.go +++ b/szdiagnostic/main.go @@ -1,8 +1,8 @@ -package g2diagnostic +package szdiagnostic // ---------------------------------------------------------------------------- // Constants // ---------------------------------------------------------------------------- -// Identfier of the g2diagnostic package found messages having the format "senzing-6033xxxx". +// Identfier of the szdiagnostic package found messages having the format "senzing-6033xxxx". const ComponentId = 6033 diff --git a/g2diagnostic/g2diagnostic.go b/szdiagnostic/szdiagnostic.go similarity index 63% rename from g2diagnostic/g2diagnostic.go rename to szdiagnostic/szdiagnostic.go index 859389e..730cbd7 100644 --- a/g2diagnostic/g2diagnostic.go +++ b/szdiagnostic/szdiagnostic.go @@ -1,71 +1,36 @@ /* - * - */ +Package szdiagnostic implements a client for the service. +*/ -// Package main implements a client for the service. -package g2diagnostic +package szdiagnostic import ( "context" "strconv" "time" - g2diagnosticapi "github.com/senzing-garage/g2-sdk-go/g2diagnostic" "github.com/senzing-garage/go-logging/logging" "github.com/senzing-garage/go-observing/notifier" "github.com/senzing-garage/go-observing/observer" "github.com/senzing-garage/go-observing/subject" + szdiagnosticapi "github.com/senzing-garage/sz-sdk-go/szdiagnostic" ) -// ---------------------------------------------------------------------------- -// Types -// ---------------------------------------------------------------------------- - -type G2diagnostic struct { - CheckDBPerfResult string - isTrace bool - logger logging.LoggingInterface - observerOrigin string - observers subject.Subject -} - -// ---------------------------------------------------------------------------- -// Internal methods -// ---------------------------------------------------------------------------- - -// --- Logging ---------------------------------------------------------------- - -// Get the Logger singleton. -func (client *G2diagnostic) getLogger() logging.LoggingInterface { - var err error = nil - if client.logger == nil { - options := []interface{}{ - &logging.OptionCallerSkip{Value: 4}, - } - client.logger, err = logging.NewSenzingSdkLogger(ComponentId, g2diagnosticapi.IdMessages, options...) - if err != nil { - panic(err) - } - } - return client.logger -} - -// Trace method entry. -func (client *G2diagnostic) traceEntry(errorNumber int, details ...interface{}) { - client.getLogger().Log(errorNumber, details...) -} - -// Trace method exit. -func (client *G2diagnostic) traceExit(errorNumber int, details ...interface{}) { - client.getLogger().Log(errorNumber, details...) +type Szdiagnostic struct { + CheckDatastorePerformanceResult string + GetDatastoreInfoResult string + isTrace bool + logger logging.LoggingInterface + observerOrigin string + observers subject.Subject } // ---------------------------------------------------------------------------- -// Interface methods +// sz-sdk-go.SzDiagnostic interface methods // ---------------------------------------------------------------------------- /* -The CheckDBPerf method performs inserts to determine rate of insertion. +The CheckDatastorePerformance method performs inserts to determine rate of insertion. Input - ctx: A context to control lifecycle. @@ -76,12 +41,14 @@ Output - A string containing a JSON document. Example: `{"numRecordsInserted":0,"insertTime":0}` */ -func (client *G2diagnostic) CheckDBPerf(ctx context.Context, secondsToRun int) (string, error) { +func (client *Szdiagnostic) CheckDatastorePerformance(ctx context.Context, secondsToRun int) (string, error) { var err error = nil if client.isTrace { entryTime := time.Now() client.traceEntry(1, secondsToRun) - defer func() { client.traceExit(2, secondsToRun, client.CheckDBPerfResult, err, time.Since(entryTime)) }() + defer func() { + client.traceExit(2, secondsToRun, client.CheckDatastorePerformanceResult, err, time.Since(entryTime)) + }() } if client.observers != nil { go func() { @@ -89,7 +56,7 @@ func (client *G2diagnostic) CheckDBPerf(ctx context.Context, secondsToRun int) ( notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8001, err, details) }() } - return client.CheckDBPerfResult, err + return client.CheckDatastorePerformanceResult, err } /* @@ -99,7 +66,7 @@ It should be called after all other calls are complete. Input - ctx: A context to control lifecycle. */ -func (client *G2diagnostic) Destroy(ctx context.Context) error { +func (client *Szdiagnostic) Destroy(ctx context.Context) error { var err error = nil if client.isTrace { entryTime := time.Now() @@ -116,155 +83,178 @@ func (client *G2diagnostic) Destroy(ctx context.Context) error { } /* -The GetObserverOrigin method returns the "origin" value of past Observer messages. +The GetDatastoreInfo method performs inserts to determine rate of insertion. Input - ctx: A context to control lifecycle. Output - - The value sent in the Observer's "origin" key/value pair. + + - A string containing a JSON document. */ -func (client *G2diagnostic) GetObserverOrigin(ctx context.Context) string { - return client.observerOrigin +func (client *Szdiagnostic) GetDatastoreInfo(ctx context.Context) (string, error) { + var err error = nil + if client.isTrace { + entryTime := time.Now() + client.traceEntry(1) + defer func() { + client.traceExit(2, client.GetDatastoreInfoResult, err, time.Since(entryTime)) + }() + } + if client.observers != nil { + go func() { + details := map[string]string{} + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8001, err, details) + }() + } + return client.GetDatastoreInfoResult, err } /* -The GetSdkId method returns the identifier of this particular Software Development Kit (SDK). -It is handy when working with multiple implementations of the same G2diagnosticInterface. -For this implementation, "mock" is returned. - +The PurgeRepository method removes every record in the Senzing repository. +Before calling purgeRepository() all other instances of the Senzing API +(whether in custom code, REST API, stream-loader, redoer, G2Loader, etc) +MUST be destroyed or shutdown. Input - ctx: A context to control lifecycle. */ -func (client *G2diagnostic) GetSdkId(ctx context.Context) string { +func (client *Szdiagnostic) PurgeRepository(ctx context.Context) error { var err error = nil + entryTime := time.Now() if client.isTrace { - entryTime := time.Now() - client.traceEntry(59) - defer func() { client.traceExit(60, err, time.Since(entryTime)) }() + client.traceEntry(117) + defer func() { client.traceExit(118, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{} - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8024, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8056, err, details) }() } - return "mock" + return err } /* -The Init method initializes the Senzing G2Diagnosis object. -It must be called prior to any other calls. +The Reinitialize method re-initializes the Senzing G2Diagnostic object. Input - ctx: A context to control lifecycle. - - moduleName: A name for the auditing node, to help identify it within system logs. - - iniParams: A JSON string containing configuration parameters. - - verboseLogging: A flag to enable deeper logging of the G2 processing. 0 for no Senzing logging; 1 for logging. + - configId: The configuration ID used for the initialization. */ -func (client *G2diagnostic) Init(ctx context.Context, moduleName string, iniParams string, verboseLogging int64) error { +func (client *Szdiagnostic) Reinitialize(ctx context.Context, configId int64) error { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(47, moduleName, iniParams, verboseLogging) - defer func() { client.traceExit(48, moduleName, iniParams, verboseLogging, err, time.Since(entryTime)) }() + client.traceEntry(51, configId) + defer func() { client.traceExit(52, configId, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{ - "iniParams": iniParams, - "moduleName": moduleName, - "verboseLogging": strconv.FormatInt(verboseLogging, 10), + "configId": strconv.FormatInt(configId, 10), } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8021, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8023, err, details) }() } return err } +// ---------------------------------------------------------------------------- +// Public non-interface methods +// ---------------------------------------------------------------------------- + /* -The InitWithConfigID method initializes the Senzing G2Diagnosis object with a non-default configuration ID. -It must be called prior to any other calls. +The GetObserverOrigin method returns the "origin" value of past Observer messages. + +Input + - ctx: A context to control lifecycle. + +Output + - The value sent in the Observer's "origin" key/value pair. +*/ +func (client *Szdiagnostic) GetObserverOrigin(ctx context.Context) string { + return client.observerOrigin +} + +/* +The GetSdkId method returns the identifier of this particular Software Development Kit (SDK). +It is handy when working with multiple implementations of the same SzDiagnostic interface. +For this implementation, "mock" is returned. Input - ctx: A context to control lifecycle. - - moduleName: A name for the auditing node, to help identify it within system logs. - - iniParams: A JSON string containing configuration parameters. - - initConfigID: The configuration ID used for the initialization. - - verboseLogging: A flag to enable deeper logging of the G2 processing. 0 for no Senzing logging; 1 for logging. */ -func (client *G2diagnostic) InitWithConfigID(ctx context.Context, moduleName string, iniParams string, initConfigID int64, verboseLogging int64) error { +func (client *Szdiagnostic) GetSdkId(ctx context.Context) string { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(49, moduleName, iniParams, initConfigID, verboseLogging) - defer func() { - client.traceExit(50, moduleName, iniParams, initConfigID, verboseLogging, err, time.Since(entryTime)) - }() + client.traceEntry(59) + defer func() { client.traceExit(60, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { - details := map[string]string{ - "iniParams": iniParams, - "initConfigID": strconv.FormatInt(initConfigID, 10), - "moduleName": moduleName, - "verboseLogging": strconv.FormatInt(verboseLogging, 10), - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8022, err, details) + details := map[string]string{} + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8024, err, details) }() } - return err + return "mock" } /* -The RegisterObserver method adds the observer to the list of observers notified. +The Initialize method initializes the Senzing G2Diagnostic object. +It must be called prior to any other calls. Input - ctx: A context to control lifecycle. - - observer: The observer to be added. + - instanceName: A name for the auditing node, to help identify it within system logs. + - settings: A JSON string containing configuration parameters. + - configId: The configuration ID used for the initialization. 0 for current default configuration. + - verboseLogging: A flag to enable deeper logging of the G2 processing. 0 for no Senzing logging; 1 for logging. */ -func (client *G2diagnostic) RegisterObserver(ctx context.Context, observer observer.Observer) error { +func (client *Szdiagnostic) Initialize(ctx context.Context, instanceName string, settings string, configId int64, verboseLogging int64) error { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(55, observer.GetObserverId(ctx)) - defer func() { client.traceExit(56, observer.GetObserverId(ctx), err, time.Since(entryTime)) }() + client.traceEntry(47, instanceName, settings, verboseLogging) + defer func() { client.traceExit(48, instanceName, settings, verboseLogging, err, time.Since(entryTime)) }() } - if client.observers == nil { - client.observers = &subject.SubjectImpl{} - } - err = client.observers.RegisterObserver(ctx, observer) if client.observers != nil { go func() { details := map[string]string{ - "observerID": observer.GetObserverId(ctx), + "settings": settings, + "instanceName": instanceName, + "verboseLogging": strconv.FormatInt(verboseLogging, 10), } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8025, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8021, err, details) }() } return err } /* -The Reinit method re-initializes the Senzing G2Diagnosis object. +The RegisterObserver method adds the observer to the list of observers notified. Input - ctx: A context to control lifecycle. - - initConfigID: The configuration ID used for the initialization. + - observer: The observer to be added. */ -func (client *G2diagnostic) Reinit(ctx context.Context, initConfigID int64) error { +func (client *Szdiagnostic) RegisterObserver(ctx context.Context, observer observer.Observer) error { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(51, initConfigID) - defer func() { client.traceExit(52, initConfigID, err, time.Since(entryTime)) }() + client.traceEntry(55, observer.GetObserverId(ctx)) + defer func() { client.traceExit(56, observer.GetObserverId(ctx), err, time.Since(entryTime)) }() } + if client.observers == nil { + client.observers = &subject.SubjectImpl{} + } + err = client.observers.RegisterObserver(ctx, observer) if client.observers != nil { go func() { details := map[string]string{ - "initConfigID": strconv.FormatInt(initConfigID, 10), + "observerId": observer.GetObserverId(ctx), } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8023, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8025, err, details) }() } return err @@ -275,9 +265,9 @@ The SetLogLevel method sets the level of logging. Input - ctx: A context to control lifecycle. - - logLevel: The desired log level. TRACE, DEBUG, INFO, WARN, ERROR, FATAL or PANIC. + - logLevelName: The desired log level. TRACE, DEBUG, INFO, WARN, ERROR, FATAL or PANIC. */ -func (client *G2diagnostic) SetLogLevel(ctx context.Context, logLevelName string) error { +func (client *Szdiagnostic) SetLogLevel(ctx context.Context, logLevelName string) error { var err error = nil if client.isTrace { entryTime := time.Now() @@ -304,7 +294,7 @@ Input - ctx: A context to control lifecycle. - origin: The value sent in the Observer's "origin" key/value pair. */ -func (client *G2diagnostic) SetObserverOrigin(ctx context.Context, origin string) { +func (client *Szdiagnostic) SetObserverOrigin(ctx context.Context, origin string) { client.observerOrigin = origin } @@ -315,7 +305,7 @@ Input - ctx: A context to control lifecycle. - observer: The observer to be added. */ -func (client *G2diagnostic) UnregisterObserver(ctx context.Context, observer observer.Observer) error { +func (client *Szdiagnostic) UnregisterObserver(ctx context.Context, observer observer.Observer) error { var err error = nil if client.isTrace { entryTime := time.Now() @@ -328,7 +318,7 @@ func (client *G2diagnostic) UnregisterObserver(ctx context.Context, observer obs // In client.notify, each observer will get notified in a goroutine. // Then client.observers may be set to nil, but observer goroutines will be OK. details := map[string]string{ - "observerID": observer.GetObserverId(ctx), + "observerId": observer.GetObserverId(ctx), } notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8027, err, details) } @@ -338,3 +328,34 @@ func (client *G2diagnostic) UnregisterObserver(ctx context.Context, observer obs } return err } + +// ---------------------------------------------------------------------------- +// Internal methods +// ---------------------------------------------------------------------------- + +// --- Logging ---------------------------------------------------------------- + +// Get the Logger singleton. +func (client *Szdiagnostic) getLogger() logging.LoggingInterface { + var err error = nil + if client.logger == nil { + options := []interface{}{ + &logging.OptionCallerSkip{Value: 4}, + } + client.logger, err = logging.NewSenzingSdkLogger(ComponentId, szdiagnosticapi.IdMessages, options...) + if err != nil { + panic(err) + } + } + return client.logger +} + +// Trace method entry. +func (client *Szdiagnostic) traceEntry(errorNumber int, details ...interface{}) { + client.getLogger().Log(errorNumber, details...) +} + +// Trace method exit. +func (client *Szdiagnostic) traceExit(errorNumber int, details ...interface{}) { + client.getLogger().Log(errorNumber, details...) +} diff --git a/szdiagnostic/szdiagnostic_examples_test.go b/szdiagnostic/szdiagnostic_examples_test.go new file mode 100644 index 0000000..eed024c --- /dev/null +++ b/szdiagnostic/szdiagnostic_examples_test.go @@ -0,0 +1,131 @@ +//go:build linux + +package szdiagnostic + +import ( + "context" + "fmt" + + "github.com/senzing-garage/go-logging/logging" + "github.com/senzing-garage/sz-sdk-go/sz" +) + +// ---------------------------------------------------------------------------- +// Interface functions - Examples for godoc documentation +// ---------------------------------------------------------------------------- + +func ExampleSzdiagnostic_CheckDatastorePerformance() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szdiagnostic/szdiagnostic_examples_test.go + ctx := context.TODO() + szDiagnostic := getSzDiagnostic(ctx) + secondsToRun := 1 + result, err := szDiagnostic.CheckDatastorePerformance(ctx, secondsToRun) + if err != nil { + fmt.Println(err) + } + fmt.Println(truncate(result, 25)) + // Output: {"numRecordsInserted":... +} + +func ExampleSzdiagnostic_GetDatastoreInfo() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szdiagnostic/szdiagnostic_examples_test.go + ctx := context.TODO() + szDiagnostic := getSzDiagnostic(ctx) + result, err := szDiagnostic.GetDatastoreInfo(ctx) + if err != nil { + fmt.Println(err) + } + fmt.Println(result) + // Output: +} + +func ExampleSzdiagnostic_PurgeRepository() { + // For more information, visit https://github.com/Senzing/sz-sdk-go-mock/blob/main/szdiagnostic/szdiagnostic_examples_test.go + ctx := context.TODO() + szDiagnostic := getSzDiagnostic(ctx) + err := szDiagnostic.PurgeRepository(ctx) + if err != nil { + fmt.Println(err) + } + // Output: +} + +// ---------------------------------------------------------------------------- +// Logging and observing +// ---------------------------------------------------------------------------- + +func ExampleSzdiagnostic_SetLogLevel() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szdiagnostic/szdiagnostic_examples_test.go + ctx := context.TODO() + szDiagnostic := getSzDiagnostic(ctx) + err := szDiagnostic.SetLogLevel(ctx, logging.LevelInfoName) + if err != nil { + fmt.Println(err) + } + // Output: +} + +func ExampleSzdiagnostic_SetObserverOrigin() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szdiagnostic/szdiagnostic_examples_test.go + ctx := context.TODO() + szDiagnostic := getSzDiagnostic(ctx) + origin := "Machine: nn; Task: UnitTest" + szDiagnostic.SetObserverOrigin(ctx, origin) + // Output: +} + +func ExampleSzdiagnostic_GetObserverOrigin() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szdiagnostic/szdiagnostic_examples_test.go + ctx := context.TODO() + szDiagnostic := getSzDiagnostic(ctx) + origin := "Machine: nn; Task: UnitTest" + szDiagnostic.SetObserverOrigin(ctx, origin) + result := szDiagnostic.GetObserverOrigin(ctx) + fmt.Println(result) + // Output: Machine: nn; Task: UnitTest +} + +// ---------------------------------------------------------------------------- +// Object creation / destruction +// ---------------------------------------------------------------------------- + +func ExampleSzdiagnostic_Initialize() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szdiagnostic/szdiagnostic_examples_test.go + ctx := context.TODO() + szDiagnostic := &Szdiagnostic{} + instanceName := "Test name" + settings, err := getSettings() + if err != nil { + fmt.Println(err) + } + verboseLogging := sz.SZ_NO_LOGGING + configId := sz.SZ_INITIALIZE_WITH_DEFAULT_CONFIGURATION + err = szDiagnostic.Initialize(ctx, instanceName, settings, configId, verboseLogging) + if err != nil { + fmt.Println(err) + } + // Output: +} + +func ExampleSzdiagnostic_Reinitialize() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szdiagnostic/szdiagnostic_examples_test.go + ctx := context.TODO() + szDiagnostic := getSzDiagnostic(ctx) + configId := getDefaultConfigId() + err := szDiagnostic.Reinitialize(ctx, configId) + if err != nil { + fmt.Println(err) + } + // Output: +} + +func ExampleSzdiagnostic_Destroy() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szdiagnostic/szdiagnostic_examples_test.go + ctx := context.TODO() + szDiagnostic := getSzDiagnostic(ctx) + err := szDiagnostic.Destroy(ctx) + if err != nil { + fmt.Println(err) + } + // Output: +} diff --git a/szdiagnostic/szdiagnostic_test.go b/szdiagnostic/szdiagnostic_test.go new file mode 100644 index 0000000..58214ab --- /dev/null +++ b/szdiagnostic/szdiagnostic_test.go @@ -0,0 +1,218 @@ +package szdiagnostic + +import ( + "context" + "fmt" + "os" + "testing" + + truncator "github.com/aquilax/truncate" + "github.com/senzing-garage/sz-sdk-go/sz" + "github.com/senzing-garage/sz-sdk-go/szerror" + "github.com/stretchr/testify/assert" +) + +const ( + defaultTruncation = 76 + printResults = false +) + +var ( + szDiagnosticSingleton *Szdiagnostic +) + +// ---------------------------------------------------------------------------- +// Interface functions - test +// ---------------------------------------------------------------------------- + +func TestSzdiagnostic_CheckDatastorePerformance(test *testing.T) { + ctx := context.TODO() + szDiagnostic := getTestObject(ctx, test) + secondsToRun := 1 + actual, err := szDiagnostic.CheckDatastorePerformance(ctx, secondsToRun) + testError(test, err) + printActual(test, actual) +} + +func TestSzdiagnostic_GetDatastoreInfo(test *testing.T) { + ctx := context.TODO() + szDiagnostic := getTestObject(ctx, test) + actual, err := szDiagnostic.GetDatastoreInfo(ctx) + testError(test, err) + printActual(test, actual) +} + +func TestSzdiagnostic_PurgeRepository(test *testing.T) { + ctx := context.TODO() + szDiagnostic := getTestObject(ctx, test) + err := szDiagnostic.PurgeRepository(ctx) + testError(test, err) +} + +// ---------------------------------------------------------------------------- +// Logging and observing +// ---------------------------------------------------------------------------- + +func TestSzdiagnostic_SetObserverOrigin(test *testing.T) { + ctx := context.TODO() + szDiagnostic := getTestObject(ctx, test) + origin := "Machine: nn; Task: UnitTest" + szDiagnostic.SetObserverOrigin(ctx, origin) +} + +func TestSzdiagnostic_GetObserverOrigin(test *testing.T) { + ctx := context.TODO() + szDiagnostic := getTestObject(ctx, test) + origin := "Machine: nn; Task: UnitTest" + szDiagnostic.SetObserverOrigin(ctx, origin) + actual := szDiagnostic.GetObserverOrigin(ctx) + assert.Equal(test, origin, actual) +} + +// ---------------------------------------------------------------------------- +// Object creation / destruction +// ---------------------------------------------------------------------------- + +func TestSzdiagnostic_AsInterface(test *testing.T) { + ctx := context.TODO() + szDiagnostic := getSzDiagnosticAsInterface(ctx) + secondsToRun := 1 + actual, err := szDiagnostic.CheckDatastorePerformance(ctx, secondsToRun) + testError(test, err) + printActual(test, actual) +} + +func TestSzdiagnostic_Initialize(test *testing.T) { + ctx := context.TODO() + szDiagnostic := &Szdiagnostic{} + instanceName := "Test name" + settings, err := getSettings() + testError(test, err) + verboseLogging := sz.SZ_NO_LOGGING + configId := sz.SZ_INITIALIZE_WITH_DEFAULT_CONFIGURATION + err = szDiagnostic.Initialize(ctx, instanceName, settings, configId, verboseLogging) + testError(test, err) +} + +func TestSzdiagnostic_Initialize_withConfigId(test *testing.T) { + ctx := context.TODO() + szDiagnostic := &Szdiagnostic{} + instanceName := "Test name" + settings, err := getSettings() + testError(test, err) + verboseLogging := sz.SZ_NO_LOGGING + configId := getDefaultConfigId() + err = szDiagnostic.Initialize(ctx, instanceName, settings, configId, verboseLogging) + testError(test, err) +} + +func TestSzdiagnostic_Reinitialize(test *testing.T) { + ctx := context.TODO() + szDiagnostic := getTestObject(ctx, test) + configId := getDefaultConfigId() + err := szDiagnostic.Reinitialize(ctx, configId) + testErrorNoFail(test, err) +} + +func TestSzdiagnostic_Destroy(test *testing.T) { + ctx := context.TODO() + szDiagnostic := getTestObject(ctx, test) + err := szDiagnostic.Destroy(ctx) + testError(test, err) + szDiagnosticSingleton = nil +} + +// ---------------------------------------------------------------------------- +// Internal functions +// ---------------------------------------------------------------------------- + +func getDefaultConfigId() int64 { + return int64(1) +} + +func getSettings() (string, error) { + return "{}", nil +} + +func getSzDiagnostic(ctx context.Context) *Szdiagnostic { + _ = ctx + if szDiagnosticSingleton == nil { + szDiagnosticSingleton = &Szdiagnostic{ + CheckDatastorePerformanceResult: `{"numRecordsInserted":76667,"insertTime":1000}`, + } + } + return szDiagnosticSingleton +} + +func getSzDiagnosticAsInterface(ctx context.Context) sz.SzDiagnostic { + return getSzDiagnostic(ctx) +} + +func getTestObject(ctx context.Context, test *testing.T) *Szdiagnostic { + _ = test + return getSzDiagnostic(ctx) +} + +func printActual(test *testing.T, actual interface{}) { + printResult(test, "Actual", actual) +} + +func printResult(test *testing.T, title string, result interface{}) { + if printResults { + test.Logf("%s: %v", title, truncate(fmt.Sprintf("%v", result), defaultTruncation)) + } +} + +func testError(test *testing.T, err error) { + if err != nil { + test.Log("Error:", err.Error()) + assert.FailNow(test, err.Error()) + } +} + +func testErrorNoFail(test *testing.T, err error) { + if err != nil { + test.Log("Error:", err.Error()) + } +} + +func truncate(aString string, length int) string { + return truncator.Truncate(aString, length, "...", truncator.PositionEnd) +} + +// ---------------------------------------------------------------------------- +// Test harness +// ---------------------------------------------------------------------------- + +func TestMain(m *testing.M) { + err := setup() + if err != nil { + if szerror.Is(err, szerror.SzUnrecoverable) { + fmt.Printf("\nUnrecoverable error detected. \n\n") + } + if szerror.Is(err, szerror.SzRetryable) { + fmt.Printf("\nRetryable error detected. \n\n") + } + if szerror.Is(err, szerror.SzBadInput) { + fmt.Printf("\nBad user input error detected. \n\n") + } + fmt.Print(err) + os.Exit(1) + } + code := m.Run() + err = teardown() + if err != nil { + fmt.Print(err) + } + os.Exit(code) +} + +func setup() error { + var err error = nil + return err +} + +func teardown() error { + var err error = nil + return err +} diff --git a/szengine/doc.go b/szengine/doc.go new file mode 100644 index 0000000..73e8c6f --- /dev/null +++ b/szengine/doc.go @@ -0,0 +1,4 @@ +/* +The szengine package is used make SzEngine requests to a mock object. +*/ +package szengine diff --git a/g2engine/main.go b/szengine/main.go similarity index 73% rename from g2engine/main.go rename to szengine/main.go index b9957c5..7b6993b 100644 --- a/g2engine/main.go +++ b/szengine/main.go @@ -1,8 +1,8 @@ -package g2engine +package szengine // ---------------------------------------------------------------------------- // Constants // ---------------------------------------------------------------------------- -// Identfier of the g2engine package found messages having the format "senzing-6034xxxx". +// Identfier of the szengine package found messages having the format "senzing-6034xxxx". const ComponentId = 6034 diff --git a/g2engine/g2engine.go b/szengine/szengine.go similarity index 59% rename from g2engine/g2engine.go rename to szengine/szengine.go index 059ff1f..dc02b1d 100644 --- a/g2engine/g2engine.go +++ b/szengine/szengine.go @@ -1,9 +1,7 @@ /* - * - */ - -// Package g2engine implements a client for the service. -package g2engine +Package szengine implements a client for the service. +*/ +package szengine import ( "context" @@ -11,111 +9,50 @@ import ( "strconv" "time" - "github.com/senzing-garage/g2-sdk-go/g2api" - g2engineapi "github.com/senzing-garage/g2-sdk-go/g2engine" "github.com/senzing-garage/go-logging/logging" "github.com/senzing-garage/go-observing/notifier" "github.com/senzing-garage/go-observing/observer" "github.com/senzing-garage/go-observing/subject" + "github.com/senzing-garage/sz-sdk-go/sz" + szengineapi "github.com/senzing-garage/sz-sdk-go/szengine" ) -// ---------------------------------------------------------------------------- -// Types -// ---------------------------------------------------------------------------- - -type G2engine struct { - AddRecordWithInfoResult string - CountRedoRecordsResult int64 - DeleteRecordWithInfoResult string - ExportConfigAndConfigIDResultConfig string - ExportConfigAndConfigIDResultConfigID int64 - ExportConfigResult string - ExportCSVEntityReportResult uintptr - ExportJSONEntityReportResult uintptr - FetchNextResult string - FindInterestingEntitiesByEntityIDResult string - FindInterestingEntitiesByRecordIDResult string - FindNetworkByEntityID_V2Result string - FindNetworkByEntityIDResult string - FindNetworkByRecordID_V2Result string - FindNetworkByRecordIDResult string - FindPathByEntityID_V2Result string - FindPathByEntityIDResult string - FindPathByRecordID_V2Result string - FindPathByRecordIDResult string - FindPathExcludingByEntityID_V2Result string - FindPathExcludingByEntityIDResult string - FindPathExcludingByRecordID_V2Result string - FindPathExcludingByRecordIDResult string - FindPathIncludingSourceByEntityID_V2Result string - FindPathIncludingSourceByEntityIDResult string - FindPathIncludingSourceByRecordID_V2Result string - FindPathIncludingSourceByRecordIDResult string - GetActiveConfigIDResult int64 - GetEntityByEntityID_V2Result string - GetEntityByEntityIDResult string - GetEntityByRecordID_V2Result string - GetEntityByRecordIDResult string - GetRecord_V2Result string - GetRecordResult string - GetRedoRecordResult string - GetRepositoryLastModifiedTimeResult int64 - GetVirtualEntityByRecordID_V2Result string - GetVirtualEntityByRecordIDResult string - HowEntityByEntityID_V2Result string - HowEntityByEntityIDResult string - isTrace bool - logger logging.LoggingInterface - observerOrigin string - observers subject.Subject - ProcessRedoRecordResult string - ProcessRedoRecordWithInfoResult string - ProcessRedoRecordWithInfoResultWithInfo string - ReevaluateEntityWithInfoResult string - ReevaluateRecordWithInfoResult string - ReplaceRecordWithInfoResult string - SearchByAttributes_V2Result string - SearchByAttributesResult string - StatsResult string - WhyEntities_V2Result string - WhyEntitiesResult string - WhyRecords_V2Result string - WhyRecordsResult string -} - -// ---------------------------------------------------------------------------- -// Internal methods -// ---------------------------------------------------------------------------- - -// --- Logging ---------------------------------------------------------------- - -// Get the Logger singleton. -func (client *G2engine) getLogger() logging.LoggingInterface { - var err error = nil - if client.logger == nil { - options := []interface{}{ - &logging.OptionCallerSkip{Value: 4}, - } - client.logger, err = logging.NewSenzingSdkLogger(ComponentId, g2engineapi.IdMessages, options...) - if err != nil { - panic(err) - } - } - return client.logger -} - -// Trace method entry. -func (client *G2engine) traceEntry(errorNumber int, details ...interface{}) { - client.getLogger().Log(errorNumber, details...) -} - -// Trace method exit. -func (client *G2engine) traceExit(errorNumber int, details ...interface{}) { - client.getLogger().Log(errorNumber, details...) +type Szengine struct { + AddRecordResult string + CountRedoRecordsResult int64 + DeleteRecordResult string + ExportConfigResult string + ExportCsvEntityReportResult uintptr + ExportJsonEntityReportResult uintptr + FetchNextResult string + FindNetworkByEntityIdResult string + FindNetworkByRecordIdResult string + FindPathByEntityIdResult string + FindPathByRecordIdResult string + GetActiveConfigIdResult int64 + GetEntityByEntityIdResult string + GetEntityByRecordIdResult string + GetRecordResult string + GetRedoRecordResult string + GetRepositoryLastModifiedTimeResult int64 + GetStatsResult string + GetVirtualEntityByRecordIdResult string + HowEntityByEntityIdResult string + isTrace bool + logger logging.LoggingInterface + observerOrigin string + observers subject.Subject + ProcessRedoRecordResult string + ReevaluateEntityResult string + ReevaluateRecordResult string + SearchByAttributesResult string + WhyEntitiesResult string + WhyRecordInEntityResult string + WhyRecordsResult string } // ---------------------------------------------------------------------------- -// Interface methods +// sz-sdk-go.SzEngine interface methods // ---------------------------------------------------------------------------- /* @@ -124,82 +61,46 @@ The AddRecord method adds a record into the Senzing repository. Input - ctx: A context to control lifecycle. - dataSourceCode: Identifies the provenance of the data. - - recordID: The unique identifier within the records of the same data source. - - jsonData: A JSON document containing the record to be added to the Senzing repository. - - loadID: An identifier used to distinguish different load batches/sessions. An empty string is acceptable. -*/ -func (client *G2engine) AddRecord(ctx context.Context, dataSourceCode string, recordID string, jsonData string, loadID string) error { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(1, dataSourceCode, recordID, jsonData, loadID) - defer func() { client.traceExit(2, dataSourceCode, recordID, jsonData, loadID, err, time.Since(entryTime)) }() - } - if client.observers != nil { - go func() { - details := map[string]string{ - "dataSourceCode": dataSourceCode, - "recordID": recordID, - "loadID": loadID, - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8001, err, details) - }() - } - return err -} - -/* -The AddRecordWithInfo method adds a record into the Senzing repository and returns information on the affected entities. - -Input - - ctx: A context to control lifecycle. - - dataSourceCode: Identifies the provenance of the data. - - recordID: The unique identifier within the records of the same data source. - - jsonData: A JSON document containing the record to be added to the Senzing repository. - - loadID: An identifier used to distinguish different load batches/sessions. An empty string is acceptable. + - recordId: The unique identifier within the records of the same data source. + - recordDefinition: A JSON document containing the record to be added to the Senzing repository. - flags: Flags used to control information returned. - -Output - - A JSON document. - See the example output. */ -func (client *G2engine) AddRecordWithInfo(ctx context.Context, dataSourceCode string, recordID string, jsonData string, loadID string, flags int64) (string, error) { +func (client *Szengine) AddRecord(ctx context.Context, dataSourceCode string, recordId string, recordDefinition string, flags int64) (string, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(3, dataSourceCode, recordID, jsonData, loadID, flags) + client.traceEntry(1, dataSourceCode, recordId, recordDefinition, flags) defer func() { - client.traceExit(4, dataSourceCode, recordID, jsonData, loadID, flags, client.AddRecordWithInfoResult, err, time.Since(entryTime)) + client.traceExit(2, dataSourceCode, recordId, recordDefinition, flags, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{ "dataSourceCode": dataSourceCode, - "recordID": recordID, - "loadID": loadID, + "recordId": recordId, } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8002, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8001, err, details) }() } - return client.AddRecordWithInfoResult, err + return client.AddRecordResult, err } /* -The CloseExport method closes the exported document created by ExportJSONEntityReport(). -It is part of the ExportJSONEntityReport(), FetchNext(), CloseExport() +The CloseExport method closes the exported document created by ExportJsonEntityReport(). +It is part of the ExportJsonEntityReport(), FetchNext(), CloseExport() lifecycle of a list of sized entities. Input - ctx: A context to control lifecycle. - - responseHandle: A handle created by ExportJSONEntityReport() or ExportCSVEntityReport(). + - exportHandle: A handle created by ExportJsonEntityReport() or ExportCsvEntityReport(). */ -func (client *G2engine) CloseExport(ctx context.Context, responseHandle uintptr) error { +func (client *Szengine) CloseExport(ctx context.Context, exportHandle uintptr) error { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(13, responseHandle) - defer func() { client.traceExit(14, responseHandle, err, time.Since(entryTime)) }() + client.traceEntry(13, exportHandle) + defer func() { client.traceExit(14, exportHandle, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { @@ -219,7 +120,7 @@ Input Output - The number of redo records in Senzing's redo queue. */ -func (client *G2engine) CountRedoRecords(ctx context.Context) (int64, error) { +func (client *Szengine) CountRedoRecords(ctx context.Context) (int64, error) { var err error = nil if client.isTrace { entryTime := time.Now() @@ -241,65 +142,26 @@ The DeleteRecord method deletes a record from the Senzing repository. Input - ctx: A context to control lifecycle. - dataSourceCode: Identifies the provenance of the data. - - recordID: The unique identifier within the records of the same data source. - - loadID: An identifier used to distinguish different load batches/sessions. An empty string is acceptable. - FIXME: How does the "loadID" affect what is deleted? -*/ -func (client *G2engine) DeleteRecord(ctx context.Context, dataSourceCode string, recordID string, loadID string) error { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(17, dataSourceCode, recordID, loadID) - defer func() { client.traceExit(18, dataSourceCode, recordID, loadID, err, time.Since(entryTime)) }() - } - if client.observers != nil { - go func() { - details := map[string]string{ - "dataSourceCode": dataSourceCode, - "recordID": recordID, - "loadID": loadID, - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8008, err, details) - }() - } - return err -} - -/* -The DeleteRecordWithInfo method deletes a record from the Senzing repository and returns information on the affected entities. - -Input - - ctx: A context to control lifecycle. - - dataSourceCode: Identifies the provenance of the data. - - recordID: The unique identifier within the records of the same data source. - - loadID: An identifier used to distinguish different load batches/sessions. An empty string is acceptable. - FIXME: How does the "loadID" affect what is deleted? + - recordId: The unique identifier within the records of the same data source. - flags: Flags used to control information returned. - -Output - - A JSON document. - See the example output. */ -func (client *G2engine) DeleteRecordWithInfo(ctx context.Context, dataSourceCode string, recordID string, loadID string, flags int64) (string, error) { +func (client *Szengine) DeleteRecord(ctx context.Context, dataSourceCode string, recordId string, flags int64) (string, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(19, dataSourceCode, recordID, loadID, flags) - defer func() { - client.traceExit(20, dataSourceCode, recordID, loadID, flags, client.DeleteRecordWithInfoResult, err, time.Since(entryTime)) - }() + client.traceEntry(17, dataSourceCode, recordId, flags) + defer func() { client.traceExit(18, dataSourceCode, recordId, flags, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{ "dataSourceCode": dataSourceCode, - "recordID": recordID, - "loadID": loadID, + "recordId": recordId, } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8009, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8008, err, details) }() } - return client.DeleteRecordWithInfoResult, err + return client.DeleteRecordResult, err } /* @@ -309,7 +171,7 @@ It should be called after all other calls are complete. Input - ctx: A context to control lifecycle. */ -func (client *G2engine) Destroy(ctx context.Context) error { +func (client *Szengine) Destroy(ctx context.Context) error { var err error = nil if client.isTrace { entryTime := time.Now() @@ -326,63 +188,8 @@ func (client *G2engine) Destroy(ctx context.Context) error { } /* -The ExportConfig method returns the Senzing engine configuration. - -Input - - ctx: A context to control lifecycle. - -Output - - A JSON document containing the current Senzing Engine configuration. -*/ -func (client *G2engine) ExportConfig(ctx context.Context) (string, error) { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(25) - defer func() { client.traceExit(26, client.ExportConfigResult, err, time.Since(entryTime)) }() - } - if client.observers != nil { - go func() { - details := map[string]string{} - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8011, err, details) - }() - } - return client.ExportConfigResult, err -} - -/* -Similar to ExportConfig(), the ExportConfigAndConfigID method returns the Senzing engine configuration and it's identifier. - -Input - - ctx: A context to control lifecycle. - -Output - - A JSON document containing the current Senzing Engine configuration. - - The unique identifier of the Senzing Engine configuration. -*/ -func (client *G2engine) ExportConfigAndConfigID(ctx context.Context) (string, int64, error) { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(23) - defer func() { - client.traceExit(24, client.ExportConfigAndConfigIDResultConfig, client.ExportConfigAndConfigIDResultConfigID, err, time.Since(entryTime)) - }() - } - if client.observers != nil { - go func() { - details := map[string]string{ - "configID": strconv.FormatInt(client.ExportConfigAndConfigIDResultConfigID, 10), - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8012, err, details) - }() - } - return client.ExportConfigAndConfigIDResultConfig, client.ExportConfigAndConfigIDResultConfigID, err -} - -/* -The ExportCSVEntityReport method initializes a cursor over a document of exported entities. -It is part of the ExportCSVEntityReport(), FetchNext(), CloseExport() +The ExportCsvEntityReport method initializes a cursor over a document of exported entities. +It is part of the ExportCsvEntityReport(), FetchNext(), CloseExport() lifecycle of a list of entities to export. Input @@ -393,13 +200,13 @@ Input Output - A handle that identifies the document to be scrolled through using FetchNext(). */ -func (client *G2engine) ExportCSVEntityReport(ctx context.Context, csvColumnList string, flags int64) (uintptr, error) { +func (client *Szengine) ExportCsvEntityReport(ctx context.Context, csvColumnList string, flags int64) (uintptr, error) { var err error = nil if client.isTrace { entryTime := time.Now() client.traceEntry(27, csvColumnList, flags) defer func() { - client.traceExit(28, csvColumnList, flags, client.ExportCSVEntityReportResult, err, time.Since(entryTime)) + client.traceExit(28, csvColumnList, flags, client.ExportCsvEntityReportResult, err, time.Since(entryTime)) }() } if client.observers != nil { @@ -408,13 +215,13 @@ func (client *G2engine) ExportCSVEntityReport(ctx context.Context, csvColumnList notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8013, err, details) }() } - return client.ExportCSVEntityReportResult, err + return client.ExportCsvEntityReportResult, err } /* -The ExportCSVEntityReportIterator method creates an Iterator that can be used in a for-loop +The ExportCsvEntityReportIterator method creates an Iterator that can be used in a for-loop to scroll through a document of exported entities. -It is a convenience method for the ExportCSVEntityReport(), FetchNext(), CloseExport() +It is a convenience method for the ExportCsvEntityReport(), FetchNext(), CloseExport() lifecycle of a list of entities to export. Input @@ -425,8 +232,8 @@ Input Output - A channel of strings that can be iterated over. */ -func (client *G2engine) ExportCSVEntityReportIterator(ctx context.Context, csvColumnList string, flags int64) chan g2api.StringFragment { - stringFragmentChannel := make(chan g2api.StringFragment) +func (client *Szengine) ExportCsvEntityReportIterator(ctx context.Context, csvColumnList string, flags int64) chan sz.StringFragment { + stringFragmentChannel := make(chan sz.StringFragment) go func() { runtime.LockOSThread() defer runtime.UnlockOSThread() @@ -448,8 +255,8 @@ func (client *G2engine) ExportCSVEntityReportIterator(ctx context.Context, csvCo } /* -The ExportJSONEntityReport method initializes a cursor over a document of exported entities. -It is part of the ExportJSONEntityReport(), FetchNext(), CloseExport() +The ExportJsonEntityReport method initializes a cursor over a document of exported entities. +It is part of the ExportJsonEntityReport(), FetchNext(), CloseExport() lifecycle of a list of entities to export. Input @@ -459,12 +266,12 @@ Input Output - A handle that identifies the document to be scrolled through using FetchNext(). */ -func (client *G2engine) ExportJSONEntityReport(ctx context.Context, flags int64) (uintptr, error) { +func (client *Szengine) ExportJsonEntityReport(ctx context.Context, flags int64) (uintptr, error) { var err error = nil if client.isTrace { entryTime := time.Now() client.traceEntry(29, flags) - defer func() { client.traceExit(30, flags, client.ExportJSONEntityReportResult, err, time.Since(entryTime)) }() + defer func() { client.traceExit(30, flags, client.ExportJsonEntityReportResult, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { @@ -472,13 +279,13 @@ func (client *G2engine) ExportJSONEntityReport(ctx context.Context, flags int64) notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8014, err, details) }() } - return client.ExportJSONEntityReportResult, err + return client.ExportJsonEntityReportResult, err } /* -The ExportJSONEntityReportIterator method creates an Iterator that can be used in a for-loop +The ExportJsonEntityReportIterator method creates an Iterator that can be used in a for-loop to scroll through a document of exported entities. -It is a convenience method for the ExportJSONEntityReport(), FetchNext(), CloseExport() +It is a convenience method for the ExportJsonEntityReport(), FetchNext(), CloseExport() lifecycle of a list of entities to export. Input @@ -488,8 +295,8 @@ Input Output - A channel of strings that can be iterated over. */ -func (client *G2engine) ExportJSONEntityReportIterator(ctx context.Context, flags int64) chan g2api.StringFragment { - stringFragmentChannel := make(chan g2api.StringFragment) +func (client *Szengine) ExportJsonEntityReportIterator(ctx context.Context, flags int64) chan sz.StringFragment { + stringFragmentChannel := make(chan sz.StringFragment) go func() { runtime.LockOSThread() defer runtime.UnlockOSThread() @@ -513,22 +320,22 @@ func (client *G2engine) ExportJSONEntityReportIterator(ctx context.Context, flag /* The FetchNext method is used to scroll through an exported document. -It is part of the ExportJSONEntityReport() or ExportCSVEntityReport(), FetchNext(), CloseExport() +It is part of the ExportJsonEntityReport() or ExportCsvEntityReport(), FetchNext(), CloseExport() lifecycle of a list of exported entities. Input - ctx: A context to control lifecycle. - - responseHandle: A handle created by ExportJSONEntityReport() or ExportCSVEntityReport(). + - exportHandle: A handle created by ExportJsonEntityReport() or ExportCsvEntityReport(). Output - - FIXME: + - TODO: Document output for FetchNext */ -func (client *G2engine) FetchNext(ctx context.Context, responseHandle uintptr) (string, error) { +func (client *Szengine) FetchNext(ctx context.Context, exportHandle uintptr) (string, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(31, responseHandle) - defer func() { client.traceExit(32, responseHandle, client.FetchNextResult, err, time.Since(entryTime)) }() + client.traceEntry(31, exportHandle) + defer func() { client.traceExit(32, exportHandle, client.FetchNextResult, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { @@ -540,878 +347,690 @@ func (client *G2engine) FetchNext(ctx context.Context, responseHandle uintptr) ( } /* -The FindInterestingEntitiesByEntityID method FIXME: +The FindNetworkByEntityId method finds all entities surrounding a requested set of entities. +This includes the requested entities, paths between them, and relations to other nearby entities. Input - ctx: A context to control lifecycle. - - entityID: The unique identifier of an entity. + - entityList: A JSON document listing entities. + Example: `{"ENTITIES": [{"ENTITY_ID": 1}, {"ENTITY_ID": 2}, {"ENTITY_ID": 3}]}` + - maxDegrees: The maximum number of degrees in paths between search entities. + - buildOutDegree: The number of degrees of relationships to show around each search entity. + - maxEntities: The maximum number of entities to return in the discovered network. - flags: Flags used to control information returned. Output - A JSON document. - See the example output. + Example: `{"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":2,"ENTITIES":[1,2]}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"SEAMAN","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":2,"FIRST_SEEN_DT":"2022-11-29 22:25:18.997","LAST_SEEN_DT":"2022-11-29 22:25:19.005"}],"LAST_SEEN_DT":"2022-11-29 22:25:19.005"},"RELATED_ENTITIES":[{"ENTITY_ID":2,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0}]},{"RESOLVED_ENTITY":{"ENTITY_ID":2,"ENTITY_NAME":"Smith","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-11-29 22:25:19.009","LAST_SEEN_DT":"2022-11-29 22:25:19.009"}],"LAST_SEEN_DT":"2022-11-29 22:25:19.009"},"RELATED_ENTITIES":[{"ENTITY_ID":1,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0}]}]}` */ -func (client *G2engine) FindInterestingEntitiesByEntityID(ctx context.Context, entityID int64, flags int64) (string, error) { +func (client *Szengine) FindNetworkByEntityId(ctx context.Context, entityList string, maxDegrees int64, buildOutDegree int64, maxEntities int64, flags int64) (string, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(33, entityID, flags) + client.traceEntry(37, entityList, maxDegrees, buildOutDegree) defer func() { - client.traceExit(34, entityID, flags, client.FindInterestingEntitiesByEntityIDResult, err, time.Since(entryTime)) + client.traceExit(38, entityList, maxDegrees, buildOutDegree, client.FindNetworkByEntityIdResult, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{ - "entityID": strconv.FormatInt(entityID, 10), + "entityList": entityList, } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8016, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8018, err, details) }() } - return client.FindInterestingEntitiesByEntityIDResult, err + return client.FindNetworkByEntityIdResult, err } /* -The FindInterestingEntitiesByRecordID method FIXME: +The FindNetworkByRecordId method finds all entities surrounding a requested set of entities identified by record identifiers. +This includes the requested entities, paths between them, and relations to other nearby entities. Input - ctx: A context to control lifecycle. - - dataSourceCode: Identifies the provenance of the data. - - recordID: The unique identifier within the records of the same data source. + - entityList: A JSON document listing entities. + Example: `{"ENTITIES": [{"ENTITY_ID": 1}, {"ENTITY_ID": 2}, {"ENTITY_ID": 3}]}` + - maxDegree: The maximum number of degrees in paths between search entities. + - buildOutDegree: The number of degrees of relationships to show around each search entity. + - maxEntities: The maximum number of entities to return in the discovered network. - flags: Flags used to control information returned. Output - A JSON document. - See the example output. + Example: `{"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":2,"ENTITIES":[1,2]}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"JOHNSON","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":2,"FIRST_SEEN_DT":"2022-12-06 14:40:34.285","LAST_SEEN_DT":"2022-12-06 14:40:34.420"}],"LAST_SEEN_DT":"2022-12-06 14:40:34.420"},"RELATED_ENTITIES":[{"ENTITY_ID":2,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0}]},{"RESOLVED_ENTITY":{"ENTITY_ID":2,"ENTITY_NAME":"OCEANGUY","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 14:40:34.359","LAST_SEEN_DT":"2022-12-06 14:40:34.359"}],"LAST_SEEN_DT":"2022-12-06 14:40:34.359"},"RELATED_ENTITIES":[{"ENTITY_ID":1,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+ADDRESS+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0}]},{"RESOLVED_ENTITY":{"ENTITY_ID":3,"ENTITY_NAME":"Smith","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 14:40:34.424","LAST_SEEN_DT":"2022-12-06 14:40:34.424"}],"LAST_SEEN_DT":"2022-12-06 14:40:34.424"},"RELATED_ENTITIES":[{"ENTITY_ID":1,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0},{"ENTITY_ID":2,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+ADDRESS+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0}]}]}` */ -func (client *G2engine) FindInterestingEntitiesByRecordID(ctx context.Context, dataSourceCode string, recordID string, flags int64) (string, error) { +func (client *Szengine) FindNetworkByRecordId(ctx context.Context, recordList string, maxDegrees int64, buildOutDegree int64, maxEntities int64, flags int64) (string, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(35, dataSourceCode, recordID, flags) + client.traceEntry(41, recordList, maxDegrees, buildOutDegree, maxEntities, flags) defer func() { - client.traceExit(36, dataSourceCode, recordID, flags, client.FindInterestingEntitiesByRecordIDResult, err, time.Since(entryTime)) + client.traceExit(42, recordList, maxDegrees, buildOutDegree, maxEntities, flags, client.FindNetworkByRecordIdResult, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{ - "dataSourceCode": dataSourceCode, - "recordID": recordID, + "recordList": recordList, } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8017, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8020, err, details) }() } - return client.FindInterestingEntitiesByRecordIDResult, err + return client.FindNetworkByRecordIdResult, err } /* -The FindNetworkByEntityID method finds all entities surrounding a requested set of entities. -This includes the requested entities, paths between them, and relations to other nearby entities. -To control output, use FindNetworkByEntityID_V2() instead. +The FindPathByEntityId method finds single relationship paths between two entities. +Paths are found using known relationships with other entities. Input - ctx: A context to control lifecycle. - - entityList: A JSON document listing entities. - Example: `{"ENTITIES": [{"ENTITY_ID": 1}, {"ENTITY_ID": 2}, {"ENTITY_ID": 3}]}` - - maxDegree: The maximum number of degrees in paths between search entities. - - buildOutDegree: The number of degrees of relationships to show around each search entity. - - maxEntities: The maximum number of entities to return in the discovered network. + - startEntityId: The entity ID for the starting entity of the search path. + - endEntityId: The entity ID for the ending entity of the search path. + - maxDegrees: The maximum number of degrees in paths between search entities. + - exclusions: A JSON document listing entities that should be avoided on the path. + - requiredDataSources: A JSON document listing data sources that should be included on the path. + - flags: Flags used to control information returned. Output - A JSON document. - Example: `{"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":2,"ENTITIES":[1,2]}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"SEAMAN","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":2,"FIRST_SEEN_DT":"2022-11-29 22:25:18.997","LAST_SEEN_DT":"2022-11-29 22:25:19.005"}],"LAST_SEEN_DT":"2022-11-29 22:25:19.005"},"RELATED_ENTITIES":[{"ENTITY_ID":2,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0}]},{"RESOLVED_ENTITY":{"ENTITY_ID":2,"ENTITY_NAME":"Smith","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-11-29 22:25:19.009","LAST_SEEN_DT":"2022-11-29 22:25:19.009"}],"LAST_SEEN_DT":"2022-11-29 22:25:19.009"},"RELATED_ENTITIES":[{"ENTITY_ID":1,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0}]}]}` + Example: `{"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":2,"ENTITIES":[1,2]}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"JOHNSON","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":2,"FIRST_SEEN_DT":"2022-12-06 14:43:49.024","LAST_SEEN_DT":"2022-12-06 14:43:49.164"}],"LAST_SEEN_DT":"2022-12-06 14:43:49.164"},"RELATED_ENTITIES":[{"ENTITY_ID":2,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0}]},{"RESOLVED_ENTITY":{"ENTITY_ID":2,"ENTITY_NAME":"OCEANGUY","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 14:43:49.104","LAST_SEEN_DT":"2022-12-06 14:43:49.104"}],"LAST_SEEN_DT":"2022-12-06 14:43:49.104"},"RELATED_ENTITIES":[{"ENTITY_ID":1,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+ADDRESS+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0}]}]}` */ -func (client *G2engine) FindNetworkByEntityID(ctx context.Context, entityList string, maxDegree int64, buildOutDegree int64, maxEntities int64) (string, error) { +func (client *Szengine) FindPathByEntityId(ctx context.Context, startEntityId int64, endEntityId int64, maxDegrees int64, exclusions string, requiredDataSources string, flags int64) (string, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(37, entityList, maxDegree, buildOutDegree, maxDegree) + client.traceEntry(45, startEntityId, endEntityId, maxDegrees) defer func() { - client.traceExit(38, entityList, maxDegree, buildOutDegree, maxDegree, client.FindNetworkByEntityIDResult, err, time.Since(entryTime)) + client.traceExit(46, startEntityId, endEntityId, maxDegrees, client.FindPathByEntityIdResult, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{ - "entityList": entityList, + "startEntityId": strconv.FormatInt(startEntityId, 10), + "endEntityId": strconv.FormatInt(endEntityId, 10), } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8018, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8022, err, details) }() } - return client.FindNetworkByEntityIDResult, err + return client.FindPathByEntityIdResult, err } /* -The FindNetworkByEntityID_V2 method finds all entities surrounding a requested set of entities. -This includes the requested entities, paths between them, and relations to other nearby entities. -It extends FindNetworkByEntityID() by adding output control flags. +The FindPathByRecordId method finds single relationship paths between two entities. +The entities are identified by starting and ending records. +Paths are found using known relationships with other entities. Input - ctx: A context to control lifecycle. - - entityList: A JSON document listing entities. - Example: `{"ENTITIES": [{"ENTITY_ID": 1}, {"ENTITY_ID": 2}, {"ENTITY_ID": 3}]}` - - maxDegree: The maximum number of degrees in paths between search entities. - - buildOutDegree: The number of degrees of relationships to show around each search entity. - - maxEntities: The maximum number of entities to return in the discovered network. + - startDataSourceCode: Identifies the provenance of the record for the starting entity of the search path. + - startRecordId: The unique identifier within the records of the same data source for the starting entity of the search path. + - endDataSourceCode: Identifies the provenance of the record for the ending entity of the search path. + - endRecordId: The unique identifier within the records of the same data source for the ending entity of the search path. + - maxDegrees: The maximum number of degrees in paths between search entities. + - exclusions: A JSON document listing entities that should be avoided on the path. + - requiredDataSources: A JSON document listing data sources that should be included on the path. - flags: Flags used to control information returned. Output + - A JSON document. - See the example output. + Example: `{"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":2,"ENTITIES":[1,2]}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"JOHNSON","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":2,"FIRST_SEEN_DT":"2022-12-06 14:48:19.522","LAST_SEEN_DT":"2022-12-06 14:48:19.667"}],"LAST_SEEN_DT":"2022-12-06 14:48:19.667"},"RELATED_ENTITIES":[{"ENTITY_ID":2,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0}]},{"RESOLVED_ENTITY":{"ENTITY_ID":2,"ENTITY_NAME":"OCEANGUY","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 14:48:19.593","LAST_SEEN_DT":"2022-12-06 14:48:19.593"}],"LAST_SEEN_DT":"2022-12-06 14:48:19.593"},"RELATED_ENTITIES":[{"ENTITY_ID":1,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+ADDRESS+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0}]}]}` */ -func (client *G2engine) FindNetworkByEntityID_V2(ctx context.Context, entityList string, maxDegree int64, buildOutDegree int64, maxEntities int64, flags int64) (string, error) { +func (client *Szengine) FindPathByRecordId(ctx context.Context, startDataSourceCode string, startRecordId string, endDataSourceCode string, endRecordId string, maxDegrees int64, exclusions string, requiredDataSources string, flags int64) (string, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(39, entityList, maxDegree, buildOutDegree, maxDegree, flags) + client.traceEntry(49, startDataSourceCode, startRecordId, endDataSourceCode, endRecordId, maxDegrees) defer func() { - client.traceExit(40, entityList, maxDegree, buildOutDegree, maxDegree, flags, client.FindNetworkByEntityID_V2Result, err, time.Since(entryTime)) + client.traceExit(50, startDataSourceCode, startRecordId, endDataSourceCode, endRecordId, maxDegrees, client.FindPathByRecordIdResult, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{ - "entityList": entityList, + "startDataSourceCode": startDataSourceCode, + "startRecordId": startRecordId, + "endDataSourceCode": endDataSourceCode, + "endRecordId": endRecordId, } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8019, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8024, err, details) }() } - return client.FindNetworkByEntityID_V2Result, err + return client.FindPathByRecordIdResult, err } /* -The FindNetworkByRecordID method finds all entities surrounding a requested set of entities identified by record identifiers. -This includes the requested entities, paths between them, and relations to other nearby entities. -To control output, use FindNetworkByRecordID_V2() instead. +The GetActiveConfigId method returns the identifier of the loaded Senzing engine configuration. Input - ctx: A context to control lifecycle. - - entityList: A JSON document listing entities. - Example: `{"ENTITIES": [{"ENTITY_ID": 1}, {"ENTITY_ID": 2}, {"ENTITY_ID": 3}]}` - - maxDegree: The maximum number of degrees in paths between search entities. - - buildOutDegree: The number of degrees of relationships to show around each search entity. - - maxEntities: The maximum number of entities to return in the discovered network. Output - - A JSON document. - Example: `{"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":2,"ENTITIES":[1,2]}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"JOHNSON","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":2,"FIRST_SEEN_DT":"2022-12-06 14:40:34.285","LAST_SEEN_DT":"2022-12-06 14:40:34.420"}],"LAST_SEEN_DT":"2022-12-06 14:40:34.420"},"RELATED_ENTITIES":[{"ENTITY_ID":2,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0}]},{"RESOLVED_ENTITY":{"ENTITY_ID":2,"ENTITY_NAME":"OCEANGUY","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 14:40:34.359","LAST_SEEN_DT":"2022-12-06 14:40:34.359"}],"LAST_SEEN_DT":"2022-12-06 14:40:34.359"},"RELATED_ENTITIES":[{"ENTITY_ID":1,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+ADDRESS+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0}]},{"RESOLVED_ENTITY":{"ENTITY_ID":3,"ENTITY_NAME":"Smith","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 14:40:34.424","LAST_SEEN_DT":"2022-12-06 14:40:34.424"}],"LAST_SEEN_DT":"2022-12-06 14:40:34.424"},"RELATED_ENTITIES":[{"ENTITY_ID":1,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0},{"ENTITY_ID":2,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+ADDRESS+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0}]}]}` + - The identifier of the active Senzing Engine configuration. */ -func (client *G2engine) FindNetworkByRecordID(ctx context.Context, recordList string, maxDegree int64, buildOutDegree int64, maxEntities int64) (string, error) { +func (client *Szengine) GetActiveConfigId(ctx context.Context) (int64, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(41, recordList, maxDegree, buildOutDegree, maxDegree) - defer func() { - client.traceExit(42, recordList, maxDegree, buildOutDegree, maxDegree, client.FindNetworkByRecordIDResult, err, time.Since(entryTime)) - }() + client.traceEntry(69) + defer func() { client.traceExit(70, client.GetActiveConfigIdResult, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { - details := map[string]string{ - "recordList": recordList, - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8020, err, details) + details := map[string]string{} + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8034, err, details) }() } - return client.FindNetworkByRecordIDResult, err + return client.GetActiveConfigIdResult, err } /* -The FindNetworkByRecordID_V2 method finds all entities surrounding a requested set of entities identified by record identifiers. -This includes the requested entities, paths between them, and relations to other nearby entities. -It extends FindNetworkByRecordID() by adding output control flags. +The GetEntityByEntityId method returns entity data based on the ID of a resolved identity. Input - ctx: A context to control lifecycle. - - entityList: A JSON document listing entities. - Example: `{"ENTITIES": [{"ENTITY_ID": 1}, {"ENTITY_ID": 2}, {"ENTITY_ID": 3}]}` - - maxDegree: The maximum number of degrees in paths between search entities. - - buildOutDegree: The number of degrees of relationships to show around each search entity. - - maxEntities: The maximum number of entities to return in the discovered network. + - entityId: The unique identifier of an entity. - flags: Flags used to control information returned. Output + - A JSON document. - See the example output. + Example: `{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"JOHNSON","FEATURES":{"ACCT_NUM":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8,"USAGE_TYPE":"CC","FEAT_DESC_VALUES":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8}]}],"ADDRESS":[{"FEAT_DESC":"772 Armstrong RD Delhi LA 71232","LIB_FEAT_ID":4,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772 Armstrong RD Delhi LA 71232","LIB_FEAT_ID":4}]}],"DOB":[{"FEAT_DESC":"4/8/1983","LIB_FEAT_ID":2,"FEAT_DESC_VALUES":[{"FEAT_DESC":"4/8/1983","LIB_FEAT_ID":2}]}],"GENDER":[{"FEAT_DESC":"F","LIB_FEAT_ID":3,"FEAT_DESC_VALUES":[{"FEAT_DESC":"F","LIB_FEAT_ID":3}]}],"LOGIN_ID":[{"FEAT_DESC":"flavorh","LIB_FEAT_ID":7,"FEAT_DESC_VALUES":[{"FEAT_DESC":"flavorh","LIB_FEAT_ID":7}]}],"NAME":[{"FEAT_DESC":"JOHNSON","LIB_FEAT_ID":1,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JOHNSON","LIB_FEAT_ID":1}]}],"PHONE":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5,"FEAT_DESC_VALUES":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5}]}],"SSN":[{"FEAT_DESC":"053-39-3251","LIB_FEAT_ID":6,"FEAT_DESC_VALUES":[{"FEAT_DESC":"053-39-3251","LIB_FEAT_ID":6}]}]},"RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":2,"FIRST_SEEN_DT":"2022-12-06 15:09:48.577","LAST_SEEN_DT":"2022-12-06 15:09:48.705"}],"LAST_SEEN_DT":"2022-12-06 15:09:48.705","RECORDS":[{"DATA_SOURCE":"TEST","RECORD_ID":"111","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"","MATCH_LEVEL":0,"MATCH_LEVEL_CODE":"","ERRULE_CODE":"","LAST_SEEN_DT":"2022-12-06 15:09:48.577"},{"DATA_SOURCE":"TEST","RECORD_ID":"FCCE9793DAAD23159DBCCEB97FF2745B92CE7919","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"+EXACTLY_SAME","MATCH_LEVEL":0,"MATCH_LEVEL_CODE":"","ERRULE_CODE":"","LAST_SEEN_DT":"2022-12-06 15:09:48.705"}]},"RELATED_ENTITIES":[{"ENTITY_ID":2,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0,"ENTITY_NAME":"OCEANGUY","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 15:09:48.647","LAST_SEEN_DT":"2022-12-06 15:09:48.647"}],"LAST_SEEN_DT":"2022-12-06 15:09:48.647"},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0,"ENTITY_NAME":"Smith","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 15:09:48.709","LAST_SEEN_DT":"2022-12-06 15:09:48.709"}],"LAST_SEEN_DT":"2022-12-06 15:09:48.709"}]}` */ -func (client *G2engine) FindNetworkByRecordID_V2(ctx context.Context, recordList string, maxDegree int64, buildOutDegree int64, maxEntities int64, flags int64) (string, error) { +func (client *Szengine) GetEntityByEntityId(ctx context.Context, entityId int64, flags int64) (string, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(43, recordList, maxDegree, buildOutDegree, maxDegree, flags) - defer func() { - client.traceExit(44, recordList, maxDegree, buildOutDegree, maxDegree, flags, client.FindNetworkByRecordID_V2Result, err, time.Since(entryTime)) - }() + client.traceEntry(71, entityId) + defer func() { client.traceExit(72, entityId, client.GetEntityByEntityIdResult, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{ - "recordList": recordList, + "entityId": strconv.FormatInt(entityId, 10), } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8021, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8035, err, details) }() } - return client.FindNetworkByRecordID_V2Result, err + return client.GetEntityByEntityIdResult, err } /* -The FindPathByEntityID method finds single relationship paths between two entities. -Paths are found using known relationships with other entities. -To control output, use FindPathByEntityID_V2() instead. +The GetEntityByRecordId method returns entity data based on the ID of a record which is a member of the entity. Input - ctx: A context to control lifecycle. - - entityID1: The entity ID for the starting entity of the search path. - - entityID2: The entity ID for the ending entity of the search path. - - maxDegree: The maximum number of degrees in paths between search entities. + - dataSourceCode: Identifies the provenance of the data. + - recordId: The unique identifier within the records of the same data source. + - flags: Flags used to control information returned. Output - A JSON document. - Example: `{"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":2,"ENTITIES":[1,2]}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"JOHNSON","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":2,"FIRST_SEEN_DT":"2022-12-06 14:43:49.024","LAST_SEEN_DT":"2022-12-06 14:43:49.164"}],"LAST_SEEN_DT":"2022-12-06 14:43:49.164"},"RELATED_ENTITIES":[{"ENTITY_ID":2,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0}]},{"RESOLVED_ENTITY":{"ENTITY_ID":2,"ENTITY_NAME":"OCEANGUY","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 14:43:49.104","LAST_SEEN_DT":"2022-12-06 14:43:49.104"}],"LAST_SEEN_DT":"2022-12-06 14:43:49.104"},"RELATED_ENTITIES":[{"ENTITY_ID":1,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+ADDRESS+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0}]}]}` + Example: `{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"JOHNSON","FEATURES":{"ACCT_NUM":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8,"USAGE_TYPE":"CC","FEAT_DESC_VALUES":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8}]}],"ADDRESS":[{"FEAT_DESC":"772 Armstrong RD Delhi LA 71232","LIB_FEAT_ID":4,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772 Armstrong RD Delhi LA 71232","LIB_FEAT_ID":4}]}],"DOB":[{"FEAT_DESC":"4/8/1983","LIB_FEAT_ID":2,"FEAT_DESC_VALUES":[{"FEAT_DESC":"4/8/1983","LIB_FEAT_ID":2}]}],"GENDER":[{"FEAT_DESC":"F","LIB_FEAT_ID":3,"FEAT_DESC_VALUES":[{"FEAT_DESC":"F","LIB_FEAT_ID":3}]}],"LOGIN_ID":[{"FEAT_DESC":"flavorh","LIB_FEAT_ID":7,"FEAT_DESC_VALUES":[{"FEAT_DESC":"flavorh","LIB_FEAT_ID":7}]}],"NAME":[{"FEAT_DESC":"JOHNSON","LIB_FEAT_ID":1,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JOHNSON","LIB_FEAT_ID":1}]}],"PHONE":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5,"FEAT_DESC_VALUES":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5}]}],"SSN":[{"FEAT_DESC":"053-39-3251","LIB_FEAT_ID":6,"FEAT_DESC_VALUES":[{"FEAT_DESC":"053-39-3251","LIB_FEAT_ID":6}]}]},"RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":2,"FIRST_SEEN_DT":"2022-12-06 15:12:25.464","LAST_SEEN_DT":"2022-12-06 15:12:25.597"}],"LAST_SEEN_DT":"2022-12-06 15:12:25.597","RECORDS":[{"DATA_SOURCE":"TEST","RECORD_ID":"111","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"","MATCH_LEVEL":0,"MATCH_LEVEL_CODE":"","ERRULE_CODE":"","LAST_SEEN_DT":"2022-12-06 15:12:25.464"},{"DATA_SOURCE":"TEST","RECORD_ID":"FCCE9793DAAD23159DBCCEB97FF2745B92CE7919","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"+EXACTLY_SAME","MATCH_LEVEL":0,"MATCH_LEVEL_CODE":"","ERRULE_CODE":"","LAST_SEEN_DT":"2022-12-06 15:12:25.597"}]},"RELATED_ENTITIES":[{"ENTITY_ID":2,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0,"ENTITY_NAME":"OCEANGUY","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 15:12:25.536","LAST_SEEN_DT":"2022-12-06 15:12:25.536"}],"LAST_SEEN_DT":"2022-12-06 15:12:25.536"},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0,"ENTITY_NAME":"Smith","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 15:12:25.603","LAST_SEEN_DT":"2022-12-06 15:12:25.603"}],"LAST_SEEN_DT":"2022-12-06 15:12:25.603"}]}` */ -func (client *G2engine) FindPathByEntityID(ctx context.Context, entityID1 int64, entityID2 int64, maxDegree int64) (string, error) { +func (client *Szengine) GetEntityByRecordId(ctx context.Context, dataSourceCode string, recordId string, flags int64) (string, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(45, entityID1, entityID2, maxDegree) + client.traceEntry(75, dataSourceCode, recordId) defer func() { - client.traceExit(46, entityID1, entityID2, maxDegree, client.FindPathByEntityIDResult, err, time.Since(entryTime)) + client.traceExit(76, dataSourceCode, recordId, client.GetEntityByRecordIdResult, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{ - "entityID1": strconv.FormatInt(entityID1, 10), - "entityID2": strconv.FormatInt(entityID2, 10), + "dataSourceCode": dataSourceCode, + "recordId": recordId, } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8022, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8037, err, details) }() } - return client.FindPathByEntityIDResult, err + return client.GetEntityByRecordIdResult, err } /* -The FindPathByEntityID_V2 method finds single relationship paths between two entities. -Paths are found using known relationships with other entities. -It extends FindPathByEntityID() by adding output control flags. +The GetRecord method returns a JSON document of a single record from the Senzing repository. Input - ctx: A context to control lifecycle. - - entityID1: The entity ID for the starting entity of the search path. - - entityID2: The entity ID for the ending entity of the search path. - - maxDegree: The maximum number of degrees in paths between search entities. + - dataSourceCode: Identifies the provenance of the data. + - recordId: The unique identifier within the records of the same data source. - flags: Flags used to control information returned. Output - A JSON document. See the example output. */ -func (client *G2engine) FindPathByEntityID_V2(ctx context.Context, entityID1 int64, entityID2 int64, maxDegree int64, flags int64) (string, error) { +func (client *Szengine) GetRecord(ctx context.Context, dataSourceCode string, recordId string, flags int64) (string, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(47, entityID1, entityID2, maxDegree, flags) + client.traceEntry(83, dataSourceCode, recordId) defer func() { - client.traceExit(48, entityID1, entityID2, maxDegree, flags, client.FindPathByEntityID_V2Result, err, time.Since(entryTime)) + client.traceExit(84, dataSourceCode, recordId, client.GetRecordResult, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{ - "entityID1": strconv.FormatInt(entityID1, 10), - "entityID2": strconv.FormatInt(entityID2, 10), + "dataSourceCode": dataSourceCode, + "recordId": recordId, } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8023, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8039, err, details) }() } - return client.FindPathByEntityID_V2Result, err + return client.GetRecordResult, err } /* -The FindPathByRecordID method finds single relationship paths between two entities. -The entities are identified by starting and ending records. -Paths are found using known relationships with other entities. -To control output, use FindPathByRecordID_V2() instead. +The GetRedoRecord method returns the next internally queued maintenance record from the Senzing repository. +Usually, the ProcessRedoRecord() or ProcessRedoRecordWithInfo() method is called to process the maintenance record +retrieved by GetRedoRecord(). Input - ctx: A context to control lifecycle. - - dataSourceCode1: Identifies the provenance of the record for the starting entity of the search path. - - recordID1: The unique identifier within the records of the same data source for the starting entity of the search path. - - dataSourceCode2: Identifies the provenance of the record for the ending entity of the search path. - - recordID2: The unique identifier within the records of the same data source for the ending entity of the search path. - - maxDegree: The maximum number of degrees in paths between search entities. Output - - A JSON document. - Example: `{"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":2,"ENTITIES":[1,2]}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"JOHNSON","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":2,"FIRST_SEEN_DT":"2022-12-06 14:48:19.522","LAST_SEEN_DT":"2022-12-06 14:48:19.667"}],"LAST_SEEN_DT":"2022-12-06 14:48:19.667"},"RELATED_ENTITIES":[{"ENTITY_ID":2,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0}]},{"RESOLVED_ENTITY":{"ENTITY_ID":2,"ENTITY_NAME":"OCEANGUY","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 14:48:19.593","LAST_SEEN_DT":"2022-12-06 14:48:19.593"}],"LAST_SEEN_DT":"2022-12-06 14:48:19.593"},"RELATED_ENTITIES":[{"ENTITY_ID":1,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+ADDRESS+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0}]}]}` */ -func (client *G2engine) FindPathByRecordID(ctx context.Context, dataSourceCode1 string, recordID1 string, dataSourceCode2 string, recordID2 string, maxDegree int64) (string, error) { +func (client *Szengine) GetRedoRecord(ctx context.Context) (string, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(49, dataSourceCode1, recordID1, dataSourceCode2, recordID2, maxDegree) - defer func() { - client.traceExit(50, dataSourceCode1, recordID1, dataSourceCode2, recordID2, maxDegree, client.FindPathByRecordIDResult, err, time.Since(entryTime)) - }() + client.traceEntry(87) + defer func() { client.traceExit(88, client.GetRedoRecordResult, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { - details := map[string]string{ - "dataSourceCode1": dataSourceCode1, - "recordID1": recordID1, - "dataSourceCode2": dataSourceCode2, - "recordID2": recordID2, - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8024, err, details) + details := map[string]string{} + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8041, err, details) }() } - return client.FindPathByRecordIDResult, err + return client.GetRedoRecordResult, err } /* -The FindPathByRecordID_V2 method finds single relationship paths between two entities. -The entities are identified by starting and ending records. -Paths are found using known relationships with other entities. -It extends FindPathByRecordID() by adding output control flags. +The GetRepositoryLastModifiedTime method retrieves the last modified time of the Senzing repository, +measured in the number of seconds between the last modified time and January 1, 1970 12:00am GMT (epoch time). Input - ctx: A context to control lifecycle. - - dataSourceCode1: Identifies the provenance of the record for the starting entity of the search path. - - recordID1: The unique identifier within the records of the same data source for the starting entity of the search path. - - dataSourceCode2: Identifies the provenance of the record for the ending entity of the search path. - - recordID2: The unique identifier within the records of the same data source for the ending entity of the search path. - - maxDegree: The maximum number of degrees in paths between search entities. - - flags: Flags used to control information returned. Output - - A JSON document. - See the example output. + - A Unix Timestamp. */ -func (client *G2engine) FindPathByRecordID_V2(ctx context.Context, dataSourceCode1 string, recordID1 string, dataSourceCode2 string, recordID2 string, maxDegree int64, flags int64) (string, error) { +func (client *Szengine) GetRepositoryLastModifiedTime(ctx context.Context) (int64, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(51, dataSourceCode1, recordID1, dataSourceCode2, recordID2, maxDegree, flags) - defer func() { - client.traceExit(52, dataSourceCode1, recordID1, dataSourceCode2, recordID2, maxDegree, flags, client.FindPathByRecordID_V2Result, err, time.Since(entryTime)) - }() + client.traceEntry(89) + defer func() { client.traceExit(90, client.GetRepositoryLastModifiedTimeResult, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { - details := map[string]string{ - "dataSourceCode1": dataSourceCode1, - "recordID1": recordID1, - "dataSourceCode2": dataSourceCode2, - "recordID2": recordID2, - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8025, err, details) + details := map[string]string{} + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8042, err, details) }() } - return client.FindPathByRecordID_V2Result, err + return client.GetRepositoryLastModifiedTimeResult, err } /* -The FindPathExcludingByEntityID method finds single relationship paths between two entities. -Paths are found using known relationships with other entities. -In addition, it will find paths that exclude certain entities from being on the path. -To control output, use FindPathExcludingByEntityID_V2() instead. +The GetStats method retrieves workload statistics for the current process. +These statistics will automatically reset after retrieval. Input - ctx: A context to control lifecycle. - - entityID1: The entity ID for the starting entity of the search path. - - entityID2: The entity ID for the ending entity of the search path. - - maxDegree: The maximum number of degrees in paths between search entities. - - excludedEntities: A JSON document listing entities that should be avoided on the path. Output - A JSON document. - Example: `{"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":2,"ENTITIES":[1,2]}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"JOHNSON","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":2,"FIRST_SEEN_DT":"2022-12-06 14:50:49.222","LAST_SEEN_DT":"2022-12-06 14:50:49.356"}],"LAST_SEEN_DT":"2022-12-06 14:50:49.356"},"RELATED_ENTITIES":[{"ENTITY_ID":2,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0}]},{"RESOLVED_ENTITY":{"ENTITY_ID":2,"ENTITY_NAME":"OCEANGUY","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 14:50:49.295","LAST_SEEN_DT":"2022-12-06 14:50:49.295"}],"LAST_SEEN_DT":"2022-12-06 14:50:49.295"},"RELATED_ENTITIES":[{"ENTITY_ID":1,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+ADDRESS+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0}]}]}` + Example: `{"workload":{"loadedRecords":5,"addedRecords":2,"deletedRecords":0,"reevaluations":0,"repairedEntities":0,"duration":56,"retries":0,"candidates":19,"actualAmbiguousTest":0,"cachedAmbiguousTest":0,"libFeatCacheHit":219,"libFeatCacheMiss":73,"unresolveTest":1,"abortedUnresolve":0,"gnrScorersUsed":1,"unresolveTriggers":{"normalResolve":0,"update":0,"relLink":0,"extensiveResolve":0,"ambiguousNoResolve":1,"ambiguousMultiResolve":0},"reresolveTriggers":{"abortRetry":0,"unresolveMovement":0,"multipleResolvableCandidates":0,"resolveNewFeatures":1,"newFeatureFTypes":[{"DOB":1}]},"reresolveSkipped":0,"filteredObsFeat":0,"expressedFeatureCalls":[{"EFCALL_ID":1,"EFUNC_CODE":"PHONE_HASHER","numCalls":1},{"EFCALL_ID":2,"EFUNC_CODE":"EXPRESS_ID","numCalls":1},{"EFCALL_ID":3,"EFUNC_CODE":"EXPRESS_ID","numCalls":1},{"EFCALL_ID":5,"EFUNC_CODE":"EXPRESS_BOM","numCalls":1},{"EFCALL_ID":7,"EFUNC_CODE":"NAME_HASHER","numCalls":4},{"EFCALL_ID":9,"EFUNC_CODE":"ADDR_HASHER","numCalls":1},{"EFCALL_ID":10,"EFUNC_CODE":"EXPRESS_BOM","numCalls":1},{"EFCALL_ID":14,"EFUNC_CODE":"EXPRESS_ID","numCalls":1},{"EFCALL_ID":16,"EFUNC_CODE":"EXPRESS_ID","numCalls":4}],"expressedFeaturesCreated":[{"ADDR_KEY":2},{"ID_KEY":7},{"NAME_KEY":14},{"PHONE_KEY":1},{"SEARCH_KEY":2}],"scoredPairs":[{"ACCT_NUM":16},{"ADDRESS":16},{"DOB":25},{"GENDER":16},{"LOGIN_ID":16},{"NAME":19},{"PHONE":16},{"SSN":19}],"cacheHit":[{"ADDRESS":12},{"DOB":18},{"NAME":13},{"PHONE":15}],"cacheMiss":[{"ADDRESS":4},{"DOB":7},{"NAME":6},{"PHONE":1}],"redoTriggers":[],"latchContention":[],"highContentionFeat":[],"highContentionResEnt":[],"genericDetect":[],"candidateBuilders":[{"ACCT_NUM":7},{"ADDR_KEY":7},{"DOB":7},{"ID_KEY":9},{"LOGIN_ID":7},{"NAME_KEY":9},{"PHONE":7},{"PHONE_KEY":7},{"SEARCH_KEY":7},{"SSN":9}],"suppressedCandidateBuilders":[],"suppressedScoredFeatureType":[],"reducedScoredFeatureType":[],"suppressedDisclosedRelationshipDomainCount":0,"CorruptEntityTestDiagnosis":{},"threadState":{"active":0,"idle":4,"sqlExecuting":0,"loader":0,"resolver":0,"scoring":0,"dataLatchContention":0,"obsEntContention":0,"resEntContention":0},"systemResources":{"initResources":[{"physicalCores":16},{"logicalCores":16},{"totalMemory":"62.6GB"},{"availableMemory":"49.5GB"}],"currResources":[{"availableMemory":"47.4GB"},{"activeThreads":0},{"workerThreads":4},{"systemLoad":[{"cpuUser":13.442277},{"cpuSystem":2.635741},{"cpuIdle":82.024246},{"cpuWait":1.634159},{"cpuSoftIrq":0.263574}]}]}}}` */ -func (client *G2engine) FindPathExcludingByEntityID(ctx context.Context, entityID1 int64, entityID2 int64, maxDegree int64, excludedEntities string) (string, error) { +func (client *Szengine) GetStats(ctx context.Context) (string, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(53, entityID1, entityID2, maxDegree, excludedEntities) - defer func() { - client.traceExit(54, entityID1, entityID2, maxDegree, excludedEntities, client.FindPathExcludingByEntityIDResult, err, time.Since(entryTime)) - }() + client.traceEntry(139) + defer func() { client.traceExit(140, client.GetStatsResult, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { - details := map[string]string{ - "entityID1": strconv.FormatInt(entityID1, 10), - "entityID2": strconv.FormatInt(entityID2, 10), - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8026, err, details) + details := map[string]string{} + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8066, err, details) }() } - return client.FindPathExcludingByEntityIDResult, err + return client.GetStatsResult, err } /* -The FindPathExcludingByEntityID_V2 method finds single relationship paths between two entities. -Paths are found using known relationships with other entities. -In addition, it will find paths that exclude certain entities from being on the path. -It extends FindPathExcludingByEntityID() by adding output control flags. - -When excluding entities, the user may choose to either strictly exclude the entities, -or prefer to exclude the entities but still include them if no other path is found. -By default, entities will be strictly excluded. -A "preferred exclude" may be done by specifying the G2_FIND_PATH_PREFER_EXCLUDE control flag. +TODO: Write description for GetVirtualEntityByRecordId +The GetVirtualEntityByRecordId method... Input - ctx: A context to control lifecycle. - - entityID1: The entity ID for the starting entity of the search path. - - entityID2: The entity ID for the ending entity of the search path. - - maxDegree: The maximum number of degrees in paths between search entities. - - excludedEntities: A JSON document listing entities that should be avoided on the path. + - recordList: A JSON document. + Example: `{"RECORDS": [{"DATA_SOURCE": "TEST","RECORD_ID": "111"},{"DATA_SOURCE": "TEST","RECORD_ID": "222"}]}` - flags: Flags used to control information returned. Output - A JSON document. - See the example output. -*/ -func (client *G2engine) FindPathExcludingByEntityID_V2(ctx context.Context, entityID1 int64, entityID2 int64, maxDegree int64, excludedEntities string, flags int64) (string, error) { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(55, entityID1, entityID2, maxDegree, excludedEntities, flags) - defer func() { - client.traceExit(56, entityID1, entityID2, maxDegree, excludedEntities, flags, client.FindPathExcludingByEntityID_V2Result, err, time.Since(entryTime)) - }() - } - if client.observers != nil { - go func() { - details := map[string]string{ - "entityID1": strconv.FormatInt(entityID1, 10), - "entityID2": strconv.FormatInt(entityID2, 10), - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8027, err, details) - }() - } - return client.FindPathExcludingByEntityID_V2Result, err -} - -/* -The FindPathExcludingByRecordID method finds single relationship paths between two entities. -Paths are found using known relationships with other entities. -In addition, it will find paths that exclude certain entities from being on the path. -To control output, use FindPathExcludingByRecordID_V2() instead. - -Input - - ctx: A context to control lifecycle. - - dataSourceCode1: Identifies the provenance of the record for the starting entity of the search path. - - recordID1: The unique identifier within the records of the same data source for the starting entity of the search path. - - dataSourceCode2: Identifies the provenance of the record for the ending entity of the search path. - - recordID2: The unique identifier within the records of the same data source for the ending entity of the search path. - - maxDegree: The maximum number of degrees in paths between search entities. - - excludedRecords: A JSON document listing entities that should be avoided on the path. - -Output - - A JSON document. - Example: `{"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":2,"ENTITIES":[1,2]}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"JOHNSON","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":2,"FIRST_SEEN_DT":"2022-12-06 14:55:02.577","LAST_SEEN_DT":"2022-12-06 14:55:02.711"}],"LAST_SEEN_DT":"2022-12-06 14:55:02.711"},"RELATED_ENTITIES":[{"ENTITY_ID":2,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0}]},{"RESOLVED_ENTITY":{"ENTITY_ID":2,"ENTITY_NAME":"OCEANGUY","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 14:55:02.649","LAST_SEEN_DT":"2022-12-06 14:55:02.649"}],"LAST_SEEN_DT":"2022-12-06 14:55:02.649"},"RELATED_ENTITIES":[{"ENTITY_ID":1,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+ADDRESS+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0}]}]}` + Example: `{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"JOHNSON","FEATURES":{"ACCT_NUM":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8,"USAGE_TYPE":"CC","FEAT_DESC_VALUES":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ADDRESS":[{"FEAT_DESC":"772 Armstrong RD Delhi LA 71232","LIB_FEAT_ID":4,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772 Armstrong RD Delhi LA 71232","LIB_FEAT_ID":4,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"772 Armstrong RD Delhi WI 53543","LIB_FEAT_ID":26,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772 Armstrong RD Delhi WI 53543","LIB_FEAT_ID":26,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ADDR_KEY":[{"FEAT_DESC":"772|ARMSTRNK||53543","LIB_FEAT_ID":37,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772|ARMSTRNK||53543","LIB_FEAT_ID":37,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"772|ARMSTRNK||71232","LIB_FEAT_ID":18,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772|ARMSTRNK||71232","LIB_FEAT_ID":18,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"772|ARMSTRNK||TL","LIB_FEAT_ID":17,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772|ARMSTRNK||TL","LIB_FEAT_ID":17,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"DOB":[{"FEAT_DESC":"4/8/1983","LIB_FEAT_ID":2,"FEAT_DESC_VALUES":[{"FEAT_DESC":"4/8/1983","LIB_FEAT_ID":2,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"6/9/1983","LIB_FEAT_ID":25,"FEAT_DESC_VALUES":[{"FEAT_DESC":"6/9/1983","LIB_FEAT_ID":25,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"GENDER":[{"FEAT_DESC":"F","LIB_FEAT_ID":3,"FEAT_DESC_VALUES":[{"FEAT_DESC":"F","LIB_FEAT_ID":3,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ID_KEY":[{"FEAT_DESC":"ACCT_NUM=5534202208773608","LIB_FEAT_ID":19,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ACCT_NUM=5534202208773608","LIB_FEAT_ID":19,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"SSN=053-39-3251","LIB_FEAT_ID":20,"FEAT_DESC_VALUES":[{"FEAT_DESC":"SSN=053-39-3251","LIB_FEAT_ID":20,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"SSN=153-33-5185","LIB_FEAT_ID":38,"FEAT_DESC_VALUES":[{"FEAT_DESC":"SSN=153-33-5185","LIB_FEAT_ID":38,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"LOGIN_ID":[{"FEAT_DESC":"flavorh","LIB_FEAT_ID":7,"FEAT_DESC_VALUES":[{"FEAT_DESC":"flavorh","LIB_FEAT_ID":7,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"flavorh2","LIB_FEAT_ID":28,"FEAT_DESC_VALUES":[{"FEAT_DESC":"flavorh2","LIB_FEAT_ID":28,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"NAME":[{"FEAT_DESC":"JOHNSON","LIB_FEAT_ID":1,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JOHNSON","LIB_FEAT_ID":1,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"OCEANGUY","LIB_FEAT_ID":24,"FEAT_DESC_VALUES":[{"FEAT_DESC":"OCEANGUY","LIB_FEAT_ID":24,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"NAME_KEY":[{"FEAT_DESC":"ASNK","LIB_FEAT_ID":29,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK","LIB_FEAT_ID":29,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|ADDRESS.CITY_STD=TL","LIB_FEAT_ID":34,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|ADDRESS.CITY_STD=TL","LIB_FEAT_ID":34,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|DOB.MMDD_HASH=0906","LIB_FEAT_ID":32,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|DOB.MMDD_HASH=0906","LIB_FEAT_ID":32,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|DOB.MMYY_HASH=0683","LIB_FEAT_ID":30,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|DOB.MMYY_HASH=0683","LIB_FEAT_ID":30,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|DOB=80906","LIB_FEAT_ID":31,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|DOB=80906","LIB_FEAT_ID":31,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|PHONE.PHONE_LAST_5=10796","LIB_FEAT_ID":33,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|PHONE.PHONE_LAST_5=10796","LIB_FEAT_ID":33,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|POST=53543","LIB_FEAT_ID":36,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|POST=53543","LIB_FEAT_ID":36,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|SSN=5185","LIB_FEAT_ID":35,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|SSN=5185","LIB_FEAT_ID":35,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN","LIB_FEAT_ID":11,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN","LIB_FEAT_ID":11,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|ADDRESS.CITY_STD=TL","LIB_FEAT_ID":12,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|ADDRESS.CITY_STD=TL","LIB_FEAT_ID":12,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|DOB.MMDD_HASH=0804","LIB_FEAT_ID":9,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|DOB.MMDD_HASH=0804","LIB_FEAT_ID":9,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|DOB.MMYY_HASH=0483","LIB_FEAT_ID":10,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|DOB.MMYY_HASH=0483","LIB_FEAT_ID":10,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|DOB=80804","LIB_FEAT_ID":13,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|DOB=80804","LIB_FEAT_ID":13,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|PHONE.PHONE_LAST_5=10796","LIB_FEAT_ID":15,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|PHONE.PHONE_LAST_5=10796","LIB_FEAT_ID":15,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|POST=71232","LIB_FEAT_ID":14,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|POST=71232","LIB_FEAT_ID":14,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|SSN=3251","LIB_FEAT_ID":16,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|SSN=3251","LIB_FEAT_ID":16,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"PHONE":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5,"FEAT_DESC_VALUES":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"PHONE_KEY":[{"FEAT_DESC":"2256710796","LIB_FEAT_ID":21,"FEAT_DESC_VALUES":[{"FEAT_DESC":"2256710796","LIB_FEAT_ID":21,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"SEARCH_KEY":[{"FEAT_DESC":"LOGIN_ID:FLAVORH2|","LIB_FEAT_ID":40,"FEAT_DESC_VALUES":[{"FEAT_DESC":"LOGIN_ID:FLAVORH2|","LIB_FEAT_ID":40,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"LOGIN_ID:FLAVORH|","LIB_FEAT_ID":22,"FEAT_DESC_VALUES":[{"FEAT_DESC":"LOGIN_ID:FLAVORH|","LIB_FEAT_ID":22,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"SSN:3251|80804|","LIB_FEAT_ID":23,"FEAT_DESC_VALUES":[{"FEAT_DESC":"SSN:3251|80804|","LIB_FEAT_ID":23,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"SSN:5185|80906|","LIB_FEAT_ID":39,"FEAT_DESC_VALUES":[{"FEAT_DESC":"SSN:5185|80906|","LIB_FEAT_ID":39,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"SSN":[{"FEAT_DESC":"053-39-3251","LIB_FEAT_ID":6,"FEAT_DESC_VALUES":[{"FEAT_DESC":"053-39-3251","LIB_FEAT_ID":6,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"153-33-5185","LIB_FEAT_ID":27,"FEAT_DESC_VALUES":[{"FEAT_DESC":"153-33-5185","LIB_FEAT_ID":27,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}]},"RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":2,"FIRST_SEEN_DT":"2022-12-06 15:20:17.088","LAST_SEEN_DT":"2022-12-06 15:20:17.161"}],"LAST_SEEN_DT":"2022-12-06 15:20:17.161","RECORDS":[{"DATA_SOURCE":"TEST","RECORD_ID":"111","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","LAST_SEEN_DT":"2022-12-06 15:20:17.088","FEATURES":[{"LIB_FEAT_ID":1},{"LIB_FEAT_ID":2},{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":4},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":6},{"LIB_FEAT_ID":7},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":9},{"LIB_FEAT_ID":10},{"LIB_FEAT_ID":11},{"LIB_FEAT_ID":12},{"LIB_FEAT_ID":13},{"LIB_FEAT_ID":14},{"LIB_FEAT_ID":15},{"LIB_FEAT_ID":16},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":18},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":20},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":22},{"LIB_FEAT_ID":23}]},{"DATA_SOURCE":"TEST","RECORD_ID":"222","ENTITY_TYPE":"TEST","INTERNAL_ID":2,"ENTITY_KEY":"740BA22D15CA88462A930AF8A7C904FF5E48226C","ENTITY_DESC":"OCEANGUY","LAST_SEEN_DT":"2022-12-06 15:20:17.161","FEATURES":[{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":24},{"LIB_FEAT_ID":25},{"LIB_FEAT_ID":26},{"LIB_FEAT_ID":27},{"LIB_FEAT_ID":28},{"LIB_FEAT_ID":29},{"LIB_FEAT_ID":30},{"LIB_FEAT_ID":31},{"LIB_FEAT_ID":32},{"LIB_FEAT_ID":33},{"LIB_FEAT_ID":34},{"LIB_FEAT_ID":35},{"LIB_FEAT_ID":36},{"LIB_FEAT_ID":37},{"LIB_FEAT_ID":38},{"LIB_FEAT_ID":39},{"LIB_FEAT_ID":40}]}]}}` */ -func (client *G2engine) FindPathExcludingByRecordID(ctx context.Context, dataSourceCode1 string, recordID1 string, dataSourceCode2 string, recordID2 string, maxDegree int64, excludedRecords string) (string, error) { +func (client *Szengine) GetVirtualEntityByRecordId(ctx context.Context, recordList string, flags int64) (string, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(57, dataSourceCode1, recordID1, dataSourceCode2, recordID2, maxDegree, excludedRecords) + client.traceEntry(91, recordList) defer func() { - client.traceExit(58, dataSourceCode1, recordID1, dataSourceCode2, recordID2, maxDegree, excludedRecords, client.FindPathExcludingByRecordIDResult, err, time.Since(entryTime)) + client.traceExit(92, recordList, client.GetVirtualEntityByRecordIdResult, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{ - "dataSourceCode1": dataSourceCode1, - "recordID1": recordID1, - "dataSourceCode2": dataSourceCode2, - "recordID2": recordID2, + "recordList": recordList, } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8028, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8043, err, details) }() } - return client.FindPathExcludingByRecordIDResult, err + return client.GetVirtualEntityByRecordIdResult, err } /* -The FindPathExcludingByRecordID_V2 method finds single relationship paths between two entities. -Paths are found using known relationships with other entities. -In addition, it will find paths that exclude certain entities from being on the path. -It extends FindPathExcludingByRecordID() by adding output control flags. - -When excluding entities, the user may choose to either strictly exclude the entities, -or prefer to exclude the entities but still include them if no other path is found. -By default, entities will be strictly excluded. -A "preferred exclude" may be done by specifying the G2_FIND_PATH_PREFER_EXCLUDE control flag. +TODO: Write description for HowEntityByEntityId +The HowEntityByEntityId method... Input - ctx: A context to control lifecycle. - - dataSourceCode1: Identifies the provenance of the record for the starting entity of the search path. - - recordID1: The unique identifier within the records of the same data source for the starting entity of the search path. - - dataSourceCode2: Identifies the provenance of the record for the ending entity of the search path. - - recordID2: The unique identifier within the records of the same data source for the ending entity of the search path. - - maxDegree: The maximum number of degrees in paths between search entities. - - excludedRecords: A JSON document listing entities that should be avoided on the path. + - entityId: The unique identifier of an entity. - flags: Flags used to control information returned. Output - A JSON document. See the example output. */ -func (client *G2engine) FindPathExcludingByRecordID_V2(ctx context.Context, dataSourceCode1 string, recordID1 string, dataSourceCode2 string, recordID2 string, maxDegree int64, excludedRecords string, flags int64) (string, error) { +func (client *Szengine) HowEntityByEntityId(ctx context.Context, entityId int64, flags int64) (string, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(59, dataSourceCode1, recordID1, dataSourceCode2, recordID2, maxDegree, excludedRecords, flags) - defer func() { - client.traceExit(60, dataSourceCode1, recordID1, dataSourceCode2, recordID2, maxDegree, excludedRecords, flags, client.FindPathExcludingByRecordID_V2Result, err, time.Since(entryTime)) - }() + client.traceEntry(95, entityId) + defer func() { client.traceExit(96, entityId, client.HowEntityByEntityIdResult, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{ - "dataSourceCode1": dataSourceCode1, - "recordID1": recordID1, - "dataSourceCode2": dataSourceCode2, - "recordID2": recordID2, + "entityId": strconv.FormatInt(entityId, 10), } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8029, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8045, err, details) }() } - return client.FindPathExcludingByRecordID_V2Result, err + return client.HowEntityByEntityIdResult, err } /* -The FindPathIncludingSourceByEntityID method finds single relationship paths between two entities. -In addition, one of the enties along the path must include a specified data source. -Specific entities may also be excluded, -using the same methodology as the FindPathExcludingByEntityID() and FindPathExcludingByRecordID(). -To control output, use FindPathIncludingSourceByEntityID_V2() instead. +The PrimeEngine method pre-initializes some of the heavier weight internal resources of the G2 engine. +The G2 Engine uses "lazy initialization". +PrimeEngine() forces initialization. Input - ctx: A context to control lifecycle. - - entityID1: The entity ID for the starting entity of the search path. - - entityID2: The entity ID for the ending entity of the search path. - - maxDegree: The maximum number of degrees in paths between search entities. - - excludedEntities: A JSON document listing entities that should be avoided on the path. - - requiredDsrcs: A JSON document listing data sources that should be included on the path. FIXME: - -Output - - A JSON document. - Example: `{"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":2,"ENTITIES":[]}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"JOHNSON","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":2,"FIRST_SEEN_DT":"2022-12-06 15:00:30.268","LAST_SEEN_DT":"2022-12-06 15:00:30.429"}],"LAST_SEEN_DT":"2022-12-06 15:00:30.429"},"RELATED_ENTITIES":[{"ENTITY_ID":2,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0}]},{"RESOLVED_ENTITY":{"ENTITY_ID":2,"ENTITY_NAME":"OCEANGUY","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 15:00:30.339","LAST_SEEN_DT":"2022-12-06 15:00:30.339"}],"LAST_SEEN_DT":"2022-12-06 15:00:30.339"},"RELATED_ENTITIES":[{"ENTITY_ID":1,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+ADDRESS+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0}]}]}` */ -func (client *G2engine) FindPathIncludingSourceByEntityID(ctx context.Context, entityID1 int64, entityID2 int64, maxDegree int64, excludedEntities string, requiredDsrcs string) (string, error) { +func (client *Szengine) PrimeEngine(ctx context.Context) error { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(61, entityID1, entityID2, maxDegree, excludedEntities, requiredDsrcs) - defer func() { - client.traceExit(62, entityID1, entityID2, maxDegree, excludedEntities, requiredDsrcs, client.FindPathIncludingSourceByEntityIDResult, err, time.Since(entryTime)) - }() + client.traceEntry(103) + defer func() { client.traceExit(104, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { - details := map[string]string{ - "entityID1": strconv.FormatInt(entityID1, 10), - "entityID2": strconv.FormatInt(entityID2, 10), - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8030, err, details) + details := map[string]string{} + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8049, err, details) }() } - return client.FindPathIncludingSourceByEntityIDResult, err + return err } /* -The FindPathIncludingSourceByEntityID_V2 method finds single relationship paths between two entities. -In addition, one of the enties along the path must include a specified data source. -Specific entities may also be excluded, -using the same methodology as the FindPathExcludingByEntityID_V2() and FindPathExcludingByRecordID_V2(). -It extends FindPathIncludingSourceByEntityID() by adding output control flags. +The ProcessRedoRecord method processes the next redo record and returns it. +Calling ProcessRedoRecord() has the potential to create more redo records in certain situations. Input - ctx: A context to control lifecycle. - - entityID1: The entity ID for the starting entity of the search path. - - entityID2: The entity ID for the ending entity of the search path. - - maxDegree: The maximum number of degrees in paths between search entities. - - excludedEntities: A JSON document listing entities that should be avoided on the path. - - requiredDsrcs: A JSON document listing data sources that should be included on the path. FIXME: - - flags: Flags used to control information returned. Output - A JSON document. - See the example output. */ -func (client *G2engine) FindPathIncludingSourceByEntityID_V2(ctx context.Context, entityID1 int64, entityID2 int64, maxDegree int64, excludedEntities string, requiredDsrcs string, flags int64) (string, error) { +func (client *Szengine) ProcessRedoRecord(ctx context.Context, redoRecord string, flags int64) (string, error) { var err error = nil + entryTime := time.Now() if client.isTrace { - entryTime := time.Now() - client.traceEntry(63, entityID1, entityID2, maxDegree, excludedEntities, requiredDsrcs, flags) - defer func() { - client.traceExit(64, entityID1, entityID2, maxDegree, excludedEntities, requiredDsrcs, flags, client.FindPathIncludingSourceByEntityID_V2Result, err, time.Since(entryTime)) - }() + client.traceEntry(107) + defer func() { client.traceExit(108, client.ProcessRedoRecordResult, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { - details := map[string]string{ - "entityID1": strconv.FormatInt(entityID1, 10), - "entityID2": strconv.FormatInt(entityID2, 10), - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8031, err, details) + details := map[string]string{} + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8051, err, details) }() } - return client.FindPathIncludingSourceByEntityID_V2Result, err + return client.ProcessRedoRecordResult, err } /* -The FindPathIncludingSourceByRecordID method finds single relationship paths between two entities. -In addition, one of the enties along the path must include a specified data source. -Specific entities may also be excluded, -using the same methodology as the FindPathExcludingByEntityID() and FindPathExcludingByRecordID(). -To control output, use FindPathIncludingSourceByRecordID_V2() instead. +TODO: Write description for ReevaluateEntity +The ReevaluateEntity method... Input - ctx: A context to control lifecycle. - - dataSourceCode1: Identifies the provenance of the record for the starting entity of the search path. - - recordID1: The unique identifier within the records of the same data source for the starting entity of the search path. - - dataSourceCode2: Identifies the provenance of the record for the ending entity of the search path. - - recordID2: The unique identifier within the records of the same data source for the ending entity of the search path. - - maxDegree: The maximum number of degrees in paths between search entities. - - excludedRecords: A JSON document listing entities that should be avoided on the path. - - requiredDsrcs: A JSON document listing data sources that should be included on the path. FIXME: - -Output - - A JSON document. - Example: `{"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":2,"ENTITIES":[]}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"JOHNSON","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":2,"FIRST_SEEN_DT":"2022-12-06 15:03:52.805","LAST_SEEN_DT":"2022-12-06 15:03:52.947"}],"LAST_SEEN_DT":"2022-12-06 15:03:52.947"},"RELATED_ENTITIES":[{"ENTITY_ID":2,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0}]},{"RESOLVED_ENTITY":{"ENTITY_ID":2,"ENTITY_NAME":"OCEANGUY","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 15:03:52.876","LAST_SEEN_DT":"2022-12-06 15:03:52.876"}],"LAST_SEEN_DT":"2022-12-06 15:03:52.876"},"RELATED_ENTITIES":[{"ENTITY_ID":1,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+ADDRESS+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0}]}]}` + - entityId: The unique identifier of an entity. + - flags: Flags used to control information returned. */ -func (client *G2engine) FindPathIncludingSourceByRecordID(ctx context.Context, dataSourceCode1 string, recordID1 string, dataSourceCode2 string, recordID2 string, maxDegree int64, excludedRecords string, requiredDsrcs string) (string, error) { +func (client *Szengine) ReevaluateEntity(ctx context.Context, entityId int64, flags int64) (string, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(65, dataSourceCode1, recordID1, dataSourceCode2, recordID2, maxDegree, excludedRecords, requiredDsrcs) - defer func() { - client.traceExit(66, dataSourceCode1, recordID1, dataSourceCode2, recordID2, maxDegree, excludedRecords, requiredDsrcs, client.FindPathIncludingSourceByRecordIDResult, err, time.Since(entryTime)) - }() + client.traceEntry(119, entityId, flags) + defer func() { client.traceExit(120, entityId, flags, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{ - "dataSourceCode1": dataSourceCode1, - "recordID1": recordID1, - "dataSourceCode2": dataSourceCode2, - "recordID2": recordID2, + "entityId": strconv.FormatInt(entityId, 10), } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8032, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8057, err, details) }() } - return client.FindPathIncludingSourceByRecordIDResult, err + return client.ReevaluateEntityResult, err } /* -The FindPathIncludingSourceByRecordID method finds single relationship paths between two entities. -In addition, one of the enties along the path must include a specified data source. -Specific entities may also be excluded, -using the same methodology as the FindPathExcludingByEntityID_V2() and FindPathExcludingByRecordID_V2(). -It extends FindPathIncludingSourceByRecordID() by adding output control flags. +TODO: Write description for ReevaluateRecord +The ReevaluateRecord method... Input - ctx: A context to control lifecycle. - - dataSourceCode1: Identifies the provenance of the record for the starting entity of the search path. - - recordID1: The unique identifier within the records of the same data source for the starting entity of the search path. - - dataSourceCode2: Identifies the provenance of the record for the ending entity of the search path. - - recordID2: The unique identifier within the records of the same data source for the ending entity of the search path. - - maxDegree: The maximum number of degrees in paths between search entities. - - excludedRecords: A JSON document listing entities that should be avoided on the path. - - requiredDsrcs: A JSON document listing data sources that should be included on the path. FIXME: + - dataSourceCode: Identifies the provenance of the data. + - recordId: The unique identifier within the records of the same data source. - flags: Flags used to control information returned. - -Output - - A JSON document. - See the example output. */ -func (client *G2engine) FindPathIncludingSourceByRecordID_V2(ctx context.Context, dataSourceCode1 string, recordID1 string, dataSourceCode2 string, recordID2 string, maxDegree int64, excludedRecords string, requiredDsrcs string, flags int64) (string, error) { +func (client *Szengine) ReevaluateRecord(ctx context.Context, dataSourceCode string, recordId string, flags int64) (string, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(67, dataSourceCode1, recordID1, dataSourceCode2, recordID2, maxDegree, excludedRecords, requiredDsrcs, flags) - defer func() { - client.traceExit(68, dataSourceCode1, recordID1, dataSourceCode2, recordID2, maxDegree, excludedRecords, requiredDsrcs, flags, client.FindPathIncludingSourceByRecordID_V2Result, err, time.Since(entryTime)) - }() + client.traceEntry(123, dataSourceCode, recordId, flags) + defer func() { client.traceExit(124, dataSourceCode, recordId, flags, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{ - "dataSourceCode1": dataSourceCode1, - "recordID1": recordID1, - "dataSourceCode2": dataSourceCode2, - "recordID2": recordID2, + "dataSourceCode": dataSourceCode, + "recordId": recordId, } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8033, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8059, err, details) }() } - return client.FindPathIncludingSourceByRecordID_V2Result, err + return client.ReevaluateRecordResult, err } /* -The GetActiveConfigID method returns the identifier of the loaded Senzing engine configuration. +The Reinitialize method re-initializes the Senzing SzEngine object using a specified configuration identifier. Input - ctx: A context to control lifecycle. - -Output - - The identifier of the active Senzing Engine configuration. + - configId: The configuration ID used for the initialization. */ -func (client *G2engine) GetActiveConfigID(ctx context.Context) (int64, error) { +func (client *Szengine) Reinitialize(ctx context.Context, configId int64) error { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(69) - defer func() { client.traceExit(70, client.GetActiveConfigIDResult, err, time.Since(entryTime)) }() + client.traceEntry(127, configId) + defer func() { client.traceExit(128, configId, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { - details := map[string]string{} - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8034, err, details) + details := map[string]string{ + "configId": strconv.FormatInt(configId, 10), + } + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8061, err, details) }() } - return client.GetActiveConfigIDResult, err + return err } /* -The GetEntityByEntityID method returns entity data based on the ID of a resolved identity. -To control output, use GetEntityByEntityID_V2() instead. +The SearchByAttributes method retrieves entity data based on a user-specified set of entity attributes. +TODO: Write description of Input for SearchByAttributes Input - ctx: A context to control lifecycle. - - entityID: The unique identifier of an entity. + - attributes: A JSON document containing the record to be added to the Senzing repository. + - searchProfile: TODO: + - flags: Flags used to control information returned. Output - - A JSON document. - Example: `{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"JOHNSON","FEATURES":{"ACCT_NUM":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8,"USAGE_TYPE":"CC","FEAT_DESC_VALUES":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8}]}],"ADDRESS":[{"FEAT_DESC":"772 Armstrong RD Delhi LA 71232","LIB_FEAT_ID":4,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772 Armstrong RD Delhi LA 71232","LIB_FEAT_ID":4}]}],"DOB":[{"FEAT_DESC":"4/8/1983","LIB_FEAT_ID":2,"FEAT_DESC_VALUES":[{"FEAT_DESC":"4/8/1983","LIB_FEAT_ID":2}]}],"GENDER":[{"FEAT_DESC":"F","LIB_FEAT_ID":3,"FEAT_DESC_VALUES":[{"FEAT_DESC":"F","LIB_FEAT_ID":3}]}],"LOGIN_ID":[{"FEAT_DESC":"flavorh","LIB_FEAT_ID":7,"FEAT_DESC_VALUES":[{"FEAT_DESC":"flavorh","LIB_FEAT_ID":7}]}],"NAME":[{"FEAT_DESC":"JOHNSON","LIB_FEAT_ID":1,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JOHNSON","LIB_FEAT_ID":1}]}],"PHONE":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5,"FEAT_DESC_VALUES":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5}]}],"SSN":[{"FEAT_DESC":"053-39-3251","LIB_FEAT_ID":6,"FEAT_DESC_VALUES":[{"FEAT_DESC":"053-39-3251","LIB_FEAT_ID":6}]}]},"RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":2,"FIRST_SEEN_DT":"2022-12-06 15:09:48.577","LAST_SEEN_DT":"2022-12-06 15:09:48.705"}],"LAST_SEEN_DT":"2022-12-06 15:09:48.705","RECORDS":[{"DATA_SOURCE":"TEST","RECORD_ID":"111","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"","MATCH_LEVEL":0,"MATCH_LEVEL_CODE":"","ERRULE_CODE":"","LAST_SEEN_DT":"2022-12-06 15:09:48.577"},{"DATA_SOURCE":"TEST","RECORD_ID":"FCCE9793DAAD23159DBCCEB97FF2745B92CE7919","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"+EXACTLY_SAME","MATCH_LEVEL":0,"MATCH_LEVEL_CODE":"","ERRULE_CODE":"","LAST_SEEN_DT":"2022-12-06 15:09:48.705"}]},"RELATED_ENTITIES":[{"ENTITY_ID":2,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0,"ENTITY_NAME":"OCEANGUY","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 15:09:48.647","LAST_SEEN_DT":"2022-12-06 15:09:48.647"}],"LAST_SEEN_DT":"2022-12-06 15:09:48.647"},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0,"ENTITY_NAME":"Smith","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 15:09:48.709","LAST_SEEN_DT":"2022-12-06 15:09:48.709"}],"LAST_SEEN_DT":"2022-12-06 15:09:48.709"}]}` + Example: `{"RESOLVED_ENTITIES":[{"MATCH_INFO":{"MATCH_LEVEL":1,"MATCH_LEVEL_CODE":"RESOLVED","MATCH_KEY":"+NAME+SSN","ERRULE_CODE":"SF1_PNAME_CSTAB","FEATURE_SCORES":{"NAME":[{"INBOUND_FEAT":"JOHNSON","CANDIDATE_FEAT":"JOHNSON","GNR_FN":100,"GNR_SN":100,"GNR_GN":70,"GENERATION_MATCH":-1,"GNR_ON":-1}],"SSN":[{"INBOUND_FEAT":"053-39-3251","CANDIDATE_FEAT":"053-39-3251","FULL_SCORE":100}]}},"ENTITY":{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"JOHNSON","FEATURES":{"ACCT_NUM":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8,"USAGE_TYPE":"CC","FEAT_DESC_VALUES":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8}]}],"ADDRESS":[{"FEAT_DESC":"772 Armstrong RD Delhi LA 71232","LIB_FEAT_ID":4,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772 Armstrong RD Delhi LA 71232","LIB_FEAT_ID":4}]}],"DOB":[{"FEAT_DESC":"4/8/1983","LIB_FEAT_ID":2,"FEAT_DESC_VALUES":[{"FEAT_DESC":"4/8/1983","LIB_FEAT_ID":2}]},{"FEAT_DESC":"4/8/1985","LIB_FEAT_ID":100001,"FEAT_DESC_VALUES":[{"FEAT_DESC":"4/8/1985","LIB_FEAT_ID":100001}]}],"GENDER":[{"FEAT_DESC":"F","LIB_FEAT_ID":3,"FEAT_DESC_VALUES":[{"FEAT_DESC":"F","LIB_FEAT_ID":3}]}],"LOGIN_ID":[{"FEAT_DESC":"flavorh","LIB_FEAT_ID":7,"FEAT_DESC_VALUES":[{"FEAT_DESC":"flavorh","LIB_FEAT_ID":7}]}],"NAME":[{"FEAT_DESC":"JOHNSON","LIB_FEAT_ID":1,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JOHNSON","LIB_FEAT_ID":1}]}],"PHONE":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5,"FEAT_DESC_VALUES":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5}]}],"SSN":[{"FEAT_DESC":"053-39-3251","LIB_FEAT_ID":6,"FEAT_DESC_VALUES":[{"FEAT_DESC":"053-39-3251","LIB_FEAT_ID":6}]}]},"RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":6,"FIRST_SEEN_DT":"2022-12-06 15:38:06.175","LAST_SEEN_DT":"2022-12-06 15:38:06.957"}],"LAST_SEEN_DT":"2022-12-06 15:38:06.957"}}}]}` */ -func (client *G2engine) GetEntityByEntityID(ctx context.Context, entityID int64) (string, error) { +func (client *Szengine) SearchByAttributes(ctx context.Context, attributes string, searchProfile string, flags int64) (string, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(71, entityID) - defer func() { client.traceExit(72, entityID, client.GetEntityByEntityIDResult, err, time.Since(entryTime)) }() + client.traceEntry(133, attributes) + defer func() { client.traceExit(134, attributes, client.SearchByAttributesResult, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { - details := map[string]string{ - "entityID": strconv.FormatInt(entityID, 10), - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8035, err, details) + details := map[string]string{} + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8064, err, details) }() } - return client.GetEntityByEntityIDResult, err + return client.SearchByAttributesResult, err } /* -The GetEntityByEntityID_V2 method returns entity data based on the ID of a resolved identity. -It extends GetEntityByEntityID() by adding output control flags. +The WhyEntities method explains why records belong to their resolved entities. +WhyEntities() will compare the record data within an entity +against the rest of the entity data and show why they are connected. +This is calculated based on the features that record data represents. Input - ctx: A context to control lifecycle. - - entityID: The unique identifier of an entity. + - entityId1: The entity ID for the starting entity of the search path. + - entityId2: The entity ID for the ending entity of the search path. - flags: Flags used to control information returned. Output - A JSON document. - See the example output. + Example: `{"WHY_RESULTS":[{"ENTITY_ID":1,"ENTITY_ID_2":2,"MATCH_INFO":{"WHY_KEY":"+PHONE+ACCT_NUM-SSN","WHY_ERRULE_CODE":"SF1","MATCH_LEVEL_CODE":"POSSIBLY_RELATED","CANDIDATE_KEYS":{"ACCT_NUM":[{"FEAT_ID":8,"FEAT_DESC":"5534202208773608"}],"ADDR_KEY":[{"FEAT_ID":17,"FEAT_DESC":"772|ARMSTRNK||TL"}],"ID_KEY":[{"FEAT_ID":19,"FEAT_DESC":"ACCT_NUM=5534202208773608"}],"PHONE":[{"FEAT_ID":5,"FEAT_DESC":"225-671-0796"}],"PHONE_KEY":[{"FEAT_ID":21,"FEAT_DESC":"2256710796"}]},"DISCLOSED_RELATIONS":{},"FEATURE_SCORES":{"ACCT_NUM":[{"INBOUND_FEAT_ID":8,"INBOUND_FEAT":"5534202208773608","INBOUND_FEAT_USAGE_TYPE":"CC","CANDIDATE_FEAT_ID":8,"CANDIDATE_FEAT":"5534202208773608","CANDIDATE_FEAT_USAGE_TYPE":"CC","FULL_SCORE":100,"SCORE_BUCKET":"SAME","SCORE_BEHAVIOR":"F1"}],"ADDRESS":[{"INBOUND_FEAT_ID":4,"INBOUND_FEAT":"772 Armstrong RD Delhi LA 71232","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":26,"CANDIDATE_FEAT":"772 Armstrong RD Delhi WI 53543","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":81,"SCORE_BUCKET":"LIKELY","SCORE_BEHAVIOR":"FF"}],"DOB":[{"INBOUND_FEAT_ID":100001,"INBOUND_FEAT":"4/8/1985","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":25,"CANDIDATE_FEAT":"6/9/1983","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":79,"SCORE_BUCKET":"NO_CHANCE","SCORE_BEHAVIOR":"FMES"},{"INBOUND_FEAT_ID":2,"INBOUND_FEAT":"4/8/1983","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":25,"CANDIDATE_FEAT":"6/9/1983","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":86,"SCORE_BUCKET":"PLAUSIBLE","SCORE_BEHAVIOR":"FMES"}],"GENDER":[{"INBOUND_FEAT_ID":3,"INBOUND_FEAT":"F","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":3,"CANDIDATE_FEAT":"F","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":100,"SCORE_BUCKET":"SAME","SCORE_BEHAVIOR":"FVME"}],"LOGIN_ID":[{"INBOUND_FEAT_ID":7,"INBOUND_FEAT":"flavorh","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":28,"CANDIDATE_FEAT":"flavorh2","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":0,"SCORE_BUCKET":"NO_CHANCE","SCORE_BEHAVIOR":"F1"}],"NAME":[{"INBOUND_FEAT_ID":1,"INBOUND_FEAT":"JOHNSON","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":24,"CANDIDATE_FEAT":"OCEANGUY","CANDIDATE_FEAT_USAGE_TYPE":"","GNR_FN":33,"GNR_SN":32,"GNR_GN":70,"GENERATION_MATCH":-1,"GNR_ON":-1,"SCORE_BUCKET":"NO_CHANCE","SCORE_BEHAVIOR":"NAME"}],"PHONE":[{"INBOUND_FEAT_ID":5,"INBOUND_FEAT":"225-671-0796","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":5,"CANDIDATE_FEAT":"225-671-0796","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":100,"SCORE_BUCKET":"SAME","SCORE_BEHAVIOR":"FF"}],"SSN":[{"INBOUND_FEAT_ID":6,"INBOUND_FEAT":"053-39-3251","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":27,"CANDIDATE_FEAT":"153-33-5185","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":0,"SCORE_BUCKET":"NO_CHANCE","SCORE_BEHAVIOR":"F1ES"}]}}}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"JOHNSON","FEATURES":{"ACCT_NUM":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8,"USAGE_TYPE":"CC","FEAT_DESC_VALUES":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ADDRESS":[{"FEAT_DESC":"772 Armstrong RD Delhi LA 71232","LIB_FEAT_ID":4,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772 Armstrong RD Delhi LA 71232","LIB_FEAT_ID":4,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ADDR_KEY":[{"FEAT_DESC":"772|ARMSTRNK||71232","LIB_FEAT_ID":18,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772|ARMSTRNK||71232","LIB_FEAT_ID":18,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"772|ARMSTRNK||TL","LIB_FEAT_ID":17,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772|ARMSTRNK||TL","LIB_FEAT_ID":17,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"DOB":[{"FEAT_DESC":"4/8/1983","LIB_FEAT_ID":2,"FEAT_DESC_VALUES":[{"FEAT_DESC":"4/8/1983","LIB_FEAT_ID":2,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"4/8/1985","LIB_FEAT_ID":100001,"FEAT_DESC_VALUES":[{"FEAT_DESC":"4/8/1985","LIB_FEAT_ID":100001,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"GENDER":[{"FEAT_DESC":"F","LIB_FEAT_ID":3,"FEAT_DESC_VALUES":[{"FEAT_DESC":"F","LIB_FEAT_ID":3,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ID_KEY":[{"FEAT_DESC":"ACCT_NUM=5534202208773608","LIB_FEAT_ID":19,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ACCT_NUM=5534202208773608","LIB_FEAT_ID":19,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"SSN=053-39-3251","LIB_FEAT_ID":20,"FEAT_DESC_VALUES":[{"FEAT_DESC":"SSN=053-39-3251","LIB_FEAT_ID":20,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"LOGIN_ID":[{"FEAT_DESC":"flavorh","LIB_FEAT_ID":7,"FEAT_DESC_VALUES":[{"FEAT_DESC":"flavorh","LIB_FEAT_ID":7,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"NAME":[{"FEAT_DESC":"JOHNSON","LIB_FEAT_ID":1,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JOHNSON","LIB_FEAT_ID":1,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"NAME_KEY":[{"FEAT_DESC":"JNSN","LIB_FEAT_ID":11,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN","LIB_FEAT_ID":11,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|ADDRESS.CITY_STD=TL","LIB_FEAT_ID":12,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|ADDRESS.CITY_STD=TL","LIB_FEAT_ID":12,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|DOB.MMDD_HASH=0804","LIB_FEAT_ID":9,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|DOB.MMDD_HASH=0804","LIB_FEAT_ID":9,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|DOB.MMYY_HASH=0483","LIB_FEAT_ID":10,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|DOB.MMYY_HASH=0483","LIB_FEAT_ID":10,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|DOB.MMYY_HASH=0485","LIB_FEAT_ID":100002,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|DOB.MMYY_HASH=0485","LIB_FEAT_ID":100002,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|DOB=80804","LIB_FEAT_ID":13,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|DOB=80804","LIB_FEAT_ID":13,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|PHONE.PHONE_LAST_5=10796","LIB_FEAT_ID":15,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|PHONE.PHONE_LAST_5=10796","LIB_FEAT_ID":15,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|POST=71232","LIB_FEAT_ID":14,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|POST=71232","LIB_FEAT_ID":14,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|SSN=3251","LIB_FEAT_ID":16,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|SSN=3251","LIB_FEAT_ID":16,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"PHONE":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5,"FEAT_DESC_VALUES":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"PHONE_KEY":[{"FEAT_DESC":"2256710796","LIB_FEAT_ID":21,"FEAT_DESC_VALUES":[{"FEAT_DESC":"2256710796","LIB_FEAT_ID":21,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"SEARCH_KEY":[{"FEAT_DESC":"LOGIN_ID:FLAVORH|","LIB_FEAT_ID":22,"FEAT_DESC_VALUES":[{"FEAT_DESC":"LOGIN_ID:FLAVORH|","LIB_FEAT_ID":22,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"SSN:3251|80804|","LIB_FEAT_ID":23,"FEAT_DESC_VALUES":[{"FEAT_DESC":"SSN:3251|80804|","LIB_FEAT_ID":23,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"SSN":[{"FEAT_DESC":"053-39-3251","LIB_FEAT_ID":6,"FEAT_DESC_VALUES":[{"FEAT_DESC":"053-39-3251","LIB_FEAT_ID":6,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}]},"RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":6,"FIRST_SEEN_DT":"2022-12-06 15:58:57.129","LAST_SEEN_DT":"2022-12-06 15:58:57.906"}],"LAST_SEEN_DT":"2022-12-06 15:58:57.906","RECORDS":[{"DATA_SOURCE":"TEST","RECORD_ID":"111","ENTITY_TYPE":"TEST","INTERNAL_ID":100001,"ENTITY_KEY":"A6C927986DF7329D1D2CDE0E8F34328AE640FB7E","ENTITY_DESC":"JOHNSON","MATCH_KEY":"","MATCH_LEVEL":0,"MATCH_LEVEL_CODE":"","ERRULE_CODE":"","LAST_SEEN_DT":"2022-12-06 15:58:57.906","FEATURES":[{"LIB_FEAT_ID":1},{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":4},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":6},{"LIB_FEAT_ID":7},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":9},{"LIB_FEAT_ID":11},{"LIB_FEAT_ID":12},{"LIB_FEAT_ID":13},{"LIB_FEAT_ID":14},{"LIB_FEAT_ID":15},{"LIB_FEAT_ID":16},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":18},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":20},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":22},{"LIB_FEAT_ID":23},{"LIB_FEAT_ID":100001},{"LIB_FEAT_ID":100002}]},{"DATA_SOURCE":"TEST","RECORD_ID":"444","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"+NAME+ADDRESS+PHONE+SSN+LOGIN_ID+ACCT_NUM","MATCH_LEVEL":1,"MATCH_LEVEL_CODE":"RESOLVED","ERRULE_CODE":"SF1_PNAME_CFF_CSTAB","LAST_SEEN_DT":"2022-12-06 15:58:57.400","FEATURES":[{"LIB_FEAT_ID":1},{"LIB_FEAT_ID":2},{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":4},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":6},{"LIB_FEAT_ID":7},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":9},{"LIB_FEAT_ID":10},{"LIB_FEAT_ID":11},{"LIB_FEAT_ID":12},{"LIB_FEAT_ID":13},{"LIB_FEAT_ID":14},{"LIB_FEAT_ID":15},{"LIB_FEAT_ID":16},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":18},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":20},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":22},{"LIB_FEAT_ID":23}]},{"DATA_SOURCE":"TEST","RECORD_ID":"555","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"+NAME+ADDRESS+PHONE+SSN+LOGIN_ID+ACCT_NUM","MATCH_LEVEL":1,"MATCH_LEVEL_CODE":"RESOLVED","ERRULE_CODE":"SF1_PNAME_CFF_CSTAB","LAST_SEEN_DT":"2022-12-06 15:58:57.404","FEATURES":[{"LIB_FEAT_ID":1},{"LIB_FEAT_ID":2},{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":4},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":6},{"LIB_FEAT_ID":7},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":9},{"LIB_FEAT_ID":10},{"LIB_FEAT_ID":11},{"LIB_FEAT_ID":12},{"LIB_FEAT_ID":13},{"LIB_FEAT_ID":14},{"LIB_FEAT_ID":15},{"LIB_FEAT_ID":16},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":18},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":20},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":22},{"LIB_FEAT_ID":23}]},{"DATA_SOURCE":"TEST","RECORD_ID":"666","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"+NAME+ADDRESS+PHONE+SSN+LOGIN_ID+ACCT_NUM","MATCH_LEVEL":1,"MATCH_LEVEL_CODE":"RESOLVED","ERRULE_CODE":"SF1_PNAME_CFF_CSTAB","LAST_SEEN_DT":"2022-12-06 15:58:57.407","FEATURES":[{"LIB_FEAT_ID":1},{"LIB_FEAT_ID":2},{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":4},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":6},{"LIB_FEAT_ID":7},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":9},{"LIB_FEAT_ID":10},{"LIB_FEAT_ID":11},{"LIB_FEAT_ID":12},{"LIB_FEAT_ID":13},{"LIB_FEAT_ID":14},{"LIB_FEAT_ID":15},{"LIB_FEAT_ID":16},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":18},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":20},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":22},{"LIB_FEAT_ID":23}]},{"DATA_SOURCE":"TEST","RECORD_ID":"777","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"+NAME+ADDRESS+PHONE+SSN+LOGIN_ID+ACCT_NUM","MATCH_LEVEL":1,"MATCH_LEVEL_CODE":"RESOLVED","ERRULE_CODE":"SF1_PNAME_CFF_CSTAB","LAST_SEEN_DT":"2022-12-06 15:58:57.410","FEATURES":[{"LIB_FEAT_ID":1},{"LIB_FEAT_ID":2},{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":4},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":6},{"LIB_FEAT_ID":7},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":9},{"LIB_FEAT_ID":10},{"LIB_FEAT_ID":11},{"LIB_FEAT_ID":12},{"LIB_FEAT_ID":13},{"LIB_FEAT_ID":14},{"LIB_FEAT_ID":15},{"LIB_FEAT_ID":16},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":18},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":20},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":22},{"LIB_FEAT_ID":23}]},{"DATA_SOURCE":"TEST","RECORD_ID":"FCCE9793DAAD23159DBCCEB97FF2745B92CE7919","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"+NAME+ADDRESS+PHONE+SSN+LOGIN_ID+ACCT_NUM","MATCH_LEVEL":1,"MATCH_LEVEL_CODE":"RESOLVED","ERRULE_CODE":"SF1_PNAME_CFF_CSTAB","LAST_SEEN_DT":"2022-12-06 15:58:57.259","FEATURES":[{"LIB_FEAT_ID":1},{"LIB_FEAT_ID":2},{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":4},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":6},{"LIB_FEAT_ID":7},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":9},{"LIB_FEAT_ID":10},{"LIB_FEAT_ID":11},{"LIB_FEAT_ID":12},{"LIB_FEAT_ID":13},{"LIB_FEAT_ID":14},{"LIB_FEAT_ID":15},{"LIB_FEAT_ID":16},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":18},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":20},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":22},{"LIB_FEAT_ID":23}]}]},"RELATED_ENTITIES":[{"ENTITY_ID":2,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0,"ENTITY_NAME":"OCEANGUY","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 15:58:57.201","LAST_SEEN_DT":"2022-12-06 15:58:57.201"}],"LAST_SEEN_DT":"2022-12-06 15:58:57.201"},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0,"ENTITY_NAME":"Smith","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 15:58:57.263","LAST_SEEN_DT":"2022-12-06 15:58:57.263"}],"LAST_SEEN_DT":"2022-12-06 15:58:57.263"}]},{"RESOLVED_ENTITY":{"ENTITY_ID":2,"ENTITY_NAME":"OCEANGUY","FEATURES":{"ACCT_NUM":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8,"USAGE_TYPE":"CC","FEAT_DESC_VALUES":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ADDRESS":[{"FEAT_DESC":"772 Armstrong RD Delhi WI 53543","LIB_FEAT_ID":26,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772 Armstrong RD Delhi WI 53543","LIB_FEAT_ID":26,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ADDR_KEY":[{"FEAT_DESC":"772|ARMSTRNK||53543","LIB_FEAT_ID":37,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772|ARMSTRNK||53543","LIB_FEAT_ID":37,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"772|ARMSTRNK||TL","LIB_FEAT_ID":17,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772|ARMSTRNK||TL","LIB_FEAT_ID":17,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"DOB":[{"FEAT_DESC":"6/9/1983","LIB_FEAT_ID":25,"FEAT_DESC_VALUES":[{"FEAT_DESC":"6/9/1983","LIB_FEAT_ID":25,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"GENDER":[{"FEAT_DESC":"F","LIB_FEAT_ID":3,"FEAT_DESC_VALUES":[{"FEAT_DESC":"F","LIB_FEAT_ID":3,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ID_KEY":[{"FEAT_DESC":"ACCT_NUM=5534202208773608","LIB_FEAT_ID":19,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ACCT_NUM=5534202208773608","LIB_FEAT_ID":19,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"SSN=153-33-5185","LIB_FEAT_ID":38,"FEAT_DESC_VALUES":[{"FEAT_DESC":"SSN=153-33-5185","LIB_FEAT_ID":38,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"LOGIN_ID":[{"FEAT_DESC":"flavorh2","LIB_FEAT_ID":28,"FEAT_DESC_VALUES":[{"FEAT_DESC":"flavorh2","LIB_FEAT_ID":28,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"NAME":[{"FEAT_DESC":"OCEANGUY","LIB_FEAT_ID":24,"FEAT_DESC_VALUES":[{"FEAT_DESC":"OCEANGUY","LIB_FEAT_ID":24,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"NAME_KEY":[{"FEAT_DESC":"ASNK","LIB_FEAT_ID":29,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK","LIB_FEAT_ID":29,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|ADDRESS.CITY_STD=TL","LIB_FEAT_ID":34,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|ADDRESS.CITY_STD=TL","LIB_FEAT_ID":34,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|DOB.MMDD_HASH=0906","LIB_FEAT_ID":32,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|DOB.MMDD_HASH=0906","LIB_FEAT_ID":32,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|DOB.MMYY_HASH=0683","LIB_FEAT_ID":30,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|DOB.MMYY_HASH=0683","LIB_FEAT_ID":30,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|DOB=80906","LIB_FEAT_ID":31,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|DOB=80906","LIB_FEAT_ID":31,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|PHONE.PHONE_LAST_5=10796","LIB_FEAT_ID":33,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|PHONE.PHONE_LAST_5=10796","LIB_FEAT_ID":33,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|POST=53543","LIB_FEAT_ID":36,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|POST=53543","LIB_FEAT_ID":36,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|SSN=5185","LIB_FEAT_ID":35,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|SSN=5185","LIB_FEAT_ID":35,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"PHONE":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5,"FEAT_DESC_VALUES":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"PHONE_KEY":[{"FEAT_DESC":"2256710796","LIB_FEAT_ID":21,"FEAT_DESC_VALUES":[{"FEAT_DESC":"2256710796","LIB_FEAT_ID":21,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"SEARCH_KEY":[{"FEAT_DESC":"LOGIN_ID:FLAVORH2|","LIB_FEAT_ID":40,"FEAT_DESC_VALUES":[{"FEAT_DESC":"LOGIN_ID:FLAVORH2|","LIB_FEAT_ID":40,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"SSN:5185|80906|","LIB_FEAT_ID":39,"FEAT_DESC_VALUES":[{"FEAT_DESC":"SSN:5185|80906|","LIB_FEAT_ID":39,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"SSN":[{"FEAT_DESC":"153-33-5185","LIB_FEAT_ID":27,"FEAT_DESC_VALUES":[{"FEAT_DESC":"153-33-5185","LIB_FEAT_ID":27,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}]},"RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 15:58:57.201","LAST_SEEN_DT":"2022-12-06 15:58:57.201"}],"LAST_SEEN_DT":"2022-12-06 15:58:57.201","RECORDS":[{"DATA_SOURCE":"TEST","RECORD_ID":"222","ENTITY_TYPE":"TEST","INTERNAL_ID":2,"ENTITY_KEY":"740BA22D15CA88462A930AF8A7C904FF5E48226C","ENTITY_DESC":"OCEANGUY","MATCH_KEY":"","MATCH_LEVEL":0,"MATCH_LEVEL_CODE":"","ERRULE_CODE":"","LAST_SEEN_DT":"2022-12-06 15:58:57.201","FEATURES":[{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":24},{"LIB_FEAT_ID":25},{"LIB_FEAT_ID":26},{"LIB_FEAT_ID":27},{"LIB_FEAT_ID":28},{"LIB_FEAT_ID":29},{"LIB_FEAT_ID":30},{"LIB_FEAT_ID":31},{"LIB_FEAT_ID":32},{"LIB_FEAT_ID":33},{"LIB_FEAT_ID":34},{"LIB_FEAT_ID":35},{"LIB_FEAT_ID":36},{"LIB_FEAT_ID":37},{"LIB_FEAT_ID":38},{"LIB_FEAT_ID":39},{"LIB_FEAT_ID":40}]}]},"RELATED_ENTITIES":[{"ENTITY_ID":1,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0,"ENTITY_NAME":"JOHNSON","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":6,"FIRST_SEEN_DT":"2022-12-06 15:58:57.129","LAST_SEEN_DT":"2022-12-06 15:58:57.906"}],"LAST_SEEN_DT":"2022-12-06 15:58:57.906"},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+ADDRESS+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0,"ENTITY_NAME":"Smith","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 15:58:57.263","LAST_SEEN_DT":"2022-12-06 15:58:57.263"}],"LAST_SEEN_DT":"2022-12-06 15:58:57.263"}]}]}` */ -func (client *G2engine) GetEntityByEntityID_V2(ctx context.Context, entityID int64, flags int64) (string, error) { +func (client *Szengine) WhyEntities(ctx context.Context, entityId1 int64, entityId2 int64, flags int64) (string, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(73, entityID, flags) + client.traceEntry(141, entityId1, entityId2) defer func() { - client.traceExit(74, entityID, flags, client.GetEntityByEntityID_V2Result, err, time.Since(entryTime)) + client.traceExit(142, entityId1, entityId2, client.WhyEntitiesResult, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{ - "entityID": strconv.FormatInt(entityID, 10), + "entityId1": strconv.FormatInt(entityId1, 10), + "entityId2": strconv.FormatInt(entityId2, 10), } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8036, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8067, err, details) }() } - return client.GetEntityByEntityID_V2Result, err + return client.WhyEntitiesResult, err } /* -The GetEntityByRecordID method returns entity data based on the ID of a record which is a member of the entity. -To control output, use GetEntityByRecordID_V2() instead. +TODO: Write description for WhyRecordInEntity +TODO: Assign entry/exit trace IDs +The WhyRecordInEntity method... Input - ctx: A context to control lifecycle. - dataSourceCode: Identifies the provenance of the data. - - recordID: The unique identifier within the records of the same data source. + - recordId: The unique identifier within the records of the same data source. + - flags: Flags used to control information returned. Output - A JSON document. - Example: `{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"JOHNSON","FEATURES":{"ACCT_NUM":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8,"USAGE_TYPE":"CC","FEAT_DESC_VALUES":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8}]}],"ADDRESS":[{"FEAT_DESC":"772 Armstrong RD Delhi LA 71232","LIB_FEAT_ID":4,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772 Armstrong RD Delhi LA 71232","LIB_FEAT_ID":4}]}],"DOB":[{"FEAT_DESC":"4/8/1983","LIB_FEAT_ID":2,"FEAT_DESC_VALUES":[{"FEAT_DESC":"4/8/1983","LIB_FEAT_ID":2}]}],"GENDER":[{"FEAT_DESC":"F","LIB_FEAT_ID":3,"FEAT_DESC_VALUES":[{"FEAT_DESC":"F","LIB_FEAT_ID":3}]}],"LOGIN_ID":[{"FEAT_DESC":"flavorh","LIB_FEAT_ID":7,"FEAT_DESC_VALUES":[{"FEAT_DESC":"flavorh","LIB_FEAT_ID":7}]}],"NAME":[{"FEAT_DESC":"JOHNSON","LIB_FEAT_ID":1,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JOHNSON","LIB_FEAT_ID":1}]}],"PHONE":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5,"FEAT_DESC_VALUES":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5}]}],"SSN":[{"FEAT_DESC":"053-39-3251","LIB_FEAT_ID":6,"FEAT_DESC_VALUES":[{"FEAT_DESC":"053-39-3251","LIB_FEAT_ID":6}]}]},"RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":2,"FIRST_SEEN_DT":"2022-12-06 15:12:25.464","LAST_SEEN_DT":"2022-12-06 15:12:25.597"}],"LAST_SEEN_DT":"2022-12-06 15:12:25.597","RECORDS":[{"DATA_SOURCE":"TEST","RECORD_ID":"111","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"","MATCH_LEVEL":0,"MATCH_LEVEL_CODE":"","ERRULE_CODE":"","LAST_SEEN_DT":"2022-12-06 15:12:25.464"},{"DATA_SOURCE":"TEST","RECORD_ID":"FCCE9793DAAD23159DBCCEB97FF2745B92CE7919","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"+EXACTLY_SAME","MATCH_LEVEL":0,"MATCH_LEVEL_CODE":"","ERRULE_CODE":"","LAST_SEEN_DT":"2022-12-06 15:12:25.597"}]},"RELATED_ENTITIES":[{"ENTITY_ID":2,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0,"ENTITY_NAME":"OCEANGUY","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 15:12:25.536","LAST_SEEN_DT":"2022-12-06 15:12:25.536"}],"LAST_SEEN_DT":"2022-12-06 15:12:25.536"},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0,"ENTITY_NAME":"Smith","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 15:12:25.603","LAST_SEEN_DT":"2022-12-06 15:12:25.603"}],"LAST_SEEN_DT":"2022-12-06 15:12:25.603"}]}` + See the example output. */ -func (client *G2engine) GetEntityByRecordID(ctx context.Context, dataSourceCode string, recordID string) (string, error) { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(75, dataSourceCode, recordID) - defer func() { - client.traceExit(76, dataSourceCode, recordID, client.GetEntityByRecordIDResult, err, time.Since(entryTime)) - }() - } - if client.observers != nil { - go func() { - details := map[string]string{ - "dataSourceCode": dataSourceCode, - "recordID": recordID, - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8037, err, details) - }() - } - return client.GetEntityByRecordIDResult, err +func (client *Szengine) WhyRecordInEntity(ctx context.Context, dataSourceCode string, recordId string, flags int64) (string, error) { + // TODO: Implement WhyRecordInEntity + return client.WhyRecordInEntityResult, nil } /* -The GetEntityByRecordID_V2 method returns entity data based on the ID of a record which is a member of the entity. -It extends GetEntityByRecordID() by adding output control flags. +The WhyRecords method explains why records belong to their resolved entities. Input - ctx: A context to control lifecycle. - - dataSourceCode: Identifies the provenance of the data. - - recordID: The unique identifier within the records of the same data source. + - dataSourceCode1: Identifies the provenance of the data. + - recordId1: The unique identifier within the records of the same data source. + - dataSourceCode2: Identifies the provenance of the data. + - recordId2: The unique identifier within the records of the same data source. - flags: Flags used to control information returned. Output - A JSON document. - See the example output. + Example: `{"WHY_RESULTS":[{"INTERNAL_ID":100001,"ENTITY_ID":1,"FOCUS_RECORDS":[{"DATA_SOURCE":"TEST","RECORD_ID":"111"}],"INTERNAL_ID_2":2,"ENTITY_ID_2":2,"FOCUS_RECORDS_2":[{"DATA_SOURCE":"TEST","RECORD_ID":"222"}],"MATCH_INFO":{"WHY_KEY":"+PHONE+ACCT_NUM-DOB-SSN","WHY_ERRULE_CODE":"SF1","MATCH_LEVEL_CODE":"POSSIBLY_RELATED","CANDIDATE_KEYS":{"ACCT_NUM":[{"FEAT_ID":8,"FEAT_DESC":"5534202208773608"}],"ADDR_KEY":[{"FEAT_ID":17,"FEAT_DESC":"772|ARMSTRNK||TL"}],"ID_KEY":[{"FEAT_ID":19,"FEAT_DESC":"ACCT_NUM=5534202208773608"}],"PHONE":[{"FEAT_ID":5,"FEAT_DESC":"225-671-0796"}],"PHONE_KEY":[{"FEAT_ID":21,"FEAT_DESC":"2256710796"}]},"DISCLOSED_RELATIONS":{},"FEATURE_SCORES":{"ACCT_NUM":[{"INBOUND_FEAT_ID":8,"INBOUND_FEAT":"5534202208773608","INBOUND_FEAT_USAGE_TYPE":"CC","CANDIDATE_FEAT_ID":8,"CANDIDATE_FEAT":"5534202208773608","CANDIDATE_FEAT_USAGE_TYPE":"CC","FULL_SCORE":100,"SCORE_BUCKET":"SAME","SCORE_BEHAVIOR":"F1"}],"ADDRESS":[{"INBOUND_FEAT_ID":4,"INBOUND_FEAT":"772 Armstrong RD Delhi LA 71232","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":26,"CANDIDATE_FEAT":"772 Armstrong RD Delhi WI 53543","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":81,"SCORE_BUCKET":"LIKELY","SCORE_BEHAVIOR":"FF"}],"DOB":[{"INBOUND_FEAT_ID":100001,"INBOUND_FEAT":"4/8/1985","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":25,"CANDIDATE_FEAT":"6/9/1983","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":79,"SCORE_BUCKET":"NO_CHANCE","SCORE_BEHAVIOR":"FMES"}],"GENDER":[{"INBOUND_FEAT_ID":3,"INBOUND_FEAT":"F","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":3,"CANDIDATE_FEAT":"F","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":100,"SCORE_BUCKET":"SAME","SCORE_BEHAVIOR":"FVME"}],"LOGIN_ID":[{"INBOUND_FEAT_ID":7,"INBOUND_FEAT":"flavorh","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":28,"CANDIDATE_FEAT":"flavorh2","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":0,"SCORE_BUCKET":"NO_CHANCE","SCORE_BEHAVIOR":"F1"}],"NAME":[{"INBOUND_FEAT_ID":1,"INBOUND_FEAT":"JOHNSON","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":24,"CANDIDATE_FEAT":"OCEANGUY","CANDIDATE_FEAT_USAGE_TYPE":"","GNR_FN":33,"GNR_SN":32,"GNR_GN":70,"GENERATION_MATCH":-1,"GNR_ON":-1,"SCORE_BUCKET":"NO_CHANCE","SCORE_BEHAVIOR":"NAME"}],"PHONE":[{"INBOUND_FEAT_ID":5,"INBOUND_FEAT":"225-671-0796","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":5,"CANDIDATE_FEAT":"225-671-0796","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":100,"SCORE_BUCKET":"SAME","SCORE_BEHAVIOR":"FF"}],"SSN":[{"INBOUND_FEAT_ID":6,"INBOUND_FEAT":"053-39-3251","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":27,"CANDIDATE_FEAT":"153-33-5185","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":0,"SCORE_BUCKET":"NO_CHANCE","SCORE_BEHAVIOR":"F1ES"}]}}}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"JOHNSON","FEATURES":{"ACCT_NUM":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8,"USAGE_TYPE":"CC","FEAT_DESC_VALUES":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ADDRESS":[{"FEAT_DESC":"772 Armstrong RD Delhi LA 71232","LIB_FEAT_ID":4,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772 Armstrong RD Delhi LA 71232","LIB_FEAT_ID":4,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ADDR_KEY":[{"FEAT_DESC":"772|ARMSTRNK||71232","LIB_FEAT_ID":18,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772|ARMSTRNK||71232","LIB_FEAT_ID":18,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"772|ARMSTRNK||TL","LIB_FEAT_ID":17,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772|ARMSTRNK||TL","LIB_FEAT_ID":17,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"DOB":[{"FEAT_DESC":"4/8/1983","LIB_FEAT_ID":2,"FEAT_DESC_VALUES":[{"FEAT_DESC":"4/8/1983","LIB_FEAT_ID":2,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"4/8/1985","LIB_FEAT_ID":100001,"FEAT_DESC_VALUES":[{"FEAT_DESC":"4/8/1985","LIB_FEAT_ID":100001,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"GENDER":[{"FEAT_DESC":"F","LIB_FEAT_ID":3,"FEAT_DESC_VALUES":[{"FEAT_DESC":"F","LIB_FEAT_ID":3,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ID_KEY":[{"FEAT_DESC":"ACCT_NUM=5534202208773608","LIB_FEAT_ID":19,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ACCT_NUM=5534202208773608","LIB_FEAT_ID":19,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"SSN=053-39-3251","LIB_FEAT_ID":20,"FEAT_DESC_VALUES":[{"FEAT_DESC":"SSN=053-39-3251","LIB_FEAT_ID":20,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"LOGIN_ID":[{"FEAT_DESC":"flavorh","LIB_FEAT_ID":7,"FEAT_DESC_VALUES":[{"FEAT_DESC":"flavorh","LIB_FEAT_ID":7,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"NAME":[{"FEAT_DESC":"JOHNSON","LIB_FEAT_ID":1,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JOHNSON","LIB_FEAT_ID":1,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"NAME_KEY":[{"FEAT_DESC":"JNSN","LIB_FEAT_ID":11,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN","LIB_FEAT_ID":11,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|ADDRESS.CITY_STD=TL","LIB_FEAT_ID":12,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|ADDRESS.CITY_STD=TL","LIB_FEAT_ID":12,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|DOB.MMDD_HASH=0804","LIB_FEAT_ID":9,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|DOB.MMDD_HASH=0804","LIB_FEAT_ID":9,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|DOB.MMYY_HASH=0483","LIB_FEAT_ID":10,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|DOB.MMYY_HASH=0483","LIB_FEAT_ID":10,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|DOB.MMYY_HASH=0485","LIB_FEAT_ID":100002,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|DOB.MMYY_HASH=0485","LIB_FEAT_ID":100002,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|DOB=80804","LIB_FEAT_ID":13,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|DOB=80804","LIB_FEAT_ID":13,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|PHONE.PHONE_LAST_5=10796","LIB_FEAT_ID":15,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|PHONE.PHONE_LAST_5=10796","LIB_FEAT_ID":15,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|POST=71232","LIB_FEAT_ID":14,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|POST=71232","LIB_FEAT_ID":14,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|SSN=3251","LIB_FEAT_ID":16,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|SSN=3251","LIB_FEAT_ID":16,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"PHONE":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5,"FEAT_DESC_VALUES":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"PHONE_KEY":[{"FEAT_DESC":"2256710796","LIB_FEAT_ID":21,"FEAT_DESC_VALUES":[{"FEAT_DESC":"2256710796","LIB_FEAT_ID":21,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"SEARCH_KEY":[{"FEAT_DESC":"LOGIN_ID:FLAVORH|","LIB_FEAT_ID":22,"FEAT_DESC_VALUES":[{"FEAT_DESC":"LOGIN_ID:FLAVORH|","LIB_FEAT_ID":22,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"SSN:3251|80804|","LIB_FEAT_ID":23,"FEAT_DESC_VALUES":[{"FEAT_DESC":"SSN:3251|80804|","LIB_FEAT_ID":23,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"SSN":[{"FEAT_DESC":"053-39-3251","LIB_FEAT_ID":6,"FEAT_DESC_VALUES":[{"FEAT_DESC":"053-39-3251","LIB_FEAT_ID":6,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}]},"RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":6,"FIRST_SEEN_DT":"2022-12-06 16:13:27.135","LAST_SEEN_DT":"2022-12-06 16:13:27.916"}],"LAST_SEEN_DT":"2022-12-06 16:13:27.916","RECORDS":[{"DATA_SOURCE":"TEST","RECORD_ID":"111","ENTITY_TYPE":"TEST","INTERNAL_ID":100001,"ENTITY_KEY":"A6C927986DF7329D1D2CDE0E8F34328AE640FB7E","ENTITY_DESC":"JOHNSON","MATCH_KEY":"","MATCH_LEVEL":0,"MATCH_LEVEL_CODE":"","ERRULE_CODE":"","LAST_SEEN_DT":"2022-12-06 16:13:27.916","FEATURES":[{"LIB_FEAT_ID":1},{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":4},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":6},{"LIB_FEAT_ID":7},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":9},{"LIB_FEAT_ID":11},{"LIB_FEAT_ID":12},{"LIB_FEAT_ID":13},{"LIB_FEAT_ID":14},{"LIB_FEAT_ID":15},{"LIB_FEAT_ID":16},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":18},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":20},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":22},{"LIB_FEAT_ID":23},{"LIB_FEAT_ID":100001},{"LIB_FEAT_ID":100002}]},{"DATA_SOURCE":"TEST","RECORD_ID":"444","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"+NAME+ADDRESS+PHONE+SSN+LOGIN_ID+ACCT_NUM","MATCH_LEVEL":1,"MATCH_LEVEL_CODE":"RESOLVED","ERRULE_CODE":"SF1_PNAME_CFF_CSTAB","LAST_SEEN_DT":"2022-12-06 16:13:27.405","FEATURES":[{"LIB_FEAT_ID":1},{"LIB_FEAT_ID":2},{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":4},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":6},{"LIB_FEAT_ID":7},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":9},{"LIB_FEAT_ID":10},{"LIB_FEAT_ID":11},{"LIB_FEAT_ID":12},{"LIB_FEAT_ID":13},{"LIB_FEAT_ID":14},{"LIB_FEAT_ID":15},{"LIB_FEAT_ID":16},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":18},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":20},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":22},{"LIB_FEAT_ID":23}]},{"DATA_SOURCE":"TEST","RECORD_ID":"555","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"+NAME+ADDRESS+PHONE+SSN+LOGIN_ID+ACCT_NUM","MATCH_LEVEL":1,"MATCH_LEVEL_CODE":"RESOLVED","ERRULE_CODE":"SF1_PNAME_CFF_CSTAB","LAST_SEEN_DT":"2022-12-06 16:13:27.408","FEATURES":[{"LIB_FEAT_ID":1},{"LIB_FEAT_ID":2},{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":4},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":6},{"LIB_FEAT_ID":7},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":9},{"LIB_FEAT_ID":10},{"LIB_FEAT_ID":11},{"LIB_FEAT_ID":12},{"LIB_FEAT_ID":13},{"LIB_FEAT_ID":14},{"LIB_FEAT_ID":15},{"LIB_FEAT_ID":16},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":18},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":20},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":22},{"LIB_FEAT_ID":23}]},{"DATA_SOURCE":"TEST","RECORD_ID":"666","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"+NAME+ADDRESS+PHONE+SSN+LOGIN_ID+ACCT_NUM","MATCH_LEVEL":1,"MATCH_LEVEL_CODE":"RESOLVED","ERRULE_CODE":"SF1_PNAME_CFF_CSTAB","LAST_SEEN_DT":"2022-12-06 16:13:27.411","FEATURES":[{"LIB_FEAT_ID":1},{"LIB_FEAT_ID":2},{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":4},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":6},{"LIB_FEAT_ID":7},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":9},{"LIB_FEAT_ID":10},{"LIB_FEAT_ID":11},{"LIB_FEAT_ID":12},{"LIB_FEAT_ID":13},{"LIB_FEAT_ID":14},{"LIB_FEAT_ID":15},{"LIB_FEAT_ID":16},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":18},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":20},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":22},{"LIB_FEAT_ID":23}]},{"DATA_SOURCE":"TEST","RECORD_ID":"777","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"+NAME+ADDRESS+PHONE+SSN+LOGIN_ID+ACCT_NUM","MATCH_LEVEL":1,"MATCH_LEVEL_CODE":"RESOLVED","ERRULE_CODE":"SF1_PNAME_CFF_CSTAB","LAST_SEEN_DT":"2022-12-06 16:13:27.418","FEATURES":[{"LIB_FEAT_ID":1},{"LIB_FEAT_ID":2},{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":4},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":6},{"LIB_FEAT_ID":7},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":9},{"LIB_FEAT_ID":10},{"LIB_FEAT_ID":11},{"LIB_FEAT_ID":12},{"LIB_FEAT_ID":13},{"LIB_FEAT_ID":14},{"LIB_FEAT_ID":15},{"LIB_FEAT_ID":16},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":18},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":20},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":22},{"LIB_FEAT_ID":23}]},{"DATA_SOURCE":"TEST","RECORD_ID":"FCCE9793DAAD23159DBCCEB97FF2745B92CE7919","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"+NAME+ADDRESS+PHONE+SSN+LOGIN_ID+ACCT_NUM","MATCH_LEVEL":1,"MATCH_LEVEL_CODE":"RESOLVED","ERRULE_CODE":"SF1_PNAME_CFF_CSTAB","LAST_SEEN_DT":"2022-12-06 16:13:27.265","FEATURES":[{"LIB_FEAT_ID":1},{"LIB_FEAT_ID":2},{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":4},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":6},{"LIB_FEAT_ID":7},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":9},{"LIB_FEAT_ID":10},{"LIB_FEAT_ID":11},{"LIB_FEAT_ID":12},{"LIB_FEAT_ID":13},{"LIB_FEAT_ID":14},{"LIB_FEAT_ID":15},{"LIB_FEAT_ID":16},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":18},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":20},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":22},{"LIB_FEAT_ID":23}]}]},"RELATED_ENTITIES":[{"ENTITY_ID":2,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0,"ENTITY_NAME":"OCEANGUY","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 16:13:27.208","LAST_SEEN_DT":"2022-12-06 16:13:27.208"}],"LAST_SEEN_DT":"2022-12-06 16:13:27.208"},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0,"ENTITY_NAME":"Smith","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 16:13:27.272","LAST_SEEN_DT":"2022-12-06 16:13:27.272"}],"LAST_SEEN_DT":"2022-12-06 16:13:27.272"}]},{"RESOLVED_ENTITY":{"ENTITY_ID":2,"ENTITY_NAME":"OCEANGUY","FEATURES":{"ACCT_NUM":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8,"USAGE_TYPE":"CC","FEAT_DESC_VALUES":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ADDRESS":[{"FEAT_DESC":"772 Armstrong RD Delhi WI 53543","LIB_FEAT_ID":26,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772 Armstrong RD Delhi WI 53543","LIB_FEAT_ID":26,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ADDR_KEY":[{"FEAT_DESC":"772|ARMSTRNK||53543","LIB_FEAT_ID":37,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772|ARMSTRNK||53543","LIB_FEAT_ID":37,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"772|ARMSTRNK||TL","LIB_FEAT_ID":17,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772|ARMSTRNK||TL","LIB_FEAT_ID":17,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"DOB":[{"FEAT_DESC":"6/9/1983","LIB_FEAT_ID":25,"FEAT_DESC_VALUES":[{"FEAT_DESC":"6/9/1983","LIB_FEAT_ID":25,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"GENDER":[{"FEAT_DESC":"F","LIB_FEAT_ID":3,"FEAT_DESC_VALUES":[{"FEAT_DESC":"F","LIB_FEAT_ID":3,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ID_KEY":[{"FEAT_DESC":"ACCT_NUM=5534202208773608","LIB_FEAT_ID":19,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ACCT_NUM=5534202208773608","LIB_FEAT_ID":19,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"SSN=153-33-5185","LIB_FEAT_ID":38,"FEAT_DESC_VALUES":[{"FEAT_DESC":"SSN=153-33-5185","LIB_FEAT_ID":38,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"LOGIN_ID":[{"FEAT_DESC":"flavorh2","LIB_FEAT_ID":28,"FEAT_DESC_VALUES":[{"FEAT_DESC":"flavorh2","LIB_FEAT_ID":28,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"NAME":[{"FEAT_DESC":"OCEANGUY","LIB_FEAT_ID":24,"FEAT_DESC_VALUES":[{"FEAT_DESC":"OCEANGUY","LIB_FEAT_ID":24,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"NAME_KEY":[{"FEAT_DESC":"ASNK","LIB_FEAT_ID":29,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK","LIB_FEAT_ID":29,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|ADDRESS.CITY_STD=TL","LIB_FEAT_ID":34,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|ADDRESS.CITY_STD=TL","LIB_FEAT_ID":34,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|DOB.MMDD_HASH=0906","LIB_FEAT_ID":32,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|DOB.MMDD_HASH=0906","LIB_FEAT_ID":32,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|DOB.MMYY_HASH=0683","LIB_FEAT_ID":30,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|DOB.MMYY_HASH=0683","LIB_FEAT_ID":30,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|DOB=80906","LIB_FEAT_ID":31,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|DOB=80906","LIB_FEAT_ID":31,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|PHONE.PHONE_LAST_5=10796","LIB_FEAT_ID":33,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|PHONE.PHONE_LAST_5=10796","LIB_FEAT_ID":33,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|POST=53543","LIB_FEAT_ID":36,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|POST=53543","LIB_FEAT_ID":36,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|SSN=5185","LIB_FEAT_ID":35,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|SSN=5185","LIB_FEAT_ID":35,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"PHONE":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5,"FEAT_DESC_VALUES":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"PHONE_KEY":[{"FEAT_DESC":"2256710796","LIB_FEAT_ID":21,"FEAT_DESC_VALUES":[{"FEAT_DESC":"2256710796","LIB_FEAT_ID":21,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"SEARCH_KEY":[{"FEAT_DESC":"LOGIN_ID:FLAVORH2|","LIB_FEAT_ID":40,"FEAT_DESC_VALUES":[{"FEAT_DESC":"LOGIN_ID:FLAVORH2|","LIB_FEAT_ID":40,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"SSN:5185|80906|","LIB_FEAT_ID":39,"FEAT_DESC_VALUES":[{"FEAT_DESC":"SSN:5185|80906|","LIB_FEAT_ID":39,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"SSN":[{"FEAT_DESC":"153-33-5185","LIB_FEAT_ID":27,"FEAT_DESC_VALUES":[{"FEAT_DESC":"153-33-5185","LIB_FEAT_ID":27,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}]},"RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 16:13:27.208","LAST_SEEN_DT":"2022-12-06 16:13:27.208"}],"LAST_SEEN_DT":"2022-12-06 16:13:27.208","RECORDS":[{"DATA_SOURCE":"TEST","RECORD_ID":"222","ENTITY_TYPE":"TEST","INTERNAL_ID":2,"ENTITY_KEY":"740BA22D15CA88462A930AF8A7C904FF5E48226C","ENTITY_DESC":"OCEANGUY","MATCH_KEY":"","MATCH_LEVEL":0,"MATCH_LEVEL_CODE":"","ERRULE_CODE":"","LAST_SEEN_DT":"2022-12-06 16:13:27.208","FEATURES":[{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":24},{"LIB_FEAT_ID":25},{"LIB_FEAT_ID":26},{"LIB_FEAT_ID":27},{"LIB_FEAT_ID":28},{"LIB_FEAT_ID":29},{"LIB_FEAT_ID":30},{"LIB_FEAT_ID":31},{"LIB_FEAT_ID":32},{"LIB_FEAT_ID":33},{"LIB_FEAT_ID":34},{"LIB_FEAT_ID":35},{"LIB_FEAT_ID":36},{"LIB_FEAT_ID":37},{"LIB_FEAT_ID":38},{"LIB_FEAT_ID":39},{"LIB_FEAT_ID":40}]}]},"RELATED_ENTITIES":[{"ENTITY_ID":1,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0,"ENTITY_NAME":"JOHNSON","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":6,"FIRST_SEEN_DT":"2022-12-06 16:13:27.135","LAST_SEEN_DT":"2022-12-06 16:13:27.916"}],"LAST_SEEN_DT":"2022-12-06 16:13:27.916"},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+ADDRESS+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0,"ENTITY_NAME":"Smith","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 16:13:27.272","LAST_SEEN_DT":"2022-12-06 16:13:27.272"}],"LAST_SEEN_DT":"2022-12-06 16:13:27.272"}]}]}` */ -func (client *G2engine) GetEntityByRecordID_V2(ctx context.Context, dataSourceCode string, recordID string, flags int64) (string, error) { +func (client *Szengine) WhyRecords(ctx context.Context, dataSourceCode1 string, recordId1 string, dataSourceCode2 string, recordId2 string, flags int64) (string, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(77, dataSourceCode, recordID, flags) + client.traceEntry(153, dataSourceCode1, recordId1, dataSourceCode2, recordId2) defer func() { - client.traceExit(78, dataSourceCode, recordID, flags, client.GetEntityByRecordID_V2Result, err, time.Since(entryTime)) + client.traceExit(154, dataSourceCode1, recordId1, dataSourceCode2, recordId2, client.WhyRecordsResult, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{ - "dataSourceCode": dataSourceCode, - "recordID": recordID, + "dataSourceCode1": dataSourceCode1, + "recordId1": recordId1, + "dataSourceCode2": dataSourceCode2, + "recordId2": recordId2, } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8038, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8073, err, details) }() } - return client.GetEntityByRecordID_V2Result, err + return client.WhyRecordsResult, err } +// ---------------------------------------------------------------------------- +// Public non-interface methods +// ---------------------------------------------------------------------------- + /* The GetObserverOrigin method returns the "origin" value of past Observer messages. @@ -1421,806 +1040,140 @@ Input Output - The value sent in the Observer's "origin" key/value pair. */ -func (client *G2engine) GetObserverOrigin(ctx context.Context) string { +func (client *Szengine) GetObserverOrigin(ctx context.Context) string { return client.observerOrigin } /* -The GetRecord method returns a JSON document of a single record from the Senzing repository. -To control output, use GetRecord_V2() instead. +The GetSdkId method returns the identifier of this particular Software Development Kit (SDK). +It is handy when working with multiple implementations of the same SzEengine interface. +For this implementation, "mock" is returned. Input - ctx: A context to control lifecycle. - - dataSourceCode: Identifies the provenance of the data. - - recordID: The unique identifier within the records of the same data source. - -Output - - A JSON document. - See the example output. */ -func (client *G2engine) GetRecord(ctx context.Context, dataSourceCode string, recordID string) (string, error) { +func (client *Szengine) GetSdkId(ctx context.Context) string { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(83, dataSourceCode, recordID) - defer func() { - client.traceExit(84, dataSourceCode, recordID, client.GetRecordResult, err, time.Since(entryTime)) - }() + client.traceEntry(161) + defer func() { client.traceExit(162, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { - details := map[string]string{ - "dataSourceCode": dataSourceCode, - "recordID": recordID, - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8039, err, details) + details := map[string]string{} + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8075, err, details) }() } - return client.GetRecordResult, err + return "mock" } /* -The GetRecord_V2 method returns a JSON document of a single record from the Senzing repository. -It extends GetRecord() by adding output control flags. +The Initialize method initializes the SzEngine object. +It must be called prior to any other calls. Input - ctx: A context to control lifecycle. - - dataSourceCode: Identifies the provenance of the data. - - recordID: The unique identifier within the records of the same data source. - - flags: Flags used to control information returned. - -Output - - A JSON document. - See the example output. + - instanceName: A name for the auditing node, to help identify it within system logs. + - settings: A JSON string containing configuration parameters. + - configId: The configuration ID used for the initialization. + - verboseLogging: A flag to enable deeper logging of the G2 processing. 0 for no Senzing logging; 1 for logging. */ -func (client *G2engine) GetRecord_V2(ctx context.Context, dataSourceCode string, recordID string, flags int64) (string, error) { +func (client *Szengine) Initialize(ctx context.Context, instanceName string, settings string, configId int64, verboseLogging int64) error { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(85, dataSourceCode, recordID, flags) - defer func() { - client.traceExit(86, dataSourceCode, recordID, flags, client.GetRecord_V2Result, err, time.Since(entryTime)) - }() + client.traceEntry(99, instanceName, settings, verboseLogging) + defer func() { client.traceExit(100, instanceName, settings, verboseLogging, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{ - "dataSourceCode": dataSourceCode, - "recordID": recordID, + "instanceName": instanceName, + "settings": settings, + "verboseLogging": strconv.FormatInt(verboseLogging, 10), } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8040, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8047, err, details) }() } - return client.GetRecord_V2Result, err + return err } /* -The GetRedoRecord method returns the next internally queued maintenance record from the Senzing repository. -Usually, the ProcessRedoRecord() or ProcessRedoRecordWithInfo() method is called to process the maintenance record -retrieved by GetRedoRecord(). +The RegisterObserver method adds the observer to the list of observers notified. Input - ctx: A context to control lifecycle. - -Output - - A JSON document. + - observer: The observer to be added. */ -func (client *G2engine) GetRedoRecord(ctx context.Context) (string, error) { +func (client *Szengine) RegisterObserver(ctx context.Context, observer observer.Observer) error { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(87) - defer func() { client.traceExit(88, client.GetRedoRecordResult, err, time.Since(entryTime)) }() + client.traceEntry(157, observer.GetObserverId(ctx)) + defer func() { client.traceExit(158, observer.GetObserverId(ctx), err, time.Since(entryTime)) }() + } + if client.observers == nil { + client.observers = &subject.SubjectImpl{} } + err = client.observers.RegisterObserver(ctx, observer) if client.observers != nil { go func() { - details := map[string]string{} - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8041, err, details) + details := map[string]string{ + "observerId": observer.GetObserverId(ctx), + } + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8076, err, details) }() } - return client.GetRedoRecordResult, err + return err } /* -The GetRepositoryLastModifiedTime method retrieves the last modified time of the Senzing repository, -measured in the number of seconds between the last modified time and January 1, 1970 12:00am GMT (epoch time). +The SetLogLevel method sets the level of logging. Input - ctx: A context to control lifecycle. - -Output - - A Unix Timestamp. + - logLevelName: The desired log level. TRACE, DEBUG, INFO, WARN, ERROR, FATAL or PANIC. */ -func (client *G2engine) GetRepositoryLastModifiedTime(ctx context.Context) (int64, error) { +func (client *Szengine) SetLogLevel(ctx context.Context, logLevelName string) error { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(89) - defer func() { client.traceExit(90, client.GetRepositoryLastModifiedTimeResult, err, time.Since(entryTime)) }() + client.traceEntry(137, logLevelName) + defer func() { client.traceExit(138, logLevelName, err, time.Since(entryTime)) }() } + err = client.getLogger().SetLogLevel(logLevelName) + client.isTrace = (logLevelName == logging.LevelTraceName) if client.observers != nil { go func() { - details := map[string]string{} - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8042, err, details) + details := map[string]string{ + "logLevelName": logLevelName, + } + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8077, err, details) }() } - return client.GetRepositoryLastModifiedTimeResult, err + return err } /* -The GetSdkId method returns the identifier of this particular Software Development Kit (SDK). -It is handy when working with multiple implementations of the same G2engineInterface. -For this implementation, "mock" is returned. +The SetObserverOrigin method sets the "origin" value in future Observer messages. + +Input + - ctx: A context to control lifecycle. + - origin: The value sent in the Observer's "origin" key/value pair. +*/ +func (client *Szengine) SetObserverOrigin(ctx context.Context, origin string) { + client.observerOrigin = origin +} + +/* +The UnregisterObserver method removes the observer to the list of observers notified. Input - ctx: A context to control lifecycle. + - observer: The observer to be added. */ -func (client *G2engine) GetSdkId(ctx context.Context) string { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(161) - defer func() { client.traceExit(162, err, time.Since(entryTime)) }() - } - if client.observers != nil { - go func() { - details := map[string]string{} - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8075, err, details) - }() - } - return "mock" -} - -/* -The GetVirtualEntityByRecordID method FIXME: -To control output, use GetVirtualEntityByRecordID_V2() instead. - -Input - - ctx: A context to control lifecycle. - - recordList: A JSON document. - -Output - - A JSON document. - Example: `{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"JOHNSON","FEATURES":{"ACCT_NUM":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8,"USAGE_TYPE":"CC","FEAT_DESC_VALUES":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ADDRESS":[{"FEAT_DESC":"772 Armstrong RD Delhi LA 71232","LIB_FEAT_ID":4,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772 Armstrong RD Delhi LA 71232","LIB_FEAT_ID":4,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"772 Armstrong RD Delhi WI 53543","LIB_FEAT_ID":26,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772 Armstrong RD Delhi WI 53543","LIB_FEAT_ID":26,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ADDR_KEY":[{"FEAT_DESC":"772|ARMSTRNK||53543","LIB_FEAT_ID":37,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772|ARMSTRNK||53543","LIB_FEAT_ID":37,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"772|ARMSTRNK||71232","LIB_FEAT_ID":18,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772|ARMSTRNK||71232","LIB_FEAT_ID":18,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"772|ARMSTRNK||TL","LIB_FEAT_ID":17,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772|ARMSTRNK||TL","LIB_FEAT_ID":17,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"DOB":[{"FEAT_DESC":"4/8/1983","LIB_FEAT_ID":2,"FEAT_DESC_VALUES":[{"FEAT_DESC":"4/8/1983","LIB_FEAT_ID":2,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"6/9/1983","LIB_FEAT_ID":25,"FEAT_DESC_VALUES":[{"FEAT_DESC":"6/9/1983","LIB_FEAT_ID":25,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"GENDER":[{"FEAT_DESC":"F","LIB_FEAT_ID":3,"FEAT_DESC_VALUES":[{"FEAT_DESC":"F","LIB_FEAT_ID":3,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ID_KEY":[{"FEAT_DESC":"ACCT_NUM=5534202208773608","LIB_FEAT_ID":19,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ACCT_NUM=5534202208773608","LIB_FEAT_ID":19,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"SSN=053-39-3251","LIB_FEAT_ID":20,"FEAT_DESC_VALUES":[{"FEAT_DESC":"SSN=053-39-3251","LIB_FEAT_ID":20,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"SSN=153-33-5185","LIB_FEAT_ID":38,"FEAT_DESC_VALUES":[{"FEAT_DESC":"SSN=153-33-5185","LIB_FEAT_ID":38,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"LOGIN_ID":[{"FEAT_DESC":"flavorh","LIB_FEAT_ID":7,"FEAT_DESC_VALUES":[{"FEAT_DESC":"flavorh","LIB_FEAT_ID":7,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"flavorh2","LIB_FEAT_ID":28,"FEAT_DESC_VALUES":[{"FEAT_DESC":"flavorh2","LIB_FEAT_ID":28,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"NAME":[{"FEAT_DESC":"JOHNSON","LIB_FEAT_ID":1,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JOHNSON","LIB_FEAT_ID":1,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"OCEANGUY","LIB_FEAT_ID":24,"FEAT_DESC_VALUES":[{"FEAT_DESC":"OCEANGUY","LIB_FEAT_ID":24,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"NAME_KEY":[{"FEAT_DESC":"ASNK","LIB_FEAT_ID":29,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK","LIB_FEAT_ID":29,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|ADDRESS.CITY_STD=TL","LIB_FEAT_ID":34,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|ADDRESS.CITY_STD=TL","LIB_FEAT_ID":34,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|DOB.MMDD_HASH=0906","LIB_FEAT_ID":32,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|DOB.MMDD_HASH=0906","LIB_FEAT_ID":32,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|DOB.MMYY_HASH=0683","LIB_FEAT_ID":30,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|DOB.MMYY_HASH=0683","LIB_FEAT_ID":30,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|DOB=80906","LIB_FEAT_ID":31,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|DOB=80906","LIB_FEAT_ID":31,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|PHONE.PHONE_LAST_5=10796","LIB_FEAT_ID":33,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|PHONE.PHONE_LAST_5=10796","LIB_FEAT_ID":33,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|POST=53543","LIB_FEAT_ID":36,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|POST=53543","LIB_FEAT_ID":36,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|SSN=5185","LIB_FEAT_ID":35,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|SSN=5185","LIB_FEAT_ID":35,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN","LIB_FEAT_ID":11,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN","LIB_FEAT_ID":11,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|ADDRESS.CITY_STD=TL","LIB_FEAT_ID":12,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|ADDRESS.CITY_STD=TL","LIB_FEAT_ID":12,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|DOB.MMDD_HASH=0804","LIB_FEAT_ID":9,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|DOB.MMDD_HASH=0804","LIB_FEAT_ID":9,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|DOB.MMYY_HASH=0483","LIB_FEAT_ID":10,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|DOB.MMYY_HASH=0483","LIB_FEAT_ID":10,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|DOB=80804","LIB_FEAT_ID":13,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|DOB=80804","LIB_FEAT_ID":13,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|PHONE.PHONE_LAST_5=10796","LIB_FEAT_ID":15,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|PHONE.PHONE_LAST_5=10796","LIB_FEAT_ID":15,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|POST=71232","LIB_FEAT_ID":14,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|POST=71232","LIB_FEAT_ID":14,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|SSN=3251","LIB_FEAT_ID":16,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|SSN=3251","LIB_FEAT_ID":16,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"PHONE":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5,"FEAT_DESC_VALUES":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"PHONE_KEY":[{"FEAT_DESC":"2256710796","LIB_FEAT_ID":21,"FEAT_DESC_VALUES":[{"FEAT_DESC":"2256710796","LIB_FEAT_ID":21,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"SEARCH_KEY":[{"FEAT_DESC":"LOGIN_ID:FLAVORH2|","LIB_FEAT_ID":40,"FEAT_DESC_VALUES":[{"FEAT_DESC":"LOGIN_ID:FLAVORH2|","LIB_FEAT_ID":40,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"LOGIN_ID:FLAVORH|","LIB_FEAT_ID":22,"FEAT_DESC_VALUES":[{"FEAT_DESC":"LOGIN_ID:FLAVORH|","LIB_FEAT_ID":22,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"SSN:3251|80804|","LIB_FEAT_ID":23,"FEAT_DESC_VALUES":[{"FEAT_DESC":"SSN:3251|80804|","LIB_FEAT_ID":23,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"SSN:5185|80906|","LIB_FEAT_ID":39,"FEAT_DESC_VALUES":[{"FEAT_DESC":"SSN:5185|80906|","LIB_FEAT_ID":39,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"SSN":[{"FEAT_DESC":"053-39-3251","LIB_FEAT_ID":6,"FEAT_DESC_VALUES":[{"FEAT_DESC":"053-39-3251","LIB_FEAT_ID":6,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"153-33-5185","LIB_FEAT_ID":27,"FEAT_DESC_VALUES":[{"FEAT_DESC":"153-33-5185","LIB_FEAT_ID":27,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}]},"RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":2,"FIRST_SEEN_DT":"2022-12-06 15:20:17.088","LAST_SEEN_DT":"2022-12-06 15:20:17.161"}],"LAST_SEEN_DT":"2022-12-06 15:20:17.161","RECORDS":[{"DATA_SOURCE":"TEST","RECORD_ID":"111","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","LAST_SEEN_DT":"2022-12-06 15:20:17.088","FEATURES":[{"LIB_FEAT_ID":1},{"LIB_FEAT_ID":2},{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":4},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":6},{"LIB_FEAT_ID":7},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":9},{"LIB_FEAT_ID":10},{"LIB_FEAT_ID":11},{"LIB_FEAT_ID":12},{"LIB_FEAT_ID":13},{"LIB_FEAT_ID":14},{"LIB_FEAT_ID":15},{"LIB_FEAT_ID":16},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":18},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":20},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":22},{"LIB_FEAT_ID":23}]},{"DATA_SOURCE":"TEST","RECORD_ID":"222","ENTITY_TYPE":"TEST","INTERNAL_ID":2,"ENTITY_KEY":"740BA22D15CA88462A930AF8A7C904FF5E48226C","ENTITY_DESC":"OCEANGUY","LAST_SEEN_DT":"2022-12-06 15:20:17.161","FEATURES":[{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":24},{"LIB_FEAT_ID":25},{"LIB_FEAT_ID":26},{"LIB_FEAT_ID":27},{"LIB_FEAT_ID":28},{"LIB_FEAT_ID":29},{"LIB_FEAT_ID":30},{"LIB_FEAT_ID":31},{"LIB_FEAT_ID":32},{"LIB_FEAT_ID":33},{"LIB_FEAT_ID":34},{"LIB_FEAT_ID":35},{"LIB_FEAT_ID":36},{"LIB_FEAT_ID":37},{"LIB_FEAT_ID":38},{"LIB_FEAT_ID":39},{"LIB_FEAT_ID":40}]}]}}` -*/ -func (client *G2engine) GetVirtualEntityByRecordID(ctx context.Context, recordList string) (string, error) { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(91, recordList) - defer func() { - client.traceExit(92, recordList, client.GetVirtualEntityByRecordIDResult, err, time.Since(entryTime)) - }() - } - if client.observers != nil { - go func() { - details := map[string]string{ - "recordList": recordList, - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8043, err, details) - }() - } - return client.GetVirtualEntityByRecordIDResult, err -} - -/* -The GetVirtualEntityByRecordID_V2 method FIXME: -It extends GetVirtualEntityByRecordID() by adding output control flags. - -Input - - ctx: A context to control lifecycle. - - recordList: A JSON document. - Example: `{"RECORDS": [{"DATA_SOURCE": "TEST","RECORD_ID": "111"},{"DATA_SOURCE": "TEST","RECORD_ID": "222"}]}` - - flags: Flags used to control information returned. - -Output - - A JSON document. - See the example output. -*/ -func (client *G2engine) GetVirtualEntityByRecordID_V2(ctx context.Context, recordList string, flags int64) (string, error) { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(93, recordList, flags) - defer func() { - client.traceExit(94, recordList, flags, client.GetVirtualEntityByRecordID_V2Result, err, time.Since(entryTime)) - }() - } - if client.observers != nil { - go func() { - details := map[string]string{ - "recordList": recordList, - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8044, err, details) - }() - } - return client.GetVirtualEntityByRecordID_V2Result, err -} - -/* -The HowEntityByEntityID method FIXME: -To control output, use HowEntityByEntityID_V2() instead. - -Input - - ctx: A context to control lifecycle. - - entityID: The unique identifier of an entity. - -Output - - A JSON document. - See the example output. -*/ -func (client *G2engine) HowEntityByEntityID(ctx context.Context, entityID int64) (string, error) { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(95, entityID) - defer func() { client.traceExit(96, entityID, client.HowEntityByEntityIDResult, err, time.Since(entryTime)) }() - } - if client.observers != nil { - go func() { - details := map[string]string{ - "entityID": strconv.FormatInt(entityID, 10), - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8045, err, details) - }() - } - return client.HowEntityByEntityIDResult, err -} - -/* -The HowEntityByEntityID_V2 method FIXME: -It extends HowEntityByEntityID() by adding output control flags. - -Input - - ctx: A context to control lifecycle. - - entityID: The unique identifier of an entity. - - flags: Flags used to control information returned. - -Output - - A JSON document. - See the example output. -*/ -func (client *G2engine) HowEntityByEntityID_V2(ctx context.Context, entityID int64, flags int64) (string, error) { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(97, entityID, flags) - defer func() { - client.traceExit(98, entityID, flags, client.HowEntityByEntityID_V2Result, err, time.Since(entryTime)) - }() - } - if client.observers != nil { - go func() { - details := map[string]string{ - "entityID": strconv.FormatInt(entityID, 10), - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8046, err, details) - }() - } - return client.HowEntityByEntityID_V2Result, err -} - -/* -The Init method initializes the Senzing G2 object. -It must be called prior to any other calls. - -Input - - ctx: A context to control lifecycle. - - moduleName: A name for the auditing node, to help identify it within system logs. - - iniParams: A JSON string containing configuration parameters. - - verboseLogging: A flag to enable deeper logging of the G2 processing. 0 for no Senzing logging; 1 for logging. -*/ -func (client *G2engine) Init(ctx context.Context, moduleName string, iniParams string, verboseLogging int64) error { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(99, moduleName, iniParams, verboseLogging) - defer func() { client.traceExit(100, moduleName, iniParams, verboseLogging, err, time.Since(entryTime)) }() - } - if client.observers != nil { - go func() { - details := map[string]string{ - "iniParams": iniParams, - "moduleName": moduleName, - "verboseLogging": strconv.FormatInt(verboseLogging, 10), - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8047, err, details) - }() - } - return err -} - -/* -The InitWithConfigID method initializes the Senzing G2 object with a non-default configuration ID. -It must be called prior to any other calls. - -Input - - ctx: A context to control lifecycle. - - moduleName: A name for the auditing node, to help identify it within system logs. - - iniParams: A JSON string containing configuration parameters. - - initConfigID: The configuration ID used for the initialization. - - verboseLogging: A flag to enable deeper logging of the G2 processing. 0 for no Senzing logging; 1 for logging. -*/ -func (client *G2engine) InitWithConfigID(ctx context.Context, moduleName string, iniParams string, initConfigID int64, verboseLogging int64) error { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(101, moduleName, iniParams, initConfigID, verboseLogging) - defer func() { - client.traceExit(102, moduleName, iniParams, initConfigID, verboseLogging, err, time.Since(entryTime)) - }() - } - if client.observers != nil { - go func() { - details := map[string]string{ - "iniParams": iniParams, - "initConfigID": strconv.FormatInt(initConfigID, 10), - "moduleName": moduleName, - "verboseLogging": strconv.FormatInt(verboseLogging, 10), - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8048, err, details) - }() - } - return err -} - -/* -The PrimeEngine method pre-initializes some of the heavier weight internal resources of the G2 engine. -The G2 Engine uses "lazy initialization". -PrimeEngine() forces initialization. - -Input - - ctx: A context to control lifecycle. -*/ -func (client *G2engine) PrimeEngine(ctx context.Context) error { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(103) - defer func() { client.traceExit(104, err, time.Since(entryTime)) }() - } - if client.observers != nil { - go func() { - details := map[string]string{} - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8049, err, details) - }() - } - return err -} - -/* -The ProcessRedoRecord method processes the next redo record and returns it. -Calling ProcessRedoRecord() has the potential to create more redo records in certain situations. - -Input - - ctx: A context to control lifecycle. - -Output - - A JSON document. -*/ -// func (client *G2engine) ProcessRedoRecord(ctx context.Context) (string, error) { -// var err error = nil -// entryTime := time.Now() -// if client.isTrace { -// client.traceEntry(107) -// defer func() { client.traceExit(108, client.ProcessRedoRecordResult, err, time.Since(entryTime)) }() -// } -// if client.observers != nil { -// go func() { -// details := map[string]string{} -// notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8051, err, details) -// }() -// } -// return client.ProcessRedoRecordResult, err -// } - -/* -The ProcessRedoRecordWithInfo method processes the next redo record and returns it and affected entities. -Calling ProcessRedoRecordWithInfo() has the potential to create more redo records in certain situations. - -Input - - ctx: A context to control lifecycle. - - flags: Flags used to control information returned. - -Output - - A JSON document with the record that was re-done. - - A JSON document with affected entities. -*/ -// func (client *G2engine) ProcessRedoRecordWithInfo(ctx context.Context, flags int64) (string, string, error) { -// var err error = nil -// entryTime := time.Now() -// if client.isTrace { -// client.traceEntry(109, flags) -// defer func() { -// client.traceExit(110, flags, client.ProcessRedoRecordWithInfoResult, client.ProcessRedoRecordWithInfoResultWithInfo, err, time.Since(entryTime)) -// }() -// } -// if client.observers != nil { -// go func() { -// details := map[string]string{} -// notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8052, err, details) -// }() -// } -// return client.ProcessRedoRecordWithInfoResult, client.ProcessRedoRecordWithInfoResultWithInfo, err -// } - -/* -The ReevaluateEntity method FIXME: - -Input - - ctx: A context to control lifecycle. - - entityID: The unique identifier of an entity. - - flags: Flags used to control information returned. -*/ -func (client *G2engine) ReevaluateEntity(ctx context.Context, entityID int64, flags int64) error { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(119, entityID, flags) - defer func() { client.traceExit(120, entityID, flags, err, time.Since(entryTime)) }() - } - if client.observers != nil { - go func() { - details := map[string]string{ - "entityID": strconv.FormatInt(entityID, 10), - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8057, err, details) - }() - } - return err -} - -/* -The ReevaluateEntityWithInfo method FIXME: - -Input - - ctx: A context to control lifecycle. - - entityID: The unique identifier of an entity. - - flags: Flags used to control information returned. - -Output - - - A JSON document. - See the example output. -*/ -func (client *G2engine) ReevaluateEntityWithInfo(ctx context.Context, entityID int64, flags int64) (string, error) { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(121, entityID, flags) - defer func() { - client.traceExit(122, entityID, flags, client.ReevaluateEntityWithInfoResult, err, time.Since(entryTime)) - }() - } - if client.observers != nil { - go func() { - details := map[string]string{ - "entityID": strconv.FormatInt(entityID, 10), - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8058, err, details) - }() - } - return client.ReevaluateEntityWithInfoResult, err -} - -/* -The ReevaluateRecord method FIXME: - -Input - - ctx: A context to control lifecycle. - - dataSourceCode: Identifies the provenance of the data. - - recordID: The unique identifier within the records of the same data source. - - flags: Flags used to control information returned. -*/ -func (client *G2engine) ReevaluateRecord(ctx context.Context, dataSourceCode string, recordID string, flags int64) error { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(123, dataSourceCode, recordID, flags) - defer func() { client.traceExit(124, dataSourceCode, recordID, flags, err, time.Since(entryTime)) }() - } - if client.observers != nil { - go func() { - details := map[string]string{ - "dataSourceCode": dataSourceCode, - "recordID": recordID, - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8059, err, details) - }() - } - return err -} - -/* -The ReevaluateRecordWithInfo method FIXME: - -Input - - ctx: A context to control lifecycle. - - dataSourceCode: Identifies the provenance of the data. - - recordID: The unique identifier within the records of the same data source. - - flags: Flags used to control information returned. - -Output - - - A JSON document. - See the example output. -*/ -func (client *G2engine) ReevaluateRecordWithInfo(ctx context.Context, dataSourceCode string, recordID string, flags int64) (string, error) { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(125, dataSourceCode, recordID, flags) - defer func() { - client.traceExit(126, dataSourceCode, recordID, flags, client.ReevaluateRecordWithInfoResult, err, time.Since(entryTime)) - }() - } - if client.observers != nil { - go func() { - details := map[string]string{ - "dataSourceCode": dataSourceCode, - "recordID": recordID, - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8060, err, details) - }() - } - return client.ReevaluateRecordWithInfoResult, err -} - -/* -The RegisterObserver method adds the observer to the list of observers notified. - -Input - - ctx: A context to control lifecycle. - - observer: The observer to be added. -*/ -func (client *G2engine) RegisterObserver(ctx context.Context, observer observer.Observer) error { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(157, observer.GetObserverId(ctx)) - defer func() { client.traceExit(158, observer.GetObserverId(ctx), err, time.Since(entryTime)) }() - } - if client.observers == nil { - client.observers = &subject.SubjectImpl{} - } - err = client.observers.RegisterObserver(ctx, observer) - if client.observers != nil { - go func() { - details := map[string]string{ - "observerID": observer.GetObserverId(ctx), - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8076, err, details) - }() - } - return err -} - -/* -The Reinit method re-initializes the Senzing G2Engine object using a specified configuration identifier. - -Input - - ctx: A context to control lifecycle. - - initConfigID: The configuration ID used for the initialization. -*/ -func (client *G2engine) Reinit(ctx context.Context, initConfigID int64) error { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(127, initConfigID) - defer func() { client.traceExit(128, initConfigID, err, time.Since(entryTime)) }() - } - if client.observers != nil { - go func() { - details := map[string]string{ - "initConfigID": strconv.FormatInt(initConfigID, 10), - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8061, err, details) - }() - } - return err -} - -/* -The ReplaceRecord method updates/replaces a record in the Senzing repository. -If record doesn't exist, a new record is added to the data repository. - -Input - - ctx: A context to control lifecycle. - - dataSourceCode: Identifies the provenance of the data. - - recordID: The unique identifier within the records of the same data source. - - jsonData: A JSON document containing the record to be added to the Senzing repository. - - loadID: An identifier used to distinguish different load batches/sessions. An empty string is acceptable. -*/ -func (client *G2engine) ReplaceRecord(ctx context.Context, dataSourceCode string, recordID string, jsonData string, loadID string) error { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(129, dataSourceCode, recordID, jsonData, loadID) - defer func() { client.traceExit(130, dataSourceCode, recordID, jsonData, loadID, err, time.Since(entryTime)) }() - } - if client.observers != nil { - go func() { - details := map[string]string{ - "dataSourceCode": dataSourceCode, - "recordID": recordID, - "loadID": loadID, - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8062, err, details) - }() - } - return err -} - -/* -The ReplaceRecordWithInfo method updates/replaces a record in the Senzing repository and returns information on the affected entities. -If record doesn't exist, a new record is added to the data repository. - -Input - - ctx: A context to control lifecycle. - - dataSourceCode: Identifies the provenance of the data. - - recordID: The unique identifier within the records of the same data source. - - jsonData: A JSON document containing the record to be added to the Senzing repository. - - loadID: An identifier used to distinguish different load batches/sessions. An empty string is acceptable. - - flags: Flags used to control information returned. - -Output - - A JSON document. - See the example output. -*/ -func (client *G2engine) ReplaceRecordWithInfo(ctx context.Context, dataSourceCode string, recordID string, jsonData string, loadID string, flags int64) (string, error) { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(131, dataSourceCode, recordID, jsonData, loadID, flags) - defer func() { - client.traceExit(132, dataSourceCode, recordID, jsonData, loadID, flags, client.ReplaceRecordWithInfoResult, err, time.Since(entryTime)) - }() - } - if client.observers != nil { - go func() { - details := map[string]string{ - "dataSourceCode": dataSourceCode, - "recordID": recordID, - "loadID": loadID, - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8063, err, details) - }() - } - return client.ReplaceRecordWithInfoResult, err -} - -/* -The SearchByAttributes method retrieves entity data based on a user-specified set of entity attributes. -To control output, use SearchByAttributes_V2() instead. - -Input - - ctx: A context to control lifecycle. - - jsonData: A JSON document containing the record to be added to the Senzing repository. - -Output - - A JSON document. - Example: `{"RESOLVED_ENTITIES":[{"MATCH_INFO":{"MATCH_LEVEL":1,"MATCH_LEVEL_CODE":"RESOLVED","MATCH_KEY":"+NAME+SSN","ERRULE_CODE":"SF1_PNAME_CSTAB","FEATURE_SCORES":{"NAME":[{"INBOUND_FEAT":"JOHNSON","CANDIDATE_FEAT":"JOHNSON","GNR_FN":100,"GNR_SN":100,"GNR_GN":70,"GENERATION_MATCH":-1,"GNR_ON":-1}],"SSN":[{"INBOUND_FEAT":"053-39-3251","CANDIDATE_FEAT":"053-39-3251","FULL_SCORE":100}]}},"ENTITY":{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"JOHNSON","FEATURES":{"ACCT_NUM":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8,"USAGE_TYPE":"CC","FEAT_DESC_VALUES":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8}]}],"ADDRESS":[{"FEAT_DESC":"772 Armstrong RD Delhi LA 71232","LIB_FEAT_ID":4,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772 Armstrong RD Delhi LA 71232","LIB_FEAT_ID":4}]}],"DOB":[{"FEAT_DESC":"4/8/1983","LIB_FEAT_ID":2,"FEAT_DESC_VALUES":[{"FEAT_DESC":"4/8/1983","LIB_FEAT_ID":2}]},{"FEAT_DESC":"4/8/1985","LIB_FEAT_ID":100001,"FEAT_DESC_VALUES":[{"FEAT_DESC":"4/8/1985","LIB_FEAT_ID":100001}]}],"GENDER":[{"FEAT_DESC":"F","LIB_FEAT_ID":3,"FEAT_DESC_VALUES":[{"FEAT_DESC":"F","LIB_FEAT_ID":3}]}],"LOGIN_ID":[{"FEAT_DESC":"flavorh","LIB_FEAT_ID":7,"FEAT_DESC_VALUES":[{"FEAT_DESC":"flavorh","LIB_FEAT_ID":7}]}],"NAME":[{"FEAT_DESC":"JOHNSON","LIB_FEAT_ID":1,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JOHNSON","LIB_FEAT_ID":1}]}],"PHONE":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5,"FEAT_DESC_VALUES":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5}]}],"SSN":[{"FEAT_DESC":"053-39-3251","LIB_FEAT_ID":6,"FEAT_DESC_VALUES":[{"FEAT_DESC":"053-39-3251","LIB_FEAT_ID":6}]}]},"RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":6,"FIRST_SEEN_DT":"2022-12-06 15:38:06.175","LAST_SEEN_DT":"2022-12-06 15:38:06.957"}],"LAST_SEEN_DT":"2022-12-06 15:38:06.957"}}}]}` -*/ -func (client *G2engine) SearchByAttributes(ctx context.Context, jsonData string) (string, error) { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(133, jsonData) - defer func() { client.traceExit(134, jsonData, client.SearchByAttributesResult, err, time.Since(entryTime)) }() - } - if client.observers != nil { - go func() { - details := map[string]string{} - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8064, err, details) - }() - } - return client.SearchByAttributesResult, err -} - -/* -The SearchByAttributes_V2 method retrieves entity data based on a user-specified set of entity attributes. -It extends SearchByAttributes() by adding output control flags. - -Input - - ctx: A context to control lifecycle. - - jsonData: A JSON document containing the record to be added to the Senzing repository. - - flags: Flags used to control information returned. - -Output - - A JSON document. - See the example output. -*/ -func (client *G2engine) SearchByAttributes_V2(ctx context.Context, jsonData string, flags int64) (string, error) { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(135, jsonData, flags) - defer func() { - client.traceExit(136, jsonData, flags, client.SearchByAttributes_V2Result, err, time.Since(entryTime)) - }() - } - if client.observers != nil { - go func() { - details := map[string]string{} - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8065, err, details) - }() - } - return client.SearchByAttributes_V2Result, err -} - -/* -The SetLogLevel method sets the level of logging. - -Input - - ctx: A context to control lifecycle. - - logLevel: The desired log level. TRACE, DEBUG, INFO, WARN, ERROR, FATAL or PANIC. -*/ -func (client *G2engine) SetLogLevel(ctx context.Context, logLevelName string) error { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(137, logLevelName) - defer func() { client.traceExit(138, logLevelName, err, time.Since(entryTime)) }() - } - err = client.getLogger().SetLogLevel(logLevelName) - client.isTrace = (logLevelName == logging.LevelTraceName) - if client.observers != nil { - go func() { - details := map[string]string{ - "logLevel": logLevelName, - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8077, err, details) - }() - } - return err -} - -/* -The SetObserverOrigin method sets the "origin" value in future Observer messages. - -Input - - ctx: A context to control lifecycle. - - origin: The value sent in the Observer's "origin" key/value pair. -*/ -func (client *G2engine) SetObserverOrigin(ctx context.Context, origin string) { - client.observerOrigin = origin -} - -/* -The Stats method retrieves workload statistics for the current process. -These statistics will automatically reset after retrieval. - -Input - - ctx: A context to control lifecycle. - -Output - - A JSON document. - Example: `{"workload":{"loadedRecords":5,"addedRecords":2,"deletedRecords":0,"reevaluations":0,"repairedEntities":0,"duration":56,"retries":0,"candidates":19,"actualAmbiguousTest":0,"cachedAmbiguousTest":0,"libFeatCacheHit":219,"libFeatCacheMiss":73,"unresolveTest":1,"abortedUnresolve":0,"gnrScorersUsed":1,"unresolveTriggers":{"normalResolve":0,"update":0,"relLink":0,"extensiveResolve":0,"ambiguousNoResolve":1,"ambiguousMultiResolve":0},"reresolveTriggers":{"abortRetry":0,"unresolveMovement":0,"multipleResolvableCandidates":0,"resolveNewFeatures":1,"newFeatureFTypes":[{"DOB":1}]},"reresolveSkipped":0,"filteredObsFeat":0,"expressedFeatureCalls":[{"EFCALL_ID":1,"EFUNC_CODE":"PHONE_HASHER","numCalls":1},{"EFCALL_ID":2,"EFUNC_CODE":"EXPRESS_ID","numCalls":1},{"EFCALL_ID":3,"EFUNC_CODE":"EXPRESS_ID","numCalls":1},{"EFCALL_ID":5,"EFUNC_CODE":"EXPRESS_BOM","numCalls":1},{"EFCALL_ID":7,"EFUNC_CODE":"NAME_HASHER","numCalls":4},{"EFCALL_ID":9,"EFUNC_CODE":"ADDR_HASHER","numCalls":1},{"EFCALL_ID":10,"EFUNC_CODE":"EXPRESS_BOM","numCalls":1},{"EFCALL_ID":14,"EFUNC_CODE":"EXPRESS_ID","numCalls":1},{"EFCALL_ID":16,"EFUNC_CODE":"EXPRESS_ID","numCalls":4}],"expressedFeaturesCreated":[{"ADDR_KEY":2},{"ID_KEY":7},{"NAME_KEY":14},{"PHONE_KEY":1},{"SEARCH_KEY":2}],"scoredPairs":[{"ACCT_NUM":16},{"ADDRESS":16},{"DOB":25},{"GENDER":16},{"LOGIN_ID":16},{"NAME":19},{"PHONE":16},{"SSN":19}],"cacheHit":[{"ADDRESS":12},{"DOB":18},{"NAME":13},{"PHONE":15}],"cacheMiss":[{"ADDRESS":4},{"DOB":7},{"NAME":6},{"PHONE":1}],"redoTriggers":[],"latchContention":[],"highContentionFeat":[],"highContentionResEnt":[],"genericDetect":[],"candidateBuilders":[{"ACCT_NUM":7},{"ADDR_KEY":7},{"DOB":7},{"ID_KEY":9},{"LOGIN_ID":7},{"NAME_KEY":9},{"PHONE":7},{"PHONE_KEY":7},{"SEARCH_KEY":7},{"SSN":9}],"suppressedCandidateBuilders":[],"suppressedScoredFeatureType":[],"reducedScoredFeatureType":[],"suppressedDisclosedRelationshipDomainCount":0,"CorruptEntityTestDiagnosis":{},"threadState":{"active":0,"idle":4,"sqlExecuting":0,"loader":0,"resolver":0,"scoring":0,"dataLatchContention":0,"obsEntContention":0,"resEntContention":0},"systemResources":{"initResources":[{"physicalCores":16},{"logicalCores":16},{"totalMemory":"62.6GB"},{"availableMemory":"49.5GB"}],"currResources":[{"availableMemory":"47.4GB"},{"activeThreads":0},{"workerThreads":4},{"systemLoad":[{"cpuUser":13.442277},{"cpuSystem":2.635741},{"cpuIdle":82.024246},{"cpuWait":1.634159},{"cpuSoftIrq":0.263574}]}]}}}` -*/ -func (client *G2engine) Stats(ctx context.Context) (string, error) { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(139) - defer func() { client.traceExit(140, client.StatsResult, err, time.Since(entryTime)) }() - } - if client.observers != nil { - go func() { - details := map[string]string{} - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8066, err, details) - }() - } - return client.StatsResult, err -} - -/* -The UnregisterObserver method removes the observer to the list of observers notified.g2config - -Input - - ctx: A context to control lifecycle. - - observer: The observer to be added. -*/ -func (client *G2engine) UnregisterObserver(ctx context.Context, observer observer.Observer) error { +func (client *Szengine) UnregisterObserver(ctx context.Context, observer observer.Observer) error { var err error = nil if client.isTrace { entryTime := time.Now() @@ -2233,7 +1186,7 @@ func (client *G2engine) UnregisterObserver(ctx context.Context, observer observe // In client.notify, each observer will get notified in a goroutine. // Then client.observers may be set to nil, but observer goroutines will be OK. details := map[string]string{ - "observerID": observer.GetObserverId(ctx), + "observerId": observer.GetObserverId(ctx), } notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8078, err, details) } @@ -2244,155 +1197,33 @@ func (client *G2engine) UnregisterObserver(ctx context.Context, observer observe return err } -/* -The WhyEntities method explains why records belong to their resolved entities. -WhyEntities() will compare the record data within an entity -against the rest of the entity data and show why they are connected. -This is calculated based on the features that record data represents. -To control output, use WhyEntities_V2() instead. - -Input - - ctx: A context to control lifecycle. - - entityID1: The entity ID for the starting entity of the search path. - - entityID2: The entity ID for the ending entity of the search path. - -Output - - A JSON document. - Example: `{"WHY_RESULTS":[{"ENTITY_ID":1,"ENTITY_ID_2":2,"MATCH_INFO":{"WHY_KEY":"+PHONE+ACCT_NUM-SSN","WHY_ERRULE_CODE":"SF1","MATCH_LEVEL_CODE":"POSSIBLY_RELATED","CANDIDATE_KEYS":{"ACCT_NUM":[{"FEAT_ID":8,"FEAT_DESC":"5534202208773608"}],"ADDR_KEY":[{"FEAT_ID":17,"FEAT_DESC":"772|ARMSTRNK||TL"}],"ID_KEY":[{"FEAT_ID":19,"FEAT_DESC":"ACCT_NUM=5534202208773608"}],"PHONE":[{"FEAT_ID":5,"FEAT_DESC":"225-671-0796"}],"PHONE_KEY":[{"FEAT_ID":21,"FEAT_DESC":"2256710796"}]},"DISCLOSED_RELATIONS":{},"FEATURE_SCORES":{"ACCT_NUM":[{"INBOUND_FEAT_ID":8,"INBOUND_FEAT":"5534202208773608","INBOUND_FEAT_USAGE_TYPE":"CC","CANDIDATE_FEAT_ID":8,"CANDIDATE_FEAT":"5534202208773608","CANDIDATE_FEAT_USAGE_TYPE":"CC","FULL_SCORE":100,"SCORE_BUCKET":"SAME","SCORE_BEHAVIOR":"F1"}],"ADDRESS":[{"INBOUND_FEAT_ID":4,"INBOUND_FEAT":"772 Armstrong RD Delhi LA 71232","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":26,"CANDIDATE_FEAT":"772 Armstrong RD Delhi WI 53543","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":81,"SCORE_BUCKET":"LIKELY","SCORE_BEHAVIOR":"FF"}],"DOB":[{"INBOUND_FEAT_ID":100001,"INBOUND_FEAT":"4/8/1985","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":25,"CANDIDATE_FEAT":"6/9/1983","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":79,"SCORE_BUCKET":"NO_CHANCE","SCORE_BEHAVIOR":"FMES"},{"INBOUND_FEAT_ID":2,"INBOUND_FEAT":"4/8/1983","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":25,"CANDIDATE_FEAT":"6/9/1983","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":86,"SCORE_BUCKET":"PLAUSIBLE","SCORE_BEHAVIOR":"FMES"}],"GENDER":[{"INBOUND_FEAT_ID":3,"INBOUND_FEAT":"F","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":3,"CANDIDATE_FEAT":"F","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":100,"SCORE_BUCKET":"SAME","SCORE_BEHAVIOR":"FVME"}],"LOGIN_ID":[{"INBOUND_FEAT_ID":7,"INBOUND_FEAT":"flavorh","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":28,"CANDIDATE_FEAT":"flavorh2","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":0,"SCORE_BUCKET":"NO_CHANCE","SCORE_BEHAVIOR":"F1"}],"NAME":[{"INBOUND_FEAT_ID":1,"INBOUND_FEAT":"JOHNSON","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":24,"CANDIDATE_FEAT":"OCEANGUY","CANDIDATE_FEAT_USAGE_TYPE":"","GNR_FN":33,"GNR_SN":32,"GNR_GN":70,"GENERATION_MATCH":-1,"GNR_ON":-1,"SCORE_BUCKET":"NO_CHANCE","SCORE_BEHAVIOR":"NAME"}],"PHONE":[{"INBOUND_FEAT_ID":5,"INBOUND_FEAT":"225-671-0796","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":5,"CANDIDATE_FEAT":"225-671-0796","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":100,"SCORE_BUCKET":"SAME","SCORE_BEHAVIOR":"FF"}],"SSN":[{"INBOUND_FEAT_ID":6,"INBOUND_FEAT":"053-39-3251","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":27,"CANDIDATE_FEAT":"153-33-5185","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":0,"SCORE_BUCKET":"NO_CHANCE","SCORE_BEHAVIOR":"F1ES"}]}}}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"JOHNSON","FEATURES":{"ACCT_NUM":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8,"USAGE_TYPE":"CC","FEAT_DESC_VALUES":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ADDRESS":[{"FEAT_DESC":"772 Armstrong RD Delhi LA 71232","LIB_FEAT_ID":4,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772 Armstrong RD Delhi LA 71232","LIB_FEAT_ID":4,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ADDR_KEY":[{"FEAT_DESC":"772|ARMSTRNK||71232","LIB_FEAT_ID":18,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772|ARMSTRNK||71232","LIB_FEAT_ID":18,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"772|ARMSTRNK||TL","LIB_FEAT_ID":17,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772|ARMSTRNK||TL","LIB_FEAT_ID":17,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"DOB":[{"FEAT_DESC":"4/8/1983","LIB_FEAT_ID":2,"FEAT_DESC_VALUES":[{"FEAT_DESC":"4/8/1983","LIB_FEAT_ID":2,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"4/8/1985","LIB_FEAT_ID":100001,"FEAT_DESC_VALUES":[{"FEAT_DESC":"4/8/1985","LIB_FEAT_ID":100001,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"GENDER":[{"FEAT_DESC":"F","LIB_FEAT_ID":3,"FEAT_DESC_VALUES":[{"FEAT_DESC":"F","LIB_FEAT_ID":3,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ID_KEY":[{"FEAT_DESC":"ACCT_NUM=5534202208773608","LIB_FEAT_ID":19,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ACCT_NUM=5534202208773608","LIB_FEAT_ID":19,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"SSN=053-39-3251","LIB_FEAT_ID":20,"FEAT_DESC_VALUES":[{"FEAT_DESC":"SSN=053-39-3251","LIB_FEAT_ID":20,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"LOGIN_ID":[{"FEAT_DESC":"flavorh","LIB_FEAT_ID":7,"FEAT_DESC_VALUES":[{"FEAT_DESC":"flavorh","LIB_FEAT_ID":7,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"NAME":[{"FEAT_DESC":"JOHNSON","LIB_FEAT_ID":1,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JOHNSON","LIB_FEAT_ID":1,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"NAME_KEY":[{"FEAT_DESC":"JNSN","LIB_FEAT_ID":11,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN","LIB_FEAT_ID":11,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|ADDRESS.CITY_STD=TL","LIB_FEAT_ID":12,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|ADDRESS.CITY_STD=TL","LIB_FEAT_ID":12,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|DOB.MMDD_HASH=0804","LIB_FEAT_ID":9,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|DOB.MMDD_HASH=0804","LIB_FEAT_ID":9,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|DOB.MMYY_HASH=0483","LIB_FEAT_ID":10,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|DOB.MMYY_HASH=0483","LIB_FEAT_ID":10,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|DOB.MMYY_HASH=0485","LIB_FEAT_ID":100002,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|DOB.MMYY_HASH=0485","LIB_FEAT_ID":100002,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|DOB=80804","LIB_FEAT_ID":13,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|DOB=80804","LIB_FEAT_ID":13,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|PHONE.PHONE_LAST_5=10796","LIB_FEAT_ID":15,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|PHONE.PHONE_LAST_5=10796","LIB_FEAT_ID":15,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|POST=71232","LIB_FEAT_ID":14,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|POST=71232","LIB_FEAT_ID":14,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|SSN=3251","LIB_FEAT_ID":16,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|SSN=3251","LIB_FEAT_ID":16,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"PHONE":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5,"FEAT_DESC_VALUES":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"PHONE_KEY":[{"FEAT_DESC":"2256710796","LIB_FEAT_ID":21,"FEAT_DESC_VALUES":[{"FEAT_DESC":"2256710796","LIB_FEAT_ID":21,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"SEARCH_KEY":[{"FEAT_DESC":"LOGIN_ID:FLAVORH|","LIB_FEAT_ID":22,"FEAT_DESC_VALUES":[{"FEAT_DESC":"LOGIN_ID:FLAVORH|","LIB_FEAT_ID":22,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"SSN:3251|80804|","LIB_FEAT_ID":23,"FEAT_DESC_VALUES":[{"FEAT_DESC":"SSN:3251|80804|","LIB_FEAT_ID":23,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"SSN":[{"FEAT_DESC":"053-39-3251","LIB_FEAT_ID":6,"FEAT_DESC_VALUES":[{"FEAT_DESC":"053-39-3251","LIB_FEAT_ID":6,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}]},"RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":6,"FIRST_SEEN_DT":"2022-12-06 15:58:57.129","LAST_SEEN_DT":"2022-12-06 15:58:57.906"}],"LAST_SEEN_DT":"2022-12-06 15:58:57.906","RECORDS":[{"DATA_SOURCE":"TEST","RECORD_ID":"111","ENTITY_TYPE":"TEST","INTERNAL_ID":100001,"ENTITY_KEY":"A6C927986DF7329D1D2CDE0E8F34328AE640FB7E","ENTITY_DESC":"JOHNSON","MATCH_KEY":"","MATCH_LEVEL":0,"MATCH_LEVEL_CODE":"","ERRULE_CODE":"","LAST_SEEN_DT":"2022-12-06 15:58:57.906","FEATURES":[{"LIB_FEAT_ID":1},{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":4},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":6},{"LIB_FEAT_ID":7},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":9},{"LIB_FEAT_ID":11},{"LIB_FEAT_ID":12},{"LIB_FEAT_ID":13},{"LIB_FEAT_ID":14},{"LIB_FEAT_ID":15},{"LIB_FEAT_ID":16},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":18},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":20},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":22},{"LIB_FEAT_ID":23},{"LIB_FEAT_ID":100001},{"LIB_FEAT_ID":100002}]},{"DATA_SOURCE":"TEST","RECORD_ID":"444","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"+NAME+ADDRESS+PHONE+SSN+LOGIN_ID+ACCT_NUM","MATCH_LEVEL":1,"MATCH_LEVEL_CODE":"RESOLVED","ERRULE_CODE":"SF1_PNAME_CFF_CSTAB","LAST_SEEN_DT":"2022-12-06 15:58:57.400","FEATURES":[{"LIB_FEAT_ID":1},{"LIB_FEAT_ID":2},{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":4},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":6},{"LIB_FEAT_ID":7},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":9},{"LIB_FEAT_ID":10},{"LIB_FEAT_ID":11},{"LIB_FEAT_ID":12},{"LIB_FEAT_ID":13},{"LIB_FEAT_ID":14},{"LIB_FEAT_ID":15},{"LIB_FEAT_ID":16},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":18},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":20},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":22},{"LIB_FEAT_ID":23}]},{"DATA_SOURCE":"TEST","RECORD_ID":"555","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"+NAME+ADDRESS+PHONE+SSN+LOGIN_ID+ACCT_NUM","MATCH_LEVEL":1,"MATCH_LEVEL_CODE":"RESOLVED","ERRULE_CODE":"SF1_PNAME_CFF_CSTAB","LAST_SEEN_DT":"2022-12-06 15:58:57.404","FEATURES":[{"LIB_FEAT_ID":1},{"LIB_FEAT_ID":2},{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":4},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":6},{"LIB_FEAT_ID":7},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":9},{"LIB_FEAT_ID":10},{"LIB_FEAT_ID":11},{"LIB_FEAT_ID":12},{"LIB_FEAT_ID":13},{"LIB_FEAT_ID":14},{"LIB_FEAT_ID":15},{"LIB_FEAT_ID":16},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":18},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":20},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":22},{"LIB_FEAT_ID":23}]},{"DATA_SOURCE":"TEST","RECORD_ID":"666","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"+NAME+ADDRESS+PHONE+SSN+LOGIN_ID+ACCT_NUM","MATCH_LEVEL":1,"MATCH_LEVEL_CODE":"RESOLVED","ERRULE_CODE":"SF1_PNAME_CFF_CSTAB","LAST_SEEN_DT":"2022-12-06 15:58:57.407","FEATURES":[{"LIB_FEAT_ID":1},{"LIB_FEAT_ID":2},{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":4},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":6},{"LIB_FEAT_ID":7},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":9},{"LIB_FEAT_ID":10},{"LIB_FEAT_ID":11},{"LIB_FEAT_ID":12},{"LIB_FEAT_ID":13},{"LIB_FEAT_ID":14},{"LIB_FEAT_ID":15},{"LIB_FEAT_ID":16},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":18},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":20},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":22},{"LIB_FEAT_ID":23}]},{"DATA_SOURCE":"TEST","RECORD_ID":"777","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"+NAME+ADDRESS+PHONE+SSN+LOGIN_ID+ACCT_NUM","MATCH_LEVEL":1,"MATCH_LEVEL_CODE":"RESOLVED","ERRULE_CODE":"SF1_PNAME_CFF_CSTAB","LAST_SEEN_DT":"2022-12-06 15:58:57.410","FEATURES":[{"LIB_FEAT_ID":1},{"LIB_FEAT_ID":2},{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":4},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":6},{"LIB_FEAT_ID":7},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":9},{"LIB_FEAT_ID":10},{"LIB_FEAT_ID":11},{"LIB_FEAT_ID":12},{"LIB_FEAT_ID":13},{"LIB_FEAT_ID":14},{"LIB_FEAT_ID":15},{"LIB_FEAT_ID":16},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":18},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":20},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":22},{"LIB_FEAT_ID":23}]},{"DATA_SOURCE":"TEST","RECORD_ID":"FCCE9793DAAD23159DBCCEB97FF2745B92CE7919","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"+NAME+ADDRESS+PHONE+SSN+LOGIN_ID+ACCT_NUM","MATCH_LEVEL":1,"MATCH_LEVEL_CODE":"RESOLVED","ERRULE_CODE":"SF1_PNAME_CFF_CSTAB","LAST_SEEN_DT":"2022-12-06 15:58:57.259","FEATURES":[{"LIB_FEAT_ID":1},{"LIB_FEAT_ID":2},{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":4},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":6},{"LIB_FEAT_ID":7},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":9},{"LIB_FEAT_ID":10},{"LIB_FEAT_ID":11},{"LIB_FEAT_ID":12},{"LIB_FEAT_ID":13},{"LIB_FEAT_ID":14},{"LIB_FEAT_ID":15},{"LIB_FEAT_ID":16},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":18},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":20},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":22},{"LIB_FEAT_ID":23}]}]},"RELATED_ENTITIES":[{"ENTITY_ID":2,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0,"ENTITY_NAME":"OCEANGUY","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 15:58:57.201","LAST_SEEN_DT":"2022-12-06 15:58:57.201"}],"LAST_SEEN_DT":"2022-12-06 15:58:57.201"},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0,"ENTITY_NAME":"Smith","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 15:58:57.263","LAST_SEEN_DT":"2022-12-06 15:58:57.263"}],"LAST_SEEN_DT":"2022-12-06 15:58:57.263"}]},{"RESOLVED_ENTITY":{"ENTITY_ID":2,"ENTITY_NAME":"OCEANGUY","FEATURES":{"ACCT_NUM":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8,"USAGE_TYPE":"CC","FEAT_DESC_VALUES":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ADDRESS":[{"FEAT_DESC":"772 Armstrong RD Delhi WI 53543","LIB_FEAT_ID":26,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772 Armstrong RD Delhi WI 53543","LIB_FEAT_ID":26,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ADDR_KEY":[{"FEAT_DESC":"772|ARMSTRNK||53543","LIB_FEAT_ID":37,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772|ARMSTRNK||53543","LIB_FEAT_ID":37,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"772|ARMSTRNK||TL","LIB_FEAT_ID":17,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772|ARMSTRNK||TL","LIB_FEAT_ID":17,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"DOB":[{"FEAT_DESC":"6/9/1983","LIB_FEAT_ID":25,"FEAT_DESC_VALUES":[{"FEAT_DESC":"6/9/1983","LIB_FEAT_ID":25,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"GENDER":[{"FEAT_DESC":"F","LIB_FEAT_ID":3,"FEAT_DESC_VALUES":[{"FEAT_DESC":"F","LIB_FEAT_ID":3,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ID_KEY":[{"FEAT_DESC":"ACCT_NUM=5534202208773608","LIB_FEAT_ID":19,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ACCT_NUM=5534202208773608","LIB_FEAT_ID":19,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"SSN=153-33-5185","LIB_FEAT_ID":38,"FEAT_DESC_VALUES":[{"FEAT_DESC":"SSN=153-33-5185","LIB_FEAT_ID":38,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"LOGIN_ID":[{"FEAT_DESC":"flavorh2","LIB_FEAT_ID":28,"FEAT_DESC_VALUES":[{"FEAT_DESC":"flavorh2","LIB_FEAT_ID":28,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"NAME":[{"FEAT_DESC":"OCEANGUY","LIB_FEAT_ID":24,"FEAT_DESC_VALUES":[{"FEAT_DESC":"OCEANGUY","LIB_FEAT_ID":24,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"NAME_KEY":[{"FEAT_DESC":"ASNK","LIB_FEAT_ID":29,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK","LIB_FEAT_ID":29,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|ADDRESS.CITY_STD=TL","LIB_FEAT_ID":34,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|ADDRESS.CITY_STD=TL","LIB_FEAT_ID":34,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|DOB.MMDD_HASH=0906","LIB_FEAT_ID":32,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|DOB.MMDD_HASH=0906","LIB_FEAT_ID":32,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|DOB.MMYY_HASH=0683","LIB_FEAT_ID":30,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|DOB.MMYY_HASH=0683","LIB_FEAT_ID":30,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|DOB=80906","LIB_FEAT_ID":31,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|DOB=80906","LIB_FEAT_ID":31,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|PHONE.PHONE_LAST_5=10796","LIB_FEAT_ID":33,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|PHONE.PHONE_LAST_5=10796","LIB_FEAT_ID":33,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|POST=53543","LIB_FEAT_ID":36,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|POST=53543","LIB_FEAT_ID":36,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|SSN=5185","LIB_FEAT_ID":35,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|SSN=5185","LIB_FEAT_ID":35,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"PHONE":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5,"FEAT_DESC_VALUES":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"PHONE_KEY":[{"FEAT_DESC":"2256710796","LIB_FEAT_ID":21,"FEAT_DESC_VALUES":[{"FEAT_DESC":"2256710796","LIB_FEAT_ID":21,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"SEARCH_KEY":[{"FEAT_DESC":"LOGIN_ID:FLAVORH2|","LIB_FEAT_ID":40,"FEAT_DESC_VALUES":[{"FEAT_DESC":"LOGIN_ID:FLAVORH2|","LIB_FEAT_ID":40,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"SSN:5185|80906|","LIB_FEAT_ID":39,"FEAT_DESC_VALUES":[{"FEAT_DESC":"SSN:5185|80906|","LIB_FEAT_ID":39,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"SSN":[{"FEAT_DESC":"153-33-5185","LIB_FEAT_ID":27,"FEAT_DESC_VALUES":[{"FEAT_DESC":"153-33-5185","LIB_FEAT_ID":27,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}]},"RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 15:58:57.201","LAST_SEEN_DT":"2022-12-06 15:58:57.201"}],"LAST_SEEN_DT":"2022-12-06 15:58:57.201","RECORDS":[{"DATA_SOURCE":"TEST","RECORD_ID":"222","ENTITY_TYPE":"TEST","INTERNAL_ID":2,"ENTITY_KEY":"740BA22D15CA88462A930AF8A7C904FF5E48226C","ENTITY_DESC":"OCEANGUY","MATCH_KEY":"","MATCH_LEVEL":0,"MATCH_LEVEL_CODE":"","ERRULE_CODE":"","LAST_SEEN_DT":"2022-12-06 15:58:57.201","FEATURES":[{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":24},{"LIB_FEAT_ID":25},{"LIB_FEAT_ID":26},{"LIB_FEAT_ID":27},{"LIB_FEAT_ID":28},{"LIB_FEAT_ID":29},{"LIB_FEAT_ID":30},{"LIB_FEAT_ID":31},{"LIB_FEAT_ID":32},{"LIB_FEAT_ID":33},{"LIB_FEAT_ID":34},{"LIB_FEAT_ID":35},{"LIB_FEAT_ID":36},{"LIB_FEAT_ID":37},{"LIB_FEAT_ID":38},{"LIB_FEAT_ID":39},{"LIB_FEAT_ID":40}]}]},"RELATED_ENTITIES":[{"ENTITY_ID":1,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0,"ENTITY_NAME":"JOHNSON","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":6,"FIRST_SEEN_DT":"2022-12-06 15:58:57.129","LAST_SEEN_DT":"2022-12-06 15:58:57.906"}],"LAST_SEEN_DT":"2022-12-06 15:58:57.906"},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+ADDRESS+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0,"ENTITY_NAME":"Smith","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 15:58:57.263","LAST_SEEN_DT":"2022-12-06 15:58:57.263"}],"LAST_SEEN_DT":"2022-12-06 15:58:57.263"}]}]}` -*/ -func (client *G2engine) WhyEntities(ctx context.Context, entityID1 int64, entityID2 int64) (string, error) { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(141, entityID1, entityID2) - defer func() { - client.traceExit(142, entityID1, entityID2, client.WhyEntitiesResult, err, time.Since(entryTime)) - }() - } - if client.observers != nil { - go func() { - details := map[string]string{ - "entityID1": strconv.FormatInt(entityID1, 10), - "entityID2": strconv.FormatInt(entityID2, 10), - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8067, err, details) - }() - } - return client.WhyEntitiesResult, err -} - -/* -The WhyEntities_V2 method explains why records belong to their resolved entities. -WhyEntities_V2() will compare the record data within an entity -against the rest of the entity data and show why they are connected. -This is calculated based on the features that record data represents. -It extends WhyEntities() by adding output control flags. +// ---------------------------------------------------------------------------- +// Internal methods +// ---------------------------------------------------------------------------- -Input - - ctx: A context to control lifecycle. - - entityID1: The entity ID for the starting entity of the search path. - - entityID2: The entity ID for the ending entity of the search path. - - flags: Flags used to control information returned. +// --- Logging ---------------------------------------------------------------- -Output - - A JSON document. - See the example output. -*/ -func (client *G2engine) WhyEntities_V2(ctx context.Context, entityID1 int64, entityID2 int64, flags int64) (string, error) { +// Get the Logger singleton. +func (client *Szengine) getLogger() logging.LoggingInterface { var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(143, entityID1, entityID2, flags) - defer func() { - client.traceExit(144, entityID1, entityID2, flags, client.WhyEntities_V2Result, err, time.Since(entryTime)) - }() - } - if client.observers != nil { - go func() { - details := map[string]string{ - "entityID1": strconv.FormatInt(entityID1, 10), - "entityID2": strconv.FormatInt(entityID2, 10), - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8068, err, details) - }() + if client.logger == nil { + options := []interface{}{ + &logging.OptionCallerSkip{Value: 4}, + } + client.logger, err = logging.NewSenzingSdkLogger(ComponentId, szengineapi.IdMessages, options...) + if err != nil { + panic(err) + } } - return client.WhyEntities_V2Result, err + return client.logger } -/* -The WhyRecords method explains why records belong to their resolved entities. -To control output, use WhyRecords_V2() instead. - -Input - - ctx: A context to control lifecycle. - - dataSourceCode1: Identifies the provenance of the data. - - recordID1: The unique identifier within the records of the same data source. - - dataSourceCode2: Identifies the provenance of the data. - - recordID2: The unique identifier within the records of the same data source. - -Output - - - A JSON document. - Example: `{"WHY_RESULTS":[{"INTERNAL_ID":100001,"ENTITY_ID":1,"FOCUS_RECORDS":[{"DATA_SOURCE":"TEST","RECORD_ID":"111"}],"INTERNAL_ID_2":2,"ENTITY_ID_2":2,"FOCUS_RECORDS_2":[{"DATA_SOURCE":"TEST","RECORD_ID":"222"}],"MATCH_INFO":{"WHY_KEY":"+PHONE+ACCT_NUM-DOB-SSN","WHY_ERRULE_CODE":"SF1","MATCH_LEVEL_CODE":"POSSIBLY_RELATED","CANDIDATE_KEYS":{"ACCT_NUM":[{"FEAT_ID":8,"FEAT_DESC":"5534202208773608"}],"ADDR_KEY":[{"FEAT_ID":17,"FEAT_DESC":"772|ARMSTRNK||TL"}],"ID_KEY":[{"FEAT_ID":19,"FEAT_DESC":"ACCT_NUM=5534202208773608"}],"PHONE":[{"FEAT_ID":5,"FEAT_DESC":"225-671-0796"}],"PHONE_KEY":[{"FEAT_ID":21,"FEAT_DESC":"2256710796"}]},"DISCLOSED_RELATIONS":{},"FEATURE_SCORES":{"ACCT_NUM":[{"INBOUND_FEAT_ID":8,"INBOUND_FEAT":"5534202208773608","INBOUND_FEAT_USAGE_TYPE":"CC","CANDIDATE_FEAT_ID":8,"CANDIDATE_FEAT":"5534202208773608","CANDIDATE_FEAT_USAGE_TYPE":"CC","FULL_SCORE":100,"SCORE_BUCKET":"SAME","SCORE_BEHAVIOR":"F1"}],"ADDRESS":[{"INBOUND_FEAT_ID":4,"INBOUND_FEAT":"772 Armstrong RD Delhi LA 71232","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":26,"CANDIDATE_FEAT":"772 Armstrong RD Delhi WI 53543","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":81,"SCORE_BUCKET":"LIKELY","SCORE_BEHAVIOR":"FF"}],"DOB":[{"INBOUND_FEAT_ID":100001,"INBOUND_FEAT":"4/8/1985","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":25,"CANDIDATE_FEAT":"6/9/1983","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":79,"SCORE_BUCKET":"NO_CHANCE","SCORE_BEHAVIOR":"FMES"}],"GENDER":[{"INBOUND_FEAT_ID":3,"INBOUND_FEAT":"F","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":3,"CANDIDATE_FEAT":"F","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":100,"SCORE_BUCKET":"SAME","SCORE_BEHAVIOR":"FVME"}],"LOGIN_ID":[{"INBOUND_FEAT_ID":7,"INBOUND_FEAT":"flavorh","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":28,"CANDIDATE_FEAT":"flavorh2","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":0,"SCORE_BUCKET":"NO_CHANCE","SCORE_BEHAVIOR":"F1"}],"NAME":[{"INBOUND_FEAT_ID":1,"INBOUND_FEAT":"JOHNSON","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":24,"CANDIDATE_FEAT":"OCEANGUY","CANDIDATE_FEAT_USAGE_TYPE":"","GNR_FN":33,"GNR_SN":32,"GNR_GN":70,"GENERATION_MATCH":-1,"GNR_ON":-1,"SCORE_BUCKET":"NO_CHANCE","SCORE_BEHAVIOR":"NAME"}],"PHONE":[{"INBOUND_FEAT_ID":5,"INBOUND_FEAT":"225-671-0796","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":5,"CANDIDATE_FEAT":"225-671-0796","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":100,"SCORE_BUCKET":"SAME","SCORE_BEHAVIOR":"FF"}],"SSN":[{"INBOUND_FEAT_ID":6,"INBOUND_FEAT":"053-39-3251","INBOUND_FEAT_USAGE_TYPE":"","CANDIDATE_FEAT_ID":27,"CANDIDATE_FEAT":"153-33-5185","CANDIDATE_FEAT_USAGE_TYPE":"","FULL_SCORE":0,"SCORE_BUCKET":"NO_CHANCE","SCORE_BEHAVIOR":"F1ES"}]}}}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1,"ENTITY_NAME":"JOHNSON","FEATURES":{"ACCT_NUM":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8,"USAGE_TYPE":"CC","FEAT_DESC_VALUES":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ADDRESS":[{"FEAT_DESC":"772 Armstrong RD Delhi LA 71232","LIB_FEAT_ID":4,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772 Armstrong RD Delhi LA 71232","LIB_FEAT_ID":4,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ADDR_KEY":[{"FEAT_DESC":"772|ARMSTRNK||71232","LIB_FEAT_ID":18,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772|ARMSTRNK||71232","LIB_FEAT_ID":18,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"772|ARMSTRNK||TL","LIB_FEAT_ID":17,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772|ARMSTRNK||TL","LIB_FEAT_ID":17,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"DOB":[{"FEAT_DESC":"4/8/1983","LIB_FEAT_ID":2,"FEAT_DESC_VALUES":[{"FEAT_DESC":"4/8/1983","LIB_FEAT_ID":2,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"4/8/1985","LIB_FEAT_ID":100001,"FEAT_DESC_VALUES":[{"FEAT_DESC":"4/8/1985","LIB_FEAT_ID":100001,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"GENDER":[{"FEAT_DESC":"F","LIB_FEAT_ID":3,"FEAT_DESC_VALUES":[{"FEAT_DESC":"F","LIB_FEAT_ID":3,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ID_KEY":[{"FEAT_DESC":"ACCT_NUM=5534202208773608","LIB_FEAT_ID":19,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ACCT_NUM=5534202208773608","LIB_FEAT_ID":19,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"SSN=053-39-3251","LIB_FEAT_ID":20,"FEAT_DESC_VALUES":[{"FEAT_DESC":"SSN=053-39-3251","LIB_FEAT_ID":20,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"LOGIN_ID":[{"FEAT_DESC":"flavorh","LIB_FEAT_ID":7,"FEAT_DESC_VALUES":[{"FEAT_DESC":"flavorh","LIB_FEAT_ID":7,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"NAME":[{"FEAT_DESC":"JOHNSON","LIB_FEAT_ID":1,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JOHNSON","LIB_FEAT_ID":1,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"NAME_KEY":[{"FEAT_DESC":"JNSN","LIB_FEAT_ID":11,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN","LIB_FEAT_ID":11,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|ADDRESS.CITY_STD=TL","LIB_FEAT_ID":12,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|ADDRESS.CITY_STD=TL","LIB_FEAT_ID":12,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|DOB.MMDD_HASH=0804","LIB_FEAT_ID":9,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|DOB.MMDD_HASH=0804","LIB_FEAT_ID":9,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|DOB.MMYY_HASH=0483","LIB_FEAT_ID":10,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|DOB.MMYY_HASH=0483","LIB_FEAT_ID":10,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|DOB.MMYY_HASH=0485","LIB_FEAT_ID":100002,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|DOB.MMYY_HASH=0485","LIB_FEAT_ID":100002,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|DOB=80804","LIB_FEAT_ID":13,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|DOB=80804","LIB_FEAT_ID":13,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|PHONE.PHONE_LAST_5=10796","LIB_FEAT_ID":15,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|PHONE.PHONE_LAST_5=10796","LIB_FEAT_ID":15,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|POST=71232","LIB_FEAT_ID":14,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|POST=71232","LIB_FEAT_ID":14,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"JNSN|SSN=3251","LIB_FEAT_ID":16,"FEAT_DESC_VALUES":[{"FEAT_DESC":"JNSN|SSN=3251","LIB_FEAT_ID":16,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"PHONE":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5,"FEAT_DESC_VALUES":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"PHONE_KEY":[{"FEAT_DESC":"2256710796","LIB_FEAT_ID":21,"FEAT_DESC_VALUES":[{"FEAT_DESC":"2256710796","LIB_FEAT_ID":21,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"SEARCH_KEY":[{"FEAT_DESC":"LOGIN_ID:FLAVORH|","LIB_FEAT_ID":22,"FEAT_DESC_VALUES":[{"FEAT_DESC":"LOGIN_ID:FLAVORH|","LIB_FEAT_ID":22,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"SSN:3251|80804|","LIB_FEAT_ID":23,"FEAT_DESC_VALUES":[{"FEAT_DESC":"SSN:3251|80804|","LIB_FEAT_ID":23,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"SSN":[{"FEAT_DESC":"053-39-3251","LIB_FEAT_ID":6,"FEAT_DESC_VALUES":[{"FEAT_DESC":"053-39-3251","LIB_FEAT_ID":6,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}]},"RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":6,"FIRST_SEEN_DT":"2022-12-06 16:13:27.135","LAST_SEEN_DT":"2022-12-06 16:13:27.916"}],"LAST_SEEN_DT":"2022-12-06 16:13:27.916","RECORDS":[{"DATA_SOURCE":"TEST","RECORD_ID":"111","ENTITY_TYPE":"TEST","INTERNAL_ID":100001,"ENTITY_KEY":"A6C927986DF7329D1D2CDE0E8F34328AE640FB7E","ENTITY_DESC":"JOHNSON","MATCH_KEY":"","MATCH_LEVEL":0,"MATCH_LEVEL_CODE":"","ERRULE_CODE":"","LAST_SEEN_DT":"2022-12-06 16:13:27.916","FEATURES":[{"LIB_FEAT_ID":1},{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":4},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":6},{"LIB_FEAT_ID":7},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":9},{"LIB_FEAT_ID":11},{"LIB_FEAT_ID":12},{"LIB_FEAT_ID":13},{"LIB_FEAT_ID":14},{"LIB_FEAT_ID":15},{"LIB_FEAT_ID":16},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":18},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":20},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":22},{"LIB_FEAT_ID":23},{"LIB_FEAT_ID":100001},{"LIB_FEAT_ID":100002}]},{"DATA_SOURCE":"TEST","RECORD_ID":"444","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"+NAME+ADDRESS+PHONE+SSN+LOGIN_ID+ACCT_NUM","MATCH_LEVEL":1,"MATCH_LEVEL_CODE":"RESOLVED","ERRULE_CODE":"SF1_PNAME_CFF_CSTAB","LAST_SEEN_DT":"2022-12-06 16:13:27.405","FEATURES":[{"LIB_FEAT_ID":1},{"LIB_FEAT_ID":2},{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":4},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":6},{"LIB_FEAT_ID":7},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":9},{"LIB_FEAT_ID":10},{"LIB_FEAT_ID":11},{"LIB_FEAT_ID":12},{"LIB_FEAT_ID":13},{"LIB_FEAT_ID":14},{"LIB_FEAT_ID":15},{"LIB_FEAT_ID":16},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":18},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":20},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":22},{"LIB_FEAT_ID":23}]},{"DATA_SOURCE":"TEST","RECORD_ID":"555","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"+NAME+ADDRESS+PHONE+SSN+LOGIN_ID+ACCT_NUM","MATCH_LEVEL":1,"MATCH_LEVEL_CODE":"RESOLVED","ERRULE_CODE":"SF1_PNAME_CFF_CSTAB","LAST_SEEN_DT":"2022-12-06 16:13:27.408","FEATURES":[{"LIB_FEAT_ID":1},{"LIB_FEAT_ID":2},{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":4},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":6},{"LIB_FEAT_ID":7},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":9},{"LIB_FEAT_ID":10},{"LIB_FEAT_ID":11},{"LIB_FEAT_ID":12},{"LIB_FEAT_ID":13},{"LIB_FEAT_ID":14},{"LIB_FEAT_ID":15},{"LIB_FEAT_ID":16},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":18},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":20},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":22},{"LIB_FEAT_ID":23}]},{"DATA_SOURCE":"TEST","RECORD_ID":"666","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"+NAME+ADDRESS+PHONE+SSN+LOGIN_ID+ACCT_NUM","MATCH_LEVEL":1,"MATCH_LEVEL_CODE":"RESOLVED","ERRULE_CODE":"SF1_PNAME_CFF_CSTAB","LAST_SEEN_DT":"2022-12-06 16:13:27.411","FEATURES":[{"LIB_FEAT_ID":1},{"LIB_FEAT_ID":2},{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":4},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":6},{"LIB_FEAT_ID":7},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":9},{"LIB_FEAT_ID":10},{"LIB_FEAT_ID":11},{"LIB_FEAT_ID":12},{"LIB_FEAT_ID":13},{"LIB_FEAT_ID":14},{"LIB_FEAT_ID":15},{"LIB_FEAT_ID":16},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":18},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":20},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":22},{"LIB_FEAT_ID":23}]},{"DATA_SOURCE":"TEST","RECORD_ID":"777","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"+NAME+ADDRESS+PHONE+SSN+LOGIN_ID+ACCT_NUM","MATCH_LEVEL":1,"MATCH_LEVEL_CODE":"RESOLVED","ERRULE_CODE":"SF1_PNAME_CFF_CSTAB","LAST_SEEN_DT":"2022-12-06 16:13:27.418","FEATURES":[{"LIB_FEAT_ID":1},{"LIB_FEAT_ID":2},{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":4},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":6},{"LIB_FEAT_ID":7},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":9},{"LIB_FEAT_ID":10},{"LIB_FEAT_ID":11},{"LIB_FEAT_ID":12},{"LIB_FEAT_ID":13},{"LIB_FEAT_ID":14},{"LIB_FEAT_ID":15},{"LIB_FEAT_ID":16},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":18},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":20},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":22},{"LIB_FEAT_ID":23}]},{"DATA_SOURCE":"TEST","RECORD_ID":"FCCE9793DAAD23159DBCCEB97FF2745B92CE7919","ENTITY_TYPE":"TEST","INTERNAL_ID":1,"ENTITY_KEY":"C6063D4396612FBA7324DB0739273BA1FE815C43","ENTITY_DESC":"JOHNSON","MATCH_KEY":"+NAME+ADDRESS+PHONE+SSN+LOGIN_ID+ACCT_NUM","MATCH_LEVEL":1,"MATCH_LEVEL_CODE":"RESOLVED","ERRULE_CODE":"SF1_PNAME_CFF_CSTAB","LAST_SEEN_DT":"2022-12-06 16:13:27.265","FEATURES":[{"LIB_FEAT_ID":1},{"LIB_FEAT_ID":2},{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":4},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":6},{"LIB_FEAT_ID":7},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":9},{"LIB_FEAT_ID":10},{"LIB_FEAT_ID":11},{"LIB_FEAT_ID":12},{"LIB_FEAT_ID":13},{"LIB_FEAT_ID":14},{"LIB_FEAT_ID":15},{"LIB_FEAT_ID":16},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":18},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":20},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":22},{"LIB_FEAT_ID":23}]}]},"RELATED_ENTITIES":[{"ENTITY_ID":2,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0,"ENTITY_NAME":"OCEANGUY","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 16:13:27.208","LAST_SEEN_DT":"2022-12-06 16:13:27.208"}],"LAST_SEEN_DT":"2022-12-06 16:13:27.208"},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0,"ENTITY_NAME":"Smith","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 16:13:27.272","LAST_SEEN_DT":"2022-12-06 16:13:27.272"}],"LAST_SEEN_DT":"2022-12-06 16:13:27.272"}]},{"RESOLVED_ENTITY":{"ENTITY_ID":2,"ENTITY_NAME":"OCEANGUY","FEATURES":{"ACCT_NUM":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8,"USAGE_TYPE":"CC","FEAT_DESC_VALUES":[{"FEAT_DESC":"5534202208773608","LIB_FEAT_ID":8,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ADDRESS":[{"FEAT_DESC":"772 Armstrong RD Delhi WI 53543","LIB_FEAT_ID":26,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772 Armstrong RD Delhi WI 53543","LIB_FEAT_ID":26,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ADDR_KEY":[{"FEAT_DESC":"772|ARMSTRNK||53543","LIB_FEAT_ID":37,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772|ARMSTRNK||53543","LIB_FEAT_ID":37,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"772|ARMSTRNK||TL","LIB_FEAT_ID":17,"FEAT_DESC_VALUES":[{"FEAT_DESC":"772|ARMSTRNK||TL","LIB_FEAT_ID":17,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"DOB":[{"FEAT_DESC":"6/9/1983","LIB_FEAT_ID":25,"FEAT_DESC_VALUES":[{"FEAT_DESC":"6/9/1983","LIB_FEAT_ID":25,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"GENDER":[{"FEAT_DESC":"F","LIB_FEAT_ID":3,"FEAT_DESC_VALUES":[{"FEAT_DESC":"F","LIB_FEAT_ID":3,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"ID_KEY":[{"FEAT_DESC":"ACCT_NUM=5534202208773608","LIB_FEAT_ID":19,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ACCT_NUM=5534202208773608","LIB_FEAT_ID":19,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"SSN=153-33-5185","LIB_FEAT_ID":38,"FEAT_DESC_VALUES":[{"FEAT_DESC":"SSN=153-33-5185","LIB_FEAT_ID":38,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"LOGIN_ID":[{"FEAT_DESC":"flavorh2","LIB_FEAT_ID":28,"FEAT_DESC_VALUES":[{"FEAT_DESC":"flavorh2","LIB_FEAT_ID":28,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"NAME":[{"FEAT_DESC":"OCEANGUY","LIB_FEAT_ID":24,"FEAT_DESC_VALUES":[{"FEAT_DESC":"OCEANGUY","LIB_FEAT_ID":24,"USED_FOR_CAND":"N","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"NAME_KEY":[{"FEAT_DESC":"ASNK","LIB_FEAT_ID":29,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK","LIB_FEAT_ID":29,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|ADDRESS.CITY_STD=TL","LIB_FEAT_ID":34,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|ADDRESS.CITY_STD=TL","LIB_FEAT_ID":34,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|DOB.MMDD_HASH=0906","LIB_FEAT_ID":32,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|DOB.MMDD_HASH=0906","LIB_FEAT_ID":32,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|DOB.MMYY_HASH=0683","LIB_FEAT_ID":30,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|DOB.MMYY_HASH=0683","LIB_FEAT_ID":30,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|DOB=80906","LIB_FEAT_ID":31,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|DOB=80906","LIB_FEAT_ID":31,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|PHONE.PHONE_LAST_5=10796","LIB_FEAT_ID":33,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|PHONE.PHONE_LAST_5=10796","LIB_FEAT_ID":33,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|POST=53543","LIB_FEAT_ID":36,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|POST=53543","LIB_FEAT_ID":36,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"ASNK|SSN=5185","LIB_FEAT_ID":35,"FEAT_DESC_VALUES":[{"FEAT_DESC":"ASNK|SSN=5185","LIB_FEAT_ID":35,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"PHONE":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5,"FEAT_DESC_VALUES":[{"FEAT_DESC":"225-671-0796","LIB_FEAT_ID":5,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"PHONE_KEY":[{"FEAT_DESC":"2256710796","LIB_FEAT_ID":21,"FEAT_DESC_VALUES":[{"FEAT_DESC":"2256710796","LIB_FEAT_ID":21,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":3,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"SEARCH_KEY":[{"FEAT_DESC":"LOGIN_ID:FLAVORH2|","LIB_FEAT_ID":40,"FEAT_DESC_VALUES":[{"FEAT_DESC":"LOGIN_ID:FLAVORH2|","LIB_FEAT_ID":40,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]},{"FEAT_DESC":"SSN:5185|80906|","LIB_FEAT_ID":39,"FEAT_DESC_VALUES":[{"FEAT_DESC":"SSN:5185|80906|","LIB_FEAT_ID":39,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"N","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}],"SSN":[{"FEAT_DESC":"153-33-5185","LIB_FEAT_ID":27,"FEAT_DESC_VALUES":[{"FEAT_DESC":"153-33-5185","LIB_FEAT_ID":27,"USED_FOR_CAND":"Y","USED_FOR_SCORING":"Y","ENTITY_COUNT":1,"CANDIDATE_CAP_REACHED":"N","SCORING_CAP_REACHED":"N","SUPPRESSED":"N"}]}]},"RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 16:13:27.208","LAST_SEEN_DT":"2022-12-06 16:13:27.208"}],"LAST_SEEN_DT":"2022-12-06 16:13:27.208","RECORDS":[{"DATA_SOURCE":"TEST","RECORD_ID":"222","ENTITY_TYPE":"TEST","INTERNAL_ID":2,"ENTITY_KEY":"740BA22D15CA88462A930AF8A7C904FF5E48226C","ENTITY_DESC":"OCEANGUY","MATCH_KEY":"","MATCH_LEVEL":0,"MATCH_LEVEL_CODE":"","ERRULE_CODE":"","LAST_SEEN_DT":"2022-12-06 16:13:27.208","FEATURES":[{"LIB_FEAT_ID":3},{"LIB_FEAT_ID":5},{"LIB_FEAT_ID":8,"USAGE_TYPE":"CC"},{"LIB_FEAT_ID":17},{"LIB_FEAT_ID":19},{"LIB_FEAT_ID":21},{"LIB_FEAT_ID":24},{"LIB_FEAT_ID":25},{"LIB_FEAT_ID":26},{"LIB_FEAT_ID":27},{"LIB_FEAT_ID":28},{"LIB_FEAT_ID":29},{"LIB_FEAT_ID":30},{"LIB_FEAT_ID":31},{"LIB_FEAT_ID":32},{"LIB_FEAT_ID":33},{"LIB_FEAT_ID":34},{"LIB_FEAT_ID":35},{"LIB_FEAT_ID":36},{"LIB_FEAT_ID":37},{"LIB_FEAT_ID":38},{"LIB_FEAT_ID":39},{"LIB_FEAT_ID":40}]}]},"RELATED_ENTITIES":[{"ENTITY_ID":1,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+PHONE+ACCT_NUM-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0,"ENTITY_NAME":"JOHNSON","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":6,"FIRST_SEEN_DT":"2022-12-06 16:13:27.135","LAST_SEEN_DT":"2022-12-06 16:13:27.916"}],"LAST_SEEN_DT":"2022-12-06 16:13:27.916"},{"ENTITY_ID":3,"MATCH_LEVEL":3,"MATCH_LEVEL_CODE":"POSSIBLY_RELATED","MATCH_KEY":"+ADDRESS+PHONE+ACCT_NUM-DOB-SSN","ERRULE_CODE":"SF1","IS_DISCLOSED":0,"IS_AMBIGUOUS":0,"ENTITY_NAME":"Smith","RECORD_SUMMARY":[{"DATA_SOURCE":"TEST","RECORD_COUNT":1,"FIRST_SEEN_DT":"2022-12-06 16:13:27.272","LAST_SEEN_DT":"2022-12-06 16:13:27.272"}],"LAST_SEEN_DT":"2022-12-06 16:13:27.272"}]}]}` -*/ -func (client *G2engine) WhyRecords(ctx context.Context, dataSourceCode1 string, recordID1 string, dataSourceCode2 string, recordID2 string) (string, error) { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(153, dataSourceCode1, recordID1, dataSourceCode2, recordID2) - defer func() { - client.traceExit(154, dataSourceCode1, recordID1, dataSourceCode2, recordID2, client.WhyRecordsResult, err, time.Since(entryTime)) - }() - } - if client.observers != nil { - go func() { - details := map[string]string{ - "dataSourceCode1": dataSourceCode1, - "recordID1": recordID1, - "dataSourceCode2": dataSourceCode2, - "recordID2": recordID2, - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8073, err, details) - }() - } - return client.WhyRecordsResult, err +// Trace method entry. +func (client *Szengine) traceEntry(errorNumber int, details ...interface{}) { + client.getLogger().Log(errorNumber, details...) } -/* -The WhyRecords_V2 method explains why records belong to their resolved entities. -It extends WhyRecords() by adding output control flags. - -Input - - ctx: A context to control lifecycle. - - dataSourceCode1: Identifies the provenance of the data. - - recordID1: The unique identifier within the records of the same data source. - - dataSourceCode2: Identifies the provenance of the data. - - recordID2: The unique identifier within the records of the same data source. - - flags: Flags used to control information returned. - -Output - - A JSON document. - See the example output. -*/ -func (client *G2engine) WhyRecords_V2(ctx context.Context, dataSourceCode1 string, recordID1 string, dataSourceCode2 string, recordID2 string, flags int64) (string, error) { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(155, dataSourceCode1, recordID1, dataSourceCode2, recordID2, flags) - defer func() { - client.traceExit(156, dataSourceCode1, recordID1, dataSourceCode2, recordID2, flags, client.WhyRecords_V2Result, err, time.Since(entryTime)) - }() - } - if client.observers != nil { - go func() { - details := map[string]string{ - "dataSourceCode1": dataSourceCode1, - "recordID1": recordID1, - "dataSourceCode2": dataSourceCode2, - "recordID2": recordID2, - } - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8074, err, details) - }() - } - return client.WhyRecords_V2Result, err +// Trace method exit. +func (client *Szengine) traceExit(errorNumber int, details ...interface{}) { + client.getLogger().Log(errorNumber, details...) } diff --git a/szengine/szengine_examples_test.go b/szengine/szengine_examples_test.go new file mode 100644 index 0000000..d4e67cd --- /dev/null +++ b/szengine/szengine_examples_test.go @@ -0,0 +1,661 @@ +//go:build linux + +package szengine + +import ( + "context" + "fmt" + + "github.com/senzing-garage/go-helpers/jsonutil" + "github.com/senzing-garage/go-helpers/truthset" + "github.com/senzing-garage/go-logging/logging" + "github.com/senzing-garage/sz-sdk-go/sz" +) + +// ---------------------------------------------------------------------------- +// Interface functions - Examples for godoc documentation +// ---------------------------------------------------------------------------- + +func ExampleSzengine_AddRecord() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + dataSourceCode := "CUSTOMERS" + recordId := "1001" + recordDefinition := `{"DATA_SOURCE": "CUSTOMERS", "RECORD_ID": "1001", "RECORD_TYPE": "PERSON", "PRIMARY_NAME_LAST": "Smith", "PRIMARY_NAME_FIRST": "Robert", "DATE_OF_BIRTH": "12/11/1978", "ADDR_TYPE": "MAILING", "ADDR_LINE1": "123 Main Street, Las Vegas NV 89132", "PHONE_TYPE": "HOME", "PHONE_NUMBER": "702-919-1300", "EMAIL_ADDRESS": "bsmith@work.com", "DATE": "1/2/18", "STATUS": "Active", "AMOUNT": "100"}` + flags := sz.SZ_WITHOUT_INFO + result, err := szEngine.AddRecord(ctx, dataSourceCode, recordId, recordDefinition, flags) + if err != nil { + fmt.Println(err) + } + fmt.Println(result) + // Output: {} +} + +func ExampleSzengine_AddRecord_secondRecord() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + dataSourceCode := "CUSTOMERS" + recordId := "1002" + recordDefinition := `{"DATA_SOURCE": "CUSTOMERS", "RECORD_ID": "1002", "RECORD_TYPE": "PERSON", "PRIMARY_NAME_LAST": "Smith", "PRIMARY_NAME_FIRST": "Bob", "DATE_OF_BIRTH": "11/12/1978", "ADDR_TYPE": "HOME", "ADDR_LINE1": "1515 Adela Lane", "ADDR_CITY": "Las Vegas", "ADDR_STATE": "NV", "ADDR_POSTAL_CODE": "89111", "PHONE_TYPE": "MOBILE", "PHONE_NUMBER": "702-919-1300", "DATE": "3/10/17", "STATUS": "Inactive", "AMOUNT": "200"}` + flags := sz.SZ_WITHOUT_INFO + result, err := szEngine.AddRecord(ctx, dataSourceCode, recordId, recordDefinition, flags) + if err != nil { + fmt.Println(err) + } + fmt.Println(result) + // Output: {} +} + +func ExampleSzengine_CloseExport() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + flags := sz.SZ_NO_FLAGS + exportHandle, err := szEngine.ExportJsonEntityReport(ctx, flags) + if err != nil { + fmt.Println(err) + } + szEngine.CloseExport(ctx, exportHandle) + // Output: +} + +func ExampleSzengine_CountRedoRecords() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + result, err := szEngine.CountRedoRecords(ctx) + if err != nil { + fmt.Println(err) + } + fmt.Println(result) + // Output: 0 +} + +func ExampleSzengine_DeleteRecord() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + dataSourceCode := "CUSTOMERS" + recordId := "1003" + flags := sz.SZ_WITHOUT_INFO + result, err := szEngine.DeleteRecord(ctx, dataSourceCode, recordId, flags) + if err != nil { + fmt.Println(err) + } + fmt.Println(result) + // Output: {} +} + +func ExampleSzengine_ExportCsvEntityReport() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + csvColumnList := "" + flags := sz.SZ_NO_FLAGS + exportHandle, err := szEngine.ExportCsvEntityReport(ctx, csvColumnList, flags) + if err != nil { + fmt.Println(err) + } + fmt.Println(exportHandle > 0) // Dummy output. + // Output: true +} + +func ExampleSzengine_ExportCsvEntityReportIterator() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + csvColumnList := "" + flags := sz.SZ_NO_FLAGS + for result := range szEngine.ExportCsvEntityReportIterator(ctx, csvColumnList, flags) { + if result.Error != nil { + fmt.Println(result.Error) + break + } + fmt.Println(result.Value) + } +} + +func ExampleSzengine_ExportJsonEntityReport() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + flags := sz.SZ_NO_FLAGS + exportHandle, err := szEngine.ExportJsonEntityReport(ctx, flags) + if err != nil { + fmt.Println(err) + } + fmt.Println(exportHandle > 0) // Dummy output. + // Output: true +} + +func ExampleSzengine_ExportJsonEntityReportIterator() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + flags := sz.SZ_NO_FLAGS + for result := range szEngine.ExportJsonEntityReportIterator(ctx, flags) { + if result.Error != nil { + fmt.Println(result.Error) + break + } + fmt.Println(result.Value) + } + // Output: +} + +func ExampleSzengine_FetchNext() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + flags := sz.SZ_NO_FLAGS + exportHandle, err := szEngine.ExportJsonEntityReport(ctx, flags) + if err != nil { + fmt.Println(err) + } + defer func() { + err = szEngine.CloseExport(ctx, exportHandle) + }() + jsonEntityReport := "" + for { + jsonEntityReportFragment, err := szEngine.FetchNext(ctx, exportHandle) + if err != nil { + fmt.Println(err) + } + if len(jsonEntityReportFragment) == 0 { + break + } + jsonEntityReport += jsonEntityReportFragment + } + fmt.Println(len(jsonEntityReport) >= 0) // Dummy output. + // Output: true +} + +func ExampleSzengine_FindNetworkByEntityId() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + entityList := `{"ENTITIES": [{"ENTITY_ID": ` + getEntityIdStringForRecord("CUSTOMERS", "1001") + `}, {"ENTITY_ID": ` + getEntityIdStringForRecord("CUSTOMERS", "1002") + `}]}` + maxDegrees := int64(2) + buildOutDegree := int64(1) + maxEntities := int64(10) + flags := sz.SZ_NO_FLAGS + result, err := szEngine.FindNetworkByEntityId(ctx, entityList, maxDegrees, buildOutDegree, maxEntities, flags) + if err != nil { + fmt.Println(err) + } + fmt.Println(result) + // Output: {"ENTITY_PATHS":[],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1}}]} +} + +func ExampleSzengine_FindNetworkByRecordId() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + recordList := `{"RECORDS": [{"DATA_SOURCE": "CUSTOMERS", "RECORD_ID": "1001"}, {"DATA_SOURCE": "CUSTOMERS", "RECORD_ID": "1002"}]}` + maxDegrees := int64(1) + buildOutDegree := int64(2) + maxEntities := int64(10) + flags := sz.SZ_NO_FLAGS + result, err := szEngine.FindNetworkByRecordId(ctx, recordList, maxDegrees, buildOutDegree, maxEntities, flags) + if err != nil { + fmt.Println(err) + } + fmt.Println(result) + // Output: {"ENTITY_PATHS":[],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1}}]} +} + +func ExampleSzengine_FindPathByEntityId() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + startEntityId := getEntityIdForRecord("CUSTOMERS", "1001") + endEntityId := getEntityIdForRecord("CUSTOMERS", "1002") + maxDegrees := int64(1) + exclusions := "" + requiredDataSources := "" + flags := sz.SZ_NO_FLAGS + result, err := szEngine.FindPathByEntityId(ctx, startEntityId, endEntityId, maxDegrees, exclusions, requiredDataSources, flags) + if err != nil { + fmt.Println(err) + } + fmt.Println(truncate(result, 107)) + // Output: {"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[1]}],"ENTITIES":[{"RESOLVED_ENTITY":... +} + +func ExampleSzengine_FindPathByEntityId_excluding() { + // TODO: Implement ExampleSzEngine_FindPathByEntityId_excluding + // // For more information, visit https://github.com/senzing-garage/sz-sdk-go-grpc/blob/main/szengine/szengine_examples_test.go + // ctx := context.TODO() + // szEngine := getSzEngine(ctx) + // startEntityId := getEntityIdForRecord("CUSTOMERS", "1001") + // endEntityId := getEntityIdForRecord("CUSTOMERS", "1002") + // maxDegrees := int64(1) + // exclusions := `{"ENTITIES": [{"ENTITY_ID": ` + getEntityIdStringForRecord("CUSTOMERS", "1003") + `}]}` + // requiredDataSources := "" + // flags := sz.SZ_NO_FLAGS + // result, err := szEngine.FindPathByEntityId(ctx, startEntityId, endEntityId, maxDegrees, exclusions, requiredDataSources, flags) + // if err != nil { + // fmt.Println(err) + // } + // fmt.Println(truncate(result, 107)) + // // Output: {"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[1]}],"ENTITIES":[{"RESOLVED_ENTITY":... +} + +func ExampleSzEngine_FindPathByEntityId_excludingAndIncluding() { + // TODO: Implement ExampleSzEngine_FindPathByEntityId_excludingAndIncluding +} + +func ExampleSzengine_FindPathByEntityId_including() { + // TODO: Implement ExampleSzEngine_FindPathByEntityId_including + // // For more information, visit https://github.com/senzing-garage/sz-sdk-go-grpc/blob/main/szengine/szengine_examples_test.go + // ctx := context.TODO() + // szEngine := getSzEngine(ctx) + // startEntityId := getEntityIdForRecord("CUSTOMERS", "1001") + // endEntityId := getEntityIdForRecord("CUSTOMERS", "1002") + // maxDegree := int64(1) + // exclusions := `{"ENTITIES": [{"ENTITY_ID": ` + getEntityIdStringForRecord("CUSTOMERS", "1003") + `}]}` + // requiredDataSources := `{"DATA_SOURCES": ["CUSTOMERS"]}` + // flags := sz.SZ_NO_FLAGS + // result, err := szEngine.FindPathByEntityId(ctx, startEntityId, endEntityId, maxDegree, exclusions, requiredDataSources, flags) + // if err != nil { + // fmt.Println(err) + // } + // fmt.Println(truncate(result, 106)) + // // Output: {"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[]}],"ENTITIES":[{"RESOLVED_ENTITY":... +} + +func ExampleSzengine_FindPathByRecordId() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + startDataSourceCode := "CUSTOMERS" + startRecordId := "1001" + endDataSourceCode := "CUSTOMERS" + endRecordId := "1002" + maxDegrees := int64(1) + exclusions := "" + requiredDataSources := "" + flags := sz.SZ_NO_FLAGS + result, err := szEngine.FindPathByRecordId(ctx, startDataSourceCode, startRecordId, endDataSourceCode, endRecordId, maxDegrees, exclusions, requiredDataSources, flags) + if err != nil { + fmt.Println(err) + } + fmt.Println(truncate(result, 87)) + // Output: {"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[1]}],"ENTITIES":... +} + +func ExampleSzengine_FindPathByRecordId_excluding() { + // TODO: Implement ExampleSzEngine_FindPathByRecordId_excluding + // // For more information, visit https://github.com/senzing-garage/sz-sdk-go-core/blob/main/szengine/szengine_examples_test.go + // ctx := context.TODO() + // szEngine := getSzEngine(ctx) + // startDataSourceCode := "CUSTOMERS" + // startRecordId := "1001" + // endDataSourceCode := "CUSTOMERS" + // endRecordId := "1002" + // maxDegree := int64(1) + // exclusions := `{"RECORDS": [{ "DATA_SOURCE": "CUSTOMERS", "RECORD_ID": "1003"}]}` + // requiredDataSources := "" + // flags := sz.SZ_NO_FLAGS + // result, err := szEngine.FindPathByRecordId(ctx, startDataSourceCode, startRecordId, endDataSourceCode, endRecordId, maxDegree, exclusions, requiredDataSources, flags) + // if err != nil { + // fmt.Println(err) + // } + // fmt.Println(truncate(result, 107)) + // // Output: {"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[1]}],"ENTITIES":[{"RESOLVED_ENTITY":... +} + +func ExampleSzEngine_FindPathByRecordId_excludingAndIncluding() { + // TODO: Implement ExampleSzEngine_FindPathByRecordId_excludingAndIncluding +} + +func ExampleSzengine_FindPathByRecordId_including() { + // TODO: Implement ExampleSzEngine_FindPathByRecordId_including + // // For more information, visit https://github.com/senzing-garage/sz-sdk-go-core/blob/main/szengine/szengine_examples_test.go + // ctx := context.TODO() + // szEngine := getSzEngine(ctx) + // startDataSourceCode := "CUSTOMERS" + // startRecordId := "1001" + // endDataSourceCode := "CUSTOMERS" + // endRecordId := "1002" + // maxDegrees := int64(1) + // exclusions := `{"ENTITIES": [{"ENTITY_ID": ` + getEntityIdStringForRecord("CUSTOMERS", "1003") + `}]}` + // requiredDataSources := `{"DATA_SOURCES": ["CUSTOMERS"]}` + // flags := sz.SZ_NO_FLAGS + // result, err := szEngine.FindPathByRecordId(ctx, startDataSourceCode, startRecordId, endDataSourceCode, endRecordId, maxDegrees, exclusions, requiredDataSources, flags) + // if err != nil { + // fmt.Println(err) + // } + // fmt.Println(truncate(result, 119)) + // // Output: {"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[]}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":... +} + +func ExampleSzengine_GetActiveConfigId() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + result, err := szEngine.GetActiveConfigId(ctx) + if err != nil { + fmt.Println(err) + } + fmt.Println(result > 0) // Dummy output. + // Output: true +} + +func ExampleSzengine_GetEntityByEntityId() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + entityId := getEntityIdForRecord("CUSTOMERS", "1001") + flags := sz.SZ_NO_FLAGS + result, err := szEngine.GetEntityByEntityId(ctx, entityId, flags) + if err != nil { + fmt.Println(err) + } + fmt.Println(result) + // Output: {"RESOLVED_ENTITY":{"ENTITY_ID":1}} +} + +func ExampleSzengine_GetEntityByRecordId() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + dataSourceCode := "CUSTOMERS" + recordId := "1001" + flags := sz.SZ_NO_FLAGS + result, err := szEngine.GetEntityByRecordId(ctx, dataSourceCode, recordId, flags) + if err != nil { + fmt.Println(err) + } + fmt.Println(result) + // Output: {"RESOLVED_ENTITY":{"ENTITY_ID":1}} +} + +func ExampleSzengine_GetRecord() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + dataSourceCode := "CUSTOMERS" + recordId := "1001" + flags := sz.SZ_NO_FLAGS + result, err := szEngine.GetRecord(ctx, dataSourceCode, recordId, flags) + if err != nil { + fmt.Println(err) + } + fmt.Println(jsonutil.Flatten(jsonutil.Normalize(result))) + // Output: {"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001"} +} + +func ExampleSzengine_GetRedoRecord() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + result, err := szEngine.GetRedoRecord(ctx) + if err != nil { + fmt.Println(err) + } + fmt.Println(result) + // Output: {"REASON":"deferred delete","DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001","DSRC_ACTION":"X"} +} + +func ExampleSzengine_GetRepositoryLastModifiedTime() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + result, err := szEngine.GetRepositoryLastModifiedTime(ctx) + if err != nil { + fmt.Println(err) + } + fmt.Println(result > 0) // Dummy output. + // Output: true +} + +func ExampleSzengine_GetStats() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + result, err := szEngine.GetStats(ctx) + if err != nil { + fmt.Println(err) + } + fmt.Println(truncate(result, 16)) + // Output: { "workload":... +} + +func ExampleSzengine_GetVirtualEntityByRecordId() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + recordList := `{"RECORDS": [{"DATA_SOURCE": "CUSTOMERS","RECORD_ID": "1001"},{"DATA_SOURCE": "CUSTOMERS","RECORD_ID": "1002"}]}` + flags := sz.SZ_NO_FLAGS + result, err := szEngine.GetVirtualEntityByRecordId(ctx, recordList, flags) + if err != nil { + fmt.Println(err) + } + fmt.Println(result) + // Output: {"RESOLVED_ENTITY":{"ENTITY_ID":1}} +} + +func ExampleSzengine_HowEntityByEntityId() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + entityId := getEntityIdForRecord("CUSTOMERS", "1001") + flags := sz.SZ_NO_FLAGS + result, err := szEngine.HowEntityByEntityId(ctx, entityId, flags) + if err != nil { + fmt.Println(err) + } + fmt.Println(jsonutil.Flatten(jsonutil.NormalizeAndSort(jsonutil.Flatten(jsonutil.Redact(result, "RECORD_ID", "INBOUND_FEAT_USAGE_TYPE"))))) + // Output: {"HOW_RESULTS":{"FINAL_STATE":{"NEED_REEVALUATION":0,"VIRTUAL_ENTITIES":[{"MEMBER_RECORDS":[{"INTERNAL_ID":1,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":null}]},{"INTERNAL_ID":2,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":null}]}],"VIRTUAL_ENTITY_ID":"V1-S1"}]},"RESOLUTION_STEPS":[{"INBOUND_VIRTUAL_ENTITY_ID":"V2","MATCH_INFO":{"ERRULE_CODE":"CNAME_CFF_CEXCL","MATCH_KEY":"+NAME+DOB+PHONE"},"RESULT_VIRTUAL_ENTITY_ID":"V1-S1","STEP":1,"VIRTUAL_ENTITY_1":{"MEMBER_RECORDS":[{"INTERNAL_ID":1,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":null}]}],"VIRTUAL_ENTITY_ID":"V1"},"VIRTUAL_ENTITY_2":{"MEMBER_RECORDS":[{"INTERNAL_ID":2,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":null}]}],"VIRTUAL_ENTITY_ID":"V2"}}]}} +} + +func ExampleSzengine_PrimeEngine() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + err := szEngine.PrimeEngine(ctx) + if err != nil { + fmt.Println(err) + } + // Output: +} + +func ExampleSzEngine_ProcessRedoRecord() { + // TODO: Uncomment after it has been implemented. + // // For more information, visit https://github.com/senzing-garage/sz-sdk-go-core/blob/main/szengine/szengine_examples_test.go + // ctx := context.TODO() + // szEngine := getSzEngine(ctx) + // redoRecord, err := szEngine.GetRedoRecord(ctx) + // if err != nil { + // fmt.Println(err) + // } + // flags := sz.SZ_WITHOUT_INFO + // result, err := szEngine.ProcessRedoRecord(ctx, redoRecord, flags) + // if err != nil { + // fmt.Println(err) + // } + // fmt.Println(result) + // // Output: {} +} + +func ExampleSzengine_ReevaluateEntity() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + entityId := getEntityIdForRecord("CUSTOMERS", "1001") + flags := sz.SZ_WITHOUT_INFO + result, err := szEngine.ReevaluateEntity(ctx, entityId, flags) + if err != nil { + fmt.Println(err) + } + fmt.Println(result) + // Output: {} +} + +func ExampleSzengine_ReevaluateRecord() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + dataSourceCode := "CUSTOMERS" + recordId := "1001" + flags := sz.SZ_WITHOUT_INFO + result, err := szEngine.ReevaluateRecord(ctx, dataSourceCode, recordId, flags) + if err != nil { + fmt.Println(err) + } + fmt.Println(result) + // Output: {} +} + +func ExampleSzengine_SearchByAttributes() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + attributes := `{"NAMES": [{"NAME_TYPE": "PRIMARY", "NAME_LAST": "Smith"}], "EMAIL_ADDRESS": "bsmith@work.com"}` + searchProfile := "" + flags := sz.SZ_NO_FLAGS + result, err := szEngine.SearchByAttributes(ctx, attributes, searchProfile, flags) + if err != nil { + fmt.Println(err) + } + fmt.Println(jsonutil.Flatten(jsonutil.Redact(jsonutil.Flatten(jsonutil.NormalizeAndSort(result)), "FIRST_SEEN_DT", "LAST_SEEN_DT"))) + // Output: {"RESOLVED_ENTITIES":[{"ENTITY":{"RESOLVED_ENTITY":{"ENTITY_ID":1}},"MATCH_INFO":{"ERRULE_CODE":"SF1","MATCH_KEY":"+PNAME+EMAIL","MATCH_LEVEL_CODE":"POSSIBLY_RELATED"}}]} +} + +func ExampleSzEngine_SearchByAttributes_searchProfile() { + // TODO: Implement ExampleSzEngine_SearchByAttributes_searchProfile +} + +func ExampleSzengine_WhyEntities() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + entityId1 := getEntityId(truthset.CustomerRecords["1001"]) + entityId2 := getEntityId(truthset.CustomerRecords["1002"]) + flags := sz.SZ_NO_FLAGS + result, err := szEngine.WhyEntities(ctx, entityId1, entityId2, flags) + if err != nil { + fmt.Println(err) + } + fmt.Println(truncate(result, 74)) + // Output: {"WHY_RESULTS":[{"ENTITY_ID":1,"ENTITY_ID_2":1,"MATCH_INFO":{"WHY_KEY":... +} + +func ExampleSzengine_WhyRecordInEntity() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + dataSourceCode := "CUSTOMERS" + recordId := "1001" + flags := sz.SZ_NO_FLAGS + result, err := szEngine.WhyRecordInEntity(ctx, dataSourceCode, recordId, flags) + if err != nil { + fmt.Println(err) + } + fmt.Println(result) + // Output: +} + +func ExampleSzengine_WhyRecords() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + dataSourceCode1 := "CUSTOMERS" + recordId1 := "1001" + dataSourceCode2 := "CUSTOMERS" + recordId2 := "1002" + flags := sz.SZ_NO_FLAGS + result, err := szEngine.WhyRecords(ctx, dataSourceCode1, recordId1, dataSourceCode2, recordId2, flags) + if err != nil { + fmt.Println(err) + } + fmt.Println(truncate(result, 115)) + // Output: {"WHY_RESULTS":[{"INTERNAL_ID":1,"ENTITY_ID":1,"FOCUS_RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001"}],... +} + +// ---------------------------------------------------------------------------- +// Logging and observing +// ---------------------------------------------------------------------------- + +func ExampleSzengine_SetLogLevel() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + err := szEngine.SetLogLevel(ctx, logging.LevelInfoName) + if err != nil { + fmt.Println(err) + } + // Output: +} + +func ExampleSzengine_SetObserverOrigin() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + origin := "Machine: nn; Task: UnitTest" + szEngine.SetObserverOrigin(ctx, origin) + // Output: +} + +func ExampleSzengine_GetObserverOrigin() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + origin := "Machine: nn; Task: UnitTest" + szEngine.SetObserverOrigin(ctx, origin) + result := szEngine.GetObserverOrigin(ctx) + fmt.Println(result) + // Output: Machine: nn; Task: UnitTest +} + +// ---------------------------------------------------------------------------- +// Object creation / destruction +// ---------------------------------------------------------------------------- + +func ExampleSzengine_Initialize() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + instanceName := "Test module name" + settings, err := getSettings() + if err != nil { + fmt.Println(err) + } + verboseLogging := sz.SZ_NO_LOGGING + configId := sz.SZ_INITIALIZE_WITH_DEFAULT_CONFIGURATION + err = szEngine.Initialize(ctx, instanceName, settings, configId, verboseLogging) + if err != nil { + fmt.Println(err) + } + // Output: +} + +func ExampleSzengine_Initialize_withConfigId() { + // TODO: Implement ExampleSzEngine_Initialize_withConfigId +} + +func ExampleSzengine_Reinitialize() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + configId, _ := szEngine.GetActiveConfigId(ctx) + err := szEngine.Reinitialize(ctx, configId) + if err != nil { + fmt.Println(err) + } + // Output: +} + +func ExampleSzengine_Destroy() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szengine/szengine_examples_test.go + ctx := context.TODO() + szEngine := getSzEngine(ctx) + err := szEngine.Destroy(ctx) + if err != nil { + fmt.Println(err) + } + // Output: +} diff --git a/szengine/szengine_test.go b/szengine/szengine_test.go new file mode 100644 index 0000000..6f8f316 --- /dev/null +++ b/szengine/szengine_test.go @@ -0,0 +1,780 @@ +package szengine + +import ( + "context" + "encoding/json" + "fmt" + "os" + "strconv" + "strings" + "testing" + + truncator "github.com/aquilax/truncate" + "github.com/senzing-garage/go-helpers/record" + "github.com/senzing-garage/go-helpers/testfixtures" + "github.com/senzing-garage/go-helpers/truthset" + "github.com/senzing-garage/sz-sdk-go/sz" + "github.com/senzing-garage/sz-sdk-go/szerror" + "github.com/stretchr/testify/assert" +) + +const ( + defaultTruncation = 76 + instanceName = "Engine Test" + printResults = false + verboseLogging = sz.SZ_NO_LOGGING +) + +type GetEntityByRecordIdResponse struct { + ResolvedEntity struct { + EntityId int64 `json:"ENTITY_ID"` + } `json:"RESOLVED_ENTITY"` +} + +var ( + szEngineSingleton *Szengine +) + +// ---------------------------------------------------------------------------- +// Interface functions - test +// ---------------------------------------------------------------------------- + +func TestSzengine_AddRecord(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + flags := sz.SZ_WITHOUT_INFO + records := []record.Record{ + truthset.CustomerRecords["1004"], + truthset.CustomerRecords["1005"], + } + for _, record := range records { + actual, err := szEngine.AddRecord(ctx, record.DataSource, record.Id, record.Json, flags) + testError(test, err) + printActual(test, actual) + defer szEngine.DeleteRecord(ctx, record.DataSource, record.Id, flags) + } +} + +func TestSzengine_AddRecord_withInfo(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + flags := sz.SZ_WITH_INFO + records := []record.Record{ + truthset.CustomerRecords["1004"], + truthset.CustomerRecords["1005"], + } + for _, record := range records { + actual, err := szEngine.AddRecord(ctx, record.DataSource, record.Id, record.Json, flags) + testError(test, err) + printActual(test, actual) + defer szEngine.DeleteRecord(ctx, record.DataSource, record.Id, flags) + } +} + +func TestSzengine_CloseExport(test *testing.T) { + // Tested in: + // - TestSzengine_ExportCsvEntityReport + // - TestSzengine_ExportJsonEntityReport +} + +func TestSzengine_CountRedoRecords(test *testing.T) { + expected := int64(0) + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + actual, err := szEngine.CountRedoRecords(ctx) + testError(test, err) + printActual(test, actual) + assert.Equal(test, expected, actual) +} + +func TestSzengine_DeleteRecord(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + record := truthset.CustomerRecords["1009"] + flags := sz.SZ_WITHOUT_INFO + actual, err := szEngine.AddRecord(ctx, record.DataSource, record.Id, record.Json, flags) + printActual(test, actual) + testError(test, err) + actual, err = szEngine.DeleteRecord(ctx, record.DataSource, record.Id, flags) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_DeleteRecord_withInfo(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + record := truthset.CustomerRecords["1010"] + flags := sz.SZ_WITH_INFO + actual, err := szEngine.AddRecord(ctx, record.DataSource, record.Id, record.Json, flags) + testError(test, err) + printActual(test, actual) + actual, err = szEngine.DeleteRecord(ctx, record.DataSource, record.Id, flags) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_ExportCsvEntityReport(test *testing.T) { + expected := []string{} + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + csvColumnList := "" + flags := sz.SZ_EXPORT_INCLUDE_ALL_ENTITIES + aHandle, err := szEngine.ExportCsvEntityReport(ctx, csvColumnList, flags) + defer func() { + err := szEngine.CloseExport(ctx, aHandle) + testError(test, err) + }() + testError(test, err) + actualCount := 0 + for actual := range szEngine.ExportCsvEntityReportIterator(ctx, csvColumnList, flags) { + assert.Equal(test, expected[actualCount], strings.TrimSpace(actual.Value)) + actualCount += 1 + } + assert.Equal(test, len(expected), actualCount) +} + +func TestSzengine_ExportCsvEntityReportIterator(test *testing.T) { + expected := []string{} + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + csvColumnList := "" + flags := sz.SZ_EXPORT_INCLUDE_ALL_ENTITIES + actualCount := 0 + for actual := range szEngine.ExportCsvEntityReportIterator(ctx, csvColumnList, flags) { + testError(test, actual.Error) + assert.Equal(test, expected[actualCount], strings.TrimSpace(actual.Value)) + actualCount += 1 + } + assert.Equal(test, len(expected), actualCount) +} + +func TestSzengine_ExportJsonEntityReport(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + aRecord := testfixtures.FixtureRecords["65536-periods"] + flags := sz.SZ_WITH_INFO + actual, err := szEngine.AddRecord(ctx, aRecord.DataSource, aRecord.Id, aRecord.Json, flags) + testError(test, err) + printActual(test, actual) + defer szEngine.DeleteRecord(ctx, aRecord.DataSource, aRecord.Id, sz.SZ_WITHOUT_INFO) + // TODO: Figure out correct flags. + // flags := sz.Flags(sz.SZ_EXPORT_DEFAULT_FLAGS, sz.SZ_EXPORT_INCLUDE_ALL_HAVING_RELATIONSHIPS, sz.SZ_EXPORT_INCLUDE_ALL_HAVING_RELATIONSHIPS) + flags = int64(-1) + aHandle, err := szEngine.ExportJsonEntityReport(ctx, flags) + defer func() { + err := szEngine.CloseExport(ctx, aHandle) + testError(test, err) + }() + testError(test, err) + jsonEntityReport := "" + for { + jsonEntityReportFragment, err := szEngine.FetchNext(ctx, aHandle) + testError(test, err) + if len(jsonEntityReportFragment) == 0 { + break + } + jsonEntityReport += jsonEntityReportFragment + } + testError(test, err) + assert.True(test, true) +} + +func TestSzengine_ExportJsonEntityReportIterator(test *testing.T) { + expected := 0 + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + flags := sz.SZ_EXPORT_INCLUDE_ALL_ENTITIES + actualCount := 0 + for actual := range szEngine.ExportJsonEntityReportIterator(ctx, flags) { + testError(test, actual.Error) + printActual(test, actual.Value) + actualCount += 1 + } + assert.Equal(test, expected, actualCount) +} + +func TestSzengine_FetchNext(test *testing.T) { + // Tested in: + // - TestSzengine_ExportJsonEntityReport +} + +func TestSzengine_FindNetworkByEntityId(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + record1 := truthset.CustomerRecords["1001"] + record2 := truthset.CustomerRecords["1002"] + entityList := `{"ENTITIES": [{"ENTITY_ID": ` + getEntityIdString(record1) + `}, {"ENTITY_ID": ` + getEntityIdString(record2) + `}]}` + maxDegrees := int64(2) + buildOutDegree := int64(1) + maxEntities := int64(10) + flags := sz.SZ_FIND_NETWORK_DEFAULT_FLAGS + actual, err := szEngine.FindNetworkByEntityId(ctx, entityList, maxDegrees, buildOutDegree, maxEntities, flags) + testErrorNoFail(test, err) + printActual(test, actual) +} + +func TestSzengine_FindNetworkByRecordId(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + record1 := truthset.CustomerRecords["1001"] + record2 := truthset.CustomerRecords["1002"] + record3 := truthset.CustomerRecords["1003"] + recordList := `{"RECORDS": [{"DATA_SOURCE": "` + record1.DataSource + `", "RECORD_ID": "` + record1.Id + `"}, {"DATA_SOURCE": "` + record2.DataSource + `", "RECORD_ID": "` + record2.Id + `"}, {"DATA_SOURCE": "` + record3.DataSource + `", "RECORD_ID": "` + record3.Id + `"}]}` + maxDegrees := int64(1) + buildOutDegree := int64(2) + maxEntities := int64(10) + flags := sz.SZ_FIND_NETWORK_DEFAULT_FLAGS + actual, err := szEngine.FindNetworkByRecordId(ctx, recordList, maxDegrees, buildOutDegree, maxEntities, flags) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_FindPathByEntityId(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + startEntityId := getEntityId(truthset.CustomerRecords["1001"]) + endEntityId := getEntityId(truthset.CustomerRecords["1002"]) + maxDegrees := int64(1) + exclusions := sz.SZ_NO_EXCLUSIONS + requiredDataSources := sz.SZ_NO_REQUIRED_DATASOURCES + flags := sz.SZ_NO_FLAGS + actual, err := szEngine.FindPathByEntityId(ctx, startEntityId, endEntityId, maxDegrees, exclusions, requiredDataSources, flags) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_FindPathByEntityId_excluding(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + startRecord := truthset.CustomerRecords["1001"] + startEntityId := getEntityId(startRecord) + endEntityId := getEntityId(truthset.CustomerRecords["1002"]) + maxDegrees := int64(1) + exclusions := `{"ENTITIES": [{"ENTITY_ID": ` + getEntityIdString(startRecord) + `}]}` + requiredDataSources := sz.SZ_NO_REQUIRED_DATASOURCES + flags := sz.SZ_NO_FLAGS + actual, err := szEngine.FindPathByEntityId(ctx, startEntityId, endEntityId, maxDegrees, exclusions, requiredDataSources, flags) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_FindPathByEntityId_excludingAndIncluding(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + startRecord := truthset.CustomerRecords["1001"] + startEntityId := getEntityId(startRecord) + endEntityId := getEntityId(truthset.CustomerRecords["1002"]) + maxDegrees := int64(1) + exclusions := `{"ENTITIES": [{"ENTITY_ID": ` + getEntityIdString(startRecord) + `}]}` + requiredDataSources := `{"DATA_SOURCES": ["` + startRecord.DataSource + `"]}` + flags := sz.SZ_NO_FLAGS + actual, err := szEngine.FindPathByEntityId(ctx, startEntityId, endEntityId, maxDegrees, exclusions, requiredDataSources, flags) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_FindPathByEntityId_including(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + startRecord := truthset.CustomerRecords["1001"] + startEntityId := getEntityId(startRecord) + endEntityId := getEntityId(truthset.CustomerRecords["1002"]) + maxDegrees := int64(1) + exclusions := sz.SZ_NO_EXCLUSIONS + requiredDataSources := `{"DATA_SOURCES": ["` + startRecord.DataSource + `"]}` + flags := sz.SZ_NO_FLAGS + actual, err := szEngine.FindPathByEntityId(ctx, startEntityId, endEntityId, maxDegrees, exclusions, requiredDataSources, flags) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_FindPathByRecordId(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + record1 := truthset.CustomerRecords["1001"] + record2 := truthset.CustomerRecords["1002"] + maxDegree := int64(1) + exclusions := sz.SZ_NO_EXCLUSIONS + requiredDataSources := sz.SZ_NO_REQUIRED_DATASOURCES + flags := sz.SZ_NO_FLAGS + actual, err := szEngine.FindPathByRecordId(ctx, record1.DataSource, record1.Id, record2.DataSource, record2.Id, maxDegree, exclusions, requiredDataSources, flags) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_FindPathByRecordId_excluding(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + record1 := truthset.CustomerRecords["1001"] + record2 := truthset.CustomerRecords["1002"] + maxDegree := int64(1) + exclusions := `{"RECORDS": [{ "DATA_SOURCE": "` + record1.DataSource + `", "RECORD_ID": "` + record1.Id + `"}]}` + requiredDataSources := sz.SZ_NO_REQUIRED_DATASOURCES + flags := sz.SZ_NO_FLAGS + actual, err := szEngine.FindPathByRecordId(ctx, record1.DataSource, record1.Id, record2.DataSource, record2.Id, maxDegree, exclusions, requiredDataSources, flags) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_FindPathByRecordId_excludingAndIncluding(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + record1 := truthset.CustomerRecords["1001"] + record2 := truthset.CustomerRecords["1002"] + maxDegree := int64(1) + exclusions := `{"RECORDS": [{ "DATA_SOURCE": "` + record1.DataSource + `", "RECORD_ID": "` + record1.Id + `"}]}` + requiredDataSources := `{"DATA_SOURCES": ["` + record1.DataSource + `"]}` + flags := sz.SZ_NO_FLAGS + actual, err := szEngine.FindPathByRecordId(ctx, record1.DataSource, record1.Id, record2.DataSource, record2.Id, maxDegree, exclusions, requiredDataSources, flags) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_FindPathByRecordId_including(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + record1 := truthset.CustomerRecords["1001"] + record2 := truthset.CustomerRecords["1002"] + maxDegree := int64(1) + exclusions := `{"ENTITIES": [{"ENTITY_ID": ` + getEntityIdString(record1) + `}]}` + requiredDataSources := `{"DATA_SOURCES": ["` + record1.DataSource + `"]}` + flags := sz.SZ_NO_FLAGS + actual, err := szEngine.FindPathByRecordId(ctx, record1.DataSource, record1.Id, record2.DataSource, record2.Id, maxDegree, exclusions, requiredDataSources, flags) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_GetActiveConfigId(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + actual, err := szEngine.GetActiveConfigId(ctx) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_GetEntityByEntityId(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + entityId := getEntityId(truthset.CustomerRecords["1001"]) + flags := sz.SZ_NO_FLAGS + actual, err := szEngine.GetEntityByEntityId(ctx, entityId, flags) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_GetEntityByRecordId(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + record := truthset.CustomerRecords["1001"] + flags := sz.SZ_NO_FLAGS + actual, err := szEngine.GetEntityByRecordId(ctx, record.DataSource, record.Id, flags) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_GetRecord(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + record := truthset.CustomerRecords["1001"] + flags := sz.SZ_NO_FLAGS + actual, err := szEngine.GetRecord(ctx, record.DataSource, record.Id, flags) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_GetRedoRecord(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + actual, err := szEngine.GetRedoRecord(ctx) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_GetRepositoryLastModifiedTime(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + actual, err := szEngine.GetRepositoryLastModifiedTime(ctx) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_GetStats(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + actual, err := szEngine.GetStats(ctx) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_GetVirtualEntityByRecordId(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + record1 := truthset.CustomerRecords["1001"] + record2 := truthset.CustomerRecords["1002"] + recordList := `{"RECORDS": [{"DATA_SOURCE": "` + record1.DataSource + `", "RECORD_ID": "` + record1.Id + `"}, {"DATA_SOURCE": "` + record2.DataSource + `", "RECORD_ID": "` + record2.Id + `"}]}` + flags := sz.SZ_NO_FLAGS + actual, err := szEngine.GetVirtualEntityByRecordId(ctx, recordList, flags) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_HowEntityByEntityId(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + entityId := getEntityId(truthset.CustomerRecords["1001"]) + flags := sz.SZ_NO_FLAGS + actual, err := szEngine.HowEntityByEntityId(ctx, entityId, flags) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_PrimeEngine(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + err := szEngine.PrimeEngine(ctx) + testError(test, err) +} + +func TestSzengine_ProcessRedoRecord(test *testing.T) { + // TODO: Implement TestSzengine_ProcessRedoRecord + // ctx := context.TODO() + // szEngine := getTestObject(ctx, test) + // flags := sz.SZ_WITHOUT_INFO + // actual, err := szEngine.ProcessRedoRecord(ctx, redoRecord, flags) + // testError(test, err) + // printActual(test, actual) +} + +func TestSzengine_ProcessRedoRecord_withInfo(test *testing.T) { + // TODO: Implement TestSzengine_ProcessRedoRecord_withInfo + // ctx := context.TODO() + // szEngine := getTestObject(ctx, test) + // flags := sz.SZ_WITH_INFO + // actual, err := szEngine.ProcessRedoRecord(ctx, redoRecord, flags) + // testError(test, err) + // printActual(test, actual) +} + +func TestSzengine_ReevaluateEntity(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + entityId := getEntityId(truthset.CustomerRecords["1001"]) + flags := sz.SZ_WITHOUT_INFO + actual, err := szEngine.ReevaluateEntity(ctx, entityId, flags) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_ReevaluateEntity_withInfo(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + entityId := getEntityId(truthset.CustomerRecords["1001"]) + flags := sz.SZ_WITH_INFO + actual, err := szEngine.ReevaluateEntity(ctx, entityId, flags) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_ReevaluateRecord(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + record := truthset.CustomerRecords["1001"] + flags := sz.SZ_WITHOUT_INFO + actual, err := szEngine.ReevaluateRecord(ctx, record.DataSource, record.Id, flags) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_ReevaluateRecord_withInfo(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + record := truthset.CustomerRecords["1001"] + flags := sz.SZ_WITH_INFO + actual, err := szEngine.ReevaluateRecord(ctx, record.DataSource, record.Id, flags) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_SearchByAttributes(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + attributes := `{"NAMES": [{"NAME_TYPE": "PRIMARY", "NAME_LAST": "JOHNSON"}], "SSN_NUMBER": "053-39-3251"}` + searchProfile := sz.SZ_NO_SEARCH_PROFILE + flags := sz.SZ_NO_FLAGS + actual, err := szEngine.SearchByAttributes(ctx, attributes, searchProfile, flags) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_StreamExportCsvEntityReport(test *testing.T) { + // TODO: Write TestSzengine_StreamExportCsvEntityReport +} + +func TestSzengine_StreamExportJsonEntityReport(test *testing.T) { + // TODO: Write TestSzengine_StreamExportJsonEntityReport +} + +func TestSzengine_SearchByAttributes_searchProfile(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + attributes := `{"NAMES": [{"NAME_TYPE": "PRIMARY", "NAME_LAST": "JOHNSON"}], "SSN_NUMBER": "053-39-3251"}` + searchProfile := sz.SZ_NO_SEARCH_PROFILE // TODO: Figure out the search profile + flags := sz.SZ_NO_FLAGS + actual, err := szEngine.SearchByAttributes(ctx, attributes, searchProfile, flags) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_WhyEntities(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + entityId1 := getEntityId(truthset.CustomerRecords["1001"]) + entityId2 := getEntityId(truthset.CustomerRecords["1002"]) + flags := sz.SZ_NO_FLAGS + actual, err := szEngine.WhyEntities(ctx, entityId1, entityId2, flags) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_WhyRecordInEntity(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + record := truthset.CustomerRecords["1001"] + flags := sz.SZ_NO_FLAGS + actual, err := szEngine.WhyRecordInEntity(ctx, record.DataSource, record.Id, flags) + testError(test, err) + printActual(test, actual) +} + +func TestSzengine_WhyRecords(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + record1 := truthset.CustomerRecords["1001"] + record2 := truthset.CustomerRecords["1002"] + flags := sz.SZ_NO_FLAGS + actual, err := szEngine.WhyRecords(ctx, record1.DataSource, record1.Id, record2.DataSource, record2.Id, flags) + testError(test, err) + printActual(test, actual) +} + +// ---------------------------------------------------------------------------- +// Logging and observing +// ---------------------------------------------------------------------------- + +func TestSzengine_SetObserverOrigin(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + origin := "Machine: nn; Task: UnitTest" + szEngine.SetObserverOrigin(ctx, origin) +} + +func TestSzengine_GetObserverOrigin(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + origin := "Machine: nn; Task: UnitTest" + szEngine.SetObserverOrigin(ctx, origin) + actual := szEngine.GetObserverOrigin(ctx) + assert.Equal(test, origin, actual) + printActual(test, actual) +} + +// ---------------------------------------------------------------------------- +// Object creation / destruction +// ---------------------------------------------------------------------------- + +func TestSzengine_AsInterface(test *testing.T) { + expected := int64(0) + ctx := context.TODO() + szEngine := getSzEngineAsInterface(ctx) + actual, err := szEngine.CountRedoRecords(ctx) + testError(test, err) + printActual(test, actual) + assert.Equal(test, expected, actual) +} + +func TestSzengine_Initialize(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + settings, err := getSettings() + testError(test, err) + configId := sz.SZ_INITIALIZE_WITH_DEFAULT_CONFIGURATION + err = szEngine.Initialize(ctx, instanceName, settings, configId, verboseLogging) + testError(test, err) +} + +func TestSzengine_Initialize_withConfigId(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + settings, err := getSettings() + testError(test, err) + configId := getDefaultConfigId() + err = szEngine.Initialize(ctx, instanceName, settings, configId, verboseLogging) + testError(test, err) +} + +func TestSzengine_Reinitialize(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + configId, err := szEngine.GetActiveConfigId(ctx) + testError(test, err) + err = szEngine.Reinitialize(ctx, configId) + testError(test, err) + printActual(test, configId) +} + +func TestSzengine_Destroy(test *testing.T) { + ctx := context.TODO() + szEngine := getTestObject(ctx, test) + err := szEngine.Destroy(ctx) + testError(test, err) +} + +// ---------------------------------------------------------------------------- +// Internal functions +// ---------------------------------------------------------------------------- + +func getDefaultConfigId() int64 { + return int64(1) +} + +func getSzEngine(ctx context.Context) *Szengine { + _ = ctx + if szEngineSingleton == nil { + szEngineSingleton = &Szengine{ + AddRecordResult: "{}", + CountRedoRecordsResult: int64(0), + DeleteRecordResult: "{}", + ExportConfigResult: `{"G2_CONFIG":{"CFG_ETYPE":[{"ETYPE_ID":...`, + ExportCsvEntityReportResult: 1, + ExportJsonEntityReportResult: 1, + FetchNextResult: ``, + FindNetworkByEntityIdResult: `{"ENTITY_PATHS":[],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1}}]}`, + FindNetworkByRecordIdResult: `{"ENTITY_PATHS":[],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1}}]}`, + FindPathByEntityIdResult: `{"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[1]}],"ENTITIES":[{"RESOLVED_ENTITY":...`, + FindPathByRecordIdResult: `{"ENTITY_PATHS":[{"START_ENTITY_ID":1,"END_ENTITY_ID":1,"ENTITIES":[1]}],"ENTITIES":...`, + GetActiveConfigIdResult: int64(1), + GetEntityByEntityIdResult: `{"RESOLVED_ENTITY":{"ENTITY_ID":1}}`, + GetEntityByRecordIdResult: `{"RESOLVED_ENTITY":{"ENTITY_ID":1}}`, + GetRecordResult: `{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001"}`, + GetRedoRecordResult: `{"REASON":"deferred delete","DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001","DSRC_ACTION":"X"}`, + GetRepositoryLastModifiedTimeResult: int64(1), + GetStatsResult: `{ "workload": { "loadedRecords": 5, "addedRecords": 5, "deletedRecords": 1, "reevaluations": 0, "repairedEntities": 0, "duration":...`, + GetVirtualEntityByRecordIdResult: `{"RESOLVED_ENTITY":{"ENTITY_ID":1}}`, + HowEntityByEntityIdResult: `{"HOW_RESULTS":{"FINAL_STATE":{"NEED_REEVALUATION":0,"VIRTUAL_ENTITIES":[{"MEMBER_RECORDS":[{"INTERNAL_ID":1,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":null}]},{"INTERNAL_ID":2,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":null}]}],"VIRTUAL_ENTITY_ID":"V1-S1"}]},"RESOLUTION_STEPS":[{"INBOUND_VIRTUAL_ENTITY_ID":"V2","MATCH_INFO":{"ERRULE_CODE":"CNAME_CFF_CEXCL","MATCH_KEY":"+NAME+DOB+PHONE"},"RESULT_VIRTUAL_ENTITY_ID":"V1-S1","STEP":1,"VIRTUAL_ENTITY_1":{"MEMBER_RECORDS":[{"INTERNAL_ID":1,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":null}]}],"VIRTUAL_ENTITY_ID":"V1"},"VIRTUAL_ENTITY_2":{"MEMBER_RECORDS":[{"INTERNAL_ID":2,"RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":null}]}],"VIRTUAL_ENTITY_ID":"V2"}}]}}`, + ProcessRedoRecordResult: ``, + ReevaluateEntityResult: "{}", + ReevaluateRecordResult: "{}", + SearchByAttributesResult: `{"RESOLVED_ENTITIES":[{"ENTITY":{"RESOLVED_ENTITY":{"ENTITY_ID":1}},"MATCH_INFO":{"ERRULE_CODE":"SF1","MATCH_KEY":"+PNAME+EMAIL","MATCH_LEVEL_CODE":"POSSIBLY_RELATED"}}]}`, + WhyEntitiesResult: `{"WHY_RESULTS":[{"ENTITY_ID":1,"ENTITY_ID_2":1,"MATCH_INFO":{"WHY_KEY":...`, + WhyRecordsResult: `{"WHY_RESULTS":[{"INTERNAL_ID":1,"ENTITY_ID":1,"FOCUS_RECORDS":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001"}],"INTERNAL_ID_2":2,"ENTITY_ID_2":1,"FOCUS_RECORDS_2":[{"DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1002"}],"MATCH_INFO":{"WHY_KEY":"+NAME+DOB+PHONE","WHY_ERRULE_CODE":"CNAME_CFF_CEXCL","MATCH_LEVEL_CODE":"RESOLVED"}}],"ENTITIES":[{"RESOLVED_ENTITY":{"ENTITY_ID":1}}]}`, + } + } + return szEngineSingleton +} + +func getSzEngineAsInterface(ctx context.Context) sz.SzEngine { + return getSzEngine(ctx) +} + +func getEntityId(record record.Record) int64 { + return getEntityIdForRecord(record.DataSource, record.Id) +} + +func getEntityIdForRecord(datasource string, id string) int64 { + ctx := context.TODO() + var result int64 = 0 + szEngine := getSzEngine(ctx) + response, err := szEngine.GetEntityByRecordId(ctx, datasource, id, sz.SZ_WITHOUT_INFO) + if err != nil { + return result + } + getEntityByRecordIdResponse := &GetEntityByRecordIdResponse{} + err = json.Unmarshal([]byte(response), &getEntityByRecordIdResponse) + if err != nil { + return result + } + return getEntityByRecordIdResponse.ResolvedEntity.EntityId +} + +func getEntityIdString(record record.Record) string { + entityId := getEntityId(record) + return strconv.FormatInt(entityId, 10) +} + +func getEntityIdStringForRecord(datasource string, id string) string { + entityId := getEntityIdForRecord(datasource, id) + return strconv.FormatInt(entityId, 10) +} + +func getSettings() (string, error) { + return "{}", nil +} + +func getTestObject(ctx context.Context, test *testing.T) *Szengine { + _ = test + return getSzEngine(ctx) +} + +func printActual(test *testing.T, actual interface{}) { + printResult(test, "Actual", actual) +} + +func printResult(test *testing.T, title string, result interface{}) { + if printResults { + test.Logf("%s: %v", title, truncate(fmt.Sprintf("%v", result), defaultTruncation)) + } +} + +func testError(test *testing.T, err error) { + if err != nil { + test.Log("Error:", err.Error()) + assert.FailNow(test, err.Error()) + } +} + +func testErrorNoFail(test *testing.T, err error) { + if err != nil { + test.Log("Error:", err.Error()) + } +} + +func truncate(aString string, length int) string { + return truncator.Truncate(aString, length, "...", truncator.PositionEnd) +} + +// ---------------------------------------------------------------------------- +// Test harness +// ---------------------------------------------------------------------------- + +func TestMain(m *testing.M) { + err := setup() + if err != nil { + if szerror.Is(err, szerror.SzUnrecoverable) { + fmt.Printf("\nUnrecoverable error detected. \n\n") + } + if szerror.Is(err, szerror.SzRetryable) { + fmt.Printf("\nRetryable error detected. \n\n") + } + if szerror.Is(err, szerror.SzBadInput) { + fmt.Printf("\nBad user input error detected. \n\n") + } + fmt.Print(err) + os.Exit(1) + } + code := m.Run() + err = teardown() + if err != nil { + fmt.Print(err) + } + os.Exit(code) +} + +func setup() error { + var err error = nil + return err +} + +func teardown() error { + var err error = nil + return err +} diff --git a/szproduct/doc.go b/szproduct/doc.go new file mode 100644 index 0000000..5236cdd --- /dev/null +++ b/szproduct/doc.go @@ -0,0 +1,4 @@ +/* +The szproduct package is used make SzProduct requests to a mock object. +*/ +package szproduct diff --git a/g2product/main.go b/szproduct/main.go similarity index 73% rename from g2product/main.go rename to szproduct/main.go index c6e4a92..92b74d6 100644 --- a/g2product/main.go +++ b/szproduct/main.go @@ -1,8 +1,8 @@ -package g2product +package szproduct // ---------------------------------------------------------------------------- // Constants // ---------------------------------------------------------------------------- -// Identfier of the g2product package found messages having the format "senzing-6036xxxx". +// Identfier of the szproduct package found messages having the format "senzing-6036xxxx". const ComponentId = 6036 diff --git a/g2product/g2product.go b/szproduct/szproduct.go similarity index 78% rename from g2product/g2product.go rename to szproduct/szproduct.go index c3a7f97..cb7819e 100644 --- a/g2product/g2product.go +++ b/szproduct/szproduct.go @@ -1,27 +1,22 @@ /* - * - */ +Package szproduct implements a client for the service. +*/ -// Package g2product implements a client for the service. -package g2product +package szproduct import ( "context" "strconv" "time" - g2productapi "github.com/senzing-garage/g2-sdk-go/g2product" "github.com/senzing-garage/go-logging/logging" "github.com/senzing-garage/go-observing/notifier" "github.com/senzing-garage/go-observing/observer" "github.com/senzing-garage/go-observing/subject" + szproductapi "github.com/senzing-garage/sz-sdk-go/szproduct" ) -// ---------------------------------------------------------------------------- -// Types -// ---------------------------------------------------------------------------- - -type G2product struct { +type Szproduct struct { isTrace bool LicenseResult string logger logging.LoggingInterface @@ -31,63 +26,88 @@ type G2product struct { } // ---------------------------------------------------------------------------- -// Internal methods +// sz-sdk-go.SzProduct interface methods // ---------------------------------------------------------------------------- -// --- Logging ---------------------------------------------------------------- +/* +The Destroy method will destroy and perform cleanup for the Senzing G2Product object. +It should be called after all other calls are complete. -// Get the Logger singleton. -func (client *G2product) getLogger() logging.LoggingInterface { +Input + - ctx: A context to control lifecycle. +*/ +func (client *Szproduct) Destroy(ctx context.Context) error { var err error = nil - if client.logger == nil { - options := []interface{}{ - &logging.OptionCallerSkip{Value: 4}, - } - client.logger, err = logging.NewSenzingSdkLogger(ComponentId, g2productapi.IdMessages, options...) - if err != nil { - panic(err) - } + if client.isTrace { + entryTime := time.Now() + client.traceEntry(3) + defer func() { client.traceExit(4, err, time.Since(entryTime)) }() } - return client.logger + if client.observers != nil { + go func() { + details := map[string]string{} + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8001, err, details) + }() + } + return err } -// Trace method entry. -func (client *G2product) traceEntry(errorNumber int, details ...interface{}) { - client.getLogger().Log(errorNumber, details...) -} +/* +The GetLicense method retrieves information about the currently used license by the Senzing API. -// Trace method exit. -func (client *G2product) traceExit(errorNumber int, details ...interface{}) { - client.getLogger().Log(errorNumber, details...) -} +Input + - ctx: A context to control lifecycle. -// ---------------------------------------------------------------------------- -// Interface methods -// ---------------------------------------------------------------------------- +Output + - A JSON document containing Senzing license metadata. + See the example output. +*/ +func (client *Szproduct) GetLicense(ctx context.Context) (string, error) { + var err error = nil + if client.isTrace { + entryTime := time.Now() + client.traceEntry(11) + defer func() { client.traceExit(12, client.LicenseResult, err, time.Since(entryTime)) }() + } + if client.observers != nil { + go func() { + details := map[string]string{} + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8003, err, details) + }() + } + return client.LicenseResult, err +} /* -The Destroy method will destroy and perform cleanup for the Senzing G2Product object. -It should be called after all other calls are complete. +The GetVersion method returns the version of the Senzing API. Input - ctx: A context to control lifecycle. + +Output + - A JSON document containing metadata about the Senzing Engine version being used. + See the example output. */ -func (client *G2product) Destroy(ctx context.Context) error { +func (client *Szproduct) GetVersion(ctx context.Context) (string, error) { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(3) - defer func() { client.traceExit(4, err, time.Since(entryTime)) }() + client.traceEntry(19) + defer func() { client.traceExit(20, client.VersionResult, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{} - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8001, err, details) + notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8006, err, details) }() } - return err + return client.VersionResult, err } +// ---------------------------------------------------------------------------- +// Public non-interface methods +// ---------------------------------------------------------------------------- + /* The GetObserverOrigin method returns the "origin" value of past Observer messages. @@ -97,19 +117,19 @@ Input Output - The value sent in the Observer's "origin" key/value pair. */ -func (client *G2product) GetObserverOrigin(ctx context.Context) string { +func (client *Szproduct) GetObserverOrigin(ctx context.Context) string { return client.observerOrigin } /* The GetSdkId method returns the identifier of this particular Software Development Kit (SDK). -It is handy when working with multiple implementations of the same G2productInterface. +It is handy when working with multiple implementations of the same SzProduct interface. For this implementation, "mock" is returned. Input - ctx: A context to control lifecycle. */ -func (client *G2product) GetSdkId(ctx context.Context) string { +func (client *Szproduct) GetSdkId(ctx context.Context) string { var err error = nil if client.isTrace { entryTime := time.Now() @@ -126,27 +146,27 @@ func (client *G2product) GetSdkId(ctx context.Context) string { } /* -The Init method initializes the Senzing G2Product object. +The Initialize method initializes the Senzing SzProduct object. It must be called prior to any other calls. Input - ctx: A context to control lifecycle. - - moduleName: A name for the auditing node, to help identify it within system logs. - - iniParams: A JSON string containing configuration parameters. + - instanceName: A name for the auditing node, to help identify it within system logs. + - settings: A JSON string containing configuration parameters. - verboseLogging: A flag to enable deeper logging of the G2 processing. 0 for no Senzing logging; 1 for logging. */ -func (client *G2product) Init(ctx context.Context, moduleName string, iniParams string, verboseLogging int64) error { +func (client *Szproduct) Initialize(ctx context.Context, instanceName string, settings string, verboseLogging int64) error { var err error = nil if client.isTrace { entryTime := time.Now() - client.traceEntry(9, moduleName, iniParams, verboseLogging) - defer func() { client.traceExit(10, moduleName, iniParams, verboseLogging, err, time.Since(entryTime)) }() + client.traceEntry(9, instanceName, settings, verboseLogging) + defer func() { client.traceExit(10, instanceName, settings, verboseLogging, err, time.Since(entryTime)) }() } if client.observers != nil { go func() { details := map[string]string{ - "iniParams": iniParams, - "moduleName": moduleName, + "instanceName": instanceName, + "settings": settings, "verboseLogging": strconv.FormatInt(verboseLogging, 10), } notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8002, err, details) @@ -155,32 +175,6 @@ func (client *G2product) Init(ctx context.Context, moduleName string, iniParams return err } -/* -The License method retrieves information about the currently used license by the Senzing API. - -Input - - ctx: A context to control lifecycle. - -Output - - A JSON document containing Senzing license metadata. - See the example output. -*/ -func (client *G2product) License(ctx context.Context) (string, error) { - var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(11) - defer func() { client.traceExit(12, client.LicenseResult, err, time.Since(entryTime)) }() - } - if client.observers != nil { - go func() { - details := map[string]string{} - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8003, err, details) - }() - } - return client.LicenseResult, err -} - /* The RegisterObserver method adds the observer to the list of observers notified. @@ -188,7 +182,7 @@ Input - ctx: A context to control lifecycle. - observer: The observer to be added. */ -func (client *G2product) RegisterObserver(ctx context.Context, observer observer.Observer) error { +func (client *Szproduct) RegisterObserver(ctx context.Context, observer observer.Observer) error { var err error = nil if client.isTrace { entryTime := time.Now() @@ -202,7 +196,7 @@ func (client *G2product) RegisterObserver(ctx context.Context, observer observer if client.observers != nil { go func() { details := map[string]string{ - "observerID": observer.GetObserverId(ctx), + "observerId": observer.GetObserverId(ctx), } notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8008, err, details) }() @@ -217,7 +211,7 @@ Input - ctx: A context to control lifecycle. - logLevel: The desired log level. TRACE, DEBUG, INFO, WARN, ERROR, FATAL or PANIC. */ -func (client *G2product) SetLogLevel(ctx context.Context, logLevelName string) error { +func (client *Szproduct) SetLogLevel(ctx context.Context, logLevelName string) error { var err error = nil if client.isTrace { entryTime := time.Now() @@ -229,7 +223,7 @@ func (client *G2product) SetLogLevel(ctx context.Context, logLevelName string) e if client.observers != nil { go func() { details := map[string]string{ - "logLevel": logLevelName, + "logLevelName": logLevelName, } notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8009, err, details) }() @@ -244,7 +238,7 @@ Input - ctx: A context to control lifecycle. - origin: The value sent in the Observer's "origin" key/value pair. */ -func (client *G2product) SetObserverOrigin(ctx context.Context, origin string) { +func (client *Szproduct) SetObserverOrigin(ctx context.Context, origin string) { client.observerOrigin = origin } @@ -255,7 +249,7 @@ Input - ctx: A context to control lifecycle. - observer: The observer to be added. */ -func (client *G2product) UnregisterObserver(ctx context.Context, observer observer.Observer) error { +func (client *Szproduct) UnregisterObserver(ctx context.Context, observer observer.Observer) error { var err error = nil if client.isTrace { entryTime := time.Now() @@ -268,7 +262,7 @@ func (client *G2product) UnregisterObserver(ctx context.Context, observer observ // In client.notify, each observer will get notified in a goroutine. // Then client.observers may be set to nil, but observer goroutines will be OK. details := map[string]string{ - "observerID": observer.GetObserverId(ctx), + "observerId": observer.GetObserverId(ctx), } notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8010, err, details) } @@ -279,28 +273,33 @@ func (client *G2product) UnregisterObserver(ctx context.Context, observer observ return err } -/* -The Version method returns the version of the Senzing API. +// ---------------------------------------------------------------------------- +// Internal methods +// ---------------------------------------------------------------------------- -Input - - ctx: A context to control lifecycle. +// --- Logging ---------------------------------------------------------------- -Output - - A JSON document containing metadata about the Senzing Engine version being used. - See the example output. -*/ -func (client *G2product) Version(ctx context.Context) (string, error) { +// Get the Logger singleton. +func (client *Szproduct) getLogger() logging.LoggingInterface { var err error = nil - if client.isTrace { - entryTime := time.Now() - client.traceEntry(19) - defer func() { client.traceExit(20, client.VersionResult, err, time.Since(entryTime)) }() - } - if client.observers != nil { - go func() { - details := map[string]string{} - notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8006, err, details) - }() + if client.logger == nil { + options := []interface{}{ + &logging.OptionCallerSkip{Value: 4}, + } + client.logger, err = logging.NewSenzingSdkLogger(ComponentId, szproductapi.IdMessages, options...) + if err != nil { + panic(err) + } } - return client.VersionResult, err + return client.logger +} + +// Trace method entry. +func (client *Szproduct) traceEntry(errorNumber int, details ...interface{}) { + client.getLogger().Log(errorNumber, details...) +} + +// Trace method exit. +func (client *Szproduct) traceExit(errorNumber int, details ...interface{}) { + client.getLogger().Log(errorNumber, details...) } diff --git a/szproduct/szproduct_examples_test.go b/szproduct/szproduct_examples_test.go new file mode 100644 index 0000000..e94eeee --- /dev/null +++ b/szproduct/szproduct_examples_test.go @@ -0,0 +1,103 @@ +//go:build linux + +package szproduct + +import ( + "context" + "fmt" + + "github.com/senzing-garage/go-logging/logging" + "github.com/senzing-garage/sz-sdk-go/sz" +) + +// ---------------------------------------------------------------------------- +// Interface functions - Examples for godoc documentation +// ---------------------------------------------------------------------------- + +func ExampleSzproduct_GetLicense() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szproduct/szproduct_examples_test.go + ctx := context.TODO() + szProduct := getSzProduct(ctx) + result, err := szProduct.GetLicense(ctx) + if err != nil { + fmt.Println(err) + } + fmt.Println(result) + // Output: {"customer":"Senzing Public Test License","contract":"Senzing Public Test - 50K records test","issueDate":"2023-11-02","licenseType":"EVAL (Solely for non-productive use)","licenseLevel":"STANDARD","billing":"YEARLY","expireDate":"2024-11-02","recordLimit":50000} +} + +func ExampleSzproduct_GetVersion() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szproduct/szproduct_examples_test.go + ctx := context.TODO() + szProduct := getSzProduct(ctx) + result, err := szProduct.GetVersion(ctx) + if err != nil { + fmt.Println(err) + } + fmt.Println(truncate(result, 43)) + // Output: {"PRODUCT_NAME":"Senzing API","VERSION":... +} + +// ---------------------------------------------------------------------------- +// Logging and observing +// ---------------------------------------------------------------------------- + +func ExampleSzproduct_SetLogLevel() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szproduct/szproduct_examples_test.go + ctx := context.TODO() + szProduct := getSzProduct(ctx) + err := szProduct.SetLogLevel(ctx, logging.LevelInfoName) + if err != nil { + fmt.Println(err) + } + // Output: +} + +func ExampleSzproduct_SetObserverOrigin() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szproduct/szproduct_examples_test.go + ctx := context.TODO() + szProduct := getSzProduct(ctx) + origin := "Machine: nn; Task: UnitTest" + szProduct.SetObserverOrigin(ctx, origin) + // Output: +} + +func ExampleSzproduct_GetObserverOrigin() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szproduct/szproduct_examples_test.go + ctx := context.TODO() + szProduct := getSzProduct(ctx) + origin := "Machine: nn; Task: UnitTest" + szProduct.SetObserverOrigin(ctx, origin) + result := szProduct.GetObserverOrigin(ctx) + fmt.Println(result) + // Output: Machine: nn; Task: UnitTest +} + +// ---------------------------------------------------------------------------- +// Object creation / destruction +// ---------------------------------------------------------------------------- + +func ExampleSzproduct_Initialize() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szproduct/szproduct_examples_test.go + ctx := context.TODO() + szProduct := getSzProduct(ctx) + instanceName := "Test name" + settings, err := getSettings() + if err != nil { + fmt.Println(err) + } + verboseLogging := sz.SZ_NO_LOGGING + szProduct.Initialize(ctx, instanceName, settings, verboseLogging) + // Output: +} + +func ExampleSzproduct_Destroy() { + // For more information, visit https://github.com/senzing-garage/sz-sdk-go-mock/blob/main/szproduct/szproduct_examples_test.go + ctx := context.TODO() + szProduct := getSzProduct(ctx) + err := szProduct.Destroy(ctx) + if err != nil { + fmt.Println(err) + } + // Output: +} diff --git a/szproduct/szproduct_test.go b/szproduct/szproduct_test.go new file mode 100644 index 0000000..b6f8a65 --- /dev/null +++ b/szproduct/szproduct_test.go @@ -0,0 +1,168 @@ +package szproduct + +import ( + "context" + "fmt" + "os" + "testing" + + truncator "github.com/aquilax/truncate" + "github.com/senzing-garage/sz-sdk-go/sz" + "github.com/stretchr/testify/assert" +) + +const ( + defaultTruncation = 76 + printResults = false +) + +var ( + szProductSingleton *Szproduct +) + +// ---------------------------------------------------------------------------- +// Interface functions - test +// ---------------------------------------------------------------------------- + +func TestSzproduct_GetLicense(test *testing.T) { + ctx := context.TODO() + szProduct := getTestObject(ctx, test) + actual, err := szProduct.GetLicense(ctx) + testError(test, err) + printActual(test, actual) +} + +func TestSzproduct_GetVersion(test *testing.T) { + ctx := context.TODO() + szProduct := getTestObject(ctx, test) + actual, err := szProduct.GetVersion(ctx) + testError(test, err) + printActual(test, actual) +} + +// ---------------------------------------------------------------------------- +// Logging and observing +// ---------------------------------------------------------------------------- + +func TestSzproduct_SetObserverOrigin(test *testing.T) { + ctx := context.TODO() + szProduct := getTestObject(ctx, test) + origin := "Machine: nn; Task: UnitTest" + szProduct.SetObserverOrigin(ctx, origin) +} + +func TestSzproduct_GetObserverOrigin(test *testing.T) { + ctx := context.TODO() + szProduct := getTestObject(ctx, test) + origin := "Machine: nn; Task: UnitTest" + szProduct.SetObserverOrigin(ctx, origin) + actual := szProduct.GetObserverOrigin(ctx) + assert.Equal(test, origin, actual) +} + +// ---------------------------------------------------------------------------- +// Object creation / destruction +// ---------------------------------------------------------------------------- + +func TestSzproduct_AsInterface(test *testing.T) { + ctx := context.TODO() + szProduct := getSzProductAsInterface(ctx) + actual, err := szProduct.GetLicense(ctx) + testError(test, err) + printActual(test, actual) +} + +func TestSzproduct_Initialize(test *testing.T) { + ctx := context.TODO() + szProduct := &Szproduct{} + instanceName := "Test name" + settings, err := getSettings() + testError(test, err) + verboseLogging := sz.SZ_NO_LOGGING + err = szProduct.Initialize(ctx, instanceName, settings, verboseLogging) + testError(test, err) +} + +func TestSzproduct_Destroy(test *testing.T) { + ctx := context.TODO() + szProduct := getTestObject(ctx, test) + err := szProduct.Destroy(ctx) + testError(test, err) +} + +// ---------------------------------------------------------------------------- +// Internal functions +// ---------------------------------------------------------------------------- + +func getSettings() (string, error) { + return "{}", nil +} + +func getSzProduct(ctx context.Context) *Szproduct { + _ = ctx + if szProductSingleton == nil { + szProductSingleton = &Szproduct{ + LicenseResult: `{"customer":"Senzing Public Test License","contract":"Senzing Public Test - 50K records test","issueDate":"2023-11-02","licenseType":"EVAL (Solely for non-productive use)","licenseLevel":"STANDARD","billing":"YEARLY","expireDate":"2024-11-02","recordLimit":50000}`, + VersionResult: `{"PRODUCT_NAME":"Senzing API","VERSION":"3.5.0","BUILD_VERSION":"3.5.0.23041","BUILD_DATE":"2023-02-09","BUILD_NUMBER":"2023_02_09__23_01","COMPATIBILITY_VERSION":{"CONFIG_VERSION":"10"},"SCHEMA_VERSION":{"ENGINE_SCHEMA_VERSION":"3.5","MINIMUM_REQUIRED_SCHEMA_VERSION":"3.0","MAXIMUM_REQUIRED_SCHEMA_VERSION":"3.99"}}`, + } + } + return szProductSingleton +} + +func getSzProductAsInterface(ctx context.Context) sz.SzProduct { + return getSzProduct(ctx) +} + +func getTestObject(ctx context.Context, test *testing.T) *Szproduct { + _ = test + return getSzProduct(ctx) +} + +func printActual(test *testing.T, actual interface{}) { + printResult(test, "Actual", actual) +} + +func printResult(test *testing.T, title string, result interface{}) { + if printResults { + test.Logf("%s: %v", title, truncate(fmt.Sprintf("%v", result), defaultTruncation)) + } +} + +func testError(test *testing.T, err error) { + if err != nil { + test.Log("Error:", err.Error()) + assert.FailNow(test, err.Error()) + } +} + +func truncate(aString string, length int) string { + return truncator.Truncate(aString, length, "...", truncator.PositionEnd) +} + +// ---------------------------------------------------------------------------- +// Test harness +// ---------------------------------------------------------------------------- + +func TestMain(m *testing.M) { + err := setup() + if err != nil { + fmt.Print(err) + os.Exit(1) + } + code := m.Run() + err = teardown() + if err != nil { + fmt.Print(err) + } + os.Exit(code) +} + +func setup() error { + var err error = nil + return err +} + +func teardown() error { + var err error = nil + return err +}