Class: ProjectMetadata
- Inherits:
-
Object
- Object
- ProjectMetadata
- Defined in:
- app/models/project_metadata.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- DOI_NOT_MINTED =
"DOI-NOT-MINTED"
Instance Attribute Summary collapse
-
#approval_note ⇒ Object
Returns the value of attribute approval_note.
-
#created_by ⇒ Object
Returns the value of attribute created_by.
-
#created_on ⇒ Object
Returns the value of attribute created_on.
-
#data_manager ⇒ Object
Returns the value of attribute data_manager.
-
#data_sponsor ⇒ Object
Returns the value of attribute data_sponsor.
-
#data_use_agreement ⇒ Object
Returns the value of attribute data_use_agreement.
-
#data_user_read_only ⇒ Object
Returns the value of attribute data_user_read_only.
-
#data_user_read_write ⇒ Object
Returns the value of attribute data_user_read_write.
-
#departments ⇒ Object
Returns the value of attribute departments.
-
#description ⇒ Object
Returns the value of attribute description.
-
#globus_request ⇒ Object
Returns the value of attribute globus_request.
-
#hpc ⇒ Object
Returns the value of attribute hpc.
-
#project_directory ⇒ Object
Returns the value of attribute project_directory.
-
#project_directory_protocol ⇒ Object
Returns the value of attribute project_directory_protocol.
-
#project_id ⇒ Object
Returns the value of attribute project_id.
-
#project_purpose ⇒ Object
Returns the value of attribute project_purpose.
-
#project_visibility ⇒ Object
Returns the value of attribute project_visibility.
-
#provisional ⇒ Object
Returns the value of attribute provisional.
-
#resource_type ⇒ Object
Returns the value of attribute resource_type.
-
#schema_version ⇒ Object
Returns the value of attribute schema_version.
-
#smb_request ⇒ Object
Returns the value of attribute smb_request.
-
#status ⇒ Object
Returns the value of attribute status.
-
#storage_capacity ⇒ Object
Returns the value of attribute storage_capacity.
-
#storage_performance_expectations ⇒ Object
Returns the value of attribute storage_performance_expectations.
-
#submission ⇒ Object
Returns the value of attribute submission.
-
#title ⇒ Object
Returns the value of attribute title.
-
#updated_by ⇒ Object
Returns the value of attribute updated_by.
-
#updated_on ⇒ Object
Returns the value of attribute updated_on.
Class Method Summary collapse
-
.default_data_use_agreement ⇒ String
The default data use agreement.
-
.default_directory_protocol ⇒ String
The default directory protocol.
-
.default_globus_request ⇒ Hash
The default globus request Hash entries.
-
.default_hpc ⇒ String
The default HPC value.
-
.default_project_visibility ⇒ String
The default project visibility.
-
.default_provisionality ⇒ Boolean
The default value for whether a project is provisional.
-
.default_resource_type ⇒ String
The default project resource type.
-
.default_smb_request ⇒ Hash
The default Samba/SMB request Hash entries.
- .new_from_hash(metadata_hash) ⇒ Object
- .new_from_params(metadata_params) ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ ProjectMetadata
constructor
A new instance of ProjectMetadata.
-
#initialize_from_hash(metadata_hash) ⇒ Object
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/MethodLength rubocop:disable Metrics/PerceivedComplexity.
-
#initialize_from_params(params) ⇒ Object
Initializes the object with the values in the params (which is an ActionController::Parameters).
-
#ro_users ⇒ Object
Alias for ‘data_user_read_only`.
-
#rw_users ⇒ Object
Alias for ‘data_user_read_write`.
-
#update_with_params(params, current_user) ⇒ Object
Updates the object with the values in the params (which is an ActionController::Parameters) Notice how we only update values that come in the params and don’t change the values that don’t come as part of the params rubocop:disable Metrics/MethodLength.
Constructor Details
#initialize ⇒ ProjectMetadata
Returns a new instance of ProjectMetadata.
68 69 70 71 72 |
# File 'app/models/project_metadata.rb', line 68 def initialize @departments = [] @data_user_read_only = [] @data_user_read_write = [] end |
Instance Attribute Details
#approval_note ⇒ Object
Returns the value of attribute approval_note.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def approval_note @approval_note end |
#created_by ⇒ Object
Returns the value of attribute created_by.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def created_by @created_by end |
#created_on ⇒ Object
Returns the value of attribute created_on.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def created_on @created_on end |
#data_manager ⇒ Object
Returns the value of attribute data_manager.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def data_manager @data_manager end |
#data_sponsor ⇒ Object
Returns the value of attribute data_sponsor.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def data_sponsor @data_sponsor end |
#data_use_agreement ⇒ Object
Returns the value of attribute data_use_agreement.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def data_use_agreement @data_use_agreement end |
#data_user_read_only ⇒ Object
Returns the value of attribute data_user_read_only.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def data_user_read_only @data_user_read_only end |
#data_user_read_write ⇒ Object
Returns the value of attribute data_user_read_write.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def data_user_read_write @data_user_read_write end |
#departments ⇒ Object
Returns the value of attribute departments.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def departments @departments end |
#description ⇒ Object
Returns the value of attribute description.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def description @description end |
#globus_request ⇒ Object
Returns the value of attribute globus_request.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def globus_request @globus_request end |
#hpc ⇒ Object
Returns the value of attribute hpc.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def hpc @hpc end |
#project_directory ⇒ Object
Returns the value of attribute project_directory.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def project_directory @project_directory end |
#project_directory_protocol ⇒ Object
Returns the value of attribute project_directory_protocol.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def project_directory_protocol @project_directory_protocol end |
#project_id ⇒ Object
Returns the value of attribute project_id.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def project_id @project_id end |
#project_purpose ⇒ Object
Returns the value of attribute project_purpose.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def project_purpose @project_purpose end |
#project_visibility ⇒ Object
Returns the value of attribute project_visibility.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def project_visibility @project_visibility end |
#provisional ⇒ Object
Returns the value of attribute provisional.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def provisional @provisional end |
#resource_type ⇒ Object
Returns the value of attribute resource_type.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def resource_type @resource_type end |
#schema_version ⇒ Object
Returns the value of attribute schema_version.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def schema_version @schema_version end |
#smb_request ⇒ Object
Returns the value of attribute smb_request.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def smb_request @smb_request end |
#status ⇒ Object
Returns the value of attribute status.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def status @status end |
#storage_capacity ⇒ Object
Returns the value of attribute storage_capacity.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def storage_capacity @storage_capacity end |
#storage_performance_expectations ⇒ Object
Returns the value of attribute storage_performance_expectations.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def storage_performance_expectations @storage_performance_expectations end |
#submission ⇒ Object
Returns the value of attribute submission.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def submission @submission end |
#title ⇒ Object
Returns the value of attribute title.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def title @title end |
#updated_by ⇒ Object
Returns the value of attribute updated_by.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def updated_by @updated_by end |
#updated_on ⇒ Object
Returns the value of attribute updated_on.
53 54 55 |
# File 'app/models/project_metadata.rb', line 53 def updated_on @updated_on end |
Class Method Details
.default_data_use_agreement ⇒ String
Returns The default data use agreement.
28 29 30 |
# File 'app/models/project_metadata.rb', line 28 def self.default_data_use_agreement "No" end |
.default_directory_protocol ⇒ String
Returns The default directory protocol.
8 9 10 |
# File 'app/models/project_metadata.rb', line 8 def self.default_directory_protocol "NFS" end |
.default_globus_request ⇒ Hash
Returns The default globus request Hash entries.
33 34 35 36 37 38 |
# File 'app/models/project_metadata.rb', line 33 def self.default_globus_request { requested: false, approved: false } end |
.default_hpc ⇒ String
Returns The default HPC value.
18 19 20 |
# File 'app/models/project_metadata.rb', line 18 def self.default_hpc "No" end |
.default_project_visibility ⇒ String
Returns The default project visibility.
23 24 25 |
# File 'app/models/project_metadata.rb', line 23 def self.default_project_visibility "Restricted" end |
.default_provisionality ⇒ Boolean
Returns The default value for whether a project is provisional.
49 50 51 |
# File 'app/models/project_metadata.rb', line 49 def self.default_provisionality false end |
.default_resource_type ⇒ String
Returns The default project resource type.
13 14 15 |
# File 'app/models/project_metadata.rb', line 13 def self.default_resource_type "TigerData Project" end |
.default_smb_request ⇒ Hash
Returns The default Samba/SMB request Hash entries.
41 42 43 44 45 46 |
# File 'app/models/project_metadata.rb', line 41 def self.default_smb_request { requested: false, approved: false } end |
.new_from_hash(metadata_hash) ⇒ Object
74 75 76 77 78 |
# File 'app/models/project_metadata.rb', line 74 def self.new_from_hash() pm = ProjectMetadata.new pm.initialize_from_hash() pm end |
.new_from_params(metadata_params) ⇒ Object
80 81 82 83 84 |
# File 'app/models/project_metadata.rb', line 80 def self.new_from_params() pm = ProjectMetadata.new pm.initialize_from_params() pm end |
Instance Method Details
#initialize_from_hash(metadata_hash) ⇒ Object
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/MethodLength rubocop:disable Metrics/PerceivedComplexity
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'app/models/project_metadata.rb', line 90 def initialize_from_hash() @title = [:title] @description = [:description] @status = [:status] if [:status] @data_sponsor = [:data_sponsor] @data_manager = [:data_manager] @departments = [:departments] @data_user_read_only = [:data_user_read_only] if [:data_user_read_only] @data_user_read_write = [:data_user_read_write] if [:data_user_read_write] @project_id = [:project_id] || ProjectMetadata::DOI_NOT_MINTED @project_purpose = [:project_purpose] @project_directory = [:project_directory] @storage_capacity = [:storage_capacity] @storage_performance_expectations = [:storage_performance_expectations] @created_by = [:created_by] if [:created_by] @created_on = [:created_on] if [:created_on] @updated_by = [:updated_by] if [:updated_by] @updated_on = [:updated_on] if [:updated_on] # NOTE: The following attributes are required by the 0.8 XML schema @hpc = [:hpc] || self.class.default_hpc @data_use_agreement = [:data_use_agreement] || self.class.default_data_use_agreement @project_visibility = [:project_visibility] || self.class.default_project_visibility @resource_type = [:resource_type] || self.class.default_resource_type @globus_request = [:globus_request] || self.class.default_globus_request @smb_request = [:smb_request] || self.class.default_smb_request @provisional = [:provisional] || self.class.default_provisionality set_defaults end |
#initialize_from_params(params) ⇒ Object
Initializes the object with the values in the params (which is an ActionController::Parameters)
133 134 135 136 137 |
# File 'app/models/project_metadata.rb', line 133 def initialize_from_params(params) @data_user_read_only = ro_users_from_params(params) @data_user_read_write = rw_users_from_params(params) initialize_from_hash(params) end |
#ro_users ⇒ Object
Alias for ‘data_user_read_only`
171 172 173 |
# File 'app/models/project_metadata.rb', line 171 def ro_users @data_user_read_only end |
#rw_users ⇒ Object
Alias for ‘data_user_read_write`
176 177 178 |
# File 'app/models/project_metadata.rb', line 176 def rw_users @data_user_read_write end |
#update_with_params(params, current_user) ⇒ Object
Updates the object with the values in the params (which is an ActionController::Parameters) Notice how we only update values that come in the params and don’t change the values that don’t come as part of the params rubocop:disable Metrics/MethodLength
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'app/models/project_metadata.rb', line 143 def update_with_params(params, current_user) set_value(params, "title") set_value(params, "description") set_value(params, "status") set_value(params, "data_sponsor") set_value(params, "data_manager") set_value(params, "departments") set_value(params, "project_id") set_value(params, "project_purpose") calculate_project_directory(params) if params["data_user_counter"].present? @data_user_read_only = ro_users_from_params(params) @data_user_read_write = rw_users_from_params(params) end update_storage_capacity(params) update_storage_performance_expectations update_approval_note(params, current_user) @submission = params[:submission] if params[:submission] # Fields that come from the edit form @updated_by = current_user.uid @updated_on = Time.current.in_time_zone("America/New_York").iso8601 end |