This is an automated email from the ASF dual-hosted git repository.

lahirujayathilake pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-custos.git

commit 9da3275f8c16040931f458267e0c3deccfc57dbe
Author: lahiruj <[email protected]>
AuthorDate: Fri May 1 17:45:35 2026 -0400

    Included person global id store
---
 allocations/domain/go.sum                          | 10 ++++
 allocations/domain/store/person_global_id_store.go | 66 ++++++++++++++++++++++
 2 files changed, 76 insertions(+)

diff --git a/allocations/domain/go.sum b/allocations/domain/go.sum
new file mode 100644
index 000000000..f4ce33795
--- /dev/null
+++ b/allocations/domain/go.sum
@@ -0,0 +1,10 @@
+filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
+filippo.io/edwards25519 v1.1.0/go.mod 
h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
+github.com/go-sql-driver/mysql v1.8.1 
h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
+github.com/go-sql-driver/mysql v1.8.1/go.mod 
h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
+github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
+github.com/jmoiron/sqlx v1.4.0/go.mod 
h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY=
+github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
+github.com/lib/pq v1.10.9/go.mod 
h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
+github.com/mattn/go-sqlite3 v1.14.22 
h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
+github.com/mattn/go-sqlite3 v1.14.22/go.mod 
h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
diff --git a/allocations/domain/store/person_global_id_store.go 
b/allocations/domain/store/person_global_id_store.go
new file mode 100644
index 000000000..314384e37
--- /dev/null
+++ b/allocations/domain/store/person_global_id_store.go
@@ -0,0 +1,66 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package store
+
+import (
+       "context"
+       "database/sql"
+       "errors"
+
+       "github.com/apache/airavata-custos/allocations/domain/model"
+       "github.com/jmoiron/sqlx"
+)
+
+type mariaDBPersonGlobalIDStore struct {
+       db *sqlx.DB
+}
+
+func NewPersonGlobalIDStore(db *sqlx.DB) PersonGlobalIDStore {
+       return &mariaDBPersonGlobalIDStore{db: db}
+}
+
+func (s *mariaDBPersonGlobalIDStore) FindPersonByGlobalID(ctx context.Context, 
globalID string) (*model.Person, error) {
+       var p model.Person
+       err := s.db.GetContext(ctx, &p,
+               `SELECT p.id, p.access_global_id, p.first_name, p.last_name, 
p.email,
+            p.organization, p.org_code, p.nsf_status_code, p.is_active, 
p.created_at, p.updated_at
+     FROM persons p
+     JOIN person_global_ids g ON p.id = g.person_id
+     WHERE g.global_id = ?`, globalID)
+       if err != nil {
+               if errors.Is(err, sql.ErrNoRows) {
+                       return nil, nil
+               }
+               return nil, err
+       }
+       return &p, nil
+}
+
+func (s *mariaDBPersonGlobalIDStore) Save(ctx context.Context, tx *sql.Tx, g 
*model.PersonGlobalID) error {
+       _, err := tx.ExecContext(ctx,
+               `INSERT INTO person_global_ids (person_id, global_id) VALUES 
(?, ?)`,
+               g.PersonID, g.GlobalID)
+       return err
+}
+
+func (s *mariaDBPersonGlobalIDStore) UpdatePersonID(ctx context.Context, tx 
*sql.Tx, oldPersonID, newPersonID string) error {
+       _, err := tx.ExecContext(ctx,
+               `UPDATE person_global_ids SET person_id = ? WHERE person_id = 
?`,
+               newPersonID, oldPersonID)
+       return err
+}

Reply via email to