73 lines
3.3 KiB
Plaintext
73 lines
3.3 KiB
Plaintext
<cfcomponent extends="taffy.core.resource" taffy:uri="/svcOperationCfsParams/compute/{svcOperationCfsParamId}" hint="вычисляет выражение в поле expression">
|
|
<cfsilent>
|
|
<cfimport prefix="m" taglib="../lib"/>
|
|
<cfset this.helper=CreateObject("component","lib.rest_api_helper")/>
|
|
</cfsilent>
|
|
|
|
|
|
<cffunction name="get" hint="вычисление возможных значений CFS параметра операции инстанса, в текущем контексте. Рекомендуется передавать keys.svcOperationCfsParamId для декларации класса параметра (а не keys.instanceOperationCfsParamUid) - он неизвестен для вновь создаваемых параметров">
|
|
<cfargument name="svcOperationCfsParamId" type="string" required=true hint="type:integer"/>
|
|
<cfargument name="keys" type="string" default={} hint="type:json keys we depend on: of the param uid itself, or operation uid, instance uid, service operation cfs param - if not all entities intstantiated yet"/>
|
|
<cfargument name="params" type="string" default="{}" hint="type:json any parameters we depend on"/>
|
|
|
|
|
|
<cftry>
|
|
<cfset this.helper.validateField(arguments, "svcOperationCfsParamId", "integer")/>
|
|
<cfset this.helper.validateField(arguments, "keys", "json")/>
|
|
<cfset this.helper.validateField(arguments, "params", "json")/>
|
|
<cfcatch type="invalidParamValue">
|
|
<cfreturn representationOf(this.helper.formatBadRequestError(cfcatch)).withStatus(400)/>
|
|
</cfcatch>
|
|
</cftry>
|
|
|
|
<cfset local={}/>
|
|
<cfset local.expression = ""/>
|
|
<cfset local.calculatedValueList = ""/>
|
|
<cfset local.keys = deserializeJson(arguments.keys)/>
|
|
<cfset local.keys.svcOperationCfsParamId=arguments.svcOperationCfsParamId/>
|
|
<cfset local.params = deserializeJson(arguments.params)/>
|
|
|
|
<cfquery name="local.qCfsParam" result="local.result">
|
|
select
|
|
<m:field_set titleMapOut="local.titleMap" lengthOut="fieldCount">
|
|
<m:field>sop.data_type</m:field>
|
|
<m:field>sop.svc_operation_cfs_param</m:field>
|
|
<m:field>sop.expression</m:field>
|
|
</m:field_set>
|
|
from svc_operation_cfs_param sop
|
|
where sop.svc_operation_cfs_param_id
|
|
= <cfqueryparam cfsqltype="cf_sql_integer" value=#arguments.svcOperationCfsParamId# null=#!isValid('integer',arguments.svcOperationCfsParamId)#/>
|
|
</cfquery>
|
|
|
|
<cfif local.qCfsParam.recordCount EQ 0>
|
|
<cfreturn representationOf(this.helper.formatMessage("Service Operation CFS Parameter Not Found")).withStatus(404)/>
|
|
</cfif>
|
|
|
|
<cfset local.expression=local.qCfsParam.expression/>
|
|
|
|
<cfif len(local.expression)>
|
|
<cfset calculatedValueList=createObject("component","lib.expression_parser")
|
|
.eval(
|
|
local.expression,
|
|
{/*context*/
|
|
component:"resources.instance_operation_cfs_param",
|
|
keys:#local.keys#,
|
|
params:#local.params#
|
|
}
|
|
)
|
|
/>
|
|
<cfelse>
|
|
<cfreturn representationOf(this.helper.formatMessage("Expression Not Found")).withStatus(404)/>
|
|
</cfif>
|
|
|
|
<cfset var out=structNew("linked")/>
|
|
<cfset "out.queryDurationMs"=getTickCount() - request.startTickCount/>
|
|
<cfset "out.values" = listToArray(local.calculatedValueList)/>
|
|
<cfset "out.runDurationMs"=getTickCount() - request.startTickCount/>
|
|
<cfreturn representationOf(out) />
|
|
</cffunction>
|
|
|
|
|
|
|
|
</cfcomponent>
|