Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
tktong committed Dec 12, 2015
1 parent fa9f010 commit 331b222
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 1 deletion.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ext {
aspectjVersion = '1.8.7'
commonsVersion = '1.3.1'
guavaVersion = '19.0-rc2'
hibernateVersion = '5.0.5.Final'
jacksonVersion = '2.6.3'
jadiraVersion = '4.0.0.GA'
jodaTimeVersion = '2.9'
Expand All @@ -42,6 +43,7 @@ ext {
powerMockVersion = '1.6.3'
springVersion = '4.2.2.RELEASE'
springBootVersion = '1.3.0.RELEASE'
springJpaVersion = '1.9.1.RELEASE'
springSecurityVersion = '4.0.3.RELEASE'
thymeleafVersion = '2.1.2.RELEASE'
thymeleafLayoutVersion = '1.2.8'
Expand Down
2 changes: 1 addition & 1 deletion core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ dependencies {
compile "org.springframework:spring-webmvc:$springVersion"
compile "org.springframework.boot:spring-boot-starter-security:$springBootVersion"
compile "org.thymeleaf:thymeleaf-spring4:$thymeleafVersion"

compile project(":utilities")
}
26 changes: 26 additions & 0 deletions core/src/main/java/org/dcsc/core/event/Event.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.dcsc.core.event;

import org.dcsc.utilities.converter.LocalDateTimeConverter;
import org.dcsc.utilities.image.Image;

import javax.persistence.*;
import java.sql.Date;
import java.sql.Time;
import java.time.LocalDateTime;

@Entity
@Table(name = "dcsc_events", schema = "public")
Expand All @@ -29,6 +31,14 @@ public class Event {
@Column(name = "endtime")
private Time endTime;

@Column(name = "start_date_time")
@Convert(converter = LocalDateTimeConverter.class)
private LocalDateTime startDateTime;

@Column(name = "end_date_time")
@Convert(converter = LocalDateTimeConverter.class)
private LocalDateTime endDateTime;

@Column(name = "location")
private String location;

Expand Down Expand Up @@ -144,4 +154,20 @@ public boolean isPublished() {
public void setPublished(boolean published) {
this.published = published;
}

public LocalDateTime getStartDateTime() {
return startDateTime;
}

public void setStartDateTime(LocalDateTime startDateTime) {
this.startDateTime = startDateTime;
}

public LocalDateTime getEndDateTime() {
return endDateTime;
}

public void setEndDateTime(LocalDateTime endDateTime) {
this.endDateTime = endDateTime;
}
}
1 change: 1 addition & 0 deletions core/src/main/java/org/dcsc/core/event/EventService.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public Optional<Event> getEventById(long id) {
return eventRepository.findEventById(id);
}


@Transactional(readOnly = true)
public Page<Event> getPagedEvents(int index, int size) {
PageRequest request = new PageRequest(index, size, Sort.Direction.DESC, EVENT_DATE_COLUMN_LABEL, EVENT_START_TIME_COLUMN_LABEL);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.dcsc.utilities.converter;

import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import java.sql.Timestamp;
import java.time.LocalDateTime;

@Converter(autoApply = true)
public class LocalDateTimeConverter implements AttributeConverter<LocalDateTime, Timestamp> {
@Override
public Timestamp convertToDatabaseColumn(LocalDateTime attribute) {
return Timestamp.valueOf(attribute);
}

@Override
public LocalDateTime convertToEntityAttribute(Timestamp dbData) {
if (dbData == null) {
return null;
}

return dbData.toLocalDateTime();
}
}

0 comments on commit 331b222

Please sign in to comment.