This repository was archived by the owner on Feb 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathindex.js
More file actions
185 lines (169 loc) · 6.35 KB
/
index.js
File metadata and controls
185 lines (169 loc) · 6.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
'use strict';
var VALID_OBJECT_TYPES = ['hmda', 'ts', 'lar'];
var VALID_EDIT_TYPES = ['validity', 'syntactical', 'quality', 'macro'];
// 2013 Spec and Edits
var filespec2013 = require('./2013/data_file_specification.json'),
hmdaMacro2013 = require('./2013/hmda-macro.json'),
hmdaQuality2013 = require('./2013/hmda-quality.json'),
hmdaSpecial2013 = require('./2013/hmda-special.json'),
hmdaSyntactical2013 = require('./2013/hmda-syntactical.json'),
larQuality2013 = require('./2013/lar-quality.json'),
larSyntactical2013 = require('./2013/lar-syntactical.json'),
larValidity2013 = require('./2013/lar-validity.json'),
tsQuality2013 = require('./2013/ts-quality.json'),
tsSyntactical2013 = require('./2013/ts-syntactical.json'),
tsValidity2013 = require('./2013/ts-validity.json');
// 2014 Spec and Edits
var filespec2014 = require('./2014/data_file_specification.json'),
hmdaMacro2014 = require('./2014/hmda-macro.json'),
hmdaQuality2014 = require('./2014/hmda-quality.json'),
hmdaSpecial2014 = require('./2014/hmda-special.json'),
hmdaSyntactical2014 = require('./2014/hmda-syntactical.json'),
larQuality2014 = require('./2014/lar-quality.json'),
larSyntactical2014 = require('./2014/lar-syntactical.json'),
larValidity2014 = require('./2014/lar-validity.json'),
tsQuality2014 = require('./2014/ts-quality.json'),
tsSyntactical2014 = require('./2014/ts-syntactical.json'),
tsValidity2014 = require('./2014/ts-validity.json');
// NPRM Spec and Edits
var filespecnprm = require('./nprm/data_file_specification.json'),
hmdaMacronprm = require('./nprm/hmda-macro.json'),
hmdaQualitynprm = require('./nprm/hmda-quality.json'),
hmdaSpecialnprm = require('./nprm/hmda-special.json'),
hmdaSyntacticalnprm = require('./nprm/hmda-syntactical.json'),
larQualitynprm = require('./nprm/lar-quality.json'),
larSyntacticalnprm = require('./nprm/lar-syntactical.json'),
larValiditynprm = require('./nprm/lar-validity.json'),
tsQualitynprm = require('./nprm/ts-quality.json'),
tsSyntacticalnprm = require('./nprm/ts-syntactical.json'),
tsValiditynprm = require('./nprm/ts-validity.json');
var specs = {
'2013': {
'filespec': filespec2013,
'hmda': {
'macro': hmdaMacro2013,
'quality': hmdaQuality2013,
'special': hmdaSpecial2013,
'syntactical': hmdaSyntactical2013
},
'lar': {
'quality': larQuality2013,
'syntactical': larSyntactical2013,
'validity': larValidity2013
},
'ts': {
'quality': tsQuality2013,
'syntactical': tsSyntactical2013,
'validity': tsValidity2013
}
},
'2014': {
'filespec': filespec2014,
'hmda': {
'macro': hmdaMacro2014,
'quality': hmdaQuality2014,
'special': hmdaSpecial2014,
'syntactical': hmdaSyntactical2014
},
'lar': {
'quality': larQuality2014,
'syntactical': larSyntactical2014,
'validity': larValidity2014
},
'ts': {
'quality': tsQuality2014,
'syntactical': tsSyntactical2014,
'validity': tsValidity2014
}
},
'nprm': {
'filespec': filespecnprm,
'hmda': {
'macro': hmdaMacronprm,
'quality': hmdaQualitynprm,
'special': hmdaSpecialnprm,
'syntactical': hmdaSyntacticalnprm
},
'lar': {
'quality': larQualitynprm,
'syntactical': larSyntacticalnprm,
'validity': larValiditynprm
},
'ts': {
'quality': tsQualitynprm,
'syntactical': tsSyntacticalnprm,
'validity': tsValiditynprm
}
}
};
/**
* Constructs new instance of the SpecAPI
* @constructs SpecAPI
*/
var SpecAPI = function() {
/**
* Get the available years that have edits defined
* @return {array} Array of valid years
*/
this.getValidYears = function() {
return Object.keys(specs);
};
/**
* Get the available defined object scope types
* @return {array} Array of the valid object scope types
*/
this.getValidObjectTypes = function() {
return VALID_OBJECT_TYPES;
};
/**
* Get the available defined edit types
* @return {array} Array of the valid edit types
*/
this.getValidEditTypes = function() {
return VALID_EDIT_TYPES;
};
/**
* Get the defined file specification for the year
* @param {string} year Year for the file specification
* @return {object} Object defining the file specification
*/
this.getFileSpec = function(year) {
if (specs[year] && specs[year].filespec) {
return specs[year].filespec;
} else {
return null;
}
};
/**
* Get a property from the defined file specification for the year.
* @param {string} year The {@link SpecAPI#getValidYears|year} for the edits
* @param {string} scope The {@link SpecAPI#getValidObjectTypes|scope} for the edits
* @param {string} property The property
* @return {object} Object defining the property within file specification
*/
this.getFileSpecProperty = function(year, scope, property) {
var spec = this.getFileSpec(year);
if (scope === 'ts' && spec && spec.transmittalSheet[property]) {
return spec.transmittalSheet[property];
} else if (scope === 'lar' && spec && spec.loanApplicationRegister[property]) {
return spec.loanApplicationRegister[property];
}
return null;
};
/**
* Gets the defined edits for the chosen year, scope, and edit type
* @param {string} year The {@link SpecAPI#getValidYears|year} for the edits
* @param {string} scope The {@link SpecAPI#getValidObjectTypes|scope} for the edits
* @param {string} editType The {@link SpecAPI#getValidEditTypes|edit} type
* @return {object} Object defining the list of edits that match the given parameters
*/
this.getEdits = function(year, scope, editType) {
if (specs[year][scope][editType]) {
return specs[year][scope][editType];
} else {
return null;
}
};
return this;
};
module.exports = new SpecAPI();