cleanup: удалены закомментированные фрагменты кода (104 блока в 14 файлах)
This commit is contained in:
@@ -4,25 +4,21 @@
|
||||
Но: мы не хотели бы менять положение сущности в дереве. Либо она в корне, либо она ниже. И получится, когда мы выбираем один параметр, нам ни к чему контекст - мы к нему однозначно адресуемся.
|
||||
Проголосуем против избыточности?
|
||||
--->
|
||||
|
||||
<!--- Все методы неявно получают
|
||||
arguments.usrId
|
||||
arguments.contragentId
|
||||
arguments.contractId
|
||||
arguments.specificationId
|
||||
|
||||
arguments.requestArguments.usrId=usrCustomerInfo.usrId; //Integer!
|
||||
arguments.requestArguments.contragentId=usrCustomerInfo.contragentId; //Integer
|
||||
arguments.requestArguments.contractId=usrCustomerInfo.contractId; //Integer
|
||||
arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //Integer
|
||||
--->
|
||||
|
||||
<cfsilent>
|
||||
<cfimport prefix="m" taglib="../lib"/>
|
||||
<cfset this.helper=CreateObject("component","lib.rest_api_helper")/><!---*** странно, почему мы его видим?---><!---вынести в апп?--->
|
||||
</cfsilent>
|
||||
<!--- cfproperty использовать не надо, это для веб сервисов --->
|
||||
|
||||
<cffunction name="init">
|
||||
<!--- *** ---------------- !!! note camelCase in keys naming!!! ----------------- --->
|
||||
<!--- для нового инстанса нам нужно знать хотя бы его класс (сервис) --->
|
||||
@@ -34,7 +30,6 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
<cfset this.instance_operation_cfs_param_uid = "00000000-0000-0000-0000-000000000000"/><!--- *** костыль default=--->
|
||||
<cfset this.instance_operation_uid = "00000000-0000-0000-0000-000000000000"/><!--- *** костыль default=--->
|
||||
<cfset this.instance_uid = "00000000-0000-0000-0000-000000000000"/><!--- *** костыль default=--->
|
||||
|
||||
<cfif structKeyExists(arguments.keys,"instanceOperationCfsParamUid") AND isValid("guid", arguments.keys.instanceOperationCfsParamUid)>
|
||||
<cfset this.instance_operation_cfs_param_uid=arguments.keys.instanceOperationCfsParamUid/>
|
||||
<cfquery name="local.qResolve">
|
||||
@@ -66,20 +61,15 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
<cfif structKeyExists(arguments.params,"resourceRealm")>
|
||||
<cfset this.resourceRealm=arguments.params.resourceRealm/>
|
||||
</cfif>
|
||||
<!--- <cfdump var=#this# abort=true/> --->
|
||||
<!--- <cfdump var=#this#/> --->
|
||||
<cfreturn this>
|
||||
</cffunction>
|
||||
|
||||
<!--- ---------------------------------------------------------------------- --->
|
||||
<!--- Прикладные функции, которые можно использовать в составе выражений. Аргументами им могут служить параметры, от которых мы зависим --->
|
||||
<!--- Добавить обработку исключений --->
|
||||
|
||||
<cffunction name="dummy" returntype="any" access="public">
|
||||
<cfargument name="arg" type="any"/>
|
||||
<cfreturn arg/>
|
||||
</cffunction>
|
||||
|
||||
<cffunction name="concat" returntype="string" access="public">
|
||||
<cfset var local={}/>
|
||||
<cfset var s=""/>
|
||||
@@ -88,7 +78,6 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
</cfloop>
|
||||
<cfreturn s/>
|
||||
</cffunction>
|
||||
|
||||
<cffunction name="getValue"><!--- используем пока только для параметров, в принципе может видеть больше, чем положено --->
|
||||
<cfargument name="token" type="string"/>
|
||||
<!--- тут такой странный синтаксис: для скоупа params подставляем getCfsParam --->
|
||||
@@ -103,7 +92,6 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
</cfif>
|
||||
<cfreturn variables[scope][name]/><!--- *** вряд ли это отработает для субпараметров --->
|
||||
</cffunction>
|
||||
|
||||
<!--- может быть, обобщить для наследуемых параметров... или для всех вообще --->
|
||||
<cffunction name="getResourceRealm">
|
||||
<!--- нужна отдельная функция, потому что resourceRealm может браться из параметров операции, а может наследоваться от родительского инстанса --->
|
||||
@@ -111,11 +99,10 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
<!--- если операция не сохранена - мы как узнаем, есть у нее параметр resourceRealm, или нет? наверно, простой джойн тут не поможет
|
||||
но никто не мешает спросить отдельно--->
|
||||
<!--- *** тут возникает определенная путаница из-за того, что часть данных берется из параметров операции, а часть из параметров инстанса (кумулятивных) --->
|
||||
<!--- <cfdump var=#this#/> --->
|
||||
<cfif structKeyExists(this,"resourceRealm") AND len(this.resourceRealm)><!--- может быть, понятнее было бы брать прямо из параметров --->
|
||||
<cfreturn this.resourceRealm/>
|
||||
</cfif>
|
||||
<!--- ищем у даннной операции CFS параметр resourceRealm ---><!--- <cfdump var=#this#/><cfabort/> --->
|
||||
<!--- ищем у даннной операции CFS параметр resourceRealm --->
|
||||
<cfquery name="local.qCfsParam">
|
||||
select p.param_value
|
||||
from svc_operation_cfs_param s
|
||||
@@ -123,7 +110,6 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
where s.svc_operation_cfs_param = 'resourceRealm'
|
||||
AND p.instance_operation_uid = <cfqueryparam cfsqltype="cf_sql_other" value=#this.instance_operation_uid# null=#!isValid('guid',this.instance_operation_uid)#/>
|
||||
</cfquery>
|
||||
<!--- <cfdump var=#local.qCfsParam#/> --->
|
||||
<!--- --->
|
||||
<cfif local.qCfsParam.recordCount>
|
||||
<!--- параметр определен в операции сервиса. Если его не нашли - значит, не судьба --->
|
||||
@@ -136,7 +122,6 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
и инстанс-операцию-параметр (регулярная реляционная иерархия)
|
||||
хотя инстанс и операция есть в параметрах (некоторое дублирование, потому что оркестратору все передается через параметры)
|
||||
--->
|
||||
|
||||
<cfset local.instance_uid = this.instance_uid/>
|
||||
<cfif !isValid("guid", local.instance_uid) OR local.instance_uid EQ "00000000-0000-0000-0000-000000000000">
|
||||
<!--- тогда нам нужно найти параметр-референс и взять его значение --->
|
||||
@@ -149,7 +134,6 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
where p.svc_operation_cfs_param_id = <cfqueryparam cfsqltype="cf_sql_integer" value=#this.svc_operation_cfs_param_id# null=#!isValid('integer',this.svc_operation_cfs_param_id)#/>
|
||||
AND r.ref_svc_id > 0
|
||||
</cfquery>
|
||||
<!--- <cfdump var=#local.qRefParam#/> --->
|
||||
<cfloop query="local.qRefParam">
|
||||
<cfif structKeyExists(this.params, local.qRefParam.svc_operation_cfs_param) AND isValid('guid', this.params[local.qRefParam.svc_operation_cfs_param])>
|
||||
<cfset local.instance_uid = this.params[local.qRefParam.svc_operation_cfs_param]/>
|
||||
@@ -163,7 +147,6 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
Можно сделать дополнительную фильтрацию по типу справочника (resourceRealm)
|
||||
--->
|
||||
</cfif>
|
||||
|
||||
<!--- внимание! мы тут опрашиваем параметры инстанса, а не операции! --->
|
||||
<!--- *** тут возникает непонятная ссылка на себя, впрочем, она не мешает --->
|
||||
<cfquery name="local.qCfsParam">
|
||||
@@ -183,9 +166,7 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
LEFT JOIN instance_cfs_param rp on (e.instance_uid=rp.instance_uid )
|
||||
LEFT JOIN instance ri on (rp.instance_uid=ri.instance_uid)
|
||||
WHERE e.instance_uid=<cfqueryparam cfsqltype="cf_sql_other" value=#local.instance_uid# null=#!isValid('guid',local.instance_uid)#/>
|
||||
|
||||
UNION
|
||||
|
||||
SELECT
|
||||
i+1 AS i
|
||||
,e.display_name
|
||||
@@ -202,7 +183,6 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
select param, param_value from r
|
||||
order by r.i desc
|
||||
</cfquery>
|
||||
|
||||
<cfif local.qCfsParam.recordCount EQ 0>
|
||||
<!--- тогда зайдем от параметров операции (только в данном экземпляре, зависимости все должны быть уже созданы) --->
|
||||
<cfquery name="local.qCfsParam">
|
||||
@@ -223,9 +203,7 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
--LEFT JOIN instance_cfs_param rp on (e.instance_uid=rp.instance_uid )
|
||||
--LEFT JOIN instance ri on (rp.instance_uid=ri.instance_uid)
|
||||
WHERE e.instance_uid=<cfqueryparam cfsqltype="cf_sql_other" value=#local.instance_uid# null=#!isValid('guid',local.instance_uid)#/>
|
||||
|
||||
UNION
|
||||
|
||||
SELECT
|
||||
i+1 AS i
|
||||
,e.display_name
|
||||
@@ -243,17 +221,14 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
order by r.i desc
|
||||
</cfquery>
|
||||
</cfif>
|
||||
<!--- <cfdump var=#local.qCfsParam#/>--->
|
||||
<cfloop query="local.qCfsParam">
|
||||
<cfif local.qCfsParam.param EQ "resourceRealm">
|
||||
<cfreturn local.qCfsParam.param_value/>
|
||||
</cfif>
|
||||
</cfloop>
|
||||
<cfreturn "Resource Realm Not Found"/>
|
||||
|
||||
</cfif>
|
||||
</cffunction>
|
||||
|
||||
<cffunction name="getCfsParam">
|
||||
<cfargument name="param" type="string"/>
|
||||
<cfargument name="subparam" type="string" required=false/>
|
||||
@@ -264,12 +239,10 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
при этом мы ожидаем в параметрах структуру paramName:{subparamName:subparamValue}
|
||||
но почему не находим в сохраненных? возможно такое совпадение, что в сценарии у нас как раз надо выбрать svcId а они не --->
|
||||
<!--- {"startupConfiguration":{"vdcUid":"ea81db31-2197-407d-b32b-e60577c2671c"}} --->
|
||||
<!--- this.params <cfdump var=#this.params#/>
|
||||
arguments <cfdump var=#arguments# /> --->
|
||||
<cfif structKeyExists(this.params,arguments.param)><!--- AND len(this.params[arguments.param]) --->
|
||||
<cfif structKeyExists(arguments,"subparam")><!--- *** не изящно, но просто и понятно --->
|
||||
<cfreturn (this.params[arguments.param])[arguments.subparam]/>
|
||||
<cfelse>this.params[arguments.param] <!--- <cfdump var=#this.params[arguments.param]#/> --->
|
||||
<cfelse>this.params[arguments.param]
|
||||
<cfreturn this.params[arguments.param]/>
|
||||
</cfif>
|
||||
</cfif>
|
||||
@@ -281,7 +254,6 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
where p.instance_operation_uid = <cfqueryparam cfsqltype="cf_sql_other" value=#this.instance_operation_uid# null=#!isValid('guid',this.instance_operation_uid)#/>
|
||||
AND s.svc_operation_cfs_param = <cfqueryparam cfsqltype="cf_sql_varchar" value=#arguments.param#/>
|
||||
</cfquery>
|
||||
<!--- <cfdump var=#this.keys#/> --->
|
||||
<cfif structKeyExists(arguments,"subparam")><!--- *** не изящно, но просто и понятно --->
|
||||
<cfset var value = deserializeJson(local.qCfsParam.param_value)/>
|
||||
<cfif isStruct(value) AND structKeyExists(value, arguments.subparam)>
|
||||
@@ -293,24 +265,13 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
<cfreturn local.qCfsParam.param_value/>
|
||||
</cfif>
|
||||
</cffunction>
|
||||
|
||||
<!--- <cffunction name="getValueFromStruct" returntype="string" hint="returns scalar">
|
||||
<cfargument name="struct" type="struct" required="true"/>
|
||||
<cfargument name="path" type="string" required="true"/>
|
||||
|
||||
<cftry>
|
||||
<cfreturn structGet("arguments.struct.#arguments.path#")/>
|
||||
<cfcatch type="any">
|
||||
<!--- можно ожидать ошибки, если по указанному пути расположена не структура --->
|
||||
<cfreturn cfcatch.message/><!--- халява, для упрощения диагностики --->
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
</cffunction> --->
|
||||
|
||||
<cffunction name="getValueFromStruct" returntype="any">
|
||||
<cfargument name="struct" type="struct" required="true"/>
|
||||
<cfargument name="path" type="string" required="true"/>
|
||||
|
||||
<cftry>
|
||||
<cfreturn structGet("arguments.struct.#arguments.path#")/>
|
||||
<cfcatch type="any">
|
||||
@@ -319,24 +280,18 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
</cffunction>
|
||||
|
||||
|
||||
<cffunction name="getStringFromStruct" returntype="string" hint="returns scalar">
|
||||
<cfargument name="struct" type="struct" required="true"/>
|
||||
<cfargument name="path" type="string" required="true"/>
|
||||
|
||||
<cfset var value = getValueFromStruct(arguments.struct,arguments.path)/>
|
||||
<cfif isStruct(value) OR isArray(value)>
|
||||
<cfreturn serializeJson(value)/>
|
||||
</cfif>
|
||||
<cfreturn toString(value)/>
|
||||
</cffunction>
|
||||
|
||||
|
||||
<cffunction name="getKeyListFromStruct" returntype="string" hint="returns list">
|
||||
<cfargument name="struct" type="struct" required="true"/>
|
||||
<cfargument name="path" type="string" required="true"/>
|
||||
|
||||
<cftry>
|
||||
<cfreturn structKeyList(structGet("arguments.struct.#arguments.path#"))/>
|
||||
<cfcatch type="any">
|
||||
@@ -346,12 +301,9 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
</cffunction>
|
||||
|
||||
|
||||
<cffunction name="getArrayAsListFromStruct" returntype="string" hint="returns list">
|
||||
<cfargument name="struct" type="struct" required="true"/>
|
||||
<cfargument name="path" type="string" required="true"/>
|
||||
|
||||
<cftry>
|
||||
<cfreturn arrayToList(structGet("arguments.struct.#arguments.path#"))/>
|
||||
<cfcatch type="any">
|
||||
@@ -361,39 +313,11 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
</cffunction>
|
||||
|
||||
|
||||
<!--- <cffunction name="getInstanceState" returntype="struct">
|
||||
<cfargument name="instanceUid" type="guid" required="true"/>
|
||||
|
||||
<cfset var local={}/>
|
||||
<cfquery name="local.qInstance" datasource="cmdb">
|
||||
select g.instance_state_uid, g.version, g.dt_state, g.instance_data, g.is_test, g.instance_uid
|
||||
from instance_state g
|
||||
where g.instance_uid=<cfqueryparam cfsqltype="cf_sql_other" value=#arguments.instanceUid#/>
|
||||
order by g.version desc
|
||||
limit 1
|
||||
</cfquery>
|
||||
<cfreturn deserializeJson(local.qInstance.instance_data)/>
|
||||
<cftry>
|
||||
<cfset var structConfig = deserializeJson(local.qInstance.instance_data)/>
|
||||
<cfcatch type="ANY">
|
||||
<cfreturn {"error":"error parsing state"}/>
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
<cfif len(structConfig)>
|
||||
<cfreturn structConfig/>
|
||||
</cfif>
|
||||
<cfreturn {}/>
|
||||
</cffunction> --->
|
||||
|
||||
<cffunction name="getInstanceState" returntype="struct">
|
||||
<cfargument name="instanceUid" default=#this.instance_uid#/><!--- type="guid" --->
|
||||
|
||||
<cfif !isValid("guid",arguments.instanceUid)>
|
||||
<cfreturn {}/><!--- иначе при неопределенном параметре мы получаем исключение --->
|
||||
</cfif>
|
||||
|
||||
<cfset var local={}/>
|
||||
<cfquery name="local.qInstance" datasource="cmdb">
|
||||
select g.instance_state_uid, g.version, g.dt_state, g.instance_data, g.is_test, g.instance_uid
|
||||
@@ -402,7 +326,6 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
order by g.version desc
|
||||
limit 1
|
||||
</cfquery>
|
||||
<!--- <cfreturn deserializeJson(local.qInstance.instance_data)/><cfabort/> --->
|
||||
<cftry>
|
||||
<cfset var structConfig = deserializeJson(local.qInstance.instance_data)/>
|
||||
<cfcatch type="ANY">
|
||||
@@ -414,19 +337,14 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
</cfif>
|
||||
<cfreturn structConfig/>
|
||||
</cffunction>
|
||||
|
||||
|
||||
<cffunction name="getResourceRealmConfig" returntype="struct">
|
||||
<cfargument name="resourceRealm" type="string" default=#getResourceRealm()#/><!--- платформа может быть определена для родительского инстанса где то в иерархии --->
|
||||
|
||||
<cfset var local={}/>
|
||||
<cfquery name="local.qResourceRealm" datasource="cmdb">
|
||||
select r.resource_realm_id, r.properties
|
||||
from resource_realm r
|
||||
where r.resource_realm=<cfqueryparam cfsqltype="cf_sql_varchar" value=#arguments.resourceRealm#/>
|
||||
</cfquery>
|
||||
<!--- <cfdump var=#arguments#/>
|
||||
<cfdump var=#local.qResourceRealm#/> --->
|
||||
<cftry>
|
||||
<cfset var structConfig = deserializeJson(local.qResourceRealm.properties)/>
|
||||
<cfcatch type="ANY">
|
||||
@@ -439,17 +357,10 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
</cfif>
|
||||
<cfreturn {}/>
|
||||
</cffunction>
|
||||
|
||||
|
||||
|
||||
|
||||
<!--- ReST methods --->
|
||||
|
||||
<!--- ----------------------------------------------------------------------------------------- --->
|
||||
<!--- ----------------------------------------------------------------------------------------- --->
|
||||
<!--- ----------------------------------------------------------------------------------------- --->
|
||||
|
||||
|
||||
<cffunction name="get" hint="CFS параметр операции инстанса">
|
||||
<cfargument name="instanceOperationCfsParamUid" type="string" required=true hint="type:guid"/>
|
||||
<cftry>
|
||||
@@ -458,16 +369,13 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
<cfreturn representationOf(this.helper.formatBadRequestError(cfcatch)).withStatus(400)/>
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
|
||||
<cfset local={}/>
|
||||
|
||||
<cfquery name="local.qCfsParam" result="local.result">
|
||||
select
|
||||
<m:field_set titleMapOut="local.titleMap" lengthOut="fieldCount">
|
||||
<m:field>iop.instance_operation_cfs_param_uid::text as instance_operation_cfs_param_uid</m:field>
|
||||
<m:field>iop.instance_operation_uid::text as instance_operation_uid</m:field>
|
||||
<m:field>iop.svc_operation_cfs_param_id</m:field>
|
||||
<!--- <m:field>iop.param_value</m:field> --->
|
||||
<m:field>case when sop.is_sensitive then '********' else iop.param_value end as param_value </m:field><!--- внимание! если параметр типа MAP, то значение нужно разобрать и замаскировать секреты --->
|
||||
<m:field>iop.note</m:field>
|
||||
<m:field>to_char(iop.dt_created, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_created</m:field>
|
||||
@@ -482,14 +390,11 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
<m:field formatter=#request.castToBool#>sop.is_hidden</m:field>
|
||||
<m:field formatter=#request.castToBool#>sop.is_disabled</m:field>
|
||||
<m:field>sop.man</m:field>
|
||||
|
||||
<m:field>sop.func</m:field>
|
||||
<m:field>sop.expression</m:field>
|
||||
<m:field>sop.nested_ref</m:field>
|
||||
<m:field>sop.state_path</m:field>
|
||||
<m:field>sop.depends_on_cfs_params</m:field>
|
||||
|
||||
|
||||
<m:field>sop.config::text as config</m:field>
|
||||
<m:field>e.service_id</m:field>
|
||||
<m:field>e.instance_uid::text as instance_uid</m:field>
|
||||
@@ -503,11 +408,9 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
where iop.instance_operation_cfs_param_uid=<cfqueryparam cfsqltype="cf_sql_other" value="#arguments.instanceOperationCfsParamUid#" null=#!isValid('guid',arguments.instanceOperationCfsParamUid)#/>
|
||||
AND si.specification_id=<cfqueryparam cfsqltype="cf_sql_integer" value=#arguments.specificationId#/>
|
||||
</cfquery>
|
||||
|
||||
<cfif local.qCfsParam.recordCount EQ 0>
|
||||
<cfreturn representationOf(this.helper.formatMessage("Not Found")).withStatus(404)/>
|
||||
</cfif>
|
||||
|
||||
<cfif len(local.qCfsParam.func)><!--- приоритет отдается функции перед списком значений--->
|
||||
<cfset var args = {
|
||||
"functionName":"#local.qCfsParam.func#",
|
||||
@@ -515,7 +418,6 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
"contractId":#arguments.contractId#
|
||||
}/> <!--- если появятся новые аргументы у новых функций, будем добавлять их сюда --->
|
||||
<cfset local.qCfsParam.value_list=generateValueList(argumentCollection=#args#)/> <!--- можно перечислить именованные аргументы обычным порядком, но с коллекцией потенциально более гибко --->
|
||||
<!--- <cfdump var=#local.qCfsParam#/><cfabort/> --->
|
||||
<cfif len(trim(local.qCfsParam.value_list)) AND listLen(local.qCfsParam.value_list) EQ 1>
|
||||
<cfset local.qCfsParam.default_value=local.qCfsParam.value_list/>
|
||||
</cfif>
|
||||
@@ -538,43 +440,32 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
</cftry>
|
||||
<cfset local.qCfsParam.value_list = getListFromState(currentState, local.qCfsParam.state_path)/>
|
||||
</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 local.qCfsParam.data_type EQ "map" OR local.qCfsParam.data_type EQ "map-fixed" OR local.qCfsParam.data_type EQ "array-map-fixed">
|
||||
<cfset processMap(local.qCfsParam)/><!--- query passed by reference --->
|
||||
</cfif>
|
||||
|
||||
<cfset var out=structNew("linked")/>
|
||||
<cfset "out.queryDurationMs"=getTickCount() - request.startTickCount/>
|
||||
|
||||
<cfset "out.instanceOperationCfsParam" = this.helper.appendRecord(
|
||||
structNew("linked"), "", local.titleMap, local.qCfsParam, this.helper.snake2camel
|
||||
)/>
|
||||
|
||||
<cfset "out.runDurationMs"=getTickCount() - request.startTickCount/>
|
||||
<cfreturn representationOf(out) />
|
||||
</cffunction><!--- get --->
|
||||
|
||||
|
||||
<cffunction name="delete" hint="Удаление CFS параметра операции по ключу.">
|
||||
<cfargument name="instanceOperationCfsParamUid" type="string" required=true hint="type:guid"/>
|
||||
|
||||
<cftry>
|
||||
<cfset this.helper.validateField(arguments, "instanceOperationCfsParamUid", "guid")/>
|
||||
<!--- *** Нужна проверка, что операция не была выполнена, иначе она становится архивной --->
|
||||
|
||||
<cfcatch type="invalidParamValue">
|
||||
<cfreturn representationOf(this.helper.formatBadRequestError(cfcatch)).withStatus(400)/>
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
|
||||
<cfset local={}/>
|
||||
<cftry><!--- *** без проверок существования --->
|
||||
|
||||
<cfquery name="local.qCheck" result="local.result">
|
||||
select
|
||||
io.dt_submit, io.submit_result
|
||||
@@ -585,19 +476,6 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
<cfif left(local.qCheck.submit_result,1) EQ "2"><!--- 201 etc --->
|
||||
<cfreturn representationOf(this.helper.formatMessage("Operation already started", "Parameter deletion disabled for started operation")).withStatus(422)/>
|
||||
</cfif>
|
||||
|
||||
<!--- <cfquery name="local.qCheckSpecification" result="local.result">
|
||||
select si.specification_id
|
||||
from instance_operation_cfs_param iop
|
||||
join instance_operation io on iop.instance_operation_uid=io.instance_operation_uid
|
||||
join instance e on (io.instance_uid=e.instance_uid)
|
||||
left outer join specification_item si on (e.specification_item_id=si.specification_item_id)
|
||||
where iop.instance_operation_cfs_param_uid=<cfqueryparam cfsqltype="cf_sql_other" value="#arguments.instanceOperationCfsParamUid#" null=#!isValid('guid',arguments.instanceOperationCfsParamUid)#/>
|
||||
AND si.specification_id=<cfqueryparam cfsqltype="cf_sql_integer" value=#arguments.specificationId#/>
|
||||
</cfquery>
|
||||
<cfif local.qCheckSpecification.recordCount EQ 0>
|
||||
<cfreturn representationOf(this.helper.formatMessage("Instance not accessible", "Instance does not belong to the current specification, contract or contragent")).withStatus(403)/>
|
||||
</cfif> --->
|
||||
<cfquery name="local.qCheckAccess" result="local.result">
|
||||
select count(*) as cnt
|
||||
from instance_operation_cfs_param iop
|
||||
@@ -610,26 +488,20 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
<cfif local.qCheckAccess.cnt EQ 0>
|
||||
<cfreturn representationOf(this.helper.formatMessage("Instance not accessible", "Instance of this CFS parameter is not accessible to the current user (at least does not belong to the default specification)")).withStatus(403)/>
|
||||
</cfif>
|
||||
|
||||
<cfquery name="local.qSave">
|
||||
delete from instance_operation_cfs_param
|
||||
where instance_operation_cfs_param_uid=<cfqueryparam cfsqltype="cf_sql_other" value="#arguments.instanceOperationCfsParamUid#" null=#!isValid('guid',arguments.instanceOperationCfsParamUid)#/>
|
||||
</cfquery>
|
||||
|
||||
<cfcatch type="any">
|
||||
<cfreturn representationOf(this.helper.formatException(cfcatch, "Internal Error")).withStatus(500)/><!--- это не нужно показывать в продуктиве --->
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
|
||||
<cfreturn noData().withStatus(204, "No Content") />
|
||||
</cffunction><!--- delete --->
|
||||
|
||||
|
||||
<cffunction name="put" hint="запись CFS параметра операции инстанса">
|
||||
<cfargument name="instanceOperationCfsParamUid" type="string" required=true hint="type:guid"/>
|
||||
<cfargument name="paramValue" type="string" required=true/>
|
||||
<cfargument name="note" type="string" required=false default=""/>
|
||||
|
||||
<cfset var local={}/>
|
||||
<cftry>
|
||||
<cfset checkInstanceParam(arguments.instanceOperationCfsParamUid, arguments.paramValue, arguments.usrId)/>
|
||||
@@ -637,7 +509,6 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
<cfreturn representationOf(this.helper.formatBadRequestError(cfcatch)).withStatus(400)/>
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
|
||||
<cfquery name="local.qSave" result="local.result">
|
||||
update instance_operation_cfs_param set
|
||||
dt_created=<cfqueryparam cfsqltype="cf_sql_timestamp" value="#Now()#" />
|
||||
@@ -649,14 +520,10 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
<!--- *** проверить существование - 404 --->
|
||||
<cfreturn noData().withStatus(204, "No Content") />
|
||||
</cffunction><!--- put --->
|
||||
|
||||
|
||||
|
||||
<cffunction name="checkInstanceParam">
|
||||
<cfargument name="instanceOperationCfsParamUid" type="guid" required=true/>
|
||||
<cfargument name="paramValue" required=true/>
|
||||
<cfargument name="usrId" type="numeric" required=true/>
|
||||
|
||||
<cfset var local={}/>
|
||||
<cfquery name="local.qCheck" result="local.result">
|
||||
select svc_operation_cfs_param_id
|
||||
@@ -666,11 +533,8 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
<cfif local.qCheck.recordCount EQ 0>
|
||||
<cfthrow type="invalidParamValue" message="Cannot find CFS parameter by instanceOperationCfsParamUid=#arguments.instanceOperationCfsParamUid#"/>
|
||||
</cfif>
|
||||
|
||||
<cfset CreateObject("component", "instance_operation_cfs_param_ls").checkParam(local.qCheck.svc_operation_cfs_param_id, arguments.paramValue, arguments.usrId, arguments.instanceOperationCfsParamUid)/>
|
||||
</cffunction>
|
||||
|
||||
|
||||
<cffunction name="processMap" returntype="void" access="public">
|
||||
<cfargument name="qParam" type="query" required=true/><!--- работаем с текущей строкой query. передача query это скорее колхоз, всего-то надо 4 понятных аргумента.
|
||||
Конечно, то, что часть из них - id, не упрощает восприяие кода --->
|
||||
@@ -678,7 +542,6 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
- сформировать дескриптор
|
||||
- замаскировать секреты --->
|
||||
<!--- здесь могут использоваться 2 критерия: формат аргумента, array/struct, либо тип --->
|
||||
|
||||
<cfset local.spContainer = {}/><!--- может быть map или array of map --->
|
||||
<cfset local.spMapArray = []/>
|
||||
<!--- мы хотим обработать и случай array-map-fixed --->
|
||||
@@ -693,7 +556,6 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
<cfset local.spMapArray = [{"error":"#cfcatch.message#"}]/><!--- теряем все данные --->
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
|
||||
<cfquery name="local.qSubparam">
|
||||
select
|
||||
sp.svc_operation_cfs_param_id
|
||||
@@ -722,8 +584,6 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
where sp.svc_operation_cfs_param_id=<cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.qParam.svc_operation_cfs_param_id#"/>
|
||||
order by sp.sort
|
||||
</cfquery>
|
||||
<!--- <cfdump var=#local.qSubparam#/><cfabort/> --->
|
||||
|
||||
<cfquery name="local.qInstSubparam">
|
||||
select
|
||||
sp.instance_operation_cfs_param_uid::text as instance_operation_cfs_param_uid
|
||||
@@ -735,11 +595,9 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
where sp.instance_operation_cfs_param_uid=<cfqueryparam cfsqltype="cf_sql_other" value="#arguments.qParam.instance_operation_cfs_param_uid#" null=#!isValid("guid",arguments.qParam.instance_operation_cfs_param_uid)#/>
|
||||
order by sp.sort
|
||||
</cfquery>
|
||||
|
||||
<!--- формируем дескриптор --->
|
||||
<cfset var mapDescriptor=structNew("linked")/>
|
||||
<cfset var parser=createObject("component","lib.expression_parser")/>
|
||||
|
||||
<cfloop query="local.qSubparam">
|
||||
<cfset structInsert(mapDescriptor, local.qSubparam.svc_operation_cfs_subparam,
|
||||
{
|
||||
@@ -776,12 +634,10 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
"uniqueScope":"#local.qSubparam.unique_scope#",
|
||||
"defaultCompute":"#local.qSubparam.default_compute#",
|
||||
"isModifiableDefinition":false
|
||||
|
||||
}, true
|
||||
)
|
||||
/>
|
||||
</cfloop>
|
||||
|
||||
<cfloop index="local.i" from=1 to=#arrayLen(local.spMapArray)#><!--- *** искусственное оборачивание в массив вот для этого, не придумал ничего умнее
|
||||
чтобы не дублировать цикл по субпараметрам. Сделано некрасиво, но работать должно.
|
||||
Ну а как сделать? Если массив - делать цикл по массиву, а если map-сразу обрабатыввать map. При этом запрос к таблице сабпараметров не хочется делать лишний раз.
|
||||
@@ -799,7 +655,6 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
</cfloop>
|
||||
</cfif>
|
||||
</cfloop>
|
||||
|
||||
<!--- *** проверку, что это не map-fixed, можно добавить здесь --->
|
||||
<!--- чтобы не вставляли в параметр что попало --->
|
||||
<!--- здесь мы не делаем цикл по массиву, поскольку не поддерживаем массив расширяемых map --->
|
||||
@@ -818,21 +673,16 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
</cfif>
|
||||
</cfloop>
|
||||
</cfif>
|
||||
|
||||
<cfset arguments.qParam.data_descriptor = mapDescriptor/>
|
||||
|
||||
<cfif (arguments.qParam.data_type EQ "array-map-fixed")>
|
||||
<cfset arguments.qParam.param_value = serializeJson(local.spMapArray)/><!--- как есть --->
|
||||
<cfelse>
|
||||
<cfset arguments.qParam.param_value = arrayLen(local.spMapArray) ? serializeJson(local.spMapArray[1]) : ""/><!--- вытаскиваем из массива-обертки --->
|
||||
</cfif>
|
||||
</cffunction>
|
||||
|
||||
|
||||
<cffunction name="generateValueList" returntype="string" access="public">
|
||||
<cfargument name="functionName" type="string" required="true"/>
|
||||
<!--- остальные атрибуты необязательные, в argumentCollection (еще вопрос, насколько безопасно объявлять один из аргументов без остальных) --->
|
||||
|
||||
<cfswitch expression=#arguments.functionName#>
|
||||
<cfcase value="">
|
||||
<cfreturn ""/>
|
||||
@@ -848,14 +698,10 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
</cfdefaultcase>
|
||||
</cfswitch>
|
||||
</cffunction>
|
||||
|
||||
|
||||
<cffunction name="getAvailableResourceRealms" returnType="string" access="public">
|
||||
<cfargument name="svcId"/>
|
||||
<cfargument name="contractId"/>
|
||||
|
||||
<cfset var local={}/>
|
||||
|
||||
<cfquery name="local.qAvailableResourceRealm"><!--- *** distinct халява, но придумывать корректную формулировку времени мало --->
|
||||
select distinct r.resource_realm, r.sort
|
||||
from resource_realm r
|
||||
@@ -867,21 +713,16 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
join svc s on r.resource_realm_type_id=s.resource_realm_type_id
|
||||
where s.svc_id=<cfqueryparam cfsqltype="CF_SQL_INTEGER" value=#arguments.svcId# null=#!isValid("integer", arguments.svcId)#/>
|
||||
order by r.sort, r.resource_realm
|
||||
</cfquery> <!--- <cfdump var=#arguments#/> cfdump здесь провоцирует NPE --->
|
||||
</cfquery>
|
||||
<cfif local.qAvailableResourceRealm.recordCount>
|
||||
<cfreturn valueList(local.qAvailableResourceRealm.resource_realm)/>
|
||||
<cfelse>
|
||||
<cfreturn ""/><!--- иначе для пустого резалтсета генерируется null --->
|
||||
</cfif>
|
||||
</cffunction>
|
||||
|
||||
|
||||
|
||||
<!--- для вложенных справочников --->
|
||||
<!--- дублировано: deck-tool/instance_operation.cfm --->
|
||||
|
||||
<cffunction name="getSelectedResourceRealm" returnType="string">
|
||||
|
||||
<cfset var local={}/>
|
||||
<cfquery name="local.qSelectedResourceRealm">
|
||||
select iop.param_value
|
||||
@@ -890,15 +731,13 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
where iop.instance_operation_uid=<cfqueryparam cfsqltype="CF_SQL_OTHER" value=#d.instance_operation_uid# null=#!isValid("guid", d.instance_operation_uid)#/>
|
||||
AND sop.svc_operation_cfs_param='resourceRealm'
|
||||
order by 1
|
||||
</cfquery> <!--- <cfdump var=#arguments#/> cfdump здесь провоцирует NPE --->
|
||||
</cfquery>
|
||||
<cfreturn local.qSelectedResourceRealm.param_value/>
|
||||
</cffunction>
|
||||
|
||||
<cffunction name="generateClosure" returntype="function">
|
||||
<cfargument name="functionName" type="string" required="true"/>
|
||||
<cfargument name="config" type="string" required="true"/>
|
||||
<!--- остальные атрибуты необязательные, в argumentCollection --->
|
||||
|
||||
<cfswitch expression=#arguments.functionName#>
|
||||
<cfcase value="">
|
||||
<cfreturn function(){}/>
|
||||
@@ -916,19 +755,15 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
</cfdefaultcase>
|
||||
</cfswitch>
|
||||
</cffunction>
|
||||
|
||||
<cffunction name="getRefFromRRealmConfig" returntype="any">
|
||||
<cfargument name="resourceRealm" type="string" required="true"/>
|
||||
<cfargument name="config" type="string" required="true"/>
|
||||
|
||||
<cfquery name="qResourceRealmConfig">
|
||||
select properties::text
|
||||
from resource_realm
|
||||
where resource_realm='ngcloud.ru'
|
||||
<!--- <cfqueryparam cfsqltype="cf_sql_varchar" value=#arguments.resourceRealm#/> --->
|
||||
</cfquery>
|
||||
|
||||
<!--- <cfset var local={}/> ---> <!--- паранойя... и есть шансы, что я неправильно понимаю эту химию скоупов--->
|
||||
<!--- паранойя... и есть шансы, что я неправильно понимаю эту химию скоупов--->
|
||||
<cfset var props = deserializeJson(qResourceRealmConfig.properties)/>
|
||||
<cfset var cfg = deserializeJson(arguments.config)/> <!--- удобнее было бы передавать сразу структуру впр --->
|
||||
<cfset cfg={"path":"vcd.providerVdc"}/><!--- *** временный пример для отладки --->
|
||||
@@ -940,12 +775,10 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
<cfset structInsert(result, containerName, structGet("props.#path#"))/>
|
||||
<cfreturn result/>
|
||||
</cffunction>
|
||||
|
||||
<!--- duplicated in deck-tool --->
|
||||
<cffunction name="getListFromState" returntype="string" hint="returns list">
|
||||
<cfargument name="state" type="struct" required="true"/>
|
||||
<cfargument name="path" type="string" required="true"/>
|
||||
|
||||
<cftry>
|
||||
<cfreturn structKeyList(structGet("arguments.state.#arguments.path#"))/>
|
||||
<cfcatch type="any">
|
||||
@@ -954,20 +787,5 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
</cffunction>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</cfcomponent>
|
||||
<!--- [{"b":"12","secret1":"preved"},{"b":"13","secret1":"preved404"},{"b":"14","secret1":"preved402"}] --->
|
||||
<!--- [{"b":"12","secret1":"preved"},{"b":"13","secret1":"preved404"},{"b":"14","secret1":"preved402"}] --->
|
||||
|
||||
Reference in New Issue
Block a user