Changeset 7283
- Timestamp:
- Jan 26, 2017, 11:19:20 AM (6 years ago)
- Location:
- branches/3.10-stable
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.10-stable/config/dist/mysql-queries.xml
r7282 r7283 91 91 UPDATE [Annotations] 92 92 SET [override_id] = COALESCE( 93 (SELECT [tmp].[id] FROM 94 (SELECT [id] FROM [Annotations]93 (SELECT [tmp].[id] FROM ( 94 SELECT [id] FROM [Annotations] 95 95 WHERE [annotationset_id] = :annotationSetId 96 96 AND [annotationtype_id] = :annotationTypeId 97 AND [source] = 0 AND [project_id] = 0 ) [tmp]98 ) 97 AND [source] = 0 AND [project_id] = 0 98 ) [tmp] ) 99 99 , 0) 100 100 WHERE id = :annotationId … … 108 108 </description> 109 109 </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] <> 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> 110 158 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 111 180 </predefined-queries> -
branches/3.10-stable/src/core/common-queries.xml
r7263 r7283 3823 3823 <description> 3824 3824 Updates the "override_id" column on a newly created project-specific 3825 ( PRIMARY) annotation to point to the existing default annotation id3826 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. 3827 3827 </description> 3828 3828 </query> -
branches/3.10-stable/src/test/TestAnnotation.java
r7260 r7283 100 100 // Test: inherit and clone annotations 101 101 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); 102 103 test_inherit_annotation(Item.RAWBIOASSAY, rawBioAssayId, intAnnotationId, false); 103 104 int clonedId = test_inherit_annotation(Item.RAWBIOASSAY, rawBioAssayId, stringAnnotationId, true); … … 110 111 // Test project specific annotations -- set a default value and a project-specific for "Project #1" 111 112 int defaultProjectAnnotationId = test_annotatate(Item.ARRAYDESIGN, arrayDesignId2, projectSpecificId, 0, "default value"); 113 test_inherit_annotation(Item.RAWBIOASSAY, rawBioAssayId2, defaultProjectAnnotationId, false); 114 112 115 TestProject.test_activate_project(project1, null); 113 116 int project1AnnotationId = test_annotatate(Item.ARRAYDESIGN, arrayDesignId2, projectSpecificId, 0, "project 1 value"); 117 test_inherit_annotation(Item.RAWBIOASSAY, rawBioAssayId2, project1AnnotationId, false); 114 118 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 } 115 125 116 126 // Check that the annotation values are as expected … … 120 130 TestProject.test_activate_project(project2, null); 121 131 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); 122 138 TestProject.test_noactive_project(); 123 124 if (TestUtil.waitBeforeDelete()) TestUtil.waitForEnter();139 test_remove_annotation(Item.ARRAYDESIGN, arrayDesignId2, projectSpecificId); 140 125 141 // Remove an annotation that is inherited 126 142 test_remove_annotation(Item.ARRAYDESIGN, arrayDesignId, intId); … … 128 144 129 145 TestRawBioAssay.test_delete(rawBioAssayId); 146 TestRawBioAssay.test_delete(rawBioAssayId2); 130 147 131 148 // Remove the annotations … … 184 201 l.addAll(Arrays.asList(value)); 185 202 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 } 187 209 } 188 210 dc.commit(); … … 368 390 if (!TestUtil.getSilent()) 369 391 { 370 write(" \tID \tAnnotation type\tAnnotation set\tSource\tP arent\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----------"); 372 394 } 373 395 } … … 387 409 } 388 410 write(i+":\t"+a.getId()+"\t"+a.getAnnotationType()+"\t"+a.getAnnotationSet()+"\t"+ 389 a.getSource()+"\t"+a.get InheritedFrom()+"\t" +411 a.getSource()+"\t"+a.getProjectId()+"\t"+a.getInheritedFrom()+"\t" + 390 412 values + "\t" + a.getUnit() + "\t" + a.getValues()); 391 413 }
Note: See TracChangeset
for help on using the changeset viewer.