← Back to team overview

dhis2-devs-core team mailing list archive

Re: Period conversion for ADX

 

I was looking at that but I don't think it fits really.  I don't so
much want to parse a date as to parse a period.  So I am thinking of
one of two possible methods:

1.  Period parseAdxPeriod(String periodString)

or

2.  String adxPeridToDxf(String periodString)

I'd do the first if I am going to save the datavalueset set directly;
or the second if I take the more indirect route of converting the
stream to a dxf2 stream and then just reusing the existing
StreamingDatavalueSet save method.  Haven't decided which yet :-(  But
I think the methods belong somewhere amongst the Period* classes.

On 10 June 2015 at 15:25, Morten Olav Hansen <mortenoh@xxxxxxxxx> wrote:
> What about DateUtils? We already have DateUtils.parseDate which we use a
> lod, parseAdxDate?
>
> --
> Morten
>
> On Wed, Jun 10, 2015 at 9:17 PM, Bob Jolliffe <bobjolliffe@xxxxxxxxx> wrote:
>>
>> Hi
>>
>> I am just looking at the task of implementing adx data import and the
>> first small thing to tackle is parsing period types.  You can see from
>> the sample here
>>
>> (https://github.com/dhis2/adx/blob/master/IHE/samples/adx_data_sample1.xml)
>> that the string form of a period in adx is of the form:
>>
>> 2010-01-01/P1M
>>
>> which is equivalent to the month of January 2010 (or 201001 in our
>> current representation).  More generally you can say this is
>>
>> <start date>/<duration>
>>
>> So the parser code should first look at the part of the string
>> beginning with P and determine the period duration from that.  Some
>> examples:
>>
>> P1M - monthly
>> P7D - weekly
>> P1Y - yearly
>> P6M - six monthly
>> P1Q - quarterly
>> P2Y - 2 yearly
>> etc
>>
>> (Though note P1Y could also indicate a financial period type.  eg
>> 2010-04-01/P1Y would correspond to our April Financial year)
>>
>> I don't intend to build a generic iso8601 parser which can recognize
>> any permutation of allowable periods.  Just the subset which
>> corresponds to what we have.   I'm trying to figure out the best place
>> to put this parser - toss up between Period, PeriodType and
>> PeriodService (all have related code).  Does anyone see an obvious
>> preference?
>>
>> --
>> Mailing list: https://launchpad.net/~dhis2-devs-core
>> Post to     : dhis2-devs-core@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~dhis2-devs-core
>> More help   : https://help.launchpad.net/ListHelp
>
>


References