Java Code Examples for lotus.domino.Session#createDateTime()
The following examples show how to use
lotus.domino.Session#createDateTime() .
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: FreeRooms901Provider.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
public List<Room> getFreeRooms(Session session, String site, Date start, Date end, int capacity) throws ModelException { List<Room> rooms = new ArrayList<Room>(); DateTime dtStart = null; DateTime dtEnd = null; try { String userName = session.getEffectiveUserName(); dtStart = session.createDateTime(start); dtEnd = session.createDateTime(end); Vector results = session.freeResourceSearch(dtStart, dtEnd, site, 0, 999, // TODO: What is the right default for maxResults? userName, capacity, null, null, 0); if ( results != null ) { Iterator iterator = results.iterator(); while (iterator.hasNext()) { String rawValue = (String)iterator.next(); // Parse the raw value into a Room object Room room = parseRoom(session, rawValue); rooms.add(room); } } } catch (NotesException e) { throw new ModelException(e.text, mapError(e.id)); } finally { BackendUtil.safeRecycle(dtStart); BackendUtil.safeRecycle(dtEnd); } return rooms; }
Example 2
Source File: NotesCalendarStore.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
public EventSet getEvents(Date fromDate, Date toDate, int skipCount, int maxEvents, ArrayList<String> rangeFieldsFilter) throws StoreException { EventSet result = null; NotesCalendar calendar = null; DateTime dtstart = null; DateTime dtend = null; try { Session session = _database.getParent(); calendar = session.getCalendar(_database); // TODO: Should we set the mask back to the default when we are done? int newMask = 0; boolean useDefaultFilterMask = true; if( rangeFieldsFilter!=null ){ Iterator<String> rangeFieldsFilterIterator = rangeFieldsFilter.iterator(); while(rangeFieldsFilterIterator.hasNext()){ String filter = rangeFieldsFilterIterator.next(); if(SUPPORT_RANGE_FILTER.containsKey(filter)){ newMask |= SUPPORT_RANGE_FILTER.get(filter); useDefaultFilterMask = false; } } } if(useDefaultFilterMask){ newMask = READ_RANGE_ALL; } // Convert Java dates to DateTime objects if ( fromDate == null ) { if ( toDate == null ) { // Start and end dates are null. Read one year of // events starting today. Date now = new Date(); dtstart = session.createDateTime(now); dtend = session.createDateTime(new Date(now.getTime() + ONE_YEAR)); } else { // Start date is null, but end date is not. Read // one year of events ending on the given date. dtstart = session.createDateTime(new Date(toDate.getTime() - ONE_YEAR)); dtend = session.createDateTime(toDate); } } else { if ( toDate == null ) { // End date is null, but start date is not. Read // one year of events starting on the given date. dtstart = session.createDateTime(fromDate); dtend = session.createDateTime( new Date(fromDate.getTime() + ONE_YEAR) ); } else { dtstart = session.createDateTime(fromDate); dtend = session.createDateTime(toDate); } } calendar.setReadRangeMask1(newMask); String events = calendar.readRange(dtstart, dtend, skipCount, maxEvents); result = new EventSet(events, calendar.getEntriesProcessed() - skipCount); } catch (NotesException e) { throw new StoreException("Error reading events", mapError(e.id), e); // $NLX-NotesCalendarStore.Errorreadingevents-1$ } finally { BackendUtil.safeRecycle(dtstart); BackendUtil.safeRecycle(dtend); BackendUtil.safeRecycle(calendar); } return result; }
Example 3
Source File: NotesCalendarStore.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
public void processEventAction(String id, String recurrenceId, RecurrenceRange range, Action action) throws StoreException { NotesCalendar calendar = null; try { Session session = _database.getParent(); calendar = session.getCalendar(_database); NotesCalendarEntry entry = calendar.getEntry(id); boolean keepInformed = false; switch(action.getActionType()) { case Action.ACTION_ACCEPT: entry.accept(action.getComments(), rangeToInt(range), recurrenceId); break; case Action.ACTION_CANCEL: entry.cancel(action.getComments(), rangeToInt(range), recurrenceId); break; case Action.ACTION_COUNTER: CounterAction ca = (CounterAction)action; DateTime start = session.createDateTime(ca.getStart()); DateTime end = session.createDateTime(ca.getEnd()); entry.counter(action.getComments(), start, end, rangeToInt(range), recurrenceId); break; case Action.ACTION_DECLINE: DeclineAction decline = (DeclineAction)action; if ( decline.getKeepInformed() != null ) { // This logic is not exactly right. We need a way to tell decline() // to use the user's default value for keepInformed. TODO: Fix // this when we have the right variant of decline(). keepInformed = decline.getKeepInformed().booleanValue(); } entry.decline(action.getComments(), keepInformed, rangeToInt(range), recurrenceId); break; case Action.ACTION_DELEGATE: DelegateAction delegate = (DelegateAction)action; if ( delegate.getKeepInformed() != null ) { // This logic is not exactly right. We need a way to tell delegate() // to use the user's default value for keepInformed. TODO: Fix // this when we have the right variant of delegate(). keepInformed = delegate.getKeepInformed().booleanValue(); } entry.delegate(delegate.getComments(), delegate.getDelegateTo(), keepInformed, rangeToInt(range), recurrenceId); break; case Action.ACTION_DELETE: entry.remove(rangeToInt(range),recurrenceId); break; case Action.ACTION_REMOVE_CANCEL: // TODO: What does this map to? break; case Action.ACTION_REQUEST_INFO: entry.requestInfo(action.getComments(),recurrenceId); break; case Action.ACTION_TENTATIVE: entry.tentativelyAccept(action.getComments(), rangeToInt(range), recurrenceId); break; case Action.ACTION_PROCESS_ALL: // TODO: Figure what this maps to. The processAll method is no longer // exported from the back end. //entry.processAll(); break; default: throw new StoreException("Error processing event action", StoreException.ERR_BAD_ACTION,new NotesException()); // $NLX-NotesCalendarStore.Errorprocessingeventaction-1$ } } catch (NotesException e) { throw new StoreException("Error processing event action", mapError(e.id), e); // $NLX-NotesEventStore.Errorprocessingeventaction-1$ } finally { BackendUtil.safeRecycle(calendar); } }
Example 4
Source File: NotesCalendarStore.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
public void processNoticeAction(String id, Action action) throws StoreException { NotesCalendar calendar = null; try { Session session = _database.getParent(); calendar = session.getCalendar(_database); NotesCalendarNotice notice = calendar.getNoticeByUNID(id); boolean keepInformed = false; switch(action.getActionType()) { case Action.ACTION_ACCEPT: notice.accept(action.getComments()); break; case Action.ACTION_COUNTER: CounterAction ca = (CounterAction)action; DateTime start = session.createDateTime(ca.getStart()); DateTime end = session.createDateTime(ca.getEnd()); notice.counter(action.getComments(), start, end); break; case Action.ACTION_DECLINE: DeclineAction decline = (DeclineAction)action; if ( decline.getKeepInformed() != null ) { // This logic is not exactly right. We need a way to tell decline() // to use the user's default value for keepInformed. TODO: Fix // this when we have the right variant of decline(). keepInformed = decline.getKeepInformed().booleanValue(); } // Without keepInformed equal keepInformed false notice.decline(action.getComments(), keepInformed); break; case Action.ACTION_DELEGATE: DelegateAction delegate = (DelegateAction)action; if ( delegate.getKeepInformed() != null ) { // This logic is not exactly right. We need a way to tell delegate() // to use the user's default value for keepInformed. TODO: Fix // this when we have the right variant of delegate(). keepInformed = delegate.getKeepInformed().booleanValue(); } notice.delegate(delegate.getComments(), delegate.getDelegateTo(), keepInformed); break; case Action.ACTION_REMOVE_CANCEL: notice.removeCancelled(); break; case Action.ACTION_REQUEST_INFO: notice.requestInfo(action.getComments()); break; case Action.ACTION_TENTATIVE: notice.tentativelyAccept(action.getComments()); break; default: throw new StoreException("Error processing notice action", StoreException.ERR_ACTION_NOT_SUPPORTED,new NotesException()); // $NLX-NotesCalendarStore.Errorprocessingnoticeaction-1$ } } catch (NotesException e) { throw new StoreException("Error processing notice action", mapError(e.id), e); // $NLX-NotesEventStore.Errorprocessingnoticeaction-1$ } finally { BackendUtil.safeRecycle(calendar); } }
Example 5
Source File: FreeRoomsProvider.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
/** * Given a list of rooms, find the ones that are free for a given range. * * @param session * @param candidates * @param start * @param end * @return * @throws NotesException */ private List<Room> findFreeRooms(Session session, List<Room> candidates, Date start, Date end) throws NotesException { List<Room> rooms = new ArrayList<Room>(); DateRange range = null; Vector freetimes = null; try { DateTime dtStart = session.createDateTime(start); DateTime dtEnd = session.createDateTime(end); range = session.createDateRange(); range.setStartDateTime(dtStart); range.setEndDateTime(dtEnd); Iterator<Room> iterator = candidates.iterator(); while ( iterator.hasNext() ) { if ( freetimes != null ) { BackendUtil.safeRecycle(freetimes); freetimes = null; } Room room = iterator.next(); String item = room.getEmailAddress(); if ( StringUtil.isEmpty(item) ) { item = room.getDistinguishedName(); } Vector<String> names = new Vector<String>(1); names.addElement(item); // Get the free time for this room Logger.get().getLogger().fine("Searching free time for " + item); // $NON-NLS-1$ try { freetimes = session.freeTimeSearch(range, 5, names, false); } catch (Throwable e) { Logger.get().warn(e, "Exception thrown searching free time for {0}", item); // $NLW-FreeRoomsProvider.Exceptionthrownsearchingfreetimef-1$ } if ( freetimes == null ) { continue; } // Compare the start and end times of the first free block DateRange freeRange = (DateRange)freetimes.get(0); Date freeStart = freeRange.getStartDateTime().toJavaDate(); Date freeEnd = freeRange.getEndDateTime().toJavaDate(); if ( start.getTime() != freeStart.getTime() || end.getTime() != freeEnd.getTime() ) { continue; } // It's completely free. Add it to the list. rooms.add(room); } } finally { BackendUtil.safeRecycle(range); BackendUtil.safeRecycle(freetimes); } return rooms; }
Example 6
Source File: DataInitializer.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
protected DateTime createDate(Session session, int year, int month, int day) throws NotesException { DateTime d = session.createDateTime(new Date()); d.setLocalDate(year, month, day); return d; }
Example 7
Source File: DataInitializer.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
protected DateTime createTime(Session session, int hour, int minute, int second) throws NotesException { DateTime d = session.createDateTime(new Date()); d.setLocalTime(hour,minute,second,0); return d; }
Example 8
Source File: DataInitializer.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
protected DateTime createDateTime(Session session, int year, int month, int day, int hour, int minute, int second) throws NotesException { DateTime d = session.createDateTime(new Date()); d.setLocalDate(year, month, day); d.setLocalTime(hour,minute,second,0); return d; }
Example 9
Source File: NotesRunner.java From org.openntf.domino with Apache License 2.0 | 4 votes |
public void run1(final Session session) throws NotesException { Long sessId = getLotusId(session); sessionid.set(sessId); Database db = session.getDatabase("", "names.nsf"); System.out.println("Db id:" + getLotusId(db)); Name name = null; int i = 0; try { for (i = 0; i <= 100000; i++) { name = session.createName(UUID.randomUUID().toString()); getLotusId(name); DateTime dt = session.createDateTime(new Date()); getLotusId(dt); DateTime end = session.createDateTime(new Date()); getLotusId(end); DateRange dr = session.createDateRange(dt, end); getLotusId(dr); Document doc = db.createDocument(); getLotusId(doc); Item i1 = doc.replaceItemValue("Foo", dr); getLotusId(i1); Item i2 = doc.replaceItemValue("Bar", dr.getText()); getLotusId(i2); Item i3 = doc.replaceItemValue("Blah", dr.getStartDateTime().getLocalTime()); getLotusId(i3); lotus.domino.ColorObject color = session.createColorObject(); getLotusId(color); color.setRGB(128, 128, 128); Item i4 = doc.replaceItemValue("color", color.getNotesColor()); getLotusId(i4); i1.recycle(); i2.recycle(); i3.recycle(); i4.recycle(); DateTime create = doc.getCreated(); getLotusId(create); @SuppressWarnings("unused") String lc = create.getLocalTime(); // if (i % 10000 == 0) { // System.out.println(Thread.currentThread().getName() + " Name " + i + " is " + name.getCommon() + " " // + "Local time is " + lc + " " + dr.getText()); // } dr.recycle(); doc.recycle(); dt.recycle(); end.recycle(); create.recycle(); color.recycle(); name.recycle(); } } catch (Throwable t) { t.printStackTrace(); System.out.println("Exception at loop point " + i); } }