@@ -130,6 +130,7 @@ class OutputService {
130
130
131
131
// save images to ecodata
132
132
props. data = saveImages(props. data, props. name, output. outputId, props. activityId);
133
+ props. data = saveAudio(props. data, props. name, output. outputId, props. activityId);
133
134
134
135
getCommonService(). updateProperties(output, props)
135
136
@@ -182,6 +183,7 @@ class OutputService {
182
183
try {
183
184
// save image properties to db
184
185
props. data = saveImages(props. data, props. name, output. outputId, activity. activityId)
186
+ props. data = saveAudio(props. data, props. name, output. outputId, activity. activityId)
185
187
186
188
getCommonService(). updateProperties(output, props)
187
189
@@ -235,7 +237,21 @@ class OutputService {
235
237
* @return the output data, with any image objects updated to include the new document id
236
238
*/
237
239
Map saveImages (Map output , String metadataName , String outputId , String activityId , Map context = null ) {
238
- URL biocollect
240
+ saveMultimedia(output, metadataName, outputId, activityId, " image" , " surveyImage" , " image" , context)
241
+ }
242
+
243
+ /**
244
+ * find images and save or delete it.
245
+ * @param activityId
246
+ * @param outputs
247
+ * @return the output data, with any image objects updated to include the new document id
248
+ */
249
+ Map saveAudio (Map output , String metadataName , String outputId , String activityId , Map context = null ) {
250
+ saveMultimedia(output, metadataName, outputId, activityId, " audio" , " surveyAudio" , " audio" , context)
251
+ }
252
+
253
+ Map saveMultimedia (Map output , String metadataName , String outputId , String activityId , String dataTypeName , String role , String type , Map context = null ) {
254
+ URL biocollect
239
255
InputStream stream
240
256
Map outputMetadata, names
241
257
OutputMetadata dataModel
@@ -244,7 +260,7 @@ class OutputService {
244
260
if (! context){
245
261
outputMetadata = metadataService. getOutputDataModelByName(metadataName) as Map
246
262
dataModel = new OutputMetadata (outputMetadata);
247
- names = dataModel. getNamesForDataType(' image ' , null );
263
+ names = dataModel. getNamesForDataType(dataTypeName , null );
248
264
} else {
249
265
names = context
250
266
}
@@ -259,8 +275,8 @@ class OutputService {
259
275
it. activityId = activityId
260
276
it. outputId = outputId
261
277
it. remove(' staged' )
262
- it. role = ' surveyImage '
263
- it. type = ' image '
278
+ it. role = role
279
+ it. type = type
264
280
// record creation requires images to have an 'identifier' attribute containing the url for the image
265
281
it. identifier = it. url
266
282
@@ -283,12 +299,12 @@ class OutputService {
283
299
// recursive check for image data
284
300
if (node instanceof Map ){
285
301
if (output[name] instanceof Map ){
286
- output[name] = saveImages (output[name], metadataName, outputId, activityId, node)
302
+ output[name] = saveMultimedia (output[name], metadataName, outputId, activityId, dataTypeName, role, type , node)
287
303
}
288
304
289
305
if (output[name] instanceof List ){
290
306
output[name]. eachWithIndex{ column , index ->
291
- output[name][index] = saveImages (column, metadataName, outputId, activityId, node)
307
+ output[name][index] = saveMultimedia (column, metadataName, outputId, activityId, dataTypeName, role, type, node)
292
308
}
293
309
}
294
310
}
0 commit comments