diff --git a/pom.xml b/pom.xml index ab8d9f6..6a8c6f4 100644 --- a/pom.xml +++ b/pom.xml @@ -60,8 +60,8 @@ provided - io.github.larsid - SOFT-IoT-DLT-Client-Tangle + br.uefs.larsid.iot.soft + soft-iot-dlt-client-tangle-hornet 1.0-SNAPSHOT provided diff --git a/src/main/java/br/uefs/larsid/iot/soft/services/NodeTypeService.java b/src/main/java/br/uefs/larsid/iot/soft/services/NodeTypeService.java deleted file mode 100644 index 686760c..0000000 --- a/src/main/java/br/uefs/larsid/iot/soft/services/NodeTypeService.java +++ /dev/null @@ -1,5 +0,0 @@ -package br.uefs.larsid.iot.soft.services; - -public interface NodeTypeService { - -} diff --git a/src/main/java/br/uefs/larsid/iot/soft/enums/ConductType.java b/src/main/java/node/type/enums/ConductType.java similarity index 66% rename from src/main/java/br/uefs/larsid/iot/soft/enums/ConductType.java rename to src/main/java/node/type/enums/ConductType.java index c8c5afc..69f7176 100644 --- a/src/main/java/br/uefs/larsid/iot/soft/enums/ConductType.java +++ b/src/main/java/node/type/enums/ConductType.java @@ -1,4 +1,4 @@ -package br.uefs.larsid.iot.soft.enums; +package node.type.enums; public enum ConductType { HONEST, MALICIOUS, SELFISH, CORRUPT, DISTURBING diff --git a/src/main/java/br/uefs/larsid/iot/soft/models/NodeType.java b/src/main/java/node/type/models/NodeType.java similarity index 91% rename from src/main/java/br/uefs/larsid/iot/soft/models/NodeType.java rename to src/main/java/node/type/models/NodeType.java index 89fe9b2..531d2d5 100644 --- a/src/main/java/br/uefs/larsid/iot/soft/models/NodeType.java +++ b/src/main/java/node/type/models/NodeType.java @@ -1,19 +1,20 @@ -package br.uefs.larsid.iot.soft.models; +package node.type.models; import br.uefs.larsid.extended.mapping.devices.services.IDevicePropertiesManager; -import br.uefs.larsid.iot.soft.models.conducts.Conduct; -import br.uefs.larsid.iot.soft.models.conducts.Honest; -import br.uefs.larsid.iot.soft.models.conducts.Malicious; -import br.uefs.larsid.iot.soft.models.tangle.LedgerConnector; -import br.uefs.larsid.iot.soft.mqtt.ListenerDevices; -import br.uefs.larsid.iot.soft.services.NodeTypeService; -import br.uefs.larsid.iot.soft.tasks.CheckDevicesTask; -import br.uefs.larsid.iot.soft.tasks.RequestDataTask; -import br.uefs.larsid.iot.soft.tasks.WaitDeviceResponseTask; -import br.uefs.larsid.iot.soft.utils.MQTTClient; import br.ufba.dcc.wiser.soft_iot.entities.Device; import br.ufba.dcc.wiser.soft_iot.entities.Sensor; import dlt.id.manager.services.IIDManagerService; +import node.type.models.conducts.Conduct; +import node.type.models.conducts.Honest; +import node.type.models.conducts.Malicious; +import node.type.models.tangle.LedgerConnector; +import node.type.mqtt.ListenerDevices; +import node.type.services.NodeTypeService; +import node.type.tasks.CheckDevicesTask; +import node.type.tasks.RequestDataTask; +import node.type.tasks.WaitDeviceResponseTask; +import node.type.utils.MQTTClient; + import java.io.IOException; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/br/uefs/larsid/iot/soft/models/conducts/Conduct.java b/src/main/java/node/type/models/conducts/Conduct.java similarity index 88% rename from src/main/java/br/uefs/larsid/iot/soft/models/conducts/Conduct.java rename to src/main/java/node/type/models/conducts/Conduct.java index f4698c2..65b6118 100644 --- a/src/main/java/br/uefs/larsid/iot/soft/models/conducts/Conduct.java +++ b/src/main/java/node/type/models/conducts/Conduct.java @@ -1,7 +1,7 @@ -package br.uefs.larsid.iot.soft.models.conducts; +package node.type.models.conducts; -import br.uefs.larsid.iot.soft.enums.ConductType; -import br.uefs.larsid.iot.soft.models.tangle.LedgerConnector; +import node.type.enums.ConductType; +import node.type.models.tangle.LedgerConnector; public abstract class Conduct { diff --git a/src/main/java/br/uefs/larsid/iot/soft/models/conducts/Honest.java b/src/main/java/node/type/models/conducts/Honest.java similarity index 80% rename from src/main/java/br/uefs/larsid/iot/soft/models/conducts/Honest.java rename to src/main/java/node/type/models/conducts/Honest.java index 135f544..2b94d25 100644 --- a/src/main/java/br/uefs/larsid/iot/soft/models/conducts/Honest.java +++ b/src/main/java/node/type/models/conducts/Honest.java @@ -1,10 +1,12 @@ -package br.uefs.larsid.iot.soft.models.conducts; +package node.type.models.conducts; +// TODO: Corrigir package em todas as classes. + +import dlt.client.tangle.hornet.enums.TransactionType; +import dlt.client.tangle.hornet.model.transactions.Evaluation; +import dlt.client.tangle.hornet.model.transactions.Transaction; +import node.type.enums.ConductType; +import node.type.models.tangle.LedgerConnector; -import br.uefs.larsid.iot.soft.enums.ConductType; -import br.uefs.larsid.iot.soft.models.tangle.LedgerConnector; -import dlt.client.tangle.enums.TransactionType; -import dlt.client.tangle.model.transactions.Evaluation; -import dlt.client.tangle.model.transactions.Transaction; import java.util.logging.Logger; public class Honest extends Conduct { @@ -13,7 +15,7 @@ public class Honest extends Conduct { /** * Método construtor. - * + * * @param ledgerConnector LedgerConnector - Conector para comunicação com a Tangle. * @param id String - Identificador único do nó. */ diff --git a/src/main/java/br/uefs/larsid/iot/soft/models/conducts/Malicious.java b/src/main/java/node/type/models/conducts/Malicious.java similarity index 88% rename from src/main/java/br/uefs/larsid/iot/soft/models/conducts/Malicious.java rename to src/main/java/node/type/models/conducts/Malicious.java index c25b9c4..436e56f 100644 --- a/src/main/java/br/uefs/larsid/iot/soft/models/conducts/Malicious.java +++ b/src/main/java/node/type/models/conducts/Malicious.java @@ -1,10 +1,11 @@ -package br.uefs.larsid.iot.soft.models.conducts; +package node.type.models.conducts; + +import dlt.client.tangle.hornet.enums.TransactionType; +import dlt.client.tangle.hornet.model.transactions.Evaluation; +import dlt.client.tangle.hornet.model.transactions.Transaction; +import node.type.enums.ConductType; +import node.type.models.tangle.LedgerConnector; -import br.uefs.larsid.iot.soft.enums.ConductType; -import br.uefs.larsid.iot.soft.models.tangle.LedgerConnector; -import dlt.client.tangle.enums.TransactionType; -import dlt.client.tangle.model.transactions.Evaluation; -import dlt.client.tangle.model.transactions.Transaction; import java.util.Random; import java.util.logging.Logger; @@ -17,7 +18,7 @@ public class Malicious extends Conduct { /** * Método construtor. - * + * * @param ledgerConnector LedgerConnector - Conector para comunicação com a Tangle. * @param id String - Identificador único do nó. * @param honestyRate float - Taxa de honestidade do nó malicioso. diff --git a/src/main/java/br/uefs/larsid/iot/soft/models/tangle/LedgerConnector.java b/src/main/java/node/type/models/tangle/LedgerConnector.java similarity index 74% rename from src/main/java/br/uefs/larsid/iot/soft/models/tangle/LedgerConnector.java rename to src/main/java/node/type/models/tangle/LedgerConnector.java index 728a1c2..3151fe0 100644 --- a/src/main/java/br/uefs/larsid/iot/soft/models/tangle/LedgerConnector.java +++ b/src/main/java/node/type/models/tangle/LedgerConnector.java @@ -1,9 +1,9 @@ -package br.uefs.larsid.iot.soft.models.tangle; +package node.type.models.tangle; -import dlt.client.tangle.model.transactions.Transaction; -import dlt.client.tangle.services.ILedgerReader; -import dlt.client.tangle.services.ILedgerSubscriber; -import dlt.client.tangle.services.ILedgerWriter; +import dlt.client.tangle.hornet.model.transactions.Transaction; +import dlt.client.tangle.hornet.services.ILedgerReader; +import dlt.client.tangle.hornet.services.ILedgerSubscriber; +import dlt.client.tangle.hornet.services.ILedgerWriter; /** * @author Allan Capistrano @@ -15,7 +15,7 @@ public class LedgerConnector { /** * Inscreve em um tópico para escutar as transações que são realizadas. - * + * * @param topic String - Tópico. * @param iLedgerSubscriber ILedgerSubscriber - Objeto para inscrição. */ @@ -25,7 +25,7 @@ public void subscribe(String topic, ILedgerSubscriber iLedgerSubscriber) { /** * Se desinscreve de um tópico. - * + * * @param topic String - Tópico. * @param iLedgerSubscriber ILedgerSubscriber - Objeto para inscrição. */ @@ -35,7 +35,7 @@ public void unsubscribe(String topic, ILedgerSubscriber iLedgerSubscriber) { /** * Põe uma transação para ser publicada na Tangle. - * + * * @param transaction Transaction - Transação que será publicada. * @throws InterruptedException */ @@ -44,13 +44,13 @@ public void put(Transaction transaction) throws InterruptedException { } /** - * Obtém uma transação a partir do hash da mesma. - * - * @param hash String - Hash da transação. + * Obtém uma transação a partir do ID da mesma. + * + * @param id String - ID da transação. * @return Transaction. */ - public Transaction getTransactionByHash(String hash) { - return this.ledgerWriter.getTransactionByHash(hash); + public Transaction getTransactionById(String id) { + return this.ledgerReader.getTransactionById(id); } public ILedgerWriter getLedgerWriter() { diff --git a/src/main/java/br/uefs/larsid/iot/soft/mqtt/ListenerDevices.java b/src/main/java/node/type/mqtt/ListenerDevices.java similarity index 94% rename from src/main/java/br/uefs/larsid/iot/soft/mqtt/ListenerDevices.java rename to src/main/java/node/type/mqtt/ListenerDevices.java index d9cbbe4..d1f5f38 100644 --- a/src/main/java/br/uefs/larsid/iot/soft/mqtt/ListenerDevices.java +++ b/src/main/java/node/type/mqtt/ListenerDevices.java @@ -1,7 +1,8 @@ -package br.uefs.larsid.iot.soft.mqtt; +package node.type.mqtt; + +import node.type.models.NodeType; +import node.type.utils.MQTTClient; -import br.uefs.larsid.iot.soft.models.NodeType; -import br.uefs.larsid.iot.soft.utils.MQTTClient; import com.google.gson.Gson; import com.google.gson.JsonObject; import java.util.logging.Logger; diff --git a/src/main/java/node/type/services/NodeTypeService.java b/src/main/java/node/type/services/NodeTypeService.java new file mode 100644 index 0000000..c7f8310 --- /dev/null +++ b/src/main/java/node/type/services/NodeTypeService.java @@ -0,0 +1,5 @@ +package node.type.services; + +public interface NodeTypeService { + +} diff --git a/src/main/java/br/uefs/larsid/iot/soft/tasks/CheckDevicesTask.java b/src/main/java/node/type/tasks/CheckDevicesTask.java similarity index 90% rename from src/main/java/br/uefs/larsid/iot/soft/tasks/CheckDevicesTask.java rename to src/main/java/node/type/tasks/CheckDevicesTask.java index 52a2dc2..c7ccff3 100644 --- a/src/main/java/br/uefs/larsid/iot/soft/tasks/CheckDevicesTask.java +++ b/src/main/java/node/type/tasks/CheckDevicesTask.java @@ -1,10 +1,11 @@ -package br.uefs.larsid.iot.soft.tasks; +package node.type.tasks; -import br.uefs.larsid.iot.soft.models.NodeType; import java.io.IOException; import java.util.TimerTask; import java.util.logging.Logger; +import node.type.models.NodeType; + /** * Classe responsável pela tarefa de atualizar a lista de dispositivos * conectados ao nó. diff --git a/src/main/java/br/uefs/larsid/iot/soft/tasks/RequestDataTask.java b/src/main/java/node/type/tasks/RequestDataTask.java similarity index 89% rename from src/main/java/br/uefs/larsid/iot/soft/tasks/RequestDataTask.java rename to src/main/java/node/type/tasks/RequestDataTask.java index 4e4c2e8..8817805 100644 --- a/src/main/java/br/uefs/larsid/iot/soft/tasks/RequestDataTask.java +++ b/src/main/java/node/type/tasks/RequestDataTask.java @@ -1,9 +1,10 @@ -package br.uefs.larsid.iot.soft.tasks; +package node.type.tasks; -import br.uefs.larsid.iot.soft.models.NodeType; import java.util.TimerTask; import java.util.logging.Logger; +import node.type.models.NodeType; + /** * Classe responsável pela tarefa de requisitar dados de um dos sensores de um * dispositivo aleatório que estão conectado ao nó. diff --git a/src/main/java/br/uefs/larsid/iot/soft/tasks/WaitDeviceResponseTask.java b/src/main/java/node/type/tasks/WaitDeviceResponseTask.java similarity index 94% rename from src/main/java/br/uefs/larsid/iot/soft/tasks/WaitDeviceResponseTask.java rename to src/main/java/node/type/tasks/WaitDeviceResponseTask.java index c4e3f68..33007fe 100644 --- a/src/main/java/br/uefs/larsid/iot/soft/tasks/WaitDeviceResponseTask.java +++ b/src/main/java/node/type/tasks/WaitDeviceResponseTask.java @@ -1,9 +1,10 @@ -package br.uefs.larsid.iot.soft.tasks; +package node.type.tasks; -import br.uefs.larsid.iot.soft.models.NodeType; import java.util.TimerTask; import java.util.logging.Logger; +import node.type.models.NodeType; + /** * Classe responsável por verificar se houve resposta do dispositivo à * requisição feita pelo nó. diff --git a/src/main/java/br/uefs/larsid/iot/soft/utils/MQTTClient.java b/src/main/java/node/type/utils/MQTTClient.java similarity index 99% rename from src/main/java/br/uefs/larsid/iot/soft/utils/MQTTClient.java rename to src/main/java/node/type/utils/MQTTClient.java index a9d3be4..2197a37 100644 --- a/src/main/java/br/uefs/larsid/iot/soft/utils/MQTTClient.java +++ b/src/main/java/node/type/utils/MQTTClient.java @@ -1,4 +1,4 @@ -package br.uefs.larsid.iot.soft.utils; +package node.type.utils; import java.util.Arrays; import java.util.logging.Logger; diff --git a/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/src/main/resources/OSGI-INF/blueprint/blueprint.xml index 9366414..b47ccac 100644 --- a/src/main/resources/OSGI-INF/blueprint/blueprint.xml +++ b/src/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -8,11 +8,11 @@ - - + + - @@ -21,12 +21,12 @@ - + -