Changeset 2941
- Timestamp:
- Nov 22, 2006, 12:11:18 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/Install.java
r2933 r2941 102 102 method. 103 103 */ 104 public static final int NEW_SCHEMA_VERSION = 2 6;104 public static final int NEW_SCHEMA_VERSION = 27; 105 105 106 106 public static synchronized void createTables(boolean update, final ProgressReporter progress) -
trunk/src/core/net/sf/basedb/core/Project.java
r2939 r2941 91 91 */ 92 92 private static final QueryRuntimeFilter RUNTIME_FILTER = new QueryRuntimeFilterImpl(); 93 93 94 94 /** 95 95 Create a new <code>Project</code> item. … … 501 501 return defaultItem; 502 502 } 503 504 /** 505 Gets the default raw data type for this project. 506 If no default value has been set for raw data type this will return Null. 507 508 @return A {@link net.sf.basedb.core.RawDataType} object 509 */ 510 public RawDataType getDefaultRawDataType() 511 { 512 RawDataType rdt = null; 513 String id = getData().getProjectDefaults().get("raw_data_type"); 514 rdt = RawDataTypes.getRawDataType(id); 515 return rdt; 516 } 517 518 /** 519 Sets a raw data type to be used as default for a project. 520 The default value will be reset if <code>rawDataType</code> is Null 521 522 @param rawDataType the {@link net.sf.basedb.core.RawDataType} to use as default. 523 */ 524 public void setDefaultRawDataType(RawDataType rawDataType) 525 { 526 checkPermission(Permission.WRITE); 527 if (rawDataType == null) 528 { 529 getData().getProjectDefaults().remove("raw_data_type"); 530 } 531 else 532 { 533 getData().getProjectDefaults().put("raw_data_type", rawDataType.getId()); 534 } 535 } 503 536 504 537 /** … … 585 618 FEATURE_EXTRACTION_PROTOCOL("default_feature_extraction_protocol", "Feat. extraction protocol", Item.PROTOCOL, ProtocolType.FEATURE_EXTRACTION), 586 619 POOLING_PROTOCOL("default_pooling_protocol", "Pooling protocol", Item.PROTOCOL, ProtocolType.POOLING), 587 PRINTING_PROTOCOL("default_printing_protocol", "Printing protocol", Item.PROTOCOL, ProtocolType.PRINTING); 620 PRINTING_PROTOCOL("default_printing_protocol", "Printing protocol", Item.PROTOCOL, ProtocolType.PRINTING), 621 RAW_DATA_TYPE("default_raw_data_type", "Raw data type", null, null); 588 622 589 623 private String name; -
trunk/src/core/net/sf/basedb/core/Update.java
r2933 r2941 316 316 <ul> 317 317 <li>Added {@link net.sf.basedb.core.data.AnnotationTypeData#getExternalId()}. 318 </ul> 319 </td> 320 </tr> 321 322 <tr> 323 <td>27</td> 324 <td> 325 <ul> 326 <li>Added {@link net.sf.basedb.core.data.ProjectData#getProjectDefaults()}. 318 327 </ul> 319 328 </td> … … 458 467 schemaVersion = setSchemaVersionInTransaction(session, 26); 459 468 } 460 461 /* 469 462 470 if (schemaVersion < 27) 463 471 { 464 472 if (progress != null) progress.display((int)(26*progress_factor), "--Updating schema version: " + schemaVersion + " -> 27..."); 465 473 schemaVersion = setSchemaVersionInTransaction(session, 27); 474 } 475 476 /* 477 if (schemaVersion < 28) 478 { 479 if (progress != null) progress.display((int)(27*progress_factor), "--Updating schema version: " + schemaVersion + " -> 28..."); 480 schemaVersion = setSchemaVersionInTransaction(session, 28); 466 481 - or - 467 schemaVersion = updateToSchemaVersion2 7(session);482 schemaVersion = updateToSchemaVersion28(session); 468 483 } 469 484 ... etc... -
trunk/src/core/net/sf/basedb/core/data/ProjectData.java
r2304 r2941 138 138 this.projectKeys = projectKeys; 139 139 } 140 141 private Map<String, String> projectDefaults; 142 /** 143 Gets the default values 144 @hibernate.map table="`ProjectDefaults`" lazy="true" 145 @hibernate.collection-key column="`project_id`" 146 @hibernate.collection-index column="`name`" type="string" length="255" not-null="true" 147 @hibernate.collection-element column="`value`" type="string" length="255" not-null="true" 148 */ 149 public Map<String, String> getProjectDefaults() 150 { 151 if (projectDefaults == null)projectDefaults = new HashMap<String,String>(); 152 return projectDefaults; 153 } 154 void setProjectDefaults(Map<String, String> projectDefaults) 155 { 156 this.projectDefaults = projectDefaults; 157 } 140 158 } -
trunk/www/my_base/projects/edit_project.jsp
r2939 r2941 43 43 import="net.sf.basedb.core.ItemResultList" 44 44 import="net.sf.basedb.core.PermissionDeniedException" 45 import="net.sf.basedb.core.RawDataType" 46 import="net.sf.basedb.core.RawDataTypes" 45 47 import="net.sf.basedb.core.Software" 46 48 import="net.sf.basedb.core.BaseException" … … 181 183 for (Project.Default d : Project.Default.values()) 182 184 { 183 BasicItem defaultValue = null; 184 int valueId = 0; 185 %> 186 var values = new Array(); 187 <% 185 188 String icon = ""; 186 189 if (project != null) 187 190 { 188 defaultValue = project.getDefaultItem(dc, d); 189 if (defaultValue != null) 191 if (d.getItemType() != null) 190 192 { 191 valueId = defaultValue.getId(); 192 icon = "notrequired_values.gif"; 193 BasicItem defaultValue = project.getDefaultItem(dc, d); 194 int valueId = 0; 195 if (defaultValue != null) 196 { 197 valueId = defaultValue.getId(); 198 icon = "notrequired_values.gif"; 199 } 200 else 201 { 202 icon = "notrequired_novalues.gif"; 203 } 204 %> 205 values[values.length] = <%=valueId%>; 206 <% 193 207 } 194 else 208 else if (d == Project.Default.RAW_DATA_TYPE) 195 209 { 196 icon = "notrequired_novalues.gif"; 210 RawDataType rdt = project.getDefaultRawDataType(); 211 String strValueId = "0"; 212 if (rdt != null) 213 { 214 strValueId = rdt.getId(); 215 icon = "notrequired_values.gif"; 216 } 217 else 218 { 219 icon = "notrequired_novalues.gif"; 220 } 221 %> 222 values[values.length] = '<%=strValueId%>'; 223 <% 197 224 } 198 225 } … … 206 233 sb.append(icon+"<span class=\"label\">"+d.getShortName()+"</span></div>\n"); 207 234 %> 208 var values = new Array();209 values[values.length] = <%=valueId%>;210 235 var di = new Parameter('<%=d.getName()%>', '<%=HTML.javaScriptEncode(d.getShortName())%>', 1, false, false, values); 211 236 <% 212 237 } 213 // TODO Set default RawDataType214 238 %> 215 239 } … … 422 446 icon.src = gif; 423 447 } 424 function default ItemOnChange(value)448 function defaultValueOnChange(value) 425 449 { 426 450 var pp = getSelectedParameter(); … … 434 458 } 435 459 updateSelectedStyle(); 436 } 460 } 437 461 function selectDefaultItemOnClick(url) 438 462 { … … 459 483 selectlist[1].text = name; 460 484 selectlist.selectedIndex = 1; 461 default ItemOnChange(selectlist[1].value);485 defaultValueOnChange(selectlist[1].value); 462 486 } 463 487 function removeOnClick() … … 545 569 <table class="form" cellspacing="2" border="0" cellpadding="0" width="100%"> 546 570 <tr valign="top"> 547 <td width=" 50%">548 <b>Project default items</b><br>549 <div class="parameterlist" style="height: <%=(int)(scale*230)%>px; margin-top: 4px;">571 <td width="40%"> 572 <b>Project defaults</b><br> 573 <div class="parameterlist" style="height: <%=(int)(scale*230)%>px; width:<%=(int)(scale*200)%>px; margin-top: 4px;"> 550 574 <%=sb.toString()%> 551 575 </div> 552 576 <base:icon image="hasvalues.gif" /> = Has value 553 577 </td> 554 <td width=" 50%">578 <td width="60%"> 555 579 <br> 556 580 <% 557 581 for (Project.Default d : Project.Default.values()) 558 582 { 559 String inputName = "value_" + d.getName(); 560 if (d.getItemType() != null) 561 { 562 String selectDefaultItemOnClick = ""; 563 String defaultItemOnChange = ""; 564 List recentItems = null; 565 BasicItem currentItem = project != null ? project.getDefaultItem(dc, d) : null; 566 boolean readCurrentItem = sc.hasPermission(Permission.READ, d.getItemType()); 567 if (d.getItemType() == Item.PROTOCOL) 568 { 569 int typeId = SystemItems.getId(d.getType()); 570 String url = "'../../admin/protocols/index.jsp?ID=" + ID + 571 "&cmd=UpdateContext&mode=selectone&callback=setDefaultItemCallback&filter:INT:protocolType=" + typeId + "'"; 572 selectDefaultItemOnClick = "selectDefaultItemOnClick(" + url + ")"; 573 recentItems = recentProtocol; 574 } 575 else if (d.getItemType() == Item.HARDWARE) 576 { 577 int typeId = SystemItems.getId(d.getType()); 578 String url = "'../../admin/hardware/index.jsp?ID=" + ID + 579 "&cmd=UpdateContext&mode=selectone&callback=setDefaultItemCallback&filter:INT:hardwareType=" + typeId + "'"; 580 selectDefaultItemOnClick = "selectDefaultItemOnClick(" + url + ")"; 581 } 582 else if (d.getItemType() == Item.SOFTWARE) 583 { 584 String url = "'../../admin/software/index.jsp?ID=" + ID + 585 "&cmd=UpdateContext&mode=selectone&callback=setDefaultItemCallback'"; 586 selectDefaultItemOnClick = "selectDefaultItemOnClick(" + url + ")"; 587 } 588 else if (d.getItemType() == Item.ARRAYDESIGN) 589 { 590 String url = "'../../lims/arraydesigns/index.jsp?ID=" + ID + 591 "&mode=selectone&callback=setDefaultItemCallback'"; 592 selectDefaultItemOnClick = "selectDefaultItemOnClick(" + url + ")"; 593 } 594 %> 595 <div id="<%=inputName%>_div" style="display: none;"> 596 <table> 597 <tr> 598 <td class="prompt"><%=d.getShortName()%></td> 599 </tr> 583 String inputName = "value_" + d.getName(); 584 %> 585 <div id="<%=inputName%>_div" style="display: none;"> 586 <table> 587 <tr> 588 <td class="prompt"><%=d.getShortName()%></td> 589 </tr> 590 <% 591 if (d.getItemType() != null) 592 { 593 String selectDefaultItemOnClick = ""; 594 String defaultItemOnChange = ""; 595 List recentItems = null; 596 boolean readCurrentItem = true; 597 BasicItem currentItem = null; 598 try 599 { 600 currentItem = project != null ? project.getDefaultItem(dc, d) : null; 601 } 602 catch (PermissionDeniedException ex) 603 { 604 readCurrentItem = false; 605 } 600 606 607 if (d.getItemType() == Item.PROTOCOL) 608 { 609 int typeId = SystemItems.getId(d.getType()); 610 String url = "'../../admin/protocols/index.jsp?ID=" + ID + 611 "&cmd=UpdateContext&mode=selectone&callback=setDefaultItemCallback&filter:INT:protocolType=" + typeId + "'"; 612 selectDefaultItemOnClick = "selectDefaultItemOnClick(" + url + ")"; 613 recentItems = recentProtocol; 614 } 615 else if (d.getItemType() == Item.HARDWARE) 616 { 617 int typeId = SystemItems.getId(d.getType()); 618 String url = "'../../admin/hardware/index.jsp?ID=" + ID + 619 "&cmd=UpdateContext&mode=selectone&callback=setDefaultItemCallback&filter:INT:hardwareType=" + typeId + "'"; 620 selectDefaultItemOnClick = "selectDefaultItemOnClick(" + url + ")"; 621 recentItems = recentHardware; 622 } 623 else if (d.getItemType() == Item.SOFTWARE) 624 { 625 String url = "'../../admin/software/index.jsp?ID=" + ID + 626 "&cmd=UpdateContext&mode=selectone&callback=setDefaultItemCallback'"; 627 selectDefaultItemOnClick = "selectDefaultItemOnClick(" + url + ")"; 628 recentItems = recentSoftware; 629 } 630 else if (d.getItemType() == Item.ARRAYDESIGN) 631 { 632 String url = "'../../lims/arraydesigns/index.jsp?ID=" + ID + 633 "&mode=selectone&callback=setDefaultItemCallback'"; 634 selectDefaultItemOnClick = "selectDefaultItemOnClick(" + url + ")"; 635 recentItems = recentArrayDesign; 636 } 637 %> 601 638 <tr> 602 639 <td> … … 610 647 newitem="<%=project == null%>" 611 648 onselect="<%=selectDefaultItemOnClick%>" 612 onchange = 'default ItemOnChange(this[this.selectedIndex].value)'649 onchange = 'defaultValueOnChange(this[this.selectedIndex].value)' 613 650 /> 614 651 </td> 652 </tr> 653 <% 654 } 655 else if (d == Project.Default.RAW_DATA_TYPE) 656 { 657 RawDataType currentDefaultRawDataType = project != null ? project.getDefaultRawDataType() : null; 658 %> 659 <tr> 660 <td> 661 <div id="<%=inputName%>" class="selectionlist"> 662 <table border="0" cellspacing="0" cellpadding="0"> 663 <tr><td> 664 <select name="<%=inputName%>" onchange="defaultValueOnChange(this[this.selectedIndex].value)"> 665 <option value="0">- none -</option> 666 <% 667 for (RawDataType rdt : RawDataTypes.getRawDataTypes()) 668 { 669 String selected = rdt.equals(currentDefaultRawDataType) ? "selected" : ""; 670 %> 671 <option value="<%=rdt.getId()%>" <%=selected%>><%=rdt.getName()%></option> 672 <% 673 } 674 %> 675 </select> 676 </td></tr> 677 </table> 678 </div> 679 </td> 615 680 </tr> 616 </table> 617 </div> 681 <% 682 } 683 %> 684 </table> 685 </div> 618 686 <% 619 }620 687 } 621 688 %> -
trunk/www/my_base/projects/index.jsp
r2939 r2941 41 41 import="net.sf.basedb.core.PermissionDeniedException" 42 42 import="net.sf.basedb.core.ItemAlreadyExistsException" 43 import="net.sf.basedb.core.RawDataType" 44 import="net.sf.basedb.core.RawDataTypes" 43 45 import="net.sf.basedb.util.RemovableUtil" 44 46 import="net.sf.basedb.util.OwnableUtil" … … 172 174 { 173 175 String selectDefault = "value_"+d.getName(); 174 int selectId = Values.getInt(request.getParameter(selectDefault), -1); 175 if (selectId >= 0) 176 if (d.getItemType() != null) 176 177 { 177 BasicItem item = null; 178 item = selectId == 0 ? null : d.getItemType().getById(dc, selectId); 179 project.setDefaultItem(dc, item, d); 178 int selectId = Values.getInt(request.getParameter(selectDefault), -1); 179 if (selectId >= 0) 180 { 181 BasicItem item = selectId == 0 ? null : d.getItemType().getById(dc, selectId); 182 project.setDefaultItem(dc, item, d); 183 } 184 } 185 else if (d == Project.Default.RAW_DATA_TYPE) 186 { 187 String selectId = request.getParameter(selectDefault); 188 if (selectId != null && selectId.length() > 0) 189 { 190 RawDataType rdt = selectId.equals("0") ? null :RawDataTypes.getRawDataType(selectId); 191 project.setDefaultRawDataType(rdt); 192 } 180 193 } 181 194 }
Note: See TracChangeset
for help on using the changeset viewer.