GWTApplication.server
Class FaultServiceImpl

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.google.gwt.user.server.rpc.RemoteServiceServlet
              extended by GWTApplication.server.FaultServiceImpl
All Implemented Interfaces:
com.google.gwt.user.client.rpc.RemoteService, com.google.gwt.user.server.rpc.SerializationPolicyProvider, FaultService, java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class FaultServiceImpl
extends com.google.gwt.user.server.rpc.RemoteServiceServlet
implements FaultService

This class implments all of the services which will be used by the fault database application to support the client AJAX/GWT componentry which runs on the client browser. This class is responsible for performing the business logic associated with the fault management system.

This class makes use of the SNMP4J classes which are use to allow the class to send SNMP TRAPS to the SNMP manager to inform it that new faults have been raised.

The class uses a database pool which is set up by the tomcat container which will permit the class rapid access to the database. The configuration of the database pool is part of the tomcat configuration and not the configuraiton of the fault management system.

Aside from SNMP4J API JavaDoc, one should look at the source code for the class SnmpRequest which is a console based class which can be used to create a SNMP manager/agent and is the best place to look if you want to change the SNMP code in this class as there is precious little documentation elsewhere.

Version:
$Id: FaultServiceImpl.java,v 1.47 2008/01/15 11:08:14 cb Exp $
Author:
Craige Bevil
See Also:
Serialized Form

Nested Class Summary
(package private) static class FaultServiceImpl.AdvancedDataType
           
(package private)  class FaultServiceImpl.MailManagementUnattendedFaults
          This is a timer task which will be used to mail a list of recipients the details of all faults which have remained in the new state for more than 48 hours.
(package private)  class FaultServiceImpl.NotifyPendingFaults
          This is a timer task which will mail the person assigned a fault if the fault is in a pending state for more than 7 days.
(package private)  class FaultServiceImpl.PrintNewFaultsInLastTwentyFourHours
          This is a timertask which will be used to print all new faults in the previous 24 hours to the printer in the operations room.
(package private) static class FaultServiceImpl.TextFieldsToSearch
          An enumeration of the list of fields in the fault table which contain text which is suitable to be searched as such.
 
Field Summary
private  javax.sql.DataSource dataSource
          This is a data resource from the servlet container which contains a postgres data source
private  org.apache.log4j.Logger logger
          Used for logging
private  FaultServiceImpl.MailManagementUnattendedFaults MailManagementUntendedFaultsTimerTask
          A timer task which is used to inform the relevant people when a fault has been left in the new state for more than 48 hours
private static int MAXNUMBEROFRESULTS
          Maximum number of items returned by database in one search
private  FaultServiceImpl.NotifyPendingFaults NotifyPendingFaultsTimerTask
          This is a timer task which will report faults which have been state pending for more than seven days.
private  FaultServiceImpl.PrintNewFaultsInLastTwentyFourHours printNewFaultsInLastTwentyFourHrsTimerTask
          This is a timer task which will be used to print the new faults everyday in the ops room in the morning
private  java.util.Timer PrintNewFaultsTimer
          This is a timer object which will be used for scheduling the printing of the new faults to the ops room printer
private  java.util.Timer ProduceOutstandingPendingFaultsMailShotTimer
          This is a timer object which will be used for scheduling the report of pending faults in the system to the assigned.
private  java.util.Timer ProduceUnattendedFaultsMailShotTimer
          This is a timer object which will be used for scheduling the report of unattended faults in the system to management.
private  java.util.Properties props
          Used to modify the global properties of the application
private static long sealVersionUID
           
(package private)  org.snmp4j.Snmp snmp
          This is the SNMP class which will be used to communicate with the SNMP manager
(package private)  org.snmp4j.smi.Address targetAddress
          This is the host which the SMNP TRAP fault alerts will be sent to
(package private)  org.snmp4j.TransportMapping transport
          This is the transport protocol which we will use which in our case will be UDP.
(package private)  org.snmp4j.security.USM usm
          The user based security model which will be used to when sending messages to the SNMP server
 
Constructor Summary
FaultServiceImpl()
           
 
Method Summary
 void addNewInstrumentToSystem(java.lang.String newInstrument)
          Will be used to add a new instrument to the database.
 void addNewRole(java.lang.String emailAddress, java.lang.Integer Role)
          Will be used to add a new user to the role which is specified.
 void addNewSystemToSystem(java.lang.String newSystem)
          Will be used to add a new system to the system.
 void addNewUser(java.lang.String Name, java.lang.String Surname, java.lang.String EmailAddress)
          Will add the details of a new user to the system.
 AuthenticationDetails authenticateUser(java.lang.String UserIdentifier, java.lang.String Password)
          This operation will be used to authenticate the user.
 java.lang.String calculateTotalAmountOfTimeSpentOnFault(int FaultNumber)
          Get the total amount of time which has been spent on a fault.
 void closeDatabaseConnections(java.sql.Connection connection, java.sql.Statement stmt, java.sql.ResultSet rs)
          Used for closing down database connections
 void closeFault(int faultId)
          Called to close a fault down by a user with administration priviledges.
private  int convertTimeToMinutes(java.lang.String TimeAmount)
          Used to convert the HH:MM field into minutes expressed as an integer.
 java.lang.Integer createFault(Fault newFault)
          This method will be called to create a new fault in the fault database from the data which should have been passed into the method by AJAX client which should be running on the clients web browser.
(package private)  void createFaultReportAsPDF(int faultId, com.lowagie.text.Document PDFDocument)
          Add the full details of the fault history into the PDF document ready for printing out.
 java.lang.Boolean faultExists(int faultId, boolean isEditable)
          Used by the client to establish if the fault actually exists in the database
 java.lang.String fetchHTMLFaultReport(int faultId, boolean addLinks)
          Fetch from the database the details of the fault and all of it's comments and prepare an HTML report which can be returned to the user
 java.util.ArrayList<Comment> getCommentDetails(java.lang.Integer DefectNumber)
          Get the details of a comment from the database which is associated with the fault number which was specified by the caller
 java.util.ArrayList<Person> getDutyTechnicians(boolean getOldStaff)
          Return the names of all of the duty technicians to the caller which are recalled from the fault database table DUTYTECHNICIANVIEW.
 Fault getFaultDetails(java.lang.Integer DefectNumber, java.lang.String locale)
          Get the details of the fault from the database which was specified by the caller
 FaultUpdateSnapshot getFaultsUpdated(java.util.Date timeOfLastUpdateCheck, java.lang.String locale)
          Get a list of the faults from the database which have been updated since the last time that this client checked the database.
 java.util.ArrayList<FaultType> getFaultType()
          Return the names of all of the FaultType to the caller which are recalled from the fault database table.
 FaultEntryDetails getFullFaultHistory(int defectNumber, java.lang.String locale)
          This will be used to return the full history of a fault.
 java.util.ArrayList<Instrument> getInstruments(boolean allInstruments)
          Return the names of all of the instrument to the caller which are recalled from the fault database table.
 java.util.ArrayList<Fault> getLinkedFaults(int DefectNumber)
          Gets all of the faults which are linked to the fault specified
 java.util.ArrayList<Person> getMembersOfStaffNotInGroup(java.lang.Integer GroupToExclude)
          Get a list of staff members which are not in the group people which have been specified by the caller from the database. this will be used for instance to get a list of all of the staff members except those in the TO group for instance.
private  java.util.ArrayList<Person> getPersonDetails(java.lang.String DatabaseView, java.lang.String ExclusionTable, boolean IncludeStaffWhichHaveLeft)
          Get the list of people as specified by the caller.
 java.util.ArrayList<java.lang.String> getPostscriptPrinters()
          Return a list of all of the printers which are currently accesible by this machine
 java.util.ArrayList<Fault> getQuickViewFaultData(int SearchType, java.lang.String locale)
          Get all faults which go back to a specific date which has been specified by the caller.
 java.util.ArrayList<Severity> getSeverity()
          Return the names of all of the severity to the caller which are recalled from the fault database table.
 java.util.ArrayList<Site> getSites()
          Return the names of all of the sites to the caller which are recalled from the fault database table.
 Solution getSolutionDetails(java.lang.Integer DefectNumber)
          Get the details of a solution from the database which is associated with the fault number which was specified by the caller
 java.util.ArrayList<Person> getStaffMembers(boolean getOldStaff)
          Return the names of all of the staff members to the caller which are recalled from the fault database table.
 java.util.ArrayList<State> getStates()
          Return the names of all of the states to the caller which are recalled from the fault database table.
 java.util.ArrayList getSubscribedFaults(AuthenticationDetails authenticationDetails, java.lang.String locale)
          This is used to get a list of the faults which the user specified is subscribed to
 java.util.ArrayList<Person> getSupportAstronomers(boolean getOldStaff)
          Return the names of all of the support astronomers to the caller which are recalled from the fault database table.
 java.util.ArrayList<FDBSystem> getSystems()
          Return the names of all of the system to the caller which are recalled from the fault database table.
 java.util.ArrayList<Person> getTelescopeOperators(boolean getOldStaff)
          Return the names of all of the telescope operators to the caller which are recalled from the fault database table TELESCOPEOPERATORVIEW.
 Workaround getWorkaroundDetails(java.lang.Integer DefectNumber)
          Get the details of a workaround from the database which is associated with the fault number which was specified by the caller
 void informEmailListenersFaultHasChanged(java.lang.String ContextMessage, int FaultNumber)
          Send an email to all of the people that have registered an interest in this fault.
 void init()
          Constructor.
 void linkFault(int parentFaultId, int childFaultId)
          Will be used to link a fault which is specified by the user to another fault
private  java.lang.String makeTextFieldDatabaseCompatible(java.lang.String InputString)
          Will be used to massage a text field into the correct format for insertion into the database
private  Comment packComment(java.sql.ResultSet rs)
          Pack the details of a comment result set object into an Comment object.
 Fault packFault(java.sql.ResultSet rs, boolean includeFullViewInformation)
          This will be simply used to pack the details of a fault as read out of the database into the fault class.
private  Fault packLink(java.sql.ResultSet rs)
          This will be simply used to pack the details of a linked fault into a fault structure.
private  Solution packSolution(java.sql.ResultSet rs)
          Pack the details of a solution result set object into an Solution object.
private  Workaround packWorkaround(java.sql.ResultSet rs)
          Pack the details of a workaround result set object into an Workaround object.
 java.util.ArrayList<Fault> performAdvancedSearch(java.util.HashMap SearchParameters, java.lang.String StartDate, java.lang.String EndDate, java.lang.String locale)
          Will be used to execute an advanced search across the database using the input data which has been provided.
 java.util.ArrayList<Fault> performBasicSearch(int DefectNumber, java.lang.String SearchTerms, java.lang.String DefectToSearchFor, java.lang.String StartDate, java.lang.String EndDate, java.lang.String locale)
          Will be used to execute a basic search across the database using the input data which has been provided.
 boolean printFault(int faultId, java.lang.String printer, boolean landscape)
          Will be used to print the fault specified on the printer which has been specified.
(package private)  void raiseSNMPAlert(int defectNumber, Fault fault)
          This is user to raise an SMNP alert when a fault has been raised in the system.
 void registerForFaultUpdates(java.lang.String emailAddress, int faultId)
          Used to record in the database that the user would like to be informed of updates on the fault
private  java.lang.String removeHTMLMarkUp(java.lang.String inputString)
          Used to remove all HTML up characters in a string so that the text can be printed in a PDF document.
 void resetPassword(java.lang.String emailAddress, java.lang.String confirmedPassword)
          Allow the password associated with the user which is provided to be changed to the demand password
 void set_dataSource(javax.sql.DataSource dataSource)
          Used to set the data source for this module
 void updateCommentDetails(Comment NewCommentDetails)
          This method is called to update the comment which is associated with the fault in the database
 boolean updateFault(Fault FaultUpdateDetails, java.lang.String locale)
          Used to update the details of fault which has been modified by the user.
 void updateFaultSubscriptionList(AuthenticationDetails authenticationDetails, java.util.HashMap newSubscriptionStatuses)
          Will update the list of faults which a user is subscribed to.
 void updateSolutionDetails(Solution NewSolutionDetails)
          This method is called to update the solution which is associated with the fault in the database
 void updateWorkaroundDetails(Workaround NewWorkaroundDetails)
          This method is called to update the workaround which is associated with the fault in the database
 
Methods inherited from class com.google.gwt.user.server.rpc.RemoteServiceServlet
doGetSerializationPolicy, doPost, doUnexpectedFailure, getSerializationPolicy, getThreadLocalRequest, getThreadLocalResponse, onAfterResponseSerialized, onBeforeRequestDeserialized, processCall, shouldCompressResponse
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

printNewFaultsInLastTwentyFourHrsTimerTask

private final FaultServiceImpl.PrintNewFaultsInLastTwentyFourHours printNewFaultsInLastTwentyFourHrsTimerTask
This is a timer task which will be used to print the new faults everyday in the ops room in the morning


MailManagementUntendedFaultsTimerTask

private final FaultServiceImpl.MailManagementUnattendedFaults MailManagementUntendedFaultsTimerTask
A timer task which is used to inform the relevant people when a fault has been left in the new state for more than 48 hours


NotifyPendingFaultsTimerTask

private final FaultServiceImpl.NotifyPendingFaults NotifyPendingFaultsTimerTask
This is a timer task which will report faults which have been state pending for more than seven days.


PrintNewFaultsTimer

private final java.util.Timer PrintNewFaultsTimer
This is a timer object which will be used for scheduling the printing of the new faults to the ops room printer


ProduceUnattendedFaultsMailShotTimer

private final java.util.Timer ProduceUnattendedFaultsMailShotTimer
This is a timer object which will be used for scheduling the report of unattended faults in the system to management.


ProduceOutstandingPendingFaultsMailShotTimer

private final java.util.Timer ProduceOutstandingPendingFaultsMailShotTimer
This is a timer object which will be used for scheduling the report of pending faults in the system to the assigned.


MAXNUMBEROFRESULTS

private static final int MAXNUMBEROFRESULTS
Maximum number of items returned by database in one search

See Also:
Constant Field Values

logger

private org.apache.log4j.Logger logger
Used for logging


targetAddress

org.snmp4j.smi.Address targetAddress
This is the host which the SMNP TRAP fault alerts will be sent to


transport

org.snmp4j.TransportMapping transport
This is the transport protocol which we will use which in our case will be UDP.


snmp

org.snmp4j.Snmp snmp
This is the SNMP class which will be used to communicate with the SNMP manager


usm

org.snmp4j.security.USM usm
The user based security model which will be used to when sending messages to the SNMP server


props

private java.util.Properties props
Used to modify the global properties of the application


dataSource

private javax.sql.DataSource dataSource
This is a data resource from the servlet container which contains a postgres data source


sealVersionUID

private static final long sealVersionUID
See Also:
Constant Field Values
Constructor Detail

FaultServiceImpl

public FaultServiceImpl()
Method Detail

set_dataSource

public void set_dataSource(javax.sql.DataSource dataSource)
Used to set the data source for this module

Parameters:
dataSource - The new data source

init

public void init()
Constructor. This initialises the log4j and SMTP handling. It also starts timer threads which will be used to print the details of the new faults to the printer in the ops room and also remind management when there is a fault which has been in the NEW state for more than 48 hours.

Overrides:
init in class javax.servlet.GenericServlet

getPersonDetails

private java.util.ArrayList<Person> getPersonDetails(java.lang.String DatabaseView,
                                                     java.lang.String ExclusionTable,
                                                     boolean IncludeStaffWhichHaveLeft)
                                              throws UnableToGetListException
Get the list of people as specified by the caller. It takes as an input parameter the name of database table which contains the data.

Parameters:
DatabaseView - The name of the database view which contains the details of the group of people to return.
Exclude - the people which are in this table. If this value is null then we do not exclude anything.
IncludeStaffWhichHaveLeft - Include staff which have left the organisation.
Returns:
ArrayList An ArrayList of People.
Throws:
UnableToGetListException - If there is a problem getting the list back from the database

getTelescopeOperators

public java.util.ArrayList<Person> getTelescopeOperators(boolean getOldStaff)
                                                  throws UnableToGetListException
Return the names of all of the telescope operators to the caller which are recalled from the fault database table TELESCOPEOPERATORVIEW.

Specified by:
getTelescopeOperators in interface FaultService
Returns:
ArrayList A array which contains objects of type Person.
Throws:
UnableToGetListException - If there is a problem getting the list back from the database

getDutyTechnicians

public java.util.ArrayList<Person> getDutyTechnicians(boolean getOldStaff)
                                               throws UnableToGetListException
Return the names of all of the duty technicians to the caller which are recalled from the fault database table DUTYTECHNICIANVIEW.

Specified by:
getDutyTechnicians in interface FaultService
Returns:
ArrayList A array which contains objects of type Person.
Throws:
UnableToGetListException - If there is a problem getting the list back from the database

getSupportAstronomers

public java.util.ArrayList<Person> getSupportAstronomers(boolean getOldStaff)
                                                  throws UnableToGetListException
Return the names of all of the support astronomers to the caller which are recalled from the fault database table. SUPPORTASTRONOMERVIEW.

Specified by:
getSupportAstronomers in interface FaultService
Returns:
ArrayList A array which contains objects of type Person.
Throws:
UnableToGetListException - If there is a problem getting the list back from the database


getStaffMembers

public java.util.ArrayList<Person> getStaffMembers(boolean getOldStaff)
                                            throws UnableToGetListException
Return the names of all of the staff members to the caller which are recalled from the fault database table. STAFFMEMBER.

Specified by:
getStaffMembers in interface FaultService
Returns:
ArrayList A array which contains objects of type Person.
Throws:
UnableToGetListException - If there is a problem getting the list back from the database


getSites

public java.util.ArrayList<Site> getSites()
                                   throws UnableToGetListException
Return the names of all of the sites to the caller which are recalled from the fault database table. SITES.

Specified by:
getSites in interface FaultService
Returns:
ArrayList A array which contains objects of type Site.
Throws:
UnableToGetListException - If there is a problem getting the list back from the database

getSystems

public java.util.ArrayList<FDBSystem> getSystems()
                                          throws UnableToGetListException
Return the names of all of the system to the caller which are recalled from the fault database table. SITES.

Specified by:
getSystems in interface FaultService
Returns:
ArrayList A array which contains objects of type System.
Throws:
UnableToGetListException - If there is a problem getting the list back from the database

getSeverity

public java.util.ArrayList<Severity> getSeverity()
                                          throws UnableToGetListException
Return the names of all of the severity to the caller which are recalled from the fault database table. SEVERITY.

Specified by:
getSeverity in interface FaultService
Returns:
ArrayList A array which contains objects of type Severity.
Throws:
UnableToGetListException - If there is a problem getting the list back from the database

getInstruments

public java.util.ArrayList<Instrument> getInstruments(boolean allInstruments)
                                               throws UnableToGetListException
Return the names of all of the instrument to the caller which are recalled from the fault database table. INSTRUMENT.

Specified by:
getInstruments in interface FaultService
Parameters:
allInstruments - Whether to get all instruments or just those which are not decommissioned.
Returns:
ArrayList A array which contains objects of type Instrument.
Throws:
UnableToGetListException - If there is a problem getting the list back from the database

updateFault

public boolean updateFault(Fault FaultUpdateDetails,
                           java.lang.String locale)
                    throws UnableToUpdateFaultException
Used to update the details of fault which has been modified by the user. The details should have had their format verified by the client and should be ready for simply updating the contents in the database now.

Specified by:
updateFault in interface FaultService
Parameters:
FaultUpdateDetails - This contains the details of the changes that were made to the fault which need to be re-inserted into the database.
locale - This is the locale in which we are operating within
Throws:
UnableToUpdateFaultException - If the fault could not be updated for whatever reason

createFault

public java.lang.Integer createFault(Fault newFault)
                              throws UnableToCreateFaultException
This method will be called to create a new fault in the fault database from the data which should have been passed into the method by AJAX client which should be running on the clients web browser. All of the parameters should have been verified by the client before they are sent down to this method so we will not verify them again.

Specified by:
createFault in interface FaultService
Parameters:
newFault - This structure will contain the details which are to be entered into the database when the fault is created.
Throws:
UnableToCreateFaultException - When the servlet is unable to create the fault in the database it throws this exception.

raiseSNMPAlert

void raiseSNMPAlert(int defectNumber,
                    Fault fault)
This is user to raise an SMNP alert when a fault has been raised in the system.

In order to test this facility out one must use the SmnpRequest class which comes the snmp4j package and set up an smtp manager. This can be done with something like the following :

java -cp //SNMP4J.jar org.snmp4j.tools.console.SnmpRequest -u aSecurityName -Ol 0.0.0.0/
 
The port number is the port number which the SNMP manager is to listen on. You will need to set the port in the init() method as well to match the port which the manager is using.

Parameters:
defectNumber - This is the number of the defect which has been raised
fault - The details of the fault which is to be entered.

getQuickViewFaultData

public java.util.ArrayList<Fault> getQuickViewFaultData(int SearchType,
                                                        java.lang.String locale)
Get all faults which go back to a specific date which has been specified by the caller.

Specified by:
getQuickViewFaultData in interface FaultService
Parameters:
SearchType - This is the type of search which is to be performed
locale - This is the locale which has been chosen by the user
Returns:
ArrayList This is an array of type fault which will contain the details of all of the faults which were found as part of the search.

packFault

public Fault packFault(java.sql.ResultSet rs,
                       boolean includeFullViewInformation)
                throws java.sql.SQLException
This will be simply used to pack the details of a fault as read out of the database into the fault class. It can be configured to work on either a result set from a fault view or the fault table.

Parameters:
rs - This is a result set which can be used to read the details of the fault which is to be packed.
includeFullViewInformation - Assumes that the result set belongs to a view and that we should pack all of that information as well.
Returns:
Fault This is a instance of the fault object which contains the details of the fault.
Throws:
java.sql.SQLException - If there is a problem reading the data from the database

packLink

private Fault packLink(java.sql.ResultSet rs)
                throws java.sql.SQLException
This will be simply used to pack the details of a linked fault into a fault structure. This is not the same as the packFault method as we are packing the information from the fault tabl and not a fault view. This is for reasons of performance as the SQL to get the details of the links from the database which was working across the views was taking 3 seconds to perform which was just unacceptable to such a critical section of code.

Parameters:
rs - This is a result set which can be used to read the details of the fault which is to be packed.
Returns:
Fault This is a instance of the fault object which contains the details of the fault.
Throws:
java.sql.SQLException - If there is a problem reading the data from the database

getFaultType

public java.util.ArrayList<FaultType> getFaultType()
                                            throws UnableToGetListException
Return the names of all of the FaultType to the caller which are recalled from the fault database table. FAULTTYPE.

Specified by:
getFaultType in interface FaultService
Returns:
ArrayList A array which contains objects of type FaultType.
Throws:
UnableToGetListException - If there is a problem getting the list back from the database

getStates

public java.util.ArrayList<State> getStates()
                                     throws UnableToGetListException
Return the names of all of the states to the caller which are recalled from the fault database table. STATES.

Specified by:
getStates in interface FaultService
Returns:
ArrayList A array which contains objects of type State.
Throws:
UnableToGetListException - If there is a problem getting the list back from the database

makeTextFieldDatabaseCompatible

private java.lang.String makeTextFieldDatabaseCompatible(java.lang.String InputString)
Will be used to massage a text field into the correct format for insertion into the database

Parameters:
InputString - This is the string which is to be converted

packSolution

private Solution packSolution(java.sql.ResultSet rs)
                       throws java.sql.SQLException
Pack the details of a solution result set object into an Solution object.

Parameters:
rs - This is a object which contains a database row which contains the details of a solution.
Throws:
java.sql.SQLException

updateSolutionDetails

public void updateSolutionDetails(Solution NewSolutionDetails)
This method is called to update the solution which is associated with the fault in the database

Specified by:
updateSolutionDetails in interface FaultService

getSolutionDetails

public Solution getSolutionDetails(java.lang.Integer DefectNumber)
Get the details of a solution from the database which is associated with the fault number which was specified by the caller

Specified by:
getSolutionDetails in interface FaultService
Parameters:
DefectNumber - This is the number of the fault which is associated with the solution which we are to return to the caller
Returns:
Solution This structure contains the details of the solution if there is one

updateWorkaroundDetails

public void updateWorkaroundDetails(Workaround NewWorkaroundDetails)
This method is called to update the workaround which is associated with the fault in the database

Specified by:
updateWorkaroundDetails in interface FaultService

getWorkaroundDetails

public Workaround getWorkaroundDetails(java.lang.Integer DefectNumber)
Get the details of a workaround from the database which is associated with the fault number which was specified by the caller

Specified by:
getWorkaroundDetails in interface FaultService
Parameters:
DefectNumber - This is the number of the fault which is associated with the workaround which we are to return to the caller
Returns:
Workaround This structure contains the details of the workaround if there is one

packWorkaround

private Workaround packWorkaround(java.sql.ResultSet rs)
                           throws java.sql.SQLException
Pack the details of a workaround result set object into an Workaround object.

Parameters:
rs - This is a object which contains a database row which contains the details of a workaround.
Throws:
java.sql.SQLException

updateCommentDetails

public void updateCommentDetails(Comment NewCommentDetails)
This method is called to update the comment which is associated with the fault in the database

Specified by:
updateCommentDetails in interface FaultService
Parameters:
NewCommentDetails - The details of the new comment.

getCommentDetails

public java.util.ArrayList<Comment> getCommentDetails(java.lang.Integer DefectNumber)
Get the details of a comment from the database which is associated with the fault number which was specified by the caller

Specified by:
getCommentDetails in interface FaultService
Parameters:
DefectNumber - This is the number of the fault which is associated with the comment which we are to return to the caller
Returns:
ArrayList This structure contains the details of all of the comments which are associated with the fault

packComment

private Comment packComment(java.sql.ResultSet rs)
                     throws java.sql.SQLException
Pack the details of a comment result set object into an Comment object.

Parameters:
rs - This is a object which contains a database row which contains the details of a comment.
Throws:
java.sql.SQLException

authenticateUser

public AuthenticationDetails authenticateUser(java.lang.String UserIdentifier,
                                              java.lang.String Password)
                                       throws UserAuthenticationFailedException
This operation will be used to authenticate the user. If authentication is successful then then level of priviledge will be returned to the caller otherwise an exception will be raised.

Specified by:
authenticateUser in interface FaultService
Parameters:
UserIdentifier - This is the user identifier of the user which is essentially his email address
Password - This is the password of the user
Returns:
AuthenticationDetails The level of priviledge and other data relating to the user which was logged on
Throws:
UserAuthenticationFailedException - Unable to authenticate the user.

informEmailListenersFaultHasChanged

public void informEmailListenersFaultHasChanged(java.lang.String ContextMessage,
                                                int FaultNumber)
Send an email to all of the people that have registered an interest in this fault. The details of the fault are recalled from the database and then sent out as a HTML or a text based message depending on the user preferences.

Specified by:
informEmailListenersFaultHasChanged in interface FaultService
Parameters:
ContextMessage - This abstract text which is associated with the fault
FaultNumber - This is the identifier of the fault which needs to be sent out to the user.

getMembersOfStaffNotInGroup

public java.util.ArrayList<Person> getMembersOfStaffNotInGroup(java.lang.Integer GroupToExclude)
                                                        throws UnableToGetListException
Get a list of staff members which are not in the group people which have been specified by the caller from the database. this will be used for instance to get a list of all of the staff members except those in the TO group for instance.

Specified by:
getMembersOfStaffNotInGroup in interface FaultService
Parameters:
GroupToExclude - This is the group of people which are to be exceluded from the list of staff returned to the caller. This parameter should be one of
  • FaultDatabaseConstants.TELESCOPEOPERATOR
  • FaultDatabaseConstants.DUTYENGINEERS
  • FaultDatabaseConstants.SUPPORTASTRONOMERS

Returns:
ArrayList An array of class Person of the people in the staff member list which are not in the group which was specified.
Throws:
UnableToGetListException - In the event that there is a problem getting the list of people.

addNewInstrumentToSystem

public void addNewInstrumentToSystem(java.lang.String newInstrument)
                              throws UnableToAddInstrumentException
Will be used to add a new instrument to the database.

Specified by:
addNewInstrumentToSystem in interface FaultService
Parameters:
newInstrument - The name of the new instrument
Throws:
UnableToGetPeopleListException - If there was a problem adding the new instrument to the list
UnableToAddInstrumentException

addNewSystemToSystem

public void addNewSystemToSystem(java.lang.String newSystem)
                          throws UnableToAddSystemException
Will be used to add a new system to the system.

Specified by:
addNewSystemToSystem in interface FaultService
Parameters:
newSystem - The name of the new system
Throws:
UnableToGetPeopleListException - If there was a problem adding the new system to the list
UnableToAddSystemException

addNewRole

public void addNewRole(java.lang.String emailAddress,
                       java.lang.Integer Role)
                throws UnableToAddNewRoleException
Will be used to add a new user to the role which is specified. For example the caller will be able to add a user to the list of telescope operators

Specified by:
addNewRole in interface FaultService
Parameters:
emailAddress - This is the email address of the person who is to be added to the people in the role which is specified
Role - This is the role into which the user will be added. Will be one of
  • TELESCOPEOPERATOR
  • DUTYENGINEER
  • SUPPORTASTRONOMER
Throws:
UnableToAddNewRoleException - If there is a problem adding the user to the role which was specified

addNewUser

public void addNewUser(java.lang.String Name,
                       java.lang.String Surname,
                       java.lang.String EmailAddress)
                throws UnableToAddNewUserException
Will add the details of a new user to the system.

Specified by:
addNewUser in interface FaultService
Parameters:
Name - This is the christian name of the user
Surname - This is the surname of the user
EmailAddress - This is the email address of the user
Throws:
UnableToAddNewUserException - If there was a problem adding the details of the new user to the system

resetPassword

public void resetPassword(java.lang.String emailAddress,
                          java.lang.String confirmedPassword)
                   throws UnableToChangePasswordException
Allow the password associated with the user which is provided to be changed to the demand password

Specified by:
resetPassword in interface FaultService
Parameters:
emailAddress - This is the email address of the user to have his password changed
confirmedPassword - This is the new password of the user
Throws:
UnableToChangePasswordException - When unable to update the password of the user

performBasicSearch

public java.util.ArrayList<Fault> performBasicSearch(int DefectNumber,
                                                     java.lang.String SearchTerms,
                                                     java.lang.String DefectToSearchFor,
                                                     java.lang.String StartDate,
                                                     java.lang.String EndDate,
                                                     java.lang.String locale)
                                              throws UnableToPerformSearchException
Will be used to execute a basic search across the database using the input data which has been provided. The user will simply specify a string of search terms possibly using wildcards and then this routine will attempt to match any faults which may contain any of the search terms. The method will search through all of the text fields as well as the description and the comment fields in the fault.

Specified by:
performBasicSearch in interface FaultService
Parameters:
DefectNumber - This is the defect number for which we should return the fault information.
SearchTerms - A list of search terms which will be used to index the fault information.
DefectToSearchFor - This is the defect number to search for if specified.
StartDate - This is the start date from when to look from. This could be left blank.
EndDate - This is the end date from when to stop looking for faults.
locale - This is the locale which the user has selected
Throws:
UnableToPerformSearchException

linkFault

public void linkFault(int parentFaultId,
                      int childFaultId)
               throws UnknownFaultSpecifiedException,
                      java.lang.Exception
Will be used to link a fault which is specified by the user to another fault

Specified by:
linkFault in interface FaultService
Parameters:
parentFaultId - This is the parent fault which the child fault will be linked to
childFaultId - This the fault which is to be linked to the parent fault
Throws:
UnknownFaultSpecifiedException - This exception is thrown if the fault which is specified by the user does not exist.
java.lang.Exception

getLinkedFaults

public java.util.ArrayList<Fault> getLinkedFaults(int DefectNumber)
Gets all of the faults which are linked to the fault specified

Parameters:
DefectNumber - This is the number of the fault which we are to return to the caller
Returns:
ArrayList Array of all of the faults which are linked

getFaultDetails

public Fault getFaultDetails(java.lang.Integer DefectNumber,
                             java.lang.String locale)
Get the details of the fault from the database which was specified by the caller

Specified by:
getFaultDetails in interface FaultService
Parameters:
DefectNumber - This is the number of the fault which we are to return to the caller
Returns:
Fault This structure contains the details of the fault

calculateTotalAmountOfTimeSpentOnFault

public java.lang.String calculateTotalAmountOfTimeSpentOnFault(int FaultNumber)
Get the total amount of time which has been spent on a fault. This will sum the total amount of time which has been allocated to comments, solutions and work arounds if they exist

Specified by:
calculateTotalAmountOfTimeSpentOnFault in interface FaultService
Parameters:
FaultNumber - This is the fault number for which we have to calculate the total time spent.
Returns:
String The total amount of time spent in hours and minutes in the format HH:MM

fetchHTMLFaultReport

public java.lang.String fetchHTMLFaultReport(int faultId,
                                             boolean addLinks)
                                      throws UnknownFaultSpecifiedException
Fetch from the database the details of the fault and all of it's comments and prepare an HTML report which can be returned to the user

Parameters:
faultId - This is the identifier of the fault which is to be printed
addLinks - Add the links which will allow user to log into the system and modify the fault
Returns:
String A string which contains a HTML based fault report
Throws:
UnknownFaultSpecifiedException - Unknown fault exception.

convertTimeToMinutes

private int convertTimeToMinutes(java.lang.String TimeAmount)
Used to convert the HH:MM field into minutes expressed as an integer.

Parameters:
TimeAmount - Time expressed in Hours:Minutes
Returns:
int The amount expressed in minutes.

registerForFaultUpdates

public void registerForFaultUpdates(java.lang.String emailAddress,
                                    int faultId)
Used to record in the database that the user would like to be informed of updates on the fault

Specified by:
registerForFaultUpdates in interface FaultService
Parameters:
emailAddress - this is the email address of the person that wants to recieve updates
faultId - This is the fault identifier of the fault that the wants to get updates for

printFault

public boolean printFault(int faultId,
                          java.lang.String printer,
                          boolean landscape)
                   throws UnknownPrinterSpecifiedException
Will be used to print the fault specified on the printer which has been specified. The method uses an external agent pdf2ps to convert the PDF which is created into postscript before it is printed. It is therefore important to ensure that this process exists and is configured on the machine which is hosting the fault database.

Specified by:
printFault in interface FaultService
Parameters:
faultId - This is the identifier of the fault to be printed
printer - This is the name of the printer which is to be used to print fault
landscape - True if the document is to be printed in landscape mode
Returns:
boolean True if we managed to print out the fault
Throws:
UnknownPrinterSpecifiedException - If the printer that was specified by the user does not exist

createFaultReportAsPDF

void createFaultReportAsPDF(int faultId,
                            com.lowagie.text.Document PDFDocument)
                      throws UnknownFaultSpecifiedException
Add the full details of the fault history into the PDF document ready for printing out.

Parameters:
faultId - This is the identifier of the fault
PDFDocument - This is the PDF document to which the fault details are to be added
Throws:
UnknownFaultSpecifiedException - If the fault specified cannot be found.

getPostscriptPrinters

public java.util.ArrayList<java.lang.String> getPostscriptPrinters()
Return a list of all of the printers which are currently accesible by this machine

Specified by:
getPostscriptPrinters in interface FaultService
Returns:
ArrayList A list of the printers which can print postscript from this machine

removeHTMLMarkUp

private java.lang.String removeHTMLMarkUp(java.lang.String inputString)
Used to remove all HTML up characters in a string so that the text can be printed in a PDF document.

Parameters:
inputString - The string to be converted.
Returns:
The converted string without the markup characters.

performAdvancedSearch

public java.util.ArrayList<Fault> performAdvancedSearch(java.util.HashMap SearchParameters,
                                                        java.lang.String StartDate,
                                                        java.lang.String EndDate,
                                                        java.lang.String locale)
                                                 throws UnableToPerformSearchException
Will be used to execute an advanced search across the database using the input data which has been provided.

Specified by:
performAdvancedSearch in interface FaultService
Parameters:
SearchParameters - These are the search parameters which will be used to search across the database.
locale - This is the locale which we are operating in
StartDate - This is the start date from when to look from. This could be left blank.
EndDate - This is the end date from when to stop looking for faults.
Returns:
ArrayList A list of the parameters which match the search criteria.
Throws:
UnableToPerformSearchException - If we were unable to perform the search for whatever reason.

closeFault

public void closeFault(int faultId)
                throws UnableToCloseFaultException
Called to close a fault down by a user with administration priviledges.

Specified by:
closeFault in interface FaultService
Parameters:
faultId - This is is the number of the fault which is to be closed down.
Throws:
UnableToCloseFaultException - Thrown when the method is unable to close down the fault for whatever reason.

getFaultsUpdated

public FaultUpdateSnapshot getFaultsUpdated(java.util.Date timeOfLastUpdateCheck,
                                            java.lang.String locale)
Get a list of the faults from the database which have been updated since the last time that this client checked the database. We return to the caller an array of the full history of the faults which have been changed.

Specified by:
getFaultsUpdated in interface FaultService
Parameters:
timeOfLastUpdateCheck - This is the time that we last checked to see if the faults we are interested in were updated
locale - This is the locale which we are operating in
Returns:
FaultUpdateSnapshot The details of all of the faults which have been updated since the time specified

faultExists

public java.lang.Boolean faultExists(int faultId,
                                     boolean isEditable)
Used by the client to establish if the fault actually exists in the database

Specified by:
faultExists in interface FaultService
Parameters:
faultId - The defect number of the fault to be checked
isEditable - Check that the fault is editable
Returns:
boolean True if the fault exists

closeDatabaseConnections

public void closeDatabaseConnections(java.sql.Connection connection,
                                     java.sql.Statement stmt,
                                     java.sql.ResultSet rs)
Used for closing down database connections

Parameters:
connection - Connection to the database to be closed.
stmt - Statement to be closed.
rs - Result set to be closed.

getFullFaultHistory

public FaultEntryDetails getFullFaultHistory(int defectNumber,
                                             java.lang.String locale)
This will be used to return the full history of a fault. This includes the fault itself, any workaround, any solution, any comments and any links.

Specified by:
getFullFaultHistory in interface FaultService
Parameters:
defectNumber - The fault number for the fault
locale - This is the locale to use
Returns:
FaultEntryDetails The full history of the fault

getSubscribedFaults

public java.util.ArrayList getSubscribedFaults(AuthenticationDetails authenticationDetails,
                                               java.lang.String locale)
This is used to get a list of the faults which the user specified is subscribed to

Specified by:
getSubscribedFaults in interface FaultService
Parameters:
authenticationDetails - The details of the person that has logged into the system.
locale - The locale which the user has selected
Returns:
ArrayList This is a list of faults which the user is subscribed to

updateFaultSubscriptionList

public void updateFaultSubscriptionList(AuthenticationDetails authenticationDetails,
                                        java.util.HashMap newSubscriptionStatuses)
Will update the list of faults which a user is subscribed to.

Specified by:
updateFaultSubscriptionList in interface FaultService
Parameters:
authenticationDetails - Details of the user
newSubscriptionStatuses - This is a hashmap of the subscription statues of faults