Changeset 6686
- Timestamp:
- Jan 20, 2015, 1:55:44 PM (8 years ago)
- Location:
- trunk/src/core/net/sf/basedb/core
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/AnnotationBetweenRestriction.java
r6127 r6686 45 45 46 46 /** 47 @since 2.4 48 @deprecated In 3.5; Use {@link #AnnotationBetweenRestriction(String, AnnotationType, Object, Object, boolean, boolean)} instead 49 */ 50 @Deprecated 51 public AnnotationBetweenRestriction(String alias, AnnotationType annotationType, Object lowValue, Object highValue, boolean includeInheriting) 52 throws InvalidDataException 53 { 54 this(alias, annotationType, lowValue, highValue, true, includeInheriting); 55 } 56 57 58 /** 59 @since 3.0 60 @deprecated In 3.5; Use {@link #AnnotationBetweenRestriction(String, int, Type, Object, Object, boolean, boolean)} instead 61 */ 62 @Deprecated 63 public AnnotationBetweenRestriction(String alias, int annotationTypeId, Type valueType, Object lowValue, Object highValue, 64 boolean includeInheriting) 65 throws InvalidDataException 66 { 67 this(alias, annotationTypeId, valueType, lowValue, highValue, true, includeInheriting); 68 } 69 70 /** 47 71 Create a new annotation restriction. 48 72 … … 56 80 correct value type for the annotation as defined by the 57 81 {@link AnnotationType#getValueType()} property 82 @param includePrimary If items with this annotation as a primary annotation 83 should be returned by the query or not 58 84 @param includeInheriting If items inherting the annotation should be returned 59 85 by the query or not 60 86 @throws InvalidDataException If any of the parameters are null 61 87 or not follow the rules above. 62 @since 2.4 63 */ 64 public AnnotationBetweenRestriction(String alias, AnnotationType annotationType, Object lowValue, Object highValue, boolean includeInheriting) 88 @since 3.5 89 */ 90 public AnnotationBetweenRestriction(String alias, AnnotationType annotationType, Object lowValue, Object highValue, 91 boolean includePrimary, boolean includeInheriting) 65 92 throws InvalidDataException 66 93 { 67 94 this(alias, annotationType.getId(), annotationType.getValueType(), lowValue, highValue, includeInheriting); 68 95 } 69 70 96 97 71 98 /** 72 99 Create a new annotation restriction. … … 82 109 correct value type for the annotation as defined by the 83 110 valueType property 111 @param includePrimary If items with this annotation as a primary annotation 112 should be returned by the query or not 84 113 @param includeInheriting If items inherting the annotation should be returned 85 114 by the query or not 86 115 @throws InvalidDataException If any of the parameters are null 87 116 or not follow the rules above. 88 @since 3. 0117 @since 3.5 89 118 */ 90 119 public AnnotationBetweenRestriction(String alias, int annotationTypeId, Type valueType, Object lowValue, Object highValue, 91 boolean include Inheriting)92 throws InvalidDataException 93 { 94 super(alias, annotationTypeId, valueType, include Inheriting);120 boolean includePrimary, boolean includeInheriting) 121 throws InvalidDataException 122 { 123 super(alias, annotationTypeId, valueType, includePrimary, includeInheriting); 95 124 if (lowValue == null) throw new InvalidUseOfNullException("lowValue"); 96 125 if (highValue == null) throw new InvalidUseOfNullException("highValue"); … … 109 138 } 110 139 111 112 140 /* 113 141 From the AnnotationRestriction class -
trunk/src/core/net/sf/basedb/core/AnnotationInRestriction.java
r6127 r6686 46 46 47 47 /** 48 Create a new annotation restriction. 48 @since 2.4 49 @deprecated In 3.5; use {@link #AnnotationInRestriction(String, AnnotationType, boolean, boolean, Object...) instead 50 */ 51 @Deprecated 52 public AnnotationInRestriction(String alias, AnnotationType annotationType, boolean includeInheriting, Object... values) 53 throws InvalidDataException 54 { 55 this(alias, annotationType, true, includeInheriting, values); 56 } 57 58 /** 59 Create a new annotation restriction. At least one of 60 includePrimary and includeInheriting must be true. 49 61 50 62 @param alias The alias to use in the restriction. 51 63 @param annotationType The annotation type to use in the query 64 @param includePrimary If items with primary annotation should be returned or not 52 65 @param includeInheriting If items inherting the annotation should be returned 53 66 by the query or not … … 57 70 @throws InvalidDataException If any of the parameters are null 58 71 or the array is empty or not follow the rules above. 59 @since 2.472 @since 3.5 60 73 */ 61 public AnnotationInRestriction(String alias, AnnotationType annotationType, boolean include Inheriting, Object... values)74 public AnnotationInRestriction(String alias, AnnotationType annotationType, boolean includePrimary, boolean includeInheriting, Object... values) 62 75 throws InvalidDataException 63 76 { 64 super(alias, annotationType, include Inheriting);77 super(alias, annotationType, includePrimary, includeInheriting); 65 78 if (values == null || values.length == 0) throw new InvalidUseOfNullException("values"); 66 79 for (int i = 0; i < values.length; ++i) … … 75 88 this.values = Arrays.asList(values); 76 89 } 90 77 91 /* 78 92 From the AnnotationRestriction class -
trunk/src/core/net/sf/basedb/core/AnnotationRestriction.java
r6444 r6686 63 63 final Type valueType; 64 64 final int annotationTypeId; 65 final boolean includePrimary; 65 66 final boolean includeInheriting; 66 67 final String alias; … … 70 71 @param annotationType The annotation type to use in the query 71 72 */ 72 AnnotationRestriction(String alias, AnnotationType annotationType, boolean include Inheriting)73 AnnotationRestriction(String alias, AnnotationType annotationType, boolean includePrimary, boolean includeInheriting) 73 74 throws InvalidDataException 74 75 { 75 76 if (annotationType == null) throw new InvalidUseOfNullException("annotationType"); 77 if (!includePrimary && !includeInheriting) 78 { 79 throw new InvalidDataException("Both includePrimary and includeInheriting parameters are FALSE"); 80 } 76 81 this.annotationTypeId = annotationType.getId(); 77 82 this.valueType = annotationType.getValueType(); 83 this.includePrimary = includePrimary; 78 84 this.includeInheriting = includeInheriting; 79 85 this.alias = alias; … … 89 95 @param valueType The type of values for annotations 90 96 */ 91 AnnotationRestriction(String alias, int annotationTypeId, Type valueType, boolean include Inheriting)97 AnnotationRestriction(String alias, int annotationTypeId, Type valueType, boolean includePrimary, boolean includeInheriting) 92 98 throws InvalidDataException 93 99 { 100 if (!includePrimary && !includeInheriting) 101 { 102 throw new InvalidDataException("Both includePrimary and includeInheriting parameters are FALSE"); 103 } 94 104 this.annotationTypeId = annotationTypeId; 95 105 this.valueType = valueType; 106 this.includePrimary = includePrimary; 96 107 this.includeInheriting = includeInheriting; 97 108 this.alias = alias; … … 193 204 if (debugSqlEnabled) logSql.debug("Executing annotation query: " + sql); 194 205 List<Integer> ids = HibernateUtil.loadList(Integer.class, sqlQuery, sc); 195 annotationSets = new StringBuilder( annotationSetIds);206 annotationSets = new StringBuilder(includePrimary ? annotationSetIds : "0"); 196 207 for (Integer id : ids) 197 208 { -
trunk/src/core/net/sf/basedb/core/AnnotationSimpleRestriction.java
r6127 r6686 52 52 53 53 /** 54 @since 2.4 55 @deprecated In 3.5; Use {@link #AnnotationSimpleRestriction(String, AnnotationType, Operator, Object, boolean, boolean)} instead 56 */ 57 @Deprecated 58 public AnnotationSimpleRestriction(String alias, AnnotationType annotationType, Operator operator, Object value, boolean includeInheriting) 59 throws InvalidDataException 60 { 61 this(alias, annotationType, operator, value, true, includeInheriting); 62 } 63 64 /** 54 65 Create a new annotation restriction using a simple expression: 55 66 <code>annotation operator value</code>. … … 63 74 correct value type for the annotation as defined by the 64 75 {@link AnnotationType#getValueType()} property 76 @param includePrimary If items with primary annotation should be returned or not 65 77 @param includeInheriting If items inherting the annotation should be returned 66 78 by the query or not 67 79 @throws InvalidDataException If any of the parameters are null 68 80 or not follow the rules above. 69 @since 2.4 70 */ 71 public AnnotationSimpleRestriction(String alias, AnnotationType annotationType, Operator operator, Object value, boolean includeInheriting) 72 throws InvalidDataException 73 { 74 super(alias, annotationType, includeInheriting); 81 @since 3.5 82 */ 83 public AnnotationSimpleRestriction(String alias, AnnotationType annotationType, Operator operator, Object value, 84 boolean includePrimary, boolean includeInheriting) 85 throws InvalidDataException 86 { 87 super(alias, annotationType, includePrimary, includeInheriting); 75 88 if (operator == null) throw new InvalidUseOfNullException("operator"); 76 89 if (value == null) throw new InvalidUseOfNullException("value"); … … 89 102 } 90 103 104 105 /** 106 @since 2.4 107 @deprecated in 3.5; Use {@link #AnnotationSimpleRestriction(String, int, Type, Operator, Object, boolean, boolean)} instead 108 */ 109 public AnnotationSimpleRestriction(String alias, int annotationTypeId, Type valueType, Operator operator, Object value, boolean includeInheriting) 110 throws InvalidDataException 111 { 112 this(alias, annotationTypeId, valueType, operator, value, true, includeInheriting); 113 } 91 114 92 115 /** … … 102 125 correct value type for the annotation as defined by the 103 126 {@link AnnotationType#getValueType()} property 127 @param includePrimary If items with primary annotation should be returned or not 104 128 @param includeInheriting TRUE if items inheriting the annotation should be returned by the query, FALSE otherwise 105 129 @throws InvalidDataException If any of the parameters are null 106 130 or not follow the rules above 107 @since 2.4 108 */ 109 public AnnotationSimpleRestriction(String alias, int annotationTypeId, Type valueType, Operator operator, Object value, boolean includeInheriting) 110 throws InvalidDataException 111 { 112 super(alias, annotationTypeId, valueType, includeInheriting); 131 @since 3.5 132 */ 133 public AnnotationSimpleRestriction(String alias, int annotationTypeId, Type valueType, Operator operator, Object value, 134 boolean includePrimary, boolean includeInheriting) 135 throws InvalidDataException 136 { 137 super(alias, annotationTypeId, valueType, includePrimary, includeInheriting); 113 138 if (valueType == null) throw new InvalidUseOfNullException("valueType"); 114 139 if (operator == null) throw new InvalidUseOfNullException("operator"); … … 126 151 this.value = value; 127 152 this.values = null; 153 } 154 155 156 /** 157 @since 2.5 158 @deprecated In 3.5; Use {@link #AnnotationSimpleRestriction(String, int, Type, Operator, List, boolean, boolean)} instead 159 */ 160 @Deprecated 161 public AnnotationSimpleRestriction(String alias, int annotationTypeId, Type valueType, Operator operator, List<Object> values, boolean includeInheriting) 162 throws InvalidDataException 163 { 164 this(alias, annotationTypeId, valueType, operator, values, true, includeInheriting); 128 165 } 129 166 … … 141 178 correct value type for the annotation as defined by the 142 179 {@link AnnotationType#getValueType()} property. 180 @param includePrimary If items with primary annotation should be returned or not 143 181 @param includeInheriting TRUE if items inheriting the annotation should be returned by the query, FALSE otherwise 144 182 @throws InvalidDataException If any of the parameters are null 145 183 or not follow the rules above 146 @since 2.5 147 */ 148 public AnnotationSimpleRestriction(String alias, int annotationTypeId, Type valueType, Operator operator, List<Object> values, boolean includeInheriting) 149 throws InvalidDataException 150 { 151 super(alias, annotationTypeId, valueType, includeInheriting); 184 @since 3.5 185 */ 186 public AnnotationSimpleRestriction(String alias, int annotationTypeId, Type valueType, Operator operator, List<Object> values, 187 boolean includePrimary, boolean includeInheriting) 188 throws InvalidDataException 189 { 190 super(alias, annotationTypeId, valueType, includePrimary, includeInheriting); 152 191 if (valueType == null) throw new InvalidUseOfNullException("valueType"); 153 192 if (operator == null) throw new InvalidUseOfNullException("operator"); … … 169 208 this.value = null; 170 209 } 171 210 172 211 /* 173 212 From the AnnotationRestriction class -
trunk/src/core/net/sf/basedb/core/HasAnnotationRestriction.java
r6127 r6686 43 43 44 44 /** 45 @deprecated In 3.5; Use {@link #HasAnnotationRestriction(String, AnnotationType, boolean, boolean, boolean)} instead 46 */ 47 @Deprecated 48 public HasAnnotationRestriction(String alias, AnnotationType annotationType, 49 boolean hasBeenAnnotatated, boolean includeInheriting) 50 { 51 this(alias, annotationType.getId(), hasBeenAnnotatated, true, includeInheriting); 52 } 53 54 /** 55 @deprecated In 3.5; Use {@link #HasAnnotationRestriction(String, int, boolean, boolean, boolean)} instead 56 */ 57 @Deprecated 58 public HasAnnotationRestriction(String alias, int annotationTypeId, 59 boolean hasBeenAnnotatated, boolean includeInheriting) 60 { 61 this(alias, annotationTypeId, hasBeenAnnotatated, true, includeInheriting); 62 } 63 64 /** 45 65 Create a new restriction that checks if an item has been annotatated 46 66 or not. … … 51 71 @param hasBeenAnnotatated TRUE to look for items that has been annotated with the given 52 72 annotation type, FALSE to look for items that hasn't 73 @param includePrimary If items with this annotation as a primary annotation 74 should be returned by the query or not 53 75 @param includeInheriting If items inherting the annotation should be returned 54 76 by the query or not 77 @since 3.5 55 78 */ 56 79 public HasAnnotationRestriction(String alias, AnnotationType annotationType, 57 boolean hasBeenAnnotatated, boolean include Inheriting)80 boolean hasBeenAnnotatated, boolean includePrimary, boolean includeInheriting) 58 81 { 59 this(alias, annotationType.getId(), hasBeenAnnotatated, include Inheriting);82 this(alias, annotationType.getId(), hasBeenAnnotatated, includePrimary, includeInheriting); 60 83 } 61 84 62 85 /** 63 @see #HasAnnotationRestriction(String, AnnotationType, boolean, boolean) 86 @see #HasAnnotationRestriction(String, AnnotationType, boolean, boolean, boolean) 87 @since 3.5 64 88 */ 65 89 public HasAnnotationRestriction(String alias, int annotationTypeId, 66 boolean hasBeenAnnotatated, boolean include Inheriting)90 boolean hasBeenAnnotatated, boolean includePrimary, boolean includeInheriting) 67 91 { 68 super(alias, annotationTypeId, null, include Inheriting);92 super(alias, annotationTypeId, null, includePrimary, includeInheriting); 69 93 this.hasBeenAnnotatated = hasBeenAnnotatated; 70 94 } -
trunk/src/core/net/sf/basedb/core/PropertyFilter.java
r6684 r6686 492 492 // Property is id of annotation type: #id 493 493 // If prefixed with two ## inherited annotations should be searched 494 // We always search for one or the other; never both 494 495 boolean searchInherited = property.startsWith("##"); 496 boolean searchPrimary = !searchInherited; 497 495 498 int annotationTypeId = (Integer)Type.INT.parseString(property.substring(searchInherited ? 2 : 1)); 496 499 … … 551 554 } 552 555 restriction = new AnnotationBetweenRestriction(alias, annotationTypeId, getValueType(), 553 objects.get(0), objects.get(1), search Inherited);556 objects.get(0), objects.get(1), searchPrimary, searchInherited); 554 557 } 555 558 else 556 559 { 557 560 restriction = new AnnotationSimpleRestriction(alias,annotationTypeId, getValueType(), 558 operator, objects, search Inherited);561 operator, objects, searchPrimary, searchInherited); 559 562 } 560 563 … … 567 570 { 568 571 restriction = new HasAnnotationRestriction(alias, annotationTypeId, 569 operator != Operator.EQ, search Inherited);572 operator != Operator.EQ, searchPrimary, searchInherited); 570 573 } 571 574 else 572 575 { 573 576 restriction = new AnnotationSimpleRestriction(alias, annotationTypeId, getValueType(), 574 operator, value, search Inherited);577 operator, value, searchPrimary, searchInherited); 575 578 } 576 579 } -
trunk/src/core/net/sf/basedb/core/query/Annotations.java
r6132 r6686 54 54 @throws InvalidDataException If annotationType or value are null. 55 55 @since 2.4 56 */ 56 @deprecated In 3.5; Use{@link AnnotationSimpleRestriction} instead 57 */ 58 @Deprecated 57 59 public static Restriction eq(String alias, AnnotationType annotationType, Object value, boolean includeInheriting) 58 60 throws InvalidDataException … … 74 76 @throws InvalidDataException If annotationType or value are null. 75 77 @since 2.4 76 */ 78 @deprecated In 3.5; Use{@link AnnotationSimpleRestriction} instead 79 */ 80 @Deprecated 77 81 public static Restriction neq(String alias, AnnotationType annotationType, Object value, boolean includeInheriting) 78 82 throws InvalidDataException … … 94 98 @throws InvalidDataException If annotationType parameter or value parameter are null. 95 99 @since 2.4 96 */ 100 @deprecated In 3.5; Use{@link AnnotationSimpleRestriction} instead 101 */ 102 @Deprecated 97 103 public static Restriction lt(String alias, AnnotationType annotationType, Object value, boolean includeInheriting) 98 104 throws InvalidDataException … … 114 120 @throws InvalidDataException If annotationType parameter or value parameter are null. 115 121 @since 2.4 116 */ 122 @deprecated In 3.5; Use{@link AnnotationSimpleRestriction} instead 123 */ 124 @Deprecated 117 125 public static Restriction lteq(String alias, AnnotationType annotationType, Object value, boolean includeInheriting) 118 126 throws InvalidDataException … … 134 142 @throws InvalidDataException If annotationType parameter or value parameter are null. 135 143 @since 2.4 136 */ 144 @deprecated In 3.5; Use{@link AnnotationSimpleRestriction} instead 145 */ 146 @Deprecated 137 147 public static Restriction gt(String alias, AnnotationType annotationType, Object value, boolean includeInheriting) 138 148 throws InvalidDataException … … 154 164 @throws InvalidDataException If annotationType parameter or value parameter are null. 155 165 @since 2.4 156 */ 166 @deprecated In 3.5; Use{@link AnnotationSimpleRestriction} instead 167 */ 168 @Deprecated 157 169 public static Restriction gteq(String alias, AnnotationType annotationType, Object value, boolean includeInheriting) 158 170 throws InvalidDataException … … 174 186 @throws InvalidDataException If annotationType parameter or value parameter are null. 175 187 @since 2.4 176 */ 188 @deprecated In 3.5; Use{@link AnnotationSimpleRestriction} instead 189 */ 190 @Deprecated 177 191 public static Restriction like(String alias, AnnotationType annotationType, Object value, boolean includeInheriting) 178 192 throws InvalidDataException … … 195 209 @throws InvalidDataException If any of the required parameters are null. 196 210 @since 2.4, 3.0 (specified that low/high values are included) 197 */ 211 @deprecated In 3.5; Use{@link AnnotationBetweenRestriction} instead 212 */ 213 @Deprecated 198 214 public static Restriction between(String alias, AnnotationType annotationType, Object lowValue, Object highValue, boolean includeInheriting) 199 215 throws InvalidDataException … … 215 231 @throws InvalidDataException If annotationType parameter or values parameter are null 216 232 @since 2.4 217 */ 233 @deprecated In 3.5; Use{@link AnnotationInRestriction} instead 234 */ 235 @Deprecated 218 236 public static Restriction in(String alias, AnnotationType annotationType, boolean includeInheriting, Object... values) 219 237 throws InvalidDataException -
trunk/src/core/net/sf/basedb/core/snapshot/AnnotationLoaderUtil.java
r6539 r6686 23 23 24 24 import java.io.Serializable; 25 import java.util.ArrayList; 25 26 import java.util.List; 26 27 … … 48 49 private final Type valueType; 49 50 private final Unit defultUnit; 50 51 private AnnotationSnapshot snapshot; 51 private final boolean searchPrimary; 52 private final boolean searchInherited; 53 54 private List<AnnotationSnapshot> snapshots; 52 55 private UnitConverter converter; 53 56 private Unit unit; … … 56 59 /** 57 60 Create a loder that uses the given snapshot manager to load annotations 58 for a single annotation type. 61 for a single annotation type. The loader will load only primary annotations. 59 62 */ 60 63 public AnnotationLoaderUtil(DbControl dc, SnapshotManager manager, AnnotationType at) 64 { 65 this(dc, manager, at, true, false); 66 } 67 68 /** 69 Create a loder that uses the given snapshot manager to load annotations 70 for a single annotation type. The loader can be configured to load primary 71 and/or inherited annotations. 72 @since 3.5 73 */ 74 public AnnotationLoaderUtil(DbControl dc, SnapshotManager manager, AnnotationType at, boolean searchPrimary, boolean searchInherited) 61 75 { 62 76 this.dc = dc; 63 77 this.manager = manager; 64 78 this.at = at; 79 this.searchPrimary = searchPrimary; 80 this.searchInherited = searchInherited; 65 81 this.atId = at.getId(); 66 82 this.valueType = at.getValueType(); 67 83 this.defultUnit = at.getDefaultUnit(); 68 84 } 85 69 86 70 87 /* … … 96 113 97 114 /** 98 Find and load annotations from the given annotation set snapshot. The 99 loader will only load primary annotations. 115 Is this loader searching for primary annotations? 116 @since 3.5 117 */ 118 public boolean isSearchingPrimaryAnnotations() 119 { 120 return searchPrimary; 121 } 122 123 /** 124 Is this loader searching for inherited annotations? 125 @since 3.5 126 */ 127 public boolean isSearchingInheritedAnnotations() 128 { 129 return searchInherited; 130 } 131 132 133 /** 134 Same as findAll but only return a boolean instead of the number 135 of snapshots found. 136 100 137 @return TRUE if an annotation was found, FALSE if not 138 @see #findAll(AnnotationSetSnapshot) 101 139 */ 102 140 public boolean find(AnnotationSetSnapshot setSnapshot) 103 141 { 104 List<AnnotationSnapshot> list = manager.findAnnotations(dc, setSnapshot, this, false); 105 if (list.size() > 0) 106 { 107 snapshot = list.get(0); 108 unit = snapshot.getUnit(dc); 142 return findAll(setSnapshot) > 0; 143 } 144 145 /** 146 Find and load annotations from the given annotation set snapshot. 147 @return The number of snapshots found 148 @since 3.5 149 */ 150 public int findAll(AnnotationSetSnapshot setSnapshot) 151 { 152 snapshots = manager.findAnnotations(dc, setSnapshot, this, searchPrimary, searchInherited); 153 int size = snapshots.size(); 154 if (size > 1) 155 { 156 unit = defultUnit; 157 } 158 else if (size == 1) 159 { 160 unit = snapshots.get(0).getUnit(dc); 109 161 } 110 162 else 111 163 { 112 snapshot = null;113 164 unit = null; 114 165 } 115 166 if (unit != null) 116 167 { 117 converter = unit. getUnitConverter(defultUnit);168 converter = unit.equals(defultUnit) ? null : unit.getUnitConverter(defultUnit); 118 169 unitSymbol = unit.getDisplaySymbol(); 170 System.out.println(at + "; unit:" + unit + "; default: " + defultUnit + "; converter: "+ converter + "; symbol:"+unitSymbol); 119 171 } 120 172 else … … 123 175 unitSymbol = null; 124 176 } 125 return snapshot != null;177 return snapshots.size(); 126 178 } 127 179 128 180 /** 129 181 Get the snapshot for the last annotation found when calling 130 {@link #find(AnnotationSetSnapshot)} 182 {@link #findAll(AnnotationSetSnapshot)}. Note! If multiple 183 annotation snapshots were found, this will only return the 184 first hit. 185 131 186 @return A snapshot or null if no annotations are found 132 187 */ 133 188 public AnnotationSnapshot getSnapshot() 134 189 { 135 return snapshot; 190 return snapshots.size() > 0 ? snapshots.get(0) : null; 191 } 192 193 /** 194 Get all snapshots found by the last {@link #findAll(AnnotationSetSnapshot)} 195 call. 196 @return A list with AnnotationSnapshot objects 197 */ 198 public List<AnnotationSnapshot> getSnapshots() 199 { 200 return snapshots; 136 201 } 137 202 … … 143 208 public List<? extends Serializable> getValues() 144 209 { 145 return snapshot.getValues(converter, valueType); 210 List<Serializable> values = new ArrayList<Serializable>(); 211 for (AnnotationSnapshot s : snapshots) 212 { 213 values.addAll(s.getValues(converter, valueType)); 214 } 215 return values; 146 216 } 147 217 148 218 /** 149 219 Get the unit of the last annotation values that was found 150 by {@link #find(AnnotationSetSnapshot)}. 220 by {@link #find(AnnotationSetSnapshot)}. Note that if 221 multiple annotations was found with different units the default 222 unit of the annotation type is used. 151 223 @return A string or null if the annotation doesn't use units 152 224 */ -
trunk/src/core/net/sf/basedb/core/snapshot/SnapshotManager.java
r6037 r6686 114 114 } 115 115 116 /** 117 Find annotations. Alwasys search primary and optionally inherited. 118 @see #findAnnotations(DbControl, AnnotationSetSnapshot, Filter, boolean, boolean) 119 */ 120 public List<AnnotationSnapshot> findAnnotations(DbControl dc, AnnotationSetSnapshot snapshot, 121 Filter<? super AnnotationSnapshot> filter, boolean searchInherited) 122 { 123 return findAnnotations(dc, snapshot, filter, true, searchInherited); 124 } 116 125 117 126 /** … … 125 134 @param filter A filter that should match the wanted annotation snapshots 126 135 or null to match all annotations 127 @param search Inherited TRUE if inherited annotations should be searched,128 FALSE to only search primary annotations136 @param searchPrimary TRUE if primary annotations should be searched 137 @param searchInherited TRUE if inherited annotations should be searched 129 138 @return A list with the found annotations 139 @since 3.5 130 140 */ 131 141 public List<AnnotationSnapshot> findAnnotations(DbControl dc, AnnotationSetSnapshot snapshot, 132 Filter<? super AnnotationSnapshot> filter, boolean search Inherited)142 Filter<? super AnnotationSnapshot> filter, boolean searchPrimary, boolean searchInherited) 133 143 { 134 144 List<AnnotationSnapshot> result = new ArrayList<AnnotationSnapshot>(); 145 if (!searchPrimary && !searchInherited) return result; 146 135 147 if (filter == null) filter = new StaticFilter<AnnotationSnapshot>(true); 136 148 // Needed for recursive searching of inherited annotations … … 168 180 } 169 181 } 170 else if (shot.hasPermission(dc, Permission.READ))182 else 171 183 { 172 184 // Primary annotation 173 if (filter.evaluate(shot)) 185 if (!searchPrimary) continue; // with the next snapshot in the list 186 187 if (shot.hasPermission(dc, Permission.READ) && filter.evaluate(shot)) 174 188 { 175 189 shot.setItem(snapshot.getItemId(), snapshot.getItemType()); … … 182 196 183 197 /** 198 @see #findAnnotations(DbControl, Annotatable, Filter, boolean, boolean) 199 */ 200 public List<AnnotationSnapshot> findAnnotations(DbControl dc, Annotatable item, 201 Filter<? super AnnotationSnapshot> filter, boolean searchInherited) 202 { 203 return findAnnotations(dc, item, filter, true, searchInherited); 204 } 205 206 /** 184 207 Utility method for calling <code>getSnapshot</code> and <code>findAnnotations</code> 185 208 in one go. … … 187 210 item doesn't have any annotations) 188 211 @see #getSnapshot(DbControl, int) 189 @see #findAnnotations(DbControl, AnnotationSetSnapshot, Filter, boolean) 212 @see #findAnnotations(DbControl, AnnotationSetSnapshot, Filter, boolean, boolean) 213 @since 3.5 190 214 */ 191 215 public List<AnnotationSnapshot> findAnnotations(DbControl dc, Annotatable item, 192 Filter<? super AnnotationSnapshot> filter, boolean searchInherited)193 194 195 196 return findAnnotations(dc, snapshot, filter, searchInherited);197 216 Filter<? super AnnotationSnapshot> filter, boolean searchPrimary, boolean searchInherited) 217 { 218 if (!item.isAnnotated()) return Collections.emptyList(); 219 AnnotationSetSnapshot snapshot = getSnapshot(dc, item.getAnnotationSet().getId()); 220 return findAnnotations(dc, snapshot, filter, searchPrimary, searchInherited); 221 } 198 222 199 223 }
Note: See TracChangeset
for help on using the changeset viewer.