I am getting exception while invoking NotesCalendar.getNewInvitations method.
NotesException: NotesCalendar error: The database handle is NULL
at lotus.domino.local.NotesCalendar.NgetNewInvitations(Native Method)
at lotus.domino.local.NotesCalendar.getNewInvitations(Unknown Source)
at JavaAgent.main(Unknown Source)
I am trying to run this code locally to Domino Server.
import lotus.domino.*;
public class JavaAgent extends NotesThread {
public static void main(String []args){
try
{
NotesThread.sinitThread(); // start thread
Session session = NotesFactory.createSession();
System.out.println("session="+session);
// (Your code goes here)
DbDirectory dbdir = session.getDbDirectory("");
System.out.println("dbdir="+dbdir);
Database db1= session.getDatabase("server", "Conf");
NotesCalendar cal = session.getCalendar(db1);
java.util.Calendar jdt = java.util.Calendar.getInstance();
jdt.set(2015, 1, 1, 1, 1, 1);
DateTime dt1 = session.createDateTime(jdt);
DateTime dt2 = session.createDateTime("Yesterday 02");
// java.util.Vector invites = cal.getNewInvitations(dt1, dt2);
// System.out.println("invites "+invites.size());
java.util.Vector invites= cal.getEntries(dt1, dt2);
for (int j = 0; j < 3; j++) {
// Create document to post results
Document doc = db1.createDocument();
doc.appendItemValue("Form", "main");
doc.appendItemValue("subject", "New invitations");
RichTextItem body = doc.createRichTextItem("body");
if (invites.size() == 0) body.appendText("No invitations");
else {
for (int i = 0; i < invites.size(); i++) {
NotesCalendarNotice cale = (NotesCalendarNotice)invites.elementAt(i);
body.appendText(cale.read());
cale.recycle();
body.addNewLine();
}
}
doc.save(true, true);
java.util.concurrent.TimeUnit.MINUTES.sleep(30);
invites = cal.getNewInvitations(dt1, cal.getUntilTime());
} }
catch(Exception e)
{
e.printStackTrace();
}
finally
{
NotesThread.stermThread(); // must terminate every thread
}
}
}
The simple answer is getNewInvitations() doesn't make sense in the context of a resource reservation database. The method was designed to read unprocessed invitations from a mail file.
However, in the comments you say your code doesn't work for mail files either. It might be helpful to get something simpler to work and then build on that. I just tried the following code:
database = session.getDatabase(null, "mail/user.nsf");
NotesCalendar calendar = session.getCalendar(database);
// Start date is 01-Jan-2015
java.util.Calendar start = java.util.Calendar.getInstance();
start.set(2015, 0, 1);
dtStart = session.createDateTime(start);
// End date is now
java.util.Calendar end = java.util.Calendar.getInstance();
dtEnd = session.createDateTime(end);
// Get entries on the calendar between start and end
Vector<?> entries = calendar.getEntries(dtStart, dtEnd);
System.out.println("Number of entries is " + entries.size());
// Get invitations from start date (from the Inbox)
Vector<?> invites = calendar.getNewInvitations(dtStart, calendar.getUntilTime());
System.out.println("Number of invites is " + invites.size());
Everything worked as expected. Perhaps you could try the above code and see if getNewInvitations() still throws an exception.
Related
I am trying to insert data into a datetime field in BigQuery via WriteStream in Java and keep getting the error
java.util.concurrent.ExecutionException: io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Cannot return an invalid datetime value of 1639484762470 microseconds relative to the Unix epoch. The range of valid datetime values is [0001-01-01 00:00:00, 9999-12-31 23:59:59.999999] on field date_time.
I tried different options: seconds, milliseconds, microseconds, cast from Unix format to Microsoft, insert formatted string (then I get an error that it should be INT64).
Where am I going wrong?
Code is pretty simple
try (JsonStreamWriter writer = JsonStreamWriter.newBuilder(writeStream.getName(), writeStream.getTableSchema(), client).build()) {
for (int i = 0; i < 2; i++) {
JSONArray jsonArr = new JSONArray();
for (int j = 0; j < 10; j++) {
JSONObject record = new JSONObject();
Date date = new Date();
record.put("date_hash", date.hashCode());
record.put("date_string", date.toString());
record.put("date_time", date.getTime());
jsonArr.put(record);
}
ApiFuture<AppendRowsResponse> future = writer.append(jsonArr, i * 10);
AppendRowsResponse response = future.get();
}
}
BEGIN:VEVENT
DTSTART;TZID=America/Los_Angeles:20151116T123000
DTEND;TZID=America/Los_Angeles:20151116T140000
EXDATE;TZID=America/Los_Angeles:20160215T123000
EXDATE;TZID=America/Los_Angeles:20160530T123000
EXDATE;TZID=America/Los_Angeles:20160704T123000
EXDATE;TZID=America/Los_Angeles:20160905T123000
EXDATE;TZID=America/Los_Angeles:20170220T123000
EXDATE;TZID=America/Los_Angeles:20170529T123000
RRULE:FREQ=WEEKLY;BYDAY=MO
DTSTAMP:20161007T103007Z
UID:up5l07cp40qiqia1evqjk02r9c#google.com
CREATED:20151116T002427Z
DESCRIPTION:
LAST-MODIFIED:20160829T190451Z
LOCATION:
SEQUENCE:2
STATUS:CONFIRMED
SUMMARY:iOS Today
TRANSP:OPAQUE
END:VEVENT
I am trying to build a calenderView for an android App using library https://github.com/alamkanak/Android-Week-View and this library https://github.com/mangstadt/biweekly to parse the ICS. However I am having problems creating Events that have recurrence, like in the example.
protected TreeMap<Integer,TreeMap<Integer,List<WeekViewEvent>>> doInBackground(String... params) {
ICalendar ical = Biweekly.parse(params[0]).first();
List<VEvent> le = ical.getEvents();
for(VEvent ev: le){
Calendar startTime = Calendar.getInstance();
startTime.setTimeInMillis(ev.getDateStart().getValue().getTime());
if(ev.getRecurrenceRule()!=null){
//Don't know what do I do here
}
int year = startTime.get(Calendar.YEAR);
int month = startTime.get(Calendar.MONTH);
//Log.v("Calendar",year+" Ano " + month +" Mes");
Calendar endTime = Calendar.getInstance();
if(ev.getDateEnd()==null){
continue;
}
endTime.setTimeInMillis(ev.getDateEnd().getValue().getTime());
WeekViewEvent we = new WeekViewEvent(0,ev.getSummary().getValue(),startTime,endTime);
if(eventos.get(we.getStartTime().get(Calendar.YEAR))==null){
TreeMap<Integer,List<WeekViewEvent>> as = new TreeMap<>();
List<WeekViewEvent> listEv = new ArrayList<>();
listEv.add(we);
as.put(we.getStartTime().get(Calendar.MONTH),listEv);
eventos.put(we.getStartTime().get(Calendar.YEAR),as);
}
else {
TreeMap<Integer, List <WeekViewEvent>> as = eventos.get(we.getStartTime().get(Calendar.YEAR));
if(as.containsKey(we.getStartTime().get(Calendar.MONTH))){
as.get(we.getStartTime().get(Calendar.MONTH)).add(we);
}else {
List<WeekViewEvent> listEv= new ArrayList<>();
listEv.add(we);
as.put(we.getStartTime().get(Calendar.MONTH),listEv);
}
}
}
return eventos;
}
Any help is appreciated.
Maybe you should give iCalendarAgenda a try at http://jfxtras.org/
It utilizes a new iCalendar API for Java called iCalendarFX. While I haven't used it on Android, I know that Tom Eugelink has got the Agenda control (that iCalendarAgenda extends) to run on Android.
I wrote iCalendarFx and it will easily parse the VEVENT you have there.
I am trying to convert pure java code into swift.But,I am having a little problem with setting the current time.I can get the current time in milliseconds.But I cant set the current time.Any help with that?
Here is my code
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
let now = NSDate()
var auctionDate = [String:String]()
let dateFormatter = NSDateFormatter()
dateFormatter.locale = NSLocale(localeIdentifier: "en_US")
var sdfDDMMYYYYEEE : NSDateFormatter!
sdfDDMMYYYYEEE.dateFormat = "dd/MM/yyyy (EEE)"
var sdfDDMMYYYY : NSDateFormatter!
sdfDDMMYYYY.dateFormat = "dd/MM/yyyy"
var sdfEEE : NSDateFormatter!
sdfEEE.dateFormat = "EEE"
// This is how i get the current time
println((now.timeIntervalSince1970)*1000 + 86400000.00)
for var i = 0; i < 5; i++ {
if sdfEEE.stringFromDate(now) == "Sun" {
// This is where i have to set my time with that ((now.timeIntervalSince1970)*1000 + 86400000.00)
i--;
continue;
}
auctionDate[(sdfDDMMYYYY.stringFromDate(now) as String)] = (sdfDDMMYYYYEEE.stringFromDate(now) as String)
// Here too I have to set my time
}
println(dateFormatter.stringFromDate(now))
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Here is the java code that I want to convert into swift code
import java.text.*;
import java.util.*;
public class DateTest{
Date now = new Date();
Map<String, String> myDate = new LinkedHashMap<String, String>();
myDate.put("", "All");
SimpleDateFormat sdfDDMMYYYYEEE = new SimpleDateFormat("dd/MM/yyyy (EEE)");
SimpleDateFormat sdfDDMMYYYY = new SimpleDateFormat("dd/MM/yyyy");
SimpleDateFormat sdfEEE = new SimpleDateFormat("EEE");
for (int i = 0; i < 5; i++) {
if (sdfEEE.format(now).equals("Sun")) {
now.setTime(now.getTime() + 86400000);
i--;
continue;
}
myDate.put(sdfDDMMYYYY.format(now), sdfDDMMYYYYEEE.format(now));
now.setTime(now.getTime() + 86400000);
}
}
Any help with setting the current time in swift.I am almost closing to my answer.
In your code you want to add seconds to time eince 1970. You're in luck, there is an initializer for that: NSDate(timeIntervalSince1970: NSTimeInterval)
let now = NSDate(timeIntervalSince1970: 86400000)
This will create a new NSDate and add 86400000 seconds to the time in seconds right now since 1970.
i m using jfreechart to draw a graph about a logger of operations in a computer.
ex:
1:2012/09/39/28 06:55:37 8 S 0x1c0c762 Terminal --geometry=134x35 --display :0.0 --role=Terminal-0x10591b0-16869-1343137248 --show-menubar --show-borders --hide-toolbars --working-directory /home/termier "Terminal", "Terminal" "Terminal - termier#akagi: ~"
2:2012/09/39/28 06:55:41 8 S 0x1600313 /usr/lib/xfce4/notifyd/xfce4-notifyd "xfce4-notifyd", "Xfce4-notifyd" "xfce4-notifyd"
for now , i can draw every point just like (2012/09/39/28 06:55:37,Terminal),scilicet: x-axis is 2012/09/39/28 06:55:37 , Y-axis is: Terminal (i use 1 to present Terminal ,as for other commands just like Terminal... 2:/usr/lib/xfce4/notifyd/xfce4-notifyd ,etc...)
but what i need is draw a block ,like:
terminal 1: _________S||||||
/usr/lib/xfce4/notifyd/xfce4-notifyd2:______________S||||||
com 3: _____S|||||
(S:start ,eg: 2000/12/12 09:22:10 start)
.....
(when the first command end, another one will be start ,i just can get the start, it means that the post command is the end time of the previous command)
but not: 1: S
2: S
3: S
here some codes to you.
private XYDataset createDataset() {
Calendar precal;
Calendar postcal;
this.flags = modelfocus.getListflag();
commands = modelfocus.getListCommand();
DateFormat formatedate = new SimpleDateFormat("yyyy/MM/ww/dd HH:mm:ss");
precal = Calendar.getInstance();
postcal = Calendar.getInstance();
for (int i = 0; i < countCom; i++) {
this.series[i] = new TimeSeries(commands.get(i));
}
for (Focus listTxt : modelfocus.getList()) {
try {
Date d = new Date();
d = formatedate.parse(listTxt.date2String());
System.out.println(d);
precal.setTime(d);
//postcal.setTime();
} catch (ParseException e) {
System.out.println("Can't change this date");
e.printStackTrace();
}
String eachCmd = listTxt.getCommand();
for (int i = 0; i < countCom; i++) {
if (eachCmd == commands.get(i)) {
series[i].addOrUpdate(new Second(precal.getTime()),
flags.get(i));
}
}
}
TimeSeriesCollection dataset = new TimeSeriesCollection();
for (int i = 0; i < countCom; i++) {
dataset.addSeries(this.series[i]);
}
return dataset;
}
Please can someone give help to solve this problem, thank you very much.
As shown in this example, you can change the Shape used to render the values of a time series. A Rectangle is shown below.
r.setSeriesShape(0, new Rectangle(-4, -4, 9, 9));
Just working on my java assignment and I've hit a brick wall I just cant seem to find a solution for - I'm not necessarily looking for an answer, even some ideas to what tools might help me :) Anyway here goes:
As the title says, I am looking to create a calendar object within an object within an Arraylist. Basically, as per the code below - I thought that when an instance of the Appointment object was created the link between the calendar object and the appointment object would be severed and I could reuse the Calendar object for the next appointment object. Unfortunately each object retains its reference to the calendar object, rather than create its own instance of the Calendar object =/.
Some background on the work:
Basically this piece of java code, scans the file and extracts the information out of it, makes sure its valid then creates an instance of the appropriate object within the one of the two arraylists. I'm working within constraints of my tutor who has specified that I must use an arraylist. Any help would greatly appreciated.
The constructor for the appointment class:
public Appointment (Patient patient, Provider provider, GregorianCalendar date, boolean standard, boolean attended)
Example Appointment Data
Appointment#84736254193#123456AF#22.30#20/12/2012#false#True
public AppointmentsManager (String path) {
this.path = path;
String[] fileLine;
boolean throwError = false;
DateFormat df = new SimpleDateFormat ("HH.mm dd/MM/yyyy");
df.setLenient(false);
GregorianCalendar calendar = new GregorianCalendar();
try {
Scanner input = new Scanner(new File(path));
String line;
while (input.hasNext()) {
line = input.nextLine();
fileLine = line.split("#");
if (fileLine.length < 0)
throw new IllegalArgumentException("Error: the data in the file is has not been delimited correctly. Please review");
if (fileLine[0].matches("Provider")) {
if (fileLine.length < 7)
throw new IllegalArgumentException("Error: the provider data in the file is incomplete. Please review");
persons.add(new Provider(fileLine[1], fileLine[2], fileLine[3], fileLine[4], fileLine[5],
fileLine[6]));
}
else if (fileLine[0].matches("Patient")) {
fileLine = line.split("#");
if (fileLine.length < 11)
throw new IllegalArgumentException("Error: the patient data in the file is incomplete. Please review");
for (int i = 0; i < persons.size(); i++) {
if (persons.get(i).getMedicare().matches(fileLine[10])) {
persons.add(new Patient(fileLine[1], fileLine[2], fileLine[3], fileLine[4], fileLine[5],
fileLine[6], fileLine[7], fileLine[8], Integer.parseInt(fileLine[9]),(Provider)persons.get(i)));
throwError = true;
}
}
if (throwError!=true) {
throw new IllegalArgumentException("Error: the provided Provider does not exist for Patient: " + fileLine[2]+", "+fileLine[1] +". Please review");
}
}
else if (fileLine[0].matches("Appointment")) {
fileLine = line.split("#");
if (fileLine.length < 7)
throw new IllegalArgumentException("Error: the appointment data in the file is incomplete. Please review");
if (!"true".equals(fileLine[5].toLowerCase()) && !"false".equals(fileLine[5].toLowerCase()))
throw new IllegalArgumentException("Error: the appointment data in the file is incorrect. Please review");
if (!"true".equals(fileLine[6].toLowerCase()) && !"false".equals(fileLine[6].toLowerCase()))
throw new IllegalArgumentException("Error: the appointment data in the file is incorrect. Please review");
//parse the fileLine parameters
calendar.setTime(df.parse(fileLine[3] + " " + fileLine[4]));
for (int i = 0; i < persons.size(); i++) {
if (persons.get(i).getMedicare().matches(fileLine[1])) {
for (int j = 0; j < persons.size(); j++) {
if (persons.get(j).getMedicare().matches(fileLine[2])) {
appointments.add(new Appointment((Patient) persons.get(i), (Provider) persons.get(j), calendar,
Boolean.parseBoolean(fileLine[5]), Boolean.parseBoolean(fileLine[6])));
throwError = true;
}
}
}
}
if (throwError!=true) {
throw new IllegalArgumentException("Error: the provided Provider or Patient does not exist in the system. Please review");
}
}
else
throw new IllegalArgumentException("Error: the data provided does not match a person, provider or appointment. Please review");
}
input.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParseException pe) {
// TODO Auto-generated catch block
throw new IllegalArgumentException("Error: the appointment date and time in the file is incorrect. Please review");
}
}
well you are sending same object to each appointment. If I understand it correctly, you want each appointment to have different calendar object. If so, just reinstantiate the calendar every time appointment is created, either in the appointment constructor or your method...
edit:
oh, I forgot, Calendar is singleton. Then I would suggest to keep only java.util.Date object in an Appointment - Calendar.getTime() creates new instance of Date.
Then you can dress it as Calendar in the getter -
public Calendar getAppointmentCalendar()
{
Calendar cal = Calendar.getInstance();
cal.setTime(this.appDate);
return cal;
}
The issue is that same calendar instance is getting passed to constructor each time. Instantiate a new Calendar instance inside the for loop where you are adding the appointment to the list. Passing a new instance would solve your issue.