-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7cdca9
commit 7843ac0
Showing
6 changed files
with
86 additions
and
66 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,12 @@ | |
import com.techlooper.repository.vnw.VnwUserRepo; | ||
import com.techlooper.service.GoogleCalendarService; | ||
import org.dozer.Mapper; | ||
import org.elasticsearch.search.aggregations.AggregationBuilders; | ||
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramBuilder; | ||
import org.elasticsearch.search.facet.datehistogram.DateHistogramFacetBuilder; | ||
import org.joda.time.format.DateTimeFormat; | ||
import org.joda.time.format.DateTimeFormatter; | ||
import org.springframework.integration.annotation.Aggregator; | ||
import org.springframework.stereotype.Service; | ||
|
||
import javax.annotation.Resource; | ||
|
@@ -27,56 +31,56 @@ | |
@Service | ||
public class GoogleCalendarServiceImpl implements GoogleCalendarService { | ||
|
||
@Resource | ||
private WebinarRepository webinarRepository; | ||
@Resource | ||
private WebinarRepository webinarRepository; | ||
|
||
@Resource | ||
private Mapper dozerMapper; | ||
@Resource | ||
private Mapper dozerMapper; | ||
|
||
@Resource | ||
private Calendar googleCalendar; | ||
@Resource | ||
private Calendar googleCalendar; | ||
|
||
@Resource | ||
private VnwUserRepo vnwUserRepo; | ||
@Resource | ||
private VnwUserRepo vnwUserRepo; | ||
|
||
private static final String CALENDAR_ID = "[email protected]"; | ||
private static final String CALENDAR_ID = "[email protected]"; | ||
|
||
public WebinarInfoDto createWebinarInfo(WebinarInfoDto webinarInfoDto, String organiser) throws IOException { | ||
VnwUser vnwUser = vnwUserRepo.findByUsernameIgnoreCase(organiser); | ||
String organiserEmail = vnwUser != null ? vnwUser.getEmail() : organiser; | ||
public WebinarInfoDto createWebinarInfo(WebinarInfoDto webinarInfoDto, String organiser) throws IOException { | ||
VnwUser vnwUser = vnwUserRepo.findByUsernameIgnoreCase(organiser); | ||
String organiserEmail = vnwUser != null ? vnwUser.getEmail() : organiser; | ||
|
||
Event event = new Event() | ||
.setSummary(webinarInfoDto.getName()) | ||
.setDescription(webinarInfoDto.getDescription()); | ||
Event event = new Event() | ||
.setSummary(webinarInfoDto.getName()) | ||
.setDescription(webinarInfoDto.getDescription()); | ||
|
||
DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("dd/MM/yyyy hh:mm a"); | ||
org.joda.time.DateTime startDate = dateTimeFormatter.parseDateTime(webinarInfoDto.getStartDate()); | ||
org.joda.time.DateTime endDate = dateTimeFormatter.parseDateTime(webinarInfoDto.getEndDate()); | ||
event.setStart(new EventDateTime().setDateTime(new DateTime(startDate.toString()))); | ||
event.setEnd(new EventDateTime().setDateTime(new DateTime(endDate.toString()))); | ||
DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("dd/MM/yyyy hh:mm a"); | ||
org.joda.time.DateTime startDate = dateTimeFormatter.parseDateTime(webinarInfoDto.getStartDate()); | ||
org.joda.time.DateTime endDate = dateTimeFormatter.parseDateTime(webinarInfoDto.getEndDate()); | ||
event.setStart(new EventDateTime().setDateTime(new DateTime(startDate.toString()))); | ||
event.setEnd(new EventDateTime().setDateTime(new DateTime(endDate.toString()))); | ||
|
||
webinarInfoDto.getAttendees().add(organiserEmail); | ||
EventAttendee[] attendees = webinarInfoDto.getAttendees().stream() | ||
.map(attEmail -> new EventAttendee().setEmail(attEmail)) | ||
.toArray(EventAttendee[]::new); | ||
webinarInfoDto.getAttendees().add(organiserEmail); | ||
EventAttendee[] attendees = webinarInfoDto.getAttendees().stream() | ||
.map(attEmail -> new EventAttendee().setEmail(attEmail)) | ||
.toArray(EventAttendee[]::new); | ||
|
||
event.setAttendees(Arrays.asList(attendees)); | ||
event.setAttendees(Arrays.asList(attendees)); | ||
|
||
event = googleCalendar.events().insert(CALENDAR_ID, event).setSendNotifications(true).execute(); | ||
event = googleCalendar.events().insert(CALENDAR_ID, event).setSendNotifications(true).execute(); | ||
|
||
WebinarEntity entity = dozerMapper.map(webinarInfoDto, WebinarEntity.class); | ||
entity.setCalendarUrl(event.getHtmlLink()); | ||
entity.setHangoutLink(event.getHangoutLink()); | ||
WebinarEntity entity = dozerMapper.map(webinarInfoDto, WebinarEntity.class); | ||
entity.setCalendarUrl(event.getHtmlLink()); | ||
entity.setHangoutLink(event.getHangoutLink()); | ||
|
||
entity.setOrganiser(organiserEmail); | ||
entity.setOrganiser(organiserEmail); | ||
|
||
entity = webinarRepository.save(entity); | ||
return dozerMapper.map(entity, WebinarInfoDto.class); | ||
} | ||
entity = webinarRepository.save(entity); | ||
return dozerMapper.map(entity, WebinarInfoDto.class); | ||
} | ||
|
||
public Collection<WebinarInfoDto> findNotExpiredWebinars() { | ||
public Collection<WebinarInfoDto> findAvailableWebinars() { | ||
AggregationBuilders.dateHistogram("availableWebinars").field("startDate").format(""); | ||
|
||
|
||
return null; | ||
} | ||
return null; | ||
} | ||
} |
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