Changeset 7298
- Timestamp:
- Feb 21, 2017, 9:49:31 AM (6 years ago)
- Location:
- trunk/src/core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/common-queries.xml
r7290 r7298 3583 3583 SELECT [annotationtype_id], [id], [version], [unit_id], [value_id], [last_update], [project_id], [override_id] 3584 3584 FROM [Annotations] 3585 WHERE [annotationset_id] = :annotationSet AND [source] = 0 AND ([project_id] = 0OR [project_id] = :activeProject)3585 WHERE [annotationset_id] = :annotationSet AND [source] = 0 AND ([project_id] = :defaultProject OR [project_id] = :activeProject) 3586 3586 </sql> 3587 3587 <description> -
trunk/src/core/net/sf/basedb/core/AnnotationBatcher.java
r7259 r7298 77 77 </ul> 78 78 79 The batcher support project-specific annotations. The default mode (setting projectId=null) 80 makes the batcher to use the currently active project. Project-specific annotation values 81 will only be created if they are different from the default values. 82 83 Setting projectId to 0 or to a specific project makes the batcher to only consider 84 default or the project-specific values. The currently active project is not taken into 85 account. 86 79 87 @author nicklas 80 88 @since 3.8 … … 90 98 private final Item itemType; 91 99 private final int activeProjectId; 100 private final Integer projectId; 92 101 93 102 // All updates through this batcher get the same date+time … … 163 172 private final Map<String, UnitConverter> unitConvertes; 164 173 174 public AnnotationBatcher(DbControl dc, Item itemType) 175 { 176 this(dc, itemType, null); 177 } 178 165 179 /** 166 180 Create a new batcher instance. 167 181 @param dc A DbControl to use for database access 168 182 @param itemType The type of items to work with. This must be an annotatable item type. 183 @param projectId Specify a project id to only consider values for that project 184 when working with a project-specific annotation, or 0 to only consider default 185 values, or null to automatically use the default or project-specific values for 186 the currently active project 187 @since 3.11 169 188 */ 170 189 @SuppressWarnings({ "unchecked", "rawtypes" }) 171 public AnnotationBatcher(DbControl dc, Item itemType )190 public AnnotationBatcher(DbControl dc, Item itemType, Integer projectId) 172 191 { 173 192 if (dc == null) throw new NullPointerException("dc"); … … 179 198 180 199 this.itemType = itemType; 181 this.activeProjectId = dc.getSessionControl().getActiveProjectId(); 200 this.projectId = projectId; 201 this.activeProjectId = projectId == null ? dc.getSessionControl().getActiveProjectId() : projectId; 182 202 this.batchDate = new Date(); 183 203 … … 218 238 PredefinedQuery.getQueryString("AB_LOAD_ANNOTATION_INFO")); 219 239 loadAnnotationInfo.setInteger("activeProject", activeProjectId); 240 loadAnnotationInfo.setInteger("defaultProject", projectId == null ? 0 : projectId); 220 241 this.loadAnnotationValues = new org.hibernate.Query[types.length]; 221 242 this.valueIds = new List[types.length]; … … 675 696 { 676 697 677 if ( info.useProjectAnnotations && info.projectId == 0 && activeProjectId != 0)698 if (projectId == null && info.useProjectAnnotations && info.projectId == 0 && activeProjectId != 0) 678 699 { 679 700 // Deleting a default value for a project-specific annotation type is only allowed … … 787 808 // If the current info is default values for a project-specific annotation 788 809 // type we need to create a new annotation that is overriding the default values 789 if ( info.useProjectAnnotations && info.projectId == 0 && activeProjectId != 0)810 if (projectId == null && info.useProjectAnnotations && info.projectId == 0 && activeProjectId != 0) 790 811 { 791 812 info.overrideId = info.annotationId;
Note: See TracChangeset
for help on using the changeset viewer.