Skip to content

Commit afc2462

Browse files
committed
Fix legacy questionnaire
Signed-off-by: Marek Aufart <[email protected]>
1 parent bbca57d commit afc2462

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

hack/tool/tackle

+8-6
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,6 @@ def apiFilePost(url, token, filePath, ignoreErrors=False):
215215
return resp.text
216216

217217
def tackle2path(obj):
218-
if 'assessment' in obj:
219-
return "/hub/pathfinder/%s" % obj.replace("--", "/") # Nested path decoding (e.g. assessments/assessment-risk)
220218
return "/hub/%s" % obj
221219

222220
def loadDump(path, fallback_value = []):
@@ -244,7 +242,7 @@ def cmdWanted(args, action):
244242

245243
class TackleTool:
246244
# TYPES order matters for import/upload to Tackle2
247-
TYPES = ['tagcategories', 'tags', 'jobfunctions', 'stakeholdergroups', 'stakeholders', 'businessservices', 'identities', 'applications', 'analyses', 'proxies', 'dependencies', 'questionnaires', 'archetypes', 'assessments', 'reviews']
245+
TYPES = ['tagcategories', 'tags', 'jobfunctions', 'stakeholdergroups', 'stakeholders', 'businessservices', 'identities', 'applications', 'proxies', 'dependencies', 'questionnaires', 'archetypes', 'assessments', 'reviews']
248246
NOT_IMPORTED_TYPES = ['taskgroups', 'tasks']
249247
TACKLE2_SEED_TYPES = ['tagcategories', 'tags', 'jobfunctions']
250248

@@ -303,16 +301,22 @@ class TackleTool:
303301

304302
# Gather Tackle 2 API objects
305303
def dumpTackle2(self):
304+
ensureDataDir(self.dataDir)
306305
for t in self.TYPES:
307306
print("Exporting %s.." % t)
308-
if "identities" in t:
307+
if t == "identities":
309308
dictCollection = apiJSON(self.tackle2Url + "/hub/identities?decrypted=1", self.tackle2Token)
310309
for dictObj in dictCollection:
311310
dictObj['key'] = self.encrypt(dictObj['key'])
312311
dictObj['password'] = self.encrypt(dictObj['password'])
313312
dictObj['settings'] = self.encrypt(dictObj['settings'])
314313
else:
315314
dictCollection = apiJSON(self.tackle2Url + tackle2path(t), self.tackle2Token)
315+
316+
# Remove legacy locked questionnaire from export to not cause conflict in import (should be 1st one)
317+
if t == "questionnaires":
318+
dictCollection = dictCollection[1:]
319+
316320
# Save data locally
317321
saveJSON(os.path.join(self.dataDir, t), dictCollection)
318322

@@ -527,8 +531,6 @@ if cmdWanted(args, "export"):
527531
# Setup data migration object
528532
tool = TackleTool(args.data_dir, '', '', c['url'], token2, c['encryption_passphase'])
529533

530-
ensureDataDir(self.dataDir)
531-
532534
# Run the export expecting clean destination
533535
print("Exporting Tackle 2 objects into %s (this might take a while..)" % args.data_dir)
534536
tool.dumpTackle2()

0 commit comments

Comments
 (0)