Changeset 2933


Ignore:
Timestamp:
Nov 17, 2006, 1:34:16 PM (16 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #172: Add externalId property to annotation type

Location:
trunk
Files:
9 edited

Legend:

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

    r2898 r2933  
    6262  public static final Item TYPE = Item.ANNOTATIONTYPE;
    6363
     64  /**
     65    The maximum length of the external id that can be stored in the database.
     66    @see #setExternalId(String)
     67    @since 2.2
     68  */
     69  public static final int MAX_EXTERNAL_ID_LENGTH = AnnotationTypeData.MAX_EXTERNAL_ID_LENGTH;
     70
     71 
    6472  /**
    6573    Create a new <code>AnnotationType</code> item.
     
    257265
    258266  /**
     267    Get the external id of the annotation type. This value can be used to link
     268    with information in external databases. It is not used by the BASE core
     269    and it doesn't have to be unique.
     270    @return The external id for the annotation type
     271    @since 2.2
     272  */
     273  public String getExternalId()
     274  {
     275    return getData().getExternalId();
     276  }
     277  /**
     278    Set the external id of the annotation type. The value
     279    may be null but must not be longer than the value specified by
     280    the {@link #MAX_EXTERNAL_ID_LENGTH} constant.
     281    @param externalId The new value for the external id
     282    @throws PermissionDeniedException If the logged in user doesn't have
     283      write permission
     284    @throws InvalidDataException If the string is too long
     285    @since 2.2
     286  */
     287  public void setExternalId(String externalId)
     288    throws PermissionDeniedException, InvalidDataException
     289  {
     290    checkPermission(Permission.WRITE);
     291    getData().setExternalId(StringUtil.setNullableString(externalId, "externalId",
     292      MAX_EXTERNAL_ID_LENGTH));
     293  }
     294
     295 
     296  /**
    259297    Add a category to this annotation type.
    260298    @param category The category to add
  • trunk/src/core/net/sf/basedb/core/Install.java

    r2929 r2933  
    102102    method.
    103103  */
    104   public static final int NEW_SCHEMA_VERSION = 25;
     104  public static final int NEW_SCHEMA_VERSION = 26;
    105105
    106106  public static synchronized void createTables(boolean update, final ProgressReporter progress)
  • trunk/src/core/net/sf/basedb/core/Update.java

    r2929 r2933  
    310310    </td>
    311311  </tr>
     312 
     313  <tr>
     314    <td>26</td>
     315    <td>
     316      <ul>
     317      <li>Added {@link net.sf.basedb.core.data.AnnotationTypeData#getExternalId()}.
     318      </ul>
     319    </td>
     320  </tr>
     321 
    312322  </table>
    313323
     
    443453      }
    444454
    445       /*
    446455      if (schemaVersion < 26)
    447456      {
    448457        if (progress != null) progress.display((int)(25*progress_factor), "--Updating schema version: " + schemaVersion + " -> 26...");
    449458        schemaVersion = setSchemaVersionInTransaction(session, 26);
     459      }
     460
     461      /*
     462      if (schemaVersion < 27)
     463      {
     464        if (progress != null) progress.display((int)(26*progress_factor), "--Updating schema version: " + schemaVersion + " -> 27...");
     465        schemaVersion = setSchemaVersionInTransaction(session, 27);
    450466        - or -
    451         schemaVersion = updateToSchemaVersion26(session);
     467        schemaVersion = updateToSchemaVersion27(session);
    452468      }
    453469      ... etc...
  • trunk/src/core/net/sf/basedb/core/data/AnnotationTypeData.java

    r2875 r2933  
    4646  {}
    4747
     48  /**
     49    The maximum length of the external id that can be stored in the database.
     50    @see #setExternalId(String)
     51    @since 2.2
     52  */
     53  public static final int MAX_EXTERNAL_ID_LENGTH = 255;
     54  private String externalId;
     55  /**
     56    Get the external id for the biomaterial
     57    @hibernate.property column="`external_id`" type="string" length="255" not-null="false"
     58    @since 2.2
     59  */
     60  public String getExternalId()
     61  {
     62    return externalId;
     63  }
     64  public void setExternalId(String externalId)
     65  {
     66    this.externalId = externalId;
     67  }
     68 
    4869  private int multiplicity;
    4970  /**
  • trunk/src/test/TestAnnotationType.java

    r2304 r2933  
    9999        at.setHeight(10);
    100100        at.setWidth(60);
     101        at.setExternalId("my.external.annotationtype");
    101102      }
    102103      if (enumValues != null)
     
    210211    if (!TestUtil.getSilent())
    211212    {
    212       write("   \tID \tName      \tDescription\tValue type\tMultiplicity\tWidth\tHeight\tMiame\tDefault value\tItem types\tEnumeration values");
    213       write("-- \t-- \t--------- \t-----------\t----------\t------------\t-----\t------\t-----\t-------------\t----------\t------------------");
     213      write("   \tID \tName      \tDescription\tValue type\tMultiplicity\tExternal ID\tWidth\tHeight\tMiame\tDefault value\tItem types\tEnumeration values");
     214      write("-- \t-- \t--------- \t-----------\t----------\t------------\t-----------\t-----\t------\t-----\t-------------\t----------\t------------------");
    214215    }
    215216  }
     
    219220    if (!TestUtil.getSilent())
    220221      write(i+":\t"+at.getId()+"\t"+at.getName()+"\t"+at.getDescription()+"\t"+at.getValueType()+
    221       "\t"+at.getMultiplicity()+"\t"+at.getWidth()+"\t"+at.getHeight()+"\t"+at.isRequiredForMiame()+
     222      "\t"+at.getMultiplicity()+"\t"+at.getExternalId()+"\t"+at.getWidth()+"\t"+at.getHeight()+"\t"+at.isRequiredForMiame()+
    222223      "\t"+at.getDefaultValue()+"\t"+at.getEnabledItems()+"\t"+at.getValues());
    223224  }
  • trunk/www/admin/annotationtypes/edit_annotationtype.jsp

    r2875 r2933  
    257257      </tr>
    258258      <tr>
     259        <td class="prompt">External ID</td>
     260        <td><input <%=clazz%> type="text" name="external_id"
     261          value="<%=HTML.encodeTags(annotationType == null ?
     262            Values.getString(cc.getPropertyValue("externalId"), "") : annotationType.getExternalId())%>"
     263          size="40" maxlength="<%=AnnotationType.MAX_EXTERNAL_ID_LENGTH%>"></td>
     264      </tr>
     265      <tr>
    259266        <td class="prompt">Multiplicity</td>
    260267        <td><input <%=clazz%> type="text" name="multiplicity"
  • trunk/www/admin/annotationtypes/index.jsp

    r2921 r2933  
    148148    annotationType.setName(Values.getStringOrNull(request.getParameter("name")));
    149149    annotationType.setDescription(Values.getStringOrNull(request.getParameter("description")));
     150    annotationType.setExternalId(Values.getStringOrNull(request.getParameter("external_id")));
    150151    annotationType.setMultiplicity(Values.getInt(request.getParameter("multiplicity"), 0));
    151152    annotationType.setDefaultValue(request.getParameter("defaultValue"));
  • trunk/www/admin/annotationtypes/list_annotationtypes.jsp

    r2921 r2933  
    252252        exportable="true"
    253253        show="always"
     254      />
     255      <tbl:columndef
     256        id="externalId"
     257        property="externalId"
     258        datatype="string"
     259        title="External id"
     260        sortable="true"
     261        filterable="true"
     262        exportable="true"
    254263      />
    255264      <tbl:columndef
     
    505514                  onclick="itemOnClick(<%=writePermission ? "event" : null%>, <%=itemId%>)"
    506515                  title="<%=tooltip%>"><%=name%></div></tbl:cell>
     516                <tbl:cell column="externalId"><%=HTML.encodeTags(item.getExternalId())%></tbl:cell>
    507517                <tbl:cell column="valueType"><%=item.getValueType()%></tbl:cell>
    508518                <tbl:cell column="isEnumeration"><%=item.isEnumeration() ?
  • trunk/www/admin/annotationtypes/view_annotationtype.jsp

    r2921 r2933  
    207207        <td class="prompt">Name</td>
    208208        <td><%=HTML.encodeTags(annotationType.getName())%></td>
     209      </tr>
     210      <tr>
     211        <td class="prompt">External ID</td>
     212        <td><%=HTML.encodeTags(annotationType.getExternalId())%></td>
    209213      </tr>
    210214      <tr>
Note: See TracChangeset for help on using the changeset viewer.