isoxml-angular
Version:
JavaScript library to parse and generate ISOXML (ISO11783-10) files
104 lines (103 loc) • 2.63 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Product = void 0;
const classRegistry_1 = require("../classRegistry");
const utils_1 = require("../utils");
const ATTRIBUTES = {
A: {
name: "ProductId",
type: "xs:ID",
isPrimaryId: true,
isOptional: false,
isOnlyV4: false,
},
B: {
name: "ProductDesignator",
type: "xs:string",
isPrimaryId: false,
isOptional: false,
isOnlyV4: false,
},
C: {
name: "ProductGroupIdRef",
type: "xs:IDREF",
isPrimaryId: false,
isOptional: true,
isOnlyV4: false,
},
D: {
name: "ValuePresentationIdRef",
type: "xs:IDREF",
isPrimaryId: false,
isOptional: true,
isOnlyV4: false,
},
E: {
name: "QuantityDDI",
type: "xs:hexBinary",
isPrimaryId: false,
isOptional: true,
isOnlyV4: false,
},
F: {
name: "ProductType",
type: "xs:NMTOKEN",
isPrimaryId: false,
isOptional: true,
isOnlyV4: true,
},
G: {
name: "MixtureRecipeQuantity",
type: "xs:long",
isPrimaryId: false,
isOptional: true,
isOnlyV4: true,
minValue: 0,
maxValue: 2147483647,
},
H: {
name: "DensityMassPerVolume",
type: "xs:long",
isPrimaryId: false,
isOptional: true,
isOnlyV4: true,
minValue: 0,
maxValue: 2147483647,
},
I: {
name: "DensityMassPerCount",
type: "xs:long",
isPrimaryId: false,
isOptional: true,
isOnlyV4: true,
minValue: 0,
maxValue: 2147483647,
},
J: {
name: "DensityVolumePerCount",
type: "xs:long",
isPrimaryId: false,
isOptional: true,
isOnlyV4: true,
minValue: 0,
maxValue: 2147483647,
},
};
const CHILD_TAGS = {
PRN: { name: "ProductRelation", isOnlyV4: true },
};
class Product {
constructor(attributes, isoxmlManager) {
this.attributes = attributes;
this.isoxmlManager = isoxmlManager;
this.tag = "PDT" /* TAGS.Product */;
}
static fromXML(xml, isoxmlManager, internalId, targetClass = Product) {
return (0, utils_1.fromXML)(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId);
}
toXML() {
return (0, utils_1.toXML)(this, ATTRIBUTES, CHILD_TAGS);
}
}
exports.Product = Product;
(0, classRegistry_1.registerEntityClass)("main", "PDT" /* TAGS.Product */, Product);