Clarity

  • 1.  Update only one of segments of allocation through XOG in gel srcipt

    Posted Jan 17, 2018 04:59 AM
      |   view attached

    I have to read my allocations for a project and need to update one of the segments of allocation and keep others same. i need to do this as an XOG in gel script. I am using attached script. Can anyone help me with it.

    With attached query, i am zeroing out all the allocations. I need to zero only for future.

    Attachment(s)

    zip
    allocation.xml.zip   2 KB 1 version


  • 2.  Re: Update only one of segments of allocation through XOG in gel srcipt
    Best Answer

    Posted Jan 24, 2018 01:49 AM

    Hi Kajal,

    Following script can be helpful for you.

     

    <core:new className="java.util.Date" var="currentDate"/>
    <core:new className="java.text.SimpleDateFormat" var="sdFmt"><core:arg type="java.lang.String" value="yyyy-MM-dd'T'HH:mm:ss"/></core:new>
    <gel:forEach select="$ProjectNode//Resources/Resource" var="OuterNode">
    <gel:set select="$OuterNode/@availTo" value="${sdFmt.format(currentDate)}"/>
    <gel:forEach select="$OuterNode//AllocCurve/Segment" var="InnerNode">
    <gel:set asString="true" select="$InnerNode/@start" var="SegmentStartDate_str"/>
    <core:set var="SegmentStartDate" value="${sdFmt.parse(SegmentStartDate_str)}"/>

    <gel:set asString="true" select="$InnerNode/@finish" var="SegmentFinishDate_str"/>
    <core:set var="SegmentFinishDate" value="${sdFmt.parse(SegmentFinishDate_str)}"/>

    <core:if test="${SegmentStartDate.compareTo(currentDate)>0}">
    <gel:set select="$InnerNode/@sum" value="${0}"/>
    </core:if>
    <core:if test="${(currentDate.compareTo(SegmentStartDate)>0)}">
    <core:if test="${(SegmentFinishDate.compareTo(currentDate)>0)}">

    <gel:set select="$InnerNode/@finish" value="${sdFmt.format(currentDate)}"/>
    <gel:parse var="RemaingSegment_xml">
    <Segment finish="${SegmentFinishDate_str}" start="${sdFmt.format(currentDate)}" sum="0.00"/>
    </gel:parse>

    <gel:set insert="true" select="$OuterNode//AllocCurve" value="${RemaingSegment_xml}"/>
    </core:if>
    </core:if>
    </gel:forEach>