Remove tenant service pattern
Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
@@ -27,7 +27,8 @@ func (r *mutationResolver) CreateProcessingActivity(ctx context.Context, input t
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
req := probo.CreateProcessingActivityRequest{
|
||||
OrganizationID: input.OrganizationID,
|
||||
@@ -52,7 +53,7 @@ func (r *mutationResolver) CreateProcessingActivity(ctx context.Context, input t
|
||||
ThirdPartyIDs: input.ThirdPartyIds,
|
||||
}
|
||||
|
||||
activity, err := prb.ProcessingActivities.Create(ctx, &req)
|
||||
activity, err := prb.ProcessingActivities.Create(ctx, scope, &req)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot create processing activity", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -69,7 +70,8 @@ func (r *mutationResolver) UpdateProcessingActivity(ctx context.Context, input t
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ID)
|
||||
prb := r.probo
|
||||
|
||||
req := probo.UpdateProcessingActivityRequest{
|
||||
ID: input.ID,
|
||||
@@ -94,7 +96,7 @@ func (r *mutationResolver) UpdateProcessingActivity(ctx context.Context, input t
|
||||
ThirdPartyIDs: &input.ThirdPartyIds,
|
||||
}
|
||||
|
||||
activity, err := prb.ProcessingActivities.Update(ctx, &req)
|
||||
activity, err := prb.ProcessingActivities.Update(ctx, scope, &req)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot update processing activity", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -111,9 +113,10 @@ func (r *mutationResolver) DeleteProcessingActivity(ctx context.Context, input t
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.ProcessingActivityID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.ProcessingActivityID)
|
||||
prb := r.probo
|
||||
|
||||
err := prb.ProcessingActivities.Delete(ctx, input.ProcessingActivityID)
|
||||
err := prb.ProcessingActivities.Delete(ctx, scope, input.ProcessingActivityID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot delete processing activity", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -130,9 +133,10 @@ func (r *mutationResolver) PublishProcessingActivityList(ctx context.Context, in
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(input.OrganizationID)
|
||||
prb := r.probo
|
||||
|
||||
document, documentVersion, err := prb.GeneratedDocuments.PublishProcessingActivityList(ctx, input.OrganizationID, input.ApproverIds, input.Minor)
|
||||
document, documentVersion, err := prb.GeneratedDocuments.PublishProcessingActivityList(ctx, scope, input.OrganizationID, input.ApproverIds, input.Minor)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
|
||||
return nil, gqlutils.Conflict(ctx, err)
|
||||
@@ -207,7 +211,8 @@ func (r *processingActivityResolver) ThirdParties(ctx context.Context, obj *type
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.ThirdPartyOrderField]{
|
||||
Field: coredata.ThirdPartyOrderFieldCreatedAt,
|
||||
@@ -222,7 +227,7 @@ func (r *processingActivityResolver) ThirdParties(ctx context.Context, obj *type
|
||||
|
||||
cursor := types.NewCursor(first, after, last, before, pageOrderBy)
|
||||
|
||||
page, err := prb.ThirdParties.ListForProcessingActivityID(ctx, obj.ID, cursor)
|
||||
page, err := prb.ThirdParties.ListForProcessingActivityID(ctx, scope, obj.ID, cursor)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot list processing activity thirdParties", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -237,9 +242,10 @@ func (r *processingActivityResolver) DataProtectionImpactAssessment(ctx context.
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
dpia, err := prb.DataProtectionImpactAssessments.GetByProcessingActivityID(ctx, obj.ID)
|
||||
dpia, err := prb.DataProtectionImpactAssessments.GetByProcessingActivityID(ctx, scope, obj.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
@@ -259,9 +265,10 @@ func (r *processingActivityResolver) TransferImpactAssessment(ctx context.Contex
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ID)
|
||||
prb := r.probo
|
||||
|
||||
tia, err := prb.TransferImpactAssessments.GetByProcessingActivityID(ctx, obj.ID)
|
||||
tia, err := prb.TransferImpactAssessments.GetByProcessingActivityID(ctx, scope, obj.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, nil
|
||||
@@ -286,11 +293,12 @@ func (r *processingActivityConnectionResolver) TotalCount(ctx context.Context, o
|
||||
return 0, err
|
||||
}
|
||||
|
||||
prb := r.ProboService(ctx, obj.ParentID.TenantID())
|
||||
scope := coredata.NewScopeFromObjectID(obj.ParentID)
|
||||
prb := r.probo
|
||||
|
||||
switch obj.Resolver.(type) {
|
||||
case *organizationResolver:
|
||||
count, err := prb.ProcessingActivities.CountForOrganizationID(ctx, obj.ParentID)
|
||||
count, err := prb.ProcessingActivities.CountForOrganizationID(ctx, scope, obj.ParentID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot count organization processing activities", log.Error(err))
|
||||
return 0, gqlutils.Internal(ctx)
|
||||
|
||||
Reference in New Issue
Block a user