.

christy [2001-12-09 15:11:32]
.
Filename
services/AlertService.java
services/EventService.java
services/MapService.java
services/NYCPassListService.java
services/ResidentsListService.java
diff --git a/services/AlertService.java b/services/AlertService.java
index e110628..fcd53fa 100644
--- a/services/AlertService.java
+++ b/services/AlertService.java
@@ -1 +1 @@
-package psl.habitats.services;


import psl.habitats.*;





import java.awt.*;
import java.awt.event.*;
import javax.swing.*;





import java.util.Date;


import java.util.Vector;


import java.util.Hashtable;


import java.util.Enumeration;





public class AlertService implements ServiceInterface {


  private static final String myDescription = "AlertService";


  Habitat masterHabitat = null;


  public void initialize(Habitat _h) {


    masterHabitat = _h;


  }


  public String getDescription(){


    return myDescription;


  }


  public String getDetailDescription(){


    StringBuffer _stringBuffer = new StringBuffer();


    _stringBuffer.setLength(0);


    _stringBuffer.append("<html><body>");


    _stringBuffer.append("<h1>" + getDescription() + "</h1>");


    _stringBuffer.append("<table border=4>");


    _stringBuffer.append("<tr><td>Purpose</td><td>Hit Panic Button</td></tr>");


    _stringBuffer.append("<tr><td>Availablity</td><td>Selected</td></tr>");


    _stringBuffer.append("<tr><td>Monitor</td><td>True</td></tr>");


    _stringBuffer.append("<tr><td>Monitor-Mode</td><td>Text</td></tr>");


    _stringBuffer.append("</table>");


    _stringBuffer.append("</body></html>");


    return _stringBuffer + "";


  }


  private JPanel panel;


  public JPanel startDisplay() {


    return (panel = new JPanel());


  }





  private static final String key1 = "First_Name";


  private static final String key2 = "Last_Name";


  private static final String key3 = "Boarding_City";


  private static final String key4 = "Boarding_Date";


  private static final String key5 = "Address";


  private static final String key6 = "Telephone";


  private static final String key7 = "SSN";


  private static final String key8 = "Age";


  private static final String key9 = "Image";





  public Hashtable performService(String _senderService, Hashtable ipList) {


    StringBuffer _stringBuffer = new StringBuffer();


    _stringBuffer.setLength(0);


    _stringBuffer.append("<html><body>\n");


    _stringBuffer.append("<h1>" + getDescription() + "</h1>\n");


    _stringBuffer.append("<table border=4>\n");


    for (Enumeration e=ipList.keys(); e.hasMoreElements(); ) {


      String key = e.nextElement().toString();


      if (key.equals(key9)) continue; 


      _stringBuffer.append("<tr><td>"+key+"</td><td>"+ipList.get(key)+"</td></tr>\n");


    }


    _stringBuffer.append("<tr><td colspan=2><img src="+ipList.get(key9)+"></td></tr>\n");


    _stringBuffer.append("</table>\n");


    _stringBuffer.append("</body></html>\n");





    final JLabel label = new JLabel("" + _stringBuffer);


    JOptionPane.showMessageDialog(null, label, "Alert Service", JOptionPane.WARNING_MESSAGE);

    /** Janak's lame attempt at getting flashing to work: either flash
     * while the JOptionPane is up (Thread must start before
     * showMessageDialog), or by using a JDialog with a custom border
     */

//     new Thread() {
//       public void run() {
// 	try {
// 	  for(int i=0; i < 10; i++) {
// 	    label.setBackground(Color.red);
// 	    Thread.currentThread().sleep(500);
// 	    label.setBackground(Color.black);
// 	    Thread.currentThread().sleep(500);
// 	  }
// 	} catch(InterruptedException ie) { ; }
//       }
//     }.start();


//     final JDialog d = new JDialog();

//     d.setLayout(new BorderLayout());

//     JLabel alertLabel = new JLabel("ALERT!", SwingConstants.CENTER);
//     d.add(alertLabel, "North");
//     d.add(label, "Center");
//     JButton okButton = new JButton("OK");
//     okButton.addActionListener(new ActionListener() {
// 	public void actionPerformed(ActionEvent e) {
// 	  d.dispose();
// 	}
//       });
//     d.add(okButton, "South");
    
//     d.pack();
//     d.setVisible(true);

    masterHabitat.log("" + _stringBuffer);


    System.out.println("JUST LOGGED: " + _stringBuffer);





    return null;


  }


}
\ No newline at end of file
+package psl.habitats.services;

import psl.habitats.*;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

import java.util.Date;
import java.util.Vector;
import java.util.Hashtable;
import java.util.Enumeration;


public class AlertService implements ServiceInterface {
    
    private static final String myDescription = "AlertService";
    Habitat masterHabitat = null;
    
    public void initialize(Habitat _h) {
	masterHabitat = _h;
    }
    
    public String getDescription(){
	return myDescription;
    }
    
    public String getDetailDescription(){
	StringBuffer _stringBuffer = new StringBuffer();
	_stringBuffer.setLength(0);
	_stringBuffer.append("<html><body>");
	_stringBuffer.append("<h1>" + getDescription() + "</h1>");
	_stringBuffer.append("<table border=4>");
	_stringBuffer.append("<tr><td>Purpose</td><td>Hit Panic Button</td></tr>");
	_stringBuffer.append("<tr><td>Availablity</td><td>Selected</td></tr>");
	_stringBuffer.append("<tr><td>Monitor</td><td>True</td></tr>");
	_stringBuffer.append("<tr><td>Monitor-Mode</td><td>Text</td></tr>");
	_stringBuffer.append("</table>");
	_stringBuffer.append("</body></html>");
	
	return _stringBuffer + "";
    }
    
    private JPanel panel;
    public JPanel startDisplay() {
	return (panel = new JPanel());
    }
    
    private static final String key1 = "First_Name";
    private static final String key2 = "Last_Name";
    private static final String key3 = "Boarding_City";
    private static final String key4 = "Boarding_Date";
    private static final String key5 = "Address";
    private static final String key6 = "Telephone";
    private static final String key7 = "SSN";
    private static final String key8 = "Age";
    private static final String key9 = "Image";
    
    public Hashtable performService(String _senderService, Hashtable ipList) {
	StringBuffer _stringBuffer = new StringBuffer();
	
	_stringBuffer.setLength(0);
	_stringBuffer.append("<html><body>\n");
	_stringBuffer.append("<h1>" + getDescription() + "</h1>\n");
	_stringBuffer.append("<table border=4>\n");
	
	for (Enumeration e=ipList.keys(); e.hasMoreElements(); ) {
	    String key = e.nextElement().toString();
	    
	    if (key.equals(key9)) continue; 
	    _stringBuffer.append("<tr><td>"+key+"</td><td>"+ipList.get(key)+"</td></tr>\n");
	    
	}
	
	_stringBuffer.append("<tr><td colspan=2><img src="+ipList.get(key9)+"></td></tr>\n");
	_stringBuffer.append("</table>\n");
	_stringBuffer.append("</body></html>\n");
	
	final JLabel label = new JLabel("" + _stringBuffer);
	
	JOptionPane.showMessageDialog(null, label, "Alert Service", JOptionPane.WARNING_MESSAGE);

	/** Janak's lame attempt at getting flashing to work: either flash
	 * while the JOptionPane is up (Thread must start before
	 * showMessageDialog), or by using a JDialog with a custom border
	 */
	
	//     new Thread() {
	//       public void run() {
	// 	try {
// 	  for(int i=0; i < 10; i++) {
// 	    label.setBackground(Color.red);
// 	    Thread.currentThread().sleep(500);
// 	    label.setBackground(Color.black);
// 	    Thread.currentThread().sleep(500);
// 	  }
// 	} catch(InterruptedException ie) { ; }
//       }
//     }.start();


//     final JDialog d = new JDialog();

//     d.setLayout(new BorderLayout());

//     JLabel alertLabel = new JLabel("ALERT!", SwingConstants.CENTER);
//     d.add(alertLabel, "North");
//     d.add(label, "Center");
//     JButton okButton = new JButton("OK");
//     okButton.addActionListener(new ActionListener() {
// 	public void actionPerformed(ActionEvent e) {
// 	  d.dispose();
// 	}
//       });
//     d.add(okButton, "South");
    
//     d.pack();
//     d.setVisible(true);

	masterHabitat.svclog(myDescription, "" + _stringBuffer);

	System.out.println("JUST LOGGED: " + _stringBuffer);
	
	return null;
    }
}
\ No newline at end of file
diff --git a/services/EventService.java b/services/EventService.java
index aec5f2a..276e454 100644
--- a/services/EventService.java
+++ b/services/EventService.java
@@ -9,267 +9,297 @@ import java.util.Hashtable;
 import java.util.Enumeration;

 public class EventService implements ServiceInterface {
-  String myDescription = "Event_Manager";
-  Habitat masterHabitat = null;
-
-  private final Hashtable informationCatalogue = new Hashtable();
-
-  private static final String key1 = "First_Name";
-  private static final String key2 = "Last_Name";
-  private static final String key3 = "Boarding_City";
-  private static final String key4 = "Boarding_Date";
-  private static final String key5 = "Address";
-  private static final String key6 = "Telephone";
-  private static final String key7 = "SSN";
-  private static final String key8 = "Age";
-  private static final String key9 = "Image";
-
-  public void initialize(Habitat _h){
-    masterHabitat = _h;
-  }
-  public String getDescription() {
-    return myDescription;
-  }
-  public String getDetailDescription(){
-    StringBuffer _stringBuffer = new StringBuffer();
-    _stringBuffer.setLength(0);
-    _stringBuffer.append("<html><body>");
-    _stringBuffer.append("<h1>" + getDescription() + "</h1>");
-    _stringBuffer.append("<table border=4>");
-    _stringBuffer.append("<tr><td>Purpose</td><td>Receive and Update Events </td></tr>");
-    _stringBuffer.append("<tr><td>Availablity</td><td>Local</td></tr>");
-    _stringBuffer.append("<tr><td>Monitor</td><td>True</td></tr>");
-    _stringBuffer.append("<tr><td>Monitor-Mode</td><td>Text</td></tr>");
-    _stringBuffer.append("</table>");
-    _stringBuffer.append("</body></html>");
-    return _stringBuffer + "";
-  }
-
-  private String phaseOneData;
-  public JPanel startDisplay(){
-    // start the GUI here
-    JPanel panel = new JPanel();
-    panel.setLayout(new BorderLayout(0, 10));
-    panel.add(new JLabel("FOR USE BY AUTHORIZED PERSONNEL!",
-			 SwingConstants.CENTER), "North");
-
-    // Set up the entry fields
-    JPanel gridPanel = new JPanel();
-    gridPanel.setLayout(new GridLayout(4,2));
-
-    gridPanel.add(new JLabel("Type of Event: "));
-    gridPanel.add(new JTextField(10));
-
-    gridPanel.add(new JLabel("Available Data: "));
-    gridPanel.add(new JTextField(10));
-
-    gridPanel.add(new JLabel("Description: "));
-    gridPanel.add(new JTextField(10));
-
-    final JLabel label = new JLabel("Enter name: ");
-    final JTextField text = new JTextField(20);
-    gridPanel.add(label);
-    gridPanel.add(text);
-
-    // Stick the fields and buttons together so that they remain adjacent
-    // in the main panel
-    JPanel fieldsAndButtonsPanel = new JPanel();
-    fieldsAndButtonsPanel.setLayout(new BorderLayout());
+    String myDescription = "Event_Manager";
+    Habitat masterHabitat = null;
+
+    private final Hashtable informationCatalogue = new Hashtable();

-    // Now add gridpanel to our parent, but wrap it in a BorderLayout
-    // to "squeeze" it at the top
-    {
-      JPanel fieldPanel = new JPanel();
-      fieldPanel.setLayout(new BorderLayout());
-      fieldPanel.add(gridPanel, "North");
-      fieldsAndButtonsPanel.add(fieldPanel, "North");
+    private static final String key1 = "First_Name";
+    private static final String key2 = "Last_Name";
+    private static final String key3 = "Boarding_City";
+    private static final String key4 = "Boarding_Date";
+    private static final String key5 = "Address";
+    private static final String key6 = "Telephone";
+    private static final String key7 = "SSN";
+    private static final String key8 = "Age";
+    private static final String key9 = "Image";
+
+    public void initialize(Habitat _h){
+	masterHabitat = _h;
     }
-
-    {
-      // Set up our buttons
-      JPanel buttonPanel = new JPanel();
-      buttonPanel.setLayout(new FlowLayout());
-      JButton button = new JButton("Action!");
-      buttonPanel.add(button);
-      fieldsAndButtonsPanel.add(buttonPanel, "Center");
-
-      button.addActionListener(new ActionListener() {
-	  public void actionPerformed(ActionEvent ae) {
-	    phaseOneData = text.getText();
-	    phaseOne();
-	  }
-	});
-
-      panel.add(fieldsAndButtonsPanel, "Center");
-
-    }
-
-
-    // Put the whole thing into a BorderLayout so that it squeezes up nicely
-    panel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
-    return panel;
-  }
-
-  private static final String PHASE_ONE_PEER = "NYC_Passengers_Query";
-  private static final String PHASE_TWO_PEER = "TexasResidentInfo";
-  private static final String PHASE_THREE_PEER = "AlertService";
-
-  int phaseOneProgress = 0, phaseTwoProgress = 0, phaseThreeProgress = 0;
-
-  private String hashtableListing(Hashtable h) {
-    StringBuffer sb = new StringBuffer("");
-    for (Enumeration e = h.keys(); e.hasMoreElements(); ) {
-      String key = "" + e.nextElement();
-      sb.append("key: " + key + ", val: " + h.get(key));
+    public String getDescription() {
+	return myDescription;
     }
-    return "" + sb;
-  }
-  public Hashtable performService(String _senderService, Hashtable ipList) {
-    Hashtable result = new Hashtable();
-    if(_senderService.equals(PHASE_ONE_PEER)) {
-      masterHabitat.log(myDescription + " :: PHASE_ONE_PEER " + PHASE_ONE_PEER);
-      switch (phaseOneProgress) {
-      case 0:
-        result.put(key1, phaseOneData);
-        phaseOneProgress++;
-        break;
-
-      case 1:
-        for (Enumeration e=ipList.keys(); e.hasMoreElements(); ) {
-          String key = e.nextElement().toString();
-          informationCatalogue.put(key, ipList.get(key));
-        }
-        masterHabitat.log(myDescription + ":: Terminating Session with " + PHASE_TWO_PEER);
-        result.put("Terminate_Session", "SESSION_ENDED");
-        phaseOneProgress = 0;
-
-        // initiate phase-II
-        phaseTwo();
-        break;
-
-      }
-
-    } else if(_senderService.equals(PHASE_TWO_PEER)) {
-      masterHabitat.log(myDescription + ":: PHASE_TWO_PEER " + PHASE_TWO_PEER);
-      switch (phaseTwoProgress) {
-      case 0:
-        result.put(key1, informationCatalogue.get(key1));
-        result.put(key2, informationCatalogue.get(key2));
-        phaseTwoProgress++;
-        break;
-
-      case 1:
-        for (Enumeration e=ipList.keys(); e.hasMoreElements(); ) {
-          String key = e.nextElement().toString();
-          informationCatalogue.put(key, ipList.get(key));
-        }
-        result.put("Terminate_Session", "SESSION_ENDED");
-				masterHabitat.log(myDescription + " Terminating Session with " + PHASE_TWO_PEER);
-        phaseTwoProgress = 0;
-
-        // initiate phase-III
-        phaseThree();
-        break;
-
-      }
-    } else if(_senderService.equals(PHASE_THREE_PEER)) {
-      masterHabitat.log(myDescription + ":: PHASE_THREE_PEER" + PHASE_THREE_PEER);
-      switch (phaseThreeProgress) {
-      case 0:
-        for (Enumeration e=informationCatalogue.keys(); e.hasMoreElements(); ) {
-          String key = e.nextElement().toString();
-          if (key.equals(key3) || key.equals(key4)) continue;
-          result.put(key, informationCatalogue.get(key));
-          // masterHabitat.log("$$$$$$$$Sending this " + key);
-        }
-        phaseThreeProgress++;
-        break;
-
-      case 1:
-        phaseThreeProgress = 0;
-				masterHabitat.log(myDescription + " Terminating Session with " + PHASE_THREE_PEER);
-        result.put("Terminate_Session", "SESSION_ENDED");
-        break;
-      }
+    public String getDetailDescription(){
+	StringBuffer _stringBuffer = new StringBuffer();
+	_stringBuffer.setLength(0);
+	_stringBuffer.append("<html><body>");
+	_stringBuffer.append("<h1>" + getDescription() + "</h1>");
+	_stringBuffer.append("<table border=4>");
+	_stringBuffer.append("<tr><td>Purpose</td><td>Receive and Update Events </td></tr>");
+	_stringBuffer.append("<tr><td>Availablity</td><td>Local</td></tr>");
+	_stringBuffer.append("<tr><td>Monitor</td><td>True</td></tr>");
+	_stringBuffer.append("<tr><td>Monitor-Mode</td><td>Text</td></tr>");
+	_stringBuffer.append("</table>");
+	_stringBuffer.append("</body></html>");
+	return _stringBuffer + "";
     }
-
-    masterHabitat.log(myDescription + ": performService, returning: " + hashtableListing(result));
-    return result;
-  }
-  private void phaseOne() {
-		masterHabitat.log(myDescription + " Received some new Info - processing it .. ");
-		masterHabitat.log(myDescription + " Number of Steps Suggested -> 3 ");
-    masterHabitat.log(myDescription + " Entering Phase One ");
-		masterHabitat.log(myDescription + " Need to gather information on 'NYC Passengers'" );
-		masterHabitat.log(myDescription + " Contact Habitat -> 'NYCTransitHabitat'");
-		masterHabitat.log(myDescription + " Contact Service -> 'NYC_Passengers_Query'");
-
-    // invoked by user entering chor's name
-    // some intelligent workflow suggested that service to be contacted
-    String useService = "NYC_Passengers_Query";
-    if(!Habitat.localService(useService)) {
-      Hashtable ipList = new Hashtable();
-      ipList.put("habitatCategory","NYCTransitHabitat");
-      ipList.put("EventType","ServiceRequest");
-      ipList.put("Request4Service", useService);
-      ipList.put("totalParams","1");
-      ipList.put("params1", key1);
-      ipList.put("totalRetvals", "4");
-      ipList.put("retvals1", key1);
-      ipList.put("retvals2", key2);
-      ipList.put("retvals3", key3);
-      ipList.put("retvals4", key4);
-
-      masterHabitat.gk.broadcast_req(myDescription, useService, ipList);
-			masterHabitat.log(myDescription + " Requesting Gatekeeper to contact Remote Service");
+
+    private String phaseOneData;
+    public JPanel startDisplay(){
+	// start the GUI here
+	JPanel panel = new JPanel();
+	panel.setLayout(new BorderLayout(0, 10));
+	panel.add(new JLabel("FOR USE BY AUTHORIZED PERSONNEL!",
+			     SwingConstants.CENTER), "North");
+
+	// Set up the entry fields
+	JPanel gridPanel = new JPanel();
+	gridPanel.setLayout(new GridLayout(4,2));
+
+	gridPanel.add(new JLabel("Type of Event: "));
+	gridPanel.add(new JTextField(10));
+
+	gridPanel.add(new JLabel("Available Data: "));
+	gridPanel.add(new JTextField(10));
+
+	gridPanel.add(new JLabel("Description: "));
+	gridPanel.add(new JTextField(10));
+
+	final JLabel label = new JLabel("Enter name: ");
+	final JTextField text = new JTextField(20);
+	gridPanel.add(label);
+	gridPanel.add(text);
+
+	// Stick the fields and buttons together so that they remain adjacent
+	// in the main panel
+	JPanel fieldsAndButtonsPanel = new JPanel();
+	fieldsAndButtonsPanel.setLayout(new BorderLayout());
+
+	// Now add gridpanel to our parent, but wrap it in a BorderLayout
+	// to "squeeze" it at the top
+	{
+	    JPanel fieldPanel = new JPanel();
+	    fieldPanel.setLayout(new BorderLayout());
+	    fieldPanel.add(gridPanel, "North");
+	    fieldsAndButtonsPanel.add(fieldPanel, "North");
+	}
+
+	{
+	    // Set up our buttons
+	    JPanel buttonPanel = new JPanel();
+	    buttonPanel.setLayout(new FlowLayout());
+	    JButton button = new JButton("Action!");
+	    buttonPanel.add(button);
+	    fieldsAndButtonsPanel.add(buttonPanel, "Center");
+
+	    button.addActionListener(new ActionListener() {
+		    public void actionPerformed(ActionEvent ae) {
+			phaseOneData = text.getText();
+			phaseOne();
+		    }
+		});
+
+	    panel.add(fieldsAndButtonsPanel, "Center");
+
+	}
+
+
+	// Put the whole thing into a BorderLayout so that it squeezes up nicely
+	panel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
+	return panel;
     }
-    masterHabitat.log(myDescription + ": phaseOne, returned");
-  }
-
-  private void phaseTwo() {
-    masterHabitat.log(myDescription + ": phaseTwo");
-    String useService = "TexasResidentInfo";
-    if (!Habitat.localService(useService)) {
-      Hashtable ipList = new Hashtable();
-      ipList.put("habitatCategory","TexasStateHabitat");
-      ipList.put("EventType","ServiceRequest");
-      ipList.put("Request4Service", useService);
-      ipList.put("totalParams","2");
-      ipList.put("params1", key1);
-      ipList.put("params2", key2);
-      ipList.put("totalRetvals", "5");
-      ipList.put("retvals1", key5);
-      ipList.put("retvals2", key6);
-      ipList.put("retvals3", key7);
-      ipList.put("retvals4", key8);
-      ipList.put("retvals5", key9);
-
-      masterHabitat.gk.broadcast_req(myDescription, useService, ipList);
+
+    private static final String PHASE_ONE_PEER = "NYC_Passengers_Query";
+    private static final String PHASE_TWO_PEER = "TexasResidentInfo";
+    private static final String PHASE_THREE_PEER = "AlertService";
+
+    int phaseOneProgress = 0, phaseTwoProgress = 0, phaseThreeProgress = 0;
+
+    private String hashtableListing(Hashtable h) {
+	StringBuffer sb = new StringBuffer("");
+	for (Enumeration e = h.keys(); e.hasMoreElements(); ) {
+	    String key = "" + e.nextElement();
+	    sb.append("key: " + key + ", val: " + h.get(key));
+	}
+	return "" + sb;
     }
-    masterHabitat.log(myDescription + ": phaseTwo, returned");
-  }
-
-  private void phaseThree() {
-    masterHabitat.log(myDescription + ": phaseThree");
-    String useService = "AlertService";
-    if (!Habitat.localService(useService)) {
-      Hashtable ipList = new Hashtable();
-      ipList.put("habitatCategory","NYCTransitHabitat");
-      ipList.put("EventType","ServiceRequest");
-      ipList.put("Request4Service", useService);
-      ipList.put("totalParams","7");
-      ipList.put("params1", key1);
-      ipList.put("params2", key2);
-      ipList.put("params3", key5);
-      ipList.put("params4", key6);
-      ipList.put("params5", key7);
-      ipList.put("params6", key8);
-      ipList.put("params7", key9);
-      ipList.put("totalRetvals", "0");
-
-      masterHabitat.gk.broadcast_req(myDescription, useService, ipList);
+
+    public Hashtable performService(String _senderService, Hashtable ipList) {
+	Hashtable result = new Hashtable();
+	if(_senderService.equals(PHASE_ONE_PEER)) {
+
+	    masterHabitat.svclog(myDescription, myDescription + " :: PHASE_ONE_PEER " + PHASE_ONE_PEER);
+
+	    switch (phaseOneProgress) {
+	    case 0:
+		result.put(key1, phaseOneData);
+		phaseOneProgress++;
+		break;
+
+	    case 1:
+		for (Enumeration e=ipList.keys(); e.hasMoreElements(); ) {
+		    String key = e.nextElement().toString();
+		    informationCatalogue.put(key, ipList.get(key));
+		}
+
+		masterHabitat.svclog(myDescription, myDescription + ":: Terminating Session with " + PHASE_TWO_PEER);
+
+		result.put("Terminate_Session", "SESSION_ENDED");
+		phaseOneProgress = 0;
+
+		// initiate phase-II
+		phaseTwo();
+		break;
+
+	    }
+
+	} else if(_senderService.equals(PHASE_TWO_PEER)) {
+
+	    masterHabitat.svclog(myDescription, myDescription + ":: PHASE_TWO_PEER " + PHASE_TWO_PEER);
+
+	    switch (phaseTwoProgress) {
+	    case 0:
+		result.put(key1, informationCatalogue.get(key1));
+		result.put(key2, informationCatalogue.get(key2));
+		phaseTwoProgress++;
+		break;
+
+	    case 1:
+		for (Enumeration e=ipList.keys(); e.hasMoreElements(); ) {
+		    String key = e.nextElement().toString();
+		    informationCatalogue.put(key, ipList.get(key));
+		}
+		result.put("Terminate_Session", "SESSION_ENDED");
+
+		masterHabitat.svclog(myDescription, myDescription + " Terminating Session with " + PHASE_TWO_PEER);
+
+		phaseTwoProgress = 0;
+
+		// initiate phase-III
+		phaseThree();
+		break;
+
+	    }
+	} else if(_senderService.equals(PHASE_THREE_PEER)) {
+
+	    masterHabitat.svclog(myDescription, myDescription + ":: PHASE_THREE_PEER" + PHASE_THREE_PEER);
+
+	    switch (phaseThreeProgress) {
+	    case 0:
+		for (Enumeration e=informationCatalogue.keys(); e.hasMoreElements(); ) {
+		    String key = e.nextElement().toString();
+		    if (key.equals(key3) || key.equals(key4)) continue;
+		    result.put(key, informationCatalogue.get(key));
+		}
+		phaseThreeProgress++;
+		break;
+
+	    case 1:
+		phaseThreeProgress = 0;
+
+		masterHabitat.svclog(myDescription, myDescription + " Terminating Session with " + PHASE_THREE_PEER);
+
+		result.put("Terminate_Session", "SESSION_ENDED");
+		break;
+	    }
+	}
+
+	masterHabitat.svclog(myDescription, myDescription + ": performService, returning: " + hashtableListing(result));
+
+	return result;
+    }
+    private void phaseOne() {
+
+	masterHabitat.svclog(myDescription, myDescription + " Received some new Info - processing it .. ");
+	masterHabitat.svclog(myDescription, myDescription + " Number of Steps Suggested -> 3 ");
+	masterHabitat.svclog(myDescription, myDescription + " Entering Phase One ");
+	masterHabitat.svclog(myDescription, myDescription + " Need to gather information on 'NYC Passengers'" );
+	masterHabitat.svclog(myDescription, myDescription + " Contact Habitat -> 'NYCTransitHabitat'");
+	masterHabitat.svclog(myDescription, myDescription + " Contact Service -> 'NYC_Passengers_Query'");
+
+	// invoked by user entering chor's name
+	// some intelligent workflow suggested that service to be contacted
+	String useService = "NYC_Passengers_Query";
+	if(!Habitat.localService(useService)) {
+	    Hashtable ipList = new Hashtable();
+	    ipList.put("habitatCategory","NYCTransitHabitat");
+	    ipList.put("EventType","ServiceRequest");
+	    ipList.put("Request4Service", useService);
+	    ipList.put("totalParams","1");
+	    ipList.put("params1", key1);
+	    ipList.put("totalRetvals", "4");
+	    ipList.put("retvals1", key1);
+	    ipList.put("retvals2", key2);
+	    ipList.put("retvals3", key3);
+	    ipList.put("retvals4", key4);
+
+	    masterHabitat.log(myDescription + " Requesting Gatekeeper to contact Remote Service" + useService);
+	    masterHabitat.svclog(myDescription, myDescription + " Await response from Remote Service" + useService);
+
+	    masterHabitat.gk.broadcast_req(myDescription, useService, ipList);
+	}
+
+	masterHabitat.svclog(myDescription, myDescription + ": phaseOne, returned");
     }
-    masterHabitat.log(myDescription + ": phaseThree, returned");
-  }
+
+    private void phaseTwo() {

+	masterHabitat.svclog(myDescription, myDescription + ": phaseTwo");
+
+	String useService = "TexasResidentInfo";
+	if (!Habitat.localService(useService)) {
+	    Hashtable ipList = new Hashtable();
+	    ipList.put("habitatCategory","TexasStateHabitat");
+	    ipList.put("EventType","ServiceRequest");
+	    ipList.put("Request4Service", useService);
+	    ipList.put("totalParams","2");
+	    ipList.put("params1", key1);
+	    ipList.put("params2", key2);
+	    ipList.put("totalRetvals", "5");
+	    ipList.put("retvals1", key5);
+	    ipList.put("retvals2", key6);
+	    ipList.put("retvals3", key7);
+	    ipList.put("retvals4", key8);
+	    ipList.put("retvals5", key9);
+
+	    masterHabitat.log(myDescription + " Requesting Gatekeeper to contact Remote Service" + useService);
+	    masterHabitat.svclog(myDescription, myDescription + " Await response from Remote Service" + useService);
+
+	    masterHabitat.gk.broadcast_req(myDescription, useService, ipList);
+
+	}
+
+	masterHabitat.svclog(myDescription, myDescription+ ": phaseTwo, returned");
+    }
+
+    private void phaseThree() {
+
+	masterHabitat.svclog(myDescription, myDescription + ": phaseThree");
+
+	String useService = "AlertService";
+	if (!Habitat.localService(useService)) {
+	    Hashtable ipList = new Hashtable();
+	    ipList.put("habitatCategory","NYCTransitHabitat");
+	    ipList.put("EventType","ServiceRequest");
+	    ipList.put("Request4Service", useService);
+	    ipList.put("totalParams","7");
+	    ipList.put("params1", key1);
+	    ipList.put("params2", key2);
+	    ipList.put("params3", key5);
+	    ipList.put("params4", key6);
+	    ipList.put("params5", key7);
+	    ipList.put("params6", key8);
+	    ipList.put("params7", key9);
+	    ipList.put("totalRetvals", "0");
+
+	    masterHabitat.log(myDescription + " Requesting Gatekeeper to contact Remote Service" + useService);
+	    masterHabitat.svclog(myDescription, myDescription + " Await response from Remote Service" + useService);
+
+	    masterHabitat.gk.broadcast_req(myDescription, useService, ipList);
+	}
+
+	masterHabitat.svclog (myDescription, myDescription + ": phaseThree, returned");
+    }
+
 }
diff --git a/services/MapService.java b/services/MapService.java
index f81321e..5fd3c17 100644
--- a/services/MapService.java
+++ b/services/MapService.java
@@ -1,36 +1,36 @@
-package psl.habitats.services;
-
-import psl.habitats.*;
-
-import javax.swing.*;
-import java.util.Hashtable;
-
-public class MapService implements ServiceInterface {  
  private static String serviceDescription = "MapService";
+package psl.habitats.services;
+
+import psl.habitats.*;
+
+import javax.swing.*;
+import java.util.Hashtable;
+
+public class MapService implements ServiceInterface {    private static String serviceDescription = "MapService";
   public MapService() {	}
-  public void initialize(Habitat _h) { }
-  public String getDescription() {
-    return serviceDescription;
-  }
-  public JPanel startDisplay() {
-    return new JPanel();
-  }
-
-  public String getDetailDescription(){
-    StringBuffer _stringBuffer = new StringBuffer();
-    _stringBuffer.setLength(0);
-    _stringBuffer.append("<html><body>");
-    _stringBuffer.append("<h1>" + getDescription() + "</h1>");
-    _stringBuffer.append("<table border=4>");
-    _stringBuffer.append("<tr><td>Purpose</td><td>Maps Database</td></tr>");
-    _stringBuffer.append("<tr><td>Availablity</td><td>Not available</td></tr>");
-    _stringBuffer.append("<tr><td>Monitor</td><td>Probably</td></tr>");
-    _stringBuffer.append("<tr><td>Monitor-Mode</td><td>NA</td></tr>");
-    _stringBuffer.append("</table>");
-    _stringBuffer.append("</body></html>");
-  return _stringBuffer + "";
-  }
-
-  public Hashtable performService(String _senderService, Hashtable ipList) {
-    return null;
-  }
+  public void initialize(Habitat _h) { }
+  public String getDescription() {
+    return serviceDescription;
+  }
+  public JPanel startDisplay() {
+    return new JPanel();
+  }
+
+  public String getDetailDescription(){
+    StringBuffer _stringBuffer = new StringBuffer();
+    _stringBuffer.setLength(0);
+    _stringBuffer.append("<html><body>");
+    _stringBuffer.append("<h1>" + getDescription() + "</h1>");
+    _stringBuffer.append("<table border=4>");
+    _stringBuffer.append("<tr><td>Purpose</td><td>Maps Database</td></tr>");
+    _stringBuffer.append("<tr><td>Availablity</td><td>Not available</td></tr>");
+    _stringBuffer.append("<tr><td>Monitor</td><td>Probably</td></tr>");
+    _stringBuffer.append("<tr><td>Monitor-Mode</td><td>NA</td></tr>");
+    _stringBuffer.append("</table>");
+    _stringBuffer.append("</body></html>");
+  return _stringBuffer + "";
+  }
+
+  public Hashtable performService(String _senderService, Hashtable ipList) {
+    return null;
+  }
 }
diff --git a/services/NYCPassListService.java b/services/NYCPassListService.java
index 5c75b76..6b8df24 100644
--- a/services/NYCPassListService.java
+++ b/services/NYCPassListService.java
@@ -8,71 +8,75 @@ import java.util.Vector;
 import java.util.Hashtable;

 public class NYCPassListService implements ServiceInterface {
-  private static final String myDescription = "NYC_Passengers_Query";
-  Habitat masterHabitat = null;
-  public void initialize(Habitat _h) {
-    masterHabitat = _h;
-  }
-  public String getDescription(){
-    return myDescription;
-  }
-  public JPanel startDisplay() {
-    return new JPanel();
-  }
+    private static final String myDescription = "NYC_Passengers_Query";
+    Habitat masterHabitat = null;
+    public void initialize(Habitat _h) {
+	masterHabitat = _h;
+    }
+    public String getDescription(){
+	return myDescription;
+    }
+    public JPanel startDisplay() {
+	return new JPanel();
+    }
+
+    public String getDetailDescription(){
+	StringBuffer _stringBuffer = new StringBuffer();
+	_stringBuffer.setLength(0);
+	_stringBuffer.append("<html><body>");
+	_stringBuffer.append("<h1>" + getDescription() + "</h1>");
+	_stringBuffer.append("<table border=4>");
+	_stringBuffer.append("<tr><td>Purpose     </td><td>AmTrak Passenger List</td></tr>");
+	_stringBuffer.append("<tr><td>Availablity </td><td>Local/Remote         </td></tr>");
+	_stringBuffer.append("<tr><td>Monitor     </td><td>True                 </td></tr>");
+	_stringBuffer.append("<tr><td>Monitor-Mode</td><td>Text                 </td></tr>");
+	_stringBuffer.append("</table>");
+	_stringBuffer.append("</body></html>");
+	return _stringBuffer + "";
+    }
+
+    private static final String key1 = "First_Name";
+    private static final String key2 = "Last_Name";
+    private static final String key3 = "Boarding_City";
+    private static final String key4 = "Boarding_Date";
+
+    public Hashtable performService(String _senderService, Hashtable ipList) {

-  public String getDetailDescription(){
-    StringBuffer _stringBuffer = new StringBuffer();
-    _stringBuffer.setLength(0);
-    _stringBuffer.append("<html><body>");
-    _stringBuffer.append("<h1>" + getDescription() + "</h1>");
-    _stringBuffer.append("<table border=4>");
-    _stringBuffer.append("<tr><td>Purpose     </td><td>AmTrak Passenger List</td></tr>");
-    _stringBuffer.append("<tr><td>Availablity </td><td>Local/Remote         </td></tr>");
-    _stringBuffer.append("<tr><td>Monitor     </td><td>True                 </td></tr>");
-    _stringBuffer.append("<tr><td>Monitor-Mode</td><td>Text                 </td></tr>");
-    _stringBuffer.append("</table>");
-    _stringBuffer.append("</body></html>");
-    return _stringBuffer + "";
-  }
+	masterHabitat.svclog(myDescription, myDescription + ": performService for " + _senderService);

-  private static final String key1 = "First_Name";
-  private static final String key2 = "Last_Name";
-  private static final String key3 = "Boarding_City";
-  private static final String key4 = "Boarding_Date";
+	Hashtable result = new Hashtable();
+	if(ipList.containsKey(key1) || ipList.containsKey(key2)){
+	    result.put(key1, lookup("" + ipList.get(key1), key1, masterHabitat.getName()));
+	    result.put(key2, lookup("" + ipList.get(key1), key2, masterHabitat.getName()));
+	    result.put(key3, lookup("" + ipList.get(key1), key3, masterHabitat.getName()));
+	    result.put(key4, lookup("" + ipList.get(key1), key4, masterHabitat.getName()));
+	} else
+	    result = null;

-  public Hashtable performService(String _senderService, Hashtable ipList) {
-    masterHabitat.log(myDescription + ": performService for " + _senderService);
-    Hashtable result = new Hashtable();
-    if(ipList.containsKey(key1) || ipList.containsKey(key2)){
-      result.put(key1, lookup("" + ipList.get(key1), key1, masterHabitat.getName()));
-      result.put(key2, lookup("" + ipList.get(key1), key2, masterHabitat.getName()));
-      result.put(key3, lookup("" + ipList.get(key1), key3, masterHabitat.getName()));
-      result.put(key4, lookup("" + ipList.get(key1), key4, masterHabitat.getName()));
-    } else
-      result = null;
-    masterHabitat.log(myDescription + ": returning requested Data ");
-    return result;
-  }
-
-  private static final String HABITAT_NAME = "AmTrak";
-  private String lookup(String key1, String key, String forHab) {
-    if (forHab.equals(HABITAT_NAME)) {
-      if (key1.equalsIgnoreCase("john")) return "" + johnHash.get(key);
-      if (key1.equalsIgnoreCase("gail")) return "" + gailHash.get(key);
-    }
-    return null;
-  }
-  private static final Hashtable gailHash = new Hashtable();
-  private static final Hashtable johnHash = new Hashtable();
-  static {
-    gailHash.put(key1, "Gail");
-    gailHash.put(key2, "Kaiser");
-    gailHash.put(key3, "Texas");
-    gailHash.put(key4, "Friday morning");
+	masterHabitat.svclog(myDescription, myDescription + ": returning requested Data ");

-    johnHash.put(key1, "John");
-    johnHash.put(key2, "Salasin");
-    johnHash.put(key3, "Texas");
-    johnHash.put(key4, "Yesterday");
-  }
+	return result;
+    }
+
+    private static final String HABITAT_NAME = "AmTrak";
+    private String lookup(String key1, String key, String forHab) {
+	if (forHab.equals(HABITAT_NAME)) {
+	    if (key1.equalsIgnoreCase("john")) return "" + johnHash.get(key);
+	    if (key1.equalsIgnoreCase("gail")) return "" + gailHash.get(key);
+	}
+	return null;
+    }
+    private static final Hashtable gailHash = new Hashtable();
+    private static final Hashtable johnHash = new Hashtable();
+    static {
+	gailHash.put(key1, "Gail");
+	gailHash.put(key2, "Kaiser");
+	gailHash.put(key3, "Texas");
+	gailHash.put(key4, "Friday morning");
+
+	johnHash.put(key1, "John");
+	johnHash.put(key2, "Salasin");
+	johnHash.put(key3, "Texas");
+	johnHash.put(key4, "Yesterday");
+    }
 }
diff --git a/services/ResidentsListService.java b/services/ResidentsListService.java
index c3e9ba5..84f1794 100644
--- a/services/ResidentsListService.java
+++ b/services/ResidentsListService.java
@@ -43,7 +43,9 @@ public class ResidentsListService implements ServiceInterface {
   private static final String key9 = "Age";

   public Hashtable performService(String _senderService, Hashtable ipList) {
-    masterHabitat.log(myDescription + ": performService for " + _senderService);
+
+    masterHabitat.svclog(myDescription, myDescription + ": performService for " + _senderService);
+
     Hashtable result = new Hashtable();
     if (ipList.containsKey(key1) && ipList.containsKey(key2)) {
       result.put(key5, lookup("" + ipList.get(key1), key5, masterHabitat.getName()));
@@ -53,7 +55,8 @@ public class ResidentsListService implements ServiceInterface {
       result.put(key9, lookup("" + ipList.get(key1), key9, masterHabitat.getName()));
     } else
       result = null;
-    masterHabitat.log(myDescription + ": returning requested data ");
+
+    masterHabitat.svclog(myDescription, myDescription + ": returning requested data ");
     return result;
   }