services.map((serviceConfig) => {
      // Allow custom handlers
      let handler = serviceConfig.hasOwnProperty('handler') ?
        new serviceConfig.handler(serviceConfig, this) :
        new ServiceHandler(serviceConfig, this)

      this._registry.set('services', serviceConfig.serviceName, handler)
      this.log(`Service '${serviceConfig.serviceName}' registered`)
    })
Beispiel #2
0
 /**
 * Construct entity type
 *
 * @param params
 */
 constructor(variables = {}) {
   this._registry = new DomainMap()
   this._registry.set('properties', 'entityTypeId', variables.entityTypeId)
   // Register handlers
   if (variables.hasOwnProperty('handlers')) {
     Object.keys(variables.handlers).forEach((handlerName, _index) => {
       this.registerHandler(handlerName, variables.handlers[handlerName])
     })
   }
 }
  /**
  * Construct services.
  *
  * TODO: Provide methods to register new resources on the fly...
  *
  * @param configuration
  */
  constructor(configuration = {}) {
    this._registry = new DomainMap()

    let debug = configuration.hasOwnProperty('debug') ?
      configuration.debug : false

    this._registry.set('properties', 'debug', debug)

    this.loadServices(configuration)
  }
Beispiel #4
0
 /**
 * Set value. Value must be valid for instance type.
 *
 * @param value
 * @return boolean succeed
 */
 setValue(value) {
   // Prepare field value
   value = this.prepareFieldValue(value)
   if (this.validateFieldValue(value)) {
     this._registry.set('properties', 'value', value)
     return true
   } else {
     system.log('FieldType', `Unable to set value, validation failed: ${value}`, 'error')
     return false
   }
 }
Beispiel #5
0
  /**
  * Construct field
  *
  * @param variables
  *   Every field construction requires field_name and field_type
  */
  constructor(variables = {}) {
    this._registry = new DomainMap()

    if (variables.hasOwnProperty('fieldId')) {
      this._registry.set('properties', 'fieldId', variables.fieldId)
    }

    // Apply field item
    if (variables.hasOwnProperty('fieldType')) {
      this.setFieldTypeInstance(variables.fieldType)
    }
    //  else
    //    throw new Error('Field generation requires fielItem attribute')
  }
Beispiel #6
0
 /**
 * Set handler.
 *
 * @param key
 * @param handler
 */
 registerHandler(key, handler) {
   this._registry.set('handlers', key, handler)
 }
Beispiel #7
0
 /**
 * Set value.
 *
 * @param value
 */
 setDefaultValue(value) {
   this._registry.set('properties', 'defaultValue', value)
 }
Beispiel #8
0
 /**
 * Construct field type
 *
 * @param params
 */
 constructor(variables = {}) {
   this._registry = new DomainMap()
   this._registry.set('properties', 'fieldTypeId', variables.fieldTypeId)
 }
Beispiel #9
0
 /**
 * Set field type item.
 *
 * @param fieldType
 */
 setFieldTypeInstance(fieldType) {
   this._registry.set('values', 'fieldType', fieldType)
 }
Beispiel #10
0
 /**
 * Set field description
 *
 * @param value
 */
 setDescription(value) {
   this._registry.set('properties', 'description', value)
   return this
 }
Beispiel #11
0
 /**
 * Set field name.
 *
 * @param value
 */
 setName(value) {
   this._registry.set('properties', 'fieldName', value)
   return this
 }
Beispiel #12
0
 /**
 * Set field property value.
 *
 * @param property key
 * @param value
 */
 setProperty(propertyKey, value) {
   this._registry.set('field_property', propertyKey, value)
   return this
 }