Changeset 6728
- Timestamp:
- Feb 13, 2015, 9:00:01 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/common-queries.xml
r6631 r6728 1949 1949 </query> 1950 1950 1951 <query id="LOAD_ANNOTATIONSET_INHERITING_ANNOTATIONTYPE" type="SQL"> 1952 <sql> 1953 SELECT [ia].[annotationset_id] FROM [InheritedAnnotations] [ia] 1954 INNER JOIN [Annotations] [a] ON [a].[id] = [ia].[annotation_id] 1955 WHERE [a].[annotationtype_id] = :annotationType 1956 </sql> 1957 <description> 1958 An SQL query that load the ID of all annotation sets that 1959 are inheriting a given annotation type. 1960 </description> 1961 </query> 1962 1963 <query id="DELETE_INHERITED_ANNOTATIONS" type="SQL"> 1964 <sql> 1965 DELETE FROM [InheritedAnnotations] 1966 WHERE [annotation_id] IN ( 1967 SELECT [id] FROM [Annotations] WHERE [annotationtype_id] = :annotationType 1968 ) 1969 </sql> 1970 <description> 1971 An SQL query that delete all directly inherited annotations of the specified 1972 annotation type. 1973 </description> 1974 </query> 1975 1951 1976 <query id="UPDATE_BYTES_FOR_EXPERIMENT" type="HQL"> 1952 1977 <sql> -
trunk/src/core/net/sf/basedb/core/AnnotationSet.java
r6721 r6728 755 755 @throws PermissionDeniedException If the logged in user 756 756 doesn't have write permission for this annotation set or 757 use permission for the annotation 757 use permission for the annotation or if the annotation type is not 758 enabled for inheritance 758 759 @throws InvalidDataException If the annotation is null 759 760 */ … … 764 765 if (annotation == null) throw new InvalidUseOfNullException("annotation"); 765 766 annotation.checkPermission(Permission.USE); 767 if (annotation.getAnnotationType().getDisableInheritance()) 768 { 769 throw new PermissionDeniedException("Inheritance has been disabled on " + annotation.getAnnotationType()); 770 } 766 771 if (getData().getInherited().add(annotation.getData())) 767 772 { -
trunk/src/core/net/sf/basedb/core/AnnotationType.java
r6465 r6728 913 913 } 914 914 915 915 /** 916 If this flag is set, annotations of this type can't be inherited 917 to child items. Use this to prevent sensitive data from being used 918 in other contexts. 919 @since 3.5 920 */ 921 public boolean getDisableInheritance() 922 { 923 return getData().getDisableInheritance(); 924 } 925 926 /** 927 If this flag is set, annotations of this type can't be inherited 928 to child items. Use this to prevent sensitive data from being used 929 in other contexts. Changing this from FALSE to TRUE will automatically 930 trigger a database action that remove all existing inherited annotations 931 of this type. 932 @throws PermissionDeniedException If the logged in user doesn't 933 have write permission 934 @since 3.5 935 */ 936 public void setDisableInheritance(boolean disableInheritance) 937 throws PermissionDeniedException 938 { 939 checkPermission(Permission.WRITE); 940 if (disableInheritance && !getData().getDisableInheritance() && isInDatabase()) 941 { 942 getDbControl().addTransactionalAction(new RemoveInheritedAnnotationsAction(this)); 943 } 944 getData().setDisableInheritance(disableInheritance); 945 } 946 916 947 /** 917 948 Get the minumum allowed value for an {@link Type#INT} or {@link Type#LONG} … … 1408 1439 } 1409 1440 1441 static class RemoveInheritedAnnotationsAction 1442 implements TransactionalAction 1443 { 1444 private final AnnotationType at; 1445 1446 public RemoveInheritedAnnotationsAction(AnnotationType at) 1447 { 1448 this.at = at; 1449 } 1450 1451 @Override 1452 public void onBeforeCommit() 1453 { 1454 // Verify that the disable flag is still set 1455 if (at.getDisableInheritance()) 1456 { 1457 DbControl dc = at.getDbControl(); 1458 org.hibernate.Session session = dc.getHibernateSession(); 1459 1460 org.hibernate.Query query = HibernateUtil.getPredefinedSQLQuery(session, "LOAD_ANNOTATIONSET_INHERITING_ANNOTATIONTYPE"); 1461 query.setInteger("annotationType", at.getId()); 1462 List<Integer> ids = HibernateUtil.loadList(Integer.class, query, dc.getSessionControl()); 1463 SnapshotManager.removeSnapshots(ids); 1464 1465 query = HibernateUtil.getPredefinedSQLQuery(session, "DELETE_INHERITED_ANNOTATIONS"); 1466 query.setInteger("annotationType", at.getId()); 1467 query.executeUpdate(); 1468 } 1469 } 1470 1471 // Nothing to do 1472 @Override 1473 public void onAfterCommit() 1474 {} 1475 1476 // Nothing to do 1477 @Override 1478 public void onRollback() 1479 {} 1480 1481 } 1410 1482 } -
trunk/src/core/net/sf/basedb/core/Install.java
r6631 r6728 118 118 method. 119 119 */ 120 public static final int NEW_SCHEMA_VERSION = Integer.valueOf(11 8).intValue();120 public static final int NEW_SCHEMA_VERSION = Integer.valueOf(119).intValue(); 121 121 122 122 public static synchronized int createTables(SchemaGenerator.Mode mode, ProgressReporter progress, -
trunk/src/core/net/sf/basedb/core/Update.java
r6631 r6728 210 210 </td> 211 211 </tr> 212 <tr> 213 <td>119</td> 214 <td> 215 Added {@link AnnotationTypeData#getDisableInheritance()}. 216 The update will set the value to FALSE for all existing annotation types. 217 </td> 218 </tr> 212 219 </table> 213 220 … … 331 338 } 332 339 333 if (schemaVersion < 11 8)334 { 335 if (progress != null) progress.display((int)(progress_current), "--Updating schema version: " + schemaVersion + " -> 11 8...");336 // Schemaversion 118 only updates the version number337 schemaVersion = setSchemaVersionInTransaction(session, 11 8);340 if (schemaVersion < 119) 341 { 342 if (progress != null) progress.display((int)(progress_current), "--Updating schema version: " + schemaVersion + " -> 119..."); 343 // Schemaversion 118-119 only updates the version number 344 schemaVersion = setSchemaVersionInTransaction(session, 119); 338 345 progress_current += progress_step; 339 346 } … … 568 575 "SET sv.appId = :appId WHERE sv.appId IS NULL"); 569 576 query.setString("appId", SchemaVersionData.BASE_APP_ID); 577 query.executeUpdate(); 578 } 579 580 if (schemaVersion < 119) 581 { 582 // Set disableInheritance=false on all annotation types 583 org.hibernate.Query query = HibernateUtil.createQuery(session, 584 "UPDATE AnnotationTypeData at " + 585 "SET at.disableInheritance = false " + 586 "WHERE at.disableInheritance IS NULL"); 570 587 query.executeUpdate(); 571 588 } -
trunk/src/core/net/sf/basedb/core/data/AnnotationTypeData.java
r6358 r6728 264 264 } 265 265 266 private boolean disableInheritance; 267 /** 268 If this flag is set, annotation of this type can't be inherited. 269 @since 3.5 270 @hibernate.property column="`disable_inherit`" type="boolean" not-null="true" 271 */ 272 public boolean getDisableInheritance() 273 { 274 return disableInheritance; 275 } 276 public void setDisableInheritance(boolean disableInheritance) 277 { 278 this.disableInheritance = disableInheritance; 279 } 280 266 281 private Set<Integer> itemTypes; 267 282 /** -
trunk/src/core/net/sf/basedb/core/snapshot/SnapshotManager.java
r6721 r6728 76 76 String cacheKey = getCacheKey(annotationSetId); 77 77 return cache.delete(cacheKey, 1000); 78 } 79 80 /** 81 Removes a list of snapshots from the static cache. 82 @param annotationSetIds A list with IDs of annotation set s 83 @return The number of successfully removed snapshots 84 @since 3.5 85 */ 86 public static int removeSnapshots(List<Integer> annotationSetIds) 87 { 88 StaticCache cache = Application.getStaticCache(); 89 int removed = 0; 90 for (Integer i : annotationSetIds) 91 { 92 String cacheKey = getCacheKey(i); 93 if (cache.delete(cacheKey, 1000)) removed++; 94 } 95 return removed; 78 96 } 79 97 -
trunk/www/admin/annotationtypes/edit_annotationtype.jsp
r6684 r6728 398 398 <td></td> 399 399 </tr> 400 <tr> 401 <th><label for="disable_inheritance">Disable inheritance</label></th> 402 <td><input type="checkbox" name="disable_inheritance" id="disable_inheritance" value="1" 403 <%=(annotationType != null && annotationType.getDisableInheritance()) || 404 (annotationType == null && Values.getBoolean(cc.getPropertyValue("disableInheritance"))) ? "checked" : ""%> 405 > 406 </td> 407 <td></td> 408 </tr> 400 409 <tr class="dynamic"> 401 410 <th>Description</th> -
trunk/www/admin/annotationtypes/index.jsp
r6358 r6728 191 191 annotationType.setProtocolParameter(Values.getBoolean(request.getParameter("is_protocol_parameter"))); 192 192 annotationType.setDisableLogOfValues(Values.getBoolean(request.getParameter("disable_log"))); 193 annotationType.setDisableInheritance(Values.getBoolean(request.getParameter("disable_inheritance"))); 193 194 if (annotationType.getValueType().canEnumerate()) 194 195 { -
trunk/www/admin/annotationtypes/list_annotationtypes.jsp
r6706 r6728 281 281 /> 282 282 <tbl:columndef 283 id="disableInheritance" 284 property="disableInheritance" 285 datatype="boolean" 286 title="Disable inheritance" 287 sortable="true" 288 filterable="true" 289 exportable="true" 290 /> 291 <tbl:columndef 283 292 id="isEnumeration" 284 293 property="enumeration" … … 603 612 <tbl:cell column="isProtocolParameter"><%=item.isProtocolParameter() ? "yes" : "no"%></tbl:cell> 604 613 <tbl:cell column="disableLogOfValues"><%=item.getDisableLogOfValues() ? "yes" : "no"%></tbl:cell> 614 <tbl:cell column="disableInheritance"><%=item.getDisableInheritance() ? "yes" : "no"%></tbl:cell> 605 615 <tbl:cell column="multiplicity"><%=item.getMultiplicity() == 0 ? "<i>- unlimited -</i>" : item.getMultiplicity()%></tbl:cell> 606 616 <tbl:cell column="defaultValue"><%=HTML.encodeTags(item.getDefaultValue())%></tbl:cell> -
trunk/www/admin/annotationtypes/view_annotationtype.jsp
r6605 r6728 278 278 <th>Disable change log</th> 279 279 <td><%=annotationType.getDisableLogOfValues() ? "yes" : "no"%></td> 280 </tr> 281 <tr> 282 <th>Disable inheritance</th> 283 <td><%=annotationType.getDisableInheritance() ? "yes" : "no"%></td> 280 284 </tr> 281 285 <tr>
Note: See TracChangeset
for help on using the changeset viewer.