@@ -124,7 +124,7 @@ def caltechdata_write(
124124 file_links = [],
125125 s3 = None ,
126126 community = None ,
127- authors = False
127+ authors = False ,
128128):
129129 """
130130 File links are links to files existing in external systems that will
@@ -149,28 +149,43 @@ def caltechdata_write(
149149 else :
150150 repo_prefix = "10.33569"
151151 pids = {}
152- if "identifiers" in metadata :
153- for identifier in metadata ["identifiers" ]:
152+ identifiers = []
153+ if "metadata" in metadata :
154+ # we have rdm schema
155+ if "identifiers" in metadata ["metadata" ]:
156+ identifiers = metadata ["metadata" ]["identifiers" ]
157+ elif "identifiers" in metadata :
158+ identifiers = metadata ["identifiers" ]
159+ for identifier in identifiers :
160+ if "identifierType" in identifier :
154161 if identifier ["identifierType" ] == "DOI" :
155162 doi = identifier ["identifier" ]
156163 prefix = doi .split ("/" )[0 ]
157-
158- if prefix == repo_prefix :
159- pids ["doi" ] = {
160- "identifier" : doi ,
161- "provider" : "datacite" ,
162- "client" : "datacite" ,
163- }
164- else :
165- pids ["doi" ] = {
166- "identifier" : doi ,
167- "provider" : "external" ,
168- }
169164 elif identifier ["identifierType" ] == "oai" :
170165 pids ["oai" ] = {
171166 "identifier" : identifier ["identifier" ],
172167 "provider" : "oai" ,
173168 }
169+ elif "scheme" in identifier :
170+ # We have RDM internal metadata
171+ if identifier ["scheme" ] == "doi" :
172+ doi = identifier ["identifier" ]
173+ prefix = doi .split ("/" )[0 ]
174+ else :
175+ doi = False
176+ if doi != False :
177+ if prefix == repo_prefix :
178+ pids ["doi" ] = {
179+ "identifier" : doi ,
180+ "provider" : "datacite" ,
181+ "client" : "datacite" ,
182+ }
183+ else :
184+ pids ["doi" ] = {
185+ "identifier" : doi ,
186+ "provider" : "external" ,
187+ }
188+
174189 metadata ["pids" ] = pids
175190
176191 if authors == False :
@@ -202,6 +217,7 @@ def caltechdata_write(
202217 data ["files" ] = {"default_preview" : "README.txt" }
203218
204219 # Make draft and publish
220+ print (data )
205221 result = requests .post (url + "/api/records" , headers = headers , json = data )
206222 if result .status_code != 201 :
207223 raise Exception (result .text )
0 commit comments