Changeset 7615


Ignore:
Timestamp:
Mar 1, 2019, 2:19:42 PM (5 years ago)
Author:
Nicklas Nordborg
Message:

References #2149: Batch item importers should be able to use an annotation for item identification

Added AnnotationTypeData.isIdentifier() so that we can flag annotation types that are intended to be used as indentifiers.

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

Legend:

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

    r7610 r7615  
    10331033    getData().setProjectAnnotations(projectAnnotations);
    10341034  }
     1035 
     1036  /**
     1037    @see #isIdentifier()
     1038    @since 3.15
     1039  */
     1040  public void setIdentifier(boolean isIdentifier)
     1041    throws PermissionDeniedException
     1042  {
     1043    checkPermission(Permission.WRITE);
     1044    getData().setIdentifier(isIdentifier);
     1045  }
     1046 
     1047  /**
     1048    If this flag is set, annotation values are considered to be alternate
     1049    identifiers for the items they belong to. But note that BASE will not
     1050    check or prevent the same value from being used for more than one item.
     1051    @since 3.15
     1052  */
     1053  public boolean isIdentifier()
     1054  {
     1055    return getData().isIdentifier();
     1056  }
    10351057
    10361058  /**
  • trunk/src/core/net/sf/basedb/core/Install.java

    r7597 r7615  
    119119    method.
    120120  */
    121   public static final int NEW_SCHEMA_VERSION = Integer.valueOf(144).intValue();
     121  public static final int NEW_SCHEMA_VERSION = Integer.valueOf(145).intValue();
    122122 
    123123  public static synchronized int createTables(SchemaGenerator.Mode mode, ProgressReporter progress,
  • trunk/src/core/net/sf/basedb/core/Update.java

    r7597 r7615  
    416416    </td>
    417417  </tr>
    418  
     418  <tr>
     419    <td>145</td>
     420    <td>
     421      Added {@link AnnotationTypeData#isIdentifier()}.
     422      The update will set the value to FALSE for all existing annotation types.
     423    </td>
     424  </tr>
     425
    419426  </table>
    420427
     
    679686        schemaVersion = updateToSchemaVersion144(session, schemaVersion);
    680687        progress_current += 2 * progress_step;
     688      }
     689     
     690      if (schemaVersion < 145)
     691      {
     692        if (progress != null) progress.display((int)(progress_current), "--Updating schema version: " + schemaVersion + " -> 145...");
     693        schemaVersion = setSchemaVersionInTransaction(session, 145);
     694        progress_current += progress_step;
    681695      }
    682696     
     
    10331047        query.executeUpdate();
    10341048      }
     1049     
     1050      if (schemaVersion < 145)
     1051      {
     1052        // Set identifier=false on all annotation types
     1053        org.hibernate.query.Query<?> query = HibernateUtil.createQuery(session,
     1054          "UPDATE AnnotationTypeData at " +
     1055          "SET at.identifier = false " +
     1056          "WHERE at.identifier IS NULL");
     1057        query.executeUpdate();
     1058      }
     1059
    10351060     
    10361061      //  Commit the changes
  • trunk/src/core/net/sf/basedb/core/data/AnnotationTypeData.java

    r7244 r7615  
    294294  }
    295295
     296  private boolean isIdentifier;
     297  /**
     298    If this flag is set, annotation values can be used as identifiers to items.
     299    @since 3.15
     300    @hibernate.property column="`is_identifier`" type="boolean" not-null="true"
     301  */
     302  public boolean isIdentifier()
     303  {
     304    return isIdentifier;
     305  }
     306  public void setIdentifier(boolean isIdentifier)
     307  {
     308    this.isIdentifier = isIdentifier;
     309  }
     310
     311 
    296312  private Set<Integer> itemTypes;
    297313  /**
Note: See TracChangeset for help on using the changeset viewer.