Lotus Notes 8.5 : Create a meeting with java - java

I started to work with Lotus Notes 8.5, and i have to create meetings in Lotus by using Java, lotus.domino and Notes.jar.
So, to do this, i create a new Document and fill it with all the needed fields (i think). This is how i create my meeting :
Document newDocument = db.createDocument();
newDocument.appendItemValue("Body", "Create meeting from java.");
newDocument.appendItemValue("Notes", "Test Notes");
newDocument.appendItemValue("Chair", "Me");
newDocument.appendItemValue("Principal", "Me");
newDocument.appendItemValue("$altPrincipal", "Me");
newDocument.appendItemValue("ExcludeFromView", "D,S");
newDocument.appendItemValue("UpdateSeq", 1);
newDocument.appendItemValue("$CSVersion", "2");
newDocument.appendItemValue("$SMTPKeepNotesItems", "1");
newDocument.appendItemValue("$CSWISL", "$S:1,$L:1,$B:1,$R:1,$E:1,$W:1,$O:1,$M:1,RequiredAttendees:1,INetRequiredNames:1,AltRequiredNames:1,StorageRequiredNames:1,OptionalAttendees:1,INetOptionalNames:1,AltOptionalNames:1,StorageOptionalNames:1,ApptUNIDURL:1,STUnyteConferenceURL:1,STUnyteConferenceID:1,SametimeType:1,WhiteBoardContent:1,STRoomName:1");
newDocument.appendItemValue("WebDateTimeInit", "1");
newDocument.appendItemValue("OrgTable", "C0");
newDocument.appendItemValue("$AlarmDisabled", "1");
newDocument.appendItemValue("$HFFlags", "1");
newDocument.appendItemValue("Form", "Appointment");
newDocument.appendItemValue("$FromPreferredLanguage", "fr");
newDocument.appendItemValue("ApptUNID", "267DEFCD6ADE4EF8C1257DF600464A1B642");
newDocument.appendItemValue("$LangChair", "");
newDocument.appendItemValue("AppointmentType", "3");
newDocument.appendItemValue("$TableSwitcher", "Description");
newDocument.appendItemValue("OnlineMeeting", "");
newDocument.appendItemValue("From", "Me");
newDocument.appendItemValue("AltChair", "Me");
newDocument.appendItemValue("OnlinePlace", "");
newDocument.appendItemValue("IsBroadcast", "");
newDocument.appendItemValue("$ExpandGroups", 3);
newDocument.appendItemValue("IsTeamCalendar", "");
newDocument.appendItemValue("Importance", "");
newDocument.appendItemValue("OrgConfidential", "");
newDocument.appendItemValue("Subject", "Meeting test from Java");
newDocument.appendItemValue("PreventCounter", "");
newDocument.appendItemValue("Location", "R1");
newDocument.appendItemValue("RoomToReserve", "");
newDocument.appendItemValue("Resources", "");
newDocument.appendItemValue("$PaperColor", 1);
newDocument.appendItemValue("STRecordMeeting", "");
newDocument.appendItemValue("WhiteBoardContent", "");
newDocument.appendItemValue("Categories", "");
newDocument.appendItemValue("$BorderColor", "7F96A3");
newDocument.appendItemValue("$WatchedItems", "$S,$L,$B,$R,$E,$W,$O,$M,RequiredAttendees,INetRequiredNames,AltRequiredNames,StorageRequiredNames,OptionalAttendees,INetOptionalNames,AltOptionalNames,StorageOptionalNames,ApptUNIDURL,STUnyteConferenceURL,STUnyteConferenceID,SametimeType,WhiteBoardContent,STRoomName");
newDocument.appendItemValue("CalForwardChairNotificationTo", "");
newDocument.appendItemValue("ReturnReceipt", "");
newDocument.appendItemValue("PreventDelegate", "");
newDocument.appendItemValue("EnterSendTo", "");
newDocument.appendItemValue("EnterCopyTo", "");
newDocument.appendItemValue("EnterBlindCopyTo", "");
newDocument.appendItemValue("ConferenceCallInfo", "");
newDocument.appendItemValue("SchedulerSwitcher", "1");
newDocument.appendItemValue("$Abstract", "");
newDocument.appendItemValue("StartTimeZone", "Z=-1$DO=1$DL=3 -1 1 10 -1 1$ZN=Western/Central Europe");
newDocument.appendItemValue("EndTimeZone", "Z=-1$DO=1$DL=3 -1 1 10 -1 1$ZN=Western/Central Europe");
newDocument.appendItemValue("NewStartTimeZone", "");
newDocument.appendItemValue("NewEndTimeZone", "");
newDocument.appendItemValue("Encrypt", "Représentation invalide. (undefined)");
newDocument.appendItemValue("Sign", "");
newDocument.appendItemValue("MeetingType", "");
newDocument.appendItemValue("$PublicAccess", "1");
newDocument.appendItemValue("StartDate", "27/02/2015");
newDocument.appendItemValue("StartTime", "11:00:00");
newDocument.appendItemValue("STARTDATETIME", s.createDateTime(new GregorianCalendar(2015, 02, 27, 11, 0, 0)));
newDocument.appendItemValue("EndDate", "27/02/2015");
newDocument.appendItemValue("EndTime", "13:00:00");
newDocument.appendItemValue("EndDateTime", s.createDateTime(new GregorianCalendar(2015, 02, 27, 13, 0, 0)));
newDocument.appendItemValue("CalendarDateTime", s.createDateTime(new GregorianCalendar(2015, 02, 27, 11, 0, 0)));
newDocument.appendItemValue("_ViewIcon", 158);
newDocument.appendItemValue("$ShowComments", "Normal");
newDocument.appendItemValue("$ShowDescription", "Show");
newDocument.appendItemValue("$BusyName", "Me");
newDocument.appendItemValue("$BusyPriority", "1");
newDocument.appendItemValue("SequenceNum", 2);
newDocument.appendItemValue("$CSTrack", "Imported from my contacts at 02/24/2015 14:00:17");
newDocument.appendItemValue("$NoPurge", s.createDateTime(new GregorianCalendar(2015, 02, 27, 13, 0, 0)));
newDocument.appendItemValue("$UpdatedBy", "Me");
newDocument.appendItemValue("$Revisions", s.createDateTime(new GregorianCalendar(2015, 02, 24, 13, 48, 31)));
newDocument.appendItemValue("tmpUseLongDate", s.createDateTime(new GregorianCalendar(2015, 02, 27, 11, 0, 0)));
newDocument.appendItemValue("tmpEventLabel", "Meeting from Java (tmpEventLabel)");
newDocument.appendItemValue("dispRepeatText", "Meeting from Java (dispRepeatText)");
newDocument.appendItemValue("tmpHideTimeZone", "");
newDocument.appendItemValue("tmpStartDate1", "27/02/2015");
newDocument.save();
When i came back to Lotus, the meeting is created and shown in the calendar.
The problem is, whatever field i add or remove, when i click on this meeting, Lotus throw me an error, saying (approximate translation from french):
Field : 'tmpStartDate1' : Temporary data required for operator or # function
So i add this new field in java, launch the program, create a meeting, and...
Field : 'tmpHideTimeZone' : Temporary data required for operator or # function
For now, it is the 5th field Lotus asked me with this message....
All 'tmp******' fields are missing, but i don't know them. I thought those fields could be generated by Lotus, because of the 'tmp', but how ?
I compare with other meetings created with Lotus Notes, and there are no such 'tmp' fields.
Any ideas ?
EDIT :
I tried this :
newDocument.computeWithForm(true, true);
It throws a NotesException if your document isn't in a good format.
When i execute my code (approximate translation again...) :
NotesException: Incorrect data type in the field.
I tried computeWithForm in another program where I create and add a contact to Lotus, and i didn't get any errors.
So indeed, there is a problem with meeting's fields...
EDIT :
Any new ideas ? I am a bit confused about how to develop on this software....

Items have types too ! Also a date is not a string, a date is a complicated animal, looks innocuous at first sight, but can bite very hard.
The Document.appendItemValue method coerces the item to be of Text type.
For date/time (not temporary ;-) items you should use Document.ReplaceItemValueCustomData and pass it an argument of class DateTime.

Related

Mesuring Derby speed with hibernate. Strange values

I'm writing application to mesure speed of CRUD with hibernate for Derby.
This is my function :
#Override
public BulkTestResult testBulkInsertScenario(Long volume, Integer repeat) {
StopWatch sw = new StopWatch();
BulkTestResult bulkTestResult = new BulkTestResult();
bulkTestResult.setStartDate(Instant.now());
bulkTestResult.setCountTest(volume);
bulkTestResult.setTestRepeat(repeat);
familyService.clear();
for(int i =0; i < repeat; i++) {
List<ProjectEntity> projects = dataAnonymization.generateProjectEntityList(volume);
runBulkTest(sw, bulkTestResult, projects, true);
}
bulkTestResult.setEndDate(Instant.now());
return bulkTestResult;
}
private void runBulkTest(StopWatch sw, BulkTestResult bulkTestResult, List<ProjectEntity> projects, boolean resetAfter) {
sw.reset();
sw.start();
familyService.save(projects);
sw.stop();
bulkTestResult.addMsSpeedResult(sw.getTime());
if (resetAfter) familyService.clear();
sw.reset();
}
clear method remove all record from DB.
The problem that I have is values that I recieved as output of application.
Testing data : 1000 record, and 10 repeats
Example speed values recieved running this test few times:
311, 116, 87, (...)38
32, 27, 30, (...) 24
22, 19, 18, (...) 21
19, 18, 18, (...) 19
Why there are so many difference and why for first time insert is always slower ?
It could be any hardware acceleration ?
I found solution.
This issue is related to optimalization. After Disable JIT, recieved values are correct.
-Djava.compiler=NONE -Xint

How to use DateTime Object split Interval Object

I have an Interval object:
Interval firstInterval =
new Interval(new DateTime(2017,06,26,07,55,30),new DateTime(2017,06,26,22,55,30));
and:
DateTime nightToDay = new DateTime(2017, 06, 26, 8, 0, 0);
DateTime dayToNight = new DateTime(2017, 06, 26, 22, 0, 0);
I want to get a Interval[]:
[
[2017-06-26 07:55:30 ~ 2017-06-26 08:00:00],
[2017-06-26 08:00:00 ~ 2017-06-26 22:00:00],
[2017-06-26 22:00:00 ~ 2017-06-26 22:55:30]
]
Of course, these parameters aren't fixed, and it is just an example.
Assuming that your general case is:
have a first interval with start and end
receives a nightToDay and dayToNight dates
output must contain 3 intervals:
start to nightToDay
nightToDay to dayToNight
dayToNight to end
And for each case above, you also need to check if the start of the interval is before the end.
If that's what you need, just do:
List<Interval> list = new ArrayList<Interval>();
if (firstInterval.getStart().isBefore(nightToDay)) {
list.add(new Interval(firstInterval.getStart(), nightToDay));
}
if (nightToDay.isBefore(dayToNight)) {
list.add(new Interval(nightToDay, dayToNight));
}
if (dayToNight.isBefore(firstInterval.getEnd())) {
list.add(new Interval(dayToNight, firstInterval.getEnd()));
}
The list will contain all the Interval objects you need.
If you need an array, it's easy to convert the list:
Interval[] intervals = new Interval[list.size()];
intervals = list.toArray(intervals);
The intervals array will have all the intervals created.

How to return a list contains Object in sqlalchemy in python, is similar to List<OrderInfo> in java

i want to get a list which contains entire OrderInfo Object, for example, if i do this, it is result which the result i want to.
def find_all(self):
result_list = []
orderDao = DaoUtil.DaoGeneric()
session = orderDao.getSession()
try:
for row in session.query(OrderInfo).all():
result_list.append({
'id':row.id,
'name': row.name,
'age': row.age,
'create_time': row.create_time.strftime("%Y-%m-%d %H:%M:%S"),
'update_time': row.update_time.strftime("%Y-%m-%d %H:%M:%S"),
'version': row.version
})
session.commit()
except Exception, e:
print e
session.rollback()
return result_list
but i want to a list which contains OrderInfo object from the query, because the result which the query return have other columns (the simple list of all DeclarativeBase's instances.) except OrderInfo{id,name,age,create_time,update_time,version}, the query do not return OrderInfo object directly. the following which i want to:
def find_all(self):
result_list = []
orderDao = DaoUtil.DaoGeneric()
session = orderDao.getSession()
try:
for row in session.query(OrderInfo).all():
result_list.append(row.orderInfo) // if the row has a property for orderInfo Object, because the result which java can achieve , the example for java is : List<OrderInfo> orderList = session.query(); please help to achieve it
session.commit()
except Exception, e:
print e
session.rollback()
return result_list
beacause i use sqlalchemy in python just now, i am not very sure. How to get a list which contains OrderInfo Object from query in sqlalchemy
#univerio
for row in session.query(OrderInfo).all():
the line of variable 's row which includes the following column:
_decl_class_registry,
_sa_class_manager,
_sa_instance_state,
metadata,
query,
id,
name,
age,
create_time,
update_time ,
version
only this (OrderInfo{id, name, age, create_time,update_time,version}) is what i want to get, other columns which i do not want to get.
OrderInfo:
from sqlalchemy import Column, Integer, String, Date, DateTime
from sqlalchemy.ext.declarative import declarative_base
Base=declarative_base()
class OrderInfo(Base):
__tablename__ = 'order_info'
# __table__ = 'order_info'
id = Column(Integer, primary_key=True)
name = Column(String(100))
age = Column(Integer)
create_time = Column(Date)
update_time = Column(Date)
version = Column(Integer)
#univerio, i write here because the comments has limit of words, it achieve this result, like this:
for row in session.query(OrderInfo).all():
result_list.append({
'id':row.id,
'name': row.name,
'age': row.age,
'create_time': row.create_time.strftime("%Y-%m-%d %H:%M:%S"),
'update_time': row.update_time.strftime("%Y-%m-%d %H:%M:%S"),
'version': row.version
})
the OrderInfo has very few columns, if the OrderInfo object has more than serveral hundred columns, but it will take a long time, so i want find the result which can simple achieve this function that is similar to List in Java
#univerio,
i find the answer which i want to get:
def find_all(self):
result_list = []
orderDao = DaoUtil.DaoGeneric()
session = orderDao.getSession()
try:
for row in session.query(OrderInfo).all():
result_list.append(DictUtil.object_as_dict(row))
session.commit()
except Exception, e:
print e
session.rollback()
return result_list
def object_as_dict(obj):
result = {instance.key: getattr(obj, instance.key) for instance in inspect(obj).mapper.column_attrs}
print result
return result
output :
[
{'updateTime': datetime.datetime(2017, 6, 15, 13, 56, 16), 'bankName': u'ICBC', 'bankNo': u'6228480666622220011', 'createTime': datetime.datetime(2017, 6, 15, 13, 56, 16), u'version': 0, u'id': 1},
{'updateTime': datetime.datetime(2017, 6, 15, 13, 57, 40), 'bankName': u'ICBC', 'bankNo': u'6228480666622220011', 'createTime': datetime.datetime(2017, 6, 15, 13, 57, 40), u'version': 0, u'id': 2},
{'updateTime': datetime.datetime(2017, 6, 15, 13, 58), 'bankName': u'ICBC', 'bankNo': u'6228480666622220011', 'createTime': datetime.datetime(2017, 6, 15, 13, 58), u'version': 0, u'id': 3}
]

Weka linear regression doesn't load

I've been following this tutorial on how to use WEKA and I have reached a point where my code will not run. I realize that I am using a different version of Weka 3.8 as opposed to 3.6 as shown in the tutorial but I thought I made the necessary changes. I get an error message on the line linearRegression.buildClassifier(dataset); and I don't know why.
Error message:
Jul 19, 2016 10:47:21 AM com.github.fommil.netlib.BLAS <clinit>
WARNING: Failed to load implementation from: com.github.fommil.netlib.NativeSystemBLAS
Jul 19, 2016 10:47:21 AM com.github.fommil.netlib.BLAS <clinit>
WARNING: Failed to load implementation from: com.github.fommil.netlib.NativeRefBLAS
Jul 19, 2016 10:47:21 AM com.github.fommil.netlib.LAPACK <clinit>
WARNING: Failed to load implementation from: com.github.fommil.netlib.NativeSystemLAPACK
Jul 19, 2016 10:47:21 AM com.github.fommil.netlib.LAPACK <clinit>
WARNING: Failed to load implementation from: com.github.fommil.netlib.NativeRefLAPACK
Code:
// Define each attribute (or column), and give it a numerical column
// number
// Likely, a better design wouldn't require the column number, but
// would instead get it from the index in the container
Attribute a1 = new Attribute("houseSize", 0);
Attribute a2 = new Attribute("lotSize", 1);
Attribute a3 = new Attribute("bedrooms", 2);
Attribute a4 = new Attribute("granite", 3);
Attribute a5 = new Attribute("bathroom", 4);
Attribute a6 = new Attribute("sellingPrice", 5);
// Each element must be added to a FastVector, a custom
// container used in this version of Weka.
// Later versions of Weka corrected this mistake by only
// using an ArrayList
ArrayList<Attribute> attrs = new ArrayList<>();
attrs.add(a1);
attrs.add(a2);
attrs.add(a3);
attrs.add(a4);
attrs.add(a5);
attrs.add(a6);
// Each data instance needs to create an Instance class
// The constructor requires the number of columns that
// will be defined. In this case, this is a good design,
// since you can pass in empty values where they exist.
Instance i1 = new DenseInstance(6);
i1.setValue(a1, 3529);
i1.setValue(a2, 9191);
i1.setValue(a3, 6);
i1.setValue(a4, 0);
i1.setValue(a5, 0);
i1.setValue(a6, 205000);
Instance i2 = new DenseInstance(6);
i1.setValue(a1, 3247);
i1.setValue(a2, 10061);
i1.setValue(a3, 5);
i1.setValue(a4, 1);
i1.setValue(a5, 1);
i1.setValue(a6, 224900);
Instance i3 = new DenseInstance(6);
i1.setValue(a1, 4032);
i1.setValue(a2, 10150);
i1.setValue(a3, 5);
i1.setValue(a4, 0);
i1.setValue(a5, 1);
i1.setValue(a6, 197900);
Instance i4 = new DenseInstance(6);
i1.setValue(a1, 2397);
i1.setValue(a2, 14156);
i1.setValue(a3, 4);
i1.setValue(a4, 1);
i1.setValue(a5, 0);
i1.setValue(a6, 189900);
Instance i5 = new DenseInstance(6);
i1.setValue(a1, 2200);
i1.setValue(a2, 9600);
i1.setValue(a3, 4);
i1.setValue(a4, 0);
i1.setValue(a5, 1);
i1.setValue(a6, 195000);
Instance i6 = new DenseInstance(6);
i1.setValue(a1, 3536);
i1.setValue(a2, 19994);
i1.setValue(a3, 6);
i1.setValue(a4, 1);
i1.setValue(a5, 1);
i1.setValue(a6, 325000);
Instance i7 = new DenseInstance(6);
i1.setValue(a1, 2983);
i1.setValue(a2, 9365);
i1.setValue(a3, 5);
i1.setValue(a4, 0);
i1.setValue(a5, 1);
i1.setValue(a6, 230000);
// Each Instance has to be added to a larger container, the
// Instances class. In the constructor for this class, you
// must give it a name, pass along the Attributes that
// are used in the data set, and the number of
// Instance objects to be added. Again, probably not ideal design
// to require the number of objects to be added in the constructor,
// especially since you can specify 0 here, and then add Instance
// objects, and it will return the correct value later (so in
// other words, you should just pass in '0' here)
Instances dataset = new Instances("housePrices", attrs, 7);
dataset.add(i1);
dataset.add(i2);
dataset.add(i3);
dataset.add(i4);
dataset.add(i5);
dataset.add(i6);
dataset.add(i7);
// In the Instances class, we need to set the column that is
// the output (aka the dependent variable). You should remember
// that some data mining methods are used to predict an output
// variable, and regression is one of them.
dataset.setClassIndex(dataset.numAttributes() - 1);
// Create the LinearRegression model, which is the data mining
// model we're using in this example
linearRegression = new LinearRegression();
try {
// This method does the "magic", and will compute the regression
// model. It takes the entire dataset we've defined to this point
// When this method completes, all our "data mining" will be
// complete
// and it is up to you to get information from the results
linearRegression.buildClassifier(dataset);
} catch (Exception e) {
e.printStackTrace();
}
}
That is not an error, but a warning. Weka cannot find some Linear Algebra Libraries (LAPACK, BLAS) during the startup of your little java app. It does not need them anyway, for the linear regression task of fitting a curve to 7 data points.
(Read this for reference https://github.com/fommil/netlib-java)
To get rid of the message, you can redirect the STDERR output of your program to /dev/null .
Using the Package Manager, I just installed the Weka Package netlibNativeLinux (or try netlibNativeWindows or netlibOSX, whatever), included its jars to the build-path, and got this warning:
Jul 20, 2016 10:20:32 AM com.github.fommil.jni.JniLoader liberalLoad
INFO: successfully loaded /tmp/jniloader5044252696376965086netlib-native_system-linux-x86_64.so
Jul 20, 2016 10:20:32 AM com.github.fommil.jni.JniLoader load
INFO: already loaded netlib-native_system-linux-x86_64.so
I also got the output 219328.35717359098 - just as the tutorial said. Did you forget to include the last lines of codes from the tutorial, especially
System.out.println(myHouseValue);
?

StringUtils.containsIgnoreCase() is returning wrong result

i have two values:
String a = "00tz"; // (Eclipse internal debug value: [, 0, 0, t, z]) and
String b = "tz"; // (Eclipse internal debug value: [, t, z])
I am reading this values from an ArrayList like
for (String a : stringLists) {
...
}
I get "false" when i compare this two values with StringUtils.containsIgnoreCase(a,b). But it should return true because "tz" is existing in "00tz".
Im using apache.commons.lang3.StringUtils. To change the values a & b didn't worked. The length of "a" is 5 and "b" is 3. It also returns false when i use a.contains(b).
These are the results when i output the value with
System.out.println(Arrays.toString(a.getBytes(StandardCharsets.UTF_8)));
a:[-17, -69, -65, 48, 48, 118, 119]
b:[-17, -69, -65, 118, 119]
Im reading this values from a .txt file which contains several values like this. I read it in this way:
File fileA = new File("test/a.txt");
File fileB = new File("test/b.txt");
lista = (ArrayList<String>) FileUtils.readLines(fileA, "utf-8");
listb = (ArrayList<String>) FileUtils.readLines(fileB, "utf-8");
Do you have an idea what the problem is?
Thank you!

Categories

Resources