-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b3dec48
commit 70d3795
Showing
42 changed files
with
1,787 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
module Lauth | ||
module Repositories | ||
class CollectionRepo < ROM::Repository[:collections] | ||
include Deps[container: "persistence.rom"] | ||
struct_namespace Lauth | ||
# auto_struct true | ||
# commands :create, update: :by_pk, delete: :by_pk | ||
|
||
def index | ||
undeleted_collections.to_a | ||
end | ||
|
||
def create(document) | ||
document = Hanami::Utils::Hash.deep_symbolize(document) | ||
id = document[:data][:id] | ||
collection = undeleted_collections.where(uniqueIdentifier: id).one | ||
return nil if collection | ||
|
||
if deleted_collections.where(uniqueIdentifier: id).one | ||
deleted_collections.where(uniqueIdentifier: id).changeset(Lauth::Persistence::Changesets::CollectionUpdate, document).commit | ||
else | ||
undeleted_collections.changeset(Lauth::Persistence::Changesets::CollectionCreate, document).commit | ||
end | ||
|
||
undeleted_collections.where(uniqueIdentifier: id).one | ||
end | ||
|
||
def find(id) | ||
undeleted_collections.where(uniqueIdentifier: id).one | ||
end | ||
|
||
def find_with_locations(id) | ||
undeleted_collections.where(uniqueIdentifier: id).combine(:locations).node(:locations) do |locations_relation| | ||
locations_relation.where(locations[:dlpsDeleted] => "f") | ||
end | ||
.one | ||
end | ||
|
||
def update(document) | ||
document = Hanami::Utils::Hash.deep_symbolize(document) | ||
id = document[:data][:id] | ||
collection = deleted_collections.where(uniqueIdentifier: id).one | ||
return nil if collection | ||
|
||
if undeleted_collections.where(uniqueIdentifier: id).one | ||
undeleted_collections.where(uniqueIdentifier: id).changeset(Lauth::Persistence::Changesets::CollectionUpdate, document).commit | ||
end | ||
|
||
undeleted_collections.where(uniqueIdentifier: id).one | ||
end | ||
|
||
def delete(id) | ||
collection = find(id) | ||
undeleted_collections.where(uniqueIdentifier: id).update(dlpsDeleted: "t") if collection | ||
collection | ||
end | ||
|
||
def by_request_uri(host, uri) | ||
collections.join(locations) | ||
.where(collections[:dlpsDeleted].is("f")) | ||
.where(locations[:dlpsDeleted].is("f")) | ||
.where(locations[:dlpsServer].is(host)) | ||
.where(Sequel.ilike(uri, locations[:dlpsPath])) | ||
.order(Sequel.function(:length, locations[:dlpsPath])) | ||
.rename(commonName: :name) | ||
.reverse | ||
.to_a | ||
end | ||
|
||
protected | ||
|
||
def undeleted_collections | ||
collections.where(dlpsDeleted: "f") | ||
end | ||
|
||
def deleted_collections | ||
collections.where(dlpsDeleted: "t") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
module Lauth | ||
module Repositories | ||
class GroupMembershipRepo < ROM::Repository[:group_memberships] | ||
include Deps[container: "persistence.rom"] | ||
struct_namespace Lauth | ||
# auto_struct true | ||
# commands :create, update: :by_pk, delete: :by_pk | ||
|
||
def index | ||
undeleted_group_memberships.to_a | ||
end | ||
|
||
def create(document) | ||
document = Hanami::Utils::Hash.deep_symbolize(document) | ||
user_id = document[:data][:attributes][:user_id] | ||
group_id = document[:data][:attributes][:group_id] | ||
group_membership = undeleted_group_memberships.where(userid: user_id, user_grp: group_id).one | ||
return nil if group_membership | ||
|
||
if deleted_group_memberships.where(userid: user_id, user_grp: group_id).one | ||
deleted_group_memberships.where(userid: user_id, user_grp: group_id).changeset(Lauth::Persistence::Changesets::GroupMembershipUpdate, document).commit | ||
else | ||
undeleted_group_memberships.changeset(Lauth::Persistence::Changesets::GroupMembershipCreate, document).commit | ||
end | ||
|
||
undeleted_group_memberships.where(userid: user_id, user_grp: group_id).one | ||
end | ||
|
||
def find(user_id, group_id) | ||
undeleted_group_memberships.where(userid: user_id, user_grp: group_id).one | ||
end | ||
|
||
def update(document) | ||
document = Hanami::Utils::Hash.deep_symbolize(document) | ||
user_id = document[:data][:attributes][:user_id] | ||
group_id = document[:data][:attributes][:group_id] | ||
group_membership = deleted_group_memberships.where(userid: user_id, user_grp: group_id).one | ||
return nil if group_membership | ||
|
||
if undeleted_group_memberships.where(userid: user_id, user_grp: group_id).one | ||
undeleted_group_memberships.where(userid: user_id, user_grp: group_id).changeset(Lauth::Persistence::Changesets::GroupMembershipUpdate, document).commit | ||
end | ||
|
||
undeleted_group_memberships.where(userid: user_id, user_grp: group_id).one | ||
end | ||
|
||
def delete(user_id, group_id) | ||
group_membership = find(user_id, group_id) | ||
undeleted_group_memberships.where(userid: user_id, user_grp: group_id).update(dlpsDeleted: "t") if group_membership | ||
group_membership | ||
end | ||
|
||
protected | ||
|
||
def undeleted_group_memberships | ||
group_memberships.where(dlpsDeleted: "f") | ||
end | ||
|
||
def deleted_group_memberships | ||
group_memberships.where(dlpsDeleted: "t") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
module Lauth | ||
module Repositories | ||
class GroupRepo < ROM::Repository[:groups] | ||
include Deps[container: "persistence.rom"] | ||
struct_namespace Lauth | ||
# auto_struct true | ||
# commands :create, update: :by_pk, delete: :by_pk | ||
|
||
def index | ||
undeleted_groups.rename(uniqueIdentifier: :id, commonName: :name).to_a | ||
end | ||
|
||
def create(document) | ||
document = Hanami::Utils::Hash.deep_symbolize(document) | ||
id = document[:data][:id] | ||
group = undeleted_groups.where(uniqueIdentifier: id).one | ||
return nil if group | ||
|
||
if deleted_groups.where(uniqueIdentifier: id).one | ||
deleted_groups.where(uniqueIdentifier: id).changeset(Lauth::Persistence::Changesets::GroupUpdate, document).commit | ||
else | ||
undeleted_groups.changeset(Lauth::Persistence::Changesets::GroupCreate, document).commit | ||
end | ||
|
||
undeleted_groups.where(uniqueIdentifier: id).rename(uniqueIdentifier: :id, commonName: :name).one | ||
end | ||
|
||
def find(id) | ||
undeleted_groups.where(uniqueIdentifier: id).rename(uniqueIdentifier: :id, commonName: :name).one | ||
end | ||
|
||
def update(document) | ||
document = Hanami::Utils::Hash.deep_symbolize(document) | ||
id = document[:data][:id] | ||
group = deleted_groups.where(uniqueIdentifier: id).one | ||
return nil if group | ||
|
||
if undeleted_groups.where(uniqueIdentifier: id).one | ||
undeleted_groups.where(uniqueIdentifier: id).changeset(Lauth::Persistence::Changesets::GroupUpdate, document).commit | ||
end | ||
|
||
undeleted_groups.where(uniqueIdentifier: id).rename(uniqueIdentifier: :id, commonName: :name).one | ||
end | ||
|
||
def delete(id) | ||
group = find(id) | ||
undeleted_groups.where(uniqueIdentifier: id).update(dlpsDeleted: "t") if group | ||
group | ||
end | ||
|
||
protected | ||
|
||
def undeleted_groups | ||
groups.where(dlpsDeleted: "f") | ||
end | ||
|
||
def deleted_groups | ||
groups.where(dlpsDeleted: "t") | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.