Changeset 5574


Ignore:
Timestamp:
Feb 18, 2011, 1:19:38 PM (13 years ago)
Author:
Nicklas Nordborg
Message:

erged patch release 2.16.2 to the trunk.

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/core/ItemContext.java

    r5527 r5574  
    4040import net.sf.basedb.core.data.UserData;
    4141import net.sf.basedb.core.data.ClientData;
     42import net.sf.basedb.util.StringLengthComparator;
    4243import net.sf.basedb.util.encode.EncodeUtil;
    4344import net.sf.basedb.util.encode.TabCrLfEncoderDecoder;
     
    5960import java.util.EnumSet;
    6061import java.util.List;
     62import java.util.TreeSet;
    6163
    6264/**
     
    11021104
    11031105    // Temporary storage for all associations that must be left joined
    1104     Set<String> leftJoins = autoLeftJoin ? new HashSet<String>() : null;
     1106    Set<String> leftJoins = autoLeftJoin ? new TreeSet<String>(new StringLengthComparator()) : null;
    11051107    Set<String> sortedProperties = autoLeftJoin ? new HashSet<String>() : null;
    11061108   
  • trunk/src/core/net/sf/basedb/core/Platform.java

    r4517 r5574  
    2424import java.util.Set;
    2525
     26import net.sf.basedb.core.Transactional.Action;
    2627import net.sf.basedb.core.data.FileTypeIndex;
    2728import net.sf.basedb.core.data.PlatformData;
     
    207208    checkPermission(Permission.WRITE);
    208209    NameableUtil.setName(getData(), name);
     210    if (isFileOnly() && isInDatabase())
     211    {
     212      getRawDataType().setName(name);
     213    }
    209214  }
    210215  public String getDescription()
     
    318323    super.initPermissions(granted, denied);
    319324  }
     325  /**
     326    Register file-only platforms as raw data type after insert and unregister
     327    after delete.
     328    @since 2.16.2
     329  */
     330  @Override
     331  void onAfterCommit(Action action)
     332  {
     333    super.onAfterCommit(action);
     334    if (action == Action.CREATE)
     335    {
     336      if (isFileOnly()) RawDataTypes.registerFileOnlyRawDataType(new RawDataType(getData()));
     337    }
     338    else if (action == Action.DELETE)
     339    {
     340      if (isFileOnly()) RawDataTypes.unregisterFileOnlyRawDataType(getRawDataType());
     341    }
     342  }
    320343  // -------------------------------------------
    321  
     344
    322345  /**
    323346    The maximum length of the external ID that can be stored in the database.
  • trunk/src/core/net/sf/basedb/core/PlatformVariant.java

    r4517 r5574  
    2424import java.util.Set;
    2525
     26import net.sf.basedb.core.Transactional.Action;
    2627import net.sf.basedb.core.data.PlatformVariantData;
    2728
     
    211212    checkPermission(Permission.WRITE);
    212213    NameableUtil.setName(getData(), name);
     214    if (isFileOnly() && isInDatabase())
     215    {
     216      getRawDataType().setName(name);
     217    }
    213218  }
    214219  public String getDescription()
     
    308313    return using;
    309314  }
     315  /**
     316    Register file-only platforms as raw data type after insert and unregister
     317    after delete.
     318    @since 2.16.2
     319  */
     320  @Override
     321  void onAfterCommit(Action action)
     322  {
     323    super.onAfterCommit(action);
     324    if (action == Action.CREATE)
     325    {
     326      if (isFileOnly()) RawDataTypes.registerFileOnlyRawDataType(new RawDataType(getData()));
     327    }
     328    else if (action == Action.DELETE)
     329    {
     330      if (isFileOnly()) RawDataTypes.unregisterFileOnlyRawDataType(getRawDataType());
     331    }
     332  }
    310333  // -------------------------------------------
    311334  /*
  • trunk/src/core/net/sf/basedb/core/RawDataType.java

    r5384 r5574  
    5050
    5151  private final String id;
    52   private final String name;
     52  private String name;
    5353  private final String description;
    5454  private final boolean fileOnly;
     
    243243
    244244  /**
     245    Update the name. Used mainly for file-only representations of
     246    raw data types when the underlying platform is changed.
     247    @since 2.16.2
     248  */
     249  void setName(String name)
     250  {
     251    this.name = name;
     252  }
     253 
     254  /**
    245255    Get a description of this raw data type. This value is the same as the
    246256    <code>description</code> attribute of the <code>&lt;raw-data-type&gt;</code>
     
    354364
    355365  /**
    356     Compare the names of the raw data types. If the names are
    357     equal the id:s are also compared.
     366    Compare the id:s of the raw data types.
     367    Note! Before 2.16.2 the name was used for comparing but this
     368    led to issues when changing the name of file-only plaforms. See
     369    ticket #1567.
    358370    @since 2.5
    359371  */
     
    361373  public int compareTo(RawDataType o)
    362374  {
    363     int r = name.compareTo(o.name);
    364     if (r != 0) return r;
    365375    return id.compareTo(o.id);
    366376  }
  • trunk/src/core/net/sf/basedb/core/RawDataTypes.java

    r4889 r5574  
    3030import net.sf.basedb.util.XMLUtil;
    3131
     32import java.util.Comparator;
    3233import java.util.HashMap;
    3334import java.util.HashSet;
     
    115116      for (PlatformData platform : HibernateUtil.loadList(PlatformData.class, query, null))
    116117      {
    117         RawDataType rdt = new RawDataType(platform);
    118         platformTypes.put(rdt.getId(), rdt);
    119         all.add(rdt);
     118        registerFileOnlyRawDataType(new RawDataType(platform));
    120119      }
    121120     
     
    124123      for (PlatformVariantData variant : HibernateUtil.loadList(PlatformVariantData.class, query, null))
    125124      {
    126         RawDataType rdt = new RawDataType(variant);
    127         platformTypes.put(rdt.getId(), rdt);
    128         all.add(rdt);
     125        registerFileOnlyRawDataType(new RawDataType(variant));
    129126      }
    130127
     
    181178  /**
    182179    Get a collection with all raw data types that has been defined. This method
    183     only returns both database and file-only raw data types. To
     180    returns both database and file-only raw data types. To
    184181    get file-only raw data types use {@link #getFileOnlyRawDataTypes()}
    185182    @return A <code>Collection</code> containing {@link RawDataType} objects
     
    189186  {
    190187    return Collections.unmodifiableCollection(all);
     188  }
     189 
     190  /**
     191    Get all raw data types sorted according to the given comparator.
     192    @param comparator A compartor
     193    @return A sorted collection
     194    @since 2.16.2
     195  */
     196  public static Collection<RawDataType> getSortedRawDataTypes(Comparator<RawDataType> comparator)
     197  {
     198    Set<RawDataType> sorted = new TreeSet<RawDataType>(comparator);
     199    sorted.addAll(all);
     200    return sorted;
    191201  }
    192202 
     
    261271      if (platform == null || !platform.isFileOnly()) return null;
    262272      rdt = new RawDataType(platform);
    263       platformTypes.put(id, rdt);
    264       all.add(rdt);
     273      registerFileOnlyRawDataType(rdt);
    265274    }
    266275    finally
     
    289298      if (variant == null || !variant.isFileOnly()) return null;
    290299      rdt = new RawDataType(variant);
    291       platformTypes.put(id, rdt);
    292       all.add(rdt);
     300      registerFileOnlyRawDataType(rdt);
    293301    }
    294302    finally
     
    300308  }
    301309
     310  static void registerFileOnlyRawDataType(RawDataType rdt)
     311  {
     312    platformTypes.put(rdt.getId(), rdt);
     313    all.add(rdt);
     314  }
     315 
     316  static void unregisterFileOnlyRawDataType(RawDataType rdt)
     317  {
     318    platformTypes.remove(rdt.getId());
     319    all.remove(rdt);
     320  }
     321 
    302322  /**
    303323    Load the raw data types and put the information in the
     
    498518  }
    499519 
     520  /**
     521    Comparator implementation that sorts raw data types
     522    according to their name. Use this with a TreeSet if you need
     523    raw data types returned from {@link RawDataTypes#getRawDataTypes()}
     524    to be in the same order as before 2.16.2.
     525 
     526    @author Nicklas
     527    @since 2.16.2
     528    @base.modified $Date$
     529  */
     530  public static class NameComparator
     531    implements Comparator<RawDataType>
     532  {
     533
     534    public NameComparator()
     535    {}
     536   
     537    @Override
     538    public int compare(RawDataType o1, RawDataType o2)
     539    {
     540      int r = o1.getName().compareTo(o2.getName());
     541      if (r != 0) return r;
     542      return o1.getId().compareTo(o2.getId());
     543    }
     544   
     545  }
    500546}
  • trunk/src/plugins/core/net/sf/basedb/plugins/RawDataFlatFileImporter.java

    r5481 r5574  
    11901190        }
    11911191      }
     1192      types.sortValues();
    11921193      rawDataTypeType = new StringParameterType(255, null, true, 1, 0, 0, types);
    11931194      rawDataTypeParameter = new PluginParameter<String>
  • trunk/src/plugins/core/net/sf/basedb/plugins/executor/ExternalProgramExecutor.java

    r5534 r5574  
    10011001          }
    10021002        }
     1003        rawDataTypes.sortValues();
    10031004        parameters.add(new PluginParameter<String>(
    10041005            PARAMETER_RAW_DATA_TYPE,
  • trunk/www/admin/platforms/edit_platform.jsp

    r5508 r5574  
    287287            <option value="">- any -
    288288            <%
    289             for (RawDataType rdt : RawDataTypes.getRawDataTypes())
     289            for (RawDataType rdt : RawDataTypes.getSortedRawDataTypes(new RawDataTypes.NameComparator()))
    290290            {
    291291              if (rdt.isStoredInDb())
  • trunk/www/admin/platforms/variants/edit_variant.jsp

    r5508 r5574  
    296296            <option value="">- any -
    297297            <%
    298             for (RawDataType rdt : RawDataTypes.getRawDataTypes())
     298            for (RawDataType rdt : RawDataTypes.getSortedRawDataTypes(new RawDataTypes.NameComparator()))
    299299            {
    300300              if (rdt.isStoredInDb())
  • trunk/www/my_base/projects/edit_project.jsp

    r5501 r5574  
    829829                  <option value="">- none -</option>
    830830                  <%
    831                   for (RawDataType rdt : RawDataTypes.getRawDataTypes())
     831                  for (RawDataType rdt : RawDataTypes.getSortedRawDataTypes(new RawDataTypes.NameComparator()))
    832832                  {
    833833                    if (rdt.isStoredInDb())
  • trunk/www/views/formulas/edit_formula.jsp

    r5501 r5574  
    457457          <option value="">- none -
    458458          <%
    459           for (RawDataType rdt : RawDataTypes.getRawDataTypes())
     459          for (RawDataType rdt :  RawDataTypes.getSortedRawDataTypes(new RawDataTypes.NameComparator()))
    460460          {
    461461            String selected = rdt == currentRawDataType ? "selected" : "";
  • trunk/www/views/formulas/list_formulas.jsp

    r5426 r5574  
    102102      rawEnumeration.add(rdt.getId(), HTML.encodeTags(rdt.getName()));
    103103    }
     104    rawEnumeration.sortValues();
    104105  }
    105106%>
  • trunk/www/views/rawbioassays/edit_rawbioassay.jsp

    r5558 r5574  
    709709            <%=hasDbSpots ? "disabled" : "" %>>
    710710          <%
    711           for (RawDataType rdt : RawDataTypes.getRawDataTypes())
     711          for (RawDataType rdt : RawDataTypes.getSortedRawDataTypes(new RawDataTypes.NameComparator()))
    712712          {
    713713            if (rdt.isStoredInDb())
Note: See TracChangeset for help on using the changeset viewer.