UNPKG

isoxml

Version:

JavaScript library to parse and generate ISOXML (ISO11783-10) files

107 lines (106 loc) 2.77 kB
import { TAGS } from './constants'; import { registerEntityClass } from '../classRegistry'; import { fromXML, toXML } from '../utils'; export var ProductProductTypeEnum; (function (ProductProductTypeEnum) { ProductProductTypeEnum["SingleDefault"] = "1"; ProductProductTypeEnum["Mixture"] = "2"; ProductProductTypeEnum["TemporaryMixture"] = "3"; })(ProductProductTypeEnum || (ProductProductTypeEnum = {})); 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 }, }; export class Product { constructor(attributes, isoxmlManager) { this.attributes = attributes; this.isoxmlManager = isoxmlManager; this.tag = TAGS.Product; } static fromXML(xml, isoxmlManager, internalId, targetClass = Product) { return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId); } toXML() { return toXML(this, ATTRIBUTES, CHILD_TAGS); } } registerEntityClass('main', TAGS.Product, Product);