Skip to content

Commit

Permalink
Only put update if metadata has actually been updated (#88)
Browse files Browse the repository at this point in the history
* Only put update if metadata has actually been updated

* Update json values and add a missed value
  • Loading branch information
CEBergin-Vivid authored Jun 10, 2023
1 parent 23a2545 commit 88e5e26
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
6 changes: 3 additions & 3 deletions wfdm-file-reindexer/jsonUpdates/wffinFieldUpdates.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
{
"fixType": "transferValueThenDelete",
"fieldNameToUpdate": "appAcronym",
"destinationFieldName": "AppAcronym "
"destinationFieldName": "AppAcronym"
},
{
"fixType": "transferValueThenDelete",
"fieldNameToUpdate": "application.domain.name",
"destinationFieldName": "AppAcronym "
"destinationFieldName": "AppAcronym"
},
{
"fixType": "transferValueThenDelete",
"fieldNameToUpdate": "Classification",
"destinationFieldName": "InformationSchedule "
"destinationFieldName": "InformationSchedule"
},
{
"fixType": "transferValueThenDelete",
Expand Down
5 changes: 5 additions & 0 deletions wfdm-file-reindexer/jsonUpdates/wfimFieldUpdates.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
"fixType": "transferValueThenDelete",
"fieldNameToUpdate": "created",
"destinationFieldName": "DateCreated"
},
{
"fixType": "transferValueThenDelete",
"fieldNameToUpdate": "content-type",
"destinationFieldName": "Format"
},
{
"fixType": "transferValueThenDelete",
Expand Down
2 changes: 1 addition & 1 deletion wfdm-file-reindexer/jsonUpdates/wfwxFieldUpdates.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"fixType": "transferValueThenDelete",
"fieldNameToUpdate": "application.domain.name",
"destinationFieldName": "AppAcronym "
"destinationFieldName": "AppAcronym"
},
{
"fixType": "transferValueThenDelete",
Expand Down
32 changes: 18 additions & 14 deletions wfdm-file-reindexer/metadata-datafix.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def update_metadata(document_id, page, row_count):
print(wfdm_doc_response)
else:
# Pull out the fileId, this is our parent for WFDM
changed = False
doc_json = wfdm_doc_response.json()
del wfdm_doc_response
# First, update the metadata records
Expand All @@ -100,23 +101,26 @@ def update_metadata(document_id, page, row_count):
doc_json['metadata'].pop(
positionInMetaArr)
positionInMetaArr = positionInMetaArr - 1
changed = True
break
elif i["fixType"] == "renameField":
meta['metadataName'] = i["destinationFieldName"]


# Now that they type is updated, we can push in an update
wfdm_put_response = requests.put(docs_endpoint + '/' + document['fileId'], data=json.dumps(
doc_json), headers={'Authorization': 'Bearer ' + token, 'content-type': 'application/json'})
# verify 200
if wfdm_put_response.status_code != 200:
print(wfdm_put_response)
# Don't fail out here, just cary on
del wfdm_put_response

# then, if this is a directory, jump into it and update the documents it contains
if document['fileType'] == 'DIRECTORY':
update_metadata(document['fileId'], 1, row_count)
changed = True


if (changed):
# Now that they type is updated, we can push in an update
wfdm_put_response = requests.put(docs_endpoint + '/' + document['fileId'], data=json.dumps(
doc_json), headers={'Authorization': 'Bearer ' + token, 'content-type': 'application/json'})
# verify 200
if wfdm_put_response.status_code != 200:
print(wfdm_put_response)
# Don't fail out here, just cary on
del wfdm_put_response

# then, if this is a directory, jump into it and update the documents it contains
if document['fileType'] == 'DIRECTORY':
update_metadata(document['fileId'], 1, row_count)

# check if we need to page
if wfdm_docs['totalPageCount'] > page:
Expand Down

0 comments on commit 88e5e26

Please sign in to comment.