Clarity

  • 1.  Delete instance right node from the XML using gel script.

    Posted Apr 17, 2019 04:53 AM

    Hi All,

     

    I'm trying to delete the specific instance right using gel script, I have tried the options shared in communities but those are not working .

    Below is the xml , where in I'm trying to remove the both nodes with ids odf_cst_xyz_res_creation_edit &odf_cst_xyz_res_creation_view


    <InstanceRights >
    <Right id="odf_cst_xyz_res_creation_edit">
    <InstanceObject id="00000095" name="00000095" type="xyz_res_creation"/>
    </Right>
    <Right id="odf_cst_xyz_res_creation_view">
    <InstanceObject id="00000095" name="00000095" type="xyz_res_creation"/>
    </Right>
    </InstanceRights>

     

    I have tried the below code in gel Script, Please look into this and correct me if i'm doing wrong here.

     

    <gel:set asString="true" select="$result//NikuDataBus/Users/User/InstanceRights/Right[@id='odf_cst_xyz_res_creation_edit']"
    var="nodeDelete"/>

    <core:set value="${nodeDelete.getParentNode()}" var="parent"/>

    <core:set value="${parent.removeChild(nodeDelete)}" var="void"/>

     

    Regards,

    Ram Babu



  • 2.  Re: Delete instance right node from the XML using gel script.

    Posted Apr 17, 2019 07:16 AM

    I am not sure I understand what you are trying to do.

    Normally the supported way is to create the xml file with gel and the further XOG it in.

    To remove rights in those versions where the parameter is supported you would have

    Right complete = true or Right completed = true

    and list just the rights you want to have remaining

     

    If you are trying to remove those instance rights from the xml and then XOG it in it will not of course write those rights, but if they already exist it will not remove them.



  • 3.  Re: Delete instance right node from the XML using gel script.

    Posted Apr 17, 2019 09:34 AM

    Hi, Actually In the above given example user have few more instance rights. Here If we append 'complete= "true" in the  <InstanceRights>node, all instance rights will be removed from the xml. But my requirement is to remove only two rights with ids 'odf_cst_xyz_res_creation_edit' and 'odf_cst_xyz_res_creation_view'  from the user write xml and the same has to XOG in back in the script.

     

     

     



  • 4.  Re: Delete instance right node from the XML using gel script.

    Posted Apr 18, 2019 10:09 AM

    The first thing that stands out is the attribute asString="true"

     

    When you do that, the returned value assigned to the var nodeDelete is just plain text and not an XML node.



  • 5.  Re: Delete instance right node from the XML using gel script.

    Posted Apr 22, 2019 08:19 AM

    Hi Nick,

    Thanks for the correction.I have tried with the updated syntax, but it is not working .

     

    <gel:set select="$result//NikuDataBus/Users/User/InstanceRights/Right[@id='odf_cst_wiley_res_creation_edit']" var="groupToDelete"/>

    <core:set value="${groupToDelete.getParentNode()}" var="parent"/>

    <core:set value="${parent.removeChild(groupToDelete)}" var="void"/>

    And when i tried to print the variable 'groupToDelete', I got the null value [Right: null].Please correct me, if I'm doing any thing wrong here.



  • 6.  Re: Delete instance right node from the XML using gel script.
    Best Answer

    Posted Apr 25, 2019 01:19 PM

    You will need to iterate over the nodes to find the ones you want to remove.

     

    <gel:script xmlns:core="jelly:core"  xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary">

         <gel:parse var="InstanceRightsXml"> 
              <InstanceRights >
                   <Right id="odf_cst_xyz_res_creation_edit">
                        <InstanceObject id="00000095" name="00000095" type="xyz_res_creation"/>
                   </Right>
                   <Right id="keep_this_one">
                        <InstanceObject id="00000095" name="00000095" type="keep_this_one"/>
                   </Right>
                   <Right id="odf_cst_xyz_res_creation_view">
                        <InstanceObject id="00000095" name="00000095" type="xyz_res_creation"/>
                   </Right>
              </InstanceRights>
         </gel:parse>

         <!-- rightEntrys are org.w3c.dom Elements --> 
         <gel:set select="$InstanceRightsXml//InstanceRights/Right/InstanceObject[@type='xyz_res_creation']" var="rightEntry"/> 
         <core:while test="${rightEntry != null}">
              <core:set var="parentNode" value="${rightEntry.getParentNode().getParentNode()}" />
              <core:expr value="${parentNode.removeChild(rightEntry.getParentNode())}" />
              <gel:set select="$InstanceRightsXml//InstanceRights/Right/InstanceObject[@type='xyz_res_creation']" var="rightEntry"/>
         </core:while>

         <gel:log>
              <gel:expr select="$InstanceRightsXml/"/>
         </gel:log>

    </gel:script>

     

     

    V/r,

    Gene



  • 7.  Re: Delete instance right node from the XML using gel script.

    Posted Apr 29, 2019 06:51 AM

    Hi Gene, Thanks. I will try  your steps and get back to you.



  • 8.  Re: Delete instance right node from the XML using gel script.

    Posted May 02, 2019 05:39 AM

    Hi Gene,

     

    Now I can remove the required nodes. Thanks for your help !!.

     

    Regards,

    Ram Babu