Skip to content
Snippets Groups Projects
Verified Commit 917abac2 authored by Jan Loewe's avatar Jan Loewe :speech_balloon:
Browse files

feat(dcc): move mappings to root folder

parent ee6c824b
Branches
Tags
No related merge requests found
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<excludeFolder url="file://$MODULE_DIR$/.tmp" /> <excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" /> <excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" /> <excludeFolder url="file://$MODULE_DIR$/tmp" />
<excludeFolder url="file://$MODULE_DIR$/lib" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GitToolBoxProjectSettings">
<option name="commitMessageIssueKeyValidationOverride">
<BoolValueOverride>
<option name="enabled" value="true" />
</BoolValueOverride>
</option>
<option name="commitMessageValidationConfigOverride">
<CommitMessageValidationOverride>
<option name="enabled" value="true" />
</CommitMessageValidationOverride>
</option>
</component>
</project>
\ No newline at end of file
import * as si from "./SI"; import * as si from "./SI";
import { XMLDate as BaseXMLDate, XMLElement as BaseXMLElement, XMLBoolean as BaseXMLBoolean, XMLList as BaseXMLList } from "../BaseTypes"; import { XMLDate as BaseXMLDate, XMLElement as BaseXMLElement, XMLNumber as BaseXMLNumber, XMLBoolean as BaseXMLBoolean, XMLList as BaseXMLList } from "./BaseTypes";
import { ensureArray } from "../Util"; import { ensureArray } from "./Util";
export const schemaVersion = "3.1.0"; export const schemaVersion = "3.1.0";
export const namespace = `https://ptb.de/dcc`; export const namespace = `https://ptb.de/dcc`;
...@@ -18,6 +18,12 @@ export class XMLBoolean extends BaseXMLBoolean { ...@@ -18,6 +18,12 @@ export class XMLBoolean extends BaseXMLBoolean {
} }
} }
export class XMLNumber extends BaseXMLNumber {
getNamespace() {
return "dcc";
}
}
export class XMLDate extends BaseXMLDate { export class XMLDate extends BaseXMLDate {
getNamespace() { getNamespace() {
return "dcc"; return "dcc";
...@@ -241,6 +247,32 @@ export class TextType extends XMLElement { ...@@ -241,6 +247,32 @@ export class TextType extends XMLElement {
super(el); super(el);
this.content = ensureArray(el.content).map((x) => new StringWithLangType(x)); this.content = ensureArray(el.content).map((x) => new StringWithLangType(x));
} }
getContent(lang?: string): StringWithLangType | undefined {
// item with undefined as lang is default
const def = this.content.find((x) => x._attr == null || x._attr.lang == null);
const items = this.content.filter((x) => x._attr != null && x._attr.lang === lang);
// if there is more than one content element
// concat the text of all content elements with same lang
if (items.length > 1) {
items.forEach((item) => {
this.content.splice(this.content.indexOf(item), 1);
});
const grouped = items.reduce((prev, curr) => {
prev._text += `\n${curr._text}`;
return prev;
});
this.content.push(grouped);
return grouped;
} else {
return items.length ? items[0] : def;
}
}
} }
/** Rich content Type can contain files and formulas beside the normal text content. */ /** Rich content Type can contain files and formulas beside the normal text content. */
......
import { Element, js2xml, xml2js } from "xml-js"; import { Element, js2xml, xml2js } from "xml-js";
import { DigitalCalibrationCertificateType } from "./SchemaMappings/DCC"; import { DigitalCalibrationCertificateType } from "./DCC";
export class DCCDocument { export class DCCDocument {
_declaration: unknown; _declaration: unknown;
......
import { XMLDate as BaseXMLDate, XMLElement as BaseXMLElement, XMLNumber as BaseXMLNumber, XMLList as BaseXMLList } from "../BaseTypes"; import { XMLDate as BaseXMLDate, XMLElement as BaseXMLElement, XMLBoolean as BaseXMLBoolean, XMLNumber as BaseXMLNumber, XMLList as BaseXMLList } from "./BaseTypes";
import { ensureArray } from "../Util"; import { ensureArray } from "./Util";
export const schemaVersion = "2.1.0"; export const schemaVersion = "2.1.0";
export const namespace = `https://ptb.de/si`; export const namespace = `https://ptb.de/si`;
export const schemaLocation = `${namespace}/v${schemaVersion}/SI_Format.xsd`; export const schemaLocation = `${namespace}/v${schemaVersion}/SI_Format.xsd`;
class XMLElement extends BaseXMLElement { export class XMLElement extends BaseXMLElement {
getNamespace() { getNamespace() {
return "si"; return "si";
} }
} }
// class XMLBoolean extends BaseXMLBoolean { getNamespace() { return "si"; }} export class XMLBoolean extends BaseXMLBoolean { getNamespace() { return "si"; }}
class XMLDate extends BaseXMLDate {
export class XMLDate extends BaseXMLDate {
getNamespace() { getNamespace() {
return "si"; return "si";
} }
} }
class XMLNumber extends BaseXMLNumber { export class XMLNumber extends BaseXMLNumber {
getNamespace() { getNamespace() {
return "si"; return "si";
} }
} }
class XMLList extends BaseXMLList { export class XMLList extends BaseXMLList {
getNamespace() { getNamespace() {
return "si"; return "si";
} }
......
export * from "./Util"; export * from "./Util";
export * from "./BaseTypes/XMLBoolean";
export * from "./BaseTypes/XMLElement";
export * from "./DCCDocument"; export * from "./DCCDocument";
export * as DCC from "./SchemaMappings/DCC"; export * from "./DCC";
export * as SI from "./SchemaMappings/SI"; export * as SI from "./SI";
{ {
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "ES2021",
"module": "commonjs", "module": "commonjs",
"declaration": true, "declaration": true,
"outDir": "./lib" "outDir": "./lib"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment