Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] feat: add generalized entity model for v2 search #530

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions internal/search/api_search.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package search

import (
"net/http"

"github.com/moov-io/base/log"

"github.com/gorilla/mux"
)

// GET /v2/search

type Controller interface {
AppendRoutes(router *mux.Router) *mux.Router
}

func NewController(logger log.Logger, service Service) Controller {

Check failure on line 17 in internal/search/api_search.go

View workflow job for this annotation

GitHub Actions / Build (Windows)

undefined: Service
return &controller{
logger: logger,
service: service,
}
}

type controller struct {
logger log.Logger
service Service

Check failure on line 26 in internal/search/api_search.go

View workflow job for this annotation

GitHub Actions / Build (Windows)

undefined: Service
}

func (c *controller) AppendRoutes(router *mux.Router) *mux.Router {
router.
Name("Search.v2").
Methods("GET").
Path("/v2/search").
HandlerFunc(c.search)

return router
}

func (c *controller) search(w http.ResponseWriter, r *http.Request) {
// TODO(adam):
}
42 changes: 42 additions & 0 deletions pkg/csl_eu/mapper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package csl

import (
"strings"
"time"

"github.com/moov-io/watchman/pkg/csl"
"github.com/moov-io/watchman/pkg/search"
)

func PtrToEntity(record *csl.EUCSLRecord) search.Entity[csl.EUCSLRecord] {
if record != nil {
return ToEntity(*record)
}
return search.Entity[csl.EUCSLRecord]{}
}

func ToEntity(record csl.EUCSLRecord) search.Entity[csl.EUCSLRecord] {
out := search.Entity[csl.EUCSLRecord]{
Source: search.SourceEUCSL,
SourceData: record,
}

if strings.EqualFold(record.EntitySubjectType, "person") {
out.Type = search.EntityPerson
out.Person = &search.Person{}

if len(record.NameAliasWholeNames) > 0 {
out.Name = record.NameAliasWholeNames[0]
out.Person.Name = record.NameAliasWholeNames[0]
out.Person.AltNames = record.NameAliasWholeNames[1:]
}
if len(record.BirthDates) > 0 {
tt, err := time.Parse("2006-01-02", record.BirthDates[0])
if err == nil {
out.Person.BirthDate = &tt
}
}
}

return out
}
186 changes: 186 additions & 0 deletions pkg/csl_us/mapper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
package mapper

import (
"github.com/moov-io/watchman/pkg/csl"
"github.com/moov-io/watchman/pkg/search"
)

// Entity List – Bureau of Industry and Security
func EL_ToEntity(record csl.EL) search.Entity[csl.EL] {
out := search.Entity[csl.EL]{
Source: search.SourceUSCSL,
SourceData: record,
}

out.Name = record.Name
// out.Type = // TODO(adam):

// record.AlternateNames []string // TODO(adam):
// record.Addresses []string // TODO(adam):

return out
}

// Military End User List
func MEU_ToEntity(record csl.MEU) search.Entity[csl.MEU] {
out := search.Entity[csl.MEU]{
Source: search.SourceUSCSL,
SourceData: record,
}

out.Name = record.Name

// Name string `json:"name"`
// Addresses string `json:"addresses"`

return out
}

// Sectoral Sanctions Identifications List (SSI) - Treasury Department
func SSI_ToEntity(record csl.SSI) search.Entity[csl.SSI] {
out := search.Entity[csl.SSI]{
Source: search.SourceUSCSL,
SourceData: record,
}

out.Name = record.Name

// Addresses []string `json:"addresses"`
// Remarks []string `json:"remarks"`
// AlternateNames []string `json:"alternateNames"`

// IDsOnRecord []string `json:"ids"`

return out
}

// Unverified List – Bureau of Industry and Security
func UVL_ToEntity(record csl.UVL) search.Entity[csl.UVL] {
out := search.Entity[csl.UVL]{
Source: search.SourceUSCSL,
SourceData: record,
}

out.Name = record.Name
// Addresses []string `json:"addresses"`

return out
}

// Foreign Sanctions Evaders (FSE) - Treasury Department
func FSE_ToEntity(record csl.FSE) search.Entity[csl.FSE] {
out := search.Entity[csl.FSE]{
Source: search.SourceUSCSL,
SourceData: record,
}

out.Name = record.Name

// Type string `json:"type"`
// Addresses []string `json:"addresses,omitempty"`
// DatesOfBirth string `json:"datesOfBirth"`
// IDs []string `json:"IDs"`

return out
}

// Nonproliferation Sanctions (ISN) - State Department
func ISN_ToEntity(record csl.ISN) search.Entity[csl.ISN] {
out := search.Entity[csl.ISN]{
Source: search.SourceUSCSL,
SourceData: record,
}

out.Name = record.Name

// Remarks []string `json:"remarks,omitempty"`
// AlternateNames []string `json:"alternateNames,omitempty"`

return out
}

// Palestinian Legislative Council List (PLC) - Treasury Department
func PLC_ToEntity(record csl.PLC) search.Entity[csl.PLC] {
out := search.Entity[csl.PLC]{
Source: search.SourceUSCSL,
SourceData: record,
}

out.Name = record.Name

// Type string `json:"type"`
// Addresses []string `json:"addresses,omitempty"`
// DatesOfBirth string `json:"datesOfBirth"`
// IDs []string `json:"IDs"`
// Remarks []string `json:"remarks,omitempty"`

return out
}

// CAPTA (formerly Foreign Financial Institutions Subject to Part 561 - Treasury Department)
func CAP_ToEntity(record csl.CAP) search.Entity[csl.CAP] {
out := search.Entity[csl.CAP]{
Source: search.SourceUSCSL,
SourceData: record,
}

out.Name = record.Name

// Type string `json:"type"`
// Addresses []string `json:"addresses,omitempty"`
// DatesOfBirth string `json:"datesOfBirth"`
// IDs []string `json:"IDs"`
// Remarks []string `json:"remarks,omitempty"`

return out
}

// ITAR Debarred (DTC) - State Department
func DTC_ToEntity(record csl.DTC) search.Entity[csl.DTC] {
out := search.Entity[csl.DTC]{
Source: search.SourceUSCSL,
SourceData: record,
}

out.Name = record.Name

// AlternateNames []string `json:"alternateNames,omitempty"`

return out
}

// Non-SDN Chinese Military-Industrial Complex Companies List (CMIC) - Treasury Department
func CMIC_ToEntity(record csl.CMIC) search.Entity[csl.CMIC] {
out := search.Entity[csl.CMIC]{
Source: search.SourceUSCSL,
SourceData: record,
}

out.Name = record.Name

// Type string `json:"type"`
// Addresses []string `json:"addresses,omitempty"`
// DatesOfBirth string `json:"datesOfBirth"`
// IDs []string `json:"IDs"`
// Remarks []string `json:"remarks,omitempty"`

return out
}

// Non-SDN Menu-Based Sanctions List (NS-MBS List) - Treasury Department
func NS_MBS_ToEntity(record csl.NS_MBS) search.Entity[csl.NS_MBS] {
out := search.Entity[csl.NS_MBS]{
Source: search.SourceUSCSL,
SourceData: record,
}

out.Name = record.Name

// Type string `json:"type"`
// Addresses []string `json:"addresses,omitempty"`
// DatesOfBirth string `json:"datesOfBirth"`
// IDs []string `json:"IDs"`
// Remarks []string `json:"remarks,omitempty"`

return out
}
Loading
Loading