/*import { Model } from './model'; import { AttributeType, DerivedOCLAttributeType, DerivedComplexAttributeType, Method, BusinessEventType, BusinessObjectType, ModifyingMethod, State, ExistenceDependency } from './meta-model'; import { AttributeValueType } from './meta-model/attribute/attributeType'; import { FSM } from './meta-model'; import { OwnershipType } from './meta-model/method/ownershipType'; import { EffectType } from './meta-model/method/effectType'; import { StateType, Transition } from './meta-model/fsm'; import * as fs from 'fs'; import { ExistenceDependencyType } from './meta-model/existenceDependency'; import { inspect } from 'util'; import { EventParticipantTable, InstanceAccessRule, OperationType, ActionType } from './meta-model/permissionsLayer'; import { AttributeReadingTable } from './meta-model/permissionsLayer'; //=====SETUP MODEL ===== const id: string = 'A01'; const model: Model = new Model(id); //=====ATTRIBUTE TYPES===== //For BOT: Order const productRef: AttributeType = new AttributeType('productRef', AttributeValueType.String, false); const price: AttributeType = new AttributeType('price', AttributeValueType.Number, false); const quantity: AttributeType = new AttributeType('quantity', AttributeValueType.Number, false); const receipt: DerivedOCLAttributeType = new DerivedOCLAttributeType('receipt', AttributeValueType.Number, 'this.price*this.quantity', false); const discount: DerivedComplexAttributeType = new DerivedComplexAttributeType('discount', AttributeValueType.Number, 'return $receipt*0,1', false); //For BOT: Customer const firstName: AttributeType = new AttributeType('firstName', AttributeValueType.String, false); const lastName: AttributeType = new AttributeType('lastName', AttributeValueType.String, false); const address: AttributeType = new AttributeType('address', AttributeValueType.String, false); //----- Add AttributeTypes to Model ----- model.addAttributeType(productRef); model.addAttributeType(price); model.addAttributeType(quantity); model.addAttributeType(receipt); model.addAttributeType(discount); model.addAttributeType(firstName); model.addAttributeType(lastName); model.addAttributeType(address); //===== BUSINESS EVENTS ===== //---For BOT: Customer const evCustomerCreate: BusinessEventType = new BusinessEventType('EV_CUSTOMER_CREATE'); const evCustomerEnd: BusinessEventType = new BusinessEventType('EV_CUSTOMER_END'); //---For BOT: Order const evOrderCreate: BusinessEventType = new BusinessEventType('EV_ORDER_CREATE'); const evOrderPaid: BusinessEventType = new BusinessEventType('EV_ORDER_PAID'); const evOrderDelivered: BusinessEventType = new BusinessEventType('EV_ORDER_DELIVERED'); //---Adding to Model model.addBusinessEventType(evCustomerCreate); model.addBusinessEventType(evCustomerEnd); model.addBusinessEventType(evOrderCreate); model.addBusinessEventType(evOrderPaid); model.addBusinessEventType(evOrderDelivered); //===== METHODS ===== //---For BOT: Customer const firstNameParam: AttributeType = firstName; const lastNameParam: AttributeType = lastName; const meCustomerCreate: Method = new Method('ME_CUSTOMER_CREATE', evCustomerCreate, OwnershipType.Own, EffectType.Create, [firstNameParam, lastNameParam]); const meCustomerEnd: Method = new Method('ME_CUSTOMER_END', evCustomerEnd, OwnershipType.Own, EffectType.End); //---Adding Methods model.addMethod(meCustomerCreate); model.addMethod(meCustomerEnd); //---For BOT: Order const productRefParam: AttributeType = productRef; const quantityParam: AttributeType = quantity; const priceParam: AttributeType = price; const meOrderCreate: Method = new Method('ME_ORDER_CREATE', evOrderCreate, OwnershipType.Own, EffectType.Create, [productRefParam, quantityParam, priceParam]); const meOrderPaid: Method = new ModifyingMethod('ME_ORDER_PAID', evOrderPaid, OwnershipType.Own, []); const meOrderDelivered: Method = new Method('ME_ORDER_DELIVERED', evOrderDelivered, OwnershipType.Own, EffectType.End); //---Adding Methods model.addMethod(meOrderCreate); model.addMethod(meOrderPaid); model.addMethod(meOrderDelivered); //===== Business Object Types ==== const botCustomer: BusinessObjectType = new BusinessObjectType('customer', true); botCustomer.addAttribute(firstName); botCustomer.addAttribute(lastName); botCustomer.addAttribute(address); botCustomer.addMethod(meCustomerCreate); botCustomer.addMethod(meCustomerEnd); const botOrder: BusinessObjectType = new BusinessObjectType('order', false); botOrder.addAttribute(productRef); botOrder.addAttribute(quantity); botOrder.addAttribute(price); botOrder.addAttribute(receipt); botOrder.addAttribute(discount); botOrder.addMethod(meOrderCreate); botOrder.addMethod(meOrderPaid); botOrder.addMethod(meOrderDelivered); //====== FINITE STATE MACHINES ===== //---For BOT: Customer: Default //---For BOT: ORDER const orderInitial: State = new State('initial', StateType.INITIAL); const orderWaitingForPayment: State = new State('waitingForPayment', StateType.EXISTING); const orderWaitingForDelivery: State = new State('waitingForDelivery', StateType.EXISTING); const orderDelivered: State = new State('delivered', StateType.FINAL); const trOrderCreate: Transition = new Transition(orderInitial, orderWaitingForPayment, meOrderCreate); const trOrderPay: Transition = new Transition(orderWaitingForPayment, orderWaitingForDelivery, meOrderPaid); const trOrderDeliver: Transition = new Transition(orderWaitingForDelivery, orderDelivered, meOrderDelivered); const fsmOrder: FSM = new FSM(botOrder, [orderInitial, orderWaitingForPayment, orderWaitingForDelivery, orderDelivered], [trOrderCreate, trOrderPay, trOrderDeliver] ); botOrder.setFSM(fsmOrder); //=====Existence Dependencies===== const edCustomerMasterOrder: ExistenceDependency = new ExistenceDependency('customer', botCustomer, botOrder, ExistenceDependencyType.MANDATORY_ONE); model.addExistenceDependency(edCustomerMasterOrder); //------ Adding Bots model.addBusinessObjectType(botCustomer); model.addBusinessObjectType(botOrder); //========================= //========================= //EPT const ept = new EventParticipantTable(model); ept.allow(evOrderCreate, botCustomer); model.setEventParticipantTable(ept); //ART const art = new AttributeReadingTable(model); art.allow(firstName, botCustomer); art.allow(lastName, botCustomer); model.setAttributeReadingTable(art); //IARs const iar1 = new InstanceAccessRule([OperationType.READ, OperationType.UPDATE], botCustomer, botCustomer, 'bo.id != ptcpt.id', ActionType.DENY); const iar2 = new InstanceAccessRule([OperationType.READ], botOrder, botCustomer, "order.customer.id === customer.id", ActionType.ALLOW); model.addInstanceAccessRule(iar1); model.addInstanceAccessRule(iar2); const pkg = model.package(); fs.writeFileSync('./output/model.json', JSON.stringify(pkg, null, 4)); const loadedModel = Model.loadFromFile('./output/model.json'); fs.writeFileSync('./output/model-read.json', JSON.stringify(loadedModel.package(), null, 4)); */ export * from './meta-model'; export * from './model';