Changeset 2929
- Timestamp:
- Nov 17, 2006, 9:36:17 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/common-queries.xml
r2927 r2929 451 451 </query> 452 452 453 <query id="GET_DISKCONSUMABLE_ITEMS_FOR_USER" type="HQL"> 454 <sql> 455 SELECT o 456 FROM net.sf.basedb.core.data.DiskConsumableData o 457 WHERE o.owner = :user 458 </sql> 459 <description> 460 Get all diskconsumable items that are owned by the specified user. 461 </description> 462 </query> 463 464 453 465 <query id="LOAD_USER_CLIENT_SETTINGS" type="HQL"> 454 466 <sql> … … 2431 2443 </query> 2432 2444 2445 <query id="SET_ITEMTYPE_ON_DISKUSAGE" type="HQL"> 2446 <sql> 2447 UPDATE DiskUsageData du 2448 SET du.itemType = :itemType 2449 WHERE du.id IN (:itemList) 2450 AND du.itemType IS NULL 2451 </sql> 2452 <description> 2453 A HQL query that sets the item type for disk usage items. 2454 </description> 2455 </query> 2456 2457 <query id="LOAD_DISKUSAGEID_FOR_FILES" type="HQL"> 2458 <sql> 2459 SELECT f.diskUsage.id 2460 FROM FileData f 2461 </sql> 2462 <description> 2463 A HQL query that loads the disk usage ID for all files. 2464 </description> 2465 </query> 2466 2467 <query id="LOAD_DISKUSAGEID_FOR_EXPERIMENTS" type="HQL"> 2468 <sql> 2469 SELECT xp.diskUsage.id 2470 FROM ExperimentData xp 2471 </sql> 2472 <description> 2473 A HQL query that loads the disk usage ID for all experiments. 2474 </description> 2475 </query> 2476 2477 <query id="LOAD_DISKUSAGEID_FOR_RAWBIOASSAYS" type="HQL"> 2478 <sql> 2479 SELECT rba.diskUsage.id 2480 FROM RawBioAssayData rba 2481 </sql> 2482 <description> 2483 A HQL query that loads the disk usage ID for all raw bioassays. 2484 </description> 2485 </query> 2486 2433 2487 </predefined-queries> -
trunk/src/core/net/sf/basedb/core/DbControl.java
r2898 r2929 520 520 521 521 // Update the disk usage information 522 currentDiskUsage.setItemType(dcItem.getType().getValue()); 522 523 currentDiskUsage.setBytes(bytes); 523 524 currentDiskUsage.setLocation(location.getValue()); -
trunk/src/core/net/sf/basedb/core/DiskUsage.java
r2927 r2929 60 60 the logged in user has generic READ permission for disk usage in which case 61 61 all items will be returned 62 @param group The group to retrieve the disk usage for 62 63 @return An {@link ItemQuery} object 63 64 */ 64 public static ItemQuery<DiskUsage> getQuery(User user )65 public static ItemQuery<DiskUsage> getQuery(User user, Group group) 65 66 { 66 67 ItemQuery<DiskUsage> query = null; … … 79 80 query = new ItemQuery<DiskUsage>(DiskUsage.class); 80 81 } 82 if (group != null) 83 { 84 query.restrictPermanent( 85 Restrictions.eq( 86 Hql.property("group"), 87 Hql.entity(group) 88 ) 89 ); 90 } 81 91 return query; 82 92 } … … 86 96 return new DiskUsageStatistics(dc); 87 97 } 98 99 100 /** 101 The item this diks usage information belongs to. 102 */ 103 private DiskConsumable item; 88 104 89 105 /** … … 146 162 } 147 163 // ------------------------------------------- 164 165 166 /** 167 Get the item this disk usage holds information for 168 @return The <code>DiskConsumable</code> item 169 @throws PermissionDeniedException If the logged in user doesn't have 170 read permission to the item 171 @throws BaseException If there is another error 172 @since 2.2 173 */ 174 public DiskConsumable getItem() 175 throws PermissionDeniedException, BaseException 176 { 177 if (item == null) 178 { 179 Item type = getItemType(); 180 DbControl dc = getDbControl(); 181 String hql = "SELECT item"+ 182 " FROM "+type.getDataClass().getName()+" item"+ 183 " WHERE item.diskUsage = :diskUsage"; 184 org.hibernate.Query query = HibernateUtil.createQuery(dc.getHibernateSession(), hql); 185 query.setEntity("diskUsage", this.getData()); 186 item = (DiskConsumable)dc.getItem(type.getItemClass(), HibernateUtil.loadData(type.getDataClass(), query)); 187 } 188 return item; 189 } 190 191 /** 192 Get the {@link Item} type of the item this annotation set belongs to. 193 @since 2.2 194 */ 195 public Item getItemType() 196 { 197 return Item.fromValue(getData().getItemType()); 198 } 199 148 200 149 201 /** -
trunk/src/core/net/sf/basedb/core/Install.java
r2899 r2929 102 102 method. 103 103 */ 104 public static final int NEW_SCHEMA_VERSION = 2 4;104 public static final int NEW_SCHEMA_VERSION = 25; 105 105 106 106 public static synchronized void createTables(boolean update, final ProgressReporter progress) -
trunk/src/core/net/sf/basedb/core/Metadata.java
r2905 r2929 52 52 private static Set<Item> removableItems; 53 53 private static Set<Item> ownableItems; 54 private static Set<Item> diskConsumableItems; 54 55 55 56 private static boolean isInitialised = false; … … 62 63 removableItems = Collections.unmodifiableSet(getImplementingItems(Removable.class)); 63 64 ownableItems = Collections.unmodifiableSet(getImplementingItems(Ownable.class)); 65 diskConsumableItems = Collections.unmodifiableSet(getImplementingItems(DiskConsumable.class)); 64 66 isInitialised = true; 65 67 } … … 74 76 shareableItems = null; 75 77 removableItems = null; 78 ownableItems = null; 79 diskConsumableItems = null; 76 80 } 77 81 … … 157 161 } 158 162 163 /** 164 Get a set containing all {@link DiskConsumable} item types. 165 The set cannot be modified. 166 */ 167 public static Set<Item> getDiskConsumableItems() 168 { 169 return diskConsumableItems; 170 } 171 159 172 /** 160 173 Cache of Metadata instances. Only one instance for each type -
trunk/src/core/net/sf/basedb/core/Update.java
r2899 r2929 296 296 <li>File parameters are stored as item parameters. The update will 297 297 move existing file parameter into the ItemValues table. 298 </ul> 299 </td> 300 </tr> 301 302 <tr> 303 <td>25</td> 304 <td> 305 <ul> 306 <li>Added {@link net.sf.basedb.core.data.DiskUsageData#getItemType()}. 307 The update will first set all null values to the correct item type 308 by checking the diskconsumable items. 298 309 </ul> 299 310 </td> … … 425 436 "--NOTE! The \"FileValues\" table is no longer used by BASE. It may be removed from the database."); 426 437 } 438 439 if (schemaVersion < 25) 440 { 441 if (progress != null) progress.display((int)(24*progress_factor), "--Updating schema version: " + schemaVersion + " -> 25..."); 442 schemaVersion = updateToSchemaVersion25(session); 443 } 427 444 428 445 /* 429 if (schemaVersion < 2 5)430 { 431 if (progress != null) progress.display((int)(2 4*progress_factor), "--Updating schema version: " + schemaVersion + " -> 25...");432 schemaVersion = setSchemaVersionInTransaction(session, 2 5);446 if (schemaVersion < 26) 447 { 448 if (progress != null) progress.display((int)(25*progress_factor), "--Updating schema version: " + schemaVersion + " -> 26..."); 449 schemaVersion = setSchemaVersionInTransaction(session, 26); 433 450 - or - 434 schemaVersion = updateToSchemaVersion2 5(session);451 schemaVersion = updateToSchemaVersion26(session); 435 452 } 436 453 ... etc... … … 843 860 // Commit the changes 844 861 HibernateUtil.commit(tx); 845 log.info("updateToSchemaVersion2 : OK");862 log.info("updateToSchemaVersion24: OK"); 846 863 } 847 864 catch (BaseException ex) … … 854 871 } 855 872 856 857 873 /** 874 Set the itemType property on all DiskUsageData items. 875 @return The new schema version (=25) 876 */ 877 private static int updateToSchemaVersion25(org.hibernate.Session session) 878 throws BaseException 879 { 880 final int schemaVersion = 25; 881 org.hibernate.Transaction tx = null; 882 try 883 { 884 tx = HibernateUtil.newTransaction(session); 885 886 // Query for setting the item type 887 org.hibernate.Query duQuery = HibernateUtil.getPredefinedQuery(session, 888 "SET_ITEMTYPE_ON_DISKUSAGE"); 889 /* 890 UPDATE DiskUsageData du 891 SET du.itemType = :itemType 892 WHERE du.id IN (:itemList) 893 */ 894 895 // Files 896 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, 897 "LOAD_DISKUSAGEID_FOR_FILES"); 898 /** 899 SELECT f.diskUsage.id 900 FROM FileData f 901 */ 902 List<Integer> ids = HibernateUtil.loadList(Integer.class, query); 903 if (ids.size() > 0) 904 { 905 duQuery.setParameter("itemType", Item.FILE.getValue(), org.hibernate.Hibernate.INTEGER); 906 duQuery.setParameterList("itemList", ids, org.hibernate.Hibernate.INTEGER); 907 HibernateUtil.executeUpdate(duQuery); 908 } 909 910 // Experiments 911 query = HibernateUtil.getPredefinedQuery(session, 912 "LOAD_DISKUSAGEID_FOR_EXPERIMENTS"); 913 /** 914 SELECT xp.diskUsage.id 915 FROM ExperimentData xp 916 */ 917 ids = HibernateUtil.loadList(Integer.class, query); 918 if (ids.size() > 0) 919 { 920 duQuery.setParameter("itemType", Item.EXPERIMENT.getValue(), org.hibernate.Hibernate.INTEGER); 921 duQuery.setParameterList("itemList", ids, org.hibernate.Hibernate.INTEGER); 922 HibernateUtil.executeUpdate(duQuery); 923 } 924 925 // Raw bioassays 926 query = HibernateUtil.getPredefinedQuery(session, 927 "LOAD_DISKUSAGEID_FOR_RAWBIOASSAYS"); 928 /** 929 SELECT rba.diskUsage.id 930 FROM RawBioAssayData rba 931 */ 932 ids = HibernateUtil.loadList(Integer.class, query); 933 if (ids.size() > 0) 934 { 935 duQuery.setParameter("itemType", Item.RAWBIOASSAY.getValue(), org.hibernate.Hibernate.INTEGER); 936 duQuery.setParameterList("itemList", ids, org.hibernate.Hibernate.INTEGER); 937 HibernateUtil.executeUpdate(duQuery); 938 } 939 940 // Update the shcema version number 941 setSchemaVersion(session, schemaVersion); 942 943 // Commit the changes 944 HibernateUtil.commit(tx); 945 log.info("updateToSchemaVersion25: OK"); 946 } 947 catch (BaseException ex) 948 { 949 if (tx != null) HibernateUtil.rollback(tx); 950 log.error("updateToSchemaVersion25: FAILED", ex); 951 throw ex; 952 } 953 return schemaVersion; 954 } 955 956 858 957 /** 859 958 Adjust the existing items in the database to be compatible with the latest mappings. -
trunk/src/core/net/sf/basedb/core/data/DiskUsageData.java
r2304 r2929 45 45 public DiskUsageData() 46 46 {} 47 48 private int itemType; 49 /** 50 Get the item type this annotation set is associated with. 51 @hibernate.property column="`item_type`" type="int" not-null="true" update="false" 52 @since 2.2 53 */ 54 public int getItemType() 55 { 56 return itemType; 57 } 58 public void setItemType(int itemType) 59 { 60 this.itemType = itemType; 61 } 47 62 48 63 private int location; -
trunk/www/admin/diskusage/index.jsp
r2927 r2929 48 48 String subContext = request.getParameter("subcontext"); 49 49 final String overviewPage = "overview.jsp?ID="+ID; 50 final String userPage = "list_users.jsp?ID="+ID; 51 final String groupPage = "list_groups.jsp?ID="+ID; 50 final String listUsersPage = "list_users.jsp?ID="+ID; 51 final String listGroupsPage = "list_groups.jsp?ID="+ID; 52 final String viewUserPage = "view_user.jsp?ID="+ID; 53 final String viewGroupPage = "view_group.jsp?ID="+ID; 52 54 53 55 String forward = null; … … 64 66 redirect = overviewPage; 65 67 } 66 else if (" PerUser".equals(cmd))68 else if ("ListUsers".equals(cmd)) 67 69 { 68 70 Base.getAndSetCurrentContext(sc, itemType, "perUser", null, defaultContext, true); 69 redirect = userPage;71 redirect = listUsersPage; 70 72 } 71 else if (" PerGroup".equals(cmd))73 else if ("ListGroups".equals(cmd)) 72 74 { 73 75 Base.getAndSetCurrentContext(sc, itemType, "perGroup", null, defaultContext, true); 74 redirect = groupPage;76 redirect = listGroupsPage; 75 77 } 76 77 78 else if ("UpdateContext".equals(cmd)) 78 79 { … … 81 82 String ss = request.getParameter("showStatistics"); 82 83 if (ss != null) cc.setSetting("showStatistics", ss); 83 redirect = "perUser".equals(subContext) ? userPage : "perGroup".equals(subContext) ? groupPage : overviewPage;84 redirect = "perUser".equals(subContext) ? listUsersPage : "perGroup".equals(subContext) ? listGroupsPage : overviewPage; 84 85 } 85 86 else if ("LoadContext".equals(cmd)) … … 88 89 int contextId = Values.getInt(request.getParameter("context")); 89 90 Base.loadContext(sc, contextId, defaultContext); 90 redirect = "perUser".equals(subContext) ? userPage : "perGroup".equals(subContext) ? groupPage : overviewPage; 91 redirect = "perUser".equals(subContext) ? listUsersPage : "perGroup".equals(subContext) ? listGroupsPage : overviewPage; 92 } 93 else if ("ViewUser".equals(cmd)) 94 { 95 // Display the view page for a single item 96 ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, "perUser", pageContext, defaultContext); 97 forward = viewUserPage; 98 } 99 else if ("ViewGroup".equals(cmd)) 100 { 101 // Display the view page for a single item 102 ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, "perGroup", pageContext, defaultContext); 103 forward = viewGroupPage; 91 104 } 92 105 else -
trunk/www/admin/diskusage/overview.jsp
r2927 r2929 80 80 if (tabId == 'users') 81 81 { 82 location.href = 'index.jsp?ID=<%=ID%>&cmd= PerUser';82 location.href = 'index.jsp?ID=<%=ID%>&cmd=ListUsers'; 83 83 } 84 84 else if (tabId == 'groups') 85 85 { 86 location.href = 'index.jsp?ID=<%=ID%>&cmd= PerGroup';86 location.href = 'index.jsp?ID=<%=ID%>&cmd=ListGroups'; 87 87 } 88 88 else
Note: See TracChangeset
for help on using the changeset viewer.