[Cosmo-dev] Re: [commits-cosmo] (travis) [4004]

Travis Vachon travis at osafoundation.org
Mon Apr 2 15:28:56 PDT 2007


@#$!#$

Eclipse let me commit with a blank commit message, so a combination  
of pilot and technical error messed this one up. Sorry about that!

Commit message should have been:

Calendar can display events sucked in from atom service.

Whoo hoo!

-Travis


On Apr 2, 2007, at 3:27 PM, svncheckin at osafoundation.org wrote:

> Revision
> 4004
> Author
> travis
> Date
> 2007-04-02 15:27:13 -0700 (Mon, 02 Apr 2007)
> Log Message
>
> Modified Paths
>
> cosmo/branches/atomwebui/cosmo/src/main/webapp/js/cosmo/datetime/ 
> Date.js
> cosmo/branches/atomwebui/cosmo/src/main/webapp/js/cosmo/view/cal.js
> Added Paths
>
> cosmo/branches/atomwebui/cosmo/src/main/webapp/js/cosmo/service/ 
> atom.js
> Removed Paths
>
> cosmo/branches/atomwebui/cosmo/src/main/webapp/js/cosmo/service/ 
> atom_service_impl.js
> Diff
>
> Modified: cosmo/branches/atomwebui/cosmo/src/main/webapp/js/cosmo/ 
> datetime/Date.js (4003 => 4004)
>
> --- cosmo/branches/atomwebui/cosmo/src/main/webapp/js/cosmo/ 
> datetime/Date.js	2007-04-02 22:06:09 UTC (rev 4003)
> +++ cosmo/branches/atomwebui/cosmo/src/main/webapp/js/cosmo/ 
> datetime/Date.js	2007-04-02 22:27:13 UTC (rev 4004)
> @@ -32,6 +32,19 @@
>  dojo.require("cosmo.util.debug");
>  dojo.require("cosmo.facade.pref");
>
> +cosmo.datetime.dateParts = {
> +    YEAR: "yyyy",
> +    QUARTER:  "q",
> +    MONTH: "m",
> +    YEAR: "y",
> +    DAY: "d",
> +    WEEKDAY: "w",
> +    WEEK: "ww",
> +    HOUR: "h",
> +    MINUTE: "n",
> +    SECOND: "s"
> +}
> +
>  cosmo.datetime.Date = function () {
>
>      var args = Array.prototype.slice.apply(arguments);
> Copied: cosmo/branches/atomwebui/cosmo/src/main/webapp/js/cosmo/ 
> service/atom.js (from rev 3993, cosmo/branches/atomwebui/cosmo/src/ 
> main/webapp/js/cosmo/service/atom_service_impl.js) (3993 => 4004)
>
> --- cosmo/branches/atomwebui/cosmo/src/main/webapp/js/cosmo/service/ 
> atom_service_impl.js	2007-04-02 18:31:44 UTC (rev 3993)
> +++ cosmo/branches/atomwebui/cosmo/src/main/webapp/js/cosmo/service/ 
> atom.js	2007-04-02 22:27:13 UTC (rev 4004)
> @@ -0,0 +1,282 @@
> +/*
> + * Copyright 2006 Open Source Applications Foundation
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,  
> software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or  
> implied.
> + * See the License for the specific language governing permissions  
> and
> + * limitations under the License.
> + */
> +
> +dojo.provide("cosmo.service.atom");
> +
> +dojo.require("cosmo.model");
> +dojo.require("cosmo.service.eim");
> +dojo.require("cosmo.util.auth");
> +dojo.require("dojo.date.serialize");
> +dojo.require("dojo.date.common");
> +
> +
> +dojo.declare("ParseError", [Error]);
> +
> +
> +
> +cosmo.service.atom = {
> +
> +    _wrapXMLHandlerFunctions: function (/*Object*/ hDict,
> +                                        /*function*/ xmlParseFunc){
> +            var self = this;
> +            var handlerDict = dojo.lang.shallowCopy(hDict);
> +            if (handlerDict.load){
> +                var old_load = handlerDict.load;
> +                handlerDict.load = function(type, data, evt){
> +
> +                    var parsedCMPXML = xmlParseFunc.apply(self,  
> [evt.responseXML])
> +
> +                    old_load(type, parsedCMPXML, evt);
> +                }
> +            }
> +			// Don't mess with "error". These responses shouldn't be XML.
> +			// Don't mess with "handle". This is a "don't mess with my  
> stuff" handler.
> +			return handlerDict;
> +        },
> +
> +
> +    getDefaultEIMRequest: function (/*Object*/ handlerDict,
> +                                    /*boolean?*/ sync){
> +		
> +        var request = cosmo.util.auth.getAuthorizedRequest()
> +
> +        request.load = handlerDict.load;
> +        request.handle =  handlerDict.handle;
> +        request.error = handlerDict.error;
> +        request.transport = "XMLHTTPTransport";
> +        request.contentType =  'text/xml';
> +        request.sync = handlerDict.sync;
> +        request.headers["Cache-Control"] = "no-cache";
> +        request.headers["Pragma"] = "no-cache";
> +        // Fight the dark powers of IE's evil caching mechanism
> +        if (document.all) {
> +            request.preventCache = true;
> +        }
> +
> +        return request;
> +    },
> +
> +    getEvents: function(uid, kwArgs){
> +
> +       if (!kwArgs){
> +           kwArgs = {};
> +       }
> +
> +       var returnValue;
> +       if (kwArgs.sync){
> +
> +           kwArgs.handle = kwArgs.load = function(type, data, xhr){
> +                               returnValue = data;
> +                           };
> +       }
> +
> +       kwArgs = this._wrapXMLHandlerFunctions(kwArgs,  
> this.atomToItemList);
> +
> +       var request = this.getDefaultEIMRequest(kwArgs);
> +       request.url = "/cosmo/atom/collection/" + uid + "/full";
> +       request.method = "GET";
> +
> +       dojo.io.bind(request);
> +       if (kwArgs.sync){
> +           return returnValue;
> +       }
> +    },
> +
> +    atomToItemList: function(atomXml){
> +        if (!atomXml){
> +            throw new ParseError("Cannot parse null, undefined, or  
> false");
> +        }
> +
> +        var entries = atomXml.getElementsByTagName("entry");
> +        var items = [];
> +        for (var i = 0; i < entries.length; i++){
> +            var c = entries[i].getElementsByTagName("content")[0];
> +            var content = c.firstChild.nodeValue;
> +            items.push(this.recordSetToObject(eval("(" + content +  
> ")")));
> +        }
> +        return items;
> +    },
> +
> +    objectToRecordSet: function(object){
> +        with (cosmo.service.eim.constants){
> +            return {
> +                uid: object.uid,
> +                records: {
> +                    item: this.objectToItemRecord(object),
> +                    note: this.objectToNoteRecord(object),
> +                    event: this.objectToEventRecord(object)
> +                }
> +            }
> +        }
> +    },
> +
> +    objectToItemRecord: function(object){
> +        with (cosmo.service.eim.constants){
> +            return {
> +                prefix: prefix.ITEM,
> +                ns: ns.ITEM,
> +                keys: {
> +                    uuid: [type.TEXT, object.uid]
> +                },
> +                fields: {
> +                    title: [type.TEXT, object.title]
> +                }
> +            }
> +        }
> +    },
> +
> +    objectToNoteRecord: function(object){
> +        with (cosmo.service.eim.constants){
> +            return {
> +                prefix: prefix.NOTE,
> +                ns: ns.NOTE,
> +                keys: {
> +                    uuid: [type.TEXT, object.uid]
> +                },
> +                fields: {
> +                    body: [type.TEXT, object.body]
> +                }
> +            }
> +        }
> +    },
> +
> +    objectToEventRecord: function(object){
> +        with (cosmo.service.eim.constants){
> +            return {
> +                prefix: prefix.EVENT,
> +                ns: ns.EVENT,
> +                keys: {
> +                    uuid: [type.TEXT, object.uid]
> +                },
> +                fields: {
> +                    body: [type.TEXT, object.description],
> +                    dtstart: [type.TEXT, this.toRfc3339 
> (object.start)],
> +                    duration: [type.TEXT,  
> cosmo.datetime.getIso8601Duration(object.start, object.end)],
> +                    anytime: [type.TEXT, object.anyTime],
> +
> +                    rrule: [type.TEXT, ""],//FIXME
> +                    status: [type.TEXT, object.status],
> +                    location: [type.TEXT, object.location]
> +                }
> +            }
> +        }
> +
> +    },
> +
> +    recordSetToObject: function(recordSet){
> +
> +        var uid  = recordSet.uuid;
> +        var title;
> +        var description;
> +        var start;
> +        var end;
> +        var allDay;
> +        var pointInTime;
> +        var anyTime;
> +        var recurrenceRule;
> +        var status;
> +        var masterEvent;
> +        var instance;
> +        var instanceDate;
> +        var loc;
> +
> +        for (recordName in recordSet.records){
> +        with (cosmo.service.eim.constants){
> +
> +           var record = recordSet.records[recordName]
> +
> +           if (recordName == prefix.ITEM){
> +               title = record.fields.title[1];
> +           }
> +
> +           if (recordName == prefix.NOTE){
> +               description = record.fields.body[1];
> +           }
> +
> +           if (recordName == prefix.EVENT){
> +
> +               start = this.fromEimDate(record.fields.dtstart[1]);
> +
> +               end = dojo.date.addIso8601Duration(start.clone(),
> +                                                   
> record.fields.duration[1]);
> +
> +               anyTime = record.fields.anytime?  
> record.fields.anytime[1]: 0;
> +
> +               recurrenceRule = null; //FIXME
> +
> +               status = record.fields.status[1];
> +
> +               masterEvent = null; //FIXME
> +
> +               instance = null; //FIXME
> +
> +               instanceDate = null; //FIXME
> +
> +               loc = record.fields.location[1];
> +           }
> +           }
> +        }
> +
> +        return calEventData = new cosmo.model.CalEventData(
> +           uid, title, description, start, end, allDay,
> +           pointInTime, anyTime, recurrenceRule, status,
> +           masterEvent, instance, instanceDate, loc);
> +
> +    },
> +
> +    fromEimDate: function(dateString){
> +        var date = dateString.split(":")[1];
> +        return new cosmo.datetime.Date(dojo.date.fromIso8601(date));
> +
> +    },
> +
> +    handlerWrapper: dojo.lang.hitch(this, function(type, data, xhr){
> +                    var o = this.atomToItemList(xhr.responseXML);
> +                    dojo.debug(o);
> +                }),
> +
> +    test: function(){
> +        dojo.debug(this.getEvents("1ea37892-a753-403e- 
> b641-7d19594860e7", {sync: true}));
> +    }
> +}
> +
> +
> +
> +dojo.date.addIso8601Duration = function (date, duration){
> +
> +    var r = "^P(?:(?:([0-9\.]*)Y)?(?:([0-9\.]*)M)?(?:([0-9\.]*)D)? 
> (?:T(?:([0-9\.]*)H)?(?:([0-9\.]*)M)?(?:([0-9\.]*)S)?)?)(?:([0-9/.]*) 
> W)?$"
> +    var dateArray = duration.match(r).slice(1);
> +    with(cosmo.datetime.dateParts){
> +        dateArray[0]? date.add(YEAR, dateArray[0]) : null;
> +        dateArray[1]? date.add(MONTH, dateArray[1]) : null;
> +        dateArray[2]? date.add(DAY, dateArray[2]) : null;
> +        dateArray[3]? date.add(HOUR, dateArray[3]) : null;
> +        dateArray[4]? date.add(MINUTE, dateArray[4]) : null;
> +        dateArray[5]? date.add(SECOND, dateArray[5]) : null;
> +    }
> +
> +    return date;
> +}
> +
> +cosmo.datetime.Date.getIso8601Duration = function(dt1, dt2){
> +   return this.diff('yyyy', dt1, dt2) +
> +          this.diff('m', dt1, dt2) +
> +          this.diff('d', dt1, dt2) +
> +          'T' +
> +          this.diff('h', dt1, dt2) +
> +          this.diff('n', dt1, dt2) +
> +          this.diff('s', dt1, dt2);
> +}
> Deleted: cosmo/branches/atomwebui/cosmo/src/main/webapp/js/cosmo/ 
> service/atom_service_impl.js (4003 => 4004)
>
> --- cosmo/branches/atomwebui/cosmo/src/main/webapp/js/cosmo/service/ 
> atom_service_impl.js	2007-04-02 22:06:09 UTC (rev 4003)
> +++ cosmo/branches/atomwebui/cosmo/src/main/webapp/js/cosmo/service/ 
> atom_service_impl.js	2007-04-02 22:27:13 UTC (rev 4004)
> @@ -1,193 +0,0 @@
> -/*
> - * Copyright 2006 Open Source Applications Foundation
> - *
> - * Licensed under the Apache License, Version 2.0 (the "License");
> - * you may not use this file except in compliance with the License.
> - * You may obtain a copy of the License at
> - *
> - *     http://www.apache.org/licenses/LICENSE-2.0
> - *
> - * Unless required by applicable law or agreed to in writing,  
> software
> - * distributed under the License is distributed on an "AS IS" BASIS,
> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or  
> implied.
> - * See the License for the specific language governing permissions  
> and
> - * limitations under the License.
> - */
> -
> -dojo.provide("cosmo.service.atom_service_impl");
> -
> -dojo.require("cosmo.model");
> -dojo.require("cosmo.service.eim");
> -
> -dojo.declare("ParseError", [Error]);
> -
> -
> -
> -cosmo.service.atom = {
> -
> -
> -    atomToItemList: function(atomXml){
> -        if (!object){
> -            throw new ParseError("Cannot parse null, undefined, or  
> false");
> -        }
> -
> -        var entries = atomXml.getElementsByTagName("entry");
> -        var items;
> -        for (var i = 0; i < entries.length; i++){
> -            var content = entries[i].getElementsByTagName 
> ("content")[0].innerHTML;
> -            items.push(recordSetToObject(eval(content)));
> -        }
> -    },
> -
> -    objectToRecordSet: function(object){
> -        with (cosmo.service.eim.constants){
> -            recordSet = {
> -                uid: object.uid,
> -                records: {
> -                    item: this.objectToItemRecord(object),
> -                    note: this.objectToNoteRecord(object),
> -                    event: this.objectToEventRecord(object)
> -                }
> -            }
> -        }
> -    },
> -
> -    objectToItemRecord: function(object){
> -        with (cosmo.service.eim.constants){
> -            return {
> -                prefix: prefix.ITEM,
> -                ns: ns.ITEM,
> -                keys: {
> -                    uuid: [type.TEXT, object.uid]
> -                },
> -                fields: {
> -                    title: [type.TEXT, object.title]
> -                }
> -            }
> -        }
> -    },
> -
> -    objectToNoteRecord: function(object){
> -        with (cosmo.service.eim.constants){
> -            return {
> -                prefix: prefix.NOTE,
> -                ns: ns.NOTE,
> -                keys: {
> -                    uuid: [type.TEXT, object.uid]
> -                },
> -                fields: {
> -                    body: [type.TEXT, object.body]
> -                }
> -            }
> -        }
> -    },
> -
> -    objectToEventRecord: function(object){
> -        with (cosmo.service.eim.constants){
> -            return {
> -                prefix: prefix.EVENT,
> -                ns: ns.EVENT,
> -                keys: {
> -                    uuid: [type.TEXT, object.uid]
> -                },
> -                fields: {
> -                    body: [type.TEXT, object.description],
> -                    dtstart: [type.TEXT, this.toRfc3339 
> (object.start)],
> -                    duration: [type.TEXT,  
> cosmo.datetime.getIso8601Duration(object.start, object.end)],
> -                    anytime: [type.TEXT, object.anyTime],
> -
> -                    rrule: [type.TEXT, ""],//FIXME
> -                    status: [type.TEXT, object.status],
> -                    location: [type.TEXT, object.location]
> -                }
> -            }
> -        }
> -
> -    },
> -
> -    recordSetToObject: function(recordSet){
> -        var uid  = recordSet.uuid;
> -        var title;
> -        var description;
> -        var start;
> -        var end;
> -        var allDay;
> -        var pointInTime;
> -        var anyTime;
> -        var recurrenceRule;
> -        var status;
> -        var masterEvent;
> -        var instance;
> -        var instanceDate;
> -        var loc;
> -
> -        for (record in recordSet){
> -
> -           if (record == this.ITEM_PREFIX){
> -               title = record.fields.title[1];
> -           }
> -
> -           if (record == this.NOTE_PREFIX){
> -               description = record.fields.body[1];
> -           }
> -
> -           if (record == this.EVENT_PREFIX){
> -               start = this.fromEimDate(record.fields.dtstart[1]);
> -
> -               end = dojo.date.addIso8601Duration(start.clone());
> -
> -               anyTime = record.fields.anytime[1];
> -
> -               recurrenceRule = null; //FIXME
> -
> -               status = record.fields.status[1];
> -
> -               masterEvent = null; //FIXME
> -
> -               instance = null; //FIXME
> -
> -               instanceDate = null; //FIXME
> -
> -               loc = record.fields.location[1];
> -           }
> -        }
> -
> -        return calEventData = new cosmo.model.CalEventData(
> -           uid, title, description, start, end, allDay,
> -           pointInTime, anyTime, recurrenceRule, status,
> -           masterEvent, instance, instanceDate, loc);
> -
> -    },
> -
> -    fromEimDate: function(dateString){
> -        return cosmo.model.Date(dojo.date.fromIso8601(dateString));
> -    }
> -}
> -
> -
> -
> -dojo.date.addIso8601Duration = function (date, duration){
> -
> -    var r = "^P(?:(?:([0-9\.]*)Y)?(?:([0-9\.]*)M)?(?:([0-9\.]*)D)? 
> (?:T(?:([0-9\.]*)H)?(?:([0-9\.]*)M)?(?:([0-9\.]*)S)?)?)(?:([0-9/.]*) 
> W)?$"
> -    var dateArray = duration.match(r).slice(1);
> -    with(dojo.date.dateParts){
> -        dateArray[0]? dojo.date.add(date, YEAR, dateArray[0]) : null;
> -        dateArray[1]? dojo.date.add(date, MONTH, dateArray[1]) :  
> null;
> -        dateArray[2]? dojo.date.add(date, DAY, dateArray[2]) : null;
> -        dateArray[3]? dojo.date.add(date, HOUR, dateArray[3]) : null;
> -        dateArray[4]? dojo.date.add(date, MINUTE, dateArray[4]) :  
> null;
> -        dateArray[5]? dojo.date.add(date, SECOND, dateArray[5]) :  
> null;
> -    }
> -
> -    return date;
> -}
> -
> -cosmo.datetime.Date.getIso8601Duration = function(dt1, dt2){
> -   return this.diff('yyyy', dt1, dt2) +
> -          this.diff('m', dt1, dt2) +
> -          this.diff('d', dt1, dt2) +
> -          'T' +
> -          this.diff('h', dt1, dt2) +
> -          this.diff('n', dt1, dt2) +
> -          this.diff('s', dt1, dt2);
> -}
> Modified: cosmo/branches/atomwebui/cosmo/src/main/webapp/js/cosmo/ 
> view/cal.js (4003 => 4004)
>
> --- cosmo/branches/atomwebui/cosmo/src/main/webapp/js/cosmo/view/ 
> cal.js	2007-04-02 22:06:09 UTC (rev 4003)
> +++ cosmo/branches/atomwebui/cosmo/src/main/webapp/js/cosmo/view/ 
> cal.js	2007-04-02 22:27:13 UTC (rev 4004)
> @@ -1132,9 +1132,15 @@
>          // Load the array of events
>          // ======================
>          try {
> -            eventLoadList = collection.conduit.getEvents(
> -                collection.collection.uid, s, e,
> -                collection.transportInfo);
> +            dojo.require("cosmo.service.atom");
> +            eventLoadList =
> +                    cosmo.service.atom.getEvents 
> (collection.collection.uid, {sync: true});
> +            dojo.debug(eventLoadList[0])
> +
> +            //collection.conduit.getEvents(
> +            //collection.collection.uid, s, e,
> +            //collection.transportInfo);
> +            //debugger
>
>          }
>          catch(e) {
>
> _______________________________________________
> Commits-Cosmo mailing list
> Commits-Cosmo at osafoundation.org
> http://lists.osafoundation.org/cgi-bin/mailman/listinfo/commits-cosmo

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osafoundation.org/pipermail/cosmo-dev/attachments/20070402/a6c09e69/attachment.html


More information about the cosmo-dev mailing list