JAVA/CORBA クラス


例:buildCollection メソッド
次のエージェントは、現在のデータベースのフォーム要素およびビュー要素を基にノートコレクションを作成します。作業は関数で行われ、入力パラメータに従ってノートコレクションが作成、構築され、削除されます。

import lotus.domino.*;

public class JavaAgent extends AgentBase {

Stream stream = null;
NoteCollection nc = null;
DxlExporter exporter = null;

public void NotesMain() {

try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();

// (Your code goes here)
Database db = agentContext.getCurrentDatabase();

// Create stream and note collection
stream = session.createStream();
nc = db.createNoteCollection(false);
exporter = session.createDxlExporter();

// Export forms
exportFormView(true, false);

// Export views
exportFormView(false, true);

// Export forms and views
exportFormView(true, true);

// Test bad call
exportFormView(false, false);

} catch(Exception e) {
e.printStackTrace();
}
}

void exportFormView(boolean form, boolean view) {

try {
// Check parameters and set up file name
String filename = null;
if (form & view)
filename = "formview";
else if (form)
filename = "form";
else if (view)
filename = "view";
else {
System.out.println("Form and view both false - no action");
return;
}

// Open DXL file named after type of action
filename = "c:\\dxl\\" + filename + ".dxl";
if (!stream.open(filename)) {
System.out.println("Could not open " + filename);
return;
}
stream.truncate();

// Create note collection
nc.selectAllNotes(false);
if (form) {
nc.setSelectForms(true);
nc.setSelectSubforms(true);
nc.setSelectSharedFields(true);
}
if (view) {
nc.setSelectViews(true);
nc.setSelectFolders(true);
}
nc.buildCollection();

// Export note collection as DXL
String output = exporter.exportDxl(nc);
stream.writeText(output);
System.out.println("DXL exported to " + filename);
stream.close();
nc.clearCollection();

return;

} catch(Exception e) {
e.printStackTrace();
}
}
}

関連項目