Is it good to get the ARServerUser context once and call the setEntry method multiple times in the loop or, is there any better way to do this?
Asked
Active
Viewed 472 times
1 Answers
1
The API provides this. Look in the ARServerUser
javadoc:
It is used like this:
//connect to AR server
ARServerUser server = new ARServerUser();
server.setServer("localhost");
server.setUser("Demo");
server.setPassword("");
// begin bulk transaction
server.beginBulkEntryTransaction();
//create and submit Entry Objects
for(int x = 0; x < 10; x++){
try {
Entry entry = new Entry();
entry.put(Constants.AR_CORE_SUBMITTER, new Value(submitter));
entry.put(Constants.AR_CORE_STATUS,new Value(status, DataType.ENUM));
entry.put(Constants.AR_CORE_SHORT_DESCRIPTION, new Value(shortDesc));
entryIdOut = server.createEntry(formName, entry);
} catch (ARException e) {
ARExceptionHandler(e, "Cannot create the entry." );
}
}
//Commit Bulk transaction: all entries are saved to Remedy
List<BulkEntryReturn> bulkIds = server.endBulkEntryTransaction(Constants.AR_BULK_ENTRY_ACTION_SEND);
//bulkIds now contains all the entry Ids for your committed entries
Note that the code above has some uninitialized variables, so will not run as is (and may throw an ARBulkException
)

JoSSte
- 2,953
- 6
- 34
- 54
-
please let me know what the last line `server.endBulkEntryTransaction(Constants.AR_BULK_ENTRY_ACTION_SEND)` is doing and what is the meaning of the arguments within this menthod. – Dusayanta Prasad Feb 17 '20 at 05:55
-
This is basically the commit. if you do not call `server.beginBulkEntryTransaction();` each call to `server.createEntry(formName, entry);` will commit the entry and the program will wait for the result. `server.endBulkEntryTransaction()` is the same as ´commit´ in SQL – JoSSte Feb 17 '20 at 08:59