Changeset 7308


Ignore:
Timestamp:
Mar 13, 2017, 9:15:46 AM (5 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #2061: Add API for setting registration date on items

Added Registered.setEntryDate() method and implemented in all subclasses.

Location:
trunk/src/core/net/sf/basedb/core
Files:
43 edited

Legend:

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

    r7260 r7308  
    186186  {
    187187    return DateUtil.copy(getData().getEntryDate());
     188  }
     189  @Override
     190  public void setEntryDate(Date entryDate)
     191  {
     192    if (isInDatabase())
     193    {
     194      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     195    }
     196    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
    188197  }
    189198  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/AnnotationTypeCategory.java

    r6881 r7308  
    131131    return DateUtil.copy(getData().getEntryDate());
    132132  }
     133  @Override
     134  public void setEntryDate(Date entryDate)
     135  {
     136    if (isInDatabase())
     137    {
     138      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     139    }
     140    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
     141  }
    133142  // -------------------------------------------
    134143
  • trunk/src/core/net/sf/basedb/core/ArrayBatch.java

    r7003 r7308  
    154154  {
    155155    return DateUtil.copy(getData().getEntryDate());
     156  }
     157  @Override
     158  public void setEntryDate(Date entryDate)
     159  {
     160    if (isInDatabase())
     161    {
     162      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     163    }
     164    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
    156165  }
    157166  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/ArrayDesign.java

    r7014 r7308  
    252252  {
    253253    return DateUtil.copy(getData().getEntryDate());
     254  }
     255  @Override
     256  public void setEntryDate(Date entryDate)
     257  {
     258    if (isInDatabase())
     259    {
     260      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     261    }
     262    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
    254263  }
    255264  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/ArraySlide.java

    r7002 r7308  
    184184    return DateUtil.copy(getData().getEntryDate());
    185185  }
     186  @Override
     187  public void setEntryDate(Date entryDate)
     188  {
     189    if (isInDatabase())
     190    {
     191      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     192    }
     193    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
     194  }
    186195  // -------------------------------------------
    187196
  • trunk/src/core/net/sf/basedb/core/BioMaterialEvent.java

    r6990 r7308  
    10541054    return DateUtil.copy(getData().getEntryDate());
    10551055  }
     1056  @Override
     1057  public void setEntryDate(Date entryDate)
     1058  {
     1059    if (isInDatabase())
     1060    {
     1061      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     1062    }
     1063    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
     1064  }
    10561065
    10571066  /**
  • trunk/src/core/net/sf/basedb/core/BioPlate.java

    r7003 r7308  
    185185  {
    186186    return DateUtil.copy(getData().getEntryDate());
     187  }
     188  @Override
     189  public void setEntryDate(Date entryDate)
     190  {
     191    if (isInDatabase())
     192    {
     193      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     194    }
     195    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
    187196  }
    188197  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/BioPlateEvent.java

    r6990 r7308  
    136136  {
    137137    return DateUtil.copy(getData().getEntryDate());
     138  }
     139  @Override
     140  public void setEntryDate(Date entryDate)
     141  {
     142    if (isInDatabase())
     143    {
     144      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     145    }
     146    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
    138147  }
    139148  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/BioSource.java

    r6881 r7308  
    130130  {
    131131    return DateUtil.copy(getData().getEntryDate());
     132  }
     133  @Override
     134  public void setEntryDate(Date entryDate)
     135  {
     136    if (isInDatabase())
     137    {
     138      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     139    }
     140    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
    132141  }
    133142  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/Client.java

    r6874 r7308  
    171171  {
    172172    return DateUtil.copy(getData().getEntryDate());
     173  }
     174  @Override
     175  public void setEntryDate(Date entryDate)
     176  {
     177    if (isInDatabase())
     178    {
     179      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     180    }
     181    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
    173182  }
    174183  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/DateUtil.java

    r7189 r7308  
    6666  }
    6767
     68  /**
     69    Make a copy of the date. If null, today's date is
     70    used instead.
     71    @since 3.11
     72  */
     73  public static Date setDateOrToday(Date value)
     74  {
     75    return value == null ? new Date() : copy(value);
     76  }
    6877
    6978  /**
  • trunk/src/core/net/sf/basedb/core/DerivedBioAssay.java

    r7082 r7308  
    450450  {
    451451    return DateUtil.copy(getData().getEntryDate());
     452  }
     453  @Override
     454  public void setEntryDate(Date entryDate)
     455  {
     456    if (isInDatabase())
     457    {
     458      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     459    }
     460    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
    452461  }
    453462  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/Experiment.java

    r6958 r7308  
    250250  {
    251251    return DateUtil.copy(getData().getEntryDate());
     252  }
     253  @Override
     254  public void setEntryDate(Date entryDate)
     255  {
     256    if (isInDatabase())
     257    {
     258      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     259    }
     260    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
    252261  }
    253262  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/ExtraValueType.java

    r7016 r7308  
    230230  {
    231231    return DateUtil.copy(getData().getEntryDate());
     232  }
     233  @Override
     234  public void setEntryDate(Date entryDate)
     235  {
     236    if (isInDatabase())
     237    {
     238      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     239    }
     240    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
    232241  }
    233242  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/Formula.java

    r6898 r7308  
    203203  {
    204204    return DateUtil.copy(getData().getEntryDate());
     205  }
     206  @Override
     207  public void setEntryDate(Date entryDate)
     208  {
     209    if (isInDatabase())
     210    {
     211      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     212    }
     213    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
    205214  }
    206215  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/Group.java

    r7016 r7308  
    264264  {
    265265    return DateUtil.copy(getData().getEntryDate());
     266  }
     267  @Override
     268  public void setEntryDate(Date entryDate)
     269  {
     270    if (isInDatabase())
     271    {
     272      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     273    }
     274    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
    266275  }
    267276  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/Hardware.java

    r6881 r7308  
    216216  {
    217217    return DateUtil.copy(getData().getEntryDate());
     218  }
     219  @Override
     220  public void setEntryDate(Date entryDate)
     221  {
     222    if (isInDatabase())
     223    {
     224      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     225    }
     226    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
    218227  }
    219228  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/ItemSubtype.java

    r7016 r7308  
    308308    return DateUtil.copy(getData().getEntryDate());
    309309  }
     310  @Override
     311  public void setEntryDate(Date entryDate)
     312  {
     313    if (isInDatabase())
     314    {
     315      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     316    }
     317    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
     318  }
    310319  // -------------------------------------------
    311320  /*
  • trunk/src/core/net/sf/basedb/core/Kit.java

    r7052 r7308  
    196196  {
    197197    return DateUtil.copy(getData().getEntryDate());
     198  }
     199  @Override
     200  public void setEntryDate(Date entryDate)
     201  {
     202    if (isInDatabase())
     203    {
     204      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     205    }
     206    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
    198207  }
    199208  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/MeasuredBioMaterial.java

    r7082 r7308  
    214214  {
    215215    return getCreationEvent().getEntryDate();
     216  }
     217  @Override
     218  public void setEntryDate(Date entryDate)
     219  {
     220    getCreationEvent().setEntryDate(entryDate);
    216221  }
    217222  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/MimeType.java

    r7016 r7308  
    251251    return DateUtil.copy(getData().getEntryDate());
    252252  }
     253  @Override
     254  public void setEntryDate(Date entryDate)
     255  {
     256    if (isInDatabase())
     257    {
     258      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     259    }
     260    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
     261  }
    253262  // -------------------------------------------
    254263
  • trunk/src/core/net/sf/basedb/core/News.java

    r7016 r7308  
    189189  {
    190190    return DateUtil.copy(getData().getEntryDate());
     191  }
     192  @Override
     193  public void setEntryDate(Date entryDate)
     194  {
     195    if (isInDatabase())
     196    {
     197      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     198    }
     199    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
    191200  }
    192201  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/PhysicalBioAssay.java

    r7003 r7308  
    190190  {
    191191    return getCreationEvent().getEntryDate();
     192  }
     193  @Override
     194  public void setEntryDate(Date entryDate)
     195  {
     196    getCreationEvent().setEntryDate(entryDate);
    192197  }
    193198  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/Plate.java

    r7014 r7308  
    176176  {
    177177    return DateUtil.copy(getData().getEntryDate());
     178  }
     179  @Override
     180  public void setEntryDate(Date entryDate)
     181  {
     182    if (isInDatabase())
     183    {
     184      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     185    }
     186    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
    178187  }
    179188  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/PlateEvent.java

    r6874 r7308  
    322322    return DateUtil.copy(getData().getEntryDate());
    323323  }
     324  @Override
     325  public void setEntryDate(Date entryDate)
     326  {
     327    if (isInDatabase())
     328    {
     329      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     330    }
     331    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
     332  }
    324333
    325334  /**
  • trunk/src/core/net/sf/basedb/core/PlateGeometry.java

    r7016 r7308  
    193193  {
    194194    return DateUtil.copy(getData().getEntryDate());
     195  }
     196  @Override
     197  public void setEntryDate(Date entryDate)
     198  {
     199    if (isInDatabase())
     200    {
     201      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     202    }
     203    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
    195204  }
    196205  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/PlateMapping.java

    r6881 r7308  
    162162    return DateUtil.copy(getData().getEntryDate());
    163163  }
     164  @Override
     165  public void setEntryDate(Date entryDate)
     166  {
     167    if (isInDatabase())
     168    {
     169      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     170    }
     171    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
     172  }
    164173  // -------------------------------------------
    165174
  • trunk/src/core/net/sf/basedb/core/PlateType.java

    r6881 r7308  
    129129  {
    130130    return DateUtil.copy(getData().getEntryDate());
     131  }
     132  @Override
     133  public void setEntryDate(Date entryDate)
     134  {
     135    if (isInDatabase())
     136    {
     137      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     138    }
     139    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
    131140  }
    132141  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/PluginConfiguration.java

    r7260 r7308  
    221221  {
    222222    return DateUtil.copy(getData().getEntryDate());
     223  }
     224  @Override
     225  public void setEntryDate(Date entryDate)
     226  {
     227    if (isInDatabase())
     228    {
     229      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     230    }
     231    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
    223232  }
    224233  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/PluginDefinition.java

    r7015 r7308  
    477477  {
    478478    return DateUtil.copy(getData().getEntryDate());
     479  }
     480  @Override
     481  public void setEntryDate(Date entryDate)
     482  {
     483    if (isInDatabase())
     484    {
     485      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     486    }
     487    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
    479488  }
    480489  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/PluginType.java

    r7016 r7308  
    250250    return DateUtil.copy(getData().getEntryDate());
    251251  }
     252  @Override
     253  public void setEntryDate(Date entryDate)
     254  {
     255    if (isInDatabase())
     256    {
     257      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     258    }
     259    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
     260  }
    252261  // -------------------------------------------
    253262
  • trunk/src/core/net/sf/basedb/core/Project.java

    r7262 r7308  
    239239    return DateUtil.copy(getData().getEntryDate());
    240240  }
     241  @Override
     242  public void setEntryDate(Date entryDate)
     243  {
     244    if (isInDatabase())
     245    {
     246      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     247    }
     248    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
     249  }
    241250  // -------------------------------------------
    242251
  • trunk/src/core/net/sf/basedb/core/Protocol.java

    r6881 r7308  
    280280    return DateUtil.copy(getData().getEntryDate());
    281281  }
     282  @Override
     283  public void setEntryDate(Date entryDate)
     284  {
     285    if (isInDatabase())
     286    {
     287      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     288    }
     289    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
     290  }
    282291  // -------------------------------------------
    283292  /*
  • trunk/src/core/net/sf/basedb/core/QuotaType.java

    r6874 r7308  
    177177    return DateUtil.copy(getData().getEntryDate());
    178178  }
     179  @Override
     180  public void setEntryDate(Date entryDate)
     181  {
     182    if (isInDatabase())
     183    {
     184      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     185    }
     186    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
     187  }
    179188  // -------------------------------------------
    180189
  • trunk/src/core/net/sf/basedb/core/RawBioAssay.java

    r7014 r7308  
    322322  {
    323323    return DateUtil.copy(getData().getEntryDate());
     324  }
     325  @Override
     326  public void setEntryDate(Date entryDate)
     327  {
     328    if (isInDatabase())
     329    {
     330      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     331    }
     332    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
    324333  }
    325334  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/Registered.java

    r4889 r7308  
    4747  public Date getEntryDate();
    4848
     49  /**
     50    Set the date the entry was registered in the database.
     51    Implementations should only allow this property to be
     52    set before the item is first stored in the database.
     53    The intention of this method is to facilitate export/import
     54    of data between server.
     55    @param entryDate A date or null to use today's date
     56    @since 3.11
     57  */
     58  public void setEntryDate(Date entryDate);
     59 
    4960}
  • trunk/src/core/net/sf/basedb/core/ReporterCloneTemplate.java

    r6881 r7308  
    230230    return DateUtil.copy(getData().getEntryDate());
    231231  }
     232  @Override
     233  public void setEntryDate(Date entryDate)
     234  {
     235    if (isInDatabase())
     236    {
     237      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     238    }
     239    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
     240  }
    232241  // -------------------------------------------
    233242
  • trunk/src/core/net/sf/basedb/core/ReporterList.java

    r6898 r7308  
    244244  {
    245245    return DateUtil.copy(getData().getEntryDate());
     246  }
     247  @Override
     248  public void setEntryDate(Date entryDate)
     249  {
     250    if (isInDatabase())
     251    {
     252      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     253    }
     254    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
    246255  }
    247256  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/ReporterType.java

    r7016 r7308  
    192192  {
    193193    return DateUtil.copy(getData().getEntryDate());
     194  }
     195  @Override
     196  public void setEntryDate(Date entryDate)
     197  {
     198    if (isInDatabase())
     199    {
     200      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     201    }
     202    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
    194203  }
    195204  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/Role.java

    r7294 r7308  
    259259  {
    260260    return DateUtil.copy(getData().getEntryDate());
     261  }
     262  @Override
     263  public void setEntryDate(Date entryDate)
     264  {
     265    if (isInDatabase())
     266    {
     267      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     268    }
     269    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
    261270  }
    262271  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/Software.java

    r6881 r7308  
    176176  {
    177177    return DateUtil.copy(getData().getEntryDate());
     178  }
     179  @Override
     180  public void setEntryDate(Date entryDate)
     181  {
     182    if (isInDatabase())
     183    {
     184      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     185    }
     186    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
    178187  }
    179188  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/Tag.java

    r6881 r7308  
    132132  {
    133133    return DateUtil.copy(getData().getEntryDate());
     134  }
     135  @Override
     136  public void setEntryDate(Date entryDate)
     137  {
     138    if (isInDatabase())
     139    {
     140      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     141    }
     142    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
    134143  }
    135144  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/User.java

    r7211 r7308  
    378378  {
    379379    return DateUtil.copy(getData().getEntryDate());
     380  }
     381  @Override
     382  public void setEntryDate(Date entryDate)
     383  {
     384    if (isInDatabase())
     385    {
     386      throw new PermissionDeniedException("Not allowed to change entryDate of " + this);
     387    }
     388    getData().setEntryDate(DateUtil.setDateOrToday(entryDate));
    380389  }
    381390  // -------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.