source: ComponentRegistry/branches/jeaferversion/ComponentBrowserGui/src/main/flex/clarin/cmdi/componentregistry/common/CommentDescription.as @ 1636

Last change on this file since 1636 was 1636, checked in by jeafer, 13 years ago

Jean-Charles branch ComponentBrowserGui commit1,
Changes regarding comment on the ComponentBrowserGui.

Starting to implement classes for Comment visualisation
CommentInfoPage? and CommentXmlPanel?
CommentService? (List and info)
Comment and CommentDescription?
Update on InfoPage?

File size: 2.1 KB
Line 
1package clarin.cmdi.componentregistry.common {
2        import clarin.cmdi.componentregistry.services.Config;
3       
4        import mx.formatters.DateFormatter;
5       
6        [Bindable]
7        public class CommentDescription {
8               
9                public var id:String;
10                public var componentId:String;
11                public var profileId:String;
12                public var description:String;
13                public var creatorName:String;
14                public var dataUrl:String;
15                public var isProfile:Boolean;
16                public var registrationDate:String;
17                public var registrationDateValue:Date;
18               
19                public function CommentDescription() {
20                }
21               
22                private function create(comment:XML, infoUrl:String, isProfileValue:Boolean):void {
23                        this.id = comment.id;
24                        this.componentId = comment.componentId;
25                        this.profileId = comment.profileId;
26                        this.description = comment.description;
27                        this.registrationDate = convertDate(comment.registrationDate);
28                        this.creatorName = comment.creatorName;
29                        this.dataUrl = infoUrl + comment.id
30                        this.isProfile = isProfileValue;
31                }
32
33                /**
34                 * getting ISO-8601 (GMT/UTC timezone) dates from the server. Need to convert this, flex does not support ISO-8601 times out of the box.
35                 */
36                private function convertDate(dateString:String):String {
37                        var validator:DateFormatter = new DateFormatter();
38                        var s:String = parseDate(dateString);
39                        var n:Number = Date.parse(s);
40                        this.registrationDateValue = new Date(n);
41                        var result:String;
42                        if (isNaN(n)) {
43                                trace("cannot convert date: " + dateString);
44                                result = dateString;
45                        } else {
46                                validator.formatString = "DD MMMM YYYY H:NN:SS"; //e.g. 02 December 2009 13:48:39
47                                result = validator.format(registrationDateValue);
48                        }
49                        return result;
50                }
51               
52                public static function parseDate(value:String):String {
53                        var dateStr:String = value;
54                        dateStr = dateStr.replace(/-/g, "/");
55                        dateStr = dateStr.replace("T", " ");
56                        dateStr = dateStr.replace("+00:00", " GMT-0000");
57                        return dateStr;
58                }
59               
60                public function createComment(comment:XML):void {
61                        if(isProfile){
62                        return create(comment, Config.instance.commentProfileInfoUrl, true);
63                        } else {
64                        return create(comment, Config.instance.commentComponentInfoUrl, false);
65                        }
66                }
67
68        }
69}
Note: See TracBrowser for help on using the repository browser.