Changeset 7283


Ignore:
Timestamp:
Jan 26, 2017, 11:19:20 AM (5 years ago)
Author:
Nicklas Nordborg
Message:

References #2049: Project-specific annotations

Updated the TestAnnotation code with tests for inheriting and removing annotations. Fixed problems with !MySQL queries.

Location:
branches/3.10-stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/3.10-stable/config/dist/mysql-queries.xml

    r7282 r7283  
    9191      UPDATE [Annotations]
    9292      SET [override_id] = COALESCE(
    93         (SELECT [tmp].[id] FROM
    94           (SELECT [id] FROM [Annotations]
     93        (SELECT [tmp].[id] FROM (
     94          SELECT [id] FROM [Annotations]
    9595          WHERE [annotationset_id] = :annotationSetId
    9696          AND [annotationtype_id] = :annotationTypeId
    97           AND [source] = 0 AND [project_id] = 0) [tmp]
    98         )
     97          AND [source] = 0 AND [project_id] = 0
     98        ) [tmp] )
    9999        , 0)
    100100      WHERE id = :annotationId
     
    108108    </description>
    109109  </query>
     110 
     111  <query id="PS_UPDATE_PROJECT_ANNOTATION_OVERRIDE_REF_INHERITED" type="HQL">
     112    <sql>
     113      UPDATE [Annotations]
     114      SET [override_id] = :annotationId
     115      WHERE [annotationset_id] = :annotationSetId
     116      AND [inherited_id] IN (
     117        SELECT [tmp].[id] FROM (
     118          SELECT [id] FROM [Annotations]
     119          WHERE [annotationset_id] = :parentSetId
     120          AND [override_id] = :parentId
     121        ) [tmp]
     122      )
     123    </sql>
     124    <description>
     125      Updates the "override_id" column on project-specific annotations
     126      to point to a newly created default annotation (INHERITED and
     127      CLONED annotations). The subquery will find project-specific annotation
     128      on the parent annotation set that is overriding the inherited annotation.
     129     
     130      To make this query work in MySQL we need a double inner subselect
     131      to force a temporary table for the values we are after.
     132    </description>
     133  </query>
     134 
     135  <query id="PS_FIND_OVERRIDE_ID_FOR_PROJECT_ANNOTATION_INHERITED" type="SQL">
     136    <sql>
     137      UPDATE [Annotations]
     138      SET [override_id] = COALESCE(
     139        (SELECT [tmp].[id] FROM (
     140          SELECT [id] FROM [Annotations]
     141          WHERE [annotationset_id] = :annotationSetId
     142          AND [inherited_id] = :parentOverrideId
     143          AND [source] &lt;&gt; 0
     144          AND [project_id] = 0
     145        ) [tmp])
     146        , 0)
     147      WHERE id = :annotationId
     148    </sql>
     149    <description>
     150      Updates the "override_id" column on a newly created project-specific
     151      (CLONED or INHERITED) annotation to point to the existing default
     152      annotation id or 0 if no default annotation exists.
     153     
     154      To make this query work in MySQL we need a double inner subselect
     155      to force a temporary table for the values we are after.
     156    </description>
     157  </query>
    110158
     159  <query id="PS_RESET_OVERRIDE_ON_PROJECT_ANNOTATIONS" type="HQL">
     160    <sql>
     161      UPDATE [Annotations] 
     162      SET [override_id] = 0
     163      WHERE [override_id] IN (:deletedAnnotations)
     164      OR [inherited_id] IN (
     165        SELECT [tmp].[id] FROM (
     166          SELECT [id] FROM [Annotations]
     167          WHERE [override_id] IN (:deletedPrimaryAnnotations)
     168        ) [tmp]
     169      )
     170    </sql>
     171    <description>
     172      Reset the "override_id" column on project-specific annotations
     173      that points to a default annotation that has been removed.
     174
     175      To make this query work in MySQL we need a double inner subselect
     176      to force a temporary table for the values we are after.
     177    </description>
     178  </query>
     179 
    111180</predefined-queries>
  • branches/3.10-stable/src/core/common-queries.xml

    r7263 r7283  
    38233823    <description>
    38243824      Updates the "override_id" column on a newly created project-specific
    3825       (PRIMARY) annotation to point to the existing default annotation id
    3826       or 0 if no default annotation exists.
     3825      (CLONED or INHERITED) annotation to point to the existing default
     3826      annotation id or 0 if no default annotation exists.
    38273827    </description>
    38283828  </query>
  • branches/3.10-stable/src/test/TestAnnotation.java

    r7260 r7283  
    100100    // Test: inherit and clone annotations
    101101    int rawBioAssayId = TestRawBioAssay.test_create(Platform.GENERIC, "genepix", null, 0, 0, 0, 0, arrayDesignId, false);
     102    int rawBioAssayId2 = TestRawBioAssay.test_create(Platform.GENERIC, "genepix", null, 0, 0, 0, 0, arrayDesignId2, false);
    102103    test_inherit_annotation(Item.RAWBIOASSAY, rawBioAssayId, intAnnotationId, false);
    103104    int clonedId = test_inherit_annotation(Item.RAWBIOASSAY, rawBioAssayId, stringAnnotationId, true);
     
    110111    // Test project specific annotations -- set a default value and a project-specific for "Project #1"
    111112    int defaultProjectAnnotationId = test_annotatate(Item.ARRAYDESIGN, arrayDesignId2, projectSpecificId, 0, "default value");
     113    test_inherit_annotation(Item.RAWBIOASSAY, rawBioAssayId2, defaultProjectAnnotationId, false);
     114   
    112115    TestProject.test_activate_project(project1, null);
    113116    int project1AnnotationId = test_annotatate(Item.ARRAYDESIGN, arrayDesignId2, projectSpecificId, 0, "project 1 value");
     117    test_inherit_annotation(Item.RAWBIOASSAY, rawBioAssayId2, project1AnnotationId, false);
    114118    TestProject.test_noactive_project();
     119   
     120    if (defaultProjectAnnotationId == project1AnnotationId)
     121    {
     122      write("--Create project-specific annotation value FAILED (test returns the default value");
     123      ok = false;
     124    }
    115125
    116126    // Check that the annotation values are as expected
     
    120130    TestProject.test_activate_project(project2, null);
    121131    test_project_annotation(Item.ARRAYDESIGN, arrayDesignId2, projectSpecificId, "default value", "project 1 value");
     132
     133   
     134    if (TestUtil.waitBeforeDelete()) TestUtil.waitForEnter();
     135   
     136    // Remove project-specific annotation
     137    test_remove_annotation(Item.ARRAYDESIGN, arrayDesignId2, projectSpecificId);
    122138    TestProject.test_noactive_project();
    123    
    124     if (TestUtil.waitBeforeDelete()) TestUtil.waitForEnter();
     139    test_remove_annotation(Item.ARRAYDESIGN, arrayDesignId2, projectSpecificId);
     140   
    125141    // Remove an annotation that is inherited
    126142    test_remove_annotation(Item.ARRAYDESIGN, arrayDesignId, intId);
     
    128144   
    129145    TestRawBioAssay.test_delete(rawBioAssayId);
     146    TestRawBioAssay.test_delete(rawBioAssayId2);
    130147
    131148    // Remove the annotations
     
    184201        l.addAll(Arrays.asList(value));
    185202        Unit unit = unitId != 0 ? Unit.getById(dc, unitId) : null;
    186         a.setValuesIfDifferent(l, unit);
     203        boolean changed = a.setValuesIfDifferent(l, unit);
     204        if (changed && at.getProjectAnnotations() && dc.getSessionControl().getActiveProjectId() != a.getProjectId())
     205        {
     206          // We have created  a different (project-specific) annotation
     207          a = as.getAnnotation(at);
     208        }
    187209      }
    188210      dc.commit();
     
    368390    if (!TestUtil.getSilent())
    369391    {
    370       write("   \tID \tAnnotation type\tAnnotation set\tSource\tParent\tValues\tUnit\tRaw values");
    371       write("-- \t-- \t---------------\t--------------\t------\t------\t------\t----\t----------");
     392      write("   \tID \tAnnotation type\tAnnotation set\tSource\tProject\tParent\tValues\tUnit\tRaw values");
     393      write("-- \t-- \t---------------\t--------------\t------\t-------\t------\t------\t----\t----------");
    372394    }
    373395  }
     
    387409    }
    388410    write(i+":\t"+a.getId()+"\t"+a.getAnnotationType()+"\t"+a.getAnnotationSet()+"\t"+
    389         a.getSource()+"\t"+a.getInheritedFrom()+"\t" +
     411        a.getSource()+"\t"+a.getProjectId()+"\t"+a.getInheritedFrom()+"\t" +
    390412        values + "\t" + a.getUnit() + "\t" + a.getValues());
    391413  }
Note: See TracChangeset for help on using the changeset viewer.