Changeset 7770
- Timestamp:
- Feb 10, 2020, 1:53:05 PM (3 years ago)
- Location:
- trunk/src
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/clients/web/net/sf/basedb/clients/web/extensions/list/ParentItemAnnotationColumn.java
r7768 r7770 1 1 package net.sf.basedb.clients.web.extensions.list; 2 2 3 import java.util.List; 3 4 import java.util.Set; 4 5 import java.util.TreeSet; 5 6 7 import net.sf.basedb.clients.web.util.HTML; 6 8 import net.sf.basedb.core.Annotatable; 7 9 import net.sf.basedb.core.AnnotationType; 8 10 import net.sf.basedb.core.snapshot.AnnotationSnapshot; 9 11 import net.sf.basedb.core.snapshot.AnnotationTypeFilter; 12 import net.sf.basedb.util.Enumeration; 10 13 import net.sf.basedb.util.filter.Filter; 11 14 … … 27 30 this.at = at; 28 31 this.atFilter = new AnnotationTypeFilter(at); 32 if (at.isEnumeration()) 33 { 34 Enumeration<String, String> annotationEnum = new Enumeration<String, String>(); 35 annotationEnum.add("", "-none-"); 36 List<?> values = at.getValues(); 37 for (Object value : values) 38 { 39 String encoded = HTML.encodeTags(value.toString()); 40 annotationEnum.add(encoded, encoded); 41 } 42 setEnumeration(annotationEnum); 43 } 29 44 } 30 45 -
trunk/src/clients/web/net/sf/basedb/clients/web/extensions/list/ParentItemColumn.java
r7768 r7770 11 11 import net.sf.basedb.core.ItemSubtype; 12 12 import net.sf.basedb.core.Metadata; 13 import net.sf.basedb.core.Type; 13 14 import net.sf.basedb.core.Metadata.PropertyPath; 14 15 import net.sf.basedb.util.AnnotationUtil; … … 74 75 col.setTitle(subtype.getName()); 75 76 col.setTooltip(subtype.getName()); 77 col.setFilterProperty("/"+tmp[1]+"/"+tmp[2]+"/name"); 76 78 } 79 col.setValueType(Type.STRING); 77 80 if (property == null || property.getHibernateType().isEntityType()) 78 81 { … … 105 108 setProperty(id); 106 109 setExportable(true); 110 setFilterable(true); 107 111 } 108 112 -
trunk/src/core/net/sf/basedb/core/ItemContext.java
r7703 r7770 27 27 import net.sf.basedb.core.query.Expressions; 28 28 import net.sf.basedb.core.query.Hql; 29 import net.sf.basedb.core.query.IdListRestriction; 29 30 import net.sf.basedb.core.query.Orders; 30 31 import net.sf.basedb.core.query.Order; … … 1516 1517 // Do not auto-join queries containing filter properties with the following prefixes 1517 1518 private static final Set<String> NO_AUTO_JOIN_PREFIXES = new HashSet<String>( 1518 Arrays.asList("£", "&", "!", "¤", "|" ));1519 Arrays.asList("£", "&", "!", "¤", "|", "/")); 1519 1520 1520 1521 /** … … 1682 1683 { 1683 1684 Map<Integer, List<Restriction>> allRestrictions = new HashMap<Integer, List<Restriction>>(); 1685 Map<Integer, IdListRestriction> rowIdListRestriction = new HashMap<Integer, IdListRestriction>(); 1684 1686 for (PropertyFilterPair filterPair : propertyFilters.values()) 1685 1687 { … … 1690 1692 { 1691 1693 Restriction r = filter.getRestriction(dc, query); 1694 int rowIndex = filter.getRowIndex(); 1695 if (r instanceof IdListRestriction) 1696 { 1697 // Filters that result in a "IdListRestriction" are merged to a single id-list 1698 // since that typically will result in a shorter list in the final SQL 1699 IdListRestriction rowIdR = rowIdListRestriction.get(rowIndex); 1700 if (rowIdR == null) 1701 { 1702 rowIdListRestriction.put(rowIndex, (IdListRestriction)r); 1703 } 1704 else 1705 { 1706 rowIdR.intersect((IdListRestriction)r); 1707 r = null; 1708 } 1709 } 1692 1710 if (r != null) 1693 1711 { 1694 int rowIndex = filter.getRowIndex();1695 1712 List<Restriction> rowRestrictions = allRestrictions.get(rowIndex); 1696 1713 if (rowRestrictions == null) -
trunk/src/core/net/sf/basedb/core/PropertyFilter.java
r7642 r7770 28 28 import java.util.Collections; 29 29 import java.util.List; 30 import java.util.Set; 31 import java.util.SortedSet; 32 import java.util.TreeSet; 30 33 import java.util.regex.Matcher; 31 34 import java.util.regex.Pattern; 32 35 36 import net.sf.basedb.core.SyncFilter.SourceItemTransform; 33 37 import net.sf.basedb.core.data.PropertyFilterData; 34 38 import net.sf.basedb.core.data.ReporterData; … … 45 49 import net.sf.basedb.core.query.Dynamic; 46 50 import net.sf.basedb.core.query.Hql; 51 import net.sf.basedb.core.query.IdListRestriction; 52 import net.sf.basedb.util.listable.ListableUtil; 53 import net.sf.basedb.util.listable.SourceItemTransformerFactory; 54 import net.sf.basedb.util.listable.SourceItemTransformerWithCache; 55 import net.sf.basedb.util.listable.TransformContext; 47 56 import net.sf.basedb.util.units.UnitUtil; 48 57 … … 790 799 } 791 800 } 792 801 else if (property != null && property.startsWith("/")) 802 { 803 // Property is Parent-item filter: /TYPE/subtype-id/(property|#annotation-id) 804 String[] parts = property.split("/", 4); 805 Item parentType = Item.valueOf(parts[1]); 806 ItemSubtype subtype = ItemSubtype.getById(dc, (Integer)Type.INT.parseString(parts[2])); 807 String parentProperty = parts[3]; 808 809 // We execute a query for the parent items... 810 EntityQuery subquery = new AbstractEntityQuery(parentType, parentType, null, "id", false, null) 811 {}; 812 subquery.restrict(Restrictions.eq(Hql.property("itemSubtype"), Hql.entity(subtype))); 813 PropertyFilter pp = new PropertyFilter(parentProperty, operator, getValue(), getValueType()); 814 subquery.restrict(pp.getRestriction(dc, subquery)); 815 816 // We then transform the list if ID:s to a list of child item ID:s using ItemList functionality 817 SortedSet<Integer> parentIds = new TreeSet<>(subquery.idList(dc)); 818 TransformContext tCtx = new TransformContext(dc); 819 820 SourceItemTransformerFactory factory = ListableUtil.getTransformerFactory(query.getItemType()); 821 factory = new SourceItemTransformerWithCache(factory); 822 Set<Integer> myIds = factory.create(parentType, SourceItemTransform.PARENT_TO_CHILD).transform(tCtx, parentIds); 823 824 // The final ID list is returned as a restriction 825 restriction = new IdListRestriction(myIds); 826 } 793 827 else 794 828 { -
trunk/src/core/net/sf/basedb/core/SyncFilter.java
r6927 r7770 472 472 should produce the same MD5. 473 473 */ 474 static String toMd5(SortedSet<Integer> listOfIds)474 public static String toMd5(SortedSet<Integer> listOfIds) 475 475 { 476 476 MessageDigest md5 = MD5.newInstance(); -
trunk/src/core/net/sf/basedb/util/listable/TransformContext.java
r6848 r7770 72 72 } 73 73 74 /** 75 Get a cache that can be used for storing transformation 76 results for some time. The cache is stored in the current 77 session and is lost if the user logs out. 78 @since 3.16 79 */ 80 public TransformCache getCache() 81 { 82 TransformCache cache = dc.getSessionControl().getSessionSetting(TransformCache.class.getName()); 83 if (cache == null) 84 { 85 cache = new TransformCache(20); 86 dc.getSessionControl().setSessionSetting(TransformCache.class.getName(), cache); 87 } 88 return cache; 89 } 90 74 91 }
Note: See TracChangeset
for help on using the changeset viewer.