Skip to content

Commit

Permalink
Undo revert of FeatureQuerier
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanslatten committed Nov 8, 2024
1 parent 157d209 commit 6379dae
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 42 deletions.
30 changes: 17 additions & 13 deletions plugins/arcgis/service/src/FeatureQuerier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ export class FeatureQuerier {
params: { f: 'json' }
});

this._console.info('ArcGIS response for ' + queryUrl + ' ' + queryResponse.toString)
const result = queryResponse as QueryObjectResult
response(result);
this._console.info('ArcGIS response for ' + queryUrl + ' ' + JSON.stringify(queryResponse, null, 2))
response(queryResponse as QueryObjectResult)
}

/**
Expand All @@ -91,9 +90,8 @@ export class FeatureQuerier {
params: { f: 'json' }
});

this._console.info('ArcGIS response for ' + queryUrl + ' ' + queryResponse)
const result = queryResponse as QueryObjectResult
response(result)
this._console.info('ArcGIS response for ' + queryUrl + ' ' + JSON.stringify(queryResponse, null, 2))
response(queryResponse as QueryObjectResult)
}

/**
Expand All @@ -108,13 +106,19 @@ export class FeatureQuerier {
queryUrl.searchParams.set('outFields', this.outFields([field]));
queryUrl.searchParams.set('returnGeometry', 'false');
this._console.info('ArcGIS query: ' + queryUrl)

const queryResponse = await request(queryUrl.toString(), {
authentication: this._identityManager
});
this._console.info('ArcGIS response for ' + queryUrl + ' ' + queryResponse)
const result = queryResponse as QueryObjectResult
response(result)

try {
const queryResponse = await request(queryUrl.toString(), {
authentication: this._identityManager,
params: { f: 'json' }

});

this._console.info('ArcGIS response for ' + queryUrl + ' ' + JSON.stringify(queryResponse, null, 2))
response(queryResponse as QueryObjectResult)
} catch (err) {
console.error("could not query", err)
}
}

/**
Expand Down
62 changes: 33 additions & 29 deletions plugins/arcgis/service/src/ObservationsSender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,20 +270,22 @@ export class ObservationsSender {
* @param objectId The arc object id of the observation.
*/
private async sendAttachment(attachment: ArcAttachment, objectId: number) {
const file = path.join(this._attachmentDirectory, attachment.contentLocator!)

const fileName = this.attachmentFileName(attachment)
this._console.info('ArcGIS ' + request + ' file ' + fileName + ' from ' + file)

const readStream = await fs.openAsBlob(file)
const test = new File([readStream], fileName)

addAttachment({
url: this._url,
authentication: this._identityManager,
featureId: objectId,
attachment: test
}).catch((error) => this._console.error(error));
if (attachment.contentLocator) {
const file = path.join(this._attachmentDirectory, attachment.contentLocator!)

const fileName = this.attachmentFileName(attachment)
this._console.info('ArcGIS ' + request + ' file ' + fileName + ' from ' + file)

const readStream = await fs.openAsBlob(file)
const attachmentFile = new File([readStream], fileName)

addAttachment({
url: this._url,
authentication: this._identityManager,
featureId: objectId,
attachment: attachmentFile
}).catch((error) => this._console.error(error));
}
}

/**
Expand All @@ -293,21 +295,23 @@ export class ObservationsSender {
* @param attachmentId The observation arc attachment id.
*/
private async updateAttachment(attachment: ArcAttachment, objectId: number, attachmentId: number) {
const file = path.join(this._attachmentDirectory, attachment.contentLocator!)

const fileName = this.attachmentFileName(attachment)
this._console.info('ArcGIS ' + request + ' file ' + fileName + ' from ' + file)

const readStream = await fs.openAsBlob(file)
const test = new File([readStream], fileName)

updateAttachment({
url: this._url,
authentication: this._identityManager,
featureId: objectId,
attachmentId,
attachment: test
}).catch((error) => this._console.error(error));
if (attachment.contentLocator) {
const file = path.join(this._attachmentDirectory, attachment.contentLocator!)

const fileName = this.attachmentFileName(attachment)
this._console.info('ArcGIS ' + request + ' file ' + fileName + ' from ' + file)

const readStream = await fs.openAsBlob(file)
const attachmentFile = new File([readStream], fileName)

updateAttachment({
url: this._url,
authentication: this._identityManager,
featureId: objectId,
attachmentId,
attachment: attachmentFile
}).catch((error) => this._console.error(error));
}
}

/**
Expand Down

0 comments on commit 6379dae

Please sign in to comment.