Changeset 2475


Ignore:
Timestamp:
Jul 31, 2006, 5:59:05 PM (17 years ago)
Author:
dominic
Message:

Fixed issues from feedbacks: code comments and patterns, standards fixes etc for annotation types category implementation

Location:
branches/dominic_annotations
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • branches/dominic_annotations/src/core/net/sf/basedb/core/AnnotationType.java

    r2410 r2475  
    361361  {
    362362    return getData().getDefaultValue();
     363   
    363364  }
    364365  /**
  • branches/dominic_annotations/src/core/net/sf/basedb/core/AnnotationTypeCategory.java

    r2400 r2475  
    2525package net.sf.basedb.core;
    2626
    27 import java.util.Collections;
    28 import java.util.Set;
    29 
    30 
    3127import net.sf.basedb.core.data.AnnotationTypeCategoryData;
    32 import net.sf.basedb.core.query.EntityQuery;
    3328import net.sf.basedb.core.query.Hql;
    3429import net.sf.basedb.core.query.Restrictions;
     
    3934  annotation type category contains other (@link AnnotationTypes} items
    4035  <p>
    41   An annotation type can belong to more than one annotation type catgeory.
     36  An annotation type can belong to more than one annotation type category.
    4237  Therefore a many to many relationship exist between <code>Annotationtype</code> and
    4338  <code>AnnotationTypeCategory</code>.
     
    6661    @param annotationtypecategory
    6762   */
    68   public AnnotationTypeCategory(AnnotationTypeCategoryData annotationtypecategory) {
     63  AnnotationTypeCategory(AnnotationTypeCategoryData annotationtypecategory) {
    6964    super(annotationtypecategory);
    7065  }
     
    8782  /**
    8883    Gets an <code>AnnotationTypeCategory</code> item when you know the id.
    89 
    9084    @param dc The <code>DbControl</code> which will be used for
    9185    permission checking and database access
     
    149143  /**
    150144    Add an annotationtype to this category
    151     @param annotationtype to add
     145    @param annotation type to add
    152146    @throws PermissionDeniedException If the logged in user doesn't
    153147      have {@link Permission#WRITE} permission for the annotationtype category and
     
    157151   */
    158152   public void addAnnotationType(AnnotationType annotationtype)
    159     throws InvalidDataException
     153    throws InvalidDataException, PermissionDeniedException
    160154   {
    161155     checkPermission(Permission.WRITE);
     
    166160   
    167161   /**
    168     Remove an annotationtype from this category
     162    Remove an annotation type from this category
    169163    @param annotationtype to remove
    170164    @throws PermissionDeniedException If the logged in user doesn't
     
    212206     return query;
    213207   }
    214    
    215    /**
    216     Gets the categorydescription. This is simply a somewhat detailed description
    217     The user can choose not to give this detailed description.
    218     @return a (@link String) Object
    219   */
    220    
    221   public String getCategoryDescription()
    222   {
    223     return getData().getCategoryDescription().trim();
    224   }
    225  
    226   /**
    227    
    228    Sets the maximum length of the categorydescription property.
    229    Check the length against this value before calling
    230    {@link #setCategoryDescription(String)} to avoid exceptions
    231      
    232    */ 
    233   public static final int MAX_CATEGORYDESCRIPTION_LENGTH = AnnotationTypeCategoryData.MAX_CATEGORYDESCRIPTION_LENGTH;
    234  
    235   /**
    236     Sets the categorydescription for this <code>AnnotationTypeCategory</code>.
    237     @throws PermissionDeniedException If the logged in user doesn't have
    238       write permission
    239     @throws InvalidDataException If the new value is longer than
    240       {@link  #MAX_CATEGORYDESCRIPTION_LENGTH}
    241     @throws BaseException If there is another error
    242   */
    243   public void setCategoryDescription(String categoryDescription)
    244     throws PermissionDeniedException, InvalidDataException, BaseException
    245   {
    246     checkPermission(Permission.WRITE);
    247     getData().setCategoryDescription(
    248         StringUtil.setNullableString(
    249             categoryDescription,"categoryDescription",MAX_CATEGORYDESCRIPTION_LENGTH));
    250   }
    251  
    252 
    253208}
  • branches/dominic_annotations/src/core/net/sf/basedb/core/Install.java

    r2400 r2475  
    515515      createLabel("Biotin", "", rootUser, keyEveryoneUse);
    516516     
    517       //Annoattion type categories
     517      //Annotation type categories
    518518     
    519519      if (progress != null) progress.display((int)(18*progress_factor), "--Creating annotation type categories...");
    520       AnnotationTypeCategoryData categoryGeneral = createAnnotationTypeCategory("General", "Default category for annotation types.",
     520      AnnotationTypeCategoryData categoryGeneral = createAnnotationTypeCategory("General",
    521521          "This category holds annotation types that have not been classified into established groups",
    522522          rootUser,keyEveryoneUse );
    523       AnnotationTypeCategoryData categoryOther = createAnnotationTypeCategory("Other", "Other category for annotation types.",
    524           "This category holds annotation types that have not been classified into established groups",
    525           rootUser,keyEveryoneUse );
    526      
    527      
     523         
    528524      // Annotation types
    529525      Item[] wells = new Item[] { Item.WELL };
     
    533529        wells, useRadio, false, rootUser, keyEveryoneUse,categoryGeneral );
    534530      createAnnotationType("Bands", "", Type.STRING, 1, new String[] { "Not done", "Good", "Missing", "Multiple" },
    535         wells, useRadio, false, rootUser, keyEveryoneUse, categoryOther );
     531        wells, useRadio, false, rootUser, keyEveryoneUse, null );
    536532      createAnnotationType("Bacterial growth", "", Type.STRING, 1, new String[] { "Not done", "Yes", "No" },
    537         wells, useRadio, false, rootUser, keyEveryoneUse, categoryOther );
     533        wells, useRadio, false, rootUser, keyEveryoneUse, null );
    538534      createAnnotationType("Comment", "", Type.STRING, 1, null,
    539535        wells, null, false, rootUser, keyEveryoneUse, categoryGeneral );
     
    14871483    Create an {@link AnnotationTypeCategory}.
    14881484  */
    1489   private static AnnotationTypeCategoryData createAnnotationTypeCategory(String name, String categoryDescription,
    1490       String description, UserData owner, ItemKeyData shareTo)
     1485  private static AnnotationTypeCategoryData createAnnotationTypeCategory(String name, String description,
     1486      UserData owner, ItemKeyData shareTo)
    14911487  {
    14921488    org.hibernate.Transaction tx = null;
     
    15121508        atc.setName(name);
    15131509        atc.setDescription(description);
    1514         atc.setCategoryDescription(categoryDescription);
    15151510        atc.setOwner(owner);
    15161511        atc.setItemKey(shareTo);
  • branches/dominic_annotations/src/core/net/sf/basedb/core/data/AnnotationTypeCategoryData.java

    r2358 r2475  
    1 /* $Id: AnnotationTypeCategoryData.java 1 2006-04-17 Dominic Oyeniran $
     1/* $Id: AnnotationTypeCategoryData.java 1 2006-04-17 dominic $
    22
    33  Copyright (C) Authors contributing to this file.
     
    3838public class AnnotationTypeCategoryData 
    3939  extends CommonData
    40  
    4140
    4241{
    4342  public AnnotationTypeCategoryData()
    4443  {}
    45  
    46   public static int MAX_CATEGORYDESCRIPTION_LENGTH = 255;
    47   private String categoryDescription;
    48  
    49   /**
    50      Get the category description property.
    51      @hibernate.property column="`category_description`" type="string"
    52       length="255" not-null="false"
    53   */
    54   public String getCategoryDescription()
    55   {
    56     return categoryDescription;
    57   }
    58  
    59   public void setCategoryDescription(String categoryDescription)
    60   {
    61     this.categoryDescription = categoryDescription;
    62   }
    63  
    6444 
    6545  private Set<AnnotationTypeData> annotationTypes;
     
    8161    return annotationTypes;
    8262  }
    83   /*
    84     In this case, the set method() is private, so that hibernate can keep track
    85     of the objects it creates in the collection and only returns ,thru the get method(),
    86     this objects.
    87    */
     63 
    8864  void setAnnotationTypes(Set<AnnotationTypeData> annotationtypes)
    8965  {
     
    9167  }
    9268 
    93  
    9469}
  • branches/dominic_annotations/src/core/net/sf/basedb/core/data/AnnotationTypeData.java

    r2345 r2475  
    204204    this.enumerationValues = enumerationValues;
    205205  }
    206   /*
    207    * Newly added properties(fields) and mappings added by Dominic Oyeniran
    208    * for handling annotation categories.
    209    *
    210    */
     206 
    211207 
    212208  private Set<AnnotationTypeCategoryData> category;
     
    219215   */
    220216 
    221   Set<AnnotationTypeCategoryData> getCategory() {
     217  public Set<AnnotationTypeCategoryData> getCategory() {
    222218    if ( category==null)
    223219    {
     
    226222    return category;
    227223  }
    228   /*
    229    the set method() without scope resolution is private and this is done so that
    230    hibernate can keep track of the objects it creates in the collection
    231    and also can 'only' return this object thru the get method().
    232    */
     224 
    233225  void setCategory(Set<AnnotationTypeCategoryData> category) {
    234226    this.category = category;
    235227  }
    236  
    237    
     228     
    238229  private Set<ExperimentData> experiments;
    239230  /**
  • branches/dominic_annotations/src/test/TestAnnotationTypeCategory.java

    r2357 r2475  
    11/*
    2   $Id: TestAnnotationTypeCategory.java 1 2006-05-11 Dominic Oyeniran $
     2  $Id: TestAnnotationTypeCategory.java 1 2006-05-11 dominic $
    33
    44    Copyright (C) Authors contributing to this file.
     
    3838public class TestAnnotationTypeCategory {
    3939
    40   private static boolean works;
     40  static boolean works=true;
     41 
    4142 
    4243  /**
     
    4647    TestUtil.checkArgs(args);
    4748    TestUtil.begin();
    48     test_all();
     49    works=test_all();
    4950    TestUtil.stop();
    5051  }
     
    5455    works=true;
    5556    int categoryid= 0;
    56     write("+++++++++++++++Testing annotation types categories+++++++++++++++++");
     57    write("++Testing annotation types categories");
    5758    write_header();
    5859    // Standard tests: create, load, list annotation type categories
    59     categoryid= test_create(test_createAnnotationTypes(Type.INT, 10, Item.SAMPLE, null, true));
     60    int id_int=TestAnnotationType.test_create(Type.INT, 10, Item.SAMPLE, null, true);
     61    categoryid= test_create(id_int);
    6062    test_load (categoryid);
    6163   
     
    6567
    6668    // Standard test: Delete
    67     //test_delete(categoryid);
     69    test_delete(categoryid);
     70    TestAnnotationType.test_delete(id_int);
    6871    write("++Testing annotation types categories"+(works ? "OK" : "Failed")+"\n");
    69    
    7072    return works;
    7173  }
    7274 
    73  
    74   static int test_create(AnnotationType at)
     75  static int test_create(int annotationTypeId)
    7576  {
    7677    if (!TestUtil.hasPermission(Permission.CREATE, Item.ANNOTATIONTYPECATEGORY)) return 0;
     
    8081    {
    8182      dc = TestUtil.getDbControl();
     83      AnnotationType at = AnnotationType.getById(dc, annotationTypeId);
    8284      AnnotationTypeCategory atgc= AnnotationTypeCategory.getNew(dc);
    8385      atgc.setName("Test Category");
    84       atgc.setCategoryDescription("+++Just simply testing the categories+++");
    85       atgc.setDescription("testing done on" + new Date().toString());
     86      //atgc.setCategoryDescription("Just simply testing the categories+++");
     87      atgc.setDescription("Added at :" + new Date().toString());
    8688      atgc.addAnnotationType(at);
    8789      dc.saveItem(atgc);
     
    105107   
    106108    return id;
    107   }
    108  
    109  
    110   static AnnotationType test_createAnnotationTypes(Type type, Object defaultValue, Item itemType, Object[] enumValues, boolean setAll)
    111   {
    112     /*
    113      the failed create permission problems will cause a null exception watch out!"!!!
    114      it causes this method to return null when called.
    115      */
    116     if (!TestUtil.hasPermission(Permission.CREATE, Item.ANNOTATIONTYPE)) return null;
    117     AnnotationType at =null;
    118     DbControl dc = null;
    119     try
    120     {
    121       dc = TestUtil.getDbControl();
    122       at = AnnotationType.getNew(dc, type);
    123       if(setAll)
    124       {
    125         at.setName("Test annotation type: "+type);
    126         at.setDescription("Added at "+new Date());
    127         at.setMultiplicity(1);
    128         at.setRequiredForMiame(true);
    129         at.setHeight(10);
    130         at.setWidth(60);
    131       }
    132       if (enumValues != null)
    133       {
    134         at.setEnumeration(true);
    135         at.setValues(Arrays.asList(enumValues));
    136         at.setDisplayAsList(true);
    137       }
    138       if (defaultValue != null) at.setDefaultValue(defaultValue.toString());
    139       at.enableForItem(itemType);
    140       dc.saveItem(at);
    141       dc.commit();
    142       write("--Create annotation type OK");
    143     }
    144     catch (Throwable ex)
    145     {
    146       write("--Create annotation type FAILED");
    147       ex.printStackTrace();
    148       works = false;
    149     }
    150     finally
    151     {
    152       if (dc != null) dc.close();
    153     }
    154     return at;
    155109  }
    156110 
     
    232186  }
    233187 
    234  
    235  
     188   
    236189  static void write(String message)
    237190  {
     
    243196    if (!TestUtil.getSilent())
    244197    {
    245       write("   \tID \tName      \tDescription\tCategory Desccription");
    246       write("-- \t-- \t--------- \t-----------\t---------------------");
    247     }
    248   }
     198      write("   \tID \tName      \tDescription");
     199      write("-- \t-- \t--------- \t-----------");
     200    }
     201  }
     202 
    249203  static void write_item(int i, AnnotationTypeCategory atgc)
    250204    throws BaseException
    251205    {
    252206    if (!TestUtil.getSilent())
    253       write(i+":\t"+atgc.getId()+"\t"+atgc.getName()+"\t"+atgc.getDescription()+"\t"+atgc.getCategoryDescription());
    254     }
    255  
     207      write(i+":\t"+atgc.getId()+"\t"+atgc.getName()+"\t"+atgc.getDescription());
     208    }
    256209 
    257210 
  • branches/dominic_annotations/src/test/TestUtil.java

    r2357 r2475  
    5252  {
    5353    login = "root";
    54     //password = "root";
    55     password ="ab26oy";
     54    password = "root";
     55   
    5656    client = "net.sf.basedb.clients.test";
    5757   
  • branches/dominic_annotations/www/admin/annotationtypecategories/edit_category.jsp

    r2468 r2475  
    200200      </tr>
    201201      <tr valign=top>
    202         <td class="prompt">Short Description</td>
    203         <td nowrap>
    204           <textarea <%=clazz%> rows="2" cols="20" name="categoryDescription" wrap="virtual"
    205             ><%=HTML.encodeTags(annotationTypeCategory == null ? cc.getPropertyValue("categoryDescription") : annotationTypeCategory.getCategoryDescription())%></textarea>
    206         </td>
    207       </tr>
    208       <tr valign=top>
    209         <td class="prompt">Detailed Description</td>
     202        <td class="prompt">Description</td>
    210203        <td nowrap>
    211204          <textarea <%=clazz%> rows="4" cols="40" name="description" wrap="virtual"
  • branches/dominic_annotations/www/admin/annotationtypecategories/index.jsp

    r2400 r2475  
    5858<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
    5959<%!
    60   private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,categoryDescription");
     60  private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,description");
    6161  private static final Item itemType = Item.ANNOTATIONTYPECATEGORY;
    6262%>
     
    147147    annotationTypeCategory.setName(Values.getStringOrNull(request.getParameter("name")));
    148148    annotationTypeCategory.setDescription(Values.getStringOrNull(request.getParameter("description")));
    149     annotationTypeCategory.setCategoryDescription(Values.getStringOrNull(request.getParameter("categoryDescription")));   
    150        
     149           
    151150    //Members tab
    152151    String[] removeAnnotationTypes = Values.getString(request.getParameter("removeAnnotationTypes")).split(",");
  • branches/dominic_annotations/www/admin/annotationtypecategories/list_categories.jsp

    r2356 r2475  
    213213        property="description"
    214214        datatype="string"
    215         title="Full Description"
    216         sortable="true"
    217         filterable="true"
    218         exportable="true"
    219       />
    220       <tbl:columndef
    221         id="categoryDescription"
    222         property="categoryDescription"
    223         datatype="string"
    224         title="Short Description"
     215        title="Description"
    225216        sortable="true"
    226217        filterable="true"
     
    375366                <tbl:cell column="name"><div class="link" onclick="itemOnClick(event, <%=itemId%>)" title="View this annotation type category (use CTRL, ALT or SHIFT to edit)"><%=name%></div></tbl:cell>
    376367                <tbl:cell column="owner"><base:propertyvalue item="<%=item%>" property="owner.name" /></tbl:cell>
    377                 <tbl:cell column="categoryDescription"><%=item.getCategoryDescription()== null ? "<i>- none -</i>" : HTML.encodeTags(item.getCategoryDescription())%></tbl:cell>
    378368                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
    379369              </tbl:row>
  • branches/dominic_annotations/www/admin/annotationtypecategories/view_category.jsp

    r2400 r2475  
    196196      </tr>
    197197      <tr>
    198         <td class="prompt">Short Description</td>
    199         <td><%=HTML.niceFormat(annotationTypeCategory.getCategoryDescription())%></td></td>
    200       </tr>
    201       <tr>
    202         <td class="prompt">Full Description</td>
     198        <td class="prompt">Description</td>
    203199        <td><%=HTML.niceFormat(annotationTypeCategory.getDescription())%></td>
    204200      </tr>
  • branches/dominic_annotations/www/admin/annotationtypes/view_annotationtype.jsp

    r2400 r2475  
    240240        %>
    241241        <h4>Membership</h4>
    242         There are no members of this role (or, you don't have permission to view them).
     242        This annotation type isn't a member of any category (or, you don't have permission to view them).
    243243        <%
    244244      }
     
    277277              <tbl:cell column="name"><%=Base.getEncodedName(annotationtypecategory, false, annotationTypeCategoryLink)%></tbl:cell>
    278278              <tbl:cell column="type">Category</tbl:cell>
    279               <tbl:cell column="description"><%=HTML.encodeTags(annotationtypecategory.getCategoryDescription())%></tbl:cell>
     279              <tbl:cell column="description"><%=HTML.encodeTags(annotationtypecategory.getDescription())%></tbl:cell>
    280280            </tbl:row>
    281281            <%
  • branches/dominic_annotations/www/admin/groups/edit_group.jsp

    r2345 r2475  
    170170    function initMembers()
    171171    {
     172      alert('Enter initmembers');
    172173      var members = document.forms['group'].members;
    173174      Link.addNewSection(members, new Section('U', 'Users'));
  • branches/dominic_annotations/www/common/annotations/annotate.jsp

    r2469 r2475  
    355355        </div>
    356356        <base:icon image="hasvalues.gif" /> = has value(s)
    357         <b>Here We Are ooooooooooooooo</b>
    358357      </td>
    359358      <td width="50%">
Note: See TracChangeset for help on using the changeset viewer.