JAVA/CORBA CLASSES
import lotus.domino.*; import java.util.Vector; import java.lang.Float; public class JavaAgent extends AgentBase { public void NotesMain() { try { Session session = getSession(); AgentContext agentContext = session.getAgentContext(); // (Your code goes here) Document agentDoc = agentContext.getSavedData(); Database db = agentContext.getCurrentDatabase(); View view = db.getView("Weekly Sales"); Document doc = view.getFirstDocument(); if (!agentDoc.hasItem("MaxSales")) { agentDoc.replaceItemValue("MaxSales", "0"); agentDoc.save(true, true); agentDoc = agentContext.getSavedData(); } while (doc != null) { Vector mvalue = agentDoc.getItemValue("MaxSales"); Vector wvalue = doc.getItemValue("Weekly_Sales"); Float maxSales = new Float((String)mvalue.firstElement()); Float weeklySales = new Float((String)wvalue.firstElement()); if (weeklySales.floatValue() > maxSales.floatValue()) { agentDoc.replaceItemValue ("MaxSales", doc.getItemValue("Weekly_Sales")); agentDoc.replaceItemValue ("MaxSales_Salesperson", doc.getItemValue("Name")); } agentDoc.save(true, true); System.out.println("Best salesperson to date is " + agentDoc.getItemValue("MaxSales_Salesperson") + " who sold $" + agentDoc.getItemValue("MaxSales")); } } catch(Exception e) { e.printStackTrace(); } } }
See Also