Skip to content
Snippets Groups Projects
Commit c729ff26 authored by Eilert Tunheim's avatar Eilert Tunheim
Browse files

Updated the constants class with input parameters from the user

parent 8a74b214
No related branches found
No related tags found
No related merge requests found
...@@ -2,8 +2,6 @@ package com.application.DB; ...@@ -2,8 +2,6 @@ package com.application.DB;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;
/** /**
* This class contains constants to be used related to database activities * This class contains constants to be used related to database activities
...@@ -20,10 +18,17 @@ public final class Constants { ...@@ -20,10 +18,17 @@ public final class Constants {
// Today's date // Today's date
public static final String TODAYS_DATE = format.format(LocalDateTime.now()); public static final String TODAYS_DATE = format.format(LocalDateTime.now());
// User inputs
public static final String TREE_SPECIES = "";
public static final String WIDTH_DIMENTION = "";
public static final String HEIGHT_DIMENTION = "";
public static final String SAWSET = "";
public static final int MOISTURE_GOAL = 0;
// Database ID/name // Database ID/name
public static final String PROJECT_ID = "sf-drying-optimization"; public static final String PROJECT_ID = "sf-drying-optimization";
/*
// Location Valasen(124) // Location Valasen(124)
// Project settings // Project settings
public static final int LOCATION_ID = 124; public static final int LOCATION_ID = 124;
...@@ -40,15 +45,12 @@ public final class Constants { ...@@ -40,15 +45,12 @@ public final class Constants {
// Winccsensordata // Winccsensordata
public static final String KWH_NAME = "VariantValue"; public static final String KWH_NAME = "VariantValue";
public static final String TIMESTAMP_NAME = "Timestamp";
public static final String VALUE_ID_NAME = "ValueID";
public static final int VALUE_ID = 51; public static final int VALUE_ID = 51;
*/
/*
// Location Arjang(174) // Location Arjang(174)
// Project settings // Project settings
public static final int LOCATION_ID = 174; public static final int LOCATION_ID = 174;
...@@ -63,11 +65,13 @@ public final class Constants { ...@@ -63,11 +65,13 @@ public final class Constants {
public static final String KILIN_NAME = "KilinId"; public static final String KILIN_NAME = "KilinId";
public static final int KILIN_ID = 16; public static final int KILIN_ID = 16;
// Winccsensordata // Swappconsensordata
public static final String KWH_NAME = "RealValue"; public static final String KWH_NAME = "RealValue";
public static final String TIMESTAMP_NAME = "Timestamp";
public static final String VALUE_ID_NAME = "ValueID";
public static final int VALUE_ID = 19; public static final int VALUE_ID = 19;
*/
} }
...@@ -168,12 +168,12 @@ public class DB { ...@@ -168,12 +168,12 @@ public class DB {
// Preparing a query statement // Preparing a query statement
// Query statement 124 Valåsen // Query statement 124 Valåsen
final String sqlStatement = "SELECT `TimeStamp`, `"+KWH_NAME+"` " + final String sqlStatement = "SELECT `" + TIMESTAMP_NAME + "`, `"+KWH_NAME+"` " +
"FROM `" + PROJECT_ID + "." + LOCATION_ID + "." + TABLE_NAME_KWH + "` " + "FROM `" + PROJECT_ID + "." + LOCATION_ID + "." + TABLE_NAME_KWH + "` " +
"WHERE TimeStamp BETWEEN " + '"'+ entry.getKey() + '"' + "WHERE " + TIMESTAMP_NAME + " BETWEEN " + '"'+ entry.getKey() + '"' +
" AND " + '"' + entry.getValue() + '"' + " AND " + '"' + entry.getValue() + '"' +
" AND ValueID = " + VALUE_ID + " " + " AND " + VALUE_ID_NAME + " = " + VALUE_ID + " " +
" ORDER BY TimeStamp ASC"; " ORDER BY " + TIMESTAMP_NAME + " ASC";
...@@ -209,7 +209,7 @@ public class DB { ...@@ -209,7 +209,7 @@ public class DB {
int variantValue = row.get(""+KWH_NAME+"").getNumericValue().intValue()-baseline; //-baseline int variantValue = row.get(""+KWH_NAME+"").getNumericValue().intValue()-baseline; //-baseline
// Retrieving the wanted data // Retrieving the wanted data
long timeStamp = row.get("TimeStamp").getTimestampValue() / 1000; long timeStamp = row.get(""+TIMESTAMP_NAME+"").getTimestampValue() / 1000;
// Riktig format, men i string // Riktig format, men i string
String formatedTimeStamp = getDateFormat().format(timeStamp); String formatedTimeStamp = getDateFormat().format(timeStamp);
...@@ -369,20 +369,8 @@ public class DB { ...@@ -369,20 +369,8 @@ public class DB {
formatedUtTidTork = splitValue[0] + " " + splitValue[1]; formatedUtTidTork = splitValue[0] + " " + splitValue[1];
} }
System.out.println("Inn formated: "+formatedInTidTork); //System.out.println("Inn formated: "+formatedInTidTork);
System.out.println("Ut formated: "+formatedUtTidTork+"\n"); //System.out.println("Ut formated: "+formatedUtTidTork+"\n");
/*
// CalculatedStop:
// DryingCompleted:
if(!row.get("CalculatedStop").isNull()){
long utTidTorkLong = row.get("CalculatedStop").getTimestampValue()/1000;
// Formating the data from long to a string in the correct date format
formatedUtTidTork = getDateFormat().format(utTidTorkLong);
} else {
formatedUtTidTork = "";
}
*/
// Checks if intidtork or outtidtork is empty, if so they are ignored and not added to the list // Checks if intidtork or outtidtork is empty, if so they are ignored and not added to the list
if (!formatedInTidTork.isEmpty() && !formatedUtTidTork.isEmpty()){ if (!formatedInTidTork.isEmpty() && !formatedUtTidTork.isEmpty()){
...@@ -391,7 +379,7 @@ public class DB { ...@@ -391,7 +379,7 @@ public class DB {
} }
//System.out.printf("%s\t\t\t%s\n",formatedInTidTork,formatedUtTidTork); //System.out.printf("%s\t\t\t%s\n",formatedInTidTork,formatedUtTidTork);
} }
System.out.printf("Size of dates: %s\n", dates.size()); System.out.printf("Size of dates: %s\n\n", dates.size());
// Returns a treemap that sorts the dates incrementally // Returns a treemap that sorts the dates incrementally
return new TreeMap<>(dates); return new TreeMap<>(dates);
......
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment