151 getListFromState
This commit is contained in:
@@ -100,8 +100,32 @@
|
||||
from instance_state st
|
||||
where st.instance_operation_uid=<cfqueryparam cfsqltype="cf_sql_other" value="#local.qInstanceOperation.instance_operation_uid#" null=#!isValid('guid',local.qInstanceOperation.instance_operation_uid)#/>
|
||||
order by st.version desc limit 1
|
||||
</cfquery>
|
||||
|
||||
<cfquery name="local.qCurrentState" result="local.result">
|
||||
select
|
||||
<m:field_set titleMapOut="local.stateTitleMap" lengthOut="local.fieldCount">
|
||||
<m:field title="instance_state_uid">st.instance_state_uid::text as instance_state_uid</m:field>
|
||||
<m:field title="v.">st.version</m:field>
|
||||
<m:field title="creator_id">st.creator_id</m:field>
|
||||
<m:field title="dt_state">to_char(st.dt_state, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_state</m:field>
|
||||
<m:field formatter=#request.castToBool#>st.is_test</m:field>
|
||||
<m:field title="instance_operation_uid">st.instance_operation_uid::text as instance_operation_uid</m:field>
|
||||
<m:field title="instance_data" formatter=#function(x){return (deserializeJson(x))}#>st.instance_data::text as instance_data</m:field>
|
||||
</m:field_set>
|
||||
from instance_state st
|
||||
where st.instance_uid=<cfqueryparam cfsqltype="cf_sql_other" value="#local.qInstanceOperation.instance_uid#" null=#!isValid('guid',local.qInstanceOperation.instance_uid)#/>
|
||||
order by st.version desc limit 1
|
||||
</cfquery>
|
||||
|
||||
<cfset var currentState = {}/>
|
||||
<cftry>
|
||||
<cfset currentState = deserializeJson(local.qCurrentState.instance_data)/>
|
||||
<cfcatch type="ANY">
|
||||
<!--- тут надо логировать ошибку ---><cfdump var=#cfcatch#/><cfabort/>
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
|
||||
<cfquery name="local.qCfsParam" result="local.result">
|
||||
select
|
||||
<m:field_set titleMapOut="local.cfsParamTitleMap" lengthOut="fieldCount">
|
||||
@@ -132,8 +156,9 @@
|
||||
<m:field>sop.sort</m:field>
|
||||
<m:field>iop.note</m:field>
|
||||
<m:field>sop.nested_ref</m:field>
|
||||
<m:field>sop.config::text</m:field>
|
||||
<m:field>null as nested_ref_data</m:field>
|
||||
<m:field>sop.config::text as config</m:field>
|
||||
<m:field>null as nested_ref_data</m:field><!--- placeholder for future data --->
|
||||
<m:field>sop.state_path</m:field>
|
||||
<m:field formatter=#request.castToBool#>sop.is_sensitive</m:field>
|
||||
</m:field_set>
|
||||
from svc_operation_cfs_param sop
|
||||
@@ -169,6 +194,17 @@
|
||||
}/>
|
||||
<cfinvoke component="instance_operation_cfs_param" method="generateClosure" argumentCollection=#args# returnVariable="local.fNestedRef"/>
|
||||
<cfset local.qCfsParam.nested_ref_data = local.fNestedRef() />
|
||||
<cfelseif len(local.qCfsParam.state_path) AND isStruct(currentState)><!--- deserializeJson может вернуть пустую строку вместо структуры,
|
||||
по крайней мере, если получает поле пустого резалтсета --->
|
||||
<cfset var args = {
|
||||
"state":#currentState#,
|
||||
"path":"#local.qCfsParam.state_path#"
|
||||
}/>
|
||||
<cfinvoke component="instance_operation_cfs_param"
|
||||
method="getListFromState"
|
||||
argumentCollection=#args#
|
||||
returnVariable="local.qCfsParam.value_list"
|
||||
/>
|
||||
</cfif>
|
||||
|
||||
<cfif data_type EQ "map">
|
||||
|
||||
@@ -55,8 +55,10 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
<m:field>sop.man</m:field>
|
||||
<m:field>sop.func</m:field>
|
||||
<m:field>sop.nested_ref</m:field>
|
||||
<m:field>sop.config</m:field>
|
||||
<m:field>sop.config::text as config</m:field>
|
||||
<m:field>sop.state_path</m:field>
|
||||
<m:field>e.service_id</m:field>
|
||||
<m:field>e.instance_uid</m:field>
|
||||
</m:field_set>
|
||||
from instance_operation_cfs_param iop
|
||||
join svc_operation_cfs_param sop on (iop.svc_operation_cfs_param_id=sop.svc_operation_cfs_param_id)
|
||||
@@ -86,6 +88,21 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
<cfelseif len(local.qCfsParam.nested_ref)>
|
||||
<cfset var fNestedRef = generateClosure(local.qCfsParam.nested_ref, local.qCfsParam.config)/>
|
||||
<cfset local.qCfsParam.nested_ref_data = fNestedRef() />
|
||||
<cfelseif len(local.qCfsParam.state_path)>
|
||||
<!--- для экономии читаем стейт только при необходимости --->
|
||||
<cfquery name="local.qCurrentState">
|
||||
select g.instance_state_uid, g.version, g.instance_data, g.is_test, g.instance_uid
|
||||
from instance_state g
|
||||
where g.instance_uid=<cfqueryparam cfsqltype="cf_sql_other" value=#local.qCfsParam.instance_uid#/>
|
||||
order by g.version desc
|
||||
limit 1
|
||||
</cfquery>
|
||||
<cfset var currentState = {}/>
|
||||
<cftry>
|
||||
<cfset currentState = deserializeJson(local.qCurrentState.instance_data)/>
|
||||
<cfcatch type="ANY"></cfcatch>
|
||||
</cftry>
|
||||
<cfset local.qCfsParam.value_list = getListFromState(currentState, local.qCfsParam.state_path)/>
|
||||
</cfif>
|
||||
|
||||
<cfif local.qCfsParam.data_type EQ "map">
|
||||
@@ -404,6 +421,20 @@ arguments.requestArguments.specificationId=usrCustomerInfo.specificationId; //In
|
||||
<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">
|
||||
<!--- можно ожидать ошибки, если по указанному пути расположена не структура --->
|
||||
<cfreturn cfcatch.message/><!--- для упрощения диагностики --->
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
</cffunction>
|
||||
|
||||
|
||||
|
||||
</cfcomponent>
|
||||
Reference in New Issue
Block a user