Skip to content

Commit

Permalink
datainfo
Browse files Browse the repository at this point in the history
  • Loading branch information
AdsonEsteves committed Jan 21, 2021
1 parent 86735cf commit 36b65ea
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 15 deletions.
7 changes: 7 additions & 0 deletions ServerAgentsServices.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@
<scope>components</scope>
<organization>SACIP</organization>
</service>
<service>
<name>getInfo</name>
<description>retorna informacoes gerais sobre os conteudos</description>
<entity>DBConnection</entity>
<scope>components</scope>
<organization>SACIP</organization>
</service>


</services>
Binary file modified board.bkp
Binary file not shown.
37 changes: 37 additions & 0 deletions src/main/java/sacip/rest/RestTutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

import java.util.List;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;

import org.midas.as.AgentServer;
import org.midas.as.manager.execution.ServiceWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

Expand Down Expand Up @@ -41,5 +46,37 @@ public String getTrilha(@PathVariable String agentPort){
}
}

@GetMapping("/getInfo")
public String getInfo(){
try {
ServiceWrapper wrapper = AgentServer.require("SACIP", "getInfo");
List run = wrapper.run();
return run.get(0).toString();
} catch (Exception e) {
LOG.error("Falhou ao pegar trilha", e);
return "Falhou ao pegar trilha: \n"+e.getLocalizedMessage();
}
}

@GetMapping("/buscarConteudo")
public String getConteudos(@RequestBody JsonNode dados){
try {
ServiceWrapper wrapper = AgentServer.require("SACIP", "findContents");
ArrayNode tags = ((ArrayNode)dados.get("tags"));

wrapper.addParameter("name", dados.get("nome").asText());
wrapper.addParameter("topic", dados.get("topico").asText());
wrapper.addParameter("taxonomy", dados.get("taxonomia").asText());
wrapper.addParameter("level", dados.get("nivel").asText());
wrapper.addParameter("tags", new ObjectMapper().convertValue(tags, String[].class));

List run = wrapper.run();
return run.toString();
} catch (Exception e) {
LOG.error("Falhou ao pegar trilha", e);
return "Falhou ao pegar trilha: \n"+e.getLocalizedMessage();
}
}

}

15 changes: 1 addition & 14 deletions src/main/java/sacip/sti/agents/PedagogicalAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,20 +166,7 @@ private String suggestContent()
if(student==null && !s.getName().equals(getAluno().getName()))
grupo.add(s);
});

// for (Student student : studentGroup) {
// boolean has = false;
// for (Student student2 : grupo) {
// if(student.getName().equals(student2.getName()))
// {
// has = true;
// break;
// }
// }
// if(!has)
// grupo.add(student);
// }


//Pedir recomendação para o recomendador
ServiceWrapper servicoGetContent = require("SACIP", "getRecommendedContent");
servicoGetContent.addParameter("estudante", getAluno());
Expand Down
37 changes: 36 additions & 1 deletion src/main/java/sacip/sti/components/DBConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.Random;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import org.midas.as.AgentServer;
import org.midas.as.agent.templates.Component;
Expand Down Expand Up @@ -93,7 +94,11 @@ public void provide(String service, Map in, List out) throws ServiceException {
case "deleteContent":
out.add(deleteContent((String) in.get("name")));
break;


case "getInfo":
out.add(getContentInfo());
break;

}
} catch (Exception e) {
out.add(e.getMessage());
Expand Down Expand Up @@ -575,6 +580,23 @@ private String deleteContent(String name)
}
}

private String getContentInfo()
{
try
{
var result = cypher.writequery("MATCH (n:INFO)"+
"RETURN n"
, Map.of());

return new ObjectMapper().writeValueAsString(result.get(0).get("n")).toString();
}
catch (Exception e)
{
LOG.error("FALHOU pegar Informacao Conteudos", e);
return "FALHOU pegar Informacao Conteudos" + e.getLocalizedMessage();
}
}

private void showNodes()
{
var result = cypher.readquery("MATCH (n) RETURN n", Map.of());
Expand Down Expand Up @@ -627,6 +649,13 @@ private void dummyData()
{"t10", "t11", "t12"},
{"t13", "t14", "t15"}
};
String[] topicos1d = {
"t1", "t2", "t3",
"t4", "t5", "t6",
"t7", "t8", "t9",
"t10", "t11", "t12",
"t13", "t14", "t15",
};

int niveis = 5;

Expand Down Expand Up @@ -660,6 +689,12 @@ private void dummyData()

doQuery("UNWIND $props AS map CREATE (n:USER) SET n = map", Map.of("props", dummyStudents.toArray()));

doQuery("CREATE (n:INFO {"+
"MAXlevel: $MAXlevel,"+
"tags: $tags,"+
"topics: $topics"+
"})", Map.of("MAXlevel", niveis, "tags", tags, "topics", topicos1d));

}

private static Map<String, Object> mapaCriacaoConteudo(String[] tags, String[][] topicos, int niveis, String[] complexidades)
Expand Down

0 comments on commit 36b65ea

Please sign in to comment.