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`) })
/** * 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) }
/** * 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 } }
/** * 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') }
/** * Set handler. * * @param key * @param handler */ registerHandler(key, handler) { this._registry.set('handlers', key, handler) }
/** * Set value. * * @param value */ setDefaultValue(value) { this._registry.set('properties', 'defaultValue', value) }
/** * Construct field type * * @param params */ constructor(variables = {}) { this._registry = new DomainMap() this._registry.set('properties', 'fieldTypeId', variables.fieldTypeId) }
/** * Set field type item. * * @param fieldType */ setFieldTypeInstance(fieldType) { this._registry.set('values', 'fieldType', fieldType) }
/** * Set field description * * @param value */ setDescription(value) { this._registry.set('properties', 'description', value) return this }
/** * Set field name. * * @param value */ setName(value) { this._registry.set('properties', 'fieldName', value) return this }
/** * Set field property value. * * @param property key * @param value */ setProperty(propertyKey, value) { this._registry.set('field_property', propertyKey, value) return this }