Skip to content

Commit

Permalink
Cambio para SQL, arreglo de fallos
Browse files Browse the repository at this point in the history
  • Loading branch information
vicsmr committed Jun 28, 2016
1 parent 619c155 commit 36b7fbc
Show file tree
Hide file tree
Showing 17 changed files with 49 additions and 190 deletions.
5 changes: 0 additions & 5 deletions security_ejem1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ public class MatchController {
private MatchRepository repository;

@RequestMapping(value = "/", method = RequestMethod.GET)
public List<Match> getMatches() {
public List<MatchX> getMatches() {
return repository.findAll();
}

@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public ResponseEntity<Match> getMatch(@PathVariable long id) {
public ResponseEntity<MatchX> getMatch(@PathVariable long id) {

log.info("Get player {}", id);

Match match = repository.findOne(id);
MatchX match = repository.findOne(id);
if (match != null) {
return new ResponseEntity<>(match, HttpStatus.OK);
} else {
Expand All @@ -44,16 +44,16 @@ public ResponseEntity<Match> getMatch(@PathVariable long id) {

@RequestMapping(value = "/", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
public Match newMatch(@RequestBody Match match) {
public MatchX newMatch(@RequestBody MatchX match) {

repository.save(match);
return match;
}

@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
public ResponseEntity<Match> updateMatch(@PathVariable long id, @RequestBody Match updatedMatch) {
public ResponseEntity<MatchX> updateMatch(@PathVariable long id, @RequestBody MatchX updatedMatch) {

Match match = repository.findOne(id);
MatchX match = repository.findOne(id);
if (match != null) {

updatedMatch.setId(id);
Expand All @@ -66,7 +66,7 @@ public ResponseEntity<Match> updateMatch(@PathVariable long id, @RequestBody Mat
}

@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public ResponseEntity<Match> deleteMatch(@PathVariable long id) {
public ResponseEntity<MatchX> deleteMatch(@PathVariable long id) {

if (repository.exists(id)) {
repository.delete(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

import org.springframework.data.jpa.repository.JpaRepository;

public interface MatchRepository extends JpaRepository<Match, Long> {
public interface MatchRepository extends JpaRepository<MatchX, Long> {

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,38 @@
import es.urjc.code.daw.library.team.Team;

@Entity
public class Match {
public class MatchX {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;

private String date;

@OneToOne(cascade={CascadeType.DETACH,CascadeType.MERGE,CascadeType.PERSIST,CascadeType.REFRESH})
@OneToOne
//@OneToOne(cascade=CascadeType.ALL)
private Schedule schedule;

@OneToOne(cascade={CascadeType.DETACH,CascadeType.MERGE,CascadeType.PERSIST,CascadeType.REFRESH})
@OneToOne
//@OneToOne(cascade=CascadeType.ALL)
private Team local;

@OneToOne(cascade={CascadeType.DETACH,CascadeType.MERGE,CascadeType.PERSIST,CascadeType.REFRESH})
@OneToOne
//@OneToOne(cascade=CascadeType.ALL)
private Team visitor;

private int resultLocal;
private int resultVisitor;

public Match() {
public MatchX() {
//super();
}



public Match(long id, String date, Schedule schedule, Team local, Team visitor, int resultLocal,
public MatchX(String date, Schedule schedule, Team local, Team visitor, int resultLocal,
int resultVisitor) {
super();
this.id = id;
this.date = date;
this.schedule = schedule;
this.local = local;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class News {
private String subtitle;
private String author;

@Column(length = 50000)
@Column(length = 20000)
private String description;
private String imgnews;

Expand Down Expand Up @@ -87,6 +87,17 @@ public void setImgnews(String imgnews) {
this.imgnews = imgnews;
}



public User getUser() {
return user;
}


public void setUser(User user) {
this.user = user;
}


@Override
public String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public interface TeamAtt {}
@JsonView(BasicAtt.class)
private String name;
@JsonView(BasicAtt.class)
@Column(length = 50000)
@Column(length = 20000)
private String biography;

//@ManyToOne(cascade=CascadeType.ALL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Controller;

import es.urjc.code.daw.library.match.MatchX;
import es.urjc.code.daw.library.match.MatchRepository;
import es.urjc.code.daw.library.news.News;
import es.urjc.code.daw.library.news.NewsRepository;
import es.urjc.code.daw.library.player.Player;
Expand Down Expand Up @@ -37,6 +39,9 @@ public class DatabaseInitializer implements CommandLineRunner {
@Autowired
private ScheduleRepository scheduleRepository;

@Autowired
private MatchRepository matchRepository;

@Autowired
private PrincipalRepository principalRepository;

Expand Down Expand Up @@ -70,8 +75,10 @@ public void run(String... args) throws Exception {
playerRepository.save(p2);

// Sample Schedules
Schedule sche = new Schedule();
scheduleRepository.save(sche);

scheduleRepository.save(new Schedule());
MatchX match = new MatchX("23", sche, madrid, valencia, 1, 0);



Expand All @@ -90,17 +97,20 @@ public void run(String... args) throws Exception {


// Sample users

userRepository.save(new User("user", "pass", "ROLE_USER"));

User usuario = new User("user", "pass", "ROLE_USER");
userRepository.save(usuario);
userRepository.save(new User("admin", "pass", "ROLE_USER", "ROLE_ADMIN"));

//Sample News
newsRepository.save(new News("Paul Pogba signs for Real Madrid",
News newes = new News("Paul Pogba signs for Real Madrid",
"Juventus announces that accepts the offer from Real Madrid for Paul Pogba. Juventus receives 80 million dollars in exchange for the player",
"Álvaro Parras Gomez",
"The french player Paul Pogba has signed a 5-year contract with Real Madrid. Juventus gets 80 million in exchange for the player. The player said in a Spanish television: 'I will live a dream I had since childhood'. Paul Labile Pogba (born 15 March 1993) is a French professional footballer who plays for France National Team. He operates primarily as a central midfielder and is comfortable at playing both in attack and defence. In Italy, he gained the nicknames Il Polpo Paul ('Paul the Octopus') for his long legs that look like tentacles during tackling or running and 'Pogboom' for his explosive style and energy on the pitch. He received the Golden Boy award for 2013, given to the best under-21 player in Europe, followed by the Bravo Award in 2014, awarded to the best under-23 player who has participated in European competitions.",
"app/img/Players/PogbaNewsReal.jpeg"));
"app/img/Players/PogbaNewsReal.jpeg");

newes.setUser(usuario);
newsRepository.save(newes);
principalRepository.save(new Principal(1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 1, 1));


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ public interface PlayersAtt {}
public String coach;

@JsonView(BasicAtt.class)
@Column(length = 50000)
@Column(length = 10000)
public String description;

@JsonView(BasicAtt.class)
@Column(length = 50000)
@Column(length = 10000)
public String history;

@JsonView(BasicAtt.class)
Expand Down
7 changes: 4 additions & 3 deletions security_ejem1/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
spring.datasource.url=jdbc:mysql://localhost/majorleaguefootball
spring.datasource.url=jdbc:mysql://localhost/majorleague
spring.datasource.username=root
spring.datasource.password=amuntRealMadrid
spring.datasource.password=pass
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.jpa.hibernate.ddl-auto: update
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.show-sql=true
server.port=8443
server.ssl.key-store=classpath:keystore.p12
server.ssl.key-store-password=tomcat
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Generated by Maven Integration for Eclipse
#Mon Jun 27 14:09:05 CEST 2016
#Tue Jun 28 16:06:52 CEST 2016
version=0.1.0
groupId=es.sidelab
m2e.projectName=Probamos
Expand Down
Loading

0 comments on commit 36b7fbc

Please sign in to comment.