Changeset 7198


Ignore:
Timestamp:
Oct 17, 2016, 9:01:25 AM (6 years ago)
Author:
Nicklas Nordborg
Message:

References #2029: Projects should be annotatable

Fixed in the data and core layer. Updates the schema version to 134.

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

Legend:

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

    r7166 r7198  
    118118    method.
    119119  */
    120   public static final int NEW_SCHEMA_VERSION = Integer.valueOf(133).intValue();
     120  public static final int NEW_SCHEMA_VERSION = Integer.valueOf(134).intValue();
    121121 
    122122  public static synchronized int createTables(SchemaGenerator.Mode mode, ProgressReporter progress,
  • trunk/src/core/net/sf/basedb/core/Project.java

    r7033 r7198  
    2525
    2626import net.sf.basedb.core.Transactional.Action;
     27import net.sf.basedb.core.data.AnnotationSetData;
    2728import net.sf.basedb.core.data.BasicData;
    2829import net.sf.basedb.core.data.ItemParameterValueData;
     
    8990public class Project
    9091  extends OwnedItem
    91   implements Nameable, Removable, Registered
     92  implements Nameable, Removable, Registered, Annotatable
    9293{
    9394  /**
     
    237238  {
    238239    return DateUtil.copy(getData().getEntryDate());
     240  }
     241  // -------------------------------------------
     242
     243  /*
     244    From the Annotatable interface
     245    -------------------------------------------
     246  */
     247  @Override
     248  public AnnotationSet getAnnotationSet()
     249    throws PermissionDeniedException, BaseException
     250  {
     251    checkBatchAnnotatableUsage(true, false);
     252    DbControl dc = getDbControl();
     253    AnnotationSet as = dc.getItem(AnnotationSet.class, getData().getAnnotationSet(), this);
     254    if (as == null)
     255    {
     256      as = AnnotationSet.getNew(dc, this);
     257      getData().setAnnotationSet(as.getData());
     258      dc.saveItemIf(this, as, false);
     259    }
     260    return as;
     261  }
     262  @Override
     263  public boolean isAnnotated()
     264  {
     265    return getData().getAnnotationSet() != null;
     266  }
     267  @Override
     268  public void removeAnnotations()
     269    throws PermissionDeniedException, BaseException
     270  {
     271    checkPermission(Permission.WRITE);
     272    AnnotationSetData as = getData().getAnnotationSet();
     273    if (as != null)
     274    {
     275      HibernateUtil.deleteData(getDbControl().getHibernateSession(), as);
     276      getData().setAnnotationSet(null);
     277    }
     278  }
     279  /**
     280    Default implementation returns null. Should be overriden by subclasses
     281    that has protocols.
     282    @return Always null
     283  */
     284  @Override
     285  public Protocol getProtocol()
     286  {
     287    return null;
     288  }
     289 
     290  /**
     291    @return Always null
     292   */
     293  public Set<Annotatable> getAnnotatableParents()
     294    throws BaseException
     295  {
     296    return null;
    239297  }
    240298  // -------------------------------------------
  • trunk/src/core/net/sf/basedb/core/Update.java

    r7165 r7198  
    331331    </td>
    332332  </tr>
     333  <tr>
     334    <td>134</td>
     335    <td>
     336      Made {@link Project} annotatable. No special database update is needed.
     337      Only increase the schema version.
     338    </td>
     339  </tr>
    333340   
    334341  </table>
     
    537544        progress_current += progress_step;
    538545      }
    539    
     546     
     547      if (schemaVersion < 134)
     548      {
     549        if (progress != null) progress.display((int)(progress_current), "--Updating schema version: " + schemaVersion + " -> 134...");
     550        // Schemaversion 134 only updates the version number
     551        schemaVersion = setSchemaVersionInTransaction(session, 134);
     552        progress_current += progress_step;
     553      }
     554
    540555      sc.logout();
    541556      if (progress != null) progress.display(100, "Database updated successfully.");
  • trunk/src/core/net/sf/basedb/core/data/ProjectData.java

    r7015 r7198  
    2525import java.util.Date;
    2626import java.util.Set;
     27
     28import net.sf.basedb.core.data.annotations.AnnotationLink;
     29
    2730import java.util.Map;
    2831import java.util.HashMap;
     
    4043public class ProjectData
    4144  extends OwnedData
    42   implements NameableData, RemovableData, RegisteredData
     45  implements NameableData, RemovableData, RegisteredData, AnnotatableData
    4346{
    4447
     
    105108  // -------------------------------------------
    106109
     110  /*
     111    From the AnnotatableData interface
     112    -------------------------------------------
     113  */
     114  private AnnotationSetData annotationSet;
     115
     116  /**
     117    @since 3.10
     118  */
     119  @Override
     120  public AnnotationSetData getAnnotationSet()
     121  {
     122    return annotationSet;
     123  }
     124 
     125  /**
     126    @since 3.10
     127  */
     128  @Override
     129  public void setAnnotationSet(AnnotationSetData annotationSet)
     130  {
     131    this.annotationSet = annotationSet;
     132  }
     133  private Set<AnnotationLink> links;
     134
     135  /**
     136    @since 3.10
     137  */
     138  @Override
     139  public Set<AnnotationLink> getAnnotations()
     140  {
     141    return links;
     142  }
     143  void setAnnotations(Set<AnnotationLink> links)
     144  {
     145    this.links = links;
     146  }
     147  // -------------------------------------------
     148 
    107149  private int autoPermission;
    108150  /**
Note: See TracChangeset for help on using the changeset viewer.