Changeset 6937
- Timestamp:
- Aug 7, 2015, 8:34:06 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/common-queries.xml
r6920 r6937 1958 1958 </query> 1959 1959 1960 <query id="NULLIFY_LINK_FROM_CLONES" type="HQL"> 1961 <sql> 1962 UPDATE AnnotationData ad 1963 SET ad.inheritedFrom = null 1964 WHERE ad.inheritedFrom = :targetId 1965 AND ad.source = 2 1966 </sql> 1967 <description> 1968 A HQL query that nullify the link from all cloned annotations 1969 to a specified target annotation. 1970 </description> 1971 </query> 1972 1960 1973 <query id="UPDATE_BYTES_FOR_EXPERIMENT" type="HQL"> 1961 1974 <sql> -
trunk/src/core/net/sf/basedb/core/Annotation.java
r6926 r6937 23 23 package net.sf.basedb.core; 24 24 25 import net.sf.basedb.core.Transactional.Action; 25 26 import net.sf.basedb.core.data.AnnotationData; 26 27 import net.sf.basedb.core.data.AnnotationTypeData; … … 218 219 super.initPermissions(granted, denied); 219 220 } 221 222 /** 223 Nullify links to this annotation from cloned annotations when this annotation is deleted 224 (since the cloned annotation should not be deleted). 225 */ 226 @Override 227 void onBeforeCommit(Action action) 228 throws BaseException 229 { 230 super.onBeforeCommit(action); 231 if (action == Action.DELETE && getSource() == Annotation.Source.PRIMARY) 232 { 233 org.hibernate.Session session = getDbControl().getHibernateSession(); 234 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, 235 "NULLIFY_LINK_FROM_CLONES"); 236 /* 237 UPDATE AnnotationData ad 238 SET ad.inheritedFrom = null 239 WHERE ad.inheritedFrom = :targetId 240 AND ad.source = CLONED 241 */ 242 query.setInteger("targetId", getId()); 243 HibernateUtil.executeUpdate(query); 244 } 245 } 246 220 247 @Override 221 248 PluginPermission getPluginPermissions() -
trunk/src/core/net/sf/basedb/core/AnnotationSet.java
r6926 r6937 855 855 856 856 /** 857 Remove an inherited an annotation. 857 Remove an inherited an annotation. The specified annotation can be 858 either a CLONED or INHERITED annotation in this set or the PRIMARY 859 annotation of another annotation set that is inherited/cloned by 860 this set. 861 858 862 @param annotation The annotation to remove 859 863 @throws PermissionDeniedException If the logged in user … … 870 874 AnnotationData toRemove = annotation.getData(); 871 875 Iterator<AnnotationData> it = getData().getAnnotations().iterator(); 876 boolean checkInherited = annotation.getSource() == Annotation.Source.PRIMARY; 877 872 878 while (it.hasNext()) 873 879 { 874 880 AnnotationData ad = it.next(); 875 if (toRemove.equals(ad.getInheritedFrom())) 881 boolean remove = checkInherited ? toRemove.equals(ad.getInheritedFrom()) : toRemove.equals(ad); 882 if (remove) 876 883 { 877 884 Annotation a = dc.getItem(Annotation.class, ad); -
trunk/src/core/net/sf/basedb/core/snapshot/AnnotationSnapshot.java
r6922 r6937 127 127 public boolean isInherited() 128 128 { 129 return inheritedFromId != 0;129 return getSource() != Annotation.Source.PRIMARY; 130 130 } 131 131 … … 605 605 { 606 606 this.inheritedFrom = inheritedFrom; 607 if (inheritedFrom == null) 608 { 609 this.inheritedFromId = 0; 610 this.inheritedFromSetId = 0; 611 } 607 612 } 608 613 -
trunk/src/core/net/sf/basedb/core/snapshot/SnapshotManager.java
r6922 r6937 198 198 { 199 199 shot.setItem(snapshot.getItemId(), snapshot.getItemType()); 200 result.add(shot);201 200 202 201 AnnotationSetSnapshot recursive = getSnapshot(dc, shot.getInheritedAnnotationSetId()); 202 AnnotationSnapshot inheritedFrom = null; 203 203 if (recursive != null) 204 204 { … … 211 211 if (primary.size() > 0) 212 212 { 213 shot.setInheritedFrom(primary.get(0));213 inheritedFrom = primary.get(0); 214 214 } 215 } 216 shot.setInheritedFrom(inheritedFrom); 217 if (inheritedFrom != null || shot.getSource() == Annotation.Source.CLONED) 218 { 219 result.add(shot); 215 220 } 216 221 } -
trunk/src/core/net/sf/basedb/util/annotations/InheritAnnotationsManager.java
r6926 r6937 99 99 for (AnnotationSnapshot inherited : snapshotManager.findAnnotations(dc, snapshot, removeFilter, false, true)) 100 100 { 101 as.removeInheritedAnnotation(inherited.get InheritedAnnotation(dc));101 as.removeInheritedAnnotation(inherited.getThisAnnotation(dc)); 102 102 } 103 103 … … 155 155 { 156 156 // We only remove the annotation if it is not the same we are going to add later 157 as.removeInheritedAnnotation(e.get InheritedAnnotation(dc));157 as.removeInheritedAnnotation(e.getThisAnnotation(dc)); 158 158 } 159 159 else -
trunk/www/common/annotations/inherit.jsp
r6912 r6937 246 246 final AnnotationSet as = item != null && item.isAnnotated() ? item.getAnnotationSet() : null; 247 247 Set<Annotation> inheritedAnnotations = null; 248 248 249 if (as != null) 249 250 { 250 ItemQuery<Annotation> inheritedQuery = as.getInheritedAnnotations(); 251 ItemQuery<Annotation> inheritedQuery = as.getAnnotations(null); 252 inheritedQuery.restrict( 253 Restrictions.neq( 254 Hql.property("source"), 255 Expressions.integer(Annotation.Source.PRIMARY.ordinal()) 256 )); 257 251 258 inheritedQuery.order(Orders.asc(Hql.property("annotationSet"))); 252 259 inheritedQuery.order(Orders.asc(Hql.property("annotationType.name"))); 253 inheritedAnnotations = new HashSet<Annotation>(inheritedQuery.list(dc)); 254 for (Annotation a : inheritedAnnotations) 255 { 256 AnnotationSet from = a.getAnnotationSet(); 257 if (!parentAnnotations.contains(from) && from.hasPermission(Permission.USE)) 258 { 259 parentAnnotations.add(from); 260 nonParents.add(from); 260 inheritedAnnotations = new HashSet<Annotation>(); 261 for (Annotation a : inheritedQuery.list(dc)) 262 { 263 a = a.getInheritedFrom(); 264 if (a != null) 265 { 266 inheritedAnnotations.add(a); 267 AnnotationSet from = a.getAnnotationSet(); 268 if (!parentAnnotations.contains(from) && from.hasPermission(Permission.USE)) 269 { 270 parentAnnotations.add(from); 271 nonParents.add(from); 272 } 261 273 } 262 274 } -
trunk/www/common/annotations/list_annotations.jsp
r6922 r6937 119 119 { 120 120 AnnotationType at = a.getAnnotationType(dc); 121 if ( !a.isInherited())121 if (a.getSource() == Annotation.Source.PRIMARY) 122 122 { 123 123 existing.put(a.getAnnotationType(dc), a); … … 470 470 /> 471 471 <tbl:columndef 472 id="values" 473 title="Values" 474 /> 475 <tbl:columndef 472 476 id="source" 473 477 title="Cloned" … … 476 480 id="item" 477 481 title="From item" 478 />479 <tbl:columndef480 id="values"481 title="Values"482 482 /> 483 483 <tbl:columndef
Note: See TracChangeset
for help on using the changeset viewer.