Skip to content
Snippets Groups Projects
Commit 01f57b89 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Downgrading to Java 6 to keep compatibility with old VIPS

parent bc4ae630
No related branches found
No related tags found
No related merge requests found
......@@ -75,8 +75,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
......
......@@ -40,7 +40,7 @@ public class LanguageUtil {
if(distinctLanguages == null)
{
Map<String, ULocale> localeBucket = new HashMap<>();
Map<String, ULocale> localeBucket = new HashMap<String, ULocale>();
for(ULocale locale:ULocale.getAvailableLocales())
{
localeBucket.put(locale.getLanguage(), locale);
......
......@@ -61,7 +61,8 @@ public class DateMap {
{
return (Double) this.getParamValueForDate(date, paramName);
}
catch(NullPointerException | ClassCastException npe) {return null;}
catch(NullPointerException ex) {return null; }
catch(ClassCastException npe) {return null;}
}
/**
......@@ -87,7 +88,8 @@ public class DateMap {
{
return (Float) this.getParamValueForDate(date, paramName);
}
catch(NullPointerException | ClassCastException npe) {return null;}
catch(NullPointerException ex) {return null; }
catch(ClassCastException npe) {return null;}
}
/**
......@@ -113,7 +115,8 @@ public class DateMap {
{
return (Integer) this.getParamValueForDate(date, paramName);
}
catch(NullPointerException | ClassCastException npe) {return null;}
catch(NullPointerException ex) {return null; }
catch(ClassCastException npe) {return null;}
}
/**
......@@ -133,7 +136,8 @@ public class DateMap {
{
return (String) this.getParamValueForDate(date, paramName);
}
catch(NullPointerException | ClassCastException npe) {return null;}
catch(NullPointerException ex) {return null; }
catch(ClassCastException npe) {return null;}
}
/**
......@@ -165,7 +169,8 @@ public class DateMap {
{
return ((HashMap)this.matrix.get(date)).get(paramName);
}
catch(NullPointerException | ClassCastException npe) {return null;}
catch(NullPointerException ex) {return null; }
catch(ClassCastException npe) {return null;}
}
......@@ -180,7 +185,8 @@ public class DateMap {
{
return ((HashMap)this.matrix.get(date)).keySet();
}
catch(NullPointerException | ClassCastException npe) {return null;}
catch(NullPointerException ex) {return null; }
catch(ClassCastException npe) {return null;}
}
/**
......@@ -291,7 +297,7 @@ public class DateMap {
public List<Date> getSortedDateAtMidnightKeys(TimeZone timeZone)
{
List<Date> retVal = new ArrayList<>();
List<Date> retVal = new ArrayList<Date>();
Calendar cal = Calendar.getInstance(timeZone);
for(Date timeStamp:this.getSortedDateKeys())
{
......
......@@ -109,9 +109,7 @@ public class ServletUtil {
{
return Integer.valueOf(request.getParameter(parameterName));
}
catch(NullPointerException | NumberFormatException ex)
{
return null;
}
catch(NullPointerException ex) {return null; }
catch(NumberFormatException nfe) {return null;}
}
}
......@@ -55,7 +55,7 @@ public class WeatherUtil {
// Special case: List has less than 24 hourly values, return empty list
if(hourlyValues.size() < 24)
{
return new ArrayList<>();
return new ArrayList<WeatherObservation>();
}
// Sort the list
Collections.sort(hourlyValues);
......@@ -75,7 +75,7 @@ public class WeatherUtil {
}
else
{
return new ArrayList<>(hourlyValues.subList(0,dateShiftIndex));
return new ArrayList<WeatherObservation>(hourlyValues.subList(0,dateShiftIndex));
}
}
......@@ -100,7 +100,7 @@ public class WeatherUtil {
*/
public List<WeatherObservation> calculateLeafWetnessHourSeriesSimple(List<WeatherObservation> temperature, List<WeatherObservation> rainfall, List<WeatherObservation> relativeHumidity) throws ConfigValidationException
{
List<WeatherObservation> retVal = new ArrayList<>();
List<WeatherObservation> retVal = new ArrayList<WeatherObservation>();
Iterator<WeatherObservation> humIt = relativeHumidity.iterator();
WeatherObservation humObs;
Iterator<WeatherObservation> rainIt = rainfall.iterator();
......@@ -214,7 +214,7 @@ public class WeatherUtil {
InvalidAggregationTypeException
{
// First we organize the hourly values into one bucket per day
Map<Date,Map> dateBucket = new HashMap<>();
Map<Date,Map> dateBucket = new HashMap<Date,Map>();
Calendar cal = Calendar.getInstance(timeZone);
String expectedParameter = observations.get(0).getElementMeasurementTypeId();
Date lastDate = null;
......@@ -229,7 +229,7 @@ public class WeatherUtil {
Map<Date, Double> hourValuesForDate = dateBucket.get(theDate);
if(hourValuesForDate == null)
{
hourValuesForDate = new HashMap<>();
hourValuesForDate = new HashMap<Date,Double>();
dateBucket.put(theDate, hourValuesForDate);
}
......@@ -247,7 +247,7 @@ public class WeatherUtil {
}
// Then we iterate the buckets, do the aggregation and create return values
List<WeatherObservation> aggregatedObservations = new ArrayList<>();
List<WeatherObservation> aggregatedObservations = new ArrayList<WeatherObservation>();
WeatherObservation templateObservation = observations.get(0);
Double aggregateValue;
for(Date aDay:dateBucket.keySet())
......@@ -414,7 +414,7 @@ public class WeatherUtil {
WeatherObservation.LOG_INTERVAL_ID_1H,
0d
);
calculatedBT = new ArrayList<>();
calculatedBT = new ArrayList<WeatherObservation>();
calculatedBT.add(emptyObs);
calculatedBT.addAll(this.calculateLeafWetnessHourSeriesNaerstad(TM, RR, Q0, FM2, UM, null));
}
......@@ -452,7 +452,7 @@ public class WeatherUtil {
*/
public List<WeatherObservation> getWeatherObservationsInPeriod(List<WeatherObservation> allObservations, Date dateStart, Date dateEnd)
{
List<WeatherObservation> retVal = new ArrayList<>();
List<WeatherObservation> retVal = new ArrayList<WeatherObservation>();
for(WeatherObservation obs:allObservations)
{
if(
......@@ -488,7 +488,7 @@ public class WeatherUtil {
{
// TODO Validation
List<WeatherObservation> calculatedLeafWetnessSeries = new ArrayList<>();
List<WeatherObservation> calculatedLeafWetnessSeries = new ArrayList<WeatherObservation>();
Double lastLatentHeatFlux = this.calculateLatentHeatFlux(
temperature.get(0).getValue(),
relativeHumidity.get(0).getValue(),
......@@ -605,7 +605,7 @@ public class WeatherUtil {
}
else if(missingValues > 0)
{
List<WeatherObservation> calculatedValues = new ArrayList<>();
List<WeatherObservation> calculatedValues = new ArrayList<WeatherObservation>();
String elementMeasurementTypeId = obsList.get(i).getElementMeasurementTypeId();
String fixingStrategy = this.getFixingStrategy(elementMeasurementTypeId);
Date lastTimestampBeforeHole = obsList.get(i-1).getTimeMeasured();
......
......@@ -148,7 +148,7 @@ public class WeatherUtilTest extends TestCase {
System.out.println("testBosnianData");
// Testing with TM values first
List<WeatherObservation> allData = this.getObservations("/bosniandata.json");
List<WeatherObservation> TM = new ArrayList<>();
List<WeatherObservation> TM = new ArrayList<WeatherObservation>();
for(WeatherObservation obs:allData)
{
if(obs.getElementMeasurementTypeId().equals("TM"))
......@@ -175,7 +175,7 @@ public class WeatherUtilTest extends TestCase {
public void testGetAggregatedDailyValues() {
System.out.println("getAggregatedDailyValues");
List<WeatherObservation> allObservations = this.getObservations("/weatherData.json");
List<WeatherObservation> TM = new ArrayList<>();
List<WeatherObservation> TM = new ArrayList<WeatherObservation>();
for(WeatherObservation obs:allObservations)
{
if(obs.getElementMeasurementTypeId().equals("TM"))
......@@ -203,7 +203,11 @@ public class WeatherUtilTest extends TestCase {
maxResults = instance.getAggregatedDailyValues(TM, timeZone,23,WeatherUtil.AGGREGATION_TYPE_MAXIMUM);
Collections.sort(maxResults);
} catch (WeatherObservationListException | InvalidAggregationTypeException ex) {
} catch (WeatherObservationListException ex)
{fail(ex.getMessage());
}
catch(InvalidAggregationTypeException ex)
{
fail(ex.getMessage());
}
assertEquals(expAvg, avgResults.get(0).getValue());
......@@ -216,12 +220,12 @@ public class WeatherUtilTest extends TestCase {
{
System.out.println("testCalculateLeafWetnessHourSeriesBestEffort");
List<WeatherObservation> allObservations = this.getObservations("/weatherDataLeafWetnessCalc.json");
List<WeatherObservation> TM = new ArrayList<>();
List<WeatherObservation> UM = new ArrayList<>();
List<WeatherObservation> FM2 = new ArrayList<>();
List<WeatherObservation> Q0 = new ArrayList<>();
List<WeatherObservation> RR = new ArrayList<>();
List<WeatherObservation> BT = new ArrayList<>();
List<WeatherObservation> TM = new ArrayList<WeatherObservation>();
List<WeatherObservation> UM = new ArrayList<WeatherObservation>();
List<WeatherObservation> FM2 = new ArrayList<WeatherObservation>();
List<WeatherObservation> Q0 = new ArrayList<WeatherObservation>();
List<WeatherObservation> RR = new ArrayList<WeatherObservation>();
List<WeatherObservation> BT = new ArrayList<WeatherObservation>();
// Add collections here
for(WeatherObservation obs:allObservations)
{
......@@ -264,7 +268,7 @@ public class WeatherUtilTest extends TestCase {
}*/
// Testing Nærstad with completely empty BT as input
BTtest = new ArrayList<>();
BTtest = new ArrayList<WeatherObservation>();
result = instance.calculateLeafWetnessHourSeriesBestEffort(BTtest, TM, RR, Q0, FM2, UM);
System.out.println("result.size=" + result.size());
// Test 1 // Result have same length as input data
......@@ -283,7 +287,7 @@ public class WeatherUtilTest extends TestCase {
// Trapman should be called now
Q0 = new ArrayList<>();
Q0 = new ArrayList<WeatherObservation>();
BTtest = BT.size() > 1 ? new ArrayList(BT.subList(0, BT.size()/2)) : new ArrayList(BT);
result = instance.calculateLeafWetnessHourSeriesBestEffort(BTtest, TM, RR, Q0, FM2, UM);
System.out.println("result.size=" + result.size());
......@@ -337,29 +341,26 @@ public class WeatherUtilTest extends TestCase {
WeatherUtil instance = new WeatherUtil();
List<WeatherObservation> TM = new ArrayList<>();
List<WeatherObservation> RR = new ArrayList<>();
List<WeatherObservation> UM = new ArrayList<>();
List<WeatherObservation> TM = new ArrayList<WeatherObservation>();
List<WeatherObservation> RR = new ArrayList<WeatherObservation>();
List<WeatherObservation> UM = new ArrayList<WeatherObservation>();
List<WeatherObservation> faultySeries = this.getObservations("/weatherDataFaultyUnequalSize.json");
for(WeatherObservation o:faultySeries)
{
switch(o.getElementMeasurementTypeId())
if(o.getElementMeasurementTypeId().equals(WeatherElements.TEMPERATURE_MEAN))
{
case WeatherElements.TEMPERATURE_MEAN:
TM.add(o);
break;
case WeatherElements.PRECIPITATION:
RR.add(o);
break;
case WeatherElements.RELATIVE_HUMIDITY:
UM.add(o);
break;
default:
// Let it pass in silence
break;
TM.add(o);
}
else if(o.getElementMeasurementTypeId().equals(WeatherElements.PRECIPITATION))
{
RR.add(o);
}
else if(o.getElementMeasurementTypeId().equals(WeatherElements.RELATIVE_HUMIDITY))
{
UM.add(o);
}
}
......@@ -393,20 +394,17 @@ public class WeatherUtilTest extends TestCase {
for(WeatherObservation o:faultySeries)
{
switch(o.getElementMeasurementTypeId())
if(o.getElementMeasurementTypeId().equals(WeatherElements.TEMPERATURE_MEAN))
{
TM.add(o);
}
else if(o.getElementMeasurementTypeId().equals(WeatherElements.PRECIPITATION))
{
RR.add(o);
}
else if(o.getElementMeasurementTypeId().equals(WeatherElements.RELATIVE_HUMIDITY))
{
case WeatherElements.TEMPERATURE_MEAN:
TM.add(o);
break;
case WeatherElements.PRECIPITATION:
RR.add(o);
break;
case WeatherElements.RELATIVE_HUMIDITY:
UM.add(o);
break;
default:
// Let it pass in silence
break;
UM.add(o);
}
}
......@@ -431,20 +429,17 @@ public class WeatherUtilTest extends TestCase {
for(WeatherObservation o:faultySeries)
{
switch(o.getElementMeasurementTypeId())
if(o.getElementMeasurementTypeId().equals(WeatherElements.TEMPERATURE_MEAN))
{
TM.add(o);
}
else if(o.getElementMeasurementTypeId().equals(WeatherElements.PRECIPITATION))
{
RR.add(o);
}
else if(o.getElementMeasurementTypeId().equals(WeatherElements.RELATIVE_HUMIDITY))
{
case WeatherElements.TEMPERATURE_MEAN:
TM.add(o);
break;
case WeatherElements.PRECIPITATION:
RR.add(o);
break;
case WeatherElements.RELATIVE_HUMIDITY:
UM.add(o);
break;
default:
// Let it pass in silence
break;
UM.add(o);
}
}
......@@ -469,20 +464,17 @@ public class WeatherUtilTest extends TestCase {
for(WeatherObservation o:faultySeries)
{
switch(o.getElementMeasurementTypeId())
if(o.getElementMeasurementTypeId().equals(WeatherElements.TEMPERATURE_MEAN))
{
TM.add(o);
}
else if(o.getElementMeasurementTypeId().equals(WeatherElements.PRECIPITATION))
{
RR.add(o);
}
else if(o.getElementMeasurementTypeId().equals(WeatherElements.RELATIVE_HUMIDITY))
{
case WeatherElements.TEMPERATURE_MEAN:
TM.add(o);
break;
case WeatherElements.PRECIPITATION:
RR.add(o);
break;
case WeatherElements.RELATIVE_HUMIDITY:
UM.add(o);
break;
default:
// Let it pass in silence
break;
UM.add(o);
}
}
......@@ -520,7 +512,7 @@ public class WeatherUtilTest extends TestCase {
JsonFactory f = new MappingJsonFactory();
JsonParser jp = f.createJsonParser(inputStream);
JsonNode all = jp.readValueAsTree();
List<WeatherObservation> observations = new ArrayList<>();
List<WeatherObservation> observations = new ArrayList<WeatherObservation>();
ObjectMapper mapper = new ObjectMapper();
Date firstDate = null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment