...
Ante el hecho de querer cambiar esas URNs que terminan en número por un nombre, debemos seguir el siguiente procedimiento
xQuery para modificar en base eXist O3BI | Consulta SQL para modificar en base de Liferay |
---|
Code Block |
---|
xquery version "3.0";
declare namespace vd='http://ns.ideasoft.biz/o3bi/schema/ViewDefinition/2011-01';
declare namespace dc='http://purl.org/dc/terms';
declare namespace dxml='http://ns.ideasoft.biz/o3bi/schema/CubeDefinition/2011-01';
declare namespace ns6='http://ns.ideasoft.biz/o3bi/schema/CubeDefinition/2011-01';
declare namespace ns3="http://ns.ideasoft.biz/common/schema/ScheduleTask/v7";
declare namespace ns4="http://ns.ideasoft.biz/o3bi/schema/Ad-Hoc/2011-01";
declare function local:chgViewRef($cubeUrn as xs:string, $newCubeUrn) as node()* {
let $baseCollection:='/db/o3bi/domains/default/current/runtime'
for $view in collection($baseCollection)//vd:viewDefinition[./dc:dublinCore/vd:cube/dc:identifier/text()=$cubeUrn]
return update replace $view/dc:dublinCore/vd:cube/dc:identifier with element{'dc:identifier'}{$newCubeUrn}
};
declare function local:chgAdhocRef($cubeUrn as xs:string, $newCubeUrn) as node()* {
let $baseCollection:='/db/o3bi/domains/default/current/runtime'
for $adhoc in collection($baseCollection)//ns4:adhoc//dc:identifier[./text() =$cubeUrn]
return(
let $tst:= update replace $adhoc with element{'dc:identifier'}{$newCubeUrn}
return $adhoc/..
)
};
declare function local:chgProfileRef($cubeUrn as xs:string, $newCubeUrn) as node()* {
let $baseCollection:='/db/o3bi/domains/default/current/runtime'
for $profile in collection($baseCollection)//dxml:cubeProfile[./dxml:cube/dc:identifier/text() = $cubeUrn]
return (
let $sts1:= update replace $profile/dxml:cube/dc:identifier with element{'dc:identifier'}{$newCubeUrn}
return $profile
)
};
declare function local:chgTaskRef($cubeUrn as xs:string, $newCubeUrn) as node()* {
let $baseCollection:='/db/o3bi/domains/default/current/runtime'
for $scheduleTask in collection($baseCollection)//ns3:scheduleTask/ns3:property[./ns3:key/text() = 'urn:cube' and ./ns3:value/text()=$cubeUrn]
return (
let $sts1:= update replace $scheduleTask/ns3:value with element{'ns3:value'}{$newCubeUrn}
return $scheduleTask/..
)
};
declare function local:chgCubeName($cubeName as xs:string, $newCubeName as xs:string, $prefixUrn as xs:string) as node()* {
let $cubeUrn:=$prefixUrn|| $cubeName
let $newCubeUrn:=$prefixUrn|| $newCubeName
let $baseCollection:='/db/o3bi/domains/default/current/runtime'
(:CubeName:)
let $cube:=collection($baseCollection)/dxml:cubeDefinition[./dc:dublinCore/dc:identifier/text()=$cubeUrn]
return
if (not(empty($cube))) then (
let $sts1:= update replace $cube/dc:dublinCore/dc:identifier with element{'dc:identifier'}{$newCubeUrn}
let $sts1:= update replace $cube/ns6:cubeName with element{'ns6:cubeName'}{$newCubeName}
let $sts1:= if (not(empty($cube/dc:dublinCore/dc:name))) then
update replace $cube/dc:dublinCore/dc:name with element{'dc:name'}{$newCubeName}
else update insert element{'dc:name'}{$newCubeName} following $cube/dc:dublinCore/dc:namespace
(:cubeView:)
let $views:=local:chgViewRef($cubeUrn, $newCubeUrn)
(:chgProfileRef:)
let $profile:=local:chgProfileRef($cubeUrn, $newCubeUrn)
(:chgTaskRef:)
let $task:=local:chgTaskRef($cubeUrn, $newCubeUrn)
(:chgAdhocRef:)
let $adhoc:=local:chgAdhocRef($cubeUrn, $newCubeUrn)
return
element{'resultadoOk'} {
$cube/ns6:cubeName,
$profile/dxml:cube/dc:identifier,
$profile,
$cube,
$views,
$task,
$adhoc
}
) else (
element{'resultado'} {
'No se encontro el cubo de name:'|| $cubeName
}
)
};
(:Ejecucion de cambio de nombre:)
let $cubeName:='2103'
let $newCubeName:='DeudoresInd'
let $prefixUrn:='urn:o3bi:default:r:cube:a:'
return local:chgCubeName($cubeName,$newCubeName, $prefixUrn) |
| Corresponde aplicar si hay ControlDashlets configurados con el cubo a modificar la urn Code Block |
---|
| UPDATE PortletPreferences
SET preferences = REPLACE(preferences, 'urn:o3bi:default:r:cube:a:2017' , 'urn:o3bi:default:r:cube:a:AtPresencial')
where preferences like'%urn:o3bi:default:r:cube:a:2017%' |
|