diff --git a/pom.xml b/pom.xml index 8228cf1..6297311 100644 --- a/pom.xml +++ b/pom.xml @@ -26,6 +26,10 @@ + + org.springframework.boot + spring-boot-starter-thymeleaf + org.springframework.boot spring-boot-starter-data-elasticsearch @@ -49,6 +53,17 @@ pom + + org.webjars + bootstrap + 3.3.7-1 + + + org.webjars + jquery + 3.1.1-1 + + diff --git a/src/main/java/com/manalejandro/arjion/WebConfig.java b/src/main/java/com/manalejandro/arjion/WebConfig.java new file mode 100644 index 0000000..10cc6df --- /dev/null +++ b/src/main/java/com/manalejandro/arjion/WebConfig.java @@ -0,0 +1,16 @@ +package com.manalejandro.arjion; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +@EnableWebMvc +public class WebConfig implements WebMvcConfigurer { + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/webjars/**").addResourceLocations("/webjars/"); + } +} diff --git a/src/main/java/com/manalejandro/arjion/controllers/MainController.java b/src/main/java/com/manalejandro/arjion/controllers/MainController.java index b4da584..1c7a517 100644 --- a/src/main/java/com/manalejandro/arjion/controllers/MainController.java +++ b/src/main/java/com/manalejandro/arjion/controllers/MainController.java @@ -1,8 +1,14 @@ package com.manalejandro.arjion.controllers; import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; @Controller public class MainController { + @RequestMapping(path = "/") + public String indexPage(final Model model) { + return "index"; + } } diff --git a/src/main/java/com/manalejandro/arjion/model/Documento.java b/src/main/java/com/manalejandro/arjion/model/Documento.java index 9029b8e..f7060cc 100644 --- a/src/main/java/com/manalejandro/arjion/model/Documento.java +++ b/src/main/java/com/manalejandro/arjion/model/Documento.java @@ -1,12 +1,32 @@ package com.manalejandro.arjion.model; +import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.elasticsearch.annotations.Mapping; import org.springframework.data.elasticsearch.annotations.Setting; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + @Document(indexName = "#{@indexName}", type = "#{@documentType}") @Setting(settingPath = "/elasticsearch/settings.json") @Mapping(mappingPath = "/elasticsearch/mapping.json") public class Documento { + @Id + public Integer id; + @JsonCreator + public Documento(@JsonProperty("id") Integer id) { + super(); + this.id = id; + } + + @JsonProperty("id") + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index dd98db8..445ed0f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,9 +1,13 @@ server.servlet.context-path=/arjion server.port=8080 -elasticsearch.clustername=development +elasticsearch.clustername=elasticsearch elasticsearch.host=localhost elasticsearch.port=9300 elasticsearch.nodename=arjion arjion.indexName=documentos arjion.documentType=documento -spring.main.allow-bean-definition-overriding=true \ No newline at end of file +spring.main.allow-bean-definition-overriding=true +spring.thymeleaf.enabled=true +spring.thymeleaf.prefix=classpath:/templates/ +spring.thymeleaf.suffix=.html +spring.thymeleaf.cache=false \ No newline at end of file diff --git a/src/main/resources/elasticsearch/mapping.json b/src/main/resources/elasticsearch/mapping.json index e69de29..35097cf 100644 --- a/src/main/resources/elasticsearch/mapping.json +++ b/src/main/resources/elasticsearch/mapping.json @@ -0,0 +1,16 @@ +{ + "documento": { + "properties": { + "@timestamp": { + "type": "date", + "format": "strict_date_optional_time||epoch_millis" + }, + "@version": { + "type": "keyword" + }, + "id": { + "type": "long" + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/elasticsearch/settings.json b/src/main/resources/elasticsearch/settings.json index e69de29..d3cc778 100644 --- a/src/main/resources/elasticsearch/settings.json +++ b/src/main/resources/elasticsearch/settings.json @@ -0,0 +1,6 @@ +{ + "index": { + "number_of_shards": "5", + "number_of_replicas": "1" + } +} \ No newline at end of file diff --git a/src/main/resources/templates/error.html b/src/main/resources/templates/error.html new file mode 100644 index 0000000..4b8ef56 --- /dev/null +++ b/src/main/resources/templates/error.html @@ -0,0 +1,10 @@ + + + + +Error + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html new file mode 100644 index 0000000..842f5cd --- /dev/null +++ b/src/main/resources/templates/index.html @@ -0,0 +1,13 @@ + + + + +Arjion + + + + + + + + \ No newline at end of file