Module: Rsmart::ETL::GRM

Defined in:
lib/rsmart_toolbox/etl/grm.rb

Overview

rSmart Grant and Research Management methods.

Class Method Summary collapse

Class Method Details

.parse_actv_ind(str, opt = { name: 'ACTV_IND', default: 'Y', valid_values: /^(Y|N)$/i }) ⇒ String

Note:

Designed specifically for ACTV_IND, but could be used on any fields that matches (Y|N).

Parse an ACTV_IND from a String.

Parameters:

  • str (String)

    the String to be parsed.

  • opt (Hash) (defaults to: { name: 'ACTV_IND', default: 'Y', valid_values: /^(Y|N)$/i })

    options Hash will be passed through to Rsmart::ETL.parse_string.

Returns:

  • (String)

    the parsed ACTV_IND.

Raises:

See Also:



336
337
338
339
340
341
342
# File 'lib/rsmart_toolbox/etl/grm.rb', line 336

def self.parse_actv_ind(str, opt={ name: 'ACTV_IND', default: 'Y', valid_values: /^(Y|N)$/i })
  #   `ACTV_IND` varchar(1) COLLATE utf8_bin DEFAULT 'Y',
  opt[:name]         = "ACTV_IND" if opt[:name].nil?
  opt[:default]      = "Y" if opt[:default].nil?
  opt[:valid_values] = /^(Y|N)$/i if opt[:valid_values].nil?
  return Rsmart::ETL::parse_flag str, opt
end

.parse_actv_ind!(row, insert_str, values_str, opt = { name: 'ACTV_IND' }) ⇒ void

Note:

Designed specifically for ACTV_IND, but could be used on any fields that matches (Y|N).

This method returns an undefined value.

Parses the ACTV_IND by column :name and mutates the SQL statement accordingly.

Parameters:

  • row (CSV::Row)

    the CSV Row being parsed

  • insert_str (String)

    the left side of the insert statement (i.e. columns)

  • values_str (String)

    the right side of the insert statement (i.e. values)

  • opt (Hash) (defaults to: { name: 'ACTV_IND' })

    options Hash will be passed through to parse_actv_ind.

See Also:



353
354
355
356
357
358
# File 'lib/rsmart_toolbox/etl/grm.rb', line 353

def self.parse_actv_ind!(row, insert_str, values_str, opt={ name: 'ACTV_IND' })
  #   `ACTV_IND` varchar(1) COLLATE utf8_bin DEFAULT 'Y',
  opt[:name] = "ACTV_IND" if opt[:name].nil?
  actv_ind = parse_actv_ind row[ Rsmart::ETL::to_symbol( opt[:name] ) ]
  Rsmart::ETL::mutate_sql_stmt! insert_str, opt[:name], values_str, actv_ind
end

.parse_address_type_code(str, opt = { name: 'ADDR_TYP_CD', length: 3, valid_values: /^(HM|OTH|WRK)$/i }) ⇒ String

Parse an ADDR_TYP_CD from a String.

Parameters:

  • str (String)

    the String to be parsed.

  • opt (Hash) (defaults to: { name: 'ADDR_TYP_CD', length: 3, valid_values: /^(HM|OTH|WRK)$/i })

    options Hash will be passed through to Rsmart::ETL.parse_string.

Returns:

  • (String)

    the parsed ADDR_TYP_CD.

Raises:

See Also:



204
205
206
207
208
209
# File 'lib/rsmart_toolbox/etl/grm.rb', line 204

def self.parse_address_type_code(str, opt={ name: 'ADDR_TYP_CD', length: 3, valid_values: /^(HM|OTH|WRK)$/i })
  opt[:name]         = "ADDR_TYP_CD" if opt[:name].nil?
  opt[:length]       = 3 if opt[:length].nil?
  opt[:valid_values] = /^(HM|OTH|WRK)$/i if opt[:valid_values].nil?
  return Rsmart::ETL::parse_flag str, opt
end

.parse_citizenship_type(str, opt = { name: 'CITIZENSHIP_TYPE_CODE', valid_values: /^([1-5])$/ }) ⇒ String

Parse a CITIZENSHIP_TYPE_CODE from a String.

Parameters:

  • str (String)

    the String to be parsed.

  • opt (Hash) (defaults to: { name: 'CITIZENSHIP_TYPE_CODE', valid_values: /^([1-5])$/ })

    options Hash will be passed through to Rsmart::ETL.parse_string.

Returns:

  • (String)

    the parsed CITIZENSHIP_TYPE_CODE.

Raises:

See Also:



309
310
311
312
313
# File 'lib/rsmart_toolbox/etl/grm.rb', line 309

def self.parse_citizenship_type(str, opt={ name: 'CITIZENSHIP_TYPE_CODE', valid_values: /^([1-5])$/ })
  opt[:name]         = "CITIZENSHIP_TYPE_CODE" if opt[:name].nil?
  opt[:valid_values] = /^([1-5])$/ if opt[:valid_values].nil?
  return Rsmart::ETL::parse_flag str, opt
end

.parse_country_code!(row, insert_str, values_str, opt = { name: 'COUNTRY_CODE', length: 3 }) ⇒ void

This method returns an undefined value.

Parses the COUNTRY_CODE by column :name and mutates the SQL statement accordingly.

Parameters:

  • row (CSV::Row)

    the CSV Row being parsed

  • insert_str (String)

    the left side of the insert statement (i.e. columns)

  • values_str (String)

    the right side of the insert statement (i.e. values)

  • opt (Hash) (defaults to: { name: 'COUNTRY_CODE', length: 3 })

    options Hash will be passed through to Rsmart::ETL.parse_string!.

See Also:



47
48
49
50
51
52
# File 'lib/rsmart_toolbox/etl/grm.rb', line 47

def self.parse_country_code!(row, insert_str, values_str, opt={ name: 'COUNTRY_CODE', length: 3 })
  #   `COUNTRY_CODE` char(3) COLLATE utf8_bin DEFAULT NULL,
  opt[:name]   = "COUNTRY_CODE" if opt[:name].nil?
  opt[:length] = 3 if opt[:length].nil?
  Rsmart::ETL::parse_string! row, insert_str, values_str, opt
end

.parse_degree(str, opt = { name: 'DEGREE', length: 5 }) ⇒ String

Parse a DEGREE from a String.

Parameters:

  • str (String)

    the String to be parsed.

  • opt (Hash) (defaults to: { name: 'DEGREE', length: 5 })

    options Hash will be passed through to Rsmart::ETL.parse_string.

Returns:

  • (String)

    the parsed DEGREE.

Raises:

See Also:



321
322
323
324
325
326
327
# File 'lib/rsmart_toolbox/etl/grm.rb', line 321

def self.parse_degree(str, opt={ name: 'DEGREE', length: 5 })
  opt[:name]         = "DEGREE" if opt[:name].nil?
  opt[:length]       = 5 if opt[:length].nil?
  opt[:valid_values] = /^(AS|BA|BComm|BEd|BS|DA|DC|DD|DDS|DEng|DFA|DH|DHA|DMin|DPA|DSN|DVM|DVS|HS|JD|LLD|LLM|MA|MAEd|MArch|MBA|MD|MDS|MDiv|MEE|MEd|MEng|MFA|MIS|MLS|MPA|MPE|MPH|MPd|MPhil|MS|MSEd|MST|MSW|MTh|PhD|PharD|ScD|ThD|UKNW)?$/ if opt[:valid_values].nil?
  opt[:upcase]       = false if opt[:upcase].nil?
  return Rsmart::ETL::parse_flag str, opt
end

.parse_email_address(str, opt = { name: 'EMAIL_ADDRESS', length: 60 }) ⇒ String

Note:

The result is validated against a email address RegExp.

Parse an EMAIL_ADDRESS from a String.

Parameters:

  • str (String)

    the String to be parsed.

  • opt (Hash) (defaults to: { name: 'EMAIL_ADDRESS', length: 60 })

    options Hash will be passed through to Rsmart::ETL.parse_string.

Returns:

  • (String)

    the parsed EMAIL_ADDRESS.

Raises:

See Also:



119
120
121
122
123
124
125
# File 'lib/rsmart_toolbox/etl/grm.rb', line 119

def self.parse_email_address(str, opt={ name: 'EMAIL_ADDRESS', length: 60 })
  #   `EMAIL_ADDRESS` varchar(60) COLLATE utf8_bin DEFAULT NULL,
  opt[:name]         = "EMAIL_ADDRESS" if opt[:name].nil?
  opt[:length]       = 60 if opt[:length].nil?
  opt[:valid_values] = /^(([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?))?$/ if opt[:valid_values].nil?
  return Rsmart::ETL::parse_string str, opt
end

.parse_email_address!(row, insert_str, values_str, opt = { name: 'EMAIL_ADDRESS' }) ⇒ void

This method returns an undefined value.

Parses the EMAIL_ADDRESS by column :name and mutates the SQL statement accordingly.

Parameters:

  • row (CSV::Row)

    the CSV Row being parsed

  • insert_str (String)

    the left side of the insert statement (i.e. columns)

  • values_str (String)

    the right side of the insert statement (i.e. values)

  • opt (Hash) (defaults to: { name: 'EMAIL_ADDRESS' })

    options Hash will be passed through to parse_email_address.

See Also:



135
136
137
138
139
140
# File 'lib/rsmart_toolbox/etl/grm.rb', line 135

def self.parse_email_address!(row, insert_str, values_str, opt={ name: 'EMAIL_ADDRESS' })
  #   `EMAIL_ADDRESS` varchar(60) COLLATE utf8_bin DEFAULT NULL,
  opt[:name] = "EMAIL_ADDRESS" if opt[:name].nil?
  email_address = parse_email_address row[ Rsmart::ETL::to_symbol( opt[:name] ) ]
  Rsmart::ETL::mutate_sql_stmt! insert_str, opt[:name], values_str, email_address
end

.parse_email_type(str, opt = { name: 'EMAIL_TYP_CD', length: 3, valid_values: /^(HM|OTH|WRK)$/i }) ⇒ String

Parse an EMAIL_TYP_CD from a String.

Parameters:

  • str (String)

    the String to be parsed.

  • opt (Hash) (defaults to: { name: 'EMAIL_TYP_CD', length: 3, valid_values: /^(HM|OTH|WRK)$/i })

    options Hash will be passed through to Rsmart::ETL.parse_string.

Returns:

  • (String)

    the parsed EMAIL_TYP_CD.

Raises:

See Also:



284
285
286
287
288
289
# File 'lib/rsmart_toolbox/etl/grm.rb', line 284

def self.parse_email_type(str, opt={ name: 'EMAIL_TYP_CD', length: 3, valid_values: /^(HM|OTH|WRK)$/i })
  opt[:name]         = "EMAIL_TYP_CD" if opt[:name].nil?
  opt[:length]       = 3 if opt[:length].nil?
  opt[:valid_values] = /^(HM|OTH|WRK)$/i if opt[:valid_values].nil?
  return Rsmart::ETL::parse_flag str, opt
end

.parse_emp_stat_cd(str, opt = { name: 'EMP_STAT_CD', valid_values: /^(A|D|L|N|P|R|S|T)$/i }) ⇒ String

Parse an EMP_STAT_CD from a String.

Parameters:

  • str (String)

    the String to be parsed.

  • opt (Hash) (defaults to: { name: 'EMP_STAT_CD', valid_values: /^(A|D|L|N|P|R|S|T)$/i })

    options Hash will be passed through to Rsmart::ETL.parse_string.

Returns:

  • (String)

    the parsed EMP_STAT_CD.

Raises:

See Also:



178
179
180
181
182
183
# File 'lib/rsmart_toolbox/etl/grm.rb', line 178

def self.parse_emp_stat_cd(str, opt={ name: 'EMP_STAT_CD', valid_values: /^(A|D|L|N|P|R|S|T)$/i })
  #   `EMP_STAT_CD` varchar(40) COLLATE utf8_bin DEFAULT NULL,
  opt[:name]         = "EMP_STAT_CD" if opt[:name].nil?
  opt[:valid_values] = /^(A|D|L|N|P|R|S|T)$/i if opt[:valid_values].nil?
  return Rsmart::ETL::parse_flag str, opt
end

.parse_emp_typ_cd(str, opt = { name: 'EMP_TYP_CD', valid_values: /^(N|O|P)$/i }) ⇒ String

Parse an EMP_TYP_CD from a String.

Parameters:

  • str (String)

    the String to be parsed.

  • opt (Hash) (defaults to: { name: 'EMP_TYP_CD', valid_values: /^(N|O|P)$/i })

    options Hash will be passed through to Rsmart::ETL.parse_string.

Returns:

  • (String)

    the parsed EMP_TYP_CD.

Raises:

See Also:



191
192
193
194
195
196
# File 'lib/rsmart_toolbox/etl/grm.rb', line 191

def self.parse_emp_typ_cd(str, opt={ name: 'EMP_TYP_CD', valid_values: /^(N|O|P)$/i })
  #   `EMP_TYP_CD` varchar(40) COLLATE utf8_bin DEFAULT NULL,
  opt[:name]         = "EMP_TYP_CD" if opt[:name].nil?
  opt[:valid_values] = /^(N|O|P)$/i if opt[:valid_values].nil?
  return Rsmart::ETL::parse_flag str, opt
end

.parse_name_code(str, opt = { name: 'NM_TYP_CD', length: 4, valid_values: /^(OTH|PRFR|PRM)$/i }) ⇒ String

Parse a NM_TYP_CD from a String.

Parameters:

  • str (String)

    the String to be parsed.

  • opt (Hash) (defaults to: { name: 'NM_TYP_CD', length: 4, valid_values: /^(OTH|PRFR|PRM)$/i })

    options Hash will be passed through to Rsmart::ETL.parse_string.

Returns:

  • (String)

    the parsed NM_TYP_CD.

Raises:

See Also:



217
218
219
220
221
222
# File 'lib/rsmart_toolbox/etl/grm.rb', line 217

def self.parse_name_code(str, opt={ name: 'NM_TYP_CD', length: 4, valid_values: /^(OTH|PRFR|PRM)$/i })
  opt[:name]         = "NM_TYP_CD" if opt[:name].nil?
  opt[:length]       = 4 if opt[:length].nil?
  opt[:valid_values] = /^(OTH|PRFR|PRM)$/i if opt[:valid_values].nil?
  return Rsmart::ETL::parse_flag str, opt
end

.parse_owned_by_unit!(row, insert_str, values_str, opt = { name: 'OWNED_BY_UNIT', required: true, length: 8 }) ⇒ void

This method returns an undefined value.

Parses the OWNED_BY_UNIT by column :name and mutates the SQL statement accordingly.

Parameters:

  • row (CSV::Row)

    the CSV Row being parsed

  • insert_str (String)

    the left side of the insert statement (i.e. columns)

  • values_str (String)

    the right side of the insert statement (i.e. values)

  • opt (Hash) (defaults to: { name: 'OWNED_BY_UNIT', required: true, length: 8 })

    options Hash will be passed through to Rsmart::ETL.parse_string!.

See Also:



104
105
106
107
108
109
110
# File 'lib/rsmart_toolbox/etl/grm.rb', line 104

def self.parse_owned_by_unit!(row, insert_str, values_str, opt={ name: 'OWNED_BY_UNIT', required: true, length: 8 })
  #   `OWNED_BY_UNIT` varchar(8) COLLATE utf8_bin NOT NULL,
  opt[:name]     = "OWNED_BY_UNIT" if opt[:name].nil?
  opt[:required] = true if opt[:required].nil?
  opt[:length]   = 8 if opt[:length].nil?
  Rsmart::ETL::parse_string! row, insert_str, values_str, opt
end

.parse_phone_number(str, opt = { name: 'PHONE_NBR', length: 12, valid_values: /^(\d{3}-\d{3}-\d{4})?$/ }) ⇒ String

Parse a PHONE_NBR from a String.

Parameters:

  • str (String)

    the String to be parsed.

  • opt (Hash) (defaults to: { name: 'PHONE_NBR', length: 12, valid_values: /^(\d{3}-\d{3}-\d{4})?$/ })

    options Hash will be passed through to Rsmart::ETL.parse_string.

Returns:

  • (String)

    the parsed PHONE_NBR.

Raises:

See Also:



271
272
273
274
275
276
# File 'lib/rsmart_toolbox/etl/grm.rb', line 271

def self.parse_phone_number(str, opt={ name: 'PHONE_NBR', length: 12, valid_values: /^(\d{3}-\d{3}-\d{4})?$/ })
  opt[:name]         = "PHONE_NBR" if opt[:name].nil?
  opt[:length]       = 12 if opt[:length].nil?
  opt[:valid_values] = /^(\d{3}-\d{3}-\d{4})?$/ if opt[:valid_values].nil?
  return Rsmart::ETL::parse_string str, opt
end

.parse_phone_type(str, opt = { name: 'PHONE_TYP_CD', length: 3, valid_values: /^(FAX|HM|MBL|OTH|WRK)$/i }) ⇒ String

Parse a PHONE_TYP_CD from a String.

Parameters:

  • str (String)

    the String to be parsed.

  • opt (Hash) (defaults to: { name: 'PHONE_TYP_CD', length: 3, valid_values: /^(FAX|HM|MBL|OTH|WRK)$/i })

    options Hash will be passed through to Rsmart::ETL.parse_string.

Returns:

  • (String)

    the parsed PHONE_TYP_CD.

Raises:

See Also:



258
259
260
261
262
263
# File 'lib/rsmart_toolbox/etl/grm.rb', line 258

def self.parse_phone_type(str, opt={ name: 'PHONE_TYP_CD', length: 3, valid_values: /^(FAX|HM|MBL|OTH|WRK)$/i })
  opt[:name]         = "PHONE_TYP_CD" if opt[:name].nil?
  opt[:length]       = 3 if opt[:length].nil?
  opt[:valid_values] = /^(FAX|HM|MBL|OTH|WRK)$/i if opt[:valid_values].nil?
  return Rsmart::ETL::parse_flag str, opt
end

.parse_postal_code!(row, insert_str, values_str, opt = { name: 'POSTAL_CODE', length: 15 }) ⇒ void

This method returns an undefined value.

Parses the POSTAL_CODE by column :name and mutates the SQL statement accordingly.

Parameters:

  • row (CSV::Row)

    the CSV Row being parsed

  • insert_str (String)

    the left side of the insert statement (i.e. columns)

  • values_str (String)

    the right side of the insert statement (i.e. values)

  • opt (Hash) (defaults to: { name: 'POSTAL_CODE', length: 15 })

    options Hash will be passed through to Rsmart::ETL.parse_string!.

See Also:



90
91
92
93
94
95
# File 'lib/rsmart_toolbox/etl/grm.rb', line 90

def self.parse_postal_code!(row, insert_str, values_str, opt={ name: 'POSTAL_CODE', length: 15 })
  #   `POSTAL_CODE` varchar(15) COLLATE utf8_bin DEFAULT NULL,
  opt[:name]   = "POSTAL_CODE" if opt[:name].nil?
  opt[:length] = 15 if opt[:length].nil?
  Rsmart::ETL::parse_string! row, insert_str, values_str, opt
end

.parse_prefix(str, opt = { name: 'PREFIX_NM', length: 3, valid_values: /^(Ms|Mrs|Mr|Dr)?$/ }) ⇒ String

Parse a PREFIX_NM from a String.

Parameters:

  • str (String)

    the String to be parsed.

  • opt (Hash) (defaults to: { name: 'PREFIX_NM', length: 3, valid_values: /^(Ms|Mrs|Mr|Dr)?$/ })

    options Hash will be passed through to Rsmart::ETL.parse_string.

Returns:

  • (String)

    the parsed PREFIX_NM.

Raises:

See Also:



230
231
232
233
234
235
236
# File 'lib/rsmart_toolbox/etl/grm.rb', line 230

def self.parse_prefix(str, opt={ name: 'PREFIX_NM', length: 3, valid_values: /^(Ms|Mrs|Mr|Dr)?$/ })
  opt[:name]         = "PREFIX_NM" if opt[:name].nil?
  opt[:length]       = 3 if opt[:length].nil?
  opt[:valid_values] = /^(Ms|Mrs|Mr|Dr)?$/ if opt[:valid_values].nil?
  opt[:upcase]       = false if opt[:upcase].nil?
  return Rsmart::ETL::parse_flag str, opt
end

.parse_principal_id(str, opt = { name: 'PRNCPL_ID', required: true, length: 40 }) ⇒ String

Parse a PRNCPL_ID from a String.

Parameters:

  • str (String)

    the String to be parsed.

  • opt (Hash) (defaults to: { name: 'PRNCPL_ID', required: true, length: 40 })

    options Hash will be passed through to Rsmart::ETL.parse_string.

Returns:

  • (String)

    the parsed PRNCPL_ID.

See Also:



147
148
149
150
151
152
153
# File 'lib/rsmart_toolbox/etl/grm.rb', line 147

def self.parse_principal_id(str, opt={ name: 'PRNCPL_ID', required: true, length: 40 })
  #   `PRNCPL_ID` varchar(40) COLLATE utf8_bin NOT NULL DEFAULT '',
  opt[:name]     = "PRNCPL_ID" if opt[:name].nil?
  opt[:required] = true if opt[:required].nil?
  opt[:length]   = 40   if opt[:length].nil?
  Rsmart::ETL::parse_string str, opt
end

.parse_principal_name(str, opt = { name: 'PRNCPL_NM', required: true, length: 100 }) ⇒ String

Parse a PRNCPL_NM from a String.

Parameters:

  • str (String)

    the String to be parsed.

  • opt (Hash) (defaults to: { name: 'PRNCPL_NM', required: true, length: 100 })

    options Hash will be passed through to Rsmart::ETL.parse_string.

Returns:

  • (String)

    the parsed PRNCPL_NM.

See Also:



160
161
162
163
164
165
166
167
168
169
170
# File 'lib/rsmart_toolbox/etl/grm.rb', line 160

def self.parse_principal_name(str, opt={ name: 'PRNCPL_NM', required: true, length: 100 })
  #   `PRNCPL_NM` varchar(100) COLLATE utf8_bin NOT NULL,
  opt[:name]     = "PRNCPL_NM" if opt[:name].nil?
  opt[:length]   = 100  if opt[:length].nil?
  opt[:required] = true if opt[:required].nil?
  prncpl_nm = Rsmart::ETL::parse_string str, opt
  unless prncpl_nm =~ /^([a-z0-9\@\.\_\-]+)$/
    raise Rsmart::ETL::error TextParseError.new "Illegal prncpl_nm found: '#{prncpl_nm}'"
  end
  return prncpl_nm
end

.parse_rolodex_id!(row, insert_str, values_str, opt = { name: 'ROLODEX_ID', required: true, length: 6 }) ⇒ void

This method returns an undefined value.

Parses the ROLODEX_ID by column :name and mutates the SQL statement accordingly.

Parameters:

  • row (CSV::Row)

    the CSV Row being parsed

  • insert_str (String)

    the left side of the insert statement (i.e. columns)

  • values_str (String)

    the right side of the insert statement (i.e. values)

  • opt (Hash) (defaults to: { name: 'ROLODEX_ID', required: true, length: 6 })

    options Hash will be passed through to Rsmart::ETL.parse_integer!.

See Also:



32
33
34
35
36
37
38
# File 'lib/rsmart_toolbox/etl/grm.rb', line 32

def self.parse_rolodex_id!(row, insert_str, values_str, opt={ name: 'ROLODEX_ID', required: true, length: 6 })
  #   `ROLODEX_ID` decimal(6,0) NOT NULL DEFAULT '0',
  opt[:name]     = "ROLODEX_ID" if opt[:name].nil?
  opt[:required] = true if opt[:required].nil?
  opt[:length]   = 6 if opt[:length].nil?
  Rsmart::ETL::parse_integer! row, insert_str, values_str, opt
end

.parse_sponsor_code!(row, insert_str, values_str, opt = { name: 'SPONSOR_CODE', required: false, length: 6 }) ⇒ void

This method returns an undefined value.

Parses the SPONSOR_CODE by column :name and mutates the SQL statement accordingly.

Parameters:

  • row (CSV::Row)

    the CSV Row being parsed

  • insert_str (String)

    the left side of the insert statement (i.e. columns)

  • values_str (String)

    the right side of the insert statement (i.e. values)

  • opt (Hash) (defaults to: { name: 'SPONSOR_CODE', required: false, length: 6 })

    options Hash will be passed through to Rsmart::ETL.parse_string!.

See Also:



75
76
77
78
79
80
81
# File 'lib/rsmart_toolbox/etl/grm.rb', line 75

def self.parse_sponsor_code!(row, insert_str, values_str, opt={ name: 'SPONSOR_CODE', required: false, length: 6 })
  #   `SPONSOR_CODE` char(6) COLLATE utf8_bin NOT NULL DEFAULT '',
  opt[:name]     = "SPONSOR_CODE" if opt[:name].nil?
  opt[:required] = false if opt[:required].nil?
  opt[:length]   = 6 if opt[:length].nil?
  Rsmart::ETL::parse_string! row, insert_str, values_str, opt
end

.parse_state!(row, insert_str, values_str, opt = { name: 'STATE', length: 30 }) ⇒ void

This method returns an undefined value.

Parses the STATE by column :name and mutates the SQL statement accordingly.

Parameters:

  • row (CSV::Row)

    the CSV Row being parsed

  • insert_str (String)

    the left side of the insert statement (i.e. columns)

  • values_str (String)

    the right side of the insert statement (i.e. values)

  • opt (Hash) (defaults to: { name: 'STATE', length: 30 })

    options Hash will be passed through to Rsmart::ETL.parse_string!.

See Also:



61
62
63
64
65
66
# File 'lib/rsmart_toolbox/etl/grm.rb', line 61

def self.parse_state!(row, insert_str, values_str, opt={ name: 'STATE', length: 30 })
  #   `STATE` varchar(30) COLLATE utf8_bin DEFAULT NULL,
  opt[:name]   = "STATE" if opt[:name].nil?
  opt[:length] = 30 if opt[:length].nil?
  Rsmart::ETL::parse_string! row, insert_str, values_str, opt
end

.parse_suffix(str, opt = { name: 'SUFFIX_NM', length: 3, valid_values: /^(Jr|Sr|Mr|Md)?$/ }) ⇒ String

Parse a SUFFIX_NM from a String.

Parameters:

  • str (String)

    the String to be parsed.

  • opt (Hash) (defaults to: { name: 'SUFFIX_NM', length: 3, valid_values: /^(Jr|Sr|Mr|Md)?$/ })

    options Hash will be passed through to Rsmart::ETL.parse_string.

Returns:

  • (String)

    the parsed SUFFIX_NM.

Raises:

See Also:



244
245
246
247
248
249
250
# File 'lib/rsmart_toolbox/etl/grm.rb', line 244

def self.parse_suffix(str, opt={ name: 'SUFFIX_NM', length: 3, valid_values: /^(Jr|Sr|Mr|Md)?$/ })
  opt[:name]         = "SUFFIX_NM" if opt[:name].nil?
  opt[:length]       = 3 if opt[:length].nil?
  opt[:valid_values] = /^(Jr|Sr|Mr|Md)?$/ if opt[:valid_values].nil?
  opt[:upcase]       = false if opt[:upcase].nil?
  return Rsmart::ETL::parse_flag str, opt
end

.parse_year(str, opt = { name: 'YEAR', length: 4, valid_values: /^(\d{4})?$/ }) ⇒ String

Parse a YEAR from a String.

Parameters:

  • str (String)

    the String to be parsed.

  • opt (Hash) (defaults to: { name: 'YEAR', length: 4, valid_values: /^(\d{4})?$/ })

    options Hash will be passed through to Rsmart::ETL.parse_string.

Returns:

  • (String)

    the parsed YEAR.

Raises:

See Also:



297
298
299
300
301
# File 'lib/rsmart_toolbox/etl/grm.rb', line 297

def self.parse_year(str, opt={ name: 'YEAR', length: 4, valid_values: /^(\d{4})?$/ })
  opt[:length]       = 4 if opt[:length].nil?
  opt[:valid_values] = /^(\d{4})?$/ if opt[:valid_values].nil?
  return Rsmart::ETL::parse_string str, opt
end

.validate_hr_xml(xml_filename) ⇒ Boolean

Note:

Any schema validation errors are output to STDOUT via puts.

Performs an XML XSD schema validation using the published schema.

Parameters:

  • xml_filename (String)

    A path to the XML file to be validated.

Returns:

  • (Boolean)

    true if no validation errors are found; otherwise false.



364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
# File 'lib/rsmart_toolbox/etl/grm.rb', line 364

def self.validate_hr_xml(xml_filename)
  ret_val = false
  # validate the resulting XML file against the official XSD schema
  uri = URI 'https://raw.githubusercontent.com/KualiCo/ce-tech-docs/master/hrmanifest.xsd'
  Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
    Tempfile.open "hrmanifest.xsd" do |schema|
      request = Net::HTTP::Get.new uri.request_uri
      http.request request do |response|
        response.read_body do |segment|
          schema.write(segment)
        end
      end
      schema.rewind
      xsd = Nokogiri::XML::Schema schema
      doc = Nokogiri::XML File.read xml_filename
      xml_errors = xsd.validate doc
      if xml_errors.empty?
        puts "Congratulations! The XML file passes XSD schema validation! w00t!\n\n"
        ret_val = true
      else
        puts "Sorry, the XML file does NOT pass XSD schema validation!:"
        xml_errors.each do |error|
          puts error.message
        end
      end
    end # schema
  end
  return ret_val
end