Changeset 7889


Ignore:
Timestamp:
Dec 4, 2020, 11:07:18 AM (11 months ago)
Author:
Nicklas Nordborg
Message:

Merge 3.17-dev-1 to the trunk

Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/clients/web/net/sf/basedb/clients/web/util/HTML.java

    r7748 r7889  
    322322        else
    323323        {
    324           m.appendReplacement(sb, "<$2>");
     324          m.appendReplacement(sb, "<$2 $3>");
    325325        }
    326326      }
  • trunk/src/core/net/sf/basedb/core/File.java

    r7856 r7889  
    5151import java.io.IOException;
    5252import java.io.InputStream;
     53import java.io.InterruptedIOException;
    5354import java.io.OutputStream;
    5455import java.io.PipedInputStream;
     
    10491050   
    10501051    ConnectionParameters server = getServerInfo();
    1051     ConnectionManager manager = ConnectionManagerUtil.createConnectionManager(this, server);
    10521052    try
    10531053    {
     1054      ConnectionManager manager = ConnectionManagerUtil.createConnectionManager(this, server);
    10541055      setMetadataFromURI(manager.getMetadata());
    10551056    }
    10561057    catch (IOException ex)
    10571058    {
     1059      Throwable cause = ex;
     1060      // If the exception is caused by an interrupt we should re-enable it to allow
     1061      // upstream code to detect it (eg. File importer when user has clicked "Abort").
     1062      while (cause != null)
     1063      {
     1064        if (cause instanceof InterruptedException || cause instanceof InterruptedIOException)
     1065        {
     1066          Thread.currentThread().interrupt();
     1067          break;
     1068        }
     1069        cause = cause.getCause();
     1070      }
    10581071      throw new BaseException("Could not load metadata for URL:" + data.getUrl(), ex);
    10591072    }
  • trunk/src/core/net/sf/basedb/core/Job.java

    r7738 r7889  
    17031703    //getData().setStatus(Status.WAITING.getValue());
    17041704    //getData().setScheduled(new Date());
    1705     setParameterValuesInternal(name, label, description, parameterType, Arrays.asList(value), true);
     1705    setParameterValuesInternal(name, label, description, parameterType, value == null ? null : Arrays.asList(value), true);
    17061706  }
    17071707 
  • trunk/src/core/net/sf/basedb/util/InputStreamTracker.java

    r4515 r7889  
    4444  private final InputStream in;
    4545 
    46 
     46  /**
     47    A scale factor to apply when counting bytes.
     48  */
     49  private final ScaleFactor scaleFactor;
     50 
    4751  /**
    4852    The number of bytes that has been read from the underlying
     
    6367  public InputStreamTracker(InputStream in)
    6468  {
     69    this(in, null);
     70  }
     71  /**
     72    Create a new input stream tracker.
     73    @param in The input stream to read from
     74    @param scaleFactor A scale factor to apply when counting bytes
     75    @since 3.17.1
     76  */
     77  public InputStreamTracker(InputStream in, ScaleFactor scaleFactor)
     78  {
    6579    if (in == null) throw new NullPointerException("in");
    6680    this.in = in;
     81    this.scaleFactor = scaleFactor == null ? new IdentityScaleFactor() : scaleFactor;
    6782  }
    6883  /*
     
    141156  public long getNumRead()
    142157  {
    143     return numRead;
    144   }
    145 
     158    return scaleFactor.scale(numRead);
     159  }
     160
     161  /**
     162    A scale factor can be used to match number of read bytes to something
     163    that better resembles actual progress.
     164    @since 3.17.1
     165  */
     166  public static interface ScaleFactor
     167  {
     168    public long scale(long numRead);
     169  }
     170 
     171  /**
     172    Do not scale number of bytes.
     173  */
     174  public static class IdentityScaleFactor
     175    implements ScaleFactor
     176  {
     177    @Override
     178    public long scale(long numRead)
     179    {
     180      return numRead;
     181    }
     182  }
     183 
     184  /**
     185    Apply a linear scale factor so that when we have read N actual bytes
     186    the getNumRead() method return N*scale bytes.
     187  */
     188  public static class LinearScaleFactor
     189    implements ScaleFactor
     190  {
     191    private final float scale;
     192    public LinearScaleFactor(float scale)
     193    {
     194      this.scale = scale;
     195    }
     196   
     197    @Override
     198    public long scale(long numRead)
     199    {
     200      return (long)(scale * numRead);
     201    }
     202  }
     203 
     204  /**
     205    Apply a curved scale factor that has a max upper limit. To begin
     206    with each byte is counted as 1, but the the more bytes that are read
     207    the scale factor is changed along curved path so that we get closer
     208    and closer to the max limit but never over.
     209  */
     210  public static class CurvedScaleFactor
     211    implements ScaleFactor
     212  {
     213    private final double max;
     214    public CurvedScaleFactor(long max)
     215    {
     216      this.max = max;
     217    }
     218   
     219    @Override
     220    public long scale(long numRead)
     221    {
     222      return (long)(max * -Math.expm1(-numRead/max));
     223    }
     224  }
    146225}
  • trunk/src/core/net/sf/basedb/util/excel/XlsxToCsvUtil.java

    r7824 r7889  
    620620    }
    621621   
     622    /**
     623      Get the size of the CSV in bytes.
     624      @since 3.17.1
     625    */
     626    public int getSize()
     627    {
     628      if (csvBytes == null) parseToBytes();
     629      return csvBytes.length;
     630    }
     631   
    622632    private void parseToBytes()
    623633    {
  • trunk/src/core/net/sf/basedb/util/formatter/PropertyFilterFormatter.java

    r7774 r7889  
    2727import net.sf.basedb.core.DbControl;
    2828import net.sf.basedb.core.Item;
     29import net.sf.basedb.core.ItemNotFoundException;
    2930import net.sf.basedb.core.Nameable;
    3031import net.sf.basedb.core.Operator;
    3132import net.sf.basedb.core.PropertyFilter;
     33import net.sf.basedb.core.RawDataType;
     34import net.sf.basedb.core.RawDataTypes;
    3235import net.sf.basedb.core.Type;
    3336import net.sf.basedb.util.Values;
     
    8689    if (property.startsWith("/"))
    8790    {
    88       // Parent item filter
    89       String[] tmp = property.split("/");
    90       int subtypeId = Values.getInt(tmp[2]);
    91       property = tmp[3];
    92       sb.append(function("parent")).append("(");
    93       sb.append(value(nameOfItem(dc, Item.ITEMSUBTYPE, subtypeId, false)));
     91      // Parent or child item filter
     92      String[] tmp = property.split("/", 5);
     93      int baseIndex = 0;
     94      String parentOrChild = "parent";
     95      if (tmp.length == 5)
     96      {
     97        baseIndex = 1;
     98        parentOrChild = tmp[1].toLowerCase();
     99      }
     100     
     101      Item relatedItemType = Item.valueOf(tmp[baseIndex+1]);
     102      property = tmp[baseIndex+3];
     103      sb.append(function(parentOrChild)).append("(");
     104      if (relatedItemType == Item.RAWBIOASSAY)
     105      {
     106        RawDataType rdt = RawDataTypes.getRawDataType(tmp[baseIndex+2]);
     107        if (rdt == null)
     108        {
     109          sb.append(value(missing(tmp[baseIndex+2], "This raw data type doesn't exist!")));
     110        }
     111        else
     112        {
     113          sb.append(value(rdt.getName()));
     114        }
     115      }
     116      else
     117      {
     118        int subtypeId = Values.getInt(tmp[baseIndex+2]);
     119        sb.append(value(nameOfItem(dc, Item.ITEMSUBTYPE, subtypeId, false)));
     120      }
    94121      sb.append(")");
    95122      if (!property.startsWith("#")) sb.append(".");
     123    }
     124    else if (property.startsWith("|"))
     125    {
     126      // Linked item filter
     127      String[] tmp = property.split("\\|", 4);
     128      sb.append(function("link")).append("(");
     129      sb.append(value(tmp[1]));
     130      if (tmp.length > 2)
     131      {
     132        sb.append(", ").append(value(tmp[2]));
     133      }
     134      sb.append(")");
     135      if (tmp.length > 3)
     136      {
     137        sb.append(".");
     138        property = tmp[3];
     139      }
     140      else
     141      {
     142        property = "";
     143      }
    96144    }
    97145   
     
    141189    {
    142190      // Item list filter
    143       if (operator != Operator.EQ) sb.append(operator("NOT"));
    144       sb.append(function("memberOfList")).append("(");
    145       sb.append(value(nameOfItem(dc, Item.ITEMLIST, Values.getInt(value), true)));
     191      if (operator.isNegationOperator()) sb.append(operator("NOT "));
     192      sb.append(function("memberOfList")).append("(");     
     193      List<Object> listIds = filter.getValuesAsObjects();
     194      String sep = "";
     195      for (Object listId : listIds)
     196      {
     197        sb.append(sep);
     198        sep = ", ";
     199        sb.append(value(nameOfItem(dc, Item.ITEMLIST, (Integer)listId, true)));
     200      }
    146201      sb.append(")");
    147202    }
     
    247302      return q+((Nameable)itemType.getById(dc, id)).getName()+q;
    248303    }
     304    catch (ItemNotFoundException ex)
     305    {
     306      return missing(Integer.toString(id), "This " + itemType.toString().toLowerCase() + " doesn't exist!");
     307    }
    249308    catch (RuntimeException ex)
    250309    {
    251       return Integer.toString(id);
     310      return missing(Integer.toString(id), ex.getMessage());
    252311    }
    253312  }
     
    285344    return tagElements ? "<function>"+function+"</function>" : function;
    286345  }
     346  private String missing(String missing, String title)
     347  {
     348    return tagElements ? "<missing title=\""+(title!=null ? title :"Missing")+"\">"+missing+"</missing>" : missing;
     349  }
    287350
    288351 
  • trunk/src/core/net/sf/basedb/util/parser/FlatFileParser.java

    r7874 r7889  
    718718    in = XlsxToCsvUtil.prepareForCheck(in);
    719719    String charsetName = charsetOrSheetName;
     720    InputStreamTracker.ScaleFactor scaleFactor = null;
    720721    if (XlsxToCsvUtil.isAnExcelFile(in))
    721722    {
     
    730731      setDataSplitterRegexp(Pattern.compile("\\t"));
    731732      charsetName = "UTF-8";
     733      InputStreamTracker tmpTracker = new InputStreamTracker(in);
    732734      try
    733735      {
    734         excelWorkbook.readWorkbook(in);
     736        excelWorkbook.readWorkbook(tmpTracker);
    735737      }
    736738      catch (IOException ex)
     
    738740        throw new RuntimeException(ex);
    739741      }
     742      long allBytes = tmpTracker.getNumRead();
    740743     
    741744      if (parseAllExcelSheets)
     
    743746        setSectionRegexp(Pattern.compile("\\[(.*)\\]"));
    744747        in = excelWorkbook.getWorkbookAsCsv();
     748        // Apply a curved scale factor since we don't know how many bytes
     749        // we get after converting all sheets to CSV
     750        scaleFactor = new InputStreamTracker.CurvedScaleFactor(allBytes);
    745751      }
    746752      else
     
    762768        excelSheetName = excelSheet.getName();
    763769        in = excelSheet.parseToCsv();
     770        int sheetBytes = excelSheet.getSize();
     771        // Apply a scale factor so that when we have parsed the sheet it seems like we have parsed the original input stream
     772        scaleFactor = new InputStreamTracker.LinearScaleFactor((float)allBytes / (float)sheetBytes);
    764773      }
    765774    }
    766775    Charset cs = CharsetUtil.getCharset(charsetName);
    767     this.tracker = new InputStreamTracker(in);
     776    this.tracker = new InputStreamTracker(in, scaleFactor);
    768777    this.reader = new BufferedReader(new InputStreamReader(tracker, cs));
    769778  }
  • trunk/www/views/itemlists/members/list_members.jsp

    r7813 r7889  
    204204      subclass="fulltable"
    205205      data-inherited-annotations="<%=annotatable%>"
     206      data-relateditem-columns="true"
    206207      >
    207208      <tbl:hidden
  • trunk/www/views/itemlists/syncfilter/ajax.jsp

    r7605 r7889  
    8989    if (sourceItemType == syncFilter.getSourceItemType())
    9090    {
    91       json.put("filter", HTML.encodeTags(formatFilter(dc, syncFilter), "value|name|operator|function"));
     91      json.put("filter", HTML.encodeTags(formatFilter(dc, syncFilter), "value|name|operator|function|missing"));
    9292    }
    9393  }
  • trunk/www/views/itemlists/syncfilter/filtertext.css

    r7604 r7889  
    2222  color: #666666;
    2323}
    24 
     24.filtertext missing
     25{
     26  text-decoration: underline dashed #d00000;
     27}
  • trunk/www/views/itemlists/view_list.jsp

    r7884 r7889  
    586586                  }
    587587                  %>
    588                   <pre class="filtertext" id="syncfilter.<%=filterId%>"><%=HTML.encodeTags(filterString, "value|name|operator|function")%></pre></tbl:cell>
     588                  <pre class="filtertext" id="syncfilter.<%=filterId%>"><%=HTML.encodeTags(filterString, "value|name|operator|function|missing")%></pre></tbl:cell>
    589589                <tbl:cell column="inSync">
    590590                  <base:icon
Note: See TracChangeset for help on using the changeset viewer.