Ignore:
Timestamp:
Apr 19, 2016, 8:56:43 AM (7 years ago)
Author:
Nicklas Nordborg
Message:

References #2000: Batch API for annotation handling

First version of the new AnnotationBatcher implementation. It should have support for creating, updating and deleting annotation values.

It lacks a lot functionality:

  • It doesn't check annotation values (eg. if a String is a String, if a values is allowed by the an enumerated annotation, etc.)
  • It doesn't handle units
  • Changes are not recorded in the change log


The AnnotationFlatFileImporter has been modified to use the batcher. All possible options for updating are supported (eg. merge).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/common-queries.xml

    r7082 r7121  
    35823582  </query>
    35833583
     3584  <query id="AB_LOAD_ANNOTATION_INFO" type="SQL">
     3585    <sql>
     3586      SELECT [annotationtype_id], [id], [version], [unit_id], [value_id], [last_update]
     3587      FROM [Annotations]
     3588      WHERE [annotationset_id] = :annotationSet AND [source] = 0
     3589    </sql>
     3590    <description>
     3591      SQL query for loading current (primary) annotations for
     3592      a given item.
     3593      Used by the AnnotationBatcher as a SQL query via Hibernate.
     3594    </description>
     3595  </query>
     3596
     3597  <query id="AB_LOAD_ANNOTATION_VALUES" type="SQL">
     3598    <sql>
     3599      SELECT [id], [value]
     3600      FROM [{1}]
     3601      WHERE [id] IN (:listOfIds)
     3602    </sql>
     3603    <description>
     3604      SQL query for loading current annotation values
     3605      for a given list of annotation value IDs.
     3606      Used by the AnnotationBatcher as a SQL query via Hibernate.
     3607    </description>
     3608  </query>
     3609
     3610  <query id="AB_INSERT_INTO_PARAMETERVALUES" type="SQL">
     3611    <sql>
     3612      INSERT INTO [ParameterValues] ([id], [discriminator], [version])
     3613      VALUES (nextval('hibernate_sequence'), ?, 0)
     3614    </sql>
     3615    <description>
     3616      SQL query for inserting rows into the ParameterValues table.
     3617      The primary key (id) must be auto-generated.
     3618      Parameters: discriminator
     3619    </description>
     3620  </query>
     3621
     3622  <query id="AB_INSERT_INTO_ANNOTATIONS" type="SQL">
     3623    <sql>
     3624      INSERT INTO [Annotations] ([id], [version], [annotationset_id], [annotationtype_id], [unit_id], [value_id], [last_update], [source])
     3625      VALUES (nextval('hibernate_sequence'), 0, ?, ?, ?, ?, ?, 0)
     3626    </sql>
     3627    <description>
     3628      SQL query for inserting rows into the Annotations table.
     3629      The primary key (id) must be auto-generated.
     3630      Parameters: annotationset_id, annotationtype_id, unit_id, value_id, last_updated
     3631    </description>
     3632  </query>
     3633
     3634  <query id="AB_UPDATE_ANNOTATIONS" type="SQL">
     3635    <sql>
     3636      UPDATE [Annotations]
     3637      SET [version] = ?, [unit_id] = ?, [last_update] = ?
     3638      WHERE [id] = ? AND [version] = ?
     3639    </sql>
     3640    <description>
     3641      SQL query for updating rows into the Annotations table.
     3642      Parameters: version (new), unit_id, last_updated, id, version (old)
     3643    </description>
     3644  </query>
     3645
     3646  <query id="AB_INSERT_INTO_ANNOTATIONSETS" type="SQL">
     3647    <sql>
     3648      INSERT INTO [AnnotationSets] ([id], [version], [item_type], [item_id])
     3649      VALUES (nextval('hibernate_sequence'), 0, {1}, ?)
     3650    </sql>
     3651    <description>
     3652      SQL query for inserting rows into the AnnotationSets table.
     3653      The primary key (id) must be auto-generated.
     3654      Parameters: item_id
     3655    </description>
     3656  </query>
     3657 
     3658  <query id="AB_UPDATE_ITEMTABLE" type="SQL">
     3659    <sql>
     3660      UPDATE [{1}]
     3661      SET [annotationset_id] = ?
     3662      WHERE [id] = ?
     3663    </sql>
     3664    <description>
     3665      SQL query for updating the annotationset_id column in any
     3666      table it exists in.
     3667      Parameters: annotationset_id, item_id
     3668    </description>
     3669  </query>
     3670
     3671  <query id="AB_NULLIFY_CLONED_ANNOTATIONS" type="SQL">
     3672    <sql>
     3673      UPDATE [Annotations]
     3674      SET [inherited_id] = null
     3675      WHERE [inherited_id] = ? and [source] = 2
     3676    </sql>
     3677    <description>
     3678      SQL query for setting the 'inherited_id' column to null
     3679      for cloned annotations that reference the annotation that
     3680      is about to be deleted.
     3681      Parameters: inherited_id
     3682    </description>
     3683  </query>
     3684
     3685  <query id="AB_DELETE_INHERITED_ANNOTATIONS" type="SQL">
     3686    <sql>
     3687      DELETE FROM [Annotations]
     3688      WHERE [inherited_id] = ? and [source] = 1
     3689    </sql>
     3690    <description>
     3691      SQL query for deleting inherited annotations that reference
     3692      the annotation that is about to be deleted.
     3693      Parameters: inherited_id
     3694    </description>
     3695  </query>
     3696
     3697  <query id="AB_DELETE_FROM_ANNOTATIONS" type="SQL">
     3698    <sql>
     3699      DELETE FROM [Annotations]
     3700      WHERE [id] = ?
     3701    </sql>
     3702    <description>
     3703      SQL query for deleting an annotation with a given id.
     3704      Used by the AnnotationBatcher as a PreparedStatement.
     3705      Parameters: id
     3706    </description>
     3707  </query>
     3708
     3709  <query id="AB_DELETE_FROM_PARAMETERVALUES" type="SQL">
     3710    <sql>
     3711      DELETE FROM [ParameterValues] WHERE [id] = ?
     3712    </sql>
     3713    <description>
     3714      SQL query for deleting a parameter value with a given id.
     3715      Used by the AnnotationBatcher as a PreparedStatement.
     3716    </description>
     3717  </query>
     3718
     3719  <query id="AB_DELETE_FROM_VALUES" type="SQL">
     3720    <sql>
     3721      DELETE FROM [{1}] WHERE [id] = ?
     3722    </sql>
     3723    <description>
     3724      SQL query for deleting all actual annotation values with a given id.
     3725      The {1} parameter is the table the value are stored in, eg. StringValues,
     3726      IntegerValues, FloatValues, etc.
     3727      Used by the AnnotationBatcher as a PreparedStatement.
     3728    </description>
     3729  </query>
     3730 
     3731  <query id="AB_INSERT_INTO_VALUES" type="SQL">
     3732    <sql>
     3733      INSERT INTO [{1}] ([id], [value]) VALUES (?, ?)
     3734    </sql>
     3735    <description>
     3736      SQL query for inserting annotation values in their respective
     3737      table (eg. StringValues, IntegerValues, FloatValues, etc.).
     3738      Used by the AnnotationBatcher as a PreparedStatement.
     3739    </description>
     3740  </query>
    35843741 
    35853742</predefined-queries>
Note: See TracChangeset for help on using the changeset viewer.