Changeset 7307
- Timestamp:
- Mar 7, 2017, 3:30:59 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/util/Enumeration.java
r6870 r7307 55 55 public static Enumeration<String, String> fromItems(Collection<? extends Nameable> items, String noneOption) 56 56 { 57 return fromItems(items, noneOption, ""); 58 } 59 60 /** 61 Create a new enumeration from a list of basic items. 62 The key of the enumeration is the id of each item 63 and the value is the name. 64 @param items A collection with items 65 @param noneOption If not null, this options will be inserted first in the 66 enumeration with an empty string as the key 67 @param noneValue Value for the 'none' option (empty string by default) 68 @since 3.11 69 */ 70 public static Enumeration<String, String> fromItems(Collection<? extends Nameable> items, String noneOption, String noneValue) 71 { 57 72 Enumeration<String, String> e = new Enumeration<String, String>(); 58 73 if (noneOption != null) 59 74 { 60 e.add( "", noneOption);75 e.add(noneValue == null ? "" : noneValue, noneOption); 61 76 } 62 77 for (Nameable item : items) … … 68 83 } 69 84 70 71 85 private final List<Entry<K, V>> entries; 72 86 private boolean locked; -
trunk/www/views/jobs/index.jsp
r6880 r7307 30 30 import="net.sf.basedb.core.Include" 31 31 import="net.sf.basedb.core.Job" 32 import="net.sf.basedb.core.Project" 32 33 import="net.sf.basedb.core.ItemQuery" 33 34 import="net.sf.basedb.core.ItemResultIterator" … … 46 47 import="net.sf.basedb.clients.web.WebException" 47 48 import="net.sf.basedb.util.Values" 49 import="net.sf.basedb.util.formatter.NameableFormatter" 48 50 import="net.sf.basedb.clients.web.util.HTML" 49 51 import="net.sf.basedb.core.plugin.GuiContext" 50 52 import="net.sf.basedb.util.extensions.ExtensionsInvoker" 53 import="net.sf.basedb.clients.web.plugins.ExportedProperty" 54 import="net.sf.basedb.clients.web.plugins.DataLoader" 51 55 import="net.sf.basedb.clients.web.extensions.ExtensionsControl" 52 56 import="net.sf.basedb.clients.web.extensions.JspContext" … … 63 67 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> 64 68 <%! 69 70 private static void registerExportUtils(ItemContext cc) 71 { 72 // Register formatters 73 cc.setObject("export.formatter.activeProjectId", new NameableFormatter()); 74 75 // Register dataloaders 76 cc.setObject("export.dataloader.activeProjectId", 77 new DataLoader<Job>() 78 { 79 @Override 80 public Object getData(DbControl dc, ExportedProperty exportedProperty, Job job) 81 { 82 Project p = null; 83 if (job.getActiveProjectId() != 0) 84 { 85 try 86 { 87 p = Project.getById(dc, job.getActiveProjectId()); 88 } 89 catch (Exception ex) 90 {} 91 } 92 return p; 93 } 94 } 95 ); 96 } 97 65 98 private static final ItemContext defaultContext = Base.createDefaultContext("scheduled", "name,pluginType,scheduled,percentComplete,status,statusMessage,description"); 66 99 { … … 221 254 dc = sc.newDbControl(); 222 255 cc.configureQuery(dc, query, true); 256 registerExportUtils(cc); 223 257 cc.setQuery(query); 224 258 JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); … … 232 266 // Run an export plugin in single-item context 233 267 ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); 268 registerExportUtils(cc); 234 269 redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+job"; 235 270 } -
trunk/www/views/jobs/list_jobs.jsp
r7290 r7307 39 39 import="net.sf.basedb.core.Nameable" 40 40 import="net.sf.basedb.core.PluginDefinition" 41 import="net.sf.basedb.core.Project" 41 42 import="net.sf.basedb.core.PermissionDeniedException" 42 43 import="net.sf.basedb.core.query.Hql" … … 120 121 typeQuery.order(Orders.asc(Hql.property("name"))); 121 122 typeQuery.setCacheResult(true); 123 124 // Load projects 125 final ItemQuery<Project> projectQuery = Project.getQuery(); 126 projectQuery.setIncludes(cc.getInclude()); 127 projectQuery.order(Orders.asc(Hql.property("name"))); 128 projectQuery.setCacheResult(true); 122 129 123 130 Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); … … 359 366 title="Type" 360 367 enumeration="<%=pluginTypes%>" 368 sortable="true" 369 filterable="true" 370 exportable="true" 371 /> 372 <tbl:columndef 373 id="activeProject" 374 property="activeProjectId" 375 datatype="int" 376 title="Active project" 377 enumeration="<%=Enumeration.fromItems(projectQuery.list(dc), "-none-", "0")%>" 361 378 sortable="true" 362 379 filterable="true" … … 743 760 %> 744 761 </tbl:cell> 762 <tbl:cell column="activeProject"> 763 <% 764 if (item.getActiveProjectId() == 0) 765 { 766 %> 767 <i>- none -</i> 768 <% 769 } 770 else 771 { 772 try 773 { 774 Project p = Project.getById(dc, item.getActiveProjectId()); 775 %> 776 <%=HTML.encodeTags(p.getName())%> 777 <% 778 } 779 catch (RuntimeException ex) 780 { 781 %> 782 <i>- denied -</i> 783 <% 784 } 785 } 786 %> 787 </tbl:cell> 745 788 <tbl:cell column="experiment" 746 789 ><base:propertyvalue -
trunk/www/views/jobs/view_job.jsp
r7267 r7307 34 34 import="net.sf.basedb.core.Job" 35 35 import="net.sf.basedb.core.JobAgent" 36 import="net.sf.basedb.core.BasicItem" 36 import="net.sf.basedb.core.Project" 37 import="net.sf.basedb.core.BasicItem" 37 38 import="net.sf.basedb.core.Nameable" 38 39 import="net.sf.basedb.core.File" … … 143 144 readAgent = false; 144 145 } 146 boolean readActiveProject = true; 147 Project activeProject = null; 148 try 149 { 150 if (job.getActiveProjectId() != 0) 151 { 152 activeProject = Project.getById(dc, job.getActiveProjectId()); 153 } 154 } 155 catch (PermissionDeniedException ex) 156 { 157 readActiveProject = false; 158 } 159 catch (Exception ex) 160 { 161 // Some other problem (for example, no longer exists) 162 } 145 163 146 164 int parameterVersion = job.getParameterVersion(); … … 280 298 <td> 281 299 <base:propertyvalue item="<%=job%>" property="owner.name" /> 300 </td> 301 </tr> 302 <tr> 303 <th>Active project</th> 304 <td> 305 <%=activeProject == null ? (readActiveProject ? "<i>- none -</i>" : "<i>- denied -</i>") : HTML.encodeTags(activeProject.getName()) %> 282 306 </td> 283 307 </tr>
Note: See TracChangeset
for help on using the changeset viewer.