-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from FH-Joanneum-Iron-Road-for-Children/develo…
…p-#58-fix-db-and-picture Develop #58 fix db and picture
- Loading branch information
Showing
32 changed files
with
421 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...c/model/event/VotingPartialResultDTO.java → ...PartialResult/VotingPartialResultDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...odel/event/VotingPartialResultMapper.java → ...tialResult/VotingPartialResultMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
import lombok.Setter; | ||
|
||
import javax.persistence.*; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
/** | ||
* @author [email protected] | ||
|
@@ -26,10 +28,10 @@ public class EventEntity { | |
strategy = GenerationType.SEQUENCE, | ||
generator = "event_id_seq" | ||
) | ||
@Column(name = "event_id") | ||
@Column(name = "event_id", nullable = false) | ||
private Long eventId; | ||
|
||
@Column | ||
@Column(nullable = false) | ||
private String title; | ||
|
||
@OneToOne(cascade = CascadeType.ALL) | ||
|
@@ -40,10 +42,10 @@ public class EventEntity { | |
@JoinColumn(name = "fk_picture", referencedColumnName = "picture_id") | ||
private PictureEntity picture; | ||
|
||
@Column(name = "start_date_time_in_utc") | ||
@Column(name = "start_date_time_in_utc", nullable = false) | ||
private long startDateTimeInUTC; | ||
|
||
@Column(name = "end_date_time_in_utc") | ||
@Column(name = "end_date_time_in_utc", nullable = false) | ||
private long endDateTimeInUTC; | ||
|
||
@ManyToOne | ||
|
@@ -54,6 +56,9 @@ public class EventEntity { | |
@JoinColumn(name = "fk_event_category", nullable = false) | ||
private EventCategoryEntity eventCategory; | ||
|
||
//@Column(name = "is_editable") | ||
// private boolean isEditable; //TODO create Task and Implement | ||
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "events") | ||
private Set<VotingEntity> votings = new HashSet<>(); | ||
|
||
@OneToMany(mappedBy = "event") | ||
private Set<VoteEntity> votes; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
import lombok.Setter; | ||
|
||
import javax.persistence.*; | ||
import java.io.Serializable; | ||
|
||
/** | ||
* @author [email protected] | ||
|
@@ -17,12 +18,28 @@ | |
public class VoteEntity { | ||
|
||
@Id | ||
@Column(name = "vote_id") | ||
private Long votingId; | ||
@SequenceGenerator( | ||
name = "vote_id_seq", | ||
sequenceName = "vote_id_seq", | ||
allocationSize = 1 | ||
) | ||
@GeneratedValue( | ||
strategy = GenerationType.SEQUENCE, | ||
generator = "vote_id_seq" | ||
) | ||
@Column(name = "vote_id", nullable = false) | ||
private Long voteId; | ||
|
||
@Column(name = "event_id") | ||
private Long eventId; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "fk_voting", nullable = false) | ||
private VotingEntity voting; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "fk_event", nullable = false) | ||
private EventEntity event; | ||
|
||
@Column(name = "device_id") | ||
private String deviceId; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/at/fh/joanneum/irfc/persistence/repository/VotingRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,24 @@ | ||
package at.fh.joanneum.irfc.persistence.repository; | ||
|
||
import at.fh.joanneum.irfc.persistence.entiy.EventEntity; | ||
import at.fh.joanneum.irfc.persistence.entiy.VotingEntity; | ||
import io.quarkus.hibernate.orm.panache.PanacheRepository; | ||
|
||
import javax.enterprise.context.RequestScoped; | ||
import java.util.Set; | ||
|
||
/** | ||
* @author https://github.com/GoldNova | ||
**/ | ||
@RequestScoped | ||
public class VotingRepository implements PanacheRepository<VotingEntity> { | ||
public boolean containsEventId(VotingEntity voting, Long eventId) { | ||
Set<EventEntity> events = voting.getEvents(); | ||
for (EventEntity event : events) { | ||
if (event.getEventId().equals(eventId)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
package at.fh.joanneum.irfc.rest; | ||
|
||
import at.fh.joanneum.irfc.model.eventInfo.EventInfoDTO; | ||
import at.fh.joanneum.irfc.model.picture.PictureDTO; | ||
import at.fh.joanneum.irfc.service.EventInfoService; | ||
import javax.enterprise.context.RequestScoped; | ||
import javax.inject.Inject; | ||
import javax.ws.rs.*; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
import java.util.List; | ||
|
||
/** | ||
* @author [email protected] | ||
|
@@ -25,6 +27,12 @@ public EventInfoDTO get(@PathParam("id") Long id){ | |
return eventInfoService.get(id); | ||
} | ||
|
||
@GET | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public List<EventInfoDTO> getAll(){ | ||
return eventInfoService.getAll(); | ||
} | ||
|
||
@POST | ||
@Produces(MediaType.APPLICATION_JSON) | ||
@Consumes(MediaType.APPLICATION_JSON) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package at.fh.joanneum.irfc.rest; | ||
|
||
import at.fh.joanneum.irfc.model.event.EventDTO; | ||
import at.fh.joanneum.irfc.model.event.EventMapper; | ||
import at.fh.joanneum.irfc.model.multipartbody.MultipartBody; | ||
import at.fh.joanneum.irfc.model.picture.PictureDTO; | ||
import at.fh.joanneum.irfc.service.PictureService; | ||
|
@@ -11,6 +13,7 @@ | |
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* @author [email protected] | ||
|
@@ -27,21 +30,27 @@ public class PictureApi { | |
public PictureDTO get(@PathParam("id") Long id){ return pictureService.get(id); } | ||
|
||
@GET | ||
@Path("/search/{searchString}") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
@Consumes(MediaType.APPLICATION_JSON) | ||
public List<PictureDTO> getByTitle(@PathParam("searchString") String searchString){ | ||
return pictureService.search(searchString); | ||
public List<PictureDTO> getAll(){ | ||
return pictureService.getAll(); | ||
} | ||
|
||
// @GET | ||
// @Path("/search/{searchString}") | ||
// @Produces(MediaType.APPLICATION_JSON) | ||
// @Consumes(MediaType.APPLICATION_JSON) | ||
// public List<PictureDTO> getByTitle(@PathParam("searchString") String searchString){ | ||
// return pictureService.search(searchString); | ||
// } | ||
|
||
@GET | ||
@Path("rootpath") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String getRootPath(){ | ||
return pictureService.getRootpath(); | ||
} | ||
|
||
//TODO: there will be only MULTIPART as input with file and altText | ||
// there will be only MULTIPART as input with file and altText | ||
// (see: https://quarkus.io/guides/rest-client-multipart) | ||
@POST | ||
@Produces(MediaType.APPLICATION_JSON) | ||
|
Oops, something went wrong.