Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions Poseiden-skeleton/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
28 changes: 28 additions & 0 deletions Poseiden-skeleton/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Poseiden-skeleton</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.springframework.ide.eclipse.boot.validation.springbootbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
5 changes: 5 additions & 0 deletions Poseiden-skeleton/.settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8
9 changes: 9 additions & 0 deletions Poseiden-skeleton/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
boot.validation.initialized=true
eclipse.preferences.version=1
75 changes: 74 additions & 1 deletion Poseiden-skeleton/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<version>2.5.2</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

Expand Down Expand Up @@ -47,6 +47,11 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
Expand All @@ -60,6 +65,41 @@
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- API, java.xml.bind module -->
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.2</version>
</dependency>

<!-- Runtime, com.sun.xml.bind module -->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.23.1-GA</version>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator-annotation-processor</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
</dependencies>

<build>
Expand All @@ -68,6 +108,39 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>
<configuration>
<excludes>
<exclude>**/*IT.java</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>test</goal>
</goals>
<phase>integration-test</phase>
<configuration>
<excludes>
<exclude>none</exclude>
</excludes>
<includes>
<include>**/*IT.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package Exceptions;


public class AlreadyExistException extends Exception {
/**
*
*/
private static final long serialVersionUID = 7199678130285702283L;

public AlreadyExistException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
@@ -1,55 +1,93 @@
package com.nnk.springboot.controllers;

import com.nnk.springboot.domain.BidList;
import javax.persistence.EntityNotFoundException;
import javax.validation.Valid;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.validation.Valid;
import com.nnk.springboot.domain.BidList;
import com.nnk.springboot.services.BidListService;

import Exceptions.AlreadyExistException;

@Controller
public class BidListController {
// TODO: Inject Bid service

@RequestMapping("/bidList/list")
public String home(Model model)
{
// TODO: call service find all bids to show to the view
return "bidList/list";
}

@GetMapping("/bidList/add")
public String addBidForm(BidList bid) {
return "bidList/add";
}

@PostMapping("/bidList/validate")
public String validate(@Valid BidList bid, BindingResult result, Model model) {
// TODO: check data valid and save to db, after saving return bid list
return "bidList/add";
}

@GetMapping("/bidList/update/{id}")
public String showUpdateForm(@PathVariable("id") Integer id, Model model) {
// TODO: get Bid by Id and to model then show to the form
return "bidList/update";
}

@PostMapping("/bidList/update/{id}")
public String updateBid(@PathVariable("id") Integer id, @Valid BidList bidList,
BindingResult result, Model model) {
// TODO: check required fields, if valid call service to update Bid and return list Bid
return "redirect:/bidList/list";
}

@GetMapping("/bidList/delete/{id}")
public String deleteBid(@PathVariable("id") Integer id, Model model) {
// TODO: Find Bid by Id and delete the bid, return to Bid list
return "redirect:/bidList/list";
}

@Autowired
private BidListService bidListService;

private static final Logger LOGGER = LoggerFactory.getLogger(BidListController.class);

@RequestMapping("/bidList/list")
public String home(Model model) {
model.addAttribute("bidLists", bidListService.findAll());
LOGGER.info("BidLists List");
return "bidList/list";
}

@GetMapping("/bidList/add")
public String addBidForm(Model model) {
model.addAttribute("bidList", new BidList());
LOGGER.info("BidList add form");
return "bidList/add";
}

@PostMapping("/bidList/validate")
public String validate(@Valid @ModelAttribute("bidList") BidList bid, BindingResult result, Model model) {
if (result.hasErrors()) {
LOGGER.debug("Invalid fields provided");
return "bidList/add";
} else {
try {
bidListService.createBidList(bid);
LOGGER.info("Bidlist added");
} catch (AlreadyExistException e) {
model.addAttribute("message", e.getMessage());
LOGGER.error("This bidlist already exists");
}
return "redirect:/bidList/list";
}
}

@GetMapping("/bidList/update/{id}")
public String showUpdateForm(@PathVariable("id") Integer id, Model model) {
BidList bidList = bidListService.findById(id);
LOGGER.info("Bidlist to update found");
model.addAttribute("bidList", bidList);
return "bidList/update";
}

@PostMapping("/bidList/update/{id}")
public String updateBid(@PathVariable("id") Integer id, @Valid BidList bidList, BindingResult result, Model model) {
if (result.hasErrors()) {
LOGGER.debug("Invalid fields provided");
return "bidList/update";
} else {
try {
bidListService.updateBidList(bidList, id);
LOGGER.info("Bidlist updated");
} catch (EntityNotFoundException e) {
model.addAttribute("message", e.getMessage());
LOGGER.error("This bidlist doesn't exist");
}
return "redirect:/bidList/list";
}
}

@GetMapping("/bidList/delete/{id}")
public String deleteBid(@PathVariable("id") Integer id, Model model) {
LOGGER.info("Deleting Bidlist with id:" + id);
bidListService.deleteById(id);
return "redirect:/bidList/list";
}
}
Loading