I am using the following code to create events on a microsoft account calendar:
Event event = new Event();
event.subject = meetingType.getName();
event.body = getMicrosoftMeetingBody(meetingType);
event.start = getMicrosoftMeetingStart(timeSlot);
event.end = getMicrosoftMeetingEnd(timeSlot, meetingType);
event.location = getMicrosoftMeetingLocation();
event.attendees = getMicrosoftMeetingAttendeeList(attendeeName, attendeeEmail);
event.isOnlineMeeting = true;
event.onlineMeetingProvider = OnlineMeetingProviderType.TEAMS_FOR_BUSINESS;
event.reminderMinutesBeforeStart = SIXTY_MINUTES;
event.responseRequested = true;
Event createdEvent = graphClient.me().calendars(userCalendar.getCalendarId()).events()
.buildRequest()
.post(event);
The above code works and is creating events on the calendar. However, it double books a slot even if there are pre-existing events on it.
Is it possible to build a request in such a way so as to not do the booking if the slot is already booked?
Related
I created my own calendar using netbeans, caldav4j and Davical. However, I can't get shared calendar list.
I can create a calendar or an event. I can see them at Agendav. But when I share calendar to other users at Agendav, I can't get it with my netbeans code.
I want to show which user shared calendar with me.
HttpClient http = createHttpClient();
HostConfiguration hostConfig = createHostConfiguration();
PropFindMethod propfind = new PropFindMethod();
propfind.setPath(caldavCredential.home);
PropProperty propFindTag = PropertyFactory.createProperty(PropertyFactory.PROPFIND);
PropProperty aclTag = PropertyFactory.createProperty(PropertyFactory.ACL);
PropProperty propTag = new PropProperty(CalDAVConstants.NS_DAV,"D","prop");
propTag.addChild(aclTag);
propFindTag.addChild(propTag);
propfind.setPropFindRequest(propFindTag);
propfind.setDepth(0);
executeMethod(hostConfig, propfind);
Set<String> keySet = (propfind.getResponseHashtable()).keySet();
for(String key: keySet){
CalDAVResponse response = (propfind.getResponseHashtable()).get(key);
String href = response.getHref();
Ace[] aces = propfind.getAces(href);
Enumeration enumerations = aces.enumeratePriviliges();
while(enumerations.hasMoreElements()){
Privilege privilege = (Privilege)enumerations.nextElement();
System.out.println("parameter: " + privilege.getParameter());
}
}
I try to get privileges but there is no parameter. I only want which user shared calendars with me. I can make calendar, add event but I can't access shared calendar list.
I am new to the PayPal SDK and I am trying to create a billing plan and change its status to ACTIVE. I have tried some sample Java code from the SDK tutorial but I can't get that code to work. Status remains CREATED. The code I tried can be found below.
What is missing/wrong?
The output from running the code is
Created plan with id = P-1MT21723NA428154CRJGOTXQ
Plan state = CREATED
Plan state = CREATED
Best regards /Lasse
// Build Plan object
Plan plan = new Plan();
plan.setName("T-Shirt of the Month Club Plan");
plan.setDescription("Template creation.");
plan.setType("fixed");
// Payment_definitions
PaymentDefinition paymentDefinition = new PaymentDefinition();
paymentDefinition.setName("Regular Payments");
paymentDefinition.setType("REGULAR");
paymentDefinition.setFrequency("MONTH");
paymentDefinition.setFrequencyInterval("1");
paymentDefinition.setCycles("12");
// Currency
Currency currency = new Currency();
currency.setCurrency("USD");
currency.setValue("20");
paymentDefinition.setAmount(currency);
// Charge_models
ChargeModels chargeModels = new ChargeModels();
chargeModels.setType("SHIPPING");
chargeModels.setAmount(currency);
List<ChargeModels> chargeModelsList = new ArrayList<>();
chargeModelsList.add(chargeModels);
paymentDefinition.setChargeModels(chargeModelsList);
// Payment_definition
List<PaymentDefinition> paymentDefinitionList = new ArrayList<>();
paymentDefinitionList.add(paymentDefinition);
plan.setPaymentDefinitions(paymentDefinitionList);
// Merchant_preferences
MerchantPreferences merchantPreferences = new MerchantPreferences();
merchantPreferences.setSetupFee(currency);
merchantPreferences.setCancelUrl("https://example.com/cancel");
merchantPreferences.setReturnUrl("https://example.com/return");
merchantPreferences.setMaxFailAttempts("0");
merchantPreferences.setAutoBillAmount("YES");
merchantPreferences.setInitialFailAmountAction("CONTINUE");
plan.setMerchantPreferences(merchantPreferences);
// Create payment
Plan createdPlan = plan.create(apiContext);
System.out.println("Created plan with id = " + createdPlan.getId());
System.out.println("Plan state = " + createdPlan.getState());
// Set up plan activate PATCH request
List<Patch> patchRequestList = new ArrayList<>();
Map<String, String> value = new HashMap<>();
value.put("state", "ACTIVE");
// Create update object to activate plan
Patch patch = new Patch();
patch.setPath("/");
patch.setValue(value);
patch.setOp("replace");
patchRequestList.add(patch);
// Activate plan
createdPlan.update(apiContext, patchRequestList);
System.out.println("Plan state = " + createdPlan.getState());
Got it!
I had to execute Plan.get(context, createdPlan.getId());
to get the latest state of the plan.
I followed the quickstart guide that Google provides on Calendar API https://developers.google.com/google-apps/calendar/quickstart/java but they dont explain how to create a new event. I found this snippet of code online
public void createEvent(Calendar cal){
Event event = new Event();
event.setSummary("Event name here");
event.setLocation("event place here");
Date startDate = new Date();
Date endDate = new Date(startDate.getTime() + 3600000);
DateTime start = new DateTime(startDate, TimeZone.getTimeZone("UTC"));
event.setStart(new EventDateTime().setDateTime(start));
DateTime end = new DateTime(endDate, TimeZone.getTimeZone("UTC"));
event.setEnd(new EventDateTime().setDateTime(end));
Event createdEvent = cal.events().insert("primary", event).execute();
System.out.println("Created event id: " + createdEvent.getId());
}
But it didn't help me, i got an error in the Event createdEvent = cal.events() section as events() doesn't exist. Any help is much appreciated, thank you.
At the bottom of your link to the documentation there is a link to Create Events. I won't duplicate the entire page here, but the gist is that you need to Create an Event object (perhaps called MyNewEvent), populate it, and then call:
MyNewEvent = service.events().insert("Some Calendar Id", MyNewEvent).execute();
I want to get workitems by querying RTC based on workitem's history, after specific date and time.
Something like this:
IQueryableAttribute recAttr1 = factory.findAttribute(projectArea, IItem.HISTORY_PROPERTY, auditableClient, null );
AttributeExpression projectExpr = new AttributeExpression(projectAttr, AttributeOperation.EQUALS, projectArea);
AttributeExpression recExpr1 = new AttributeExpression(recAttr1, AttributeOperation.AFTER, timeStamp );
Term term= new Term(Operator.AND);
term.add(recExpr1);
IQueryClient queryClient = (IQueryClient) teamRepository.getClientLibrary(IQueryClient.class);
IQueryResult<IResolvedResult<IWorkItem>> result = queryClient.getResolvedExpressionResults(projectArea, (Expression)term, IWorkItem.FULL_PROFILE);
Is there any property like below?
IItem.HISTORY_PROPERTY
In a eclipse plugin for the Lotus Notes client I need to create a meeting in a user's mailfile. I have created successfully an appointment in my own mailfile using the NotesCalendar object. (see code below ). What I don't seem to get right is to create a meeting instead of an appointment. On the database level the difference is made by a field called appointmenttype which is set to 3 in the case of a meeting and 0 in the case of a appointment.
According to resources I found I need to add the xProperty "X-LOTUS-APPTTYPE" with a value of "3" to my Ical4j object but for some reason this is not being processed by the NotesCalendar.createEntry() method.
Does someone have any idea how to create a Meeting in a mailfile using the NotesCalendar notes classes and Ical4j?
(the reason I have added the xPages tag is that I hope someone in the xPages community ever has used the notescalendar objects before )
Code that creates an appointment:
DateTime meetingStart = new DateTime(c.getStartTime().getTime());
DateTime meetingEnd = new DateTime(c.getEndTime().getTime());
VEvent meeting = new VEvent(meetingStart, meetingEnd, c.getSubject());
// Add chair
Attendee chairAttendee = new Attendee(URI.create("mailto:j.somhorst#development.acuity.nl"));
chairAttendee.getParameters().add(Role.CHAIR);
// Add invitees
for(User invitee : c.getUserParticipants()){
Attendee attendee = new Attendee(URI.create("mailto:"+invitee.getEmail()));
attendee.getParameters().add(Role.REQ_PARTICIPANT);
meeting.getProperties().add(attendee);
}
// create calendar for ics export
Calendar call = new Calendar();
call.getProperties().add(new ProdId("-//Lotus Development Corporation//NONSGML Notes 9.0.1//EN_API_C"));
call.getComponents().add(meeting);
// notes specific fields
meeting.getProperties().add(new XProperty("X-LOTUS-NOTESVERSION","2"));
meeting.getProperties().add(new XProperty("X-LOTUS-APPTTYPE","3"));
NotesCalendar notesCalendar = NotesUtil.getNotesCalendar(s);
if(notesCalendar!=null){
notesCalendar.setAutoSendNotices(false);
NotesCalendarEntry entry = notesCalendar.createEntry(call.toString());
String icallvalue = entry.read();
System.out.println(icallvalue);
}