Weather Station Data Management System Software Design Document Version 2.5 4/15/2009 Document Control Approval The Guidance Team and the customer shall approve this document. Document Change Control Initial Release:1.5Current Release:2.5Indicator of Last Page in Document:Q.E.DDate of Last Review:04/15/09Date of Next Review:04/15/09Target Date for Next Update:04/15/09 Distribution List This following list of people shall receive a copy of this document every time a new version of this document becomes available: Guidance Team Members: Dr. Steve Roach B.S Evelyn Torres Customer: Dr. Craig Tweedie Software Team Members: Carmen Avila Neith Estrada Antonio Garza Albert Hernandez Veronica Valenzuela Leonel Villagomez Change Summary The following table details changes made between versions of this document VersionDateModifierDescription2.004/13/09TeamInitial Draft2.104/14/09Neith EstradaModified Sections 2,7 and 82.204/14/09Antonio GarzaModified Sections 2, 3 and 52.304/15/09Veronica ValenzuelaModified Sections 1, 42.404/15/09Carmen AvilaModified Sections 2 and 62.504/15/09Leonel VillagomezModified Section 1 Table of Contents TOC o "
h z Document Control PAGEREF _Toc227597700 h ii Approval PAGEREF _Toc227597701 h ii Document Change Control PAGEREF _Toc227597702 h ii Distribution List PAGEREF _Toc227597703 h ii Change Summary PAGEREF _Toc227597704 h ii Introduction PAGEREF _Toc227597705 h 1 1.1Purpose and Intended Audience PAGEREF _Toc227597706 h 1 1.2Scope of Product PAGEREF _Toc227597707 h 1 1.3References PAGEREF _Toc227597708 h 1 1.4Definitions, Acronyms, and Abbreviations PAGEREF _Toc227597709 h 1 1.1.1Definitions PAGEREF _Toc227597710 h 1 1.4.1Acronyms and Abbreviations PAGEREF _Toc227597711 h 2 1.5Overview PAGEREF _Toc227597712 h 2 2Decomposition Description PAGEREF _Toc227597713 h 3 2.1System Collaboration Diagram PAGEREF _Toc227597714 h 3 2.2Subsystem and Component Descriptions PAGEREF _Toc227597715 h 4 3Detailed Description of API Component PAGEREF _Toc227597716 h 6 3.1API Component PAGEREF _Toc227597717 h 6 3.2ServerProtocol Class PAGEREF _Toc227597718 h 6 3.2.1Contract 1: Manage interaction between database and other subsystems. PAGEREF _Toc227597719 h 6 3.3DatabaseServer Class PAGEREF _Toc227597720 h 7 3.4PHPObjectGenerator Class PAGEREF _Toc227597721 h 7 4Detailed Description of Query Manager Component PAGEREF _Toc227597722 h 8 4.1Query Manager Component PAGEREF _Toc227597723 h 8 4.2SecureQueryVerifer Class PAGEREF _Toc227597724 h 8 4.3QueryGenerator Class PAGEREF _Toc227597725 h 9 4.3.1Contract 2: Construct SQL Query String PAGEREF _Toc227597726 h 9 4.4UpdateQueryGen Class PAGEREF _Toc227597727 h 10 4.5InsertIntoQueryGen Class PAGEREF _Toc227597728 h 10 4.6SelectFromQueryGen Class PAGEREF _Toc227597729 h 10 4.7RemoveFromQueryGen Class PAGEREF _Toc227597730 h 10 5Detailed Description of Database Connection Manager Component PAGEREF _Toc227597731 h 11 5.1Database Connection Manager Component PAGEREF _Toc227597732 h 11 5.2ConnectionExecuter Class PAGEREF _Toc227597733 h 11 5.2.1Contract 3: Execute a query string. PAGEREF _Toc227597734 h 11 5.3DataSetConfiguration Class PAGEREF _Toc227597735 h 12 6Detailed Description of Unit Conversion Component PAGEREF _Toc227597736 h 13 6.1Unit Conversion Component PAGEREF _Toc227597737 h 13 6.2AuxiliaryClass PAGEREF _Toc227597738 h 13 6.3EvaluationClass PAGEREF _Toc227597739 h 14 6.4ConverterClass PAGEREF _Toc227597740 h 15 6.4.1Contract 5: Do Unit Conversion PAGEREF _Toc227597741 h 15 7Detailed Description of Email Notification Component PAGEREF _Toc227597742 h 16 7.1Email Notification Component PAGEREF _Toc227597743 h 16 7.2EmailManager Class PAGEREF _Toc227597744 h 16 7.2.1Contract 6 Send Email Notification PAGEREF _Toc227597745 h 16 Appendix A: Weather Database Schema PAGEREF _Toc227597746 h 17 Appendix B: DataSet and Cell Objects PAGEREF _Toc227597747 h 18 Introduction Purpose and Intended Audience The purpose of creating a Software Design Document (SDD) is to provide an overall guidance of the architecture and design of the AWSD Database subsystem. The intent of this document is to give a detailed description of how the Database subsystem is divided in order to better fulfill the requirements of the client. Furthermore, the SDD should adequately provide any information needed by developers in order to understand the lifecycle of the subsystem and implement the Database subsystem. Scope of Product Global warming produced by activities such as, pollution from automobiles and oil refineries, has become a great concern due to its negative impact on the planet. In order to better understand how global warming is affecting the planet, ecologists are now trying to collect and study patterns of climate change. When analyzed, the collection of climate data could play a crucial role in understanding the past, present, and future climate change patterns. Due to advances in technology it is now possible to deploy weather stations around the globe to collect data about a climate such as temperature, amount of rainfall, among others automatically. The collection of data by these weathers stations gives an enormous volume of data, which makes it hard for an Ecologist to do by hand or even in a spreadsheet. Therefore, Dr. Craig Tweedie and researchers in the Systems Ecology Lab (SEL) at the University of Texas at El Paso (UTEP) are seeking to create a system on which the collection and analysis of climate data can be easily done. In response to this need the 2009 Software Engineering II class is designing and implementing an Automatic Weather Station Database system. The AWSD Database subsystem assigned to Team CAT.6 is responsible for the management of all weather station data. The management of the weather data includes allowing other subsystems a means of communicating with Weather Database. The Database subsystem is also responsible for the email notification and unit conversion functionality. References . S. Roach, F. Modave, “Automatic Weather Station Database SRS”, UTEP Software Engineering 2009, [Online document], 2009 Jan 24, available at: http://courses.utep.edu/Default.aspx?tabid=40297 . S. Roach, “Software Design Document”, available at: http://courses.utep.edu/Default.aspx?tabid=5661 Definitions, Acronyms, and Abbreviations Definitions CouplingThe degree to which each component relies on each one of the other component.CollaborationCooperation and interaction between components.ComponentIn this document a component refers to a subsystem or a subdivision.DatasetThe collection of data returned from the Database, usually presented in tabular form.DatabaseA comprehensive collection of related data organized for convenient access, generally in a computer.Design EntitiesSubsystems and classes.InterfaceA means of communication and interaction between two entities which could be the system and the user, as an example.MetadataData that provides information about other data. In this system, metadata describes the weather data uploaded such as time, sensor serial number, and weather station serial number.Query A command sent to a DBMS to extract or update information in the database. In this system, queries are sent to the DBMS in SQL.SchemaThe description of the tables and views in a database together with the relationships between them. Acronyms and Abbreviations APIApplication Program InterfaceAWSDAutomatic Weather Station DatabaseDBDatabaseDBMSDatabase Management SystemNMNotification ManagerUCUnit ConversionWSWeather Station Overview Throughout this document the Database subsystem will be described in terms of its decomposition, dependency and detailed design. The decomposition section contains information regarding the structure of the system along with the major division between the design entities. The dependency section describes the design entities and any collaboration within the system. Last but not least, the detailed design section provides internal descriptions of each component ant its organization. Decomposition Description The descriptions of our components will enable designers and maintainers to better identify the major entities and responsibilities of each of the entities by providing them with an encapsulated description of the main areas that our domain for database management covers. These descriptions will offer insight of the designers and maintainers on what responsibilities each entity was designed to fulfill. System Collaboration Diagram The AWSD system is divided into five design entities, these being the System (or Administrator) Tools, the Data Provider subsystem, the Search subsystem, the Data Analysis, and the Database subsystem. Each of these subsystems contains one of the main functionalities the system is to offer the user. The Database design entity is responsible for managing the database and the communication with it. The Search subsystem's main focus is the interaction that the user has in order to look up data from the database, and offering a mechanism for doing so. The Data Analysis is responsible for taking whatever data set a user generated with a search and generating analysis and plots on the given data. The Data Provider subsystem is responsible for all interaction that a user has in order to add new data to the system's database, including all security and validation checks. And finally, the System Tools design entity relates to all functionality the administrator needs in order to fully manage the system, including user interfaces to do so. In addition to the five mentioned subsystems, an Email Notification design entity, which belongs to the Database subsystem, is responsible for notifying users of changes in the data he or she may have used in the past. Figure 2.1 AWSD UML Component Diagram Subsystem and Component Descriptions Figure 2.2 Database Subsystem UML Component Diagram API Description: Provide functions for the others subsystems for them to communicate with the Weather Database.
*API component can be found in section 3
1.- Manage interaction between Weather Database and other design entities.
Query Manager: Description: Generate an sql query given a string *Query Manager component can be found in section 4 Contracts: 2. Construct sql query and pass query to QueryExecuter Database Connection Manager: Description: Connect to the database and manages queries to retrieve and update the database. As well as generate and format the data set that is to be returned from a query. *ConnectionExecuter component can be found in section 5 Contracts: 3.- Execute a query string. Unit Conversion: Description: This component is used as the name indicates to convert units. If we have a record in the database such as temperature sensor in Celsius unit and the user wants to see those records in Fahrenheit units, we use the component of Unit Conversion to perform the task. *Unit Conversion component can be found in section 6 Contracts: 4.- Provide any unit conversion that the user wants. NotificationManager: Description: This component keeps track the changes done to data in the weather database and notifies users who requested the notification. This component also should keep track of the last run of notification process. *NotificationManager component can be found in section 7 Contracts: 5.- Send email Notifications Detailed Description of API Component API Component Purpose: Provide functions for the others subsystems for them to communicate with the Weather Database. Classes: ServerProtocol, DatabaseServer, PHPObjectGenerator, WebServerManager. Figure 4.1 API Component UML Class Diagram ServerProtocol Class Description: Responsible for receiving incoming requests from other subsystems. Super Classes: none Private responsibilities:
Receive incoming data request.
Manage type of request for storing or retrieving data.
Contract 1: Manage interaction between database and other subsystems. Description: Manage incoming requests from other subsystems to the database. Responsibilities:
Receive incoming data request.
Translate from PHP instances to Java instances and vice versa.
Generate and decompose a PHP DataSet object.
Protocols: public String processInput(Array theInput) Pre-conditions:
Have access to the internet
Have connection to database server
The request was passed to the class database server class.
public void translatePHPObject(Object o) Pre-conditions:
Object received is php object
A 2D java array was created.
public void translateJavaObject(Object o) Pre-conditions:
Object received is java object
A 2D PHP array was created.
DatabaseServer Class Description: This class works as a means of communicating the PHP language side to the Java side. Super Classes: none Private responsibilities:
Translate PHP instances to Java instances.
Translate Java instances to PHP instances.
PHPObjectGenerator Class Description: This class composes and decomposes the DataSet (appendix B) object from and to PHP. Super Classes: nonePrivate responsibilities:
Populate a PHP language object to be passed back to the calling component.
Retrieve data from PHP language object to transform to Java data.
Detailed Description of Query Manager Component Query Manager Component Purpose: The Query Manager component is responsible for managing the construction of sql queries from a string provided by the API. This component contains a number of classes responsible for generating one of four query types. The query types include insert, update, select, and remove from the Weather Database. Classes: QueryGenerator, SecureQueryVerifier, UpdateQueryGen, InsertIntoQueryGen, SelectFromQueryGen, RemoveFromQueryGen Figure 4.1 Query Manager Component UML Class Diagram SecureQueryVerifer Class Description: Generate a sql query string Private responsibilities:
Make Query Verification
Know the rules to verify security
Inform of an unsafe query
Send safe string to QueryExecuter
QueryGenerator Class Description: Generate a sql query string Private responsibilities:
Accept a string as parameter
Know how to construct appropriate select, update, remove, or select sql query string
Construct sql query
Send newly constructed sql query to SecureQueryVerifier
Protocols: public string update(String sqlQuery) Pre-condition:
Receive query string
Return an update sql query to QueryExecutor
Source Class: UpdateQueryGen public string insertInto(String sqlQuery) Pre-condition:
Receive query string
Return an insert sql query to QueryExecutor
Source Class: InsertIntoQueryGen public string selectFrom(String sqlQuery) Pre-condition:
Receive query string
Return a select sql query to QueryExecutor
Source Class: SelectFromQueryGen public string removeFrom(String sqlQuery) Pre-condition:
Receive query string
Return a remove sql query to QueryExecutor
Source Class: RemoveFromQueryGen UpdateQueryGen Class Description: Constructs an update sql query Super Classes: QueryGenerator Private responsibilities:
Have template for an update string
Generate an update query string
InsertIntoQueryGen Class Description: Constructs an insert sql query. Super Classes: QueryGenerator Private responsibilities:
Have template for an insert string
Generate an insert query string
SelectFromQueryGen Class Description: Constructs a select sql query. Super Classes: QueryGenerator Private responsibilities:
Have template for a select string
Generate a select query string
RemoveFromQueryGen Class Description: Constructs a remove sql query. Super Classes: QueryGenerator Private responsibilities:
Have template for a remove string
Generate a remove query string
Detailed Description of Database Connection Manager Component Database Connection Manager Component Purpose: Manage all relation between the system’s implementation and the database. Classes: ConnectionExecuter, DataSetConfiguration, and PHPObjectGenerator. Figure 5.1 Database Connection Manager Component UML Class Diagram ConnectionExecuter Class Description: responsible for creating the connection to the PostgreSQL database and the execution of query strings. Super Classes: none Private responsibilities:
Create a secure connection to the PostgreSQL database.
Close the connection to the database.
Execute a data retrieval query string.
Execute a database modification query string
Contract 3: Execute a query string. Name: Execute a query string (3) Description: Execute a query to the database. Responsibilities:
Create a connection with the database.
Execute query string.
Close connection to the database.
Protocols public void connect() Pre-Conditions: - Database user login is not null. - Database password is not null. Post-Conditions: Connection is not null. public void closeConnection() Pre-Conditions: Connection is not null. Post-Conditions: Connection is null. public void insertInto(String) Pre-Conditions: - Connection is not null. - Given string is not null. - Insert string is has been tested for security. - Insert string is in the correct format. Post-Conditions:
Database has been modified.
public resultSet selectFrom(String) Pre-Conditions: - Connection is not null. - Given string is not null. - Select string is has been tested for security. - Select string is in the correct format. Post-Conditions:
Returned result set is not null.
public void updateInto(String) Pre-Conditions: - Connection is not null. - Given string is not null. - Update string is has been tested for security. - Update string is in the correct format. Post-Conditions:
Database has been modified.
DataSetConfiguration Class Description: responsible for taking the result set data from the ConnectionExecuter and modifying it in order to pass to the system a version of the data that is formatted and understandable to satisfy the user’s needs. Super Classes: none Private responsibilities:
Generate an object containing the resulting data of the user query.
Managing any other result that may be necessary to be returned from the database
Detailed Description of Unit Conversion Component Unit Conversion Component Purpose: This component is going to be use in case the user wants a different unit measure from the one stored in the database. The name of this component is UnitConversion Manager. The purpose is to provide to user the option of analyze data on different measurement units. Classes: ConverterClass, AuxiliaryClass, and EvaluateClass. Figure 6.1 Unit Conversion Component UML Class Diagram AuxiliaryClass Description: This class is in charge of provides methods to help other classes. This component contains three methods. Super Classes: none Private responsibilities:
Find variable in the formula.
Identify operators in the formula.
Find index of each operator.
Protocols public int findVariable(String tokens, String current) Pre-Conditions: The formula that is going to be represented as an array of strings named tokens is no empty. The formula has to contain a variable that is equal to the parameter passed named current. Post-Conditions: Return the index of the variable in the formula. public ArrayList findOperators(String tokens) Pre-Conditions: The formula that is going to be represented as an array of strings named tokens is no empty. The formula contains at least one operator. Post-Conditions: Return a list of operators ordered according to operators hierarchy. public int findIndex(String tokens, String operator) Pre-Conditions: The formula that is going to be represented as an array of strings named tokens is no empty. The formula contains at least one operator. Post-Conditions: Return the index of the operator passed as parameter. EvaluationClass Description: This class is in charge of do the appropriate operation on each expression and send results to the ConverterClass. This component has two methods. Super Classes: none Private responsibilities:
Evaluate expression inside parenthesis and send back the formula without parenthesis.
Evaluate complete formula.
Protocols public double evaluateFormula(String tokens, ArrayList operators) Pre-Conditions: The formula that is going to be represented as an array of strings named tokens is no empty. The formula has at least one operator. Post-Conditions: Return the new value in the unit requested. public String eliminateParentesis(String tokens) Pre-Conditions: The formula that is going to be represented as an array of strings named tokens is no empty. Post-Conditions: Do operations inside parenthesis and return the new array of tokens without parenthesis. ConverterClass Description: This class is in charge of receives the unit conversion request and send back the array of strings with the new values to the query results. This component has only one method. Super Classes: none Private responsibilities:
Send the array of values to the EvaluateClass to obtain new values.
Contract 5: Do Unit Conversion Description: Provide user any unit they want. Responsibilities:
Provide new values to the query results.
Protocol: String doConversion(String values,String current,String request,String formula) Pre-Conditions: The formula that is going to be represented as an array of strings named tokens is no empty. The parameter current is the one store in the database it is no empty. The parameter request is the measure unit that the user wants it is no empty. The parameter formula is the formula we are going to use to do the conversion it is no empty and it contains the current as the only variable. Post-Conditions: Return a string array that contains all values in the unit requested. Detailed Description of Email Notification Component Email Notification Component Purpose: Keep track the changes done to data in the weather database and notifies users who requested the notification. This component also should keep track of the last run of notification process. Classes: EmailManager EmailManager Class Description: This class sends emails to users when there was a change in the data. Super Classes: none Private responsibilities:
Access the database and identify changes in it.
Get a list of affected users from the database.
Contract 6 Send Email Notification Name: Send Email Notification (1) Description: send email to users who download a query that was changed. Responsibilities:
Send only one mail for user each time.
Generate the mail to be send.
Protocols public void genEmail() Pre-Conditions: - Service of the Database is running - ConnectionExecuter class is in the src folder. Post-Conditions: Emails addresses were got from the database. Emails were sent The notification flag field was changed to false. public ArrayList removeDuplicateEmails() Pre-Conditions: List of emails address from the database was created. Post-Conditions: A list without duplicate emails was created. public void sendMail(ArrayList emailAddress, String query) Pre-Conditions: Have access to the internet. List of email s addresses Post-Conditions: Emails were sent. Appendix A: Weather Database Schema 22925-2841 Appendix B: DataSet and Cell Objects Q.E.D