有什么方法可以使用 Java 在 BMC Remedy 中一次创建多个记录?
Is there any way to create multiple records at once in BMC Remedy using Java?
一次获取ARServerUser上下文然后在循环中多次调用setEntry方法好不好,或者有更好的方法吗?
API 提供了这一点。查看 ARServerUser
javadoc:
它是这样使用的:
//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
请注意,上面的代码有一些未初始化的变量,因此不会 运行 原样(并且可能会抛出 ARBulkException
)
一次获取ARServerUser上下文然后在循环中多次调用setEntry方法好不好,或者有更好的方法吗?
API 提供了这一点。查看 ARServerUser
javadoc:
它是这样使用的:
//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
请注意,上面的代码有一些未初始化的变量,因此不会 运行 原样(并且可能会抛出 ARBulkException
)