/*******************************************************************************
$Source: /cvs/repositories/openii3/project/java/examples/org/any_openeai_enterprise/applications/selfservice/Frame1.java,v $
$Revision: 1.10 $
*******************************************************************************/
/**********************************************************************
This file is part of the OpenEAI sample, reference implementation,
and deployment management suite created by Tod Jackson
(tod@openeai.org) and Steve Wheat (steve@openeai.org) at
the University of Illinois Urbana-Champaign.
Copyright (C) 2002 The OpenEAI Software Foundation
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For specific licensing details and examples of how this software
can be used to implement integrations for your enterprise, visit
http://www.OpenEai.org/licensing.
*/
package org.any_openeai_enterprise.applications.selfservice;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import javax.swing.JTabbedPane;
import java.awt.Rectangle;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import java.awt.event.MouseEvent;
import javax.swing.JTextArea;
import javax.swing.JScrollPane;
import javax.swing.JPanel;
import org.openeai.config.AppConfig;
//import org.openeai.moa.jmsobjects.JmsEnterpriseObject;
import org.openeai.jms.producer.PointToPointProducer;
import com.any_erp_vendor.moa.jmsobjects.person.v1_0.BasicPerson;
import com.any_erp_vendor.moa.objects.resources.v1_0.Date;
import com.any_erp_vendor.moa.objects.resources.v1_0.Name;
import com.any_erp_vendor.moa.objects.resources.v1_0.Address;
import com.any_erp_vendor.moa.objects.resources.v1_0.Phone;
import com.any_erp_vendor.moa.objects.resources.v1_0.Email;
import com.any_erp_vendor.moa.jmsobjects.person.v1_0.EmergencyContact;
import com.openii.moa.jmsobjects.services.v1_0.AddressValidation;
import com.openii.moa.objects.resources.v1_0.*;
import org.any_openeai_enterprise.moa.objects.resources.v1_0.LightweightPerson;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;
import javax.swing.JList;
import org.openeai.moa.ActionableEnterpriseObject;
/**
* This is a simple Swing container that is integrated with the "Any ERP Vendor"
* Gateway (com.any-erp-vendor.Gateway for short). The actual gateway is
* implemented in the com.any_erp_vendor.messaging.gateways.AevRequestCommand class.
* This gateway which is part of the OpenEAI sample enterprise is authoritative for
* BasicPerson, BasicEmployee and EmergencyContact enterprise message objects.
* <P>
* Since we don't want to store that information in our own local repository, this
* self service application simply requests that certain actions be performed in that
* gateway. It can Query, Create, Update and Delete BasicPerson and EmergencyContact
* objects in the com.any-erp-vendor.Gateway.
* <P>
* This container will request the following messaging actions be performed in
* the com.any-erp-vendor.Gateway:
* <ul>
* <li>com.any-erp-vendor.Person/BasicPerson/1.0/Query-Request
* <li>com.any-erp-vendor.Person/BasicPerson/1.0/Create-Request
* <li>com.any-erp-vendor.Person/BasicPerson/1.0/Update-Request
* <li>com.any-erp-vendor.Person/BasicPerson/1.0/Delete-Request
* <li>com.any-erp-vendor.Person/EmergencyContact/1.0/Query-Request
* <li>com.any-erp-vendor.Person/EmergencyContact/1.0/Create-Request
* <li>com.any-erp-vendor.Person/EmergencyContact/1.0/Update-Request
* <li>com.any-erp-vendor.Person/EmergencyContact/1.0/Delete-Request
* </ul>
**/
public class Frame1 extends JFrame {
JMenuItem menuHelpAbout = new JMenuItem();
JMenu menuHelp = new JMenu();
JMenuItem menuFileExit = new JMenuItem();
JMenu menuFile = new JMenu();
JMenuBar menuBar1 = new JMenuBar();
JLabel jLabel1 = new JLabel();
JTextField instIdTextField = new JTextField();
JButton bp_queryButton = new JButton();
JLabel jLabel3 = new JLabel();
JScrollPane jScrollPane1 = new JScrollPane();
JPanel basicPersonPanel = new JPanel();
JTabbedPane jTabbedPane1 = new JTabbedPane();
JTextArea bp_resultsTextArea = new JTextArea();
JTextField bp_firstNameTextField = new JTextField();
JTextField bp_middleNameTextField = new JTextField();
JTextField bp_lastNameTextField = new JTextField();
JComboBox bp_genderComboBox = new JComboBox();
JTextField bp_birthDateTextField = new JTextField();
JLabel jLabel2 = new JLabel();
JLabel jLabel4 = new JLabel();
JLabel jLabel5 = new JLabel();
JLabel jLabel6 = new JLabel();
JLabel jLabel7 = new JLabel();
JButton bp_createButton = new JButton();
JButton bp_updateButton = new JButton();
JButton bp_deleteButton = new JButton();
JPanel basicEmployeePanel = new JPanel();
JButton be_queryButton = new JButton();
JTextField be_instIdTextField = new JTextField();
JLabel jLabel8 = new JLabel();
JButton be_createButton = new JButton();
JButton be_updateButton = new JButton();
JButton be_deleteButton = new JButton();
JPanel ecPanel = new JPanel();
JLabel jLabel10 = new JLabel();
JLabel ec_bpName = new JLabel();
JButton ec_queryButton = new JButton();
JScrollPane jScrollPane2 = new JScrollPane();
JTextArea ec_textArea = new JTextArea();
JScrollPane jScrollPane3 = new JScrollPane();
JList ecList = new JList();
JTextField ec_firstName = new JTextField();
JTextField ec_lastName = new JTextField();
JTextField ec_street1 = new JTextField();
JTextField ec_city = new JTextField();
JTextField ec_zip = new JTextField();
JTextField ec_phone = new JTextField();
JLabel jLabel11 = new JLabel();
JLabel jLabel12 = new JLabel();
JLabel jLabel13 = new JLabel();
JLabel jLabel14 = new JLabel();
JLabel jLabel15 = new JLabel();
JLabel jLabel16 = new JLabel();
JLabel jLabel17 = new JLabel();
JComboBox ec_relation = new JComboBox();
JLabel jLabel18 = new JLabel();
JScrollPane jScrollPane4 = new JScrollPane();
JScrollPane jScrollPane5 = new JScrollPane();
JScrollPane jScrollPane5e = new JScrollPane();
JList bp_addressList = new JList();
JList bp_phoneList = new JList();
JList bp_emailList = new JList();
JLabel jLabel19 = new JLabel();
JLabel jLabel20 = new JLabel();
JLabel jLabel20e = new JLabel();
JTextField bp_street1 = new JTextField();
JTextField bp_city = new JTextField();
JTextField bp_zip = new JTextField();
JComboBox bp_addressType = new JComboBox();
JLabel jLabel21 = new JLabel();
JLabel jLabel22 = new JLabel();
JLabel jLabel23 = new JLabel();
JLabel jLabel24 = new JLabel();
JLabel jLabel25 = new JLabel();
JButton bp_addressAdd = new JButton();
JTextField bp_effectiveDate = new JTextField();
JLabel jLabel26 = new JLabel();
JComboBox bp_phoneType = new JComboBox();
JComboBox bp_emailType = new JComboBox();
JLabel jLabel27 = new JLabel();
JLabel jLabel27e = new JLabel();
JTextField bp_phoneAreaCode = new JTextField();
JLabel jLabel28 = new JLabel();
JTextField bp_phoneNumber = new JTextField();
JTextField bp_emailAddress = new JTextField();
JCheckBox bp_emailPreferred = new JCheckBox();
JCheckBox bp_emailActive = new JCheckBox();
JLabel jLabel29 = new JLabel();
JLabel jLabel29e = new JLabel();
JButton bp_phoneAdd = new JButton();
JButton bp_emailAdd = new JButton();
JButton bp_addressDelete = new JButton();
JButton bp_phoneDelete = new JButton();
JButton bp_emailDelete = new JButton();
JButton av_validateAddress = new JButton();
BasicPerson baselineBasicPerson = null;
EmergencyContact baselineEmergencyContact = null;
AppConfig APP_CONFIG = null;
static final String BASIC_PERSON = "BasicPerson.v1_0";
static final String EMERGENCY_CONTACT = "EmergencyContact.v1_0";
static final String LIGHTWEIGHT_PERSON = "LightweightPerson.v1_0";
static final String SELF_SERVICE_PRODUCER = "SelfServiceAppProducer";
static final String ADDRESS_VALIDATION_PRODUCER = "AddressValidationProducer";
static final String VALID_ADDRESS = "ValidAddress.v1_0";
JButton ec_createButton = new JButton();
JButton ec_updateButton = new JButton();
JButton ec_deleteButton = new JButton();
JComboBox ec_priority = new JComboBox();
JLabel jLabel30 = new JLabel();
JComboBox bp_stateList = new JComboBox();
JComboBox ec_stateList = new JComboBox();
JButton bp_addressAdd1 = new JButton();
JButton bp_phoneAdd1 = new JButton();
JButton bp_emailAdd1 = new JButton();
JButton clearButton = new JButton();
/**
* This constructor is called by both the SelfServiceApplication class as well as
* the SelfServiceAppCommand class. Each of these classes initialize an AppConfig
* object and pass it to this constructor.
* <P>
* The difference is, the SelfServiceApplication is a "typical" Java class with a "main"
* routine that loads a Properties object and builds an AppConfig based on the Deployment
* document referred to in that Properties object.
* <P>
* The SelfServiceAppCommand class is an OpenEAI ScheduledCommand that is initialized
* by the org.openeai.afa.GenericAppRunner class. The Command instantiates and builds
* an AppConfig object for itself and it is this AppConfig object that is passed to this
* Frame1 class.
* <P>
* The benefits to developing applications (even GUI applications) like this is that
* no one has to develop the code to actually load the properties object and every application
* can be started by the same class (GenericAppRunner). This simplifies deployment,
* runtime scripts and administration.
**/
public Frame1(AppConfig a) {
APP_CONFIG = a;
try {
jbInit();
} catch(Exception e) {
e.printStackTrace();
}
new Thread(new DropDownLoader()).start();
}
private void jbInit() throws Exception {
this.setJMenuBar(menuBar1);
this.getContentPane().setLayout(null);
this.setSize(new Dimension(644, 800));
this.setTitle("Any OpenEAI Enterprise Self Service Application");
menuFile.setText("File");
jLabel1.setText("Institutional ID:");
jLabel1.setHorizontalAlignment(SwingConstants.LEFT);
jLabel1.setBounds(new Rectangle(20, 13, 75, 15));
instIdTextField.setMaximumSize(new Dimension(9, 9));
instIdTextField.setBounds(new Rectangle(105, 10, 100, 20));
bp_queryButton.setText("Query");
bp_queryButton.setBounds(new Rectangle(250, 15, 73, 27));
bp_queryButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(MouseEvent e) {
bp_queryButton_mouseClicked(e);
}
});
jLabel3.setText("Results From Action");
jLabel3.setHorizontalTextPosition(SwingConstants.LEADING);
jLabel3.setBounds(new Rectangle(20, 560, 280, 15));
jScrollPane1.setBounds(new Rectangle(20, 580, 550, 75));
basicPersonPanel.setLayout(null);
basicEmployeePanel.setLayout(null);
be_queryButton.setText("Query");
be_queryButton.setBounds(new Rectangle(195, 20, 73, 27));
be_instIdTextField.setText("jTextField1");
be_instIdTextField.setBounds(new Rectangle(50, 40, 100, 20));
jLabel8.setText("Institutional ID:");
jLabel8.setBounds(new Rectangle(45, 20, 105, 15));
jLabel8.setHorizontalAlignment(SwingConstants.RIGHT);
be_createButton.setText("Create");
be_createButton.setBounds(new Rectangle(285, 20, 73, 27));
be_updateButton.setText("Update");
be_updateButton.setBounds(new Rectangle(375, 20, 73, 27));
be_deleteButton.setText("Delete");
be_deleteButton.setBounds(new Rectangle(465, 20, 73, 27));
ecPanel.setLayout(null);
jLabel10.setText("Emergency Contacts for:");
jLabel10.setBounds(new Rectangle(30, 75, 170, 15));
ec_bpName.setBounds(new Rectangle(30, 90, 175, 15));
ec_queryButton.setText("Query");
ec_queryButton.setBounds(new Rectangle(250, 25, 73, 27));
ec_queryButton.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
ec_queryButton_mouseClicked(e);
}
});
jScrollPane2.setBounds(new Rectangle(25, 325, 550, 75));
jScrollPane3.setBounds(new Rectangle(30, 110, 175, 170));
ecList.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
ecList_mouseClicked(e);
}
});
ec_firstName.setBounds(new Rectangle(250, 140, 145, 20));
ec_lastName.setBounds(new Rectangle(405, 140, 135, 20));
ec_street1.setBounds(new Rectangle(250, 180, 290, 20));
ec_city.setBounds(new Rectangle(250, 220, 115, 20));
ec_zip.setBounds(new Rectangle(460, 220, 80, 20));
ec_phone.setBounds(new Rectangle(250, 260, 115, 20));
jLabel11.setText("Street 1");
jLabel11.setBounds(new Rectangle(250, 160, 40, 16));
jLabel12.setText("City");
jLabel12.setBounds(new Rectangle(250, 200, 40, 16));
jLabel13.setText("State");
jLabel13.setBounds(new Rectangle(370, 200, 40, 16));
jLabel14.setText("Zip");
jLabel14.setBounds(new Rectangle(460, 200, 40, 16));
jLabel15.setText("First Name");
jLabel15.setBounds(new Rectangle(250, 125, 85, 15));
jLabel16.setText("Last Name");
jLabel16.setBounds(new Rectangle(405, 125, 90, 15));
jLabel17.setText("Phone");
jLabel17.setBounds(new Rectangle(250, 240, 40, 16));
ec_relation.setBounds(new Rectangle(250, 95, 124, 20));
jLabel18.setText("Relationship:");
jLabel18.setBounds(new Rectangle(250, 75, 85, 15));
jScrollPane4.setBounds(new Rectangle(25, 185, 185, 115));
jScrollPane5.setBounds(new Rectangle(25, 345, 185, 85));
jScrollPane5e.setBounds(new Rectangle(25, 455, 185, 85));
bp_addressList.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
bp_addressList_mouseClicked(e);
}
});
bp_phoneList.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
bp_phoneList_mouseClicked(e);
}
});
bp_emailList.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
bp_emailList_mouseClicked(e);
}
});
jLabel19.setText("Addresses");
jLabel19.setBounds(new Rectangle(25, 170, 115, 15));
jLabel20.setText("Phones");
jLabel20.setBounds(new Rectangle(25, 325, 40, 16));
jLabel20e.setText("Email Addresses");
jLabel20e.setBounds(new Rectangle(25, 435, 200, 16));
bp_street1.setBounds(new Rectangle(265, 230, 295, 20));
bp_city.setBounds(new Rectangle(265, 275, 105, 20));
bp_zip.setBounds(new Rectangle(495, 275, 65, 20));
bp_addressType.setBounds(new Rectangle(265, 185, 124, 20));
av_validateAddress.setText("Validate Address");
av_validateAddress.setBounds(new Rectangle(470, 305, 115, 30));
av_validateAddress.setToolTipText("Validate the mailing address.");
av_validateAddress.setHorizontalAlignment(SwingConstants.LEFT);
av_validateAddress.setHorizontalTextPosition(SwingConstants.LEFT);
av_validateAddress.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
av_validateAddress_mouseClicked(e);
}
});
jLabel21.setText("Street 1");
jLabel21.setBounds(new Rectangle(265, 210, 60, 15));
jLabel22.setText("City");
jLabel22.setBounds(new Rectangle(265, 255, 40, 16));
jLabel23.setText("State");
jLabel23.setBounds(new Rectangle(385, 255, 40, 16));
jLabel24.setText("Zip");
jLabel24.setBounds(new Rectangle(500, 255, 40, 16));
jLabel25.setText("Address Type:");
jLabel25.setBounds(new Rectangle(265, 170, 90, 15));
bp_addressAdd.setText("<");
bp_addressAdd.setBounds(new Rectangle(215, 185, 40, 25));
bp_addressAdd.setToolTipText("Add new or update selected Address in list.");
bp_addressAdd.setHorizontalAlignment(SwingConstants.LEFT);
bp_addressAdd.setHorizontalTextPosition(SwingConstants.LEFT);
bp_addressAdd.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
bp_addressAdd_mouseClicked(e);
}
});
bp_effectiveDate.setBounds(new Rectangle(415, 185, 90, 20));
jLabel26.setText("Effective Date (mm/dd/yyyy)");
jLabel26.setBounds(new Rectangle(415, 170, 150, 15));
bp_phoneType.setBounds(new Rectangle(265, 360, 124, 20));
bp_emailType.setBounds(new Rectangle(265, 470, 124, 20));
bp_emailPreferred.setText("Preferred");
bp_emailPreferred.setBounds(new Rectangle(490, 470, 90, 20));
bp_emailActive.setText("Active");
bp_emailActive.setBounds(new Rectangle(420, 470, 60, 20));
jLabel27.setText("Phone Type");
jLabel27.setBounds(new Rectangle(265, 345, 80, 15));
jLabel27e.setText("Email Type");
jLabel27e.setBounds(new Rectangle(265, 455, 80, 15));
bp_phoneAreaCode.setBounds(new Rectangle(265, 405, 60, 20));
jLabel28.setText("Area Code");
jLabel28.setBounds(new Rectangle(265, 390, 70, 15));
bp_phoneNumber.setBounds(new Rectangle(345, 405, 90, 20));
bp_emailAddress.setBounds(new Rectangle(265, 515, 250, 20));
jLabel29.setText("Phone Number (xxx-xxxx)");
jLabel29.setBounds(new Rectangle(345, 390, 150, 15));
jLabel29e.setText("Email Address");
jLabel29e.setBounds(new Rectangle(265, 500, 150, 15));
bp_phoneAdd.setText("<");
bp_phoneAdd.setBounds(new Rectangle(215, 345, 40, 25));
bp_phoneAdd.setToolTipText("Add or update selected Phone in list.");
bp_phoneAdd.setHorizontalAlignment(SwingConstants.LEFT);
bp_phoneAdd.setHorizontalTextPosition(SwingConstants.LEFT);
bp_phoneAdd.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
bp_phoneAdd_mouseClicked(e);
}
});
bp_emailAdd.setText("<");
bp_emailAdd.setBounds(new Rectangle(215, 455, 40, 25));
bp_emailAdd.setToolTipText("Add or update selected Email in list.");
bp_emailAdd.setHorizontalAlignment(SwingConstants.LEFT);
bp_emailAdd.setHorizontalTextPosition(SwingConstants.LEFT);
bp_emailAdd.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
bp_emailAdd_mouseClicked(e);
}
});
bp_addressDelete.setText("-");
bp_addressDelete.setBounds(new Rectangle(215, 245, 40, 25));
bp_addressDelete.setToolTipText("Delete selected Address from list.");
bp_addressDelete.setHorizontalAlignment(SwingConstants.LEFT);
bp_addressDelete.setHorizontalTextPosition(SwingConstants.LEFT);
bp_addressDelete.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
bp_addressDelete_mouseClicked(e);
}
});
bp_phoneDelete.setText("-");
bp_phoneDelete.setBounds(new Rectangle(215, 405, 40, 25));
bp_phoneDelete.setToolTipText("Delete selected Phone from list.");
bp_phoneDelete.setHorizontalAlignment(SwingConstants.LEFT);
bp_phoneDelete.setHorizontalTextPosition(SwingConstants.LEFT);
bp_phoneDelete.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
bp_phoneDelete_mouseClicked(e);
}
});
bp_emailDelete.setText("-");
bp_emailDelete.setBounds(new Rectangle(215, 515, 40, 25));
bp_emailDelete.setToolTipText("Delete selected Email from list.");
bp_emailDelete.setHorizontalAlignment(SwingConstants.LEFT);
bp_emailDelete.setHorizontalTextPosition(SwingConstants.LEFT);
bp_emailDelete.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
bp_emailDelete_mouseClicked(e);
}
});
ec_createButton.setText("Create");
ec_createButton.setBounds(new Rectangle(330, 25, 73, 27));
ec_createButton.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
ec_createButton_mouseClicked(e);
}
});
ec_updateButton.setText("Update");
ec_updateButton.setBounds(new Rectangle(410, 25, 73, 27));
ec_updateButton.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
ec_updateButton_mouseClicked(e);
}
});
ec_deleteButton.setText("Delete");
ec_deleteButton.setBounds(new Rectangle(490, 25, 73, 27));
ec_deleteButton.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
ec_deleteButton_mouseClicked(e);
}
});
ec_priority.setBounds(new Rectangle(405, 95, 124, 20));
jLabel30.setText("Priority");
jLabel30.setBounds(new Rectangle(405, 75, 40, 16));
bp_stateList.setBounds(new Rectangle(375, 275, 115, 20));
ec_stateList.setBounds(new Rectangle(370, 220, 90, 20));
bp_addressAdd1.setText("+");
bp_addressAdd1.setBounds(new Rectangle(215, 215, 40, 25));
bp_addressAdd1.setToolTipText("Add new Address to list.");
bp_addressAdd1.setHorizontalAlignment(SwingConstants.LEFT);
bp_addressAdd1.setHorizontalTextPosition(SwingConstants.LEFT);
bp_addressAdd1.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
bp_addressAdd1_mouseClicked(e);
}
});
bp_phoneAdd1.setText("+");
bp_phoneAdd1.setBounds(new Rectangle(215, 375, 40, 25));
bp_phoneAdd1.setToolTipText("Add Phone to list.");
bp_phoneAdd1.setHorizontalAlignment(SwingConstants.LEFT);
bp_phoneAdd1.setHorizontalTextPosition(SwingConstants.LEFT);
bp_phoneAdd1.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
bp_phoneAdd1_mouseClicked(e);
}
});
bp_emailAdd1.setText("+");
bp_emailAdd1.setBounds(new Rectangle(215, 485, 40, 25));
bp_emailAdd1.setToolTipText("Add Email to list.");
bp_emailAdd1.setHorizontalAlignment(SwingConstants.LEFT);
bp_emailAdd1.setHorizontalTextPosition(SwingConstants.LEFT);
bp_emailAdd1.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
bp_emailAdd1_mouseClicked(e);
}
});
clearButton.setText("Clear");
clearButton.setBounds(new Rectangle(270, 10, 73, 27));
clearButton.setToolTipText("Clears all fields on the form.");
clearButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(MouseEvent e) {
clearButton_mouseClicked(e);
}
});
jTabbedPane1.setBounds(new Rectangle(15, 50, 600, 695));
bp_resultsTextArea.setLineWrap(true);
bp_createButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(MouseEvent e) {
bp_createButton_mouseClicked(e);
}
});
bp_updateButton.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(MouseEvent e)
{
bp_updateButton_mouseClicked(e);
}
});
bp_deleteButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(MouseEvent e) {
bp_deleteButton_mouseClicked(e);
}
});
basicEmployeePanel.add(be_deleteButton, null);
basicEmployeePanel.add(be_updateButton, null);
basicEmployeePanel.add(be_createButton, null);
basicEmployeePanel.add(jLabel8, null);
basicEmployeePanel.add(be_instIdTextField, null);
basicEmployeePanel.add(be_queryButton, null);
jTabbedPane1.addTab("Person Info", basicPersonPanel);
jTabbedPane1.addTab("Employee Info", basicEmployeePanel);
jScrollPane2.getViewport().add(ec_textArea, null);
jScrollPane3.getViewport().add(ecList, null);
ecPanel.add(ec_stateList, null);
ecPanel.add(jLabel30, null);
ecPanel.add(ec_priority, null);
ecPanel.add(ec_deleteButton, null);
ecPanel.add(ec_updateButton, null);
ecPanel.add(ec_createButton, null);
ecPanel.add(jLabel18, null);
ecPanel.add(ec_relation, null);
ecPanel.add(jLabel17, null);
ecPanel.add(jLabel16, null);
ecPanel.add(jLabel15, null);
ecPanel.add(jLabel14, null);
ecPanel.add(jLabel13, null);
ecPanel.add(jLabel12, null);
ecPanel.add(jLabel11, null);
ecPanel.add(ec_phone, null);
ecPanel.add(ec_zip, null);
ecPanel.add(ec_city, null);
ecPanel.add(ec_street1, null);
ecPanel.add(ec_lastName, null);
ecPanel.add(ec_firstName, null);
ecPanel.add(jScrollPane3, null);
ecPanel.add(jScrollPane2, null);
ecPanel.add(ec_queryButton, null);
ecPanel.add(ec_bpName, null);
ecPanel.add(jLabel10, null);
jTabbedPane1.addTab("Emergency Contact Info", ecPanel);
jTabbedPane1.setSelectedIndex(0);
jTabbedPane1.setSelectedComponent(basicPersonPanel);
bp_resultsTextArea.setText("jTextArea1");
bp_firstNameTextField.setBounds(new Rectangle(25, 80, 125, 20));
bp_middleNameTextField.setBounds(new Rectangle(165, 80, 125, 20));
bp_lastNameTextField.setBounds(new Rectangle(310, 80, 125, 20));
bp_genderComboBox.setBounds(new Rectangle(25, 120, 124, 20));
bp_birthDateTextField.setBounds(new Rectangle(165, 120, 125, 20));
jLabel2.setText("First Name");
jLabel2.setBounds(new Rectangle(25, 65, 115, 15));
jLabel4.setText("Middle Name");
jLabel4.setBounds(new Rectangle(165, 65, 115, 16));
jLabel5.setText("Last Name");
jLabel5.setBounds(new Rectangle(310, 65, 115, 16));
jLabel6.setText("Gender");
jLabel6.setBounds(new Rectangle(25, 105, 70, 15));
jLabel7.setText("Birth Date (mm/dd/yyyy)");
jLabel7.setBounds(new Rectangle(165, 105, 125, 15));
bp_createButton.setText("Create");
bp_createButton.setBounds(new Rectangle(330, 15, 73, 27));
bp_updateButton.setText("Update");
bp_updateButton.setBounds(new Rectangle(415, 15, 73, 27));
bp_deleteButton.setText("Delete");
bp_deleteButton.setBounds(new Rectangle(495, 15, 73, 27));
menuFileExit.setText("Exit");
menuFileExit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
fileExit_ActionPerformed(ae);
}
});
menuHelp.setText("Help");
menuHelpAbout.setText("About");
menuHelpAbout.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
helpAbout_ActionPerformed(ae);
}
});
menuFile.add(menuFileExit);
menuBar1.add(menuFile);
menuHelp.add(menuHelpAbout);
menuBar1.add(menuHelp);
basicPersonPanel.add(bp_phoneAdd1, null);
basicPersonPanel.add(bp_emailAdd1, null);
basicPersonPanel.add(bp_addressAdd1, null);
basicPersonPanel.add(bp_stateList, null);
basicPersonPanel.add(bp_phoneDelete, null);
basicPersonPanel.add(bp_emailDelete, null);
basicPersonPanel.add(bp_addressDelete, null);
basicPersonPanel.add(bp_phoneAdd, null);
basicPersonPanel.add(bp_emailAdd, null);
basicPersonPanel.add(jLabel29, null);
basicPersonPanel.add(jLabel29e, null);
basicPersonPanel.add(bp_phoneNumber, null);
basicPersonPanel.add(bp_emailAddress, null);
basicPersonPanel.add(bp_emailPreferred, null);
basicPersonPanel.add(bp_emailActive, null);
basicPersonPanel.add(jLabel28, null);
basicPersonPanel.add(bp_phoneAreaCode, null);
basicPersonPanel.add(jLabel27, null);
basicPersonPanel.add(bp_phoneType, null);
basicPersonPanel.add(bp_emailType, null);
basicPersonPanel.add(jLabel27e, null);
basicPersonPanel.add(bp_emailType, null);
basicPersonPanel.add(jLabel26, null);
basicPersonPanel.add(bp_effectiveDate, null);
basicPersonPanel.add(bp_addressAdd, null);
basicPersonPanel.add(av_validateAddress, null);
basicPersonPanel.add(jLabel25, null);
basicPersonPanel.add(jLabel24, null);
basicPersonPanel.add(jLabel23, null);
basicPersonPanel.add(jLabel22, null);
basicPersonPanel.add(jLabel21, null);
basicPersonPanel.add(bp_addressType, null);
basicPersonPanel.add(bp_zip, null);
basicPersonPanel.add(bp_city, null);
basicPersonPanel.add(bp_street1, null);
basicPersonPanel.add(jLabel20, null);
basicPersonPanel.add(jLabel20e, null);
basicPersonPanel.add(jLabel19, null);
jScrollPane5.getViewport().add(bp_phoneList, null);
basicPersonPanel.add(jScrollPane5, null);
jScrollPane5e.getViewport().add(bp_emailList, null);
basicPersonPanel.add(jScrollPane5e, null);
jScrollPane4.getViewport().add(bp_addressList, null);
basicPersonPanel.add(jScrollPane4, null);
basicPersonPanel.add(bp_deleteButton, null);
basicPersonPanel.add(bp_updateButton, null);
basicPersonPanel.add(bp_createButton, null);
basicPersonPanel.add(jLabel7, null);
basicPersonPanel.add(jLabel6, null);
basicPersonPanel.add(jLabel5, null);
basicPersonPanel.add(jLabel4, null);
basicPersonPanel.add(jLabel2, null);
basicPersonPanel.add(bp_birthDateTextField, null);
basicPersonPanel.add(bp_genderComboBox, null);
basicPersonPanel.add(bp_lastNameTextField, null);
basicPersonPanel.add(bp_middleNameTextField, null);
basicPersonPanel.add(bp_firstNameTextField, null);
basicPersonPanel.add(bp_queryButton, null);
basicPersonPanel.add(jLabel3, null);
jScrollPane1.getViewport().add(bp_resultsTextArea, null);
basicPersonPanel.add(jScrollPane1, null);
bp_genderComboBox.addItem("Male");
bp_genderComboBox.addItem("Female");
bp_genderComboBox.addItem("Unknown");
ec_relation.addItem("Wife");
ec_relation.addItem("Husband");
ec_relation.addItem("Sister");
ec_relation.addItem("Brother");
ec_priority.addItem("1");
ec_priority.addItem("2");
ec_priority.addItem("3");
ec_priority.addItem("4");
ec_priority.addItem("5");
// bp_addressType.addItem("Home");
// bp_addressType.addItem("Office");
// bp_phoneType.addItem("Home");
// bp_phoneType.addItem("Office");
// bp_phoneType.addItem("Mobile");
this.getContentPane().add(clearButton, null);
this.getContentPane().add(jTabbedPane1, null);
this.getContentPane().add(instIdTextField, null);
this.getContentPane().add(jLabel1, null);
clearAllFields();
}
void fileExit_ActionPerformed(ActionEvent e) {
System.exit(0);
}
void helpAbout_ActionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(this, new Frame1_AboutBoxPanel1(), "About", JOptionPane.PLAIN_MESSAGE);
}
/**
* Queries for a BasicPerson and populates the screen with the person information passed
* back (if any are found matching the query criteria). Sends a
* com.any-erp-vendor.Person/BasicPerson/1.0/Query-Request to the com.any-erp-vendor.Gateway gateway.
* <P>
* <ul>
* <li>Retrieves a LightweightPerson from AppConfig
* <li>Populates the LightweightPerson object with the InstitutionalId and Name
* information entered on the form.
* <li>Retrieves the BasicPerson object from AppConfig.
* <li>Retrieves the "SelfServiceAppProducer" object from AppConfig (PointToPointProducer).
* <li>Calls the 'query' method on the BasicPerson object passing the populated LightweightPerson
* object and the SelfServiceAppProducer. This will return a java.util.List of BasicPerson objects
* if any are found that match the query criteria specified in the LightweightPerson object. In
* the case of the BasicPerson object, only one should ever be returned.
* <li>Pulls the BasicPerson object out of the returned list.
* <li>Saves a clone of the BasicPerson object that might be used later if an update
* is performed.
* <li>Populates the BasicPerson fields on the screen with data contained in the BasicPerson
* object returned from the query.
* </ul>
* <P>
* Any errors that occur during the request will be logged in the TextArea at the
* bottom of the form.
**/
protected void bp_queryButton_mouseClicked(MouseEvent e) {
clearBasicPersonFields();
String messageObjectName = BASIC_PERSON;
org.openeai.OpenEaiObject.logger.info("Message Object Name is: " + messageObjectName);
try {
LightweightPerson lPerson =
(LightweightPerson)APP_CONFIG.getObject(LIGHTWEIGHT_PERSON);
org.openeai.OpenEaiObject.logger.info("got LightweightPerson...");
lPerson.setInstitutionalId(instIdTextField.getText());
org.openeai.OpenEaiObject.logger.info("set instid on lightweight person...");
org.any_openeai_enterprise.moa.objects.resources.v1_0.Name aName = lPerson.newName();
if (bp_lastNameTextField.getText() != null && bp_lastNameTextField.getText().length() > 0) {
aName.setLastName(bp_lastNameTextField.getText());
lPerson.setName(aName);
}
if (bp_firstNameTextField.getText() != null && bp_firstNameTextField.getText().length() > 0) {
aName.setFirstName(bp_firstNameTextField.getText());
lPerson.setName(aName);
}
if (bp_middleNameTextField.getText() != null && bp_middleNameTextField.getText().length() > 0) {
aName.setMiddleName(bp_middleNameTextField.getText());
lPerson.setName(aName);
}
ActionableEnterpriseObject jeo = (ActionableEnterpriseObject)APP_CONFIG.getObject(messageObjectName);
org.openeai.OpenEaiObject.logger.info("got " + messageObjectName + " from AppConfig, performing Query...");
java.util.List a = jeo.query(lPerson, (PointToPointProducer)APP_CONFIG.getObject(SELF_SERVICE_PRODUCER));
org.openeai.OpenEaiObject.logger.info("Executed Query...");
StringBuffer results = new StringBuffer();
if (a.size() == 0) {
bp_resultsTextArea.setText("No rows found matching the query.");
}
else {
for (int i=0; i<a.size(); i++) {
BasicPerson bp = (BasicPerson)a.get(i);
baselineBasicPerson = (BasicPerson)bp.clone();
// get the addresses associated to the basic person
java.util.List addrs = bp.getAddress();
java.util.Vector vAddr = new java.util.Vector();
if (addrs.size() > 0) {
for (int j=0; j<addrs.size(); j++) {
Address addr = bp.getAddress(j);
vAddr.add(addr);
}
}
bp_addressList.setListData(vAddr);
bp_addressList.updateUI();
// get the phones associated to the basic person
java.util.List phones = bp.getPhone();
java.util.Vector vPhone = new java.util.Vector();
if (phones.size() > 0) {
for (int j=0; j<phones.size(); j++) {
Phone p = bp.getPhone(j);
vPhone.add(p);
}
}
bp_phoneList.setListData(vPhone);
bp_phoneList.updateUI();
// get the emails associated to the basic person
java.util.List emails = bp.getEmail();
java.util.Vector vEmail = new java.util.Vector();
if (emails.size() > 0) {
for (int j=0; j<emails.size(); j++) {
Email p = bp.getEmail(j);
vEmail.add(p);
org.openeai.OpenEaiObject.logger.info("Email="+p.toXmlString());
}
}
bp_emailList.setListData(vEmail);
bp_emailList.updateUI();
results.append(bp.getXmlEnterpriseObject().toXmlString() + "\n");
bp_lastNameTextField.setText(bp.getName().getLastName());
bp_firstNameTextField.setText(bp.getName().getFirstName());
bp_middleNameTextField.setText(bp.getName().getMiddleName());
bp_genderComboBox.setSelectedItem(bp.getGender());
if (bp.getBirthDate() != null && bp.getBirthDate().isEmpty() == false) {
bp_birthDateTextField.setText(bp.getBirthDate().getMonth() + "/" +
bp.getBirthDate().getDay() + "/" +
bp.getBirthDate().getYear());
}
}
bp_resultsTextArea.setText(results.toString());
}
}
catch (Exception openeaiExc) {
String errMessage = "Exception executing query. " + openeaiExc.getMessage();
org.openeai.OpenEaiObject.logger.fatal("Exception executing query.", openeaiExc);
bp_resultsTextArea.setText(errMessage);
}
}
/**
* Populates a BasicPerson object with the form data and sends a
* com.any-erp-vendor.Person/BasicPerson/1.0/Update-Request message to the
* com.any-erp-vendor.Gateway gateway.
* <P>
* <ul>
* <li>Retrieves a BasicPerson object from AppConfig
* <li>Populates the BasicPerson object with information entered on the form. This will
* be the 'NewData' in the Update-Request.
* <li>Sets the Baseline object in the BasicPerson to the one saved during the query
* earlier. This will be the 'BaselineData' in the Update-Request and is the "last known state"
* of the object according to this application.
* <li>Retrieves the "SelfServiceAppProducer" object from AppConfig (PointToPointProducer).
* <li>Calls the 'update' method on the BasicPerson object passing SelfServiceAppProducer.
* <li>Sets the local baseline BasicPerson object to the current state (the NewData from the Update-Request).
* This is a short cut so we will be able to perform another Update-Request without having to re-query for the baseline.
* </ul>
* <P>
* Any errors that occur during the request will be logged in the TextArea at the
* bottom of the form.
**/
protected void bp_updateButton_mouseClicked(MouseEvent e)
{
try {
String messageObjectName = BASIC_PERSON;
org.openeai.OpenEaiObject.logger.info("Message Object Name is: " + messageObjectName);
BasicPerson bPerson = (BasicPerson)APP_CONFIG.getObject(messageObjectName);
org.openeai.OpenEaiObject.logger.info("got " + messageObjectName + " from AppConfig, performing Update...");
populateBasicPerson(bPerson);
bPerson.setBaseline(baselineBasicPerson);
try {
bPerson.update((PointToPointProducer)APP_CONFIG.getObject(SELF_SERVICE_PRODUCER));
baselineBasicPerson = (BasicPerson)bPerson.getXmlEnterpriseObject().clone();
org.openeai.OpenEaiObject.logger.info("Executed Update request...");
bp_resultsTextArea.setText("Update was successful.");
}
catch (Exception openeaiExc) {
String errMessage = "Exception executing update. " + openeaiExc.getMessage();
org.openeai.OpenEaiObject.logger.fatal(errMessage, openeaiExc);
bp_resultsTextArea.setText(errMessage);
}
}
catch (Exception openeaiExc) {
String errMessage = "Exception executing update. " + openeaiExc.getMessage();
org.openeai.OpenEaiObject.logger.fatal("Exception executing update.", openeaiExc);
bp_resultsTextArea.setText(errMessage);
}
}
/**
* Populates a BasicPerson object with the form data and sends a
* com.any-erp-vendor.Person/BasicPerson/1.0/Create-Request message to the
* com.any-erp-vendor.Gateway gateway.
* <P>
* <ul>
* <li>Retrieves a BasicPerson object from AppConfig
* <li>Populates the BasicPerson object with information entered on the form.
* <li>Retrieves the "SelfServiceAppProducer" object from AppConfig (PointToPointProducer).
* <li>Calls the 'create' method on the BasicPerson object passing the SelfServiceAppProducer.
* </ul>
* <P>
* Any errors that occur during the request will be logged in the TextArea at the
* bottom of the form.
**/
protected void bp_createButton_mouseClicked(MouseEvent e) {
try {
String messageObjectName = BASIC_PERSON;
org.openeai.OpenEaiObject.logger.info("Message Object Name is: " + messageObjectName);
BasicPerson bPerson = (BasicPerson)APP_CONFIG.getObject(messageObjectName);
org.openeai.OpenEaiObject.logger.info("got " + messageObjectName + " from AppConfig, performing Create...");
populateBasicPerson(bPerson);
try {
bPerson.create((PointToPointProducer)APP_CONFIG.getObject(SELF_SERVICE_PRODUCER));
baselineBasicPerson = (BasicPerson)bPerson.clone();
org.openeai.OpenEaiObject.logger.info("Executed Create request...");
bp_resultsTextArea.setText("Create was successful.");
}
catch (Exception openeaiExc) {
String errMessage = "Exception executing create. " + openeaiExc.getMessage();
org.openeai.OpenEaiObject.logger.fatal(errMessage, openeaiExc);
bp_resultsTextArea.setText(errMessage);
}
}
catch (Exception openeaiExc) {
String errMessage = "Exception executing create. " + openeaiExc.getMessage();
org.openeai.OpenEaiObject.logger.fatal("Exception executing create.", openeaiExc);
bp_resultsTextArea.setText(errMessage);
}
}
/**
* Populates the BasicPerson object passed in with data from the form. This includes
* InstitutionalId, Name, Gender, BirthDate, all Address objects that are stored in the
* Address list and all Phone objects that are stored in the Phone list and all Email objects
* that are stored in the Email list.
* <P>
* When data is being set on this object, the rules specified in the Enterprise Object (EO)
* documents are applied. Depending on those rules, errors may occur but they aren't coded
* here. They're automatically applied with the setter methods are called on the objects
* involved.
* <P>
* For example, if the InstitutionalId field specified in the BasicPersonEO.xml file
* says it must be 'numeric' and it must be exactly 9 characters in length, an exception will
* be thrown if any non-numeric characters are entered into the InstitutionalId TextField on the form
* or if the data entered into that field is not equal to 9 characters in length. Non of that logic
* is coded here. It's specified in the EO document and the rules are automatically applied when
* the BasicPerson.setInstitutionalId(String) method is called.
* <P>
* @param BasicPerson the BasicPerson object to popultate.
* @throws org.openeai.moa.EnterpriseObjectException if any errors occur while populating
* the BasicPerson object.
**/
protected void populateBasicPerson(BasicPerson bPerson) throws org.openeai.moa.EnterpriseObjectException {
try {
String instId = instIdTextField.getText();
Name aName = bPerson.newName();
aName.setLastName(bp_lastNameTextField.getText());
aName.setFirstName(bp_firstNameTextField.getText());
aName.setMiddleName(bp_middleNameTextField.getText());
bPerson.setInstitutionalId(instId);
bPerson.setName(aName);
bPerson.setGender((String)bp_genderComboBox.getSelectedItem());
// get the birth date and verify it's format, then populate the
// address' effective date information with it.
SimpleDateFormat formatter = new SimpleDateFormat( "MM/dd/yyyy" );
String sDate = bp_birthDateTextField.getText();
if (sDate != null && sDate.length() > 0) {
try {
java.util.Date d = formatter.parse(sDate);
Calendar calendar = new GregorianCalendar();
calendar.setTime(d);
Date bDate = new Date("BirthDate");
bDate.setMonth(Integer.toString(calendar.get(Calendar.MONTH)+1));
bDate.setDay(Integer.toString(calendar.get(Calendar.DAY_OF_MONTH)));
bDate.setYear(Integer.toString(calendar.get(Calendar.YEAR)));
bPerson.setBirthDate(bDate);
} catch (Exception exc) {
org.openeai.OpenEaiObject.logger.fatal(exc.getMessage(), exc);
bp_resultsTextArea.setText("Invalid BirthDate '" + sDate + "' " + exc.getMessage());
return;
}
}
// get all the address objects from the address list.
javax.swing.ListModel lm = bp_addressList.getModel();
for (int i=0; i<lm.getSize(); i++) {
bPerson.addAddress((Address)lm.getElementAt(i));
}
// get all the phone objects from the address list.
javax.swing.ListModel phone_lm = bp_phoneList.getModel();
for (int i=0; i<phone_lm.getSize(); i++) {
bPerson.addPhone((Phone)phone_lm.getElementAt(i));
}
// get all the phone objects from the address list.
javax.swing.ListModel email_lm = bp_emailList.getModel();
for (int i=0; i<email_lm.getSize(); i++) {
bPerson.addEmail((Email)email_lm.getElementAt(i));
}
}
catch (Exception e) {
throw new org.openeai.moa.EnterpriseObjectException(e.getMessage());
}
}
/**
* Populates a BasicPerson object with the form data and sends a
* com.any-erp-vendor.Person/BasicPerson/1.0/Delete-Request message to the
* com.any-erp-vendor.Gateway gateway.
* <P>
* <ul>
* <li>Retrieves a BasicPerson object from AppConfig
* <li>Populates the BasicPerson object with information entered on the form.
* <li>Retrieves the "SelfServiceAppProducer" object from AppConfig (PointToPointProducer).
* <li>Calls the 'delete' method on the BasicPerson object passing the 'deleteAction'
* of 'delete' and the SelfServiceAppProducer.
* </ul>
* <P>
* Any errors that occur during the request will be logged in the TextArea at the
* bottom of the form.
**/
protected void bp_deleteButton_mouseClicked(MouseEvent e) {
try {
String messageObjectName = BASIC_PERSON;
org.openeai.OpenEaiObject.logger.info("Message Object Name is: " + messageObjectName);
BasicPerson bPerson = (BasicPerson)APP_CONFIG.getObject(messageObjectName);
org.openeai.OpenEaiObject.logger.info("got " + messageObjectName + " from AppConfig, performing Delete...");
populateBasicPerson(bPerson);
try {
bPerson.delete("delete", (PointToPointProducer)APP_CONFIG.getObject(SELF_SERVICE_PRODUCER));
org.openeai.OpenEaiObject.logger.info("Executed Delete request...");
bp_resultsTextArea.setText("Delete was successful.");
}
catch (Exception openeaiExc) {
String errMessage = "Exception executing delete. " + openeaiExc.getMessage();
org.openeai.OpenEaiObject.logger.fatal(errMessage, openeaiExc);
bp_resultsTextArea.setText(errMessage);
}
}
catch (Exception openeaiExc) {
String errMessage = "Exception executing delete. " + openeaiExc.getMessage();
org.openeai.OpenEaiObject.logger.fatal("Exception executing delete.", openeaiExc);
bp_resultsTextArea.setText(errMessage);
}
}
/**
* Retrieves the Address object stored in the List at the selected index and populates the Address
* form items with information contained in that Address object.
**/
protected void bp_addressList_mouseClicked(MouseEvent e)
{
Address a = (Address)bp_addressList.getSelectedValue();
if (a != null) {
bp_addressType.setSelectedItem(a.getType());
bp_street1.setText(a.getStreet1());
bp_city.setText(a.getCityOrLocality());
bp_stateList.setSelectedItem(a.getStateOrProvince());
bp_zip.setText(a.getZipOrPostalCode());
bp_effectiveDate.setText(a.getEffectiveDate().getMonth() + "/" +
a.getEffectiveDate().getDay() + "/" +
a.getEffectiveDate().getYear());
}
}
void clearAllFields() {
instIdTextField.setText("");
clearBasicPersonFields();
clearEmergencyContactFields();
}
void clearBasicPersonFields() {
bp_resultsTextArea.setText("");
bp_lastNameTextField.setText("");
bp_firstNameTextField.setText("");
bp_middleNameTextField.setText("");
bp_birthDateTextField.setText("");
bp_genderComboBox.setSelectedIndex(-1);
clearAddressFields();
clearPhoneFields();
clearEmailFields();
}
void clearEmergencyContactFields() {
ec_relation.setSelectedIndex(-1);
ec_priority.setSelectedIndex(-1);
ec_firstName.setText("");
ec_lastName.setText("");
clearAddressFields();
clearPhoneFields();
}
void clearAddressFields() {
bp_addressList.setListData(new java.util.Vector());
bp_addressList.updateUI();
bp_addressType.setSelectedIndex(-1);
bp_street1.setText("");
bp_city.setText("");
bp_stateList.setSelectedIndex(-1);
bp_zip.setText("");
bp_effectiveDate.setText("");
ec_street1.setText("");
ec_city.setText("");
ec_stateList.setSelectedIndex(-1);
ec_zip.setText("");
}
void clearPhoneFields() {
bp_phoneList.setListData(new java.util.Vector());
bp_phoneList.updateUI();
bp_phoneType.setSelectedIndex(-1);
bp_phoneAreaCode.setText("");
bp_phoneNumber.setText("");
ec_phone.setText("");
}
void clearEmailFields() {
bp_emailList.setListData(new java.util.Vector());
bp_emailList.updateUI();
bp_emailType.setSelectedIndex(-1);
//bp_phoneAreaCode.setText("");
bp_emailAddress.setText("");
bp_emailPreferred.setSelected(false);
bp_emailActive.setSelected(false);
}
/**
* If no items in the Address list are selected, this method will create a new Address
* object, popultate it with information contained in the Address form fields and
* add that object to the list.
* <P>
* If an item is selected, it will be replaced with an updated Address object that
* contains the currently entered Address form field information.
**/
protected void bp_addressAdd_mouseClicked(MouseEvent e)
{
String messageObjectName = BASIC_PERSON;
org.openeai.OpenEaiObject.logger.info("Message Object Name is: " + messageObjectName);
try {
Address addr = null;
int index = bp_addressList.getSelectedIndex();
if (index == -1) {
BasicPerson bPerson = (BasicPerson)APP_CONFIG.getObject(messageObjectName);
org.openeai.OpenEaiObject.logger.info("got " + messageObjectName + " from AppConfig");
addr = bPerson.newAddress();
}
else {
addr = (Address)bp_addressList.getSelectedValue();
}
addr.setType((String)bp_addressType.getSelectedItem());
addr.setStreet1(bp_street1.getText());
addr.setCityOrLocality(bp_city.getText());
addr.setStateOrProvince((String)bp_stateList.getSelectedItem());
addr.setZipOrPostalCode(bp_zip.getText());
// get the effective date and verify it's format, then populate the
// address' effective date information with it.
SimpleDateFormat formatter = new SimpleDateFormat( "MM/dd/yyyy" );
String sDate = bp_effectiveDate.getText();
try {
java.util.Date d = formatter.parse(sDate);
Calendar calendar = new GregorianCalendar();
calendar.setTime(d);
Date effDate = new Date("EffectiveDate");
effDate.setMonth(Integer.toString(calendar.get(Calendar.MONTH)+1));
effDate.setDay(Integer.toString(calendar.get(Calendar.DAY_OF_MONTH)));
effDate.setYear(Integer.toString(calendar.get(Calendar.YEAR)));
addr.setEffectiveDate(effDate);
} catch (Exception exc) {
org.openeai.OpenEaiObject.logger.fatal(exc.getMessage(), exc);
bp_resultsTextArea.setText("Invalid EffectiveDate '" + sDate + "' " + exc.getMessage());
return;
}
javax.swing.ListModel lm = bp_addressList.getModel();
java.util.Vector vAddr = new java.util.Vector();
for (int i=0; i<lm.getSize(); i++) {
vAddr.add(lm.getElementAt(i));
}
if (index != -1) {
vAddr.remove(index);
}
vAddr.add(addr);
bp_addressList.setListData(vAddr);
bp_addressList.updateUI();
}
catch (Exception exc) {
}
}
/**
* Retrieves the Phone object stored in the List at the selected index and populates the Phone
* form items with information contained in that Phone object.
**/
void bp_phoneList_mouseClicked(MouseEvent e)
{
Phone p = (Phone)bp_phoneList.getSelectedValue();
if (p != null) {
bp_phoneType.setSelectedItem(p.getType());
bp_phoneAreaCode.setText(p.getPhoneArea());
bp_phoneNumber.setText(p.getPhoneNumber());
}
}
/**
* Retrieves the Email object stored in the List at the selected index and populates the Email
* form items with information contained in that Email object.
**/
void bp_emailList_mouseClicked(MouseEvent e)
{
Email p = (Email)bp_emailList.getSelectedValue();
if (p != null) {
bp_emailType.setSelectedItem(p.getType());
//bp_phoneAreaCode.setText(p.getPhoneArea());
bp_emailAddress.setText(p.getEmailAddress());
bp_emailPreferred.setSelected(p.getPreferred().equals("Yes"));
bp_emailActive.setSelected(p.getStatus().equals("Active"));
}
}
/**
*
*
**/
void av_validateAddress_mouseClicked(MouseEvent e)
{
String messageObjectName = VALID_ADDRESS;
org.openeai.OpenEaiObject.logger.info("Message Object Name is: " + messageObjectName);
try {
AddressValidation vaddress = (AddressValidation)APP_CONFIG.getObject(messageObjectName);
AddressValidationQuerySpecification vaddressQuery = (AddressValidationQuerySpecification)APP_CONFIG.getObject("ValidAddressQuerySpecification.v1_0");;
org.openeai.OpenEaiObject.logger.info("got ValidAddress...");
com.openii.moa.objects.resources.v1_0.Address address = vaddress.newAddress();
if (!"".equals(bp_street1.getText()) && !"".equals(bp_city.getText()) && bp_stateList.getSelectedItem()!=null) {
address.setStreet1(bp_street1.getText());
address.setCityOrLocality(bp_city.getText());
address.setStateOrProvince(bp_stateList.getSelectedItem().toString());
address.setNation("US");
address.setZipOrPostalCode(bp_zip.getText());
com.openii.moa.objects.resources.v1_0.Date ed = address.newEffectiveDate();
ed.setMonth("12");
ed.setDay("5");
ed.setYear("2006");
address.setEffectiveDate(ed);
} else {
bp_resultsTextArea.setText("Address not vaild. Need Street1, City and State.");
return;
}
//vaddress.setAddress(address);
vaddressQuery.setAddress(address);
//ActionableEnterpriseObject jeo = (ActionableEnterpriseObject)APP_CONFIG.getObject(messageObjectName);
ActionableEnterpriseObject jeo = vaddress;
org.openeai.OpenEaiObject.logger.info("got " + messageObjectName + " from AppConfig, performing Query...");
java.util.List a = jeo.query(vaddressQuery, (PointToPointProducer)APP_CONFIG.getObject(ADDRESS_VALIDATION_PRODUCER));
org.openeai.OpenEaiObject.logger.info("Executed Query...");
StringBuffer results = new StringBuffer();
if (a.size() == 0) {
bp_resultsTextArea.setText("No rows found matching the query.");
}
else {
for (int i=0; i<a.size(); i++) {
AddressValidation av = (AddressValidation)a.get(i);
List b = av.getMatchStatus();
if (b.size() == 0) {
bp_resultsTextArea.setText("Can't find MatchStatus in the query.");
}
else {
if (a.size()==1) {
List c=av.getAddress();
if (c.size()==1) {
com.openii.moa.objects.resources.v1_0.Address betterAddress = (com.openii.moa.objects.resources.v1_0.Address) c.get(0);
bp_street1.setText(betterAddress.getStreet1());
bp_zip.setText(betterAddress.getZipOrPostalCode());
bp_city.setText(betterAddress.getCityOrLocality());
}
}
String msg="";
for (int j=0; j<b.size(); j++) {
MatchStatus ms = (MatchStatus)b.get(j);
msg+=ms.getStatusCode()+": "+ms.getDescription()+". ";
}
bp_resultsTextArea.setText(msg);
}
}
}
} catch (Exception openeaiExc) {
String errMessage = "Exception executing query. " + openeaiExc.getMessage();
org.openeai.OpenEaiObject.logger.fatal("Exception executing query.", openeaiExc);
bp_resultsTextArea.setText(errMessage);
}
}
/**
* If no items in the Phone list are selected, this method will create a new Phone
* object, popultate it with information contained in the Phone form fields and
* add that object to the list.
* <P>
* If an item is selected, it will be replaced with an updated Phone object that
* contains the currently entered Phone form field information.
**/
protected void bp_phoneAdd_mouseClicked(MouseEvent e)
{
String messageObjectName = BASIC_PERSON;
org.openeai.OpenEaiObject.logger.info("Message Object Name is: " + messageObjectName);
try {
Phone p = null;
int index = bp_phoneList.getSelectedIndex();
if (index == -1) {
BasicPerson bPerson = (BasicPerson)APP_CONFIG.getObject(messageObjectName);
org.openeai.OpenEaiObject.logger.info("got " + messageObjectName + " from AppConfig");
p = bPerson.newPhone();
}
else {
p = (Phone)bp_phoneList.getSelectedValue();
}
p.setType((String)bp_phoneType.getSelectedItem());
p.setPhoneArea(bp_phoneAreaCode.getText());
p.setPhoneNumber(bp_phoneNumber.getText());
javax.swing.ListModel lm = bp_phoneList.getModel();
java.util.Vector vPhones = new java.util.Vector();
for (int i=0; i<lm.getSize(); i++) {
vPhones.add(lm.getElementAt(i));
}
if (index != -1) {
vPhones.remove(index);
}
vPhones.add(p);
bp_phoneList.setListData(vPhones);
bp_phoneList.updateUI();
}
catch (Exception exc) {
}
}
/**
* If no items in the Email list are selected, this method will create a new Email
* object, popultate it with information contained in the Email form fields and
* add that object to the list.
* <P>
* If an item is selected, it will be replaced with an updated Email object that
* contains the currently entered Email form field information.
**/
protected void bp_emailAdd_mouseClicked(MouseEvent e)
{
String messageObjectName = BASIC_PERSON;
org.openeai.OpenEaiObject.logger.info("Message Object Name is: " + messageObjectName);
try {
Email p = null;
int index = bp_emailList.getSelectedIndex();
if (index == -1) {
BasicPerson bPerson = (BasicPerson)APP_CONFIG.getObject(messageObjectName);
org.openeai.OpenEaiObject.logger.info("got " + messageObjectName + " from AppConfig");
p = bPerson.newEmail();
}
else {
p = (Email)bp_emailList.getSelectedValue();
}
p.setType((String)bp_emailType.getSelectedItem());
//p.setPhoneArea(bp_phoneAreaCode.getText());
p.setEmailAddress(bp_emailAddress.getText());
if (bp_emailPreferred.isSelected()) {
p.setPreferred("Yes");
} else {
p.setPreferred("No");
}
if (bp_emailActive.isSelected()) {
p.setStatus("Active");
} else {
p.setStatus("New");
}
javax.swing.ListModel lm = bp_emailList.getModel();
java.util.Vector vEmail = new java.util.Vector();
for (int i=0; i<lm.getSize(); i++) {
vEmail.add(lm.getElementAt(i));
}
if (index != -1) {
vEmail.remove(index);
}
vEmail.add(p);
bp_emailList.setListData(vEmail);
bp_emailList.updateUI();
}
catch (Exception exc) {
}
}
/**
* Deletes the selected Phone object from the Phone list.
**/
protected void bp_phoneDelete_mouseClicked(MouseEvent e)
{
int index = bp_phoneList.getSelectedIndex();
javax.swing.ListModel lm = bp_phoneList.getModel();
java.util.Vector v = new java.util.Vector();
for (int i=0; i<lm.getSize(); i++) {
v.add(lm.getElementAt(i));
}
v.remove(index);
bp_phoneList.setListData(v);
bp_phoneList.updateUI();
bp_phoneType.setSelectedIndex(-1);
bp_phoneAreaCode.setText("");
bp_phoneNumber.setText("");
}
/**
* Deletes the selected Email object from the Email list.
**/
protected void bp_emailDelete_mouseClicked(MouseEvent e)
{
int index = bp_emailList.getSelectedIndex();
javax.swing.ListModel lm = bp_emailList.getModel();
java.util.Vector v = new java.util.Vector();
for (int i=0; i<lm.getSize(); i++) {
v.add(lm.getElementAt(i));
}
v.remove(index);
bp_emailList.setListData(v);
bp_emailList.updateUI();
bp_emailType.setSelectedIndex(-1);
//bp_phoneAreaCode.setText("");
bp_emailAddress.setText("");
bp_emailPreferred.setSelected(false);
bp_emailActive.setSelected(false);
}
/**
* Deletes the selected Address object from the Address list.
**/
protected void bp_addressDelete_mouseClicked(MouseEvent e)
{
int index = bp_addressList.getSelectedIndex();
javax.swing.ListModel lm = bp_addressList.getModel();
java.util.Vector v = new java.util.Vector();
for (int i=0; i<lm.getSize(); i++) {
v.add(lm.getElementAt(i));
}
v.remove(index);
bp_addressList.setListData(v);
bp_addressList.updateUI();
bp_addressType.setSelectedIndex(-1);
bp_street1.setText("");
bp_city.setText("");
bp_stateList.setSelectedIndex(-1);
bp_zip.setText("");
bp_effectiveDate.setText("");
}
/**
* Queries for an EmergencyContact and populates the screen with the person information passed
* back (if any are found matching the query criteria). Sends a
* com.any-erp-vendor.Person/EmergencyContact/1.0/Query-Request to the com.any-erp-vendor.Gateway gateway.
* <P>
* <ul>
* <li>Retrieves a LightweightPerson from AppConfig
* <li>Populates the LightweightPerson object with the InstitutionalId
* <li>Retrieves the BasicPerson object from AppConfig.
* <li>Retrieves the "SelfServiceAppProducer" object from AppConfig (PointToPointProducer).
* <li>Calls the 'query' method on the BasicPerson object passing the populated LightweightPerson
* object and the SelfServiceAppProducer.
* <li>Verifies that a person is returned. This is because, we can't create any
* EmergencyContacts unless the BasicPerson exists. This is just a requirement we decided
* to implement for example sake. It's actually a requirement of the Any ERP Vendor's ERP system.
* <li>If a BasicPerson exists, it retrieves an EmergencyContact object from AppConfig.
* <li>Calls the 'query' method on the EmergencyContact passing the LightweightPerson and
* SelfServiceAppProducer. This will return a java.util.List of EmergencyContacts. Each one
* of these EmergencyContact objects will be added to the EmergencyContact form List display.
* </ul>
* <P>
* Any errors that occur during the request will be logged in the TextArea at the
* bottom of the form.
**/
protected void ec_queryButton_mouseClicked(MouseEvent e)
{
// first, get the name associated to the person who's emergency contacts we're looking for
String messageObjectName = BASIC_PERSON;
org.openeai.OpenEaiObject.logger.info("Message Object Name is: " + messageObjectName);
try {
LightweightPerson lPerson =
(LightweightPerson)APP_CONFIG.getObject(LIGHTWEIGHT_PERSON);
org.openeai.OpenEaiObject.logger.info("got LightweightPerson...");
lPerson.setInstitutionalId(instIdTextField.getText());
org.openeai.OpenEaiObject.logger.info("set instid on lightweight person...");
ActionableEnterpriseObject bpJeo = (ActionableEnterpriseObject)APP_CONFIG.getObject(messageObjectName);
org.openeai.OpenEaiObject.logger.info("got " + messageObjectName + " from AppConfig, performing Query...");
java.util.List a = bpJeo.query(lPerson, (PointToPointProducer)APP_CONFIG.getObject(SELF_SERVICE_PRODUCER));
org.openeai.OpenEaiObject.logger.info("Executed Query...");
String personName = null;
if (a.size() == 0) {
ec_textArea.setText("No Person information can be found for that inst id.");
return;
}
else {
for (int i=0; i<a.size(); i++) {
BasicPerson bp = (BasicPerson)a.get(i);
personName = bp.getName().getFirstName() + " " + bp.getName().getLastName();
ec_bpName.setText(personName);
}
}
// now, query for the emerency contacts for this person using the same LightweightPerson
messageObjectName = EMERGENCY_CONTACT;
ActionableEnterpriseObject ecJeo = (ActionableEnterpriseObject)APP_CONFIG.getObject(messageObjectName);
org.openeai.OpenEaiObject.logger.info("got " + messageObjectName + " from AppConfig, performing Query...");
java.util.List eclist = ecJeo.query(lPerson, (PointToPointProducer)APP_CONFIG.getObject(SELF_SERVICE_PRODUCER));
org.openeai.OpenEaiObject.logger.info("Executed Query...");
if (eclist.size() == 0) {
ec_textArea.setText("No EmergencyContacts found for " + personName);
}
else {
ec_textArea.setText(eclist.size() + " EmergencyContacts were found for " + personName);
java.util.Vector v = new java.util.Vector();
for (int i=0; i<eclist.size(); i++) {
EmergencyContact ec = (EmergencyContact)eclist.get(i);
String ecName = ec.getName().getFirstName() + " " + ec.getName().getLastName();
v.add(ec);
}
ecList.setListData(v);
ecList.updateUI();
}
}
catch (Exception openeaiExc) {
String errMessage = "Exception executing query for EmergencyContact information. " + openeaiExc.getMessage();
org.openeai.OpenEaiObject.logger.fatal("Exception executing query.", openeaiExc);
ec_textArea.setText(errMessage);
}
}
/**
* Retrieves the EmergencyContact object from the list at the selected index and
* populates the EmergencyContact form fields with data contained within that object.
* Also, sets the baseline EmergencyContact object to be a clone of the one selected.
* This baseline object will be used when a
* com.any-erp-vendor.Person/EmergencyContact/1.0/Update-Request is sent.
**/
protected void ecList_mouseClicked(MouseEvent e)
{
EmergencyContact ec = (EmergencyContact)ecList.getSelectedValue();
try {
baselineEmergencyContact = (EmergencyContact)ec.clone();
}
catch (Exception exc) {
}
ec_relation.setSelectedItem(ec.getRelationship());
ec_priority.setSelectedItem(ec.getPriority());
ec_firstName.setText(ec.getName().getFirstName());
ec_lastName.setText(ec.getName().getLastName());
Address a = ec.getAddress();
if (a != null) {
ec_street1.setText(a.getStreet1());
ec_city.setText(a.getCityOrLocality());
ec_stateList.setSelectedItem(a.getStateOrProvince());
ec_zip.setText(a.getZipOrPostalCode());
}
Phone p = ec.getPhone();
if (p != null) {
ec_phone.setText(p.getPhoneNumber());
}
}
/**
* Populates the EmergencyContact object passed in with data from the form. This includes
* OwnerId (InstitutionalId of the person to whom this emergency contact is related),
* priority, relationship, emergency contact Name,
* emergency contact's Address and the emergency contact's Phone.
* <P>
* When data is being set on this object, the rules specified in the Enterprise Object (EO)
* documents are applied. Depending on those rules, errors may occur but they aren't coded
* here. They're automatically applied with the setter methods are called on the objects
* involved.
* <P>
* For example, if the OwnerId field specified in the EmergencyContactEO.xml file
* says it must be 'numeric' and it must be exactly 9 characters in length, an exception will
* be thrown if any non-numeric characters are entered into the InstitutionalId TextField on the form
* or if the data entered into that field is not equal to 9 characters in length. Non of that logic
* is coded here. It's specified in the EO document and the rules are automatically applied when
* the EmergencyContact.setOwnerId(String) method is called.
* <P>
* @param EmergencyContact the EmergencyContact object to popultate.
* @throws org.openeai.moa.EnterpriseObjectException if any errors occur while populating
* the EmergencyContact object.
**/
protected void populateEmergencyContact(EmergencyContact ec) throws org.openeai.moa.EnterpriseObjectException {
try {
ec.setOwnerId(instIdTextField.getText());
ec.setPriority((String)ec_priority.getSelectedItem());
ec.setRelationship((String)ec_relation.getSelectedItem());
Name name = ec.newName();
name.setFirstName(ec_firstName.getText());
name.setLastName(ec_lastName.getText());
ec.setName(name);
Address a = ec.newAddress();
// get the effective date and verify it's format, then populate the
// address' effective date information with it.
// since emergency contacts don't care about effective date, we'll just use today's date.
try {
Calendar calendar = new GregorianCalendar();
calendar.setTime(new java.util.Date());
Date effDate = new Date("EffectiveDate");
effDate.setMonth(Integer.toString(calendar.get(Calendar.MONTH)+1));
effDate.setDay(Integer.toString(calendar.get(Calendar.DAY_OF_MONTH)));
effDate.setYear(Integer.toString(calendar.get(Calendar.YEAR)));
a.setEffectiveDate(effDate);
} catch (Exception exc) {
org.openeai.OpenEaiObject.logger.fatal(exc.getMessage(), exc);
// ec_textArea.setText("Invalid EffectiveDate '" + sDate + "' " + exc.getMessage());
return;
}
// our system, doesn't care about the address types associated to emergency contacts so,
// we're going to hard code it...
a.setType("Home");
a.setStreet1(ec_street1.getText());
a.setCityOrLocality(ec_city.getText());
a.setStateOrProvince((String)ec_stateList.getSelectedItem());
a.setZipOrPostalCode(ec_zip.getText());
ec.setAddress(a);
if (ec_phone.getText() != null && ec_phone.getText().length() > 0) {
Phone p = ec.newPhone();
ec_phone.setText(p.getPhoneNumber());
ec.setPhone(p);
}
}
catch (Exception e) {
org.openeai.OpenEaiObject.logger.fatal(e.getMessage(), e);
throw new org.openeai.moa.EnterpriseObjectException(e.getMessage());
}
}
/**
* Populates an EmergencyContact object with the form data and sends a
* com.any-erp-vendor.Person/EmergencyContact/1.0/Create-Request message to the
* com.any-erp-vendor.Gateway gateway.
* <P>
* <P>
* <ul>
* <li>Retrieves an EmergencyContact object from AppConfig
* <li>Populates the EmergencyContact object with information entered on the form.
* <li>Retrieves the "SelfServiceAppProducer" object from AppConfig (PointToPointProducer).
* <li>Calls the 'create' method on the EmergencyContact object passing the SelfServiceAppProducer.
* </ul>
* <P>
* Any errors that occur during the request will be logged in the TextArea at the
* bottom of the form.
**/
protected void ec_createButton_mouseClicked(MouseEvent e)
{
try {
String messageObjectName = EMERGENCY_CONTACT;
org.openeai.OpenEaiObject.logger.info("Message Object Name is: " + messageObjectName);
EmergencyContact ec = (EmergencyContact)APP_CONFIG.getObject(messageObjectName);
org.openeai.OpenEaiObject.logger.info("got " + messageObjectName + " from AppConfig, performing Create...");
populateEmergencyContact(ec);
try {
ec.create((PointToPointProducer)APP_CONFIG.getObject(SELF_SERVICE_PRODUCER));
org.openeai.OpenEaiObject.logger.info("Executed Create request...");
ec_textArea.setText("Create was successful.");
ec_queryButton_mouseClicked(null);
}
catch (Exception openeaiExc) {
String errMessage = "Exception executing create. " + openeaiExc.getMessage();
org.openeai.OpenEaiObject.logger.fatal(errMessage, openeaiExc);
ec_textArea.setText(errMessage);
}
}
catch (Exception openeaiExc) {
String errMessage = "Exception executing create. " + openeaiExc.getMessage();
org.openeai.OpenEaiObject.logger.fatal("Exception executing create.", openeaiExc);
ec_textArea.setText(errMessage);
}
}
/**
* Populates an EmergencyContact object with the form data and sends a
* com.any-erp-vendor.Person/EmergencyContact/1.0/Delete-Request message to the
* com.any-erp-vendor.Gateway gateway.
* <P>
* <ul>
* <li>Retrieves an EmergencyContact object from AppConfig
* <li>Populates the EmergencyContact object with information entered on the form.
* <li>Retrieves the "SelfServiceAppProducer" object from AppConfig (PointToPointProducer).
* <li>Calls the 'delete' method on the EmergencyContact object passing the 'deleteAction'
* of 'delete' and the SelfServiceAppProducer.
* </ul>
* <P>
* Any errors that occur during the request will be logged in the TextArea at the
* bottom of the form.
**/
void ec_deleteButton_mouseClicked(MouseEvent e)
{
EmergencyContact ec = (EmergencyContact)ecList.getSelectedValue();
if (ec != null) {
try {
ec.delete("delete", (PointToPointProducer)APP_CONFIG.getObject(SELF_SERVICE_PRODUCER));
org.openeai.OpenEaiObject.logger.info("Executed Delete request...");
ec_textArea.setText("Delete was successful.");
ec_queryButton_mouseClicked(null);
}
catch (Exception openeaiExc) {
String errMessage = "Exception executing delete. " + openeaiExc.getMessage();
org.openeai.OpenEaiObject.logger.fatal(errMessage, openeaiExc);
ec_textArea.setText(errMessage);
}
}
}
/**
* Populates an EmergencyContact object with the form data and sends a
* com.any-erp-vendor.Person/EmergencyContact/1.0/Update-Request message to the
* com.any-erp-vendor.Gateway gateway.
* <P>
* <ul>
* <li>Retrieves a EmergencyContact object from AppConfig
* <li>Populates the EmergencyContact object with information entered on the form. This will
* be the 'NewData' in the Update-Request.
* <li>Sets the Baseline object in the EmergencyContact to the one saved when the
* EmergencyContact object was selected from the EmergencyContact List on the form.
* This will be the 'BaselineData' in the Update-Request and is the "last known state"
* of the object according to this application.
* <li>Retrieves the "SelfServiceAppProducer" object from AppConfig (PointToPointProducer).
* <li>Calls the 'update' method on the EmergencyContact object passing SelfServiceAppProducer.
* </ul>
* <P>
* Any errors that occur during the request will be logged in the TextArea at the
* bottom of the form.
**/
protected void ec_updateButton_mouseClicked(MouseEvent e)
{
try {
String messageObjectName = EMERGENCY_CONTACT;
org.openeai.OpenEaiObject.logger.info("Message Object Name is: " + messageObjectName);
EmergencyContact ec = (EmergencyContact)APP_CONFIG.getObject(messageObjectName);
org.openeai.OpenEaiObject.logger.info("got " + messageObjectName + " from AppConfig, performing Create...");
populateEmergencyContact(ec);
ec.setBaseline(baselineEmergencyContact);
try {
ec.update((PointToPointProducer)APP_CONFIG.getObject(SELF_SERVICE_PRODUCER));
org.openeai.OpenEaiObject.logger.info("Executed Update request...");
ec_textArea.setText("Update was successful.");
ec_queryButton_mouseClicked(null);
}
catch (Exception openeaiExc) {
String errMessage = "Exception executing update. " + openeaiExc.getMessage();
org.openeai.OpenEaiObject.logger.fatal(errMessage, openeaiExc);
ec_textArea.setText(errMessage);
}
}
catch (Exception openeaiExc) {
String errMessage = "Exception executing update. " + openeaiExc.getMessage();
org.openeai.OpenEaiObject.logger.fatal("Exception executing update.", openeaiExc);
ec_textArea.setText(errMessage);
}
}
/**
* Clears the Address List selection and calls the bp_addressAdd_mouseClicked method.
* This results in an Address object always being added to the list that contains the
* information specified in the Address form fields.
**/
void bp_addressAdd1_mouseClicked(MouseEvent e)
{
bp_addressList.clearSelection();
bp_addressAdd_mouseClicked(e);
}
/**
* Clears the Phone List selection and calls the bp_phoneAdd_mouseClicked method.
* This results in a Phone object always being added to the list that contains the
* information specified in the Phone form fields.
**/
protected void bp_phoneAdd1_mouseClicked(MouseEvent e)
{
bp_phoneList.clearSelection();
bp_phoneAdd_mouseClicked(e);
}
/**
* Clears the Email List selection and calls the bp_phoneAdd_mouseClicked method.
* This results in a Email object always being added to the list that contains the
* information specified in the Email form fields.
**/
protected void bp_emailAdd1_mouseClicked(MouseEvent e)
{
bp_emailList.clearSelection();
bp_emailAdd_mouseClicked(e);
}
/**
* This thread is executed when the Frame is first instantiated. It retrieves
* objects from AppConfig and uses Translations that can be found in the BasicPerson's
* Enterprise Objects (EO) document to populate the State, Address Type and Phone Type
* Drop Down combo boxes. This is just an example of how this information that's
* available to you at run time can be used if needed. By doing this, we're sure
* that this application will only be permitting allowable enterprise values for these
* fields.
* <P>
* It's executed in a Thread so the form isn't waiting on it to load these objects. That
* can happen in the background.
**/
protected class DropDownLoader implements java.lang.Runnable {
public DropDownLoader() {
}
public void run() {
try {
BasicPerson bPerson =
(BasicPerson)APP_CONFIG.getObject(BASIC_PERSON);
// state drop downs
java.util.HashMap hm = bPerson.getEnterpriseFields().getFieldsForObject("Address");
org.openeai.config.Field stateField = (org.openeai.config.Field)hm.get("StateOrProvince");
org.openeai.config.EnterpriseTranslator et = stateField.getFormatter().getTranslator();
java.util.Enumeration keys = et.getMappings().keys();
while (keys.hasMoreElements()) {
String fieldName = (String)keys.nextElement();
org.openeai.OpenEaiObject.logger.info("Field name: " + fieldName);
java.util.List l = (java.util.List)et.getMappings().get(fieldName);
for (int i=0; i<l.size(); i++) {
org.openeai.config.EnterpriseMapping em = (org.openeai.config.EnterpriseMapping)l.get(i);
bp_stateList.addItem(em.getEnterpriseValue());
ec_stateList.addItem(em.getEnterpriseValue());
}
}
bp_stateList.setSelectedIndex(-1);
ec_stateList.setSelectedIndex(-1);
// address type drop downs
org.openeai.config.Field addrTypeField = (org.openeai.config.Field)hm.get("Type");
org.openeai.config.EnterpriseTranslator et2 = addrTypeField.getFormatter().getTranslator();
java.util.Enumeration keys2 = et2.getMappings().keys();
while (keys2.hasMoreElements()) {
String fieldName = (String)keys2.nextElement();
org.openeai.OpenEaiObject.logger.info("Field name: " + fieldName);
java.util.List l = (java.util.List)et2.getMappings().get(fieldName);
for (int i=0; i<l.size(); i++) {
org.openeai.config.EnterpriseMapping em = (org.openeai.config.EnterpriseMapping)l.get(i);
bp_addressType.addItem(em.getEnterpriseValue());
}
}
bp_addressType.setSelectedIndex(-1);
// phone type drop down
java.util.HashMap hm2 = bPerson.getEnterpriseFields().getFieldsForObject("Phone");
org.openeai.config.Field phoneTypeField = (org.openeai.config.Field)hm2.get("Type");
org.openeai.config.EnterpriseTranslator et3 = phoneTypeField.getFormatter().getTranslator();
java.util.Enumeration keys3 = et3.getMappings().keys();
while (keys3.hasMoreElements()) {
String fieldName = (String)keys3.nextElement();
org.openeai.OpenEaiObject.logger.info("Field name: " + fieldName);
java.util.List l = (java.util.List)et3.getMappings().get(fieldName);
for (int i=0; i<l.size(); i++) {
org.openeai.config.EnterpriseMapping em = (org.openeai.config.EnterpriseMapping)l.get(i);
bp_phoneType.addItem(em.getEnterpriseValue());
}
}
bp_phoneType.setSelectedIndex(-1);
// email type drop down
java.util.HashMap hm3 = bPerson.getEnterpriseFields().getFieldsForObject("Email");
org.openeai.config.Field emailTypeField = (org.openeai.config.Field)hm3.get("Type");
org.openeai.config.EnterpriseTranslator et4 = emailTypeField.getFormatter().getTranslator();
java.util.Enumeration keys4 = et4.getMappings().keys();
while (keys4.hasMoreElements()) {
String fieldName = (String)keys4.nextElement();
org.openeai.OpenEaiObject.logger.info("Field name: " + fieldName);
java.util.List l = (java.util.List)et4.getMappings().get(fieldName);
for (int i=0; i<l.size(); i++) {
org.openeai.config.EnterpriseMapping em = (org.openeai.config.EnterpriseMapping)l.get(i);
bp_emailType.addItem(em.getEnterpriseValue());
}
}
bp_emailType.setSelectedIndex(-1);
}
catch (Exception exc) {
org.openeai.OpenEaiObject.logger.fatal(exc.getMessage(), exc);
}
}
}
void clearButton_mouseClicked(MouseEvent e) {
clearAllFields();
}
}