From 536f363556b4f21a8987a14c7ec426185d1cfe57 Mon Sep 17 00:00:00 2001 From: renanaferreira Date: Mon, 4 Jan 2021 10:01:22 +0000 Subject: [PATCH] remove testing code and add new files --- .../main/java/com/ies/blossom/Testing.java | 76 ------------------- .../blossom/controllers/ParcelController.java | 1 - .../java/com/ies/blossom/entitys/Parcel.java | 3 +- .../blossom/model/GoodPlantMeasureModel.java | 22 ++++++ 4 files changed, 24 insertions(+), 78 deletions(-) delete mode 100644 blossom/src/main/java/com/ies/blossom/Testing.java create mode 100644 blossom/src/main/java/com/ies/blossom/model/GoodPlantMeasureModel.java diff --git a/blossom/src/main/java/com/ies/blossom/Testing.java b/blossom/src/main/java/com/ies/blossom/Testing.java deleted file mode 100644 index 1feb311..0000000 --- a/blossom/src/main/java/com/ies/blossom/Testing.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.ies.blossom; - -import java.sql.Date; -import java.sql.Timestamp; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import com.ies.blossom.entitys.HumMeasure; -import com.ies.blossom.entitys.HumSensor; -import com.ies.blossom.entitys.Parcel; -import com.ies.blossom.entitys.PhMeasure; -import com.ies.blossom.entitys.PhSensor; -import com.ies.blossom.entitys.Plant; - -public class Testing { - - - public static void makeData(Parcel parcel, List plants) { - plants = new ArrayList(); - Plant plant = new Plant("Daisy", "Daisius", 2.0, 1.0, 1.0, 2.0); - parcel.setPlant(plant); - plants.add(plant); - plants.add(new Plant("Rosa", "Rosita", 1.5, 1.0, 1.0, 2.5)); - plants.add(new Plant("Margarida", "Margaridus", 0.5, 0.3, 1.0, 2.5)); - - Double[] lista = new Double[]{1.0, 1.6, 1.4}; - Double[] lista2 = new Double[]{4.0, 1.6, 1.4}; - try { - parcel.setPhSensors(makePhSensors(parcel, lista2)); - parcel.setHumSensors(makeHumSensors(parcel, lista)); - } catch (ParseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - - private static Set makeHumSensors(Parcel parcel, Double[] lista) throws ParseException{ - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); - - Set humsensores = new HashSet(); - HumSensor humsensor; - List humeasures; - for (Double double1 : lista) { - humsensor = new HumSensor(parcel, new Date((sdf.parse("2019-01-01 00:00:00")).getTime())); - humeasures = new ArrayList(); - humeasures.add(new HumMeasure(humsensor, new Timestamp((sdf.parse("2019-01-03 00:00:00")).getTime()) , double1)); - humsensor.setMeasures(humeasures); - humsensores.add(humsensor); - } - return humsensores; - } - - private static Set makePhSensors(Parcel parcel, Double[] lista) throws ParseException{ - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); - - Set phsensores = new HashSet(); - PhSensor phsensor; - List phmeasures; - for (Double double1 : lista) { - phsensor = new PhSensor(parcel, new Date((sdf.parse("2019-01-01 00:00:00")).getTime())); - phmeasures = new ArrayList(); - phmeasures.add(new PhMeasure(phsensor, new Timestamp((sdf.parse("2019-01-03 00:00:00")).getTime()), double1)); - phsensor.setMeasures(phmeasures); - phsensores.add(phsensor); - } - return phsensores; - } - - - -} diff --git a/blossom/src/main/java/com/ies/blossom/controllers/ParcelController.java b/blossom/src/main/java/com/ies/blossom/controllers/ParcelController.java index 15ed1b2..3adde28 100644 --- a/blossom/src/main/java/com/ies/blossom/controllers/ParcelController.java +++ b/blossom/src/main/java/com/ies/blossom/controllers/ParcelController.java @@ -1,6 +1,5 @@ package com.ies.blossom.controllers; -import com.ies.blossom.Testing; import com.ies.blossom.entitys.HumMeasure; import com.ies.blossom.entitys.HumSensor; import com.ies.blossom.entitys.Parcel; diff --git a/blossom/src/main/java/com/ies/blossom/entitys/Parcel.java b/blossom/src/main/java/com/ies/blossom/entitys/Parcel.java index 7105b7c..ddedb76 100644 --- a/blossom/src/main/java/com/ies/blossom/entitys/Parcel.java +++ b/blossom/src/main/java/com/ies/blossom/entitys/Parcel.java @@ -214,7 +214,8 @@ private Boolean plantIsGoodForParcel(Plant plant, boolean usesPh, boolean usesHu // private GoodPlantMeasureModel checkPlantMeasureConditions(boolean isHumidity, Plant plant, Set sensores) { - if(this.noMeasure(isHumidity, null)) { + sensores = this.getSensores(isHumidity, sensores); + if(this.noMeasure(isHumidity, sensores)) { return null; } Double percentage = this.generalMeasurePercentage(isHumidity, plant, sensores); diff --git a/blossom/src/main/java/com/ies/blossom/model/GoodPlantMeasureModel.java b/blossom/src/main/java/com/ies/blossom/model/GoodPlantMeasureModel.java new file mode 100644 index 0000000..0e42fe1 --- /dev/null +++ b/blossom/src/main/java/com/ies/blossom/model/GoodPlantMeasureModel.java @@ -0,0 +1,22 @@ +package com.ies.blossom.model; + +public class GoodPlantMeasureModel { + + + private double percentage; + private boolean good; + + public GoodPlantMeasureModel(double percentage, boolean good){ + this.percentage = percentage; + this.good = good; + } + + public double getPercentage() { + return percentage; + } + + public boolean isGood() { + return good; + } + +}