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;
}
}
Related
I am doing a notification on my app and I am using firestore. My problem is I want to send a notification to the user when the snapshotlistener detect a newly added data to the database But when I open the app it will show the existing notification right away even though i did not added a new data. I need some conditions where I can only get the newly added data or if there's something lacking in my database data that will need in order to overcome this issue. Below is my databse structure.
db.collection("Buyers")
.document(userID)
.collection("Notifications")
.addSnapshotListener(new EventListener<QuerySnapshot>() {
#Override
public void onEvent(#Nullable QuerySnapshot snapshots, #Nullable FirebaseFirestoreException e) {
if (e != null) {
Log.e(LOG_DB, e.toString());
return;
}
for (DocumentChange dc : snapshots.getDocumentChanges()) {
if (dc.getType() == DocumentChange.Type.ADDED) {
String title = dc.getDocument().getData().get("notificationTitle").toString();
String body = dc.getDocument().getData().get("notificationBody").toString();
//Method to set Notifications
getNotification(title, body);
}
}
}
});
If you just want to send notifications, you can use Firebase Cloud Messages which may provide the functionality you are trying to implement yourself.
https://firebase.google.com/docs/cloud-messaging
If you want to send a Notification after data is changed in your Firestore you can use FireStore Triggers (https://firebase.google.com/docs/functions/firestore-events) and send a Notification via a firebase function call (Send push notifications using Cloud Functions for Firebase)
I had a similar issue and this is how I solved it:
Get a count of your current items added and save in Shared Preferences
Upon opening the app get the current count of items and compare with the saved number in shared preferences
Set a condition where if the current count of item is more than the saved number in shared preferences, the notification is called.
I am able to get what I want but I am not sure if this is the right way to do this.
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, -5);
Date before = calendar.getTime();
Calendar calendar1 = Calendar.getInstance();
Date until = calendar1.getTime();
for (DocumentChange dc : snapshots.getDocumentChanges()) {
Date date = (Date) dc.getDocument().getData().get("notificationDate");
if (dc.getType() == DocumentChange.Type.ADDED) {
if (!before.after(date) && !until.before(date)){
Log.d("life", "Data: "+date);
String title = dc.getDocument().getData().get("notificationTitle").toString();
String body = dc.getDocument().getData().get("notificationBody").toString();
getNotification(title, body);
}
}
}
What i have done here was I retrieve the current and the current time minus 5 mins.(You can choose how many delayed the mins you want) then made a condition where it must only show the notifications within the 5mins delayed date.
Note:
I know this was not the proper practice but this gets the result that I want. If you didn't want my answer please let me know and post your own answer so I can acknowledge your answer.
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.
I am using Couchbase Lite SDK for android and saving an object instance of MyClass as a document in the database. MyClass has an attribute that stores the date in the java.util.Date. During run time, I fetch all the instances of MyClass saved in the database and store them in the ArrayList<MyClass>. When I insert a new document into the database and read the values from the database to show all the entered instances, the date field saved in the database is retrieved as a Long when I next try to fetch the details from the database. The code I use to load the details from the database is:
Code snippet 1:
for (Field field: fields) {
field.setAccessible(true);
if (properties.containsKey(field.getName())) {
if ("date".equals(field.getName())) {
Log.d("DebugTag", properties.get(field.getName()) + "");
long dateLong = (Long) properties.get(field.getName());
details.setDate(new Date(dateLong));
} else {
field.set(details, properties.get(field.getName()));
}
} else if("_id".equals(field.getName())) {
details.set_id(document.getId());
} else {
final String msg = "Field " + field.getName() + " not present in document ";
Log.e(TAG, msg);
}
}
You can see that I have added an additional check in case the field is date. This works perfectly fine. So, I save a new entry to database and come back to the page where I see all the entries made into the database.
Now, I have implemented a new functionality to update the details of a record in the database. For updating the record I have the following implementation:
Code snippet 2:
public static boolean updateDocument(Database database, String docID, Map<String, Object> map) {
if (null == database || null == map || null == docID) {
return false;
}
boolean success = true;
Document document = database.getDocument(docID);
try {
// Have to put in the last revision id as well to update the document.
// If we do not do this, this will throw exception.
map.put("_rev", document.getProperty("_rev"));
// Putting new properties in the document ...
document.putProperties(map);
} catch (CouchbaseLiteException e) {
Log.e(TAG, "Error putting property", e);
success = false;
}
return success;
}
After doing this when I try to reload the items, it gives me exception while reading the date field in my Code snippet 1 saying that the Date object cannot be typecasted as Long and the application crashes. Now, when I again open the application, it works perfectly fine with all the changes to the edited entry reflecting correctly. Can anyone let me know the reason for this? I suspect, until we close the database connection, the changes are not committed to the actual database location and the date field in the updated entry is kept in the cache as the Date object in my case.
PS: Although, I have found a workaround for this by setting the date as a Long object in the payload (map in function updateDocument() in Code snippet 2), it would still be interesting to understand the problem I faced.
Looking at this further, this could be reasons related to auto-boxing where long to Long conversion of primitive types to the object wrapper class is crashing the application when trying to save.
Have you tried:
long value = Long.parseLong((String)...);
More specifically in Code snippet 1:
long dateLong = Long.parseLong((String)properties.get(field.getName()));
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.
I am new to this forum. I have a doubt about JSP/servlet in my application
I have developed an application in which user may search some data based on some criteria and he will get data from database(through Hibernate to servlet and to JSP). When some data is displayed on screen based on search he/she may try to copy the URL and forward to anyone or If he try to open in different browser it is showing an empty page.
eg: if i try to paste the link given bellow it is showing blank page
example link
but i need to display the data how this can be achieved.
Edited: After clicking on job search in menu bar as mentioned in comments the page will redirect to a servlet
if(action.equals("searchjob")){
String requireskills=request.getParameter("txt_requireSkills");
String location=request.getParameter("txt_locationName");
session.setAttribute("location",location);
String minexp1=request.getParameter("dd_minimum");
String maxexp1=request.getParameter("dd_maximum");
jobsearchDAO = new JobSearchDAOImpl();
List<JobPostInfo> data=jobsearchDAO.jobsearchlist(requireskills,location,minexp1,maxexp1);
if(data!=null && data.size()!=0){
//save data
if(!(session.getAttribute("LoginObject")==null)){
JobSeeker jobSeeker=(JobSeeker)session.getAttribute("LoginObject");
JobSearchCriteria jobsearchcriteria= new JobSearchCriteria();
jobsearchDAO=new JobSearchDAOImpl();
jobsearchcriteria.setKeyWords(requireskills);
jobsearchcriteria.setLocation(location);
JobSeeker jobseeker=(JobSeeker)session.getAttribute("jobseeker");
//
// jobsearchcriteria.setJobSeeker(jobseeker.getJobSeekerSn());
jobsearchcriteria.setJscTs(new Date());
int value=jobsearchDAO.savesearch(jobsearchcriteria);
System.out.println("savesearch value------>"+value);
}
session.setAttribute("jobsearchlist", data);
// session.setAttribute("success","Search Criteria is saved to database.");
response.sendRedirect("jobsearchresult.jsp");
}else
{
session.setAttribute("error","No Records found");
response.sendRedirect("jobsearch.jsp");
}
}
This is the code in DAOIMPL
public List<JobPostInfo> jobsearchlist(String requireskills,String location,String minexp1,String maxexp1) throws Exception{
long minexp;
long maxexp;
try{
session =getSession();
//Criteria Query
Criteria query=session.createCriteria(JobPostInfo.class,"jpost");
// if(minexp1.equals("0") && (maxexp1.equals("") || maxexp1==null)){
if((minexp1.equals("-1") || minexp1=="-1") && maxexp1==null){
}
else if(minexp1.equals("0")){
minexp=Long.parseLong(minexp1);
long min=1;
query.add(Restrictions.lt("jpost.experienceMin",min));
}else if(!(minexp1.equals("") || minexp1==null) && maxexp1.equals("-1")) {
minexp=Long.parseLong(minexp1);
query.add(Restrictions.ge("jpost.experienceMin",minexp));
}else if(!(minexp1==null && maxexp1==null)){
minexp=Long.parseLong(minexp1);
maxexp=Long.parseLong(maxexp1);
query.add(Restrictions.and(Restrictions.ge("jpost.experienceMin",minexp),Restrictions.le("jpost.experienceMax",maxexp)));
}
//For Location
if(!(location==null|| location.equals(""))){
query.createAlias("jpost.location","location");
query.add(Restrictions.like("location.locationName",location).ignoreCase());
}
//For Keyword
if(!(requireskills==null || requireskills.equals(""))){
query.add(Restrictions.like("jpost.requiredSkills","%"+requireskills+"%").ignoreCase());
}//requireskills
List<JobPostInfo> list = query.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list();
if(list.size()==0){
return null;
}else{
return list;
}
}catch(HibernateException e){
e.printStackTrace();
}finally {
close(session);
}
return null;
}
I solved my problem. It's a very basic mistake and I hope this will help others:
response.sendRedirect("jobsearchresult.jsp") is replaced by request.getRequestDispatcher("studentinformation.jsp").forward(request, response)
or include-method. The second thing is, the session is created and initialized with the servlet. When I copy the link in a different browser, a certain block of the servlet will be executed. Example:
action.equals("searchjob")
So at the time the session is not available yet, I initialize it in every block like separating declaration and initialization.