@@ -8,7 +8,7 @@ import environment from '@ngageoint/mage.service/lib/environment/env'
88import fs from 'fs'
99import path from 'path'
1010import { ArcGISIdentityManager , IFeature , request } from "@esri/arcgis-rest-request"
11- import { addFeatures , updateFeatures , getAttachments , updateAttachment , addAttachment , deleteAttachments } from "@esri/arcgis-rest-feature-service" ;
11+ import { addFeatures , updateFeatures , deleteFeatures , getAttachments , updateAttachment , addAttachment , deleteAttachments } from "@esri/arcgis-rest-feature-service" ;
1212
1313/**
1414 * Class that transforms observations into a json string that can then be sent to an arcgis server.
@@ -63,7 +63,8 @@ export class ObservationsSender {
6363 url : this . _url ,
6464 authentication : this . _identityManager ,
6565 features : observations . objects as IFeature [ ]
66- } ) . then ( this . responseHandler ( observations ) ) . catch ( ( error ) => this . _console . error ( error ) ) ;
66+ } ) . then ( this . responseHandler ( observations ) )
67+ . catch ( ( error ) => this . _console . error ( 'Error in ObservationSender.sendAdds :: ' + error ) ) ;
6768 }
6869
6970 /**
@@ -79,7 +80,8 @@ export class ObservationsSender {
7980 url : this . _url ,
8081 authentication : this . _identityManager ,
8182 features : observations . objects as IFeature [ ]
82- } ) . then ( this . responseHandler ( observations , true ) ) . catch ( ( error ) => this . _console . error ( error ) ) ;
83+ } ) . then ( this . responseHandler ( observations , true ) )
84+ . catch ( ( error ) => this . _console . error ( 'Error in ObservationSender.sendUpdates :: ' + error ) ) ;
8385 }
8486
8587 /**
@@ -89,12 +91,11 @@ export class ObservationsSender {
8991 sendDelete ( id : string ) {
9092 this . _console . info ( 'ArcGIS deleteFeatures id: ' + id )
9193
92- request ( ` ${ this . _url } / deleteFeatures` , {
93- httpMethod : 'POST' ,
94+ deleteFeatures ( {
95+ url : this . _url ,
9496 authentication : this . _identityManager ,
95- params : {
96- where : `${ this . _config . observationIdField } LIKE \'%${ id } \'`
97- }
97+ where : `${ this . _config . observationIdField } LIKE \'%${ id } %\'` ,
98+ objectIds : [ ]
9899 } ) . catch ( ( error ) => this . _console . error ( 'Error in ObservationSender.sendDelete :: ' + error ) ) ;
99100 }
100101
@@ -105,14 +106,13 @@ export class ObservationsSender {
105106 sendDeleteEvent ( id : number ) {
106107 this . _console . info ( 'ArcGIS deleteFeatures by event ' + this . _config . observationIdField + ': ' + id ) ;
107108
108- request ( ` ${ this . _url } / deleteFeatures` , {
109- httpMethod : 'POST' ,
109+ deleteFeatures ( {
110+ url : this . _url ,
110111 authentication : this . _identityManager ,
111- params : {
112- where : ! ! this . _config . eventIdField
113- ? this . _config . eventIdField + '=' + id
114- : this . _config . observationIdField + ' LIKE\'%' + this . _config . idSeparator + id + '\''
115- }
112+ where : ! ! this . _config . eventIdField
113+ ? `${ this . _config . eventIdField } = ${ id } `
114+ : this . _config . observationIdField + ' LIKE\'%' + this . _config . idSeparator + id + '\'' ,
115+ objectIds : [ ]
116116 } ) . catch ( ( error ) => this . _console . error ( 'Error in ObservationSender.sendDeleteEvent :: ' + error ) ) ;
117117 }
118118
@@ -237,10 +237,10 @@ export class ObservationsSender {
237237
238238 const fileName = this . attachmentFileName ( attachment )
239239 this . _console . info ( 'ArcGIS ' + request + ' file ' + fileName + ' from ' + file )
240-
240+
241241 const readStream = await fs . openAsBlob ( file )
242242 const attachmentFile = new File ( [ readStream ] , fileName )
243-
243+
244244 addAttachment ( {
245245 url : this . _url ,
246246 authentication : this . _identityManager ,
@@ -262,10 +262,10 @@ export class ObservationsSender {
262262
263263 const fileName = this . attachmentFileName ( attachment )
264264 this . _console . info ( 'ArcGIS ' + request + ' file ' + fileName + ' from ' + file )
265-
265+
266266 const readStream = await fs . openAsBlob ( file )
267267 const attachmentFile = new File ( [ readStream ] , fileName )
268-
268+
269269 updateAttachment ( {
270270 url : this . _url ,
271271 authentication : this . _identityManager ,
0 commit comments