Changeset 2259


Ignore:
Timestamp:
09/27/12 16:38:55 (12 years ago)
Author:
olhsha
Message:

safari still duplicates an item in url (experimenting with removing guid did not help), with the reading from a file everything is ok. The date sorting is fixed in comments. But now there is a problem with the date comparison in Abstract descriptions

Location:
ComponentRegistry/branches/ComponentRegistry-1.13.0-olha/ComponentRegistry/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/branches/ComponentRegistry-1.13.0-olha/ComponentRegistry/src/main/binding/rss/rss-2_0.xsd

    r2252 r2259  
    7676                </xs:annotation>
    7777            </xs:element>
    78             <xs:element name="description" type="xs:string" minOccurs="0">
    79                 <xs:annotation>
    80                     <xs:documentation>The item synopsis.</xs:documentation>
    81                 </xs:annotation>
    82             </xs:element>
    8378            <xs:element name="link" type="xs:anyURI" minOccurs="0">
    8479            </xs:element>
     80            <xs:element name="description" type="xs:string" minOccurs="0">
     81                <xs:annotation>
     82                    <xs:documentation>The item synopsis.</xs:documentation>
     83                </xs:annotation>
     84            </xs:element>
    8585            <xs:element name="category" type="Category" minOccurs="0">
    8686                <xs:annotation>
     
    123123                </xs:annotation>
    124124            </xs:element>
     125           
    125126            <xs:element name="link" type="xs:anyURI">
    126127                <xs:annotation>
     
    128129                </xs:annotation>
    129130            </xs:element>
     131           
    130132            <xs:element name="description" type="xs:string">
    131133                <xs:annotation>
     
    133135                </xs:annotation>
    134136            </xs:element>
     137           
    135138            <xs:element name="language" type="xs:language" minOccurs="0">
    136139                <xs:annotation>
  • ComponentRegistry/branches/ComponentRegistry-1.13.0-olha/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/RssCreator.java

    r2256 r2259  
    8181    }
    8282
     83    public String getTitle(){
     84        return this.title;
     85    }
     86   
    8387    /**
    8488     * Sets the value of the link property.
     
    9195    }
    9296
     97    public String getLink(){
     98        return this.link;
     99    }
     100     
    93101    /**
    94102     * Sets the value of the description property.
  • ComponentRegistry/branches/ComponentRegistry-1.13.0-olha/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/model/AbstractDescription.java

    r2221 r2259  
    55import java.util.Comparator;
    66import java.util.Date;
     7import javax.xml.bind.DatatypeConverter;
    78
    89import javax.xml.bind.annotation.XmlAccessType;
     
    186187        //compare two components by the date of registration
    187188        // the dates, which are strings accrording to  ISO 8601, compared lexicographically
    188        
     189    @Override   
    189190        public int compare(AbstractDescription o1, AbstractDescription o2) {
    190191           
    191192            int result = 0;
    192              
    193             DateFormat df = DateFormat.getDateTimeInstance();
    194            
    195             try{
    196             Date d1 = df.parse(o1.getRegistrationDate());
    197             Date d2 = df.parse(o2.getRegistrationDate());
    198            
    199             result = d1.compareTo(d2);
    200            
    201             } catch (ParseException pe)  {return 0;};
    202            
    203            
     193           
     194            Date d1 = DatatypeConverter.parseDateTime(o1.getRegistrationDate()).getTime();
     195            Date d2 = DatatypeConverter.parseDateTime(o2.getRegistrationDate()).getTime();
     196           
     197            result = d2.compareTo(d1);
    204198           
    205199            return result;
  • ComponentRegistry/branches/ComponentRegistry-1.13.0-olha/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/model/Comment.java

    r2229 r2259  
    11package clarin.cmdi.componentregistry.model;
    22
     3import java.text.DateFormat;
    34import java.text.ParseException;
     5import java.util.Comparator;
    46import java.util.Date;
     7import javax.xml.bind.DatatypeConverter;
    58import javax.xml.bind.annotation.XmlAccessType;
    69import javax.xml.bind.annotation.XmlAccessorType;
     
    132135        return com;
    133136    }
     137   
     138   
     139    public static final Comparator<Comment> COMPARE_ON_DATE = new Comparator<Comment>() {
     140       
     141        //compare two commments by the date of registration
     142        // the dates, which are strings accrording to  ISO 8601, compared lexicographically
     143    @Override   
     144    public int compare(Comment o1, Comment o2) {
     145           
     146            int result = 0;
     147           
     148            Date d1 = DatatypeConverter.parseDateTime(o1.getCommentDate()).getTime();
     149            Date d2 = DatatypeConverter.parseDateTime(o2.getCommentDate()).getTime();
     150           
     151            result = d2.compareTo(d1);
     152           
     153            return result;
     154        }
     155    };
    134156}
  • ComponentRegistry/branches/ComponentRegistry-1.13.0-olha/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java

    r2257 r2259  
    10431043        // ?? this is for debugging. But, anyway, how to get all the profiles without the need to type them in?
    10441044        // what if a user do not remember his/her id of profile?
    1045         /* grabbing all registered profile names from the register and outputting them  on the tomcat terminal */
    1046         List<ProfileDescription> lprfaux = getRegisteredProfiles(userspace, true);
     1045        // grabbing all registered profile names from the register and outputting them  on the tomcat terminal */
     1046        /*List<ProfileDescription> lprfaux = getRegisteredProfiles(userspace, true);
    10471047       
    10481048        for (ProfileDescription currentProfile : lprfaux) {
     
    10501050            LOG.debug(currentProfileId);
    10511051        }
    1052         /* end of grabbing */
    1053 
    1054 
    1055         // TODO: add sorting !
     1052        */
     1053        // end of grabbing */
     1054
     1055
    10561056
    10571057        final Principal principal = security.getUserPrincipal();
     
    10591059
    10601060        String baseUri = getApplicationBaseURI()+"/";
    1061         LOG.debug("Basis uri "+baseUri);
    10621061       
    10631062       
     
    10661065        if (comments.size()<limitInt) {limitInt = comments.size();};
    10671066        List<Comment> sublist = comments.subList(0, limitInt);
    1068        
    1069        
     1067        Collections.sort(sublist, Comment.COMPARE_ON_DATE);
     1068       
     1069        for (Comment comm: sublist){
     1070            LOG.debug(comm.getCommentDate());
     1071        }
    10701072         
    10711073        RssCreatorComments instance = new RssCreatorComments(baseUri);
    10721074        instance.setFlagIsFromProfile(true);
    10731075        instance.setDescription("Update of comments for current profile");
    1074         instance.setTitle("Comments feed for the profile \""+
     1076       
     1077        String hrefPostfix = "&view=comments";
     1078        String hrefInfix = "?item=";
     1079        instance.setLink(baseUri+hrefInfix+profileId+hrefPostfix);
     1080       
     1081        String title="Comments feed for the profile \""+
    10751082                getRegistry(getStatus(userspace)).getProfileDescription(profileId).getName()+
    1076                 "\" ");
    1077         instance.setLink(baseUri+"profiles/rss");
     1083                "\" ";
     1084        instance.setTitle(title);
     1085       
    10781086       
    10791087        Rss result = instance.makeRss(sublist);
    1080        
    1081        
    10821088       
    10831089        // testing stuff
  • ComponentRegistry/branches/ComponentRegistry-1.13.0-olha/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/RssCreatorCommentsTest.java

    r2256 r2259  
    124124            System.out.println(resitems.get(i).getPubDate());
    125125            System.out.println(resitems.get(i).getDescription());
     126            System.out.println(resitems.get(i).getLink());
    126127            System.out.println(resitems.get(i).getGuid().getValue());
    127128            System.out.println("  ");
Note: See TracChangeset for help on using the changeset viewer.