Skip to content

Commit b34eb84

Browse files
committed
this should work up to the datasets in a root collection, need testing and strategy for the folders
1 parent 9b9cbed commit b34eb84

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

scripts/migration/migrate.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,15 +201,26 @@ def process_collection_descendants(collection, headers, v2_parent_id, v2_parent_
201201
for child in child_col_json:
202202
if v2_parent_type == "dataset":
203203
print(f"Add folder to the dataset")
204+
folder_name = child["name"]
205+
new_folder = create_folder_if_not_exists_or_get(folder_name, None, v2_dataset_id, headers)
206+
process_collection_descendants(child, headers, new_folder['id'], 'folder', v2_dataset_id )
204207
else:
205208
print(f"parent was a folder")
206-
print(f"Make a folder for this child")
207-
print(f"Call process descendants")
208-
process_collection_descendants(child, headers)
209+
print(f"Add folder to the dataset")
210+
folder_name = child["name"]
211+
new_folder = create_folder_if_not_exists_or_get(folder_name, v2_parent_id, v2_dataset_id, headers)
212+
process_collection_descendants(child, headers, new_folder['id'], 'folder', v2_dataset_id)
209213

210214
for dataset in dataset_json:
211-
print(f"Make a folder for this dataset")
212-
print(f"Add folders and subfolders")
215+
if v2_parent_type == "dataset":
216+
print(f"Parent is a dataset")
217+
new_folder = create_folder_if_not_exists_or_get(dataset["name"], v2_parent_id, v2_dataset_id, headers)
218+
print(f"Now we need to add the sub folders of this dataset")
219+
else:
220+
print(f"Parent is a folder")
221+
new_folder = create_folder_if_not_exists_or_get(dataset["name"], v2_parent_id, v2_dataset_id, headers)
222+
223+
213224

214225
def process_dataset_folders(dataset, headers):
215226
pass

0 commit comments

Comments
 (0)