cleanup: удалены закомментированные фрагменты кода (104 блока в 14 файлах)
This commit is contained in:
@@ -1,28 +1,21 @@
|
||||
<cfcomponent extends="taffy.core.resource" taffy:uri="/instanceOperations/{instanceUid}/{svcOperationId}" hint="template for default instance operation. Legacy URL: /instanceOperations/default/{svcOperationId}">
|
||||
|
||||
<cfsilent>
|
||||
<cfimport prefix="m" taglib="../lib"/>
|
||||
<cfset this.helper=CreateObject("component","lib.rest_api_helper")/>
|
||||
</cfsilent>
|
||||
|
||||
|
||||
<cffunction name="get" hint="Шаблон операции экземпляра">
|
||||
<cfargument name="instanceUid" type="string" required=true hint="type:guid|'default'"/>
|
||||
<cfargument name="svcOperationId" type="string" required=true hint="type:integer"/>
|
||||
|
||||
<cftry>
|
||||
<cfif arguments.instanceUid NEQ 'default'>
|
||||
<cfset this.helper.validateField(arguments, "instanceUid", "guid")/>
|
||||
</cfif>
|
||||
<cfset this.helper.validateField(arguments, "svcOperationId", "integer")/>
|
||||
|
||||
<cfcatch type="invalidParamValue">
|
||||
<cfreturn representationOf(this.helper.formatBadRequestError(cfcatch)).withStatus(400)/>
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
|
||||
<cfset var local={}/>
|
||||
|
||||
<cfquery name="local.qSvcOperation" result="local.result">
|
||||
select
|
||||
<m:field_set titleMapOut="local.titleMap" lengthOut="local.fieldCount">
|
||||
@@ -36,11 +29,9 @@
|
||||
from svc_operation o
|
||||
where o.svc_operation_id=<cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.svcOperationId#" null=#!isValid('integer',arguments.svcOperationId)#/>
|
||||
</cfquery>
|
||||
|
||||
<cfif local.qSvcOperation.recordCount EQ 0>
|
||||
<cfreturn representationOf(this.helper.formatMessage("Not Found")).withStatus(404)/>
|
||||
</cfif>
|
||||
|
||||
<!--- получаем параметры из свежего стейта --->
|
||||
<cfset local.instanceDataParams = {}/>
|
||||
<cfset var currentState = {}/>
|
||||
@@ -62,13 +53,10 @@
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
</cfif>
|
||||
|
||||
|
||||
<cfquery name="local.qCfsParam" result="local.result">
|
||||
select
|
||||
<m:field_set titleMapOut="local.cfsParamMap" lengthOut="local.fieldCount">
|
||||
<m:field title="ID" cfSqlType="CF_SQL_INTEGER">p.svc_operation_cfs_param_id</m:field>
|
||||
<!--- <m:field cfSqlType="CF_SQL_INTEGER">p.svc_operation_id</m:field> --->
|
||||
<m:field>p.svc_operation_cfs_param</m:field>
|
||||
<m:field>p.label</m:field>
|
||||
<m:field>p.data_type</m:field>
|
||||
@@ -92,7 +80,6 @@
|
||||
<m:field>p.man</m:field>
|
||||
<m:field>p.sort</m:field>
|
||||
<m:field>p.nested_ref</m:field>
|
||||
<!--- <m:field>p.config::text as config</m:field> --->
|
||||
<m:field>p.config::text</m:field><!--- в таком виде конфиг доступен для кода, но не выводится в респонсе --->
|
||||
<m:field>null as nested_ref_data</m:field>
|
||||
<m:field>p.state_path</m:field>
|
||||
@@ -114,8 +101,6 @@
|
||||
AND p.is_actual
|
||||
order by p.sort, p.svc_operation_cfs_param_id
|
||||
</cfquery>
|
||||
|
||||
|
||||
<cfloop query="local.qCfsParam">
|
||||
<cfif len(local.qCfsParam.func)><!--- приоритет отдается функции перед списком значений--->
|
||||
<cfset var args = {
|
||||
@@ -124,7 +109,6 @@
|
||||
"contractId":#arguments.contractId#
|
||||
}/> <!--- если появятся новые аргументы у новых функций, будем добавлять их сюда --->
|
||||
<cfinvoke component="instance_operation_cfs_param" method="generateValueList" argumentCollection=#args# returnVariable="local.qCfsParam.value_list"/>
|
||||
|
||||
<cfif len(trim(local.qCfsParam.value_list)) AND listLen(local.qCfsParam.value_list) EQ 1>
|
||||
<cfset local.qCfsParam.default_value=local.qCfsParam.value_list/><!--- *** не очень красиво перетирать query, но делаем это довольно часто --->
|
||||
</cfif>
|
||||
@@ -147,12 +131,10 @@
|
||||
returnVariable="local.qCfsParam.value_list"
|
||||
/>
|
||||
</cfif>
|
||||
|
||||
<cfif (len(local.qCfsParam.func) OR len(local.qCfsParam.expression) OR len(local.qCfsParam.state_path) OR len(local.qCfsParam.nested_ref))
|
||||
AND len(local.qCfsParam.value_list) EQ 0>
|
||||
<cfset local.qCfsParam.value_list = []/>
|
||||
</cfif>
|
||||
|
||||
<cfif data_type EQ "map" OR data_type EQ "map-fixed" OR data_type EQ "array-map-fixed"><!--- *** частичное дублирование с instance_operation_cfs_param.processMap --->
|
||||
<!--- без полей инстанса, только шаблон --->
|
||||
<cfquery name="local.qSubparam">
|
||||
@@ -184,43 +166,31 @@
|
||||
where sp.svc_operation_cfs_param_id=<cfqueryparam cfsqltype="cf_sql_integer" value="#svc_operation_cfs_param_id#"/>
|
||||
order by sp.sort
|
||||
</cfquery>
|
||||
|
||||
|
||||
|
||||
<cfset var mapDescriptor=structNew("linked")/>
|
||||
<!--- *** выдавать на фронт expression нам ни к чему, это временное явление --->
|
||||
<cfloop query="local.qSubparam">
|
||||
|
||||
<cfif len(local.qSubparam.func)><!--- приоритет отдается функции перед списком значений--->
|
||||
<cfset var args = {
|
||||
"functionName":"#local.qSubparam.func#",
|
||||
"svcId":#local.qSvcOperation.svc_id#,
|
||||
"contractId":#arguments.contractId#
|
||||
}/>
|
||||
|
||||
<cfinvoke component="instance_operation_cfs_param" method="generateValueList" argumentCollection=#args# returnVariable="local.qSubparam.value_list"/>
|
||||
|
||||
<cfif len(trim(local.qSubparam.value_list)) AND listLen(local.qSubparam.value_list) EQ 1>
|
||||
<cfset local.qSubparam.default_value=local.qSubparam.value_list/><!--- *** не очень красиво перетирать query, но делаем это довольно часто --->
|
||||
</cfif>
|
||||
</cfif>
|
||||
|
||||
<cfif (len(local.qSubparam.func) OR len(local.qSubparam.expression) )
|
||||
AND len(local.qSubparam.value_list) EQ 0>
|
||||
<cfset local.qSubparam.value_list = []/>
|
||||
</cfif>
|
||||
|
||||
<cfset var def = computeDefault(local.qSubparam.default_compute, local.qSubparam.default_value, qSvcOperation.svc_id, arguments.usrId)/>
|
||||
<!--- *** пока не пытаемся восстановить значения из стейта
|
||||
<cfif len(local.qSubparam.default_value) EQ 0>
|
||||
<!--- и вот наконец мы извлекаем старое значение из стейта --->
|
||||
<cfset var paramName = this.helper.snake2camel(local.qSubparam.svc_operation_cfs_subparam)/>
|
||||
<cfif structKeyExists(local.instanceDataParams, paramName)>
|
||||
<cfset var oldValue = structFind(local.instanceDataParams, paramName)/>
|
||||
<cfset def = isStruct(oldValue) ? serializeJson(oldValue) : oldValue/> <!--- потому что передаем строку, а не объект --->
|
||||
</cfif>
|
||||
</cfif> --->
|
||||
|
||||
<cfset structInsert(mapDescriptor, local.qSubparam.svc_operation_cfs_subparam,
|
||||
{
|
||||
"svcOperationCfsSubparamId":"#local.qSubparam.svc_operation_cfs_subparam_id#",
|
||||
@@ -248,27 +218,17 @@
|
||||
}, true
|
||||
)
|
||||
/><!--- *** вообще-то передавать в дескриптор func и default_compute не нужно, это для не забыть --->
|
||||
|
||||
</cfloop>
|
||||
|
||||
<cfset local.qCfsParam.data_descriptor = mapDescriptor/>
|
||||
</cfif><!---/map --->
|
||||
|
||||
</cfloop>
|
||||
|
||||
<!--- <cfdump var=#local.qCfsParam# abort=true/> --->
|
||||
<!--- <cfset queryDeleteColumn(local.qCfsParam, "func")/> --->
|
||||
|
||||
<cfset var out=structNew("linked")/>
|
||||
<cfset "out.queryDurationMs"=getTickCount() - request.startTickCount/>
|
||||
|
||||
<cfset "out.svcOperation" = this.helper.appendRecord(
|
||||
structNew("linked"), "", local.titleMap, local.qSvcOperation, this.helper.snake2camel
|
||||
)/>
|
||||
|
||||
<cfset "out.svcOperation.cfsParams"=[]/>
|
||||
<!--- подставляем значение из стейта, если оно там есть (некорректно, потому что в стейте RFS параметры) --->
|
||||
|
||||
<cfloop query=#local.qCfsParam#>
|
||||
<cfset local.qCfsParam.default_value = computeDefault(local.qCfsParam.default_compute, local.qCfsParam.default_value, qSvcOperation.svc_id, arguments.usrId)/><!--- *** не очень хорошо модифицировать запрос --->
|
||||
<cfif len(local.qCfsParam.default_value) EQ 0>
|
||||
@@ -280,16 +240,11 @@
|
||||
</cfif>
|
||||
</cfif>
|
||||
<cfset var rec = this.helper.appendRecord(structNew("linked"), "", local.cfsParamMap, local.qCfsParam, this.helper.snake2camel)/>
|
||||
<!--- <cfdump var=#rec# abort=true/> --->
|
||||
|
||||
<cfset arrayAppend(out.svcOperation.cfsParams, rec)/>
|
||||
</cfloop>
|
||||
|
||||
<cfset "out.runDurationMs"=getTickCount() - request.startTickCount/>
|
||||
<cfreturn representationOf(out) />
|
||||
|
||||
</cffunction>
|
||||
|
||||
<!--- *** выглядит ужасно, но красивый вариант не придумывается ряд месяцев --->
|
||||
<!--- *** Внимание! нужно учитывать скоуп уникальности --->
|
||||
<cffunction name="computeDefault">
|
||||
@@ -297,7 +252,6 @@
|
||||
<cfargument name="original"/>
|
||||
<cfargument name="service_id" type="numeric"/>
|
||||
<cfargument name="usr_id" type="numeric"/>
|
||||
|
||||
<cfswitch expression=#arguments.defaultCompute#>
|
||||
<cfcase value="display_name">
|
||||
<cfset var dnGenerator = CreateObject("component", "instance_ls")/>
|
||||
@@ -316,7 +270,5 @@
|
||||
<cfreturn #arguments.original#/>
|
||||
</cfdefaultcase>
|
||||
</cfswitch>
|
||||
|
||||
</cffunction>
|
||||
|
||||
</cfcomponent>
|
||||
|
||||
Reference in New Issue
Block a user