Add new gdpr registries
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -67,6 +67,8 @@ const (
|
||||
UserAPIKeyEntityType uint16 = 43
|
||||
UserAPIKeyMembershipEntityType uint16 = 44
|
||||
MeetingEntityType uint16 = 45
|
||||
ProcessingActivityDPIAEntityType uint16 = 46
|
||||
ProcessingActivityTIAEntityType uint16 = 47
|
||||
)
|
||||
|
||||
type EntityInfo struct {
|
||||
@@ -259,6 +261,14 @@ var entityRegistry = map[uint16]EntityInfo{
|
||||
Model: "Meeting",
|
||||
Table: "meetings",
|
||||
},
|
||||
ProcessingActivityDPIAEntityType: {
|
||||
Model: "ProcessingActivityDPIA",
|
||||
Table: "processing_activity_data_protection_impact_assessments",
|
||||
},
|
||||
ProcessingActivityTIAEntityType: {
|
||||
Model: "ProcessingActivityTIA",
|
||||
Table: "processing_activity_transfer_impact_assessments",
|
||||
},
|
||||
}
|
||||
|
||||
func EntityTable(entityType uint16) (string, bool) {
|
||||
|
||||
62
pkg/coredata/migrations/20251216T153357Z.sql
Normal file
62
pkg/coredata/migrations/20251216T153357Z.sql
Normal file
@@ -0,0 +1,62 @@
|
||||
ALTER TABLE processing_activities ADD COLUMN last_review_date DATE;
|
||||
ALTER TABLE processing_activities ADD COLUMN next_review_date DATE;
|
||||
|
||||
CREATE TYPE processing_activity_role AS ENUM ('CONTROLLER', 'PROCESSOR');
|
||||
ALTER TABLE processing_activities ADD COLUMN IF NOT EXISTS role processing_activity_role NOT NULL DEFAULT 'PROCESSOR';
|
||||
ALTER TABLE processing_activities ALTER COLUMN role DROP DEFAULT;
|
||||
|
||||
ALTER TABLE processing_activities ADD COLUMN IF NOT EXISTS data_protection_officer_id TEXT REFERENCES peoples(id) ON DELETE RESTRICT;
|
||||
|
||||
CREATE TYPE processing_activity_dpia_residual_risk AS ENUM ('LOW', 'MEDIUM', 'HIGH');
|
||||
|
||||
CREATE TABLE processing_activity_data_protection_impact_assessments (
|
||||
id TEXT PRIMARY KEY,
|
||||
tenant_id TEXT NOT NULL,
|
||||
organization_id TEXT NOT NULL,
|
||||
processing_activity_id TEXT NOT NULL,
|
||||
description TEXT,
|
||||
necessity_and_proportionality TEXT,
|
||||
potential_risk TEXT,
|
||||
mitigations TEXT,
|
||||
residual_risk processing_activity_dpia_residual_risk,
|
||||
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
updated_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
|
||||
CONSTRAINT processing_activity_dpia_organization_id_fkey
|
||||
FOREIGN KEY (organization_id)
|
||||
REFERENCES organizations(id)
|
||||
ON UPDATE CASCADE
|
||||
ON DELETE CASCADE,
|
||||
|
||||
CONSTRAINT processing_activity_dpia_processing_activity_id_fkey
|
||||
FOREIGN KEY (processing_activity_id)
|
||||
REFERENCES processing_activities(id)
|
||||
ON UPDATE CASCADE
|
||||
ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE processing_activity_transfer_impact_assessments (
|
||||
id TEXT PRIMARY KEY,
|
||||
tenant_id TEXT NOT NULL,
|
||||
organization_id TEXT NOT NULL,
|
||||
processing_activity_id TEXT NOT NULL,
|
||||
data_subjects TEXT,
|
||||
legal_mechanism TEXT,
|
||||
transfer TEXT,
|
||||
local_law_risk TEXT,
|
||||
supplementary_measures TEXT,
|
||||
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
updated_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
|
||||
CONSTRAINT processing_activity_tia_organization_id_fkey
|
||||
FOREIGN KEY (organization_id)
|
||||
REFERENCES organizations(id)
|
||||
ON UPDATE CASCADE
|
||||
ON DELETE CASCADE,
|
||||
|
||||
CONSTRAINT processing_activity_tia_processing_activity_id_fkey
|
||||
FOREIGN KEY (processing_activity_id)
|
||||
REFERENCES processing_activities(id)
|
||||
ON UPDATE CASCADE
|
||||
ON DELETE CASCADE
|
||||
);
|
||||
@@ -47,6 +47,10 @@ type (
|
||||
SecurityMeasures *string `db:"security_measures"`
|
||||
DataProtectionImpactAssessment ProcessingActivityDataProtectionImpactAssessment `db:"data_protection_impact_assessment"`
|
||||
TransferImpactAssessment ProcessingActivityTransferImpactAssessment `db:"transfer_impact_assessment"`
|
||||
LastReviewDate *time.Time `db:"last_review_date"`
|
||||
NextReviewDate *time.Time `db:"next_review_date"`
|
||||
Role ProcessingActivityRole `db:"role"`
|
||||
DataProtectionOfficerID *gid.GID `db:"data_protection_officer_id"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}
|
||||
@@ -92,6 +96,10 @@ SELECT
|
||||
security_measures,
|
||||
data_protection_impact_assessment,
|
||||
transfer_impact_assessment,
|
||||
last_review_date,
|
||||
next_review_date,
|
||||
role,
|
||||
data_protection_officer_id,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
@@ -186,6 +194,10 @@ SELECT
|
||||
security_measures,
|
||||
data_protection_impact_assessment,
|
||||
transfer_impact_assessment,
|
||||
last_review_date,
|
||||
next_review_date,
|
||||
role,
|
||||
data_protection_officer_id,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
@@ -246,6 +258,10 @@ INSERT INTO processing_activities (
|
||||
security_measures,
|
||||
data_protection_impact_assessment,
|
||||
transfer_impact_assessment,
|
||||
last_review_date,
|
||||
next_review_date,
|
||||
role,
|
||||
data_protection_officer_id,
|
||||
created_at,
|
||||
updated_at
|
||||
) VALUES (
|
||||
@@ -269,6 +285,10 @@ INSERT INTO processing_activities (
|
||||
@security_measures,
|
||||
@data_protection_impact_assessment,
|
||||
@transfer_impact_assessment,
|
||||
@last_review_date,
|
||||
@next_review_date,
|
||||
@role,
|
||||
@data_protection_officer_id,
|
||||
@created_at,
|
||||
@updated_at
|
||||
)
|
||||
@@ -295,6 +315,10 @@ INSERT INTO processing_activities (
|
||||
"security_measures": p.SecurityMeasures,
|
||||
"data_protection_impact_assessment": p.DataProtectionImpactAssessment,
|
||||
"transfer_impact_assessment": p.TransferImpactAssessment,
|
||||
"last_review_date": p.LastReviewDate,
|
||||
"next_review_date": p.NextReviewDate,
|
||||
"role": p.Role,
|
||||
"data_protection_officer_id": p.DataProtectionOfficerID,
|
||||
"created_at": p.CreatedAt,
|
||||
"updated_at": p.UpdatedAt,
|
||||
}
|
||||
@@ -330,6 +354,10 @@ SET
|
||||
security_measures = @security_measures,
|
||||
data_protection_impact_assessment = @data_protection_impact_assessment,
|
||||
transfer_impact_assessment = @transfer_impact_assessment,
|
||||
last_review_date = @last_review_date,
|
||||
next_review_date = @next_review_date,
|
||||
role = @role,
|
||||
data_protection_officer_id = @data_protection_officer_id,
|
||||
updated_at = @updated_at
|
||||
WHERE
|
||||
%s
|
||||
@@ -356,6 +384,10 @@ WHERE
|
||||
"security_measures": p.SecurityMeasures,
|
||||
"data_protection_impact_assessment": p.DataProtectionImpactAssessment,
|
||||
"transfer_impact_assessment": p.TransferImpactAssessment,
|
||||
"last_review_date": p.LastReviewDate,
|
||||
"next_review_date": p.NextReviewDate,
|
||||
"role": p.Role,
|
||||
"data_protection_officer_id": p.DataProtectionOfficerID,
|
||||
"updated_at": p.UpdatedAt,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
@@ -435,6 +467,10 @@ INSERT INTO processing_activities (
|
||||
security_measures,
|
||||
data_protection_impact_assessment,
|
||||
transfer_impact_assessment,
|
||||
last_review_date,
|
||||
next_review_date,
|
||||
role,
|
||||
data_protection_officer_id,
|
||||
created_at,
|
||||
updated_at
|
||||
)
|
||||
@@ -459,6 +495,10 @@ SELECT
|
||||
par.security_measures,
|
||||
par.data_protection_impact_assessment,
|
||||
par.transfer_impact_assessment,
|
||||
par.last_review_date,
|
||||
par.next_review_date,
|
||||
par.role,
|
||||
par.data_protection_officer_id,
|
||||
par.created_at,
|
||||
par.updated_at
|
||||
FROM processing_activities par
|
||||
|
||||
359
pkg/coredata/processing_activity_dpia.go
Normal file
359
pkg/coredata/processing_activity_dpia.go
Normal file
@@ -0,0 +1,359 @@
|
||||
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"maps"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
"go.gearno.de/kit/pg"
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type ErrProcessingActivityDPIANotFound struct {
|
||||
Identifier string
|
||||
}
|
||||
|
||||
func (e ErrProcessingActivityDPIANotFound) Error() string {
|
||||
return fmt.Sprintf("processing activity dpia not found: %q", e.Identifier)
|
||||
}
|
||||
|
||||
type (
|
||||
ProcessingActivityDPIA struct {
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
ProcessingActivityID gid.GID `db:"processing_activity_id"`
|
||||
Description *string `db:"description"`
|
||||
NecessityAndProportionality *string `db:"necessity_and_proportionality"`
|
||||
PotentialRisk *string `db:"potential_risk"`
|
||||
Mitigations *string `db:"mitigations"`
|
||||
ResidualRisk *ProcessingActivityDPIAResidualRisk `db:"residual_risk"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}
|
||||
|
||||
ProcessingActivityDPIAs []*ProcessingActivityDPIA
|
||||
)
|
||||
|
||||
func (dpia *ProcessingActivityDPIA) CursorKey(field ProcessingActivityDPIAOrderField) page.CursorKey {
|
||||
switch field {
|
||||
case ProcessingActivityDPIAOrderFieldCreatedAt:
|
||||
return page.NewCursorKey(dpia.ID, dpia.CreatedAt)
|
||||
}
|
||||
|
||||
panic(fmt.Sprintf("unsupported order by: %s", field))
|
||||
}
|
||||
|
||||
func (dpias *ProcessingActivityDPIAs) CountByOrganizationID(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
organizationID gid.GID,
|
||||
) (int, error) {
|
||||
q := `
|
||||
SELECT
|
||||
COUNT(id)
|
||||
FROM
|
||||
processing_activity_data_protection_impact_assessments
|
||||
WHERE
|
||||
%s
|
||||
AND organization_id = @organization_id
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"organization_id": organizationID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
row := conn.QueryRow(ctx, q, args)
|
||||
|
||||
var count int
|
||||
err := row.Scan(&count)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("cannot count processing activity dpias: %w", err)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
func (dpias *ProcessingActivityDPIAs) LoadByOrganizationID(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
organizationID gid.GID,
|
||||
cursor *page.Cursor[ProcessingActivityDPIAOrderField],
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
id,
|
||||
organization_id,
|
||||
processing_activity_id,
|
||||
description,
|
||||
necessity_and_proportionality,
|
||||
potential_risk,
|
||||
mitigations,
|
||||
residual_risk,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
processing_activity_data_protection_impact_assessments
|
||||
WHERE
|
||||
%s
|
||||
AND organization_id = @organization_id
|
||||
AND %s
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"organization_id": organizationID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
maps.Copy(args, cursor.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query processing activity dpias: %w", err)
|
||||
}
|
||||
|
||||
results, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[ProcessingActivityDPIA])
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot collect processing activity dpias: %w", err)
|
||||
}
|
||||
|
||||
*dpias = results
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dpia *ProcessingActivityDPIA) LoadByID(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
dpiaID gid.GID,
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
id,
|
||||
organization_id,
|
||||
processing_activity_id,
|
||||
description,
|
||||
necessity_and_proportionality,
|
||||
potential_risk,
|
||||
mitigations,
|
||||
residual_risk,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
processing_activity_data_protection_impact_assessments
|
||||
WHERE
|
||||
%s
|
||||
AND id = @dpia_id
|
||||
LIMIT 1;
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"dpia_id": dpiaID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query processing activity dpia: %w", err)
|
||||
}
|
||||
|
||||
result, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[ProcessingActivityDPIA])
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return &ErrProcessingActivityDPIANotFound{Identifier: dpiaID.String()}
|
||||
}
|
||||
return fmt.Errorf("cannot collect processing activity dpia: %w", err)
|
||||
}
|
||||
|
||||
*dpia = result
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dpia *ProcessingActivityDPIA) LoadByProcessingActivityID(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
processingActivityID gid.GID,
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
id,
|
||||
organization_id,
|
||||
processing_activity_id,
|
||||
description,
|
||||
necessity_and_proportionality,
|
||||
potential_risk,
|
||||
mitigations,
|
||||
residual_risk,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
processing_activity_data_protection_impact_assessments
|
||||
WHERE
|
||||
%s
|
||||
AND processing_activity_id = @processing_activity_id
|
||||
LIMIT 1;
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"processing_activity_id": processingActivityID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query processing activity dpia: %w", err)
|
||||
}
|
||||
|
||||
result, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[ProcessingActivityDPIA])
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return &ErrProcessingActivityDPIANotFound{Identifier: processingActivityID.String()}
|
||||
}
|
||||
return fmt.Errorf("cannot collect processing activity dpia: %w", err)
|
||||
}
|
||||
|
||||
*dpia = result
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dpia *ProcessingActivityDPIA) Insert(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
) error {
|
||||
q := `
|
||||
INSERT INTO processing_activity_data_protection_impact_assessments (
|
||||
id,
|
||||
tenant_id,
|
||||
organization_id,
|
||||
processing_activity_id,
|
||||
description,
|
||||
necessity_and_proportionality,
|
||||
potential_risk,
|
||||
mitigations,
|
||||
residual_risk,
|
||||
created_at,
|
||||
updated_at
|
||||
) VALUES (
|
||||
@id,
|
||||
@tenant_id,
|
||||
@organization_id,
|
||||
@processing_activity_id,
|
||||
@description,
|
||||
@necessity_and_proportionality,
|
||||
@potential_risk,
|
||||
@mitigations,
|
||||
@residual_risk,
|
||||
@created_at,
|
||||
@updated_at
|
||||
)
|
||||
`
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"id": dpia.ID,
|
||||
"tenant_id": scope.GetTenantID(),
|
||||
"organization_id": dpia.OrganizationID,
|
||||
"processing_activity_id": dpia.ProcessingActivityID,
|
||||
"description": dpia.Description,
|
||||
"necessity_and_proportionality": dpia.NecessityAndProportionality,
|
||||
"potential_risk": dpia.PotentialRisk,
|
||||
"mitigations": dpia.Mitigations,
|
||||
"residual_risk": dpia.ResidualRisk,
|
||||
"created_at": dpia.CreatedAt,
|
||||
"updated_at": dpia.UpdatedAt,
|
||||
}
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot insert processing activity dpia: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dpia *ProcessingActivityDPIA) Update(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
) error {
|
||||
q := `
|
||||
UPDATE processing_activity_data_protection_impact_assessments SET
|
||||
description = @description,
|
||||
necessity_and_proportionality = @necessity_and_proportionality,
|
||||
potential_risk = @potential_risk,
|
||||
mitigations = @mitigations,
|
||||
residual_risk = @residual_risk,
|
||||
updated_at = @updated_at
|
||||
WHERE
|
||||
%s
|
||||
AND id = @id
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"id": dpia.ID,
|
||||
"description": dpia.Description,
|
||||
"necessity_and_proportionality": dpia.NecessityAndProportionality,
|
||||
"potential_risk": dpia.PotentialRisk,
|
||||
"mitigations": dpia.Mitigations,
|
||||
"residual_risk": dpia.ResidualRisk,
|
||||
"updated_at": dpia.UpdatedAt,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot update processing activity dpia: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dpia *ProcessingActivityDPIA) Delete(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
) error {
|
||||
q := `
|
||||
DELETE FROM processing_activity_data_protection_impact_assessments
|
||||
WHERE
|
||||
%s
|
||||
AND id = @id
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"id": dpia.ID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot delete processing activity dpia: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
45
pkg/coredata/processing_activity_dpia_order_field.go
Normal file
45
pkg/coredata/processing_activity_dpia_order_field.go
Normal file
@@ -0,0 +1,45 @@
|
||||
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
package coredata
|
||||
|
||||
import "fmt"
|
||||
|
||||
type ProcessingActivityDPIAOrderField string
|
||||
|
||||
const (
|
||||
ProcessingActivityDPIAOrderFieldCreatedAt ProcessingActivityDPIAOrderField = "CREATED_AT"
|
||||
)
|
||||
|
||||
func (p ProcessingActivityDPIAOrderField) Column() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p ProcessingActivityDPIAOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p ProcessingActivityDPIAOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
func (p *ProcessingActivityDPIAOrderField) UnmarshalText(text []byte) error {
|
||||
val := string(text)
|
||||
switch val {
|
||||
case string(ProcessingActivityDPIAOrderFieldCreatedAt):
|
||||
*p = ProcessingActivityDPIAOrderFieldCreatedAt
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("invalid ProcessingActivityDPIAOrderField value: %q", val)
|
||||
}
|
||||
68
pkg/coredata/processing_activity_dpia_residual_risk.go
Normal file
68
pkg/coredata/processing_activity_dpia_residual_risk.go
Normal file
@@ -0,0 +1,68 @@
|
||||
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type ProcessingActivityDPIAResidualRisk string
|
||||
|
||||
const (
|
||||
ProcessingActivityDPIAResidualRiskLow ProcessingActivityDPIAResidualRisk = "LOW"
|
||||
ProcessingActivityDPIAResidualRiskMedium ProcessingActivityDPIAResidualRisk = "MEDIUM"
|
||||
ProcessingActivityDPIAResidualRiskHigh ProcessingActivityDPIAResidualRisk = "HIGH"
|
||||
)
|
||||
|
||||
func ProcessingActivityDPIAResidualRisks() []ProcessingActivityDPIAResidualRisk {
|
||||
return []ProcessingActivityDPIAResidualRisk{
|
||||
ProcessingActivityDPIAResidualRiskLow,
|
||||
ProcessingActivityDPIAResidualRiskMedium,
|
||||
ProcessingActivityDPIAResidualRiskHigh,
|
||||
}
|
||||
}
|
||||
|
||||
func (p ProcessingActivityDPIAResidualRisk) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p *ProcessingActivityDPIAResidualRisk) Scan(value any) error {
|
||||
var s string
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
s = v
|
||||
case []byte:
|
||||
s = string(v)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for ProcessingActivityDPIAResidualRisk: %T", value)
|
||||
}
|
||||
|
||||
switch s {
|
||||
case "LOW":
|
||||
*p = ProcessingActivityDPIAResidualRiskLow
|
||||
case "MEDIUM":
|
||||
*p = ProcessingActivityDPIAResidualRiskMedium
|
||||
case "HIGH":
|
||||
*p = ProcessingActivityDPIAResidualRiskHigh
|
||||
default:
|
||||
return fmt.Errorf("invalid ProcessingActivityDPIAResidualRisk value: %q", s)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p ProcessingActivityDPIAResidualRisk) Value() (driver.Value, error) {
|
||||
return p.String(), nil
|
||||
}
|
||||
64
pkg/coredata/processing_activity_role.go
Normal file
64
pkg/coredata/processing_activity_role.go
Normal file
@@ -0,0 +1,64 @@
|
||||
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type ProcessingActivityRole string
|
||||
|
||||
const (
|
||||
ProcessingActivityRoleController ProcessingActivityRole = "CONTROLLER"
|
||||
ProcessingActivityRoleProcessor ProcessingActivityRole = "PROCESSOR"
|
||||
)
|
||||
|
||||
func ProcessingActivityRoles() []ProcessingActivityRole {
|
||||
return []ProcessingActivityRole{
|
||||
ProcessingActivityRoleController,
|
||||
ProcessingActivityRoleProcessor,
|
||||
}
|
||||
}
|
||||
|
||||
func (p ProcessingActivityRole) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p *ProcessingActivityRole) Scan(value any) error {
|
||||
var s string
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
s = v
|
||||
case []byte:
|
||||
s = string(v)
|
||||
default:
|
||||
return fmt.Errorf("unsupported type for ProcessingActivityRole: %T", value)
|
||||
}
|
||||
|
||||
switch s {
|
||||
case "CONTROLLER":
|
||||
*p = ProcessingActivityRoleController
|
||||
case "PROCESSOR":
|
||||
*p = ProcessingActivityRoleProcessor
|
||||
default:
|
||||
return fmt.Errorf("invalid ProcessingActivityRole value: %q", s)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p ProcessingActivityRole) Value() (driver.Value, error) {
|
||||
return p.String(), nil
|
||||
}
|
||||
359
pkg/coredata/processing_activity_tia.go
Normal file
359
pkg/coredata/processing_activity_tia.go
Normal file
@@ -0,0 +1,359 @@
|
||||
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
package coredata
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"maps"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
"go.gearno.de/kit/pg"
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
type ErrProcessingActivityTIANotFound struct {
|
||||
Identifier string
|
||||
}
|
||||
|
||||
func (e ErrProcessingActivityTIANotFound) Error() string {
|
||||
return fmt.Sprintf("processing activity tia not found: %q", e.Identifier)
|
||||
}
|
||||
|
||||
type (
|
||||
ProcessingActivityTIA struct {
|
||||
ID gid.GID `db:"id"`
|
||||
OrganizationID gid.GID `db:"organization_id"`
|
||||
ProcessingActivityID gid.GID `db:"processing_activity_id"`
|
||||
DataSubjects *string `db:"data_subjects"`
|
||||
LegalMechanism *string `db:"legal_mechanism"`
|
||||
Transfer *string `db:"transfer"`
|
||||
LocalLawRisk *string `db:"local_law_risk"`
|
||||
SupplementaryMeasures *string `db:"supplementary_measures"`
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}
|
||||
|
||||
ProcessingActivityTIAs []*ProcessingActivityTIA
|
||||
)
|
||||
|
||||
func (tia *ProcessingActivityTIA) CursorKey(field ProcessingActivityTIAOrderField) page.CursorKey {
|
||||
switch field {
|
||||
case ProcessingActivityTIAOrderFieldCreatedAt:
|
||||
return page.NewCursorKey(tia.ID, tia.CreatedAt)
|
||||
}
|
||||
|
||||
panic(fmt.Sprintf("unsupported order by: %s", field))
|
||||
}
|
||||
|
||||
func (tias *ProcessingActivityTIAs) CountByOrganizationID(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
organizationID gid.GID,
|
||||
) (int, error) {
|
||||
q := `
|
||||
SELECT
|
||||
COUNT(id)
|
||||
FROM
|
||||
processing_activity_transfer_impact_assessments
|
||||
WHERE
|
||||
%s
|
||||
AND organization_id = @organization_id
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"organization_id": organizationID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
row := conn.QueryRow(ctx, q, args)
|
||||
|
||||
var count int
|
||||
err := row.Scan(&count)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("cannot count processing activity tias: %w", err)
|
||||
}
|
||||
|
||||
return count, nil
|
||||
}
|
||||
|
||||
func (tias *ProcessingActivityTIAs) LoadByOrganizationID(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
organizationID gid.GID,
|
||||
cursor *page.Cursor[ProcessingActivityTIAOrderField],
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
id,
|
||||
organization_id,
|
||||
processing_activity_id,
|
||||
data_subjects,
|
||||
legal_mechanism,
|
||||
transfer,
|
||||
local_law_risk,
|
||||
supplementary_measures,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
processing_activity_transfer_impact_assessments
|
||||
WHERE
|
||||
%s
|
||||
AND organization_id = @organization_id
|
||||
AND %s
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment(), cursor.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"organization_id": organizationID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
maps.Copy(args, cursor.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query processing activity tias: %w", err)
|
||||
}
|
||||
|
||||
results, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[ProcessingActivityTIA])
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot collect processing activity tias: %w", err)
|
||||
}
|
||||
|
||||
*tias = results
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tia *ProcessingActivityTIA) LoadByID(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
tiaID gid.GID,
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
id,
|
||||
organization_id,
|
||||
processing_activity_id,
|
||||
data_subjects,
|
||||
legal_mechanism,
|
||||
transfer,
|
||||
local_law_risk,
|
||||
supplementary_measures,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
processing_activity_transfer_impact_assessments
|
||||
WHERE
|
||||
%s
|
||||
AND id = @tia_id
|
||||
LIMIT 1;
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"tia_id": tiaID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query processing activity tia: %w", err)
|
||||
}
|
||||
|
||||
result, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[ProcessingActivityTIA])
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return &ErrProcessingActivityTIANotFound{Identifier: tiaID.String()}
|
||||
}
|
||||
return fmt.Errorf("cannot collect processing activity tia: %w", err)
|
||||
}
|
||||
|
||||
*tia = result
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tia *ProcessingActivityTIA) LoadByProcessingActivityID(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
processingActivityID gid.GID,
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
id,
|
||||
organization_id,
|
||||
processing_activity_id,
|
||||
data_subjects,
|
||||
legal_mechanism,
|
||||
transfer,
|
||||
local_law_risk,
|
||||
supplementary_measures,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
processing_activity_transfer_impact_assessments
|
||||
WHERE
|
||||
%s
|
||||
AND processing_activity_id = @processing_activity_id
|
||||
LIMIT 1;
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"processing_activity_id": processingActivityID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query processing activity tia: %w", err)
|
||||
}
|
||||
|
||||
result, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[ProcessingActivityTIA])
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return &ErrProcessingActivityTIANotFound{Identifier: processingActivityID.String()}
|
||||
}
|
||||
return fmt.Errorf("cannot collect processing activity tia: %w", err)
|
||||
}
|
||||
|
||||
*tia = result
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tia *ProcessingActivityTIA) Insert(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
) error {
|
||||
q := `
|
||||
INSERT INTO processing_activity_transfer_impact_assessments (
|
||||
id,
|
||||
tenant_id,
|
||||
organization_id,
|
||||
processing_activity_id,
|
||||
data_subjects,
|
||||
legal_mechanism,
|
||||
transfer,
|
||||
local_law_risk,
|
||||
supplementary_measures,
|
||||
created_at,
|
||||
updated_at
|
||||
) VALUES (
|
||||
@id,
|
||||
@tenant_id,
|
||||
@organization_id,
|
||||
@processing_activity_id,
|
||||
@data_subjects,
|
||||
@legal_mechanism,
|
||||
@transfer,
|
||||
@local_law_risk,
|
||||
@supplementary_measures,
|
||||
@created_at,
|
||||
@updated_at
|
||||
)
|
||||
`
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"id": tia.ID,
|
||||
"tenant_id": scope.GetTenantID(),
|
||||
"organization_id": tia.OrganizationID,
|
||||
"processing_activity_id": tia.ProcessingActivityID,
|
||||
"data_subjects": tia.DataSubjects,
|
||||
"legal_mechanism": tia.LegalMechanism,
|
||||
"transfer": tia.Transfer,
|
||||
"local_law_risk": tia.LocalLawRisk,
|
||||
"supplementary_measures": tia.SupplementaryMeasures,
|
||||
"created_at": tia.CreatedAt,
|
||||
"updated_at": tia.UpdatedAt,
|
||||
}
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot insert processing activity tia: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tia *ProcessingActivityTIA) Update(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
) error {
|
||||
q := `
|
||||
UPDATE processing_activity_transfer_impact_assessments SET
|
||||
data_subjects = @data_subjects,
|
||||
legal_mechanism = @legal_mechanism,
|
||||
transfer = @transfer,
|
||||
local_law_risk = @local_law_risk,
|
||||
supplementary_measures = @supplementary_measures,
|
||||
updated_at = @updated_at
|
||||
WHERE
|
||||
%s
|
||||
AND id = @id
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{
|
||||
"id": tia.ID,
|
||||
"data_subjects": tia.DataSubjects,
|
||||
"legal_mechanism": tia.LegalMechanism,
|
||||
"transfer": tia.Transfer,
|
||||
"local_law_risk": tia.LocalLawRisk,
|
||||
"supplementary_measures": tia.SupplementaryMeasures,
|
||||
"updated_at": tia.UpdatedAt,
|
||||
}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot update processing activity tia: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tia *ProcessingActivityTIA) Delete(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
) error {
|
||||
q := `
|
||||
DELETE FROM processing_activity_transfer_impact_assessments
|
||||
WHERE
|
||||
%s
|
||||
AND id = @id
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"id": tia.ID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
_, err := conn.Exec(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot delete processing activity tia: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
45
pkg/coredata/processing_activity_tia_order_field.go
Normal file
45
pkg/coredata/processing_activity_tia_order_field.go
Normal file
@@ -0,0 +1,45 @@
|
||||
// Copyright (c) 2025 Probo Inc <hello@getprobo.com>.
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice appear in all copies.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
package coredata
|
||||
|
||||
import "fmt"
|
||||
|
||||
type ProcessingActivityTIAOrderField string
|
||||
|
||||
const (
|
||||
ProcessingActivityTIAOrderFieldCreatedAt ProcessingActivityTIAOrderField = "CREATED_AT"
|
||||
)
|
||||
|
||||
func (p ProcessingActivityTIAOrderField) Column() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p ProcessingActivityTIAOrderField) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
func (p ProcessingActivityTIAOrderField) MarshalText() ([]byte, error) {
|
||||
return []byte(p.String()), nil
|
||||
}
|
||||
|
||||
func (p *ProcessingActivityTIAOrderField) UnmarshalText(text []byte) error {
|
||||
val := string(text)
|
||||
switch val {
|
||||
case string(ProcessingActivityTIAOrderFieldCreatedAt):
|
||||
*p = ProcessingActivityTIAOrderFieldCreatedAt
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("invalid ProcessingActivityTIAOrderField value: %q", val)
|
||||
}
|
||||
Reference in New Issue
Block a user