Skip to content

Commit

Permalink
add support for data management plans by organization and repository. #…
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Sep 8, 2020
1 parent 4638b70 commit 1846afd
Show file tree
Hide file tree
Showing 22 changed files with 618 additions and 167 deletions.
64 changes: 42 additions & 22 deletions app/graphql/schema.graphql

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion app/graphql/types/data_catalog_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class DataCatalogType < BaseObject
argument :repository_id, String, required: false
argument :member_id, String, required: false
argument :license, String, required: false
argument :resource_type, String, required: false
argument :has_citations, Int, required: false
argument :has_parts, Int, required: false
argument :has_versions, Int, required: false
Expand Down Expand Up @@ -79,7 +80,7 @@ def software_application
end

def datasets(**args)
Doi.gql_query(args[:query], re3data_id: object[:id], user_id: args[:user_id], client_id: args[:repository_id], provider_id: args[:member_id], license: args[:license], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], resource_type_id: "Dataset", published: args[:published], state: "findable", page: { cursor: args[:cursor].present? ? Base64.urlsafe_decode64(args[:cursor]) : nil, size: args[:size] })
Doi.gql_query(args[:query], re3data_id: object[:id], user_id: args[:user_id], client_id: args[:repository_id], resource_type: args[:resource_type], provider_id: args[:member_id], license: args[:license], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], resource_type_id: "Dataset", published: args[:published], state: "findable", page: { cursor: args[:cursor].present? ? Base64.urlsafe_decode64(args[:cursor]) : nil, size: args[:size] })
end

def view_count
Expand Down
34 changes: 33 additions & 1 deletion app/graphql/types/funder_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class FunderType < BaseObject
argument :registration_agency, String, required: false
argument :has_person, Boolean, required: false
argument :license, String, required: false
argument :resource_type, String, required: false
argument :language, String, required: false
argument :has_organization, Boolean, required: false
argument :has_citations, Int, required: false
Expand All @@ -44,6 +45,7 @@ class FunderType < BaseObject
argument :registration_agency, String, required: false
argument :has_person, Boolean, required: false
argument :license, String, required: false
argument :resource_type, String, required: false
argument :language, String, required: false
argument :has_organization, Boolean, required: false
argument :has_citations, Int, required: false
Expand All @@ -67,6 +69,7 @@ class FunderType < BaseObject
argument :registration_agency, String, required: false
argument :has_person, Boolean, required: false
argument :license, String, required: false
argument :resource_type, String, required: false
argument :language, String, required: false
argument :has_organization, Boolean, required: false
argument :has_citations, Int, required: false
Expand All @@ -79,6 +82,28 @@ class FunderType < BaseObject
argument :after, String, required: false
end

field :data_management_plans, DataManagementPlanConnectionWithTotalType, null: true, description: "Data management plans from this organization" do
argument :query, String, required: false
argument :ids, [String], required: false
argument :published, String, required: false
argument :user_id, String, required: false
argument :affiliation_id, String, required: false
argument :repository_id, String, required: false
argument :member_id, String, required: false
argument :registration_agency, String, required: false
argument :resource_type, String, required: false
argument :license, String, required: false
argument :language, String, required: false
argument :has_citations, Int, required: false
argument :has_parts, Int, required: false
argument :has_versions, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :field_of_science, String, required: false
argument :first, Int, required: false, default_value: 25
argument :after, String, required: false
end

field :works, WorkConnectionWithTotalType, null: true, description: "Funded works" do
argument :query, String, required: false
argument :ids, [String], required: false
Expand All @@ -89,6 +114,7 @@ class FunderType < BaseObject
argument :affiliation_id, String, required: false
argument :registration_agency, String, required: false
argument :resource_type_id, String, required: false
argument :resource_type, String, required: false
argument :has_person, Boolean, required: false
argument :license, String, required: false
argument :language, String, required: false
Expand Down Expand Up @@ -123,6 +149,12 @@ def softwares(**args)
ElasticsearchModelResponseConnection.new(response(args), context: self.context, first: args[:first], after: args[:after])
end

def data_management_plans(**args)
args[:resource_type_id] = "Text"
args[:resource_type] = "Data Management Plan"
ElasticsearchModelResponseConnection.new(response(args), context: self.context, first: args[:first], after: args[:after])
end

def works(**args)
ElasticsearchModelResponseConnection.new(response(args), context: self.context, first: args[:first], after: args[:after])
end
Expand All @@ -146,6 +178,6 @@ def citation_count
end

def response(**args)
Doi.gql_query(args[:query], ids: args[:ids], funder_id: object.id, user_id: args[:user_id], client_id: args[:repository_id], provider_id: args[:member_id], affiliation_id: args[:affiliation_id], resource_type_id: args[:resource_type_id], agency: args[:registration_agency], language: args[:language], license: args[:license], has_person: args[:has_person], has_organization: args[:has_organization], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], field_of_science: args[:field_of_science], published: args[:published], state: "findable", page: { cursor: args[:after].present? ? Base64.urlsafe_decode64(args[:after]) : [], size: args[:first] })
Doi.gql_query(args[:query], ids: args[:ids], funder_id: object.id, user_id: args[:user_id], client_id: args[:repository_id], provider_id: args[:member_id], affiliation_id: args[:affiliation_id], resource_type_id: args[:resource_type_id], resource_type: args[:resource_type], agency: args[:registration_agency], language: args[:language], license: args[:license], has_person: args[:has_person], has_organization: args[:has_organization], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], field_of_science: args[:field_of_science], published: args[:published], state: "findable", page: { cursor: args[:after].present? ? Base64.urlsafe_decode64(args[:after]) : [], size: args[:first] })
end
end
37 changes: 33 additions & 4 deletions app/graphql/types/member_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class MemberType < BaseObject
argument :repository_id, String, required: false
argument :funder_id, String, required: false
argument :affiliation_id, String, required: false
argument :resource_type_id, String, required: false
argument :license, String, required: false
argument :resource_type, String, required: false
argument :language, String, required: false
argument :has_person, Boolean, required: false
argument :has_organization, Boolean, required: false
Expand All @@ -52,8 +52,8 @@ class MemberType < BaseObject
argument :repository_id, String, required: false
argument :funder_id, String, required: false
argument :affiliation_id, String, required: false
argument :resource_type_id, String, required: false
argument :license, String, required: false
argument :resource_type, String, required: false
argument :language, String, required: false
argument :has_person, Boolean, required: false
argument :has_organization, Boolean, required: false
Expand All @@ -76,8 +76,8 @@ class MemberType < BaseObject
argument :repository_id, String, required: false
argument :funder_id, String, required: false
argument :affiliation_id, String, required: false
argument :resource_type_id, String, required: false
argument :license, String, required: false
argument :resource_type, String, required: false
argument :language, String, required: false
argument :has_person, Boolean, required: false
argument :has_organization, Boolean, required: false
Expand All @@ -92,6 +92,28 @@ class MemberType < BaseObject
argument :after, String, required: false
end

field :data_management_plans, DataManagementPlanConnectionWithTotalType, null: true, description: "Data management plans from this organization" do
argument :query, String, required: false
argument :ids, [String], required: false
argument :published, String, required: false
argument :user_id, String, required: false
argument :funder_id, String, required: false
argument :repository_id, String, required: false
argument :affiliation_id, String, required: false
argument :registration_agency, String, required: false
argument :resource_type, String, required: false
argument :license, String, required: false
argument :language, String, required: false
argument :has_citations, Int, required: false
argument :has_parts, Int, required: false
argument :has_versions, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :field_of_science, String, required: false
argument :first, Int, required: false, default_value: 25
argument :after, String, required: false
end

field :works, WorkConnectionWithTotalType, null: true, description: "Works by this provider." do
argument :query, String, required: false
argument :ids, [String], required: false
Expand All @@ -101,6 +123,7 @@ class MemberType < BaseObject
argument :funder_id, String, required: false
argument :affiliation_id, String, required: false
argument :resource_type_id, String, required: false
argument :resource_type, String, required: false
argument :license, String, required: false
argument :language, String, required: false
argument :has_person, Boolean, required: false
Expand Down Expand Up @@ -159,6 +182,12 @@ def softwares(**args)
ElasticsearchModelResponseConnection.new(response(args), context: self.context, first: args[:first], after: args[:after])
end

def data_management_plans(**args)
args[:resource_type_id] = "Text"
args[:resource_type] = "Data Management Plan"
ElasticsearchModelResponseConnection.new(response(args), context: self.context, first: args[:first], after: args[:after])
end

def works(**args)
ElasticsearchModelResponseConnection.new(response(args), context: self.context, first: args[:first], after: args[:after])
end
Expand Down Expand Up @@ -192,6 +221,6 @@ def citation_count
end

def response(**args)
Doi.gql_query(args[:query], ids: args[:ids], user_id: args[:user_id], client_id: args[:repository_id], provider_id: object.member_type == "consortium" ? nil : object.uid, consortium_id: object.member_type == "consortium" ? object.uid : nil, funder_id: args[:funder_id], affiliation_id: args[:affiliation_id], resource_type_id: args[:resource_type_id], has_person: args[:has_person], has_funder: args[:has_funder], has_affiliation: args[:has_affiliation], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], field_of_science: args[:field_of_science], published: args[:published], language: args[:language], license: args[:license], state: "findable", page: { cursor: args[:after].present? ? Base64.urlsafe_decode64(args[:after]) : [], size: args[:first] })
Doi.gql_query(args[:query], ids: args[:ids], user_id: args[:user_id], client_id: args[:repository_id], provider_id: object.member_type == "consortium" ? nil : object.uid, consortium_id: object.member_type == "consortium" ? object.uid : nil, funder_id: args[:funder_id], affiliation_id: args[:affiliation_id], resource_type_id: args[:resource_type_id], resource_type: args[:resource_type], has_person: args[:has_person], has_funder: args[:has_funder], has_affiliation: args[:has_affiliation], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], field_of_science: args[:field_of_science], published: args[:published], language: args[:language], license: args[:license], state: "findable", page: { cursor: args[:after].present? ? Base64.urlsafe_decode64(args[:after]) : [], size: args[:first] })
end
end
34 changes: 33 additions & 1 deletion app/graphql/types/organization_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class OrganizationType < BaseObject
argument :member_id, String, required: false
argument :registration_agency, String, required: false
argument :license, String, required: false
argument :resource_type, String, required: false
argument :language, String, required: false
argument :has_citations, Int, required: false
argument :has_parts, Int, required: false
Expand All @@ -48,6 +49,7 @@ class OrganizationType < BaseObject
argument :member_id, String, required: false
argument :registration_agency, String, required: false
argument :license, String, required: false
argument :resource_type, String, required: false
argument :language, String, required: false
argument :has_citations, Int, required: false
argument :has_parts, Int, required: false
Expand All @@ -68,6 +70,29 @@ class OrganizationType < BaseObject
argument :repository_id, String, required: false
argument :member_id, String, required: false
argument :registration_agency, String, required: false
argument :resource_type, String, required: false
argument :license, String, required: false
argument :language, String, required: false
argument :has_citations, Int, required: false
argument :has_parts, Int, required: false
argument :has_versions, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :field_of_science, String, required: false
argument :first, Int, required: false, default_value: 25
argument :after, String, required: false
end

field :data_management_plans, DataManagementPlanConnectionWithTotalType, null: true, description: "Data management plans from this organization" do
argument :query, String, required: false
argument :ids, [String], required: false
argument :published, String, required: false
argument :user_id, String, required: false
argument :funder_id, String, required: false
argument :repository_id, String, required: false
argument :member_id, String, required: false
argument :registration_agency, String, required: false
argument :resource_type, String, required: false
argument :license, String, required: false
argument :language, String, required: false
argument :has_citations, Int, required: false
Expand All @@ -90,6 +115,7 @@ class OrganizationType < BaseObject
argument :member_id, String, required: false
argument :registration_agency, String, required: false
argument :resource_type_id, String, required: false
argument :resource_type, String, required: false
argument :license, String, required: false
argument :language, String, required: false
argument :has_citations, Int, required: false
Expand Down Expand Up @@ -139,6 +165,12 @@ def softwares(**args)
ElasticsearchModelResponseConnection.new(response(args), context: self.context, first: args[:first], after: args[:after])
end

def data_management_plans(**args)
args[:resource_type_id] = "Text"
args[:resource_type] = "Data Management Plan"
ElasticsearchModelResponseConnection.new(response(args), context: self.context, first: args[:first], after: args[:after])
end

def works(**args)
ElasticsearchModelResponseConnection.new(response(args), context: self.context, first: args[:first], after: args[:after])
end
Expand Down Expand Up @@ -173,6 +205,6 @@ def citation_count
end

def response(**args)
Doi.gql_query(args[:query], ids: args[:ids], affiliation_id: object.id, user_id: args[:user_id], client_id: args[:repository_id], provider_id: args[:member_id], funder_id: args[:funder_id] || object.fundref.join(","), resource_type_id: args[:resource_type_id], agency: args[:registration_agency], language: args[:language], license: args[:license], has_person: args[:has_person], has_funder: args[:has_funder], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], field_of_science: args[:field_of_science], published: args[:published], state: "findable", page: { cursor: args[:after].present? ? Base64.urlsafe_decode64(args[:after]) : [], size: args[:first] })
Doi.gql_query(args[:query], ids: args[:ids], affiliation_id: object.id, user_id: args[:user_id], client_id: args[:repository_id], provider_id: args[:member_id], funder_id: args[:funder_id] || object.fundref.join(","), resource_type_id: args[:resource_type_id], resource_type: args[:resource_type], agency: args[:registration_agency], language: args[:language], license: args[:license], has_person: args[:has_person], has_funder: args[:has_funder], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], field_of_science: args[:field_of_science], published: args[:published], state: "findable", page: { cursor: args[:after].present? ? Base64.urlsafe_decode64(args[:after]) : [], size: args[:first] })
end
end
Loading

0 comments on commit 1846afd

Please sign in to comment.