73 lines
3.2 KiB
Plaintext
73 lines
3.2 KiB
Plaintext
<cfcomponent extends="taffy.core.resource" taffy:uri="/svcOperationCfsSubparams/compute/{svcOperationCfsSubparamId}" hint="вычисляет выражение в поле expression">
|
|
|
|
<cfsilent>
|
|
<cfimport prefix="m" taglib="../lib"/>
|
|
<cfset this.helper=CreateObject("component","lib.rest_api_helper")/>
|
|
</cfsilent>
|
|
|
|
|
|
<cffunction name="get" hint="вычисление возможных значений cубпараметра CFS параметра операции, в текущем контексте">
|
|
<cfargument name="svcOperationCfsSubparamId" 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 posted parameters we depend on"/>
|
|
|
|
<cftry>
|
|
<cfset this.helper.validateField(arguments, "svcOperationCfsSubparamId", "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.params" = deserializeJson(arguments.params)/>
|
|
|
|
<cfset "local.keys.svcOperationCfsSubparamId" = arguments.svcOperationCfsSubparamId/>
|
|
|
|
<cfquery name="local.qCfsSubparam" result="local.result">
|
|
select
|
|
<m:field_set titleMapOut="local.titleMap" lengthOut="fieldCount">
|
|
<m:field>sop.svc_operation_cfs_param_id</m:field>
|
|
<m:field>sop.data_type</m:field>
|
|
<m:field>sop.svc_operation_cfs_subparam</m:field>
|
|
<m:field>sop.expression</m:field>
|
|
</m:field_set>
|
|
from svc_operation_cfs_subparam sop
|
|
where sop.svc_operation_cfs_subparam_id
|
|
= <cfqueryparam cfsqltype="cf_sql_integer" value=#arguments.svcOperationCfsSubparamId# null=#!isValid('integer',arguments.svcOperationCfsSubparamId)#/>
|
|
</cfquery>
|
|
|
|
<cfif local.qCfsSubparam.recordCount EQ 0>
|
|
<cfreturn representationOf(this.helper.formatMessage("Service Operation CFS Parameter Not Found")).withStatus(404)/>
|
|
</cfif>
|
|
|
|
<cfset "local.expression"=local.qCfsSubparam.expression/>
|
|
<cfset "local.keys.svcOperationCfsParamId" = local.qCfsSubparam.svc_operation_cfs_param_id/>
|
|
|
|
<cfif len(local.expression)>
|
|
<cfset local.calculatedValueList=createObject("component","lib.expression_parser")
|
|
.eval(
|
|
local.expression,
|
|
{
|
|
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>
|