how to create a lotus notes meeting using java in domino designer - java

Hi i am trying to create meeting in lotus notes using java.i am able to send a meeting invite to the recipients.But when i send a meeting the options available to the chair and the recipients are the same.(options like accept,decline).But the options for the chair and the recipients should be different.can anyone please tell how to do this?
public DocumentKey save(final Session session, final Database db, boolean send,
String moveToFolder) throws NotesException, Io Exception {
//setBody(null);
Document doc = null;
RichTextItem rti = null;
try {
doc = db.createDocument();
db.getView(ServiceConstants.MEETINGS);
// Here i am setting all the properties for that document.
// I cant post that code as it has
// over 100 properties, so more than 100 lines of code
rti = doc.createRichTextItem(ServiceConstants.BODY);
rti.appendText(getBody());
if ((attachment != null) && (attachment.length > 0)) {
for (int i = 0; i < attachment.length; i++) {
attachment[i].save(rti);
}
}
doc.save(true, true, true);
if (send) {
doc.send();
}
if (!isBlank(moveToFolder)) {
doc.putInFolder(moveToFolder, true);
}
setKey(new DocumentKey(doc.getNoteID()));
} finally {
Helper.cleanupIfNeeded(rti);
Helper.cleanupIfNeeded(doc);
}
return getKey();
}

To successfully schedule a meeting, you need to follow the calendaring and scheduling schema
In short: A meeting has to be created in the chair's mail file and the invitations have to be responses (doc.MakeResponse(...)) to that main document and sent via mail. The "ApptUnid"- item ties them all together.
Read the documentation in the link, it is very good

If you are using Notes / Domino 9.0 or greater, you should consider using the lotus.domino.NotesCalendar interface and its related interfaces. These relatively new interfaces let you create, read and update calendar entries using iCalendar format.
Here's some sample code:
// Get the NotesCalendar object from the database
NotesCalendar notesCalendar = session.getCalendar(database);
if ( notesCalendar == null ) {
throw new Exception("Cannot open calendar.");
}
// Create a meeting in iCalendar format
String ical = iCalendarMeeting();
// Create the meeting on the Notes calendar
NotesCalendarEntry entry = notesCalendar.createEntry(ical);
This code creates an instance of NotesCalendar from an instance of Database. Then it gets the representation of a meeting in iCalendar format (the iCalendarMeeting method is not shown). Finally, it calls NotesCalendar.createEntry() to create the meeting. The createEntry method places the meeting on the organizer's calender and sends an invitation to all attendees.

Related

Java have Alexa Custom Skill ask for missing slots

I am currently building a custom skill for Alexa in Java.
I want Alexa to set an appointment using an existing Exchange Server.
For the appointment I want Alexa to check wether a name, a date and a time are given by the user. I do so using if-statements like:
if(date.getValue() == null) {
return askResponse("Please give a date in order to create an appointment")
What happens is Alexa asks for the missing slot but when I answer the skill just quits. I don't know how to have Alexa recognize my response.
Code is as follows:
public SpeechletResponse getTerminResponse(Slot name, Slot date, Slot time, Session session, IntentRequest request) throws Exception {
if(time.getValue() == null) {
return askResponse("Please insert time");
} else if (date.getValue() == null) {
return askResponse("Please insert date");
} else if (name.getValue() == null) {
return askResponse("Please insert name");
} else {
try {
String[] datumArray = date.getValue().split("-");
String[] zeitArray = time.getValue().split(":");
Date startDate = new Date((Integer.parseInt(datumArray[0])-1900), (Integer.parseInt(datumArray[1])-1), (Integer.parseInt(datumArray[2])), (Integer.parseInt(zeitArray[0])), (Integer.parseInt(zeitArray[1])), 0);
Date endDate = new Date((Integer.parseInt(datumArray[0])-1900), (Integer.parseInt(datumArray[1])-1), (Integer.parseInt(datumArray[2])), (Integer.parseInt(zeitArray[0]))+1, (Integer.parseInt(zeitArray[1])), 0);
System.out.println(startDatum.toString());
System.out.println(endDatum.toString());
ExchangeHelper eh = new ExchangeHelper();
eh.createMeeting(name.getValue(), "Test", startDate, endDate);
return getTellSpeechletResponse("Appointment created successfully");
} catch (Exception e) {
System.out.println(e);
return askResponse("Failed to create appointment");
}
}
}
Here is my Interaction Model
Any help would be highly appreciated since I have been researching documentations and examples for days and I just can not get it to work.
Best regards
Can you give the code for getTellSpeechletResponse?
According to the picture you attached you are using the "new" Dialog model so that Amazon collect all the slots for you intent.
https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/dialog-interface-reference#directives
Most probably you forgot to send back the DelegateDirective (via speechletResponse.setDirectives(...)) to amazon to tell Alexa to take care for collecting the slot values. But this only can be answered if you send the code. I would also like to see an Dialog Java example by amazon but haven't found yet.
If you are using this dialog model you also don't need the if elses as alexa recognize itself which slots are missing. You have to mark this "Is this slot required to fulfill the intent" with yes in the interaction model. Than you also don't need to create own ask responses but just to give utterances in interaction model for your 4 slots.

Creating Meeting lotus Meeting using ICall

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);
}

EWS Java get meetings

I am trying to integrate exchange calendar with my custom calendar. Till now i am able to integrate new creation of meeting from my calendar to Exchange.
But the issue i am facing is from Exchange to my calendar. If i create a new meeting in outlook, and and if i search it through below code i am getting results.
<code>
CalendarFolder calendarFolder = CalendarFolder.bind(eService, WellKnownFolderName.Calendar);
CalendarView calendarView = new CalendarView(startOfMonth.toDate(), endOfMonth.toDate());
FindItemsResults<Appointment> aprilMeetings = alendarFolder.findAppointments(calendarView);
</code>
in above list i am getting all meetings between start and end date. My question is how to identify whether its a new meeting or updated meeting or canceled meeting.
I tried these methods,
<code>
appointment.getIsNew().
appointment.getIsCancelled()
appointment.getIsUnmodified()
</code>
But all above methods return false. I need to find a way to figure out this so that i can sync items from my Exchange Server to my custom application (Note: I am also creating iCal file in my application, so i can use my application when exchange is not connected).
Regards.
you can use the following code to get updated/new meetings.
Date startDate1 = formatter.parse("2014-04-25 07:00:00");
SearchFilter filter = new SearchFilter.IsGreaterThanOrEqualTo(ItemSchema.LastModifiedTime,startDate1);
FindItemsResults<Item> findResults = exchange.findItems(WellKnownFolderName.Calendar, filter, new ItemView(10));
for (Item item : findResults.getItems())
{
Appointment appt = (Appointment)item;
System.out.println("SUBJECT====="+appt.getSubject());
System.out.println("Location========"+appt.getLocation());
System.out.println("Start Time========"+appt.getStart());
System.out.println("End Time========"+appt.getEnd());
System.out.println("Email Address========"+ appt.getOrganizer().getAddress());
System.out.println("Last Modified Time========"+appt.getLastModifiedTime());
}

Lotus Domino Java API meeting creation and cancellation

I am using Lotus Domino Java API for iNotes 8.5. I am able to create an meeting and add rooms, resources for the meeting request and send to all attendees from my Java program. But I have a problem while cancelling the meeting:
When I cancel the meeting, the calender entry is getting deleted from the calendar, but the rooms and resources are getting release.
Here is what I am trying to do for cancellation:
option-1:
1. get the notes document from Database with the UNID
2. delete the document
option-2:
1. get the notes document from Database with UNID
2. remove rooms and resources from document
3. save document
4. remove document
After using the above two options, I am still seeing that resources are not getting released. Can some one please help me with a solution or idea's for resolving this issue.
Since the I am not able to release the rooms and resources programmatically, I have a over head of releasing the rooms manually every time the meeting is cancelled.
code I am using:
public boolean removeResources(Document d) throws Exception
{
if(null!= d.getItemValue("Room"))
d.removeItem("Room");
if(null!= d.getItemValue("RequiredResources"))
d.removeItem("RequiredResources");
return d.save(true);
}
I am not an expert with the C&E system in Domino but if you need to remove a field from a document in the method you're writing, then try this:
public boolean removeResources(Document d) throws NotesException
{
boolean bUpdated = false;
if(d.hasItem("Room")) {
d.removeItem("Room");
bUpdated=true;
}
if(d.hasItem("RequiredResources")) {
d.removeItem("RequiredResources");
bUpdated=true;
}
if (bUpdated) {
// something changed, so commit to document (d)
if (d.save(true)) {
return true;
} else {
return false;
}
}else {
// no changes therefore no resources were in the document, so return true anyway
return true;
}
}

How can I send from the server-side (Google App Engine, Cloud Endpoints) the information to my client?

I have an Android Application that is stored in the Cloud, with Google App Engine. I use Cloud Endpoints. My problem is that I cannot send the data from the server to my client(Android Device), or better said, so far, I have no idea how to do that.
So far, I have managed to insert data in the datastore, by creating an endpoint and calling the method that is in charge with adding a record in the database(that's located on the server side, in myProject - AppEngine) , using the following code (on the client):\
Noteendpoint.Builder endpointBuilder = new Noteendpoint.Builder(
AndroidHttp.newCompatibleTransport(),
new JacksonFactory(),
new HttpRequestInitializer() {
public void initialize(HttpRequest httpRequest) { }
});
Noteendpoint endpoint = CloudEndpointUtils.updateBuilder(
endpointBuilder).build();
try {
// Construct the note.
Note note = new Note().setDescription("Note DescriptionRoxana");
String noteID = new Date().toString();
note.setId(noteID);
note.setEmailAddress("E-Mail AddressRoxana");
// Insert the Note, by calling a method that's on the server side - insertNote();
Note result = endpoint.insertNote(note).execute();
} catch (IOException e) {
e.printStackTrace();
}
But I cannot see a way of retrieving data from the datastore and to display it on the server side. I tried to do the same, create an endpoint, that will call the method that retrieves all the records in the database (method that is located on the server), but my application crashes.
The code for the method that retrieves data from the datastore is the following:
public CollectionResponse<Note> listNote(
#Nullable #Named("cursor") String cursorString,
#Nullable #Named("limit") Integer limit) {
EntityManager mgr = null;
Cursor cursor = null;
List<Note> execute = null;
try {
mgr = getEntityManager();
Query query = mgr.createQuery("select from Note as Note");
if (cursorString != null && cursorString != "") {
cursor = Cursor.fromWebSafeString(cursorString);
query.setHint(JPACursorHelper.CURSOR_HINT, cursor);
}
if (limit != null) {
query.setFirstResult(0);
query.setMaxResults(limit);
}
execute = (List<Note>) query.getResultList();
cursor = JPACursorHelper.getCursor(execute);
if (cursor != null)
cursorString = cursor.toWebSafeString();
// Tight loop for fetching all entities from datastore and accomodate
// for lazy fetch.
for (Note obj : execute)
;
} finally {
mgr.close();
}
return CollectionResponse.<Note> builder().setItems(execute)
.setNextPageToken(cursorString).build();
}
You see, the returned type is collection response. You have access to this type of data, after performing the following import:
import com.google.api.server.spi.response.CollectionResponse;
I inferred that this is a data type characteristic to the server side, thus, I have no idea how I can cast it into a List, ArrayList, or any other type of collection, that can be used on the client side.
How should I do it then? Since adding data was so easy and so straight forward, I have assumed that retrieving data would be performed in the same manner, but apparently I am missing something essential for this matter.
Thank you in advance!
The classes you use in the backend are not the same as the classes you'll use in the client. Endpoints will generate a set of libraries for you, either on the command line or with tooling like Google Plugin for Eclipse. See Using Endpoints in an Android Client.
The generated class representing the collection of Notes in your example will be named something like NotesCollection. This object will have a method getItems, which provides you a List<Note> you can iterate on in your Android application.
Similar to having an endpoint for inserting data into a datastore model(methods of type POST), you need to have an endpoint for querying the data from the datastore model (methods of type GET). After you define both these methods, you need generate your discovery document and client library so that clients know about both these methods and can call them. If your speaking about displaying the data in the web itself then you can build a Javascript client by using the required client library.

Categories

Resources