com.google.api.services.calendar.model.Calendar Java Examples

The following examples show how to use com.google.api.services.calendar.model.Calendar. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GoogleCalendarResource.java    From camel-quarkus with Apache License 2.0 6 votes vote down vote up
@Path("/read")
@GET
@Produces(MediaType.TEXT_PLAIN)
public Response readCalendar(@QueryParam("calendarId") String calendarId) {
    try {
        Calendar response = producerTemplate.requestBody("google-calendar://calendars/get?inBody=calendarId", calendarId,
                Calendar.class);
        if (response != null) {
            return Response.ok(response.getSummary()).build();
        } else {
            return Response.status(Response.Status.NOT_FOUND).build();
        }
    } catch (CamelExecutionException e) {
        Exception exchangeException = e.getExchange().getException();
        if (exchangeException != null && exchangeException.getCause() instanceof GoogleJsonResponseException) {
            GoogleJsonResponseException originalException = (GoogleJsonResponseException) exchangeException.getCause();
            return Response.status(originalException.getStatusCode()).build();
        }
        throw e;
    }
}
 
Example #2
Source File: AddCalendarWorkitemHandler.java    From jbpm-work-items with Apache License 2.0 6 votes vote down vote up
public void executeWorkItem(WorkItem workItem,
                            WorkItemManager workItemManager) {
    Map<String, Object> results = new HashMap<String, Object>();

    String paramCalendarSummary = (String) workItem.getParameter("CalendarSummary");

    try {

        RequiredParameterValidator.validate(this.getClass(),
                                            workItem);

        com.google.api.services.calendar.Calendar client = auth.getAuthorizedCalendar(appName,
                                                                                      clientSecret);

        results.put(RESULTS_CALENDAR,
                    addCalendar(client,
                                paramCalendarSummary));

        workItemManager.completeWorkItem(workItem.getId(),
                                         results);
    } catch (Exception e) {
        handleException(e);
    }
}
 
Example #3
Source File: CalendarMessageFormatter.java    From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static Consumer<EmbedCreateSpec> getCalendarLinkEmbed(Calendar cal, GuildSettings settings) {
	return spec -> {
		Guild guild = DisCalClient.getClient().getGuildById(settings.getGuildID()).block();

		if (settings.isBranded() && guild != null)
			spec.setAuthor(guild.getName(), GlobalConst.discalSite, guild.getIconUrl(Image.Format.PNG).orElse(GlobalConst.iconUrl));
		else
			spec.setAuthor("DisCal", GlobalConst.discalSite, GlobalConst.iconUrl);

		spec.setTitle(MessageManager.getMessage("Embed.Calendar.Link.Title", settings));

		if (cal.getSummary() != null)
			spec.addField(MessageManager.getMessage("Embed.Calendar.Link.Summary", settings), cal.getSummary(), true);

		if (cal.getDescription() != null)
			spec.addField(MessageManager.getMessage("Embed.Calendar.Link.Description", settings), cal.getDescription(), true);

		spec.addField(MessageManager.getMessage("Embed.Calendar.Link.TimeZone", settings), cal.getTimeZone(), false);
		spec.setUrl(CalendarMessageFormatter.getCalendarLink(settings.getGuildID()));
		spec.setFooter(MessageManager.getMessage("Embed.Calendar.Link.CalendarId", "%id%", cal.getId(), settings), null);
		spec.setColor(GlobalConst.discalColor);
	};
}
 
Example #4
Source File: LinkCalendarCommand.java    From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Issues the command this Object is responsible for.
 *
 * @param args  The command arguments.
 * @param event The event received.
 * @return <code>true</code> if successful, else <code>false</code>.
 */
@Override
public boolean issueCommand(String[] args, MessageCreateEvent event, GuildSettings settings) {
	try {
		//TODO: Handle multiple calendars...
		CalendarData data = DatabaseManager.getManager().getMainCalendar(event.getGuild().block().getId());

		if (data.getCalendarAddress().equalsIgnoreCase("primary")) {
			//Does not have a calendar.
			MessageManager.sendMessageAsync(MessageManager.getMessage("Creator.Calendar.NoCalendar", settings), event);
		} else {
			Calendar cal = CalendarAuth.getCalendarService(settings).calendars().get(data.getCalendarAddress()).execute();

			MessageManager.sendMessageAsync(CalendarMessageFormatter.getCalendarLinkEmbed(cal, settings), event);
		}
	} catch (Exception e) {
		Logger.getLogger().exception(event.getMember().get(), "Failed to connect to Google Cal.", e, true, this.getClass());
		MessageManager.sendMessageAsync(MessageManager.getMessage("Notification.Error.Unknown", settings), event);
	}
	return false;
}
 
Example #5
Source File: LinkCalendarCommand.java    From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Issues the command this Object is responsible for.
 *
 * @param args  The command arguments.
 * @param event The event received.
 * @return <code>true</code> if successful, else <code>false</code>.
 */
@Override
public boolean issueCommand(String[] args, MessageCreateEvent event, GuildSettings settings) {
	try {
		//TODO: Handle multiple calendars...
		CalendarData data = DatabaseManager.getManager().getMainCalendar(event.getGuild().block().getId());

		if (data.getCalendarAddress().equalsIgnoreCase("primary")) {
			//Does not have a calendar.
			MessageManager.sendMessageAsync(MessageManager.getMessage("Creator.Calendar.NoCalendar", settings), event);
		} else {
			Calendar cal = CalendarAuth.getCalendarService(settings).calendars().get(data.getCalendarAddress()).execute();

			MessageManager.sendMessageAsync(CalendarMessageFormatter.getCalendarLinkEmbed(cal, settings), event);
		}
	} catch (Exception e) {
		Logger.getLogger().exception(event.getMember().get(), "Failed to connect to Google Cal.", e, true, this.getClass());
		MessageManager.sendMessageAsync(MessageManager.getMessage("Notification.Error.Unknown", settings), event);
	}
	return false;
}
 
Example #6
Source File: CalendarMessageFormatter.java    From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static Consumer<EmbedCreateSpec> getCalendarLinkEmbed(Calendar cal, GuildSettings settings) {
	return spec -> {
		Guild guild = DisCalClient.getClient().getGuildById(settings.getGuildID()).block();

		if (settings.isBranded() && guild != null)
			spec.setAuthor(guild.getName(), GlobalConst.discalSite, guild.getIconUrl(Image.Format.PNG).orElse(GlobalConst.iconUrl));
		else
			spec.setAuthor("DisCal", GlobalConst.discalSite, GlobalConst.iconUrl);

		spec.setTitle(MessageManager.getMessage("Embed.Calendar.Link.Title", settings));

		if (cal.getSummary() != null)
			spec.addField(MessageManager.getMessage("Embed.Calendar.Link.Summary", settings), cal.getSummary(), true);

		if (cal.getDescription() != null)
			spec.addField(MessageManager.getMessage("Embed.Calendar.Link.Description", settings), cal.getDescription(), true);

		spec.addField(MessageManager.getMessage("Embed.Calendar.Link.TimeZone", settings), cal.getTimeZone(), false);
		spec.setUrl(CalendarMessageFormatter.getCalendarLink(settings.getGuildID()));
		spec.setFooter(MessageManager.getMessage("Embed.Calendar.Link.CalendarId", "%id%", cal.getId(), settings), null);
		spec.setColor(GlobalConst.discalColor);
	};
}
 
Example #7
Source File: GoogleCalendarIntegrationTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
private static Calendar createTestCalendar(ProducerTemplate template, String testId) {
    Calendar calendar = new Calendar();

    calendar.setSummary(testId + UUID.randomUUID().toString());
    calendar.setTimeZone("America/St_Johns");

    return template.requestBody("google-calendar://calendars/insert?inBody=content", calendar, Calendar.class);
}
 
Example #8
Source File: GoogleCalendarResource.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
@Path("/create")
@POST
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
public Response createCalendar(String summary) throws Exception {
    Calendar calendar = new Calendar();
    calendar.setSummary(summary);
    calendar.setTimeZone("Europe/London");
    Calendar response = producerTemplate.requestBody("google-calendar://calendars/insert?inBody=content", calendar,
            Calendar.class);
    return Response
            .created(new URI("https://camel.apache.org/"))
            .entity(response.getId())
            .build();
}
 
Example #9
Source File: WebCalendar.java    From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 5 votes vote down vote up
public WebCalendar fromCalendar(CalendarData cd, GuildSettings gs) {
	if (cd.getCalendarAddress().equalsIgnoreCase("primary")) {
		id = "primary";
		address = "primary";
		link = "N/a";
		name = "N/a";
		description = "N/a";
		timezone = "N/a";
	} else {
		id = cd.getCalendarId();
		address = cd.getCalendarAddress();
		link = "https://www.discalbot.com/embed/calendar/" + gs.getGuildID().asString();
		external = cd.isExternal();
		try {
			Calendar cal = CalendarAuth.getCalendarService(gs).calendars().get(id).execute();
			name = cal.getSummary();
			description = cal.getDescription();
			timezone = cal.getTimeZone().replaceAll("/", "___");
		} catch (Exception e) {
			Logger.getLogger().exception(null, "[WEB] Failed to get calendar!", e, true, this.getClass());
			name = "ERROR!";
			description = "ERROR";
			timezone = "ERROR";
		}
	}
	return this;
}
 
Example #10
Source File: WebCalendar.java    From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 5 votes vote down vote up
public WebCalendar fromCalendar(CalendarData cd, GuildSettings gs) {
	if (cd.getCalendarAddress().equalsIgnoreCase("primary")) {
		id = "primary";
		address = "primary";
		link = "N/a";
		name = "N/a";
		description = "N/a";
		timezone = "N/a";
	} else {
		id = cd.getCalendarId();
		address = cd.getCalendarAddress();
		link = "https://www.discalbot.com/embed/calendar/" + gs.getGuildID().asString();
		external = cd.isExternal();
		try {
			Calendar cal = CalendarAuth.getCalendarService(gs).calendars().get(id).execute();
			name = cal.getSummary();
			description = cal.getDescription();
			timezone = cal.getTimeZone().replaceAll("/", "___");
		} catch (Exception e) {
			Logger.getLogger().exception(null, "[WEB] Failed to get calendar!", e, true, this.getClass());
			name = "ERROR!";
			description = "ERROR";
			timezone = "ERROR";
		}
	}
	return this;
}
 
Example #11
Source File: PreEvent.java    From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 4 votes vote down vote up
public PreEvent(Snowflake _guildId, Event e) {
	guildId = _guildId;
	eventId = e.getId();

	color = EventColor.fromNameOrHexOrID(e.getColorId());

	recurrence = new Recurrence();

	if (e.getRecurrence() != null && e.getRecurrence().size() > 0) {
		recur = true;
		recurrence.fromRRule(e.getRecurrence().get(0));
	}

	if (e.getSummary() != null)
		summary = e.getSummary();

	if (e.getDescription() != null)
		description = e.getDescription();

	if (e.getLocation() != null)
		location = e.getLocation();


	startDateTime = e.getStart();
	endDateTime = e.getEnd();

	//Here is where I need to fix the display times
	GuildSettings settings = DatabaseManager.getManager().getSettings(guildId);
	//TODO: Support multiple calendars
	CalendarData data = DatabaseManager.getManager().getMainCalendar(guildId);

	Calendar cal = null;
	try {
		cal = CalendarAuth.getCalendarService(settings).calendars().get(data.getCalendarAddress()).execute();
	} catch (Exception ex) {
		Logger.getLogger().exception(null, "Failed to get proper date time for event!", ex, true, this.getClass());
	}

	if (cal != null) {

		//Check if either DateTime or just Date...
		if (e.getStart().getDateTime() != null) {
			//DateTime
			viewableStartDate = new EventDateTime().setDateTime(new DateTime(TimeUtils.applyTimeZoneOffset(e.getStart().getDateTime().getValue(), cal.getTimeZone())));
			viewableEndDate = new EventDateTime().setDateTime(new DateTime(TimeUtils.applyTimeZoneOffset(e.getEnd().getDateTime().getValue(), cal.getTimeZone())));
		} else {
			//Just Date
			viewableStartDate = new EventDateTime().setDate(new DateTime(TimeUtils.applyTimeZoneOffset(e.getStart().getDate().getValue(), cal.getTimeZone())));
			viewableEndDate = new EventDateTime().setDate(new DateTime(TimeUtils.applyTimeZoneOffset(e.getEnd().getDate().getValue(), cal.getTimeZone())));
		}
	} else {
		//Almost definitely not correct, but we need something displayed here.
		viewableStartDate = e.getStart();
		viewableEndDate = e.getEnd();
	}

	eventData = DatabaseManager.getManager().getEventData(guildId, e.getId());

	editing = false;
	lastEdit = System.currentTimeMillis();
}
 
Example #12
Source File: DashboardHandler.java    From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 4 votes vote down vote up
@PostMapping(value = "/create/calendar")
public static String handleCalendarCreate(HttpServletRequest request, HttpServletResponse response, @RequestParam Map<String, String> queryParams) {
	try {
		String name = queryParams.get("cal-name");
		String desc = queryParams.get("cal-desc");
		String tz = queryParams.get("cal-tz");

		Map m = DiscordAccountHandler.getHandler().getAccount(request);
		WebGuild g = (WebGuild) m.get("selected");

		if (g.isDiscalRole()) {
			Calendar calendar = new Calendar();
			calendar.setSummary(name);
			calendar.setDescription(desc);
			calendar.setTimeZone(tz.replace("___", "/"));
			try {
				com.google.api.services.calendar.Calendar service = CalendarAuth.getCalendarService(g.getSettings());

				Calendar confirmed = service.calendars().insert(calendar).execute();
				AclRule rule = new AclRule();
				AclRule.Scope scope = new AclRule.Scope();
				scope.setType("default");
				rule.setScope(scope).setRole("reader");
				service.acl().insert(confirmed.getId(), rule).execute();
				CalendarData calendarData = new CalendarData(Snowflake.of(g.getId()), 1);
				calendarData.setCalendarId(confirmed.getId());
				calendarData.setCalendarAddress(confirmed.getId());
				DatabaseManager.getManager().updateCalendar(calendarData);

				//Refresh to display correct info...
				g.setCalendar(new WebCalendar().fromCalendar(calendarData, g.getSettings()));
			} catch (Exception ex) {
				Logger.getLogger().exception(null, "[WEB] Failed to confirm calendar.", ex, true, DashboardHandler.class);
			}
		}
		//Finally redirect back to the dashboard
		response.sendRedirect("/dashboard/guild/calendar");
		return "redirect:/dashboard/guild/calendar";
	} catch (Exception e) {
		Logger.getLogger().exception(null, "[WEB] Calendar create failed!", e, true, DashboardHandler.class);

		response.setContentType("application/json");
		response.setStatus(500);
		return ResponseUtils.getJsonResponseMessage("Internal Server Error");
	}
}
 
Example #13
Source File: TimeCommand.java    From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void calendarTime(MessageCreateEvent event, GuildSettings settings) {
	try {
		//TODO: Handle multiple calendars...
		CalendarData data = DatabaseManager.getManager().getMainCalendar(event.getGuild().block().getId());

		if (data.getCalendarAddress().equalsIgnoreCase("primary")) {
			//Does not have a calendar.
			MessageManager.sendMessageAsync(MessageManager.getMessage("Creator.Calendar.NoCalendar", settings), event);
		} else {
			Calendar cal = CalendarAuth.getCalendarService(settings).calendars().get(data.getCalendarAddress()).execute();

			LocalDateTime ldt = LocalDateTime.now(ZoneId.of(cal.getTimeZone()));

			//Okay... format and then we can go from there...
			DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy/MM/dd hh:mm:ss a");
			String thisIsTheCorrectTime = format.format(ldt);

			//Build embed and send.
			Consumer<EmbedCreateSpec> embed = spec -> {
				Guild guild = event.getGuild().block();

				if (settings.isBranded() && guild != null)
					spec.setAuthor(guild.getName(), GlobalConst.discalSite, guild.getIconUrl(Image.Format.PNG).orElse(GlobalConst.iconUrl));
				else
					spec.setAuthor("DisCal", GlobalConst.discalSite, GlobalConst.iconUrl);

				spec.setTitle(MessageManager.getMessage("Embed.Time.Title", settings));
				spec.addField(MessageManager.getMessage("Embed.Time.Time", settings), thisIsTheCorrectTime, false);
				spec.addField(MessageManager.getMessage("Embed.Time.TimeZone", settings), cal.getTimeZone(), false);

				spec.setFooter(MessageManager.getMessage("Embed.Time.Footer", settings), null);
				spec.setUrl(CalendarMessageFormatter.getCalendarLink(settings.getGuildID()));
				spec.setColor(GlobalConst.discalColor);
			};
			MessageManager.sendMessageAsync(embed, event);
		}
	} catch (Exception e) {
		Logger.getLogger().exception(event.getMember().get(), "Failed to connect to Google Cal.", e, true, this.getClass());
		MessageManager.sendMessageAsync(MessageManager.getMessage("Notification.Error.Unknown", settings), event);
	}
}
 
Example #14
Source File: DashboardHandler.java    From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 4 votes vote down vote up
@PostMapping(value = "/create/calendar")
public static String handleCalendarCreate(HttpServletRequest request, HttpServletResponse response, @RequestParam Map<String, String> queryParams) {
	try {
		String name = queryParams.get("cal-name");
		String desc = queryParams.get("cal-desc");
		String tz = queryParams.get("cal-tz");

		Map m = DiscordAccountHandler.getHandler().getAccount(request);
		WebGuild g = (WebGuild) m.get("selected");

		if (g.isDiscalRole()) {
			Calendar calendar = new Calendar();
			calendar.setSummary(name);
			calendar.setDescription(desc);
			calendar.setTimeZone(tz.replace("___", "/"));
			try {
				com.google.api.services.calendar.Calendar service = CalendarAuth.getCalendarService(g.getSettings());

				Calendar confirmed = service.calendars().insert(calendar).execute();
				AclRule rule = new AclRule();
				AclRule.Scope scope = new AclRule.Scope();
				scope.setType("default");
				rule.setScope(scope).setRole("reader");
				service.acl().insert(confirmed.getId(), rule).execute();
				CalendarData calendarData = new CalendarData(Snowflake.of(g.getId()), 1);
				calendarData.setCalendarId(confirmed.getId());
				calendarData.setCalendarAddress(confirmed.getId());
				DatabaseManager.getManager().updateCalendar(calendarData);

				//Refresh to display correct info...
				g.setCalendar(new WebCalendar().fromCalendar(calendarData, g.getSettings()));
			} catch (Exception ex) {
				Logger.getLogger().exception(null, "[WEB] Failed to confirm calendar.", ex, true, DashboardHandler.class);
			}
		}
		//Finally redirect back to the dashboard
		response.sendRedirect("/dashboard/guild/calendar");
		return "redirect:/dashboard/guild/calendar";
	} catch (Exception e) {
		Logger.getLogger().exception(null, "[WEB] Calendar create failed!", e, true, DashboardHandler.class);

		response.setContentType("application/json");
		response.setStatus(500);
		return ResponseUtils.getJsonResponseMessage("Internal Server Error");
	}
}
 
Example #15
Source File: TimeCommand.java    From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void calendarTime(MessageCreateEvent event, GuildSettings settings) {
	try {
		//TODO: Handle multiple calendars...
		CalendarData data = DatabaseManager.getManager().getMainCalendar(event.getGuild().block().getId());

		if (data.getCalendarAddress().equalsIgnoreCase("primary")) {
			//Does not have a calendar.
			MessageManager.sendMessageAsync(MessageManager.getMessage("Creator.Calendar.NoCalendar", settings), event);
		} else {
			Calendar cal = CalendarAuth.getCalendarService(settings).calendars().get(data.getCalendarAddress()).execute();

			LocalDateTime ldt = LocalDateTime.now(ZoneId.of(cal.getTimeZone()));

			//Okay... format and then we can go from there...
			DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy/MM/dd hh:mm:ss a");
			String thisIsTheCorrectTime = format.format(ldt);

			//Build embed and send.
			Consumer<EmbedCreateSpec> embed = spec -> {
				Guild guild = event.getGuild().block();

				if (settings.isBranded() && guild != null)
					spec.setAuthor(guild.getName(), GlobalConst.discalSite, guild.getIconUrl(Image.Format.PNG).orElse(GlobalConst.iconUrl));
				else
					spec.setAuthor("DisCal", GlobalConst.discalSite, GlobalConst.iconUrl);

				spec.setTitle(MessageManager.getMessage("Embed.Time.Title", settings));
				spec.addField(MessageManager.getMessage("Embed.Time.Time", settings), thisIsTheCorrectTime, false);
				spec.addField(MessageManager.getMessage("Embed.Time.TimeZone", settings), cal.getTimeZone(), false);

				spec.setFooter(MessageManager.getMessage("Embed.Time.Footer", settings), null);
				spec.setUrl(CalendarMessageFormatter.getCalendarLink(settings.getGuildID()));
				spec.setColor(GlobalConst.discalColor);
			};
			MessageManager.sendMessageAsync(embed, event);
		}
	} catch (Exception e) {
		Logger.getLogger().exception(event.getMember().get(), "Failed to connect to Google Cal.", e, true, this.getClass());
		MessageManager.sendMessageAsync(MessageManager.getMessage("Notification.Error.Unknown", settings), event);
	}
}
 
Example #16
Source File: PreEvent.java    From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 4 votes vote down vote up
public PreEvent(Snowflake _guildId, Event e) {
	guildId = _guildId;
	eventId = e.getId();

	color = EventColor.fromNameOrHexOrID(e.getColorId());

	recurrence = new Recurrence();

	if (e.getRecurrence() != null && e.getRecurrence().size() > 0) {
		recur = true;
		recurrence.fromRRule(e.getRecurrence().get(0));
	}

	if (e.getSummary() != null)
		summary = e.getSummary();

	if (e.getDescription() != null)
		description = e.getDescription();

	if (e.getLocation() != null)
		location = e.getLocation();


	startDateTime = e.getStart();
	endDateTime = e.getEnd();

	//Here is where I need to fix the display times
	GuildSettings settings = DatabaseManager.getManager().getSettings(guildId);
	//TODO: Support multiple calendars
	CalendarData data = DatabaseManager.getManager().getMainCalendar(guildId);

	Calendar cal = null;
	try {
		cal = CalendarAuth.getCalendarService(settings).calendars().get(data.getCalendarAddress()).execute();
	} catch (Exception ex) {
		Logger.getLogger().exception(null, "Failed to get proper date time for event!", ex, true, this.getClass());
	}

	if (cal != null) {

		//Check if either DateTime or just Date...
		if (e.getStart().getDateTime() != null) {
			//DateTime
			viewableStartDate = new EventDateTime().setDateTime(new DateTime(TimeUtils.applyTimeZoneOffset(e.getStart().getDateTime().getValue(), cal.getTimeZone())));
			viewableEndDate = new EventDateTime().setDateTime(new DateTime(TimeUtils.applyTimeZoneOffset(e.getEnd().getDateTime().getValue(), cal.getTimeZone())));
		} else {
			//Just Date
			viewableStartDate = new EventDateTime().setDate(new DateTime(TimeUtils.applyTimeZoneOffset(e.getStart().getDate().getValue(), cal.getTimeZone())));
			viewableEndDate = new EventDateTime().setDate(new DateTime(TimeUtils.applyTimeZoneOffset(e.getEnd().getDate().getValue(), cal.getTimeZone())));
		}
	} else {
		//Almost definitely not correct, but we need something displayed here.
		viewableStartDate = e.getStart();
		viewableEndDate = e.getEnd();
	}

	eventData = DatabaseManager.getManager().getEventData(guildId, e.getId());

	editing = false;
	lastEdit = System.currentTimeMillis();
}
 
Example #17
Source File: AddCalendarWorkitemHandler.java    From jbpm-work-items with Apache License 2.0 4 votes vote down vote up
public Calendar addCalendar(com.google.api.services.calendar.Calendar client,
                            String calendarSummary) throws IOException {
    Calendar entry = new Calendar();
    entry.setSummary(calendarSummary);
    return client.calendars().insert(entry).execute();
}
 
Example #18
Source File: PreCalendar.java    From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 3 votes vote down vote up
public PreCalendar(Snowflake _guildId, Calendar calendar) {
	guildId = _guildId;
	summary = calendar.getSummary();

	if (calendar.getDescription() != null)
		description = calendar.getDescription();

	if (calendar.getTimeZone() != null)
		timezone = calendar.getTimeZone();


	editing = false;

	lastEdit = System.currentTimeMillis();
}
 
Example #19
Source File: PreCalendar.java    From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 3 votes vote down vote up
public PreCalendar(Snowflake _guildId, Calendar calendar) {
	guildId = _guildId;
	summary = calendar.getSummary();

	if (calendar.getDescription() != null)
		description = calendar.getDescription();

	if (calendar.getTimeZone() != null)
		timezone = calendar.getTimeZone();


	editing = false;

	lastEdit = System.currentTimeMillis();
}
 
Example #20
Source File: CalendarCreatorResponse.java    From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Creates a new response.
 *
 * @param _successful Whether or not the creation was successful.
 * @param _calendar   The calendar created.
 */
public CalendarCreatorResponse(boolean _successful, Calendar _calendar) {
	successful = _successful;
	calendar = _calendar;
}
 
Example #21
Source File: CalendarCreatorResponse.java    From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * The calendar involved. Can be null.
 *
 * @return The calendar involved, may be null.
 */
public Calendar getCalendar() {
	return calendar;
}
 
Example #22
Source File: CalendarCreatorResponse.java    From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Sets the calendar involved.
 *
 * @param _calendar The calendar involved.
 */
public void setCalendar(Calendar _calendar) {
	calendar = _calendar;
}
 
Example #23
Source File: CalendarCreatorResponse.java    From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Creates a new response.
 *
 * @param _successful Whether or not the creation was successful.
 * @param _calendar   The calendar created.
 */
public CalendarCreatorResponse(boolean _successful, Calendar _calendar) {
	successful = _successful;
	calendar = _calendar;
}
 
Example #24
Source File: CalendarCreatorResponse.java    From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * The calendar involved. Can be null.
 *
 * @return The calendar involved, may be null.
 */
public Calendar getCalendar() {
	return calendar;
}
 
Example #25
Source File: CalendarCreatorResponse.java    From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Sets the calendar involved.
 *
 * @param _calendar The calendar involved.
 */
public void setCalendar(Calendar _calendar) {
	calendar = _calendar;
}