firethorn

changeset 4291:71251f7804f0 2.1.35-stv-issue-1182

Updated fix for Issue #1182
author Stelios <stv@roe.ac.uk>
date Thu Mar 05 23:41:55 2020 +0200 (11 months ago)
parents 4ec5bb78de25
children 822a5b9c622b
files firethorn-core/src/main/java/uk/ac/roe/wfau/firethorn/meta/adql/AdqlColumn.java firethorn-webapp/src/main/java/uk/ac/roe/wfau/firethorn/webapp/votable/BaseTableVOTableController.java
line diff
     1.1 --- a/firethorn-core/src/main/java/uk/ac/roe/wfau/firethorn/meta/adql/AdqlColumn.java	Wed Mar 04 00:01:08 2020 +0200
     1.2 +++ b/firethorn-core/src/main/java/uk/ac/roe/wfau/firethorn/meta/adql/AdqlColumn.java	Thu Mar 05 23:41:55 2020 +0200
     1.3 @@ -259,7 +259,7 @@
     1.4                  case TIMESTAMP :
     1.5                      return AdqlColumn.AdqlType.DATETIME;
     1.6                  case TINYINT :
     1.7 -                    return AdqlColumn.AdqlType.INTEGER;
     1.8 +                    return AdqlColumn.AdqlType.SHORT;
     1.9  
    1.10  
    1.11                  case BLOB :
     2.1 --- a/firethorn-webapp/src/main/java/uk/ac/roe/wfau/firethorn/webapp/votable/BaseTableVOTableController.java	Wed Mar 04 00:01:08 2020 +0200
     2.2 +++ b/firethorn-webapp/src/main/java/uk/ac/roe/wfau/firethorn/webapp/votable/BaseTableVOTableController.java	Thu Mar 05 23:41:55 2020 +0200
     2.3 @@ -32,7 +32,6 @@
     2.4  import uk.ac.roe.wfau.firethorn.meta.adql.AdqlColumn;
     2.5  import uk.ac.roe.wfau.firethorn.meta.base.BaseColumn;
     2.6  import uk.ac.roe.wfau.firethorn.meta.base.BaseTable;
     2.7 -import uk.ac.roe.wfau.firethorn.webapp.votable.AbstractTableController.AbstractFormatter;
     2.8  
     2.9  /**
    2.10   * Spring MVC controller to format a {@link BaseTable} as a <a href='http://www.ivoa.net/documents/VOTable/'>VOTable</a>.
    2.11 @@ -151,28 +150,43 @@
    2.12          public String format(final ResultSet results)
    2.13          throws SQLException
    2.14              {
    2.15 -        		String byteArrayString = "";
    2.16 -    		
    2.17 -	        	if (results.getObject(index())!=null){
    2.18 -	        		byte[] bytes = results.getBytes(
    2.19 -	                            index()
    2.20 -	                            );
    2.21 -	        		
    2.22 -                    int aux;
    2.23 -   	                final StringBuilder builder = new StringBuilder();
    2.24 -			        for (byte b : bytes) {
    2.25 -		                 if(b<0) aux=256+b; else aux=b; 
    2.26 -		    	         builder.append(aux  + " ");
    2.27 -			        }
    2.28 -		
    2.29 -			        byteArrayString = builder.toString();
    2.30 +                String byteArrayString = "";
    2.31 +                int aux;
    2.32 +	            final StringBuilder builder = new StringBuilder(); 
    2.33 +                		
    2.34 +                if (results.getObject(index())!=null){
    2.35 +                	
    2.36 +                    boolean isarray;
    2.37  
    2.38 +                	try {
    2.39 +                		isarray = column.meta().adql().type().isarray();
    2.40 +					} catch (ProtectionException e) {
    2.41 +						isarray = false;
    2.42 +					}
    2.43 +
    2.44 +					if (!isarray) {
    2.45 +					    short shortval = results.getShort(
    2.46 +					            index()
    2.47 +					        );
    2.48 +					    builder.append(shortval);       
    2.49 +							
    2.50 +					} else {
    2.51 +					    
    2.52 +					    byte[] bytes = results.getBytes(
    2.53 +					        index()
    2.54 +					    );
    2.55 +					    
    2.56 +					    for (byte b : bytes) {
    2.57 +					        if(b<0) aux=256+b; else aux=b; 
    2.58 +					            builder.append(aux  + " ");
    2.59 +					    } 
    2.60 +						  
    2.61 +					}
    2.62  				
    2.63 -				} 
    2.64 -					    
    2.65 -			    return byteArrayString.trim();
    2.66 +                }
    2.67  
    2.68 -            
    2.69 +                byteArrayString = builder.toString();
    2.70 +                return byteArrayString.trim();
    2.71              }
    2.72          }
    2.73      
    2.74 @@ -191,9 +205,6 @@
    2.75          public String format(final ResultSet results)
    2.76          throws SQLException
    2.77              {
    2.78 -        		System.out.println(results.getString(index()));
    2.79 -        		System.out.println(String.valueOf(results.getInt(index())));
    2.80 -
    2.81  	    		if (results.getObject(index())!=null){
    2.82  	    			return  results.getString(index());
    2.83  	    		} else {
    2.84 @@ -312,50 +323,27 @@
    2.85  
    2.86          if (column.meta().adql().type() != null)
    2.87              {
    2.88 -            if (column.meta().adql().type() == AdqlColumn.AdqlType.DATE)
    2.89 +
    2.90 +            writer.append(" datatype='");
    2.91 +            writer.append(column.meta().adql().type().votype());
    2.92 +            writer.append("'");
    2.93 +
    2.94 +            if (column.meta().adql().arraysize() != null)
    2.95                  {
    2.96 -                writer.append(" datatype='char'");
    2.97 -                writer.append(" arraysize='*'");
    2.98 +                if (column.meta().adql().arraysize() == AdqlColumn.NON_ARRAY_SIZE)
    2.99 +                    {
   2.100 +                    }
   2.101 +                else if (column.meta().adql().arraysize() == AdqlColumn.VAR_ARRAY_SIZE || column.meta().adql().arraysize() <= 0)
   2.102 +                    {
   2.103 +                    writer.append(" arraysize='*'");
   2.104 +                    }
   2.105 +                else {
   2.106 +                    writer.append(" arraysize='");
   2.107 +                    writer.append(column.meta().adql().arraysize().toString());
   2.108 +                    writer.append("'");
   2.109                  }
   2.110 -            else if (column.meta().adql().type() == AdqlColumn.AdqlType.TIME)
   2.111 -                {
   2.112 -                writer.append(" datatype='char'");
   2.113 -                writer.append(" arraysize='*'");
   2.114 -                }
   2.115 -            else if (column.meta().adql().type() == AdqlColumn.AdqlType.DATETIME)
   2.116 -                {
   2.117 -                writer.append(" datatype='char'");
   2.118 -                writer.append(" arraysize='*'");
   2.119 -                }
   2.120 -            else if (column.meta().adql().type() == AdqlColumn.AdqlType.INTEGER) {
   2.121 -		writer.append(" datatype='int'");
   2.122 -		}
   2.123 -	    else if (column.meta().adql().type() == AdqlColumn.AdqlType.BYTE) {
   2.124 -		writer.append(" datatype='unsignedByte'");
   2.125 -                writer.append(" arraysize='*'");
   2.126 -		}
   2.127 -            else {
   2.128 -                writer.append(" datatype='");
   2.129 -                writer.append(column.meta().adql().type().name().toString().replace("'", "''").toLowerCase());
   2.130 -                writer.append("'");
   2.131 -
   2.132 +            }
   2.133                  
   2.134 -                if (column.meta().adql().arraysize() != null)
   2.135 -                    {
   2.136 -                    if (column.meta().adql().arraysize() == AdqlColumn.NON_ARRAY_SIZE)
   2.137 -                        {
   2.138 -                        }
   2.139 -                    else if (column.meta().adql().arraysize() == AdqlColumn.VAR_ARRAY_SIZE || column.meta().adql().arraysize() <= 0)
   2.140 -                        {
   2.141 -                        writer.append(" arraysize='*'");
   2.142 -                        }
   2.143 -                    else {
   2.144 -                        writer.append(" arraysize='");
   2.145 -                        writer.append(column.meta().adql().arraysize().toString());
   2.146 -                        writer.append("'");
   2.147 -                        }
   2.148 -                    }
   2.149 -                }
   2.150              if (column.meta().adql() != null)
   2.151                  {
   2.152                  writer.append(" xtype='");