Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions api/src/main/kotlin/edu/wgu/osmt/csv/BatchImportRichSkill.kt
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ class BatchImportRichSkill: CsvImport<RichSkillRow> {
}?.filterNotNull()
}

fun parse_jobcodes(rowValue: String?): List<JobCodeDao>? {
return split_field(rowValue)?.map { code ->
val sanitizedCode = JobCodeBreakout.jobRoleCode(code)
jobCodeRepository.findByCodeOrCreate(sanitizedCode!!)
fun parse_jobcodes(rowValue: String?, parserFunction:
(codeParam: String) -> String?): List<JobCodeDao>? {
return split_field(rowValue)?.map {
code -> jobCodeRepository.findByCodeOrCreate(parserFunction(code)!!)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be doing something different now. Did the jobRoleCode(code) get inlined somehow?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh duh. I see it now.

}
}

Expand Down Expand Up @@ -140,6 +140,10 @@ class BatchImportRichSkill: CsvImport<RichSkillRow> {
var certifications: List<KeywordDao>? = null
var employers: List<KeywordDao>? = null
var alignments: List<KeywordDao>? = null
var blsMajor: List<JobCodeDao>? = null
var blsMinor: List<JobCodeDao>? = null
var blsBroad: List<JobCodeDao>? = null
var blsDetailed: List<JobCodeDao>? = null
var occupations: List<JobCodeDao>? = null
var collections: List<CollectionDao>? = null

Expand All @@ -149,14 +153,19 @@ class BatchImportRichSkill: CsvImport<RichSkillRow> {
standards = parse_keywords(KeywordTypeEnum.Standard, row.standards)
certifications = parse_keywords(KeywordTypeEnum.Certification, row.certifications)
employers = parse_keywords(KeywordTypeEnum.Employer, row.employer)
occupations = parse_jobcodes(row.jobRoles)
blsMajor = parse_jobcodes(row.blsMajors, JobCodeBreakout::majorCode)
blsMinor = parse_jobcodes(row.blsMinors, JobCodeBreakout::minorCode)
blsBroad = parse_jobcodes(row.blsBroads, JobCodeBreakout::broadCode)
blsDetailed = parse_jobcodes(row.blsDetaileds, JobCodeBreakout::detailedCode)
occupations = parse_jobcodes(row.jobRoles, JobCodeBreakout::jobRoleCode)
collections = parse_collections(row.collections)

if (row.alignmentTitle != null || row.alignmentUri != null) {
alignments = listOf( keywordRepository.findOrCreate(KeywordTypeEnum.Alignment, value = row.alignmentTitle, uri = row.alignmentUri) ).filterNotNull()
}

val all_keywords = concatenate(keywords, standards, certifications, employers, alignments)
val allJobcodes = concatenate(blsMajor,blsMinor,blsBroad,blsDetailed,occupations)

if (row.skillName != null && row.skillStatement != null) {
richSkillRepository.create(RsdUpdateObject(
Expand All @@ -165,7 +174,7 @@ class BatchImportRichSkill: CsvImport<RichSkillRow> {
category = NullableFieldUpdate(category),
keywords = all_keywords?.let { ListFieldUpdate(add = it) },
collections = collections?.let {ListFieldUpdate(add = it)},
jobCodes = occupations?.let { ListFieldUpdate(add = it) },
jobCodes = allJobcodes?.let { ListFieldUpdate(add = it) },
author = NullableFieldUpdate(keywordRepository.getDefaultAuthor())
), user)
log.info("created skill '${row.skillName!!}'")
Expand Down