isoxml
Version:
JavaScript library to parse and generate ISOXML (ISO11783-10) files
80 lines (79 loc) • 2.26 kB
JavaScript
import { TAGS } from './constants';
import { registerEntityClass } from '../classRegistry';
import { fromXML, toXML } from '../utils';
export var ProductAllocationTransferModeEnum;
(function (ProductAllocationTransferModeEnum) {
ProductAllocationTransferModeEnum["Filling"] = "1";
ProductAllocationTransferModeEnum["Emptying"] = "2";
ProductAllocationTransferModeEnum["Remainder"] = "3";
})(ProductAllocationTransferModeEnum || (ProductAllocationTransferModeEnum = {}));
const ATTRIBUTES = {
A: {
name: 'ProductIdRef',
type: 'xs:IDREF',
isPrimaryId: false,
isOptional: false,
isOnlyV4: false,
},
B: {
name: 'QuantityDDI',
type: 'xs:hexBinary',
isPrimaryId: false,
isOptional: true,
isOnlyV4: false,
},
C: {
name: 'QuantityValue',
type: 'xs:long',
isPrimaryId: false,
isOptional: true,
isOnlyV4: false,
minValue: 0,
maxValue: 2147483647,
},
D: {
name: 'TransferMode',
type: 'xs:NMTOKEN',
isPrimaryId: false,
isOptional: true,
isOnlyV4: false,
},
E: {
name: 'DeviceElementIdRef',
type: 'xs:IDREF',
isPrimaryId: false,
isOptional: true,
isOnlyV4: false,
},
F: {
name: 'ValuePresentationIdRef',
type: 'xs:IDREF',
isPrimaryId: false,
isOptional: true,
isOnlyV4: false,
},
G: {
name: 'ProductSubTypeIdRef',
type: 'xs:IDREF',
isPrimaryId: false,
isOptional: true,
isOnlyV4: true,
},
};
const CHILD_TAGS = {
ASP: { name: 'AllocationStamp', isOnlyV4: false },
};
export class ProductAllocation {
constructor(attributes, isoxmlManager) {
this.attributes = attributes;
this.isoxmlManager = isoxmlManager;
this.tag = TAGS.ProductAllocation;
}
static fromXML(xml, isoxmlManager, internalId, targetClass = ProductAllocation) {
return fromXML(xml, isoxmlManager, targetClass, ATTRIBUTES, CHILD_TAGS, internalId);
}
toXML() {
return toXML(this, ATTRIBUTES, CHILD_TAGS);
}
}
registerEntityClass('main', TAGS.ProductAllocation, ProductAllocation);