Skip to content

Commit

Permalink
Dates returned from API calls are now correctly converted to Data obj…
Browse files Browse the repository at this point in the history
…ects.
  • Loading branch information
Josh McCullough committed Jul 1, 2015
1 parent 9301023 commit bad885b
Show file tree
Hide file tree
Showing 18 changed files with 315 additions and 225 deletions.
1 change: 1 addition & 0 deletions Content/Scripts/API/Output/hiw-api-lite.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ declare module hiw {
/** Recusively fills this instance with the provided data.
* @param json A JSON object containing the properties and values to copy to this instance. */
fill(json: any, exclude?: Array<string>): void;
protected parseDate(value: any): Date;
}
}
declare module hiw {
Expand Down
18 changes: 18 additions & 0 deletions Content/Scripts/API/Output/hiw-api-lite.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Content/Scripts/API/Output/hiw-api-lite.js.map

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion Content/Scripts/API/Output/hiw-api-lite.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions Content/Scripts/API/Output/hiw-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ declare module hiw {
/** Recusively fills this instance with the provided data.
* @param json A JSON object containing the properties and values to copy to this instance. */
fill(json: any, exclude?: Array<string>): void;
protected parseDate(value: any): Date;
}
}
declare module hiw {
Expand Down Expand Up @@ -944,6 +945,8 @@ declare module hiw {
* @param page The page of data to retrieve.
* @return An IEnumerable of DataCategories */
static getAll(api: API, callback: IAPICallback<Array<DataCategory>>, page?: number, pageSize?: number): Async;
/** Handles special data types during "fill". */
fill(json: any, exclude?: Array<string>): void;
/** Gets how many DataCategories exist. */
static getAllCount(api: API, callback: IAPICallback<number>): Async;
/** Gets how many pages of data exist for the DataCategories method. */
Expand Down Expand Up @@ -1109,6 +1112,8 @@ declare module hiw {
* @param page The page of data to retrieve.
* @return An IEnumerable of DataSourceDataSuppliers */
static getAll(api: API, callback: IAPICallback<Array<DataSourceDataSupplier>>, page?: number, pageSize?: number): Async;
/** Handles special data types during "fill". */
fill(json: any, exclude?: Array<string>): void;
/** Gets how many DataSourceDataSuppliers exist. */
static getAllCount(api: API, callback: IAPICallback<number>): Async;
/** Gets how many pages of data exist for the DataSourceDataSuppliers method. */
Expand Down Expand Up @@ -1223,6 +1228,8 @@ declare module hiw {
* @param page The page of data to retrieve.
* @return An IEnumerable of DataSources */
static getAll(api: API, callback: IAPICallback<Array<DataSource>>, page?: number, pageSize?: number): Async;
/** Handles special data types during "fill". */
fill(json: any, exclude?: Array<string>): void;
/** Gets how many DataSources exist. */
static getAllCount(api: API, callback: IAPICallback<number>): Async;
/** Gets how many pages of data exist for the DataSources method. */
Expand Down Expand Up @@ -1353,6 +1360,8 @@ declare module hiw {
* @param page The page of data to retrieve.
* @return An IEnumerable of DataSuppliers */
static getAll(api: API, callback: IAPICallback<Array<DataSupplier>>, page?: number, pageSize?: number): Async;
/** Handles special data types during "fill". */
fill(json: any, exclude?: Array<string>): void;
/** Gets how many DataSuppliers exist. */
static getAllCount(api: API, callback: IAPICallback<number>): Async;
/** Gets how many pages of data exist for the DataSuppliers method. */
Expand Down Expand Up @@ -2777,6 +2786,8 @@ declare module hiw {
* @param page The page of data to retrieve.
* @return An IEnumerable of GlossaryTerms */
static getAll(api: API, callback: IAPICallback<Array<GlossaryTerm>>, page?: number, pageSize?: number): Async;
/** Handles special data types during "fill". */
fill(json: any, exclude?: Array<string>): void;
/** Gets how many GlossaryTerms exist. */
static getAllCount(api: API, callback: IAPICallback<number>): Async;
/** Gets how many pages of data exist for the GlossaryTerms method. */
Expand Down Expand Up @@ -3007,6 +3018,8 @@ declare module hiw {
* @param page The page of data to retrieve.
* @return An IEnumerable of HP2020TSMs */
static getAll(api: API, callback: IAPICallback<Array<HP2020TSM>>, page?: number, pageSize?: number): Async;
/** Handles special data types during "fill". */
fill(json: any, exclude?: Array<string>): void;
/** Gets how many HP2020TSMs exist. */
static getAllCount(api: API, callback: IAPICallback<number>): Async;
/** Gets how many pages of data exist for the HP2020TSMs method. */
Expand Down Expand Up @@ -4663,6 +4676,8 @@ declare module hiw {
* @param page The page of data to retrieve.
* @return An IEnumerable of IndicatorDescriptions */
static getAll(api: API, callback: IAPICallback<Array<IndicatorDescription>>, page?: number, pageSize?: number): Async;
/** Handles special data types during "fill". */
fill(json: any, exclude?: Array<string>): void;
/** Gets how many IndicatorDescriptions exist. */
static getAllCount(api: API, callback: IAPICallback<number>): Async;
/** Gets how many pages of data exist for the IndicatorDescriptions method. */
Expand Down Expand Up @@ -5342,6 +5357,8 @@ declare module hiw {
* @param page The page of data to retrieve.
* @return An IEnumerable of Initiatives */
static getAll(api: API, callback: IAPICallback<Array<Initiative>>, page?: number, pageSize?: number): Async;
/** Handles special data types during "fill". */
fill(json: any, exclude?: Array<string>): void;
/** Gets how many Initiatives exist. */
static getAllCount(api: API, callback: IAPICallback<number>): Async;
/** Gets how many pages of data exist for the Initiatives method. */
Expand Down Expand Up @@ -5455,6 +5472,8 @@ declare module hiw {
* @param page The page of data to retrieve.
* @return An IEnumerable of Keywords */
static getAll(api: API, callback: IAPICallback<Array<Keyword>>, page?: number, pageSize?: number): Async;
/** Handles special data types during "fill". */
fill(json: any, exclude?: Array<string>): void;
/** Gets how many Keywords exist. */
static getAllCount(api: API, callback: IAPICallback<number>): Async;
/** Gets how many pages of data exist for the Keywords method. */
Expand Down Expand Up @@ -7124,6 +7143,8 @@ declare module hiw {
* @param page The page of data to retrieve.
* @return An IEnumerable of Urls */
static getAll(api: API, callback: IAPICallback<Array<Url>>, page?: number, pageSize?: number): Async;
/** Handles special data types during "fill". */
fill(json: any, exclude?: Array<string>): void;
/** Gets how many Urls exist. */
static getAllCount(api: API, callback: IAPICallback<number>): Async;
/** Gets how many pages of data exist for the Urls method. */
Expand Down Expand Up @@ -7513,6 +7534,7 @@ declare module hiw {
loadDate: Date;
serviceVersion: number;
protected getFields(): any;
fill(json: any, exclude?: Array<string>): void;
static version(api: API, callback: IAPICallback<VersionInfo>): void;
}
}
Expand Down
78 changes: 78 additions & 0 deletions Content/Scripts/API/Output/hiw-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,24 @@ var hiw;
this.links.push(hiw.extend(new hiw.Link(), json.Links[i]));
}
};
ServiceDataObject.prototype.parseDate = function (value) {
if (value == null)
return null;
else {
var match = value.toString().match(/\/Date\((\d+)(?:([+-])(\d\d)(\d\d))?\)\//);
var milliseconds = null;
if (match == null)
return new Date(NaN);
milliseconds = parseInt(match[1], 10);
if (match[2] && match[3] && match[4]) {
var tzDirection = (match[2] == "+" ? -1 : 1);
var tzHours = parseInt(match[3], 10);
var tzMinutes = parseInt(match[4], 10);
milliseconds += (tzDirection * ((tzHours * 60) + tzMinutes) * 60000);
}
return new Date(milliseconds);
}
};
return ServiceDataObject;
})(hiw.ServiceObject);
hiw.ServiceDataObject = ServiceDataObject;
Expand Down Expand Up @@ -1569,6 +1587,11 @@ var hiw;
BaseDataCategory.getAll = function (api, callback, page, pageSize) {
return api.executeEndpoint(hiw.Endpoint.fromSelf(), callback, null, null, page, pageSize);
};
/** Handles special data types during "fill". */
BaseDataCategory.prototype.fill = function (json, exclude) {
_super.prototype.fill.call(this, json, exclude);
this.modifyDate = this.parseDate(this.modifyDate);
};
/** Gets how many DataCategories exist. */
BaseDataCategory.getAllCount = function (api, callback) {
return api.executeEndpoint(hiw.Endpoint.fromSelf(), callback);
Expand Down Expand Up @@ -1846,6 +1869,11 @@ var hiw;
BaseDataSourceDataSupplier.getAll = function (api, callback, page, pageSize) {
return api.executeEndpoint(hiw.Endpoint.fromSelf(), callback, null, null, page, pageSize);
};
/** Handles special data types during "fill". */
BaseDataSourceDataSupplier.prototype.fill = function (json, exclude) {
_super.prototype.fill.call(this, json, exclude);
this.modificationDate = this.parseDate(this.modificationDate);
};
/** Gets how many DataSourceDataSuppliers exist. */
BaseDataSourceDataSupplier.getAllCount = function (api, callback) {
return api.executeEndpoint(hiw.Endpoint.fromSelf(), callback);
Expand Down Expand Up @@ -1990,6 +2018,11 @@ var hiw;
BaseDataSource.getAll = function (api, callback, page, pageSize) {
return api.executeEndpoint(hiw.Endpoint.fromSelf(), callback, null, null, page, pageSize);
};
/** Handles special data types during "fill". */
BaseDataSource.prototype.fill = function (json, exclude) {
_super.prototype.fill.call(this, json, exclude);
this.modifyDate = this.parseDate(this.modifyDate);
};
/** Gets how many DataSources exist. */
BaseDataSource.getAllCount = function (api, callback) {
return api.executeEndpoint(hiw.Endpoint.fromSelf(), callback);
Expand Down Expand Up @@ -2208,6 +2241,13 @@ var hiw;
BaseDataSupplier.getAll = function (api, callback, page, pageSize) {
return api.executeEndpoint(hiw.Endpoint.fromSelf(), callback, null, null, page, pageSize);
};
/** Handles special data types during "fill". */
BaseDataSupplier.prototype.fill = function (json, exclude) {
_super.prototype.fill.call(this, json, exclude);
this.modifyDate = this.parseDate(this.modifyDate);
_super.prototype.fill.call(this, json, exclude);
this.validationDate = this.parseDate(this.validationDate);
};
/** Gets how many DataSuppliers exist. */
BaseDataSupplier.getAllCount = function (api, callback) {
return api.executeEndpoint(hiw.Endpoint.fromSelf(), callback);
Expand Down Expand Up @@ -4371,6 +4411,11 @@ var hiw;
BaseGlossaryTerm.getAll = function (api, callback, page, pageSize) {
return api.executeEndpoint(hiw.Endpoint.fromSelf(), callback, null, null, page, pageSize);
};
/** Handles special data types during "fill". */
BaseGlossaryTerm.prototype.fill = function (json, exclude) {
_super.prototype.fill.call(this, json, exclude);
this.modificationDate = this.parseDate(this.modificationDate);
};
/** Gets how many GlossaryTerms exist. */
BaseGlossaryTerm.getAllCount = function (api, callback) {
return api.executeEndpoint(hiw.Endpoint.fromSelf(), callback);
Expand Down Expand Up @@ -4745,6 +4790,11 @@ var hiw;
BaseHP2020TSM.getAll = function (api, callback, page, pageSize) {
return api.executeEndpoint(hiw.Endpoint.fromSelf(), callback, null, null, page, pageSize);
};
/** Handles special data types during "fill". */
BaseHP2020TSM.prototype.fill = function (json, exclude) {
_super.prototype.fill.call(this, json, exclude);
this.modifyDate = this.parseDate(this.modifyDate);
};
/** Gets how many HP2020TSMs exist. */
BaseHP2020TSM.getAllCount = function (api, callback) {
return api.executeEndpoint(hiw.Endpoint.fromSelf(), callback);
Expand Down Expand Up @@ -7383,6 +7433,13 @@ var hiw;
BaseIndicatorDescription.getAll = function (api, callback, page, pageSize) {
return api.executeEndpoint(hiw.Endpoint.fromSelf(), callback, null, null, page, pageSize);
};
/** Handles special data types during "fill". */
BaseIndicatorDescription.prototype.fill = function (json, exclude) {
_super.prototype.fill.call(this, json, exclude);
this.modificationDate = this.parseDate(this.modificationDate);
_super.prototype.fill.call(this, json, exclude);
this.modifyDate = this.parseDate(this.modifyDate);
};
/** Gets how many IndicatorDescriptions exist. */
BaseIndicatorDescription.getAllCount = function (api, callback) {
return api.executeEndpoint(hiw.Endpoint.fromSelf(), callback);
Expand Down Expand Up @@ -8436,6 +8493,11 @@ var hiw;
BaseInitiative.getAll = function (api, callback, page, pageSize) {
return api.executeEndpoint(hiw.Endpoint.fromSelf(), callback, null, null, page, pageSize);
};
/** Handles special data types during "fill". */
BaseInitiative.prototype.fill = function (json, exclude) {
_super.prototype.fill.call(this, json, exclude);
this.modifyDate = this.parseDate(this.modifyDate);
};
/** Gets how many Initiatives exist. */
BaseInitiative.getAllCount = function (api, callback) {
return api.executeEndpoint(hiw.Endpoint.fromSelf(), callback);
Expand Down Expand Up @@ -8619,6 +8681,11 @@ var hiw;
BaseKeyword.getAll = function (api, callback, page, pageSize) {
return api.executeEndpoint(hiw.Endpoint.fromSelf(), callback, null, null, page, pageSize);
};
/** Handles special data types during "fill". */
BaseKeyword.prototype.fill = function (json, exclude) {
_super.prototype.fill.call(this, json, exclude);
this.modifyDate = this.parseDate(this.modifyDate);
};
/** Gets how many Keywords exist. */
BaseKeyword.getAllCount = function (api, callback) {
return api.executeEndpoint(hiw.Endpoint.fromSelf(), callback);
Expand Down Expand Up @@ -11240,6 +11307,13 @@ var hiw;
BaseUrl.getAll = function (api, callback, page, pageSize) {
return api.executeEndpoint(hiw.Endpoint.fromSelf(), callback, null, null, page, pageSize);
};
/** Handles special data types during "fill". */
BaseUrl.prototype.fill = function (json, exclude) {
_super.prototype.fill.call(this, json, exclude);
this.modifyDate = this.parseDate(this.modifyDate);
_super.prototype.fill.call(this, json, exclude);
this.validationDate = this.parseDate(this.validationDate);
};
/** Gets how many Urls exist. */
BaseUrl.getAllCount = function (api, callback) {
return api.executeEndpoint(hiw.Endpoint.fromSelf(), callback);
Expand Down Expand Up @@ -11848,6 +11922,10 @@ var hiw;
VersionInfo.prototype.getFields = function () {
return VersionInfo.Fields;
};
VersionInfo.prototype.fill = function (json, exclude) {
_super.prototype.fill.call(this, json, exclude);
this.loadDate = this.parseDate(this.loadDate);
};
VersionInfo.version = function (api, callback) {
api.executeEndpoint(hiw.Endpoint.fromSelf(), callback);
};
Expand Down
2 changes: 1 addition & 1 deletion Content/Scripts/API/Output/hiw-api.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit bad885b

Please sign in to comment.