@@ -21,16 +21,6 @@ export class ObservationsSender {
2121 */
2222 private _url : string ;
2323
24- /**
25- * The full url to the feature layer receiving observations.
26- */
27- private _urlAdd : string ;
28-
29- /**
30- * The full url to the feature layer receiving updates.
31- */
32- private _urlUpdate : string ;
33-
3424 /**
3525 * Used to log to the console.
3626 */
@@ -56,8 +46,6 @@ export class ObservationsSender {
5646 */
5747 constructor ( layerInfo : LayerInfo , config : ArcGISPluginConfig , identityManager : ArcGISIdentityManager , console : Console ) {
5848 this . _url = layerInfo . url ;
59- this . _urlAdd = this . _url + '/addFeatures' ;
60- this . _urlUpdate = this . _url + '/updateFeatures' ;
6149 this . _console = console ;
6250 this . _attachmentDirectory = environment . attachmentBaseDirectory ;
6351 this . _config = config ;
@@ -70,7 +58,7 @@ export class ObservationsSender {
7058 * @param observations The observations to convert.
7159 */
7260 sendAdds ( observations : ArcObjects ) {
73- this . _console . info ( 'ArcGIS addFeatures url ' + this . _urlAdd ) ;
61+ this . _console . info ( 'ArcGIS addFeatures' ) ;
7462
7563 let responseHandler = this . addResponseHandler ( observations ) ;
7664 addFeatures ( {
@@ -87,7 +75,7 @@ export class ObservationsSender {
8775 * @returns The json string of the observations.
8876 */
8977 sendUpdates ( observations : ArcObjects ) {
90- this . _console . info ( 'ArcGIS updateFeatures url ' + this . _urlUpdate ) ;
78+ this . _console . info ( 'ArcGIS updateFeatures' ) ;
9179
9280 let responseHandler = this . updateResponseHandler ( observations ) ;
9381 updateFeatures ( {
@@ -101,36 +89,34 @@ export class ObservationsSender {
10189 * Delete an observation.
10290 * @param id The observation id.
10391 */
104- sendDelete ( id : number ) {
105- const url = this . _url + '/deleteFeatures'
106- this . _console . info ( 'ArcGIS deleteFeatures url ' + url + ', ' + this . _config . observationIdField + ': ' + id )
92+ sendDelete ( id : string ) {
93+ this . _console . info ( 'ArcGIS deleteFeatures id: ' + id )
10794
108- deleteFeatures ( {
109- url ,
95+ request ( ` ${ this . _url } /deleteFeatures` , {
96+ httpMethod : 'POST' ,
11097 authentication : this . _identityManager ,
111- objectIds : [ id ]
112- } ) . catch ( ( error ) => this . _console . error ( error ) ) ;
98+ params : {
99+ where : `${ this . _config . observationIdField } LIKE \'%${ id } \'`
100+ }
101+ } ) . catch ( ( error ) => this . _console . error ( 'Error in ObservationSender.sendDelete :: ' + error ) ) ;
113102 }
114103
115104 /**
116105 * Deletes all observations that are apart of a specified event.
117106 * @param id The event id.
118107 */
119- sendDeleteEvent ( id : number ) {
120-
121- const url = this . _url + '/deleteFeatures'
108+ sendDeleteEvent ( id : string ) {
109+ this . _console . info ( 'ArcGIS deleteFeatures by event ' + this . _config . observationIdField + ': ' + id ) ;
122110
123- this . _console . info ( 'ArcGIS deleteFeatures by event url ' + url + ', ' + this . _config . observationIdField + ': ' + id )
124-
125- const form = new FormData ( )
126-
127- if ( this . _config . eventIdField == null ) {
128- form . append ( 'where' , this . _config . observationIdField + ' LIKE\'%' + this . _config . idSeparator + id + '\'' )
129- } else {
130- form . append ( 'where' , this . _config . eventIdField + '=' + id )
131- }
132-
133- this . sendDelete ( id ) ;
111+ request ( `${ this . _url } /deleteFeatures` , {
112+ httpMethod : 'POST' ,
113+ authentication : this . _identityManager ,
114+ params : {
115+ where : ! ! this . _config . eventIdField
116+ ? this . _config . eventIdField + '=' + id
117+ : this . _config . observationIdField + ' LIKE\'%' + this . _config . idSeparator + id + '\''
118+ }
119+ } ) . catch ( ( error ) => this . _console . error ( 'Error in ObservationSender.sendDeleteEvent :: ' + error ) ) ;
134120 }
135121
136122 /**
@@ -207,7 +193,6 @@ export class ObservationsSender {
207193 */
208194 private queryAndUpdateAttachments ( observation : ArcObservation , objectId : number ) {
209195 // Query for existing attachments
210- const queryUrl = this . _url + '/' + objectId + '/attachments'
211196 getAttachments ( {
212197 url : this . _url ,
213198 authentication : this . _identityManager ,
@@ -225,7 +210,6 @@ export class ObservationsSender {
225210 * @param attachmentInfos The arc attachment infos.
226211 */
227212 private updateAttachments ( observation : ArcObservation , objectId : number , attachmentInfos : AttachmentInfo [ ] ) {
228-
229213 // Build a mapping between existing arc attachment names and the attachment infos
230214 let nameAttachments = new Map < string , AttachmentInfo > ( )
231215 if ( attachmentInfos != null ) {
@@ -319,7 +303,6 @@ export class ObservationsSender {
319303 * @param attachmentInfos The arc attachment infos.
320304 */
321305 private deleteAttachments ( objectId : number , attachmentInfos : AttachmentInfo [ ] ) {
322-
323306 const attachmentIds : number [ ] = [ ]
324307
325308 for ( const attachmentInfo of attachmentInfos ) {
0 commit comments