Parsing Calendar blob from Oracle Primavera using Javascript

661 Views Asked by At

Oracle Primavera stores Calendar data as blob in base64 encoded format, which when decoded gives the following content,

(0||CalendarData()( (0||DaysOfWeek()( (0||1()()) (0||2()( (0||0(s|08:00|f|16:00)()))) (0||3()( (0||0(s|08:00|f|16:00)()))) (0||4()( (0||0(s|08:00|f|16:00)()))) (0||5()( (0||0(s|08:00|f|16:00)()))) (0||6()( (0||0(s|08:00|f|16:00)()))) (0||7()()))) (0||VIEW(ShowTotal|Y)()) (0||Exceptions()( (0||0(d|39814)()) (0||1(d|39815)()) (0||2(d|39818)()) (0||3(d|39819)()) (0||4(d|39820)()) (0||5(d|39821)()) (0||6(d|39822)()) (0||7(d|39825)()) (0||8(d|39826)()) (0||9(d|39827)()) (0||10(d|39828)()) (0||11(d|39829)()) (0||12(d|39832)()) (0||13(d|39833)()) (0||14(d|39834)()) (0||15(d|39835)()) (0||16(d|39836)()) (0||17(d|39839)()) (0||18(d|39840)()) (0||19(d|39841)()) (0||20(d|39842)()) (0||21(d|39843)()) (0||22(d|39846)()) (0||23(d|39847)()) (0||24(d|39848)()) (0||25(d|39849)()) (0||26(d|39850)()) (0||27(d|39853)()) (0||28(d|39854)()) (0||29(d|39855)()) (0||30(d|39856)()) (0||31(d|39857)()) (0||32(d|39860)()) (0||33(d|39861)()) (0||34(d|39862)()) (0||35(d|39863)()) (0||36(d|39864)()) (0||37(d|39867)()) (0||38(d|39868)()) (0||39(d|39869)()) (0||40(d|39870)()) (0||41(d|39871)()) (0||42(d|39874)()) (0||43(d|39875)()) (0||44(d|39876)()) (0||45(d|39877)()) (0||46(d|39878)()) (0||47(d|39881)()) (0||48(d|39882)()) (0||49(d|39883)()) (0||50(d|39884)()) (0||51(d|39885)()) (0||52(d|39888)()) (0||53(d|39889)()) (0||54(d|39890)()) (0||55(d|39891)()) (0||56(d|39892)()) (0||57(d|39895)()) (0||58(d|39896)()) (0||59(d|39897)()) (0||60(d|39898)()) (0||61(d|39899)()) (0||62(d|39902)()) (0||63(d|39903)()) (0||64(d|39923)()) (0||65(d|39958)()) (0||66(d|39997)()) (0||67(d|40063)()) (0||68(d|40098)()) (0||69(d|40128)()) (0||70(d|40133)()) (0||71(d|40134)()) (0||72(d|40135)()) (0||73(d|40136)()) (0||74(d|40137)()) (0||75(d|40140)()) (0||76(d|40141)()) (0||77(d|40142)()) (0||78(d|40143)()) (0||79(d|40144)()) (0||80(d|40147)()) (0||81(d|40148)()) (0||82(d|40149)()) (0||83(d|40150)()) (0||84(d|40151)()) (0||85(d|40154)()) (0||86(d|40155)()) (0||87(d|40156)()) (0||88(d|40157)()) (0||89(d|40158)()) (0||90(d|40161)()) (0||91(d|40162)()) (0||92(d|40163)()) (0||93(d|40164)()) (0||94(d|40165)()) (0||95(d|40168)()) (0||96(d|40169)()) (0||97(d|40170)()) (0||98(d|40171)()) (0||99(d|40172)()) (0||100(d|40175)()) (0||101(d|40176)()) (0||102(d|40177)()) (0||103(d|40178)()) (0||104(d|40179)()) (0||105(d|40182)()) (0||106(d|40183)()) (0||107(d|40184)()) (0||108(d|40185)()) (0||109(d|40186)()) (0||110(d|40189)()) (0||111(d|40190)()) (0||112(d|40191)()) (0||113(d|40192)()) (0||114(d|40193)()) (0||115(d|40196)()) (0||116(d|40197)()) (0||117(d|40198)()) (0||118(d|40199)()) (0||119(d|40200)()) (0||120(d|40203)()) (0||121(d|40204)()) (0||122(d|40205)()) (0||123(d|40206)()) (0||124(d|40207)()) (0||125(d|40210)()) (0||126(d|40211)()) (0||127(d|40212)()) (0||128(d|40213)()) (0||129(d|40214)()) (0||130(d|40217)()) (0||131(d|40218)()) .....

How can I read the dates from this variable ? I need to convert it into JSON to be used by the script. I need all the exceptions - the value and date ( For instance, 131 is the exception and 40218 is the date ). Thank you,

2

There are 2 best solutions below

1
On BEST ANSWER

MPXJ reads this data. The relevant code can be found starting here https://github.com/joniles/mpxj/blob/master/src/net/sf/mpxj/primavera/PrimaveraReader.java#L181 which I suspect you can translate easily enough into Javascript.

0
On

This is how I did this in PHP Parse the data with a nested parenthesis class

https://gist.github.com/Xeoncross/4710324

Then deal with the time intervals

if( preg_match('~^s\|([0-9]+):([0-9]+)\|f\|([0-9]+):([0-9]+)$~', $string, $match) )
{   // Start and finish times
    $interval[] = array(
        's' => array(
            't' => $match[1].':'.$match[2],
            'h' => (int)$match[1],
            'm' => (int)$match[2],
        ),
        'f' => array(
            't' => $match[3].':'.$match[4],
            'h' => (int)$match[3],
            'm' => (int)$match[4],
        )
    );
}