Skip to content

Commit

Permalink
feat: start on EU and US CSL mappers
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdecaf committed Mar 12, 2024
1 parent eb75cb1 commit 8c70f81
Show file tree
Hide file tree
Showing 2 changed files with 228 additions and 0 deletions.
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
}

0 comments on commit 8c70f81

Please sign in to comment.