// $Id: notificationExample.java,v 1.5 2002/05/21 00:16:34 mdean Exp $


/**
 * code to generate sample notification
 */
class notificationExample
{

    public static void main(String args[])
	throws Exception
    {
	java.text.DateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
	df.setTimeZone(java.util.TimeZone.getTimeZone("GMT"));

	com.hp.hpl.mesa.rdf.jena.model.Model model = new com.hp.hpl.mesa.rdf.jena.mem.ModelMem();

	// construct Notification
	com.hp.hpl.mesa.rdf.jena.model.Resource notification = model.createResource();
	model.add(notification,
		  com.hp.hpl.mesa.rdf.jena.vocabulary.RDF.type,
		  org.daml.sonat.vocabulary.mcda_notification_ont.MCDANotification);
	model.add(notification,
		  org.daml.sonat.vocabulary.notification_ont.from,
		  model.createResource("http://www.daml.org/2002/03/agents/agency#agent1")); // XXX - use current agent - #agent1 used as example even though it's an ENP agent rather than MCDA
	model.add(notification,
		  org.daml.sonat.vocabulary.notification_ont.to,
		  model.createResource("mailto:mdean@bbn.com")); // XXX - dynamically compute based on user for current agent
	model.add(notification,
		  org.daml.sonat.vocabulary.notification_ont.timestamp,
		  df.format(new java.util.Date())); // now
	model.add(notification,
		  org.daml.sonat.vocabulary.notification_ont.priority,
		  model.createResource("http://www.daml.org/2002/05/notification/notification-ont#high")); // XXX - genvocab should generate notification_ont.high
	model.add(notification,
		  org.daml.sonat.vocabulary.mcda_notification_ont.analysis,
		  model.createResource("http://www.daml.org/2002/05/mcda/mcdaExample#analysis1"));
	model.add(notification,
		  org.daml.sonat.vocabulary.mcda_notification_ont.oldBestAlternative,
		  model.createResource("http://www.daml.org/2002/05/mcda/mcdaExample#alternative1"));
	model.add(notification,
		  org.daml.sonat.vocabulary.mcda_notification_ont.newBestAlternative,
		  model.createResource("http://www.daml.org/2002/05/mcda/mcdaExample#alternative2"));
	model.add(notification,
		  org.daml.sonat.vocabulary.mcda_notification_ont.oldComputedValue,
		  24);
	model.add(notification,
		  org.daml.sonat.vocabulary.mcda_notification_ont.newComputedValue,
		  27);
	model.add(notification,
		  org.daml.sonat.vocabulary.mcda_notification_ont.summary,
		  "#alternative2 now favored over #alternative1 by 5");

	// construct NotificationMessage
	com.hp.hpl.mesa.rdf.jena.model.Resource message = model.createResource();
	model.add(message,
		  com.hp.hpl.mesa.rdf.jena.vocabulary.RDF.type,
		  org.daml.sonat.vocabulary.notification.NotificationMessage);
	model.add(message,
		  org.daml.sonat.vocabulary.notification.notification,
		  notification);

	// generate String containing DAML
	java.io.StringWriter daml = new java.io.StringWriter();
	java.io.PrintWriter writer = new java.io.PrintWriter(daml);
	writer.println("<?xml version='1.0' encoding='ISO-8859-1'?>");
	model.write(writer);
	writer.close();

	// print DAML
	System.out.println(daml.toString());

	// XXX - send DAML to Notification Agent
    }
}
