sdd 4

29
CAT.6 Weather Station Data Management System Software Design Document Version 2.5 6/6/22 2009 CAT.6

Upload: guifei-shi

Post on 01-Sep-2014

561 views

Category:

Design


2 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Sdd 4

CAT.6

Weather Station Data Management SystemSoftware Design Document

Version 2.54/7/23

2009 CAT.6

Page 2: Sdd 4

Software Design Document

Document Control

ApprovalThe Guidance Team and the customer shall approve this document.

Document Change ControlInitial Release: 1.5

Current Release: 2.5Indicator of Last Page in Document: Q.E.D

Date of Last Review: 04/15/09Date of Next Review: 04/15/09

Target Date for Next Update: 04/15/09

Distribution ListThis 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 RoachB.S Evelyn Torres

Customer: Dr. Craig Tweedie

Software Team Members:

Carmen AvilaNeith EstradaAntonio GarzaAlbert HernandezVeronica ValenzuelaLeonel Villagomez

Change SummaryThe following table details changes made between versions of this document

Version Date Modifier Description2.0 04/13/09 Team Initial Draft2.1 04/14/09 Neith Estrada Modified Sections 2,7 and 82.2 04/14/09 Antonio Garza Modified Sections 2, 3 and 52.3 04/15/09 Veronica Valenzuela Modified Sections 1, 42.4 04/15/09 Carmen Avila Modified Sections 2 and 62.5 04/15/09 Leonel Villagomez Modified Section 1

Software Design Document CAT.6 Date

Page

Page 3: Sdd 4

Software Design Document

Table of Contents

DOCUMENT CONTROL............................................................................................................................II

APPROVAL.....................................................................................................................................................IIDOCUMENT CHANGE CONTROL....................................................................................................................IIDISTRIBUTION LIST.......................................................................................................................................IICHANGE SUMMARY......................................................................................................................................II

INTRODUCTION..........................................................................................................................................1

1.1 PURPOSE AND INTENDED AUDIENCE.................................................................................................11.2 SCOPE OF PRODUCT..........................................................................................................................11.3 REFERENCES......................................................................................................................................11.4 DEFINITIONS, ACRONYMS, AND ABBREVIATIONS.............................................................................1

1.1.1 Definitions.................................................................................................................................11.4.1 Acronyms and Abbreviations....................................................................................................2

1.5 OVERVIEW.........................................................................................................................................2

2 DECOMPOSITION DESCRIPTION...................................................................................................3

2.1 SYSTEM COLLABORATION DIAGRAM................................................................................................32.2 SUBSYSTEM AND COMPONENT DESCRIPTIONS.................................................................................4

3 DETAILED DESCRIPTION OF API COMPONENT.......................................................................6

3.1 API COMPONENT..............................................................................................................................63.2 SERVERPROTOCOL CLASS.................................................................................................................6

3.2.1 Contract 1: Manage interaction between database and other subsystems..............................63.3 DATABASESERVER CLASS................................................................................................................73.4 PHPOBJECTGENERATOR CLASS.......................................................................................................7

4 DETAILED DESCRIPTION OF QUERY MANAGER COMPONENT.........................................8

4.1 QUERY MANAGER COMPONENT.......................................................................................................84.2 SECUREQUERYVERIFER CLASS.........................................................................................................84.3 QUERYGENERATOR CLASS...............................................................................................................9

4.3.1 Contract 2: Construct SQL Query String.................................................................................94.4 UPDATEQUERYGEN CLASS.............................................................................................................104.5 INSERTINTOQUERYGEN CLASS.......................................................................................................104.6 SELECTFROMQUERYGEN CLASS....................................................................................................104.7 REMOVEFROMQUERYGEN CLASS...................................................................................................10

5 DETAILED DESCRIPTION OF DATABASE CONNECTION MANAGER COMPONENT...11

5.1 DATABASE CONNECTION MANAGER COMPONENT.........................................................................115.2 CONNECTIONEXECUTER CLASS......................................................................................................11

5.2.1 Contract 3: Execute a query string.........................................................................................115.3 DATASETCONFIGURATION CLASS..................................................................................................12

6 DETAILED DESCRIPTION OF UNIT CONVERSION COMPONENT......................................13

6.1 UNIT CONVERSION COMPONENT....................................................................................................136.2 AUXILIARYCLASS...........................................................................................................................136.3 EVALUATIONCLASS.........................................................................................................................146.4 CONVERTERCLASS..........................................................................................................................15

6.4.1 Contract 5: Do Unit Conversion............................................................................................15

7 DETAILED DESCRIPTION OF EMAIL NOTIFICATION COMPONENT...............................16

7.1 EMAIL NOTIFICATION COMPONENT................................................................................................16

Software Design Document CAT.6 Date

Page

Page 4: Sdd 4

Software Design Document

7.2 EMAILMANAGER CLASS.................................................................................................................167.2.1 Contract 6 Send Email Notification........................................................................................16

APPENDIX A: WEATHER DATABASE SCHEMA...............................................................................17

APPENDIX B: DATASET AND CELL OBJECTS..................................................................................18

Software Design Document CAT.6 Date

Page

Page 5: Sdd 4

Software Design Document

Introduction

1.1 Purpose and Intended AudienceThe 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.

1.2 Scope of ProductGlobal 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.

1.3 References[1]. 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[2]. S. Roach, “Software Design Document”, available at: http://courses.utep.edu/Default.aspx?tabid=5661

Software Design Document <Enter team name here> Date4/7/2023 3:47 PM

Page1

Page 6: Sdd 4

Software Design Document

1.4 Definitions, Acronyms, and Abbreviations

1.1.1 DefinitionsCoupling The degree to which each component relies on each

one of the other component.

Collaboration Cooperation and interaction between components.Component In this document a component refers to a subsystem or

a subdivision.Dataset The collection of data returned from the Database,

usually presented in tabular form.Database A comprehensive collection of related data organized

for convenient access, generally in a computer.Design Entities Subsystems and classes.

Interface A means of communication and interaction between two entities which could be the system and the user, as an example.

Metadata Data 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.

Schema The description of the tables and views in a database together with the relationships between them.

1.4.1 Acronyms and AbbreviationsAPI Application Program Interface

AWSD Automatic Weather Station DatabaseDB Database

DBMS Database Management SystemNM Notification Manager

UC Unit ConversionWS Weather Station

1.5 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.

Software Design Document <Enter team name here> Date4/7/2023 3:47 PM

Page2

Page 7: Sdd 4

Software Design Document

2 Decomposition DescriptionThe 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.

2.1 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

Software Design Document CAT.6 Date4/7/2023 3:47 PM

Page3

Page 8: Sdd 4

Software Design Document

2.2 Subsystem and Component Descriptions

Figure 2.2 Database Subsystem UML Component Diagram

APIDescription: Provide functions for the others subsystems for them to communicate with the Weather Database.

*API component can be found in section 3

Contracts: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 4Contracts:

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 5Contracts:

3.- Execute a query string.

Software Design Document CAT.6 Date4/7/2023 3:47 PM

Page4

Page 9: Sdd 4

Software Design Document

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 6Contracts:

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

Software Design Document CAT.6 Date4/7/2023 3:47 PM

Page5

Page 10: Sdd 4

Software Design Document

3 Detailed Description of API Component

3.1 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

3.2 ServerProtocol ClassDescription: Responsible for receiving incoming requests from other subsystems.Super Classes: nonePrivate responsibilities:

- Receive incoming data request.- Manage type of request for storing or retrieving data.

3.2.1 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

Post-conditions:- The request was passed to the class database server class.

public void translatePHPObject(Object o)Pre-conditions:

- Object received is php objectPost-conditions:

- A 2D java array was created.

Software Design Document CAT.6 Date4/7/2023 3:47 PM

Page6

Page 11: Sdd 4

Software Design Document

public void translateJavaObject(Object o)Pre-conditions:

- Object received is java objectPost-conditions:

- A 2D PHP array was created.

3.3 DatabaseServer ClassDescription: This class works as a means of communicating the PHP language side to the Java side. Super Classes: nonePrivate responsibilities:

- Translate PHP instances to Java instances.- Translate Java instances to PHP instances.

3.4 PHPObjectGenerator ClassDescription: 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.

Software Design Document CAT.6 Date4/7/2023 3:47 PM

Page7

Page 12: Sdd 4

Software Design Document

4 Detailed Description of Query Manager Component

4.1 Query Manager ComponentPurpose: 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

4.2 SecureQueryVerifer ClassDescription: Generate a sql query string Private responsibilities:

- Make Query Verification- Know the rules to verify security- Execute verification- Inform of an unsafe query- Send safe string to QueryExecuter

4.3 QueryGenerator ClassDescription: 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

Software Design Document CAT.6 Date4/7/2023 3:47 PM

Page8

Page 13: Sdd 4

Software Design Document

- Send newly constructed sql query to SecureQueryVerifier

4.3.1 Contract 2: Construct SQL Query StringDescription: Provide sql query stringResponsibilities:

- Know the syntax for the query string- Construct sql query - Send constructed query to SecureQueryVerifier

Protocols:

public string update(String sqlQuery)Pre-condition:

- Receive query string

Post-condition: - Return an update sql query to QueryExecutor

Source Class: UpdateQueryGen

public string insertInto(String sqlQuery)Pre-condition:

- Receive query string

Post-condition: - Return an insert sql query to QueryExecutor

Source Class: InsertIntoQueryGen

public string selectFrom(String sqlQuery)Pre-condition:

- Receive query string

Post-condition: - Return a select sql query to QueryExecutor

Source Class: SelectFromQueryGen

public string removeFrom(String sqlQuery)Pre-condition:

- Receive query string

Post-condition: - Return a remove sql query to QueryExecutor

Source Class: RemoveFromQueryGen

Software Design Document CAT.6 Date4/7/2023 3:47 PM

Page9

Page 14: Sdd 4

Software Design Document

4.4 UpdateQueryGen Class Description: Constructs an update sql querySuper Classes: QueryGeneratorPrivate responsibilities:

- Have template for an update string- Generate an update query string

4.5 InsertIntoQueryGen ClassDescription: Constructs an insert sql query. Super Classes: QueryGeneratorPrivate responsibilities:

- Have template for an insert string- Generate an insert query string

4.6 SelectFromQueryGen ClassDescription: Constructs a select sql query. Super Classes: QueryGeneratorPrivate responsibilities:

- Have template for a select string- Generate a select query string

4.7 RemoveFromQueryGen ClassDescription: Constructs a remove sql query. Super Classes: QueryGeneratorPrivate responsibilities:

- Have template for a remove string- Generate a remove query string

Software Design Document CAT.6 Date4/7/2023 3:47 PM

Page10

Page 15: Sdd 4

Software Design Document

5 Detailed Description of Database Connection Manager Component

5.1 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

5.2 ConnectionExecuter ClassDescription: responsible for creating the connection to the PostgreSQL database and the execution of query strings.Super Classes: nonePrivate 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

5.2.1 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.

Protocolspublic 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:

Software Design Document CAT.6 Date4/7/2023 3:47 PM

Page11

Page 16: Sdd 4

Software Design Document

- 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.

5.3 DataSetConfiguration ClassDescription: 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: nonePrivate 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

Software Design Document CAT.6 Date4/7/2023 3:47 PM

Page12

Page 17: Sdd 4

Software Design Document

6 Detailed Description of Unit Conversion Component

6.1 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

6.2 AuxiliaryClassDescription: This class is in charge of provides methods to help other classes. This component contains three methods.Super Classes: nonePrivate 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.

Software Design Document CAT.6 Date4/7/2023 3:47 PM

Page13

Page 18: Sdd 4

Software Design Document

public ArrayList<String> 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.

6.3 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: nonePrivate responsibilities:

- Evaluate expression inside parenthesis and send back the formula without parenthesis.- Evaluate complete formula.

Protocols

public double evaluateFormula(String[] tokens, ArrayList<String> 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.

Software Design Document CAT.6 Date4/7/2023 3:47 PM

Page14

Page 19: Sdd 4

Software Design Document

6.4 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: nonePrivate responsibilities:

- Send the array of values to the EvaluateClass to obtain new values.

6.4.1 Contract 5: Do Unit ConversionDescription: 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.

Software Design Document CAT.6 Date4/7/2023 3:47 PM

Page15

Page 20: Sdd 4

Software Design Document

7 Detailed Description of Email Notification Component

7.1 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

7.2 EmailManager ClassDescription: This class sends emails to users when there was a change in the data. Super Classes: nonePrivate responsibilities:

- Access the database and identify changes in it.- Get a list of affected users from the database.- Send emails

7.2.1 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<String> 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<String> emailAddress, String query)Pre-Conditions:

- Have access to the internet.- List of email s addresses

Post-Conditions: - Emails were sent.

Software Design Document CAT.6 Date4/7/2023 3:47 PM

Page16

Page 21: Sdd 4

Software Design Document

Appendix A: Weather Database Schema

Software Design Document CAT.6 Date4/7/2023 3:47 PM

Page17

Page 22: Sdd 4

Software Design Document

Appendix B: DataSet and Cell Objects

Q.E.D

Software Design Document CAT.6 Date4/7/2023 3:47 PM

Page18