Skip to content

Commit

Permalink
ajustando porta do adente rastreador
Browse files Browse the repository at this point in the history
  • Loading branch information
AdsonEsteves committed Jan 20, 2021
1 parent 19b403f commit 86735cf
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
Binary file modified board.bkp
Binary file not shown.
7 changes: 6 additions & 1 deletion src/main/java/sacip/sti/agents/InterfaceAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;

import org.midas.as.AgentServer;
import org.midas.as.agent.board.Board;
Expand Down Expand Up @@ -139,7 +140,11 @@ public String fazLogin(@RequestBody JsonNode credenciais) {

require("SACIP"+setLocal, "registerStudent"+setLocal).run();

return setLocal+"";
ObjectNode newNode = new ObjectMapper().createObjectNode();
newNode.put("porta", setLocal);
newNode.set("estudante", new ObjectMapper().valueToTree(estudantes.get(0)));

return newNode.toString();

} catch (Exception e) {
LOG.error("ERRO NO LOGIN", e);
Expand Down
26 changes: 13 additions & 13 deletions src/main/java/sacip/sti/agents/TrackingAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
public class TrackingAgent extends Agent implements MessageListener {

private static Logger LOG = LoggerFactory.getLogger(AgentServer.class);
private String port;

@Override
public void provide(String service, Map in, List out) throws ServiceException {
Expand Down Expand Up @@ -71,24 +70,25 @@ protected void lifeCycle() throws LifeCycleException, InterruptedException {
Board.addMessageListener("SACIP", this);

while (alive) {
LOG.info("INSTANCIA " + this.port + " viva");
Thread.sleep(300000);
LOG.info("INSTANCIA " + super.getPort() + " viva");

try {
ServiceWrapper wrapper = require("SACIP"+this.port, "getAluno"+this.port);
Student estudante = (Student) wrapper.run();
descobrirModulosMaisUtilizados(estudante);
descobrirTagsMaisUtilizadas(estudante);
descobrirTopicosMaisUtilizados(estudante);
verificarFrequenciaDoAluno(estudante);
descobrirTempoGastoPorTopico(estudante);
descobrirTempoGastoPorTag(estudante);
descobrirTempoGastoPorModulo(estudante);
descobrirTiposDeExercicioQueMelhorEPiorSaiu(estudante);
ServiceWrapper wrapper = require("SACIP"+super.getPort(), "getAluno"+super.getPort());
Student estudante = (Student) wrapper.run().get(0);
// descobrirModulosMaisUtilizados(estudante);
// descobrirTagsMaisUtilizadas(estudante);
// descobrirTopicosMaisUtilizados(estudante);
// verificarFrequenciaDoAluno(estudante);
// descobrirTempoGastoPorTopico(estudante);
// descobrirTempoGastoPorTag(estudante);
// descobrirTempoGastoPorModulo(estudante);
// descobrirTiposDeExercicioQueMelhorEPiorSaiu(estudante);

} catch (Exception e) {

LOG.error("Ocorreu um erro no ciclo de vida do Agente Rastreador", e);
}
Thread.sleep(30000);
}

}
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/sacip/sti/components/DBConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -702,10 +702,13 @@ private static Map<String, Object> mapaCriacaoUsuario(String[] tags, String[] co

String name = randomString();
String password = randomString();
String avatar = randomString();
String genero = generos[generator.nextInt(generos.length)];
String nivelEdu = niveisEdu[generator.nextInt(niveisEdu.length)];
int idade = generator.nextInt(30)+12;
String[] links = {"https://cdn.discordapp.com/attachments/571157550956019741/800619655366574091/12243585_1694508097447198_1004266710788666891_n.jpg",
"https://cdn.discordapp.com/attachments/571157550956019741/800619703089365002/21077295_1119616784841346_734019202998452151_n.jpg",
"https://cdn.discordapp.com/attachments/571157550956019741/800619727889629264/1521285067403.jpg"};
String avatar = links[generator.nextInt(3)];


conteudo.put("name", name);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/sacip/sti/dataentities/Student.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public List<String> getPreferencias() {
return this.preferencias;
}

public String getPreferenciasAsString() {
public String buildPreferenciasAsString() {

StringBuilder builder = new StringBuilder();

Expand Down Expand Up @@ -157,7 +157,7 @@ public String toString() {
", genero:'" + genero + "'" +
", idade:" + idade + "" +
", nivelEducacional:'" + nivelEducacional + "'" +
", preferencias:[" + getPreferenciasAsString() + "]" +
", preferencias:[" + buildPreferenciasAsString() + "]" +
", trilha:" + trilha + "" +
", exerciciosResolvidos:" + exerciciosResolvidos + "" +
", tempoResolucao:" + tempoResolucao + "" +
Expand Down

0 comments on commit 86735cf

Please sign in to comment.