Skip to content

Commit d4bf793

Browse files
committed
Implement renaming logic
1 parent ec58dc7 commit d4bf793

1 file changed

Lines changed: 55 additions & 7 deletions

File tree

archive/new-naming-scheme.js

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,64 @@ for (let shaclDir of shaclDirs) {
1313
shaclFiles = shaclFiles.concat((await promises.readdir(shaclDir)).map(file => `${shaclDir}/${file}`).filter(file => file.endsWith(".ttl")))
1414
}
1515

16+
const map = {
17+
"ff:hilfe-zum-lebensunterhalt": "ff:hlu",
18+
"ff:kindergeld": "ff:kdg",
19+
"ff:kinderzuschlag": "ff:kzl",
20+
"ff:bafoeg": "ff:bfg",
21+
"ff:buergergeld": "ff:bgd",
22+
"ff:arbeitslosengeld": "ff:alg",
23+
"ff:berufsausbildungsbeihilfe-bab": "ff:bab",
24+
"ff:wohngeld": "ff:wog",
25+
"ff:grundsicherung-im-alter-und-bei-erwerbsminderung": "ff:gsi",
26+
"ff:bildung-und-teilhabe-bei-bezug-von-buergergeld": "ff:but",
27+
"ff:ausbildungsgeld": "ff:asg",
28+
"ff:blindengeld": "ff:blg",
29+
"ff:blindenhilfe": "ff:blh",
30+
"ff:bundesfoerderung-effiziente-gebaeude": "ff:beg",
31+
"ff:exist-gruendungsstipendium": "ff:exs",
32+
"ff:forschungszulage": "ff:fzl",
33+
"ff:ibb-altersgerecht-wohnen": "ff:iaw",
34+
"ff:ibb-gruendungsbonus": "ff:igb",
35+
"ff:ifb-gruendung-nachfolge": "ff:ifn",
36+
"ff:ilb-kredit-gruendung": "ff:ilg",
37+
"ff:kurzzeitige-arbeitsverhinderung": "ff:kav",
38+
"ff:uebergangsgeld": "ff:ueg",
39+
"ff:wolfenbuettel-ansiedlung": "ff:wfa",
40+
"ff:wolfenbuettel-gastronomische-aussenmoeblierung": "ff:wfgam",
41+
"ff:wolfenbuettel-stiftung-organisation": "ff:wfsto",
42+
"ff:wolfenbuettel-stiftung-person": "ff:wfstp",
43+
"ff:allgemeine-krankenversicherungspflicht": "ff:akv",
44+
"ff:arbeitsassistenz": "ff:aas",
45+
"ff:eingliederungshilfe": "ff:egh",
46+
"ff:erwerbsminderungsrente-teilweise": "ff:emt",
47+
"ff:erwerbsminderungsrente-voll": "ff:emv",
48+
"ff:persoenliches-budget": "ff:pbg",
49+
"ff:schwerbehindertenausweis": "ff:sba",
50+
"ff:substitutionstherapie-diamorphin": "ff:std",
51+
"ff:substitutionstherapie-regulaer": "ff:str"
52+
}
53+
1654
for (let file of shaclFiles) {
1755
// let filename = path.basename(file)
1856
let content = await promises.readFile(file, "utf8")
19-
const cls = "ff:RequirementProfile"
20-
const regex = new RegExp(`^([^\\s#;]+)\\s+a\\s+${cls}\\b`, "gm")
57+
58+
let cls = "ff:RequirementProfile"
59+
let regex = new RegExp(`(.*?)\\s+a\\s+${cls}`)
60+
const oldRpUri = content.match(regex)[1].trim()
61+
const newRpUri = map[oldRpUri]
62+
content = content.split(oldRpUri + " a ").join(newRpUri + " a ")
63+
content = content.split(oldRpUri + "MainShape").join(newRpUri + "MainShape")
64+
content = content.split(oldRpUri + "FlowShape").join(newRpUri + "FlowShape")
65+
66+
cls = "sh:PropertyShape"
67+
regex = new RegExp(`^([^\\s#;]+)\\s+a\\s+${cls}\\b`, "gm")
2168
const matches = [... content.matchAll(regex)].map(m => m[1].trim())
22-
console.log(matches[0])
23-
/*for (let match of matches) {
24-
const hash = Math.random().toString(36).slice(2, 5)
25-
content = content.split(match).join(`${match}_${hash}`)
69+
for (let oldPsUri of matches) {
70+
let localName = oldPsUri.split(":")[1]
71+
let newPsUri = newRpUri + localName.charAt(0).toUpperCase() + localName.slice(1)
72+
content = content.split(oldPsUri).join(newPsUri)
2673
}
27-
await promises.writeFile(file, content, "utf8")*/
74+
75+
await promises.writeFile(file, content, "utf8")
2876
}

0 commit comments

Comments
 (0)