|
1 | | -import { CATEGORY_SCHEME_ID, CATEGORY_ID, CATEGORY_SCHEME_LABEL, CATEGORY_LABEL } from "@utils/contants"; |
| 1 | +import { |
| 2 | + CATEGORY_SCHEME_ID, |
| 3 | + CATEGORY_ID, |
| 4 | + CATEGORY_SCHEME_LABEL, |
| 5 | + CATEGORY_LABEL, |
| 6 | + VARIABLE_ID, |
| 7 | + VARIABLE_LABEL |
| 8 | +} from "@utils/contants"; |
2 | 9 |
|
3 | 10 | import { DDIBaseObject, DDIDetailledObject, DDIObjectIDs, DDIObjectLabels } from "@model/ddi"; |
4 | 11 |
|
5 | 12 | import { getCategories, getCategory } from "./Category"; |
6 | 13 | import { getCategoryScheme, getCategorySchemes } from "./CategoryScheme"; |
| 14 | +import { getVariable, getVariables } from "./Variable"; |
7 | 15 |
|
8 | 16 | export const getDDIObjects = (xmlDoc: Document): DDIBaseObject[] => [ |
9 | 17 | ...getCategorySchemes(xmlDoc), |
10 | | - ...getCategories(xmlDoc) |
| 18 | + ...getCategories(xmlDoc), |
| 19 | + ...getVariables(xmlDoc) |
11 | 20 | ]; |
12 | 21 |
|
13 | 22 | export const getDDIObject = (content: Document, type: DDIObjectIDs, id: string): DDIDetailledObject => { |
14 | 23 | if (type === CATEGORY_SCHEME_ID) return getCategoryScheme(content, id); |
15 | 24 | if (type === CATEGORY_ID) return getCategory(content, id); |
| 25 | + if (type === VARIABLE_ID) return getVariable(content, id); |
16 | 26 | throw new Error(`Unknow DDI object type: ${type}`); |
17 | 27 | }; |
18 | 28 |
|
19 | 29 | export const getTitle = (type: DDIObjectIDs): DDIObjectLabels => { |
20 | | - if (type === "category-scheme") return CATEGORY_SCHEME_LABEL; |
21 | | - if (type === "category") return CATEGORY_LABEL; |
| 30 | + if (type === CATEGORY_SCHEME_ID) return CATEGORY_SCHEME_LABEL; |
| 31 | + if (type === CATEGORY_ID) return CATEGORY_LABEL; |
| 32 | + if (type === VARIABLE_ID) return VARIABLE_LABEL; |
22 | 33 | throw new Error(`Unknow type: ${type}`); |
23 | 34 | }; |
0 commit comments