Add optional 'oldLabel' argument to help ensure previous graphs are removed.
1 parent 3653f61 commit 31f2cc31006db0df67856b094a2856c3d1f87bb0
@Alex Tucker Alex Tucker authored on 11 Oct 2018
Showing 1 changed file
View
12
vars/uploadTidy.groovy
def call(csvs, String mapping=null) {
def call(csvs, String mapping=null, oldLabel=null) {
configFileProvider([configFile(fileId: 'pmd', variable: 'configfile')]) {
def config = readJSON(text: readFile(file: configfile))
String PMD = config['pmd_api']
String credentials = config['credentials']
String datasetGraph = "${baseURI}/graph/${datasetPath}"
String metadataGraph = "${datasetGraph}/metadata"
drafter.deleteGraph(PMD, credentials, newJobDraft.id, metadataGraph)
drafter.deleteGraph(PMD, credentials, newJobDraft.id, datasetGraph)
if (oldLabel) {
String oldDatasetPath = oldLabel
.replaceAll('[^\\w/]', '-')
.replaceAll('-+', '-')
.replaceAll('-\$', '')
String oldDatasetGraph = "${baseURI}/graph/${oldDatasetPath}"
String oldMetadataGraph = "${oldDatasetGraph}/metadata"
drafter.deleteGraph(PMD, credentials, newJobDraft.id, oldMetadataGraph)
drafter.deleteGraph(PMD, credentials, newJobDraft.id, oldDatasetGraph)
}
drafter.addData(PMD, credentials, newJobDraft.id,
readFile("out/dataset.trig"), "application/trig;charset=UTF-8")
 
csvs.each { csv ->