Skip to content

Commit

Permalink
Fixes in model_migration.py
Browse files Browse the repository at this point in the history
  • Loading branch information
mzouros committed Nov 1, 2023
1 parent 0997bca commit 76e80c1
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions scripts/EOSCProfilev4.08_M30Release/model_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

##################################################### FUNCTIONS ########################################################
def datasource_migration(directory):
for file in os.listdir(args.path + datasourceFolder):
for file in os.listdir(directory + datasourceFolder):
if file.endswith('.json'):
isVersion = False
with open(directory + datasourceFolder + file, 'r') as json_file:
Expand Down Expand Up @@ -100,17 +100,19 @@ def migrate_datasources(json_file, isVersion):
originalOpenAIREId.text = alternativeIdentifierValue.text
datasource.append(originalOpenAIREId)
break
identifiers.remove(alternativeIdentifiers)
identifiers.remove(alternativeIdentifiers)

root.write('output.xml')
with open("../EOSCProfilev4.08_M30Release/output.xml", "r") as xml_file:
with open("output.xml", "r") as xml_file:
content = xml_file.readlines()
content = "".join(content)
bs_content = bs(content, "xml")
json_data['payload'] = str(bs_content)
if isVersion:
json_data['resource']['payload'] = json_data['payload']

return json_data


def migrate_other_resources(json_file, resourceType, isVersion):
global resource
Expand All @@ -127,8 +129,8 @@ def migrate_other_resources(json_file, resourceType, isVersion):
resource = root.find('{http://einfracentral.eu}interoperabilityRecord')
migrate_alternative_identifiers(root, resource)

root.write('output.xml')
with open("../EOSCProfilev4.08_M30Release/output.xml", "r") as xml_file:
root.write(resourceType + '-output.xml')
with open(resourceType + "-output.xml", "r") as xml_file:
content = xml_file.readlines()
content = "".join(content)
bs_content = bs(content, "xml")
Expand Down Expand Up @@ -196,7 +198,7 @@ def migrate_services(json_file, isVersion):
elif researchCategory.text == "research_category-mrd":
marketplaceLocation.text = "marketplace_location-manage_research_data"
marketplaceLocations.append(marketplaceLocation)
resourceExtras.remove(researchCategories)
resourceExtras.remove(researchCategories)
service.append(marketplaceLocations)

# horizontalService / remove ResourceExtras -> horizontalService
Expand All @@ -205,8 +207,8 @@ def migrate_services(json_file, isVersion):
existingHorizontalService = resourceExtras.find('{http://einfracentral.eu}horizontalService')
if existingHorizontalService is not None:
horizontalService.text = existingHorizontalService.text
resourceExtras.remove(existingHorizontalService)
service.append(horizontalService)
resourceExtras.remove(horizontalService)

# alternativeIdentifiers
migrate_alternative_identifiers(root, service)
Expand Down

0 comments on commit 76e80c1

Please sign in to comment.