findTypeAssignment(interfaceUsage, type) {
    Validate.isA(interfaceUsage, InterfaceUsage)
    Validate.isA(type, TypeDefinition)

    return this.refsTypeAssignment.find(typeAssing=>
      typeAssing.refsTargetType.length>0
      && typeAssing.refTargetType===type
      && typeAssing.refContext===interfaceUsage
    )
  }
    components.forEach(component=>{
      Validate.isFunctionWithArity(component.func, 1)

      const componentDependenciesExtractor = new ComponentDependenciesExtractor()

      const res = component.func(componentDependenciesExtractor)

      Validate.isNull(res)

      componentDependencies[component.func] = componentDependenciesExtractor.getDependencies()
    })
Beispiel #3
0
  constructor(ticklet, definition) {
    Validate.isA(ticklet, Ticklet)
    Validate.isA(definition, OutputDefinition)

    this._ticklet = ticklet
    this._definition = definition

    this._value = [definition.defaultValue(), null]
    this._validFrom = [-1, -2]

    this._depending = []
    this._probes = []
  }
  addComponent(componentDefinition, x, y) {
    Validate.isA(componentDefinition, ComponentDefinition)

    const componentUsage = ComponentUsage.create(componentDefinition, x, y)

    this.businessObject.addRef('componentUsage', componentUsage.businessObject)
  }
Beispiel #5
0
  addProbe(name) {
    Validate.notBlank(name)

    if (!this._probes.includes(name)) {
      this._probes.push(name)
    }
  }
  constructor(tickletRepository) {
    Validate.isA(tickletRepository, TickletRepository)

    this.tickletRepository = tickletRepository
    this._root = {
      _subs: {}
    }
  }
  static create(businessSpace) {
    Validate.isA(businessSpace, BusinessSpace)

    const businessObject = new BusinessObject(businessSpace, 'ComponentImplementation')
    businessObject.setProperty("name", "default")

    return new ComponentImplementation(businessObject)
  }
  get(id) {
    const [namespaceParts, name] = this.splitId(id)

    let act = this._root

    namespaceParts.forEach(part=>{
      if (act!==undefined) {
        act = act._subs[part]
      }
    })

    Validate.notNull(act)

    Validate.isSet(act, name)

    return act[name]
  }
Beispiel #9
0
  static create(interfaceDefinition) {
    Validate.isA(interfaceDefinition, InterfaceDefinition)

    const businessObject = new BusinessObject(interfaceDefinition.businessObject.space, 'InterfaceUsage')
    businessObject.setProperty("name", "new interface")
    businessObject.setProperty("side", "left")
    businessObject.setProperty("sideRatio", 0.5)
    businessObject.addRef("interfaceDefinition", interfaceDefinition.businessObject)

    return new InterfaceUsage(businessObject)
  }
  add(tickletClass) {
    console.log(`Adding ticklet definition ${tickletClass.name}`)

    Validate.isFunctionWithArity(tickletClass.define, 1, `Static function define(builder) not defined on ${tickletClass.name} or defined with wrong arity`)
    Validate.isFunctionWithArity(tickletClass.prototype.tick, 0, `Function tick() not defined on ${tickletClass.name} or defined with wrong arity`)

    const definitionBuilder = new TickletDefinitionBuilder()
    const res = tickletClass.define(definitionBuilder)

    Validate.isNull(res)

    const tickletDefinition = definitionBuilder.build(tickletClass.name)

    console.log(`Defined %c ticklet ${tickletDefinition.name()} %c %o`,
       'color: #00aa00; font-weight: bold',
       'color: #000000; font-weight: normal',
       tickletDefinition.toDebug())


    this.definitionsVal[tickletDefinition.name()] = tickletDefinition
  }
  build() {
    if (this._fromInstance) {
      Validate.valid(this._instances[this._fromInstance]!==undefined,
        `Cannot find source instance '${this._fromInstance}'`)

      const objFrom = this._instances[this._fromInstance].definition()

      Validate.valid(objFrom.hasOutput(this._fromOutput),
        `Cannot find output ${this._fromOutput}`)
    } else {
      Validate.valid(this._inputs.some(i=>i.name()===this._fromOutput),
        `Cannot find output ${this._fromOutput}`)
    }

    if (this._toInstance) {
      Validate.valid(this._instances[this._toInstance]!==undefined,
        `Cannot find target instance '${this._toInstance}'`)

      const objTo = this._instances[this._toInstance].definition()

      Validate.valid(objTo.hasInput(this._toInput), `Cannot find input ${this._toInput}`)
    } else {
      Validate.valid(this._outputs.some(o=>o.name()===this._toInput),
      `Cannot find input ${this._toInput}`)
    }

    return new ConnectionDefinition(Tools.generateUUID(), this._fromInstance, this._fromOutput,
      this._toInstance, this._toInput, this._probe)
  }
  constructor(businessObject) {
    Validate.notNull(businessObject)

    this._businessObject = businessObject
    this._businessObject.owner = this
    this._businessObject.addValidator(()=>{
      if (!this.name) {
        this._businessObject.addPropertyProblem('name', 'Name must not be blank')
      }
    })

    BusinessObject.definePropertyAccessors(this, this._businessObject, 'name')

    BusinessObject.defineRefsAccessors(this, this._businessObject, 'type')
    BusinessObject.defineRefsAccessors(this, this._businessObject, 'typeAssignment')
    BusinessObject.defineRefsAccessors(this, this._businessObject, 'componentUsage')
    BusinessObject.defineRefsAccessors(this, this._businessObject, 'connectionsLayer')
  }
Beispiel #13
0
  constructor(businessObject) {
    Validate.notNull(businessObject)

    this._businessObject = businessObject
    this._businessObject.owner = this
    this._businessObject.addValidator(()=>{
      if (!this.name) {
        this._businessObject.addPropertyProblem('name', 'Name must not be blank')
      }

      if (!['top', 'left', 'bottom', 'right'].includes(this.side)) {
        this._businessObject.addPropertyProblem('side', `Unknown side '${this.side}'`)
      }
    })

    BusinessObject.definePropertyAccessors(this, this._businessObject, 'name')
    BusinessObject.definePropertyAccessors(this, this._businessObject, 'side')
    BusinessObject.definePropertyAccessors(this, this._businessObject, 'sideRatio')

    BusinessObject.definePropertyAccessors(this, this._businessObject, 'definitionSide')

    BusinessObject.defineRefsAccessors(this, this._businessObject, 'interfaceDefinition')
  }
 probe(name) {
   Validate.notBlank(name)
   this._probe = name
 }
 toInput(name) {
   Validate.notBlank(name)
   this._toInput = name
 }
 toInstance(name) {
   Validate.notBlank(name)
   this._toInstance = name
 }
 fromOutput(name) {
   Validate.notBlank(name)
   this._fromOutput = name
 }
Beispiel #18
0
  addDepending(depending) {
    Validate.isA(depending, Input)

    this._depending.push(depending)
  }
  addAll(components) {
    Validate.isArray(components)

    const componentDependencies = this._extractDependencies(components)

    const doneComponents = []

    while (doneComponents.length<components.length) {
      const component = components.find(component=>
        !doneComponents.includes(component.func)
        &&
        componentDependencies[component.func].every(name=>this.isDefined(name))
      )

      if (component===undefined) {
        const deps = []

        components.forEach(component=>{
          if (!doneComponents.includes(component.func)) {
            componentDependencies[component.func].forEach(dep=>deps.push(dep))
          }
        })

        throw `Cyclic dependency? Missing dependencies are: ${[...new Set(deps)].join(', ')}`
      }

      doneComponents.push(component.func)

      Validate.isFunctionWithArity(component.func, 1)

      const componentBuilder = new ComponentDefinitionBuilder(this.tickletRepository, this, component.path, component.name)

      const res = component.func(componentBuilder)

      Validate.isNull(res)

      const componentDefinition = componentBuilder.build()

      console.log(`Defined %c component ${componentDefinition.name()} %c %o`,
        'color: #00aa00; font-weight: bold',
        'color: #000000; font-weight: normal',
        componentDefinition.toDebug())

      const [namespaceParts, name] = this.splitId(componentDefinition.id())

      let act = this._root

      namespaceParts.forEach(part=>{
        if (act._subs[part]===undefined) {
          act._subs[part] = {
            _subs: {}
          }
        }

        act = act._subs[part]
      })

      Validate.notSet(act, name)

      act[name] = componentDefinition
    }
  }
 probeName() {
   Validate.valid(this.hasProbe())
   return this._probe
 }
  get(tickletName) {
    Validate.isSet(this.definitionsVal, tickletName)

    return this.definitionsVal[tickletName]
  }