100 instance_operation_default with memory
This commit is contained in:
+1
-1
@@ -51,7 +51,7 @@
|
||||
|
||||
//variables.framework.docs={};
|
||||
variables.framework.docs.APIName="Deck API";
|
||||
variables.framework.docs.APIVersion="0.099";
|
||||
variables.framework.docs.APIVersion="0.100";
|
||||
|
||||
variables.framework.globalHeaders = structNew();
|
||||
variables.framework.globalHeaders["Access-Control-Expose-Headers"] = "Location";
|
||||
|
||||
@@ -147,29 +147,14 @@
|
||||
}/> <!--- если появятся новые аргументы у новых функций, будем добавлять их сюда --->
|
||||
<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>
|
||||
|
||||
</cfif>
|
||||
</cfloop>
|
||||
|
||||
<!--- <cfquery name="local.qAvailableResourceRealm" result="local.result">
|
||||
select
|
||||
<m:field_set titleMapOut="local.realmTitleMap" lengthOut="local.realmFieldCount">
|
||||
<m:field>r.resource_realm_id</m:field>
|
||||
<m:field>r.resource_realm_type_id</m:field>
|
||||
<m:field>r.resource_realm</m:field>
|
||||
</m:field_set>
|
||||
from resource_realm r
|
||||
join resource_realm_type t on (r.resource_realm_type_id=t.resource_realm_type_id)
|
||||
/*left outer join resource_realm p on (r.parent_id=p.resource_realm_id)*/
|
||||
join resource_realm_access a on
|
||||
(r.resource_realm_id=a.resource_realm_id
|
||||
AND (a.contract_id=<cfqueryparam cfsqltype="CF_SQL_INTEGER" value=#arguments.contractId#/>
|
||||
OR a.contract_id=0) /*0 means access to any contract*/
|
||||
AND a.is_enabled)
|
||||
join svc s on r.resource_realm_type_id=s.resource_realm_type_id
|
||||
where s.svc_id=<cfqueryparam cfsqltype="CF_SQL_INTEGER" value=#local.qInstanceOperation.service_id#/>
|
||||
order by 1
|
||||
</cfquery> --->
|
||||
|
||||
|
||||
<cfset "out.queryDurationMs"=getTickCount() - request.startTickCount/>
|
||||
|
||||
<cfset "out.instanceOperation" = this.helper.appendRecord(
|
||||
@@ -188,11 +173,6 @@
|
||||
|
||||
<cfset "out.instanceOperation.state"=(local.qState.recordCount GT 0) ? this.helper.appendRecord(structNew("linked"), "", local.stateTitleMap, local.qState, this.helper.snake2camel) : {}/>
|
||||
|
||||
<!--- <cfset "out.instanceOperation.availableResourceRealms"=[]/>
|
||||
<cfloop query=#local.qAvailableResourceRealm#>
|
||||
<cfset arrayAppend(out.instanceOperation.availableResourceRealms, this.helper.appendRecord(structNew("linked"), "", local.realmTitleMap, local.qAvailableResourceRealm, this.helper.snake2camel))/>
|
||||
</cfloop> --->
|
||||
|
||||
<cfset "out.runDurationMs"=getTickCount() - request.startTickCount/>
|
||||
<cfreturn representationOf(out) />
|
||||
</cffunction>
|
||||
@@ -214,7 +194,7 @@
|
||||
AND a.is_enabled)
|
||||
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 1
|
||||
order by r.sort
|
||||
</cfquery> <!--- <cfdump var=#arguments#/> cfdump здесь провоцирует NPE --->
|
||||
<cfreturn valueList(local.qAvailableResourceRealm.resource_realm)/>
|
||||
</cffunction>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<cfcomponent extends="taffy.core.resource" taffy:uri="/instanceOperations/default/{svcOperationId}" hint="template for default instance operation">
|
||||
<cfcomponent extends="taffy.core.resource" taffy:uri="/instanceOperations/{instanceUid}/{svcOperationId}" hint="template for default instance operation. Legacy URL: /instanceOperations/default/{svcOperationId}">
|
||||
<!--- ну и как мне передать второй параметр для GET? --->
|
||||
|
||||
<cfsilent>
|
||||
<cfimport prefix="m" taglib="../lib"/>
|
||||
@@ -7,18 +8,23 @@
|
||||
|
||||
|
||||
<cffunction name="get" hint="Шаблон операции экземпляра"><!--- *** TODO проверка принадлежности тенанту --->
|
||||
<cfargument name="instanceUid" type="string" required=true hint="type:guid|'default'"/>
|
||||
<cfargument name="svcOperationId" type="string" required=true hint="type:integer"/>
|
||||
<!--- <cfargument name="usrId" type="string" hint="type:integer; no need to provide this argument in request, it is injected by IAM"/> ---><!--- arguments.usrId неявно инжектируется из Application.cfm, также contractId, contragentId ... --->
|
||||
|
||||
|
||||
|
||||
<!--- <cfargument name="usrId" type="string" hint="type:integer; no need to provide this argument in request, it is injected by IAM"/> ---><!--- arguments.usrId неявно инжектируется из Application.cfm, а с ним contractId, contragentId ... --->
|
||||
|
||||
<cftry>
|
||||
<cfset this.helper.validateField(arguments, "svcOperationId", "integer")/>
|
||||
<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">
|
||||
@@ -30,9 +36,32 @@
|
||||
<m:field title="Руководство">o.man</m:field>
|
||||
</m:field_set>
|
||||
from svc_operation o
|
||||
where o.svc_operation_id=<cfqueryparam cfsqltype="cf_sql_other" value="#arguments.svcOperationId#" null=#!isValid('integer',arguments.svcOperationId)#/>
|
||||
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={}/>
|
||||
<cfquery name="local.qState" result="local.result">
|
||||
select instance_data->'params' as params
|
||||
from instance_state
|
||||
where instance_uid=<cfqueryparam cfsqltype="cf_sql_other" value="#arguments.instanceUid#" null=#!isValid('guid',arguments.instanceUid)#/>
|
||||
order by version desc
|
||||
limit 1
|
||||
</cfquery>
|
||||
<cfif local.qState.recordCount GT 0>
|
||||
<cftry>
|
||||
<cfset local.instanceDataParams = deserializeJson(local.qState.params)/>
|
||||
<cfcatch type="ANY">
|
||||
<cfdump var=#cfcatch#/><cfabort/>
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
</cfif>
|
||||
|
||||
|
||||
<cfquery name="local.qCfsParam" result="local.result">
|
||||
select
|
||||
<m:field_set titleMapOut="local.cfsParamMap" lengthOut="local.fieldCount">
|
||||
@@ -70,13 +99,10 @@
|
||||
from svc_operation_cfs_param p
|
||||
where p.svc_operation_id=<cfqueryparam cfsqltype="cf_sql_other" value="#arguments.svcOperationId#" null=#!isValid('integer',arguments.svcOperationId)#/>
|
||||
order by p.sort, p.svc_operation_cfs_param_id
|
||||
</cfquery>
|
||||
|
||||
<cfif local.qSvcOperation.recordCount EQ 0>
|
||||
<cfreturn representationOf(this.helper.formatMessage("Not Found")).withStatus(404)/>
|
||||
</cfif>
|
||||
|
||||
</cfquery>
|
||||
|
||||
|
||||
<!--- тут разорвана обработка, ниже есть повторный проход по параметрам --->
|
||||
<cfloop query="local.qCfsParam">
|
||||
<cfif len(func)><!--- приоритет отдается функции перед списком значений--->
|
||||
<cfset var args = {
|
||||
@@ -86,32 +112,13 @@
|
||||
}/> <!--- если появятся новые аргументы у новых функций, будем добавлять их сюда --->
|
||||
<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/><!--- *** не очень красиво перетирать query--->
|
||||
</cfif>
|
||||
</cfif>
|
||||
</cfloop>
|
||||
|
||||
</cfloop>
|
||||
<cfset queryDeleteColumn(local.qCfsParam, "func")/>
|
||||
|
||||
|
||||
<!--- <cfquery name="local.qAvailableResourceRealm" result="local.result">
|
||||
select distinct /***халява*/
|
||||
<m:field_set titleMapOut="local.realmTitleMap" lengthOut="local.realmFieldCount">
|
||||
<m:field>r.resource_realm_id</m:field>
|
||||
<m:field>r.resource_realm_type_id</m:field>
|
||||
<m:field>r.resource_realm</m:field>
|
||||
</m:field_set>
|
||||
from resource_realm r
|
||||
join resource_realm_type t on (r.resource_realm_type_id=t.resource_realm_type_id)
|
||||
/*left outer join resource_realm p on (r.parent_id=p.resource_realm_id)*/
|
||||
join resource_realm_access a on
|
||||
(r.resource_realm_id=a.resource_realm_id
|
||||
AND (a.contract_id=<cfqueryparam cfsqltype="CF_SQL_INTEGER" value=#arguments.contractId#/>
|
||||
OR a.contract_id=0) /*0 means access to any contract*/
|
||||
AND a.is_enabled)
|
||||
join svc s on r.resource_realm_type_id=s.resource_realm_type_id
|
||||
where s.svc_id=<cfqueryparam cfsqltype="CF_SQL_INTEGER" value=#local.qSvcOperation.svc_id#/>
|
||||
order by 1
|
||||
</cfquery> --->
|
||||
|
||||
<cfset var out=structNew("linked")/>
|
||||
<cfset "out.queryDurationMs"=getTickCount() - request.startTickCount/>
|
||||
|
||||
@@ -122,21 +129,21 @@
|
||||
<cfset "out.svcOperation.cfsParams"=[]/>
|
||||
<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>
|
||||
<!--- и вот наконец мы извлекаем старое значение из стейта --->
|
||||
<cfset var paramName = this.helper.snake2camel(local.qCfsParam.svc_operation_cfs_param)/>
|
||||
<cfif structKeyExists(local.instanceDataParams, paramName)>
|
||||
<cfset local.qCfsParam.default_value = structFind(local.instanceDataParams, paramName)/>
|
||||
</cfif>
|
||||
</cfif>
|
||||
<cfset var rec = this.helper.appendRecord(structNew("linked"), "", local.cfsParamMap, local.qCfsParam, this.helper.snake2camel)/>
|
||||
|
||||
<cfset arrayAppend(out.svcOperation.cfsParams, rec)/>
|
||||
</cfloop>
|
||||
|
||||
<!--- <cfset "out.svcOperation.availableResourceRealms"=[]/>
|
||||
<cfloop query=#local.qAvailableResourceRealm#>
|
||||
<cfset arrayAppend(out.svcOperation.availableResourceRealms, this.helper.appendRecord(structNew("linked"), "", local.realmTitleMap, local.qAvailableResourceRealm, this.helper.snake2camel))/>
|
||||
</cfloop> --->
|
||||
|
||||
<cfset "out.runDurationMs"=getTickCount() - request.startTickCount/>
|
||||
<cfreturn representationOf(out) />
|
||||
|
||||
|
||||
|
||||
|
||||
</cffunction>
|
||||
|
||||
<!--- *** выглядит ужасно, но красивый вариант не придумывается ряд месяцев --->
|
||||
@@ -164,28 +171,6 @@
|
||||
|
||||
</cffunction>
|
||||
|
||||
|
||||
<!--- <cffunction name="getAvailableResourceRealms" returnType="string">
|
||||
<cfargument name="svcId" type="numeric">
|
||||
<cfargument name="contractId" type="numeric">
|
||||
|
||||
<cfset var local={}/>
|
||||
|
||||
<cfquery name="local.qAvailableResourceRealm"><!--- *** distinct халява, но придумывать корректную формулировку времени мало --->
|
||||
select distinct r.resource_realm
|
||||
from resource_realm r
|
||||
join resource_realm_access a on
|
||||
(r.resource_realm_id=a.resource_realm_id
|
||||
AND (a.contract_id=<cfqueryparam cfsqltype="CF_SQL_INTEGER" value=#arguments.contractId# />
|
||||
OR a.contract_id=0) /*0 means access to any contract*/
|
||||
AND a.is_enabled)
|
||||
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#/>
|
||||
order by 1
|
||||
</cfquery>
|
||||
<cfreturn valueList(local.qAvailableResourceRealm.resource_realm)/><!--- пишут, что есть valueToArray --->
|
||||
</cffunction> --->
|
||||
|
||||
<cffunction name="getAvailableResourceRealms" returnType="string">
|
||||
<cfargument name="svcId"/>
|
||||
<cfargument name="contractId"/>
|
||||
|
||||
Reference in New Issue
Block a user