Skip to content

Commit

Permalink
ajustando entidades
Browse files Browse the repository at this point in the history
  • Loading branch information
shina authored and shina committed Jan 18, 2021
1 parent 3515dda commit 19b403f
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 33 deletions.
7 changes: 7 additions & 0 deletions UserAgentsServices.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
<scope>mas</scope>
<organization>SACIP</organization>
</service>
<service>
<name>getTrilha</name>
<description>retorna a trilha atual do aluno</description>
<entity>PedagogicalAgent</entity>
<scope>mas</scope>
<organization>SACIP</organization>
</service>

<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<!-- SACIP Tracking Agent -->
Expand Down
Binary file modified board.bkp
Binary file not shown.
25 changes: 11 additions & 14 deletions src/main/java/sacip/rest/RestTutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,17 @@ public String getConteudosRecomendados(@PathVariable String agentPort){
}
}

// @GetMapping("/trilha/{user}")
// public String getTrilhaUsuario(String name) {
// return test;
// }

// @GetMapping("/trilha")
// public String getTrilhas(String name) {
// return test;
// }

// @GetMapping("/dicas")
// public String getDicas(String name) {
// return test;
// }
@GetMapping("/requisitaTrilha/{agentPort}")
public String getTrilha(@PathVariable String agentPort){
try {
ServiceWrapper wrapper = AgentServer.require("SACIP"+agentPort, "getTrilha"+agentPort);
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();
}
}

}

8 changes: 7 additions & 1 deletion src/main/java/sacip/sti/agents/PedagogicalAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import java.util.Map;
import java.util.Map.Entry;

import com.fasterxml.jackson.databind.ObjectMapper;

import org.midas.as.AgentServer;
import org.midas.as.agent.board.Board;
import org.midas.as.agent.board.BoardException;
Expand Down Expand Up @@ -89,6 +91,10 @@ public void provide(String service, Map in, List out) throws ServiceException {
out.add(getAluno());
break;

case "getTrilha":
out.add(new ObjectMapper().valueToTree(trilha));
break;

case "suggestContent":
out.add(suggestContent());
break;
Expand Down Expand Up @@ -184,7 +190,7 @@ private String suggestContent()
{
return "vazio";
}
String recomendacoes = (String) resultado.get(0);
String recomendacoes = resultado.get(0).toString();

return recomendacoes;

Expand Down
7 changes: 5 additions & 2 deletions src/main/java/sacip/sti/agents/RecommenderAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.Set;

import org.midas.as.AgentServer;
Expand Down Expand Up @@ -51,7 +54,7 @@ protected void lifeCycle() throws LifeCycleException, InterruptedException {
//Board.setContextAttribute("eventState", "checkErrors");
}

private String getConteudosRecomendados(List<Student> grupo, Student aluno, List<Content> trilha) {
private Object getConteudosRecomendados(List<Student> grupo, Student aluno, List<Content> trilha) {

List<String> preferenciasAluno = aluno.getPreferencias();

Expand Down Expand Up @@ -172,7 +175,7 @@ public int compare(Content o1, Content o2) {

//retornando conteudos
String exercicio = top10Conteudos.toString();
return exercicio;
return new ObjectMapper().valueToTree(top10Conteudos);
}
catch (Exception e)
{
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/sacip/sti/components/DBConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,15 @@ private Content instanceContent(Map in)
{
try {
return new Content((String)in.get("name"),
(String)in.get("descricao"),
((Long)in.get("level")).intValue(),
(String)in.get("topic"),
(String)in.get("complexity"),
(boolean)in.get("exercise"),
((Long)in.get("taxonomy")).intValue(),
(List<String>) in.get("tags"),
(String)in.get("link"));
(String)in.get("link"),
(String)in.get("imageLink"));
} catch (Exception e) {
LOG.error("Não foi possível instanciar o conteúdo", e);
return null;
Expand Down Expand Up @@ -665,23 +667,30 @@ private static Map<String, Object> mapaCriacaoConteudo(String[] tags, String[][]
Map<String, Object> conteudo = new HashMap<>();

String name = randomString();
String descricao = randomString();
Random generator = new Random();
int level = generator.nextInt(5) + 1;
String topico = topicos[level-1][generator.nextInt(3)];
String complexidade = complexidades[generator.nextInt(4)];
int taxonomia = generator.nextInt(6);
boolean exercicio = generator.nextBoolean();
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 imageLink = links[generator.nextInt(3)];

contentNames.add(name);

conteudo.put("name", name);
conteudo.put("level", level);
conteudo.put("descricao", descricao);
conteudo.put("topic", topico);
conteudo.put("complexity", complexidade);
conteudo.put("exercise", exercicio);
conteudo.put("taxonomy", taxonomia);
conteudo.put("tags", tags);
conteudo.put("link", name);
conteudo.put("level", level);
conteudo.put("imageLink", imageLink);

return conteudo;
}
Expand Down
48 changes: 34 additions & 14 deletions src/main/java/sacip/sti/dataentities/Content.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

import java.util.List;

import org.midas.util.MidasBean;

public class Content extends MidasBean{
public class Content{

private String name;
private String descricao;
private String topic;
private String complexity;
private boolean exercise;
private int taxonomy;
private List<String> tags;
private String link;
private int level;
private String imageLink;

public int pontos = 0;

Expand All @@ -22,15 +22,17 @@ public Content() {
}


public Content(String name, int level, String topic, String complexity, boolean exercise, int taxonomy, List<String> tags, String link) {
public Content(String name, String descricao, int level, String topic, String complexity, boolean exercise, int taxonomy, List<String> tags, String link, String imageLink) {
this.name = name;
this.descricao = descricao;
this.topic = topic;
this.complexity = complexity;
this.exercise = exercise;
this.taxonomy = taxonomy;
this.tags = tags;
this.link = link;
this.level = level;
this.imageLink = imageLink;
}

public String getName() {
Expand All @@ -41,6 +43,14 @@ public void setName(String name) {
this.name = name;
}

public String getDescricao() {
return descricao;
}

public void setDescricao(String descricao) {
this.descricao = descricao;
}

public String getTopic() {
return this.topic;
}
Expand Down Expand Up @@ -81,7 +91,7 @@ public List<String> getTags() {
return this.tags;
}

public String getTagsAsString() {
public String buildTagsAsString() {

StringBuilder builder = new StringBuilder();

Expand Down Expand Up @@ -115,19 +125,29 @@ public void setLevel(int level) {
this.level = level;
}

public String getImageLink() {
return imageLink;
}

public void setImageLink(String imageLink) {
this.imageLink = imageLink;
}

@Override
public String toString() {
return "{" +
" name:'" + getName() + "'" +
", level:'" + getLevel() + "'" +
", topic:'" + getTopic() + "'" +
", complexity:'" + getComplexity() + "'" +
", exercise:" + isExercise() + "" +
", taxonomy:'" + getTaxonomy() + "'" +
", tags:[" + getTagsAsString() + "]" +
", link:'" + getLink() + "'" +
" name='" + getName() + "'" +
", descricao='" + getDescricao() + "'" +
", topic='" + getTopic() + "'" +
", complexity='" + getComplexity() + "'" +
", exercise='" + isExercise() + "'" +
", taxonomy='" + getTaxonomy() + "'" +
", tags:[" + buildTagsAsString() + "]" +
", link='" + getLink() + "'" +
", level='" + getLevel() + "'" +
", imageLink='" + getImageLink() + "'" +
"}";
}


}

0 comments on commit 19b403f

Please sign in to comment.