Develop an Asset Management System (AMS) for Ho Chi Minh University of Industry



Similar documents
Hibernate Language Binding Guide For The Connection Cloud Using Java Persistence API (JAP)

Customer Bank Account Management System Technical Specification Document

PERFORMANCE EVALUATION OF JAVA OBJECT-RELATIONAL MAPPING TOOLS HASEEB YOUSAF. (Under the Direction of John A. Miller)

Performance Comparison of Persistence Frameworks

Object-Relational Databases

Performance Evaluation of Java Object Relational Mapping Tools

Using Relational Databases to Provide Object Persistence

Lesson 8: Introduction to Databases E-R Data Modeling

Using SQL Server Management Studio

Object Oriented Databases. OOAD Fall 2012 Arjun Gopalakrishna Bhavya Udayashankar

Research Article. ISSN (Print) *Corresponding author Lili Wang

Oracle Application Express - Application Migration Workshop

ORM IN WEB PROGRAMMING. Course project report for 6WW Erik Wang

Ken Goldberg Database Lab Notes. There are three types of relationships: One-to-One (1:1) One-to-Many (1:N) Many-to-Many (M:N).

White Paper: 1) Architecture Objectives: The primary objective of this architecture is to meet the. 2) Architecture Explanation

Project Databases Report

IBM Operational Decision Manager Version 8 Release 5. Getting Started with Business Rules

Table of Content. Introduction to ObjectDB and JPA. Object Model: Types, Entities, Primary Keys. Database Connections

Relational Database Basics Review

Case Studies of Running the Platform. NetBeans UML Servlet JSP GlassFish EJB

Developing an EJB3 Application. on WebSphere 6.1. using RAD 7.5

OTN Developer Day Enterprise Java. Hands on Lab Manual JPA 2.0 and Object Relational Mapping Basics

Enterprise Application Development In Java with AJAX and ORM

Database Management. Chapter Objectives

Admin Reference Guide. PinPoint Document Management System

Getting Started with Telerik Data Access. Contents

Database Migration : An In Depth look!!

Access Queries (Office 2003)

A Brief Introduction to MySQL

Simple Invoicing Desktop Database with MS Access c 2015 by David W. Gerbing School of Business Administration Portland State University

What is a database? COSC 304 Introduction to Database Systems. Database Introduction. Example Problem. Databases in the Real-World

WEB-BASED STUDENT MANAGEMENT SYSTEM USING RFID

Foundations of Information Management

CACHÉ: FLEXIBLE, HIGH-PERFORMANCE PERSISTENCE FOR JAVA APPLICATIONS

The Entity-Relationship Model

Introduction to Computing. Lectured by: Dr. Pham Tran Vu

Topic: Relationships in ER Diagram and Relationships in MS Access

1 File Processing Systems

NetBeans IDE Field Guide

Virtuoso Replication and Synchronization Services

zen Platform technical white paper

ODBC Client Driver Help Kepware, Inc.

3 Setting up Databases on a Microsoft SQL 7.0 Server

Java 7 Recipes. Freddy Guime. vk» (,\['«** g!p#« Carl Dea. Josh Juneau. John O'Conner

HP IMC Firewall Manager

What is Data Virtualization?

SQL Server An Overview

The Jeff's Ticket Tracking System

User Replicator USER S GUIDE

An Interface from YAWL to OpenERP

Security Development Tool for Microsoft Dynamics AX 2012 WHITEPAPER

HP Quality Center. Upgrade Preparation Guide

SEER Enterprise Shared Database Administrator s Guide

Software Design Specification

GlassFish v3. Building an ex tensible modular Java EE application server. Jerome Dochez and Ludovic Champenois Sun Microsystems, Inc.

E-Notebook SQL 12.0 Desktop Database Migration and Upgrade Guide. E-Notebook SQL 12.0 Desktop Database Migration and Upgrade Guide

Review Manager Guide

Data Modeling Basics

Sophos Enterprise Console Auditing user guide. Product version: 5.2

SAP Business Objects Business Intelligence platform Document Version: 4.1 Support Package Data Federation Administration Tool Guide

SharePoint AD Information Sync Installation Instruction

Oracle Data Integrator: Administration and Development

Business Process Management

Basic Unix/Linux 1. Software Testing Interview Prep

- Suresh Khanal. Microsoft Excel Short Questions and Answers 1

Web Services API Developer Guide

Vector HelpDesk - Administrator s Guide

Advanced Service Design

CONFIGURATION AND APPLICATIONS DEPLOYMENT IN WEBSPHERE 6.1

Object Oriented Database Management System for Decision Support System.

1. INTRODUCTION TO RDBMS

TIME KEEP LEGAL BILLING SOFTWARE DESIGN DOCUMENT. Mike Don Cheng-Yu. CS 524 Software Engineer Professor: Dr Liang

Using MS-SQL Server with Visual DataFlex March, 2009

Oracle Fusion Middleware

1. Introduction What is Slice? Background Why Slice? Purpose of this Document Intended Audience...

Jet Data Manager 2012 User Guide

Service Oriented Architectures

M4 Systems. Remittance (ER) User Guide

Creating Database Tables in Microsoft SQL Server

SQL Server Database Administration and Design By Dave Peru, October 2011

INTRODUCING ORACLE APPLICATION EXPRESS. Keywords: database, Oracle, web application, forms, reports

Kaseya 2. User Guide. Version 1.0

Course Number: IAC-SOFT-WDAD Web Design and Application Development

ORACLE USER PRODUCTIVITY KIT USAGE TRACKING ADMINISTRATION & REPORTING RELEASE 3.6 PART NO. E

Welcome to PowerClaim Net Services!

Time Tracking System with GWT

Implementing the Shop with EJB

Single Sign-On Guide for Blackbaud NetCommunity and The Patron Edge Online

High Level Design Distributed Network Traffic Controller

Specialized Programme on Web Application Development using Open Source Tools

SAMPLE FINAL EXAMINATION SPRING SESSION 2015

Synchronization Agent Configuration Guide

DATABASE MANAGEMENT SYSTEM

Tutorial on Relational Database Design

Software Architecture Document

Sports Management Information Systems. Camilo Rostoker November 22, 2002

NovaBACKUP. Storage Server. NovaStor / May 2011

ER/Studio 8.0 New Features Guide

Transcription:

MASTER INFORMATION TECHNOLOGY SOFTWARE ENGINEERING Develop an Asset Management System (AMS) for Ho Chi Minh University of Industry Supervisor: Pham Minh Tung Student: Tu Thi Xuan Hien HO CHI MINH CITY 12/2011

Abstract Nowadays, HCM University of Industry becomes one of the biggest universities in Vietnam with five branches. It possesses a huge quantity of equipment using for the training, so that there is a need of building a program for managing all assets of the university. The project Develop an asset management system of the HCM University of Industry is created to meet this demand. This project develops an application that can help the managers to evaluate the values of all equipment, to manage the allocation the assets among five branches, or among different departments of one branch. Furthermore, the Asset Management System can also be useful in managing the repair, insurance, liquidation, and replacement of all equipment. The development of the asset management system is based on the three-tierarchitecture and Object Relational Mapping (ORM). It is implemented in three phases: researching ORM Java Persistence API and Hibernate, analyzing and designing database using MS-SQL, and implementing the program using JAVA language. 1

TABLE OF CONTENTS CHAPTER 1. INTRODUCTION... 5 1.1 About Ho Chi Minh University of Industry... 5 1.2 About project... 5 1.3 Technologies used for implementation of the project... 6 1.4 The project implementing plan table... 6 CHAPTER 2. FEATURES OF TECHNOLOGY... 8 2.1 Object relational mapping (ORM)... 8 2.1.1 Impedance mismatch... 8 2.1.2 What is ORM?... 8 2.1.3 Why choosing ORM?... 9 2.2 Java Persistence API (JPA)... 10 2.3 Hibernate... 10 CHAPTER 3. ANALYSIS AND DESIGN DATABASE... 12 3.1 Requirement collection and analysis... 12 3.1.1 Requirements of users... 12 3.1.2 Asset processing... 13 3.1.3 Application users... 13 3.1.4 Data requirements... 14 3.2 Functional requirement... 14 3.3 Non-functional requirement... 15 3.4 Use case for a HUI database... 16 3.4.1 Use cases for the user admin... 16 3.4.2 Use cases for the branch managers:... 16 3.4.3 Use cases for the department managers... 17 3.4.4 Sequence diagram... 18 3.5 Conceptual database design... 18 3.5.1 The ER schema diagram for the AMS database.... 18 3.5.2 Class diagram... 20 3.5.3 Relational Database model of AMS... 20 CHAPTER 4. IMPLEMENTATION OF APPLICATION... 22 2

4.1 Structure of the application... 22 4.2 Data processing... 23 4.3 Functional of the application... 24 CHAPTER 5. CONCLUSION AND IMPROVEMENT... 26 5.1 Conclusion... 26 5.2 Improvement... 26 APPENDIX 1. HIBERNATE AND JPA... 28 1.1. Hibernate Architecture... 28 1.2. JPA using Hibernate Annotations... 28 1.3. Managing entities... 30 1.4. The Java Persistence Query Language (JPQL):... 32 APPENDIX 2. INSTALLATION GUIDE... 33 2.1. System requirements:... 33 2.2. Restore database... 33 APPENDIX 3. HUI ASSET DATABASE STRUCTURE... 34 APPENDIX 4. DEMO APPLICATION... 38 4.1. Login window... 38 4.2. Main window... 38 APPENDIX 5. WORKING WITH HIBERNATE JPA ON ECLIPSE... 42 REFERENCES... 49 3

TABLE OF FIGURES Figure 1: Asset processing... 13 Figure 2: Using cases of the User Admin... 16 Figure 3: Using cases of the branch manager... 17 Figure 4: Use case for department manager... 18 Figure 5: Sequence diagram for application... 18 Figure 6: ER diagram for database... 19 Figure 7: The class diagram for AMS... 20 Figure 8: Relational Database model in SQL... 20 Figure 9: Hibernate architecture... 28 Figure 10: State of entity instances... 32 Figure 11: Log in window... 38 Figure 12: The main window... 38 Figure 13: The Branch management window... 39 Figure 14: The Provider management window... 39 Figure 15: The Employee management window... 40 Figure 16: The Asset management window... 40 Figure 17: The Asset management window... 41 Figure 18: The Asset management window... 41 4

CHAPTER 1. INTRODUCTION 1.1 About Ho Chi Minh University of Industry Ho Chi Minh University of Industry (HUI) is one of the biggest technical and vocational education universities in Viet Nam with 5 branches whose head office is located in Hochiminh City. The university is headed by principal Tran Tuan Anh responsible for controlling the general operations of the entire school, and six vice principals who are in charge of dealing with different issues. Now I work for the Computer Science Engineering Department. There are about 60 staffs working here, responsible for educating and training of many different levels from vocational ones to those of university. With the focus in the field of software technology, network technology, media and web technology, this department attracts about 1000 students each year. I have been working here for over 10 years, in charge of some subjects of basic such as programming technical, Database management system, and web design Software Engineering Center is another department of the university, providing software resolutions which are used internally and nation-wide as well. This is the department where I do my internship. My project is one of those assigned by the university. Mr. Pham Minh Tung, my supervisor, is the director of this center, managing about 20 staffs. 1.2 About project In the past, due to the small quantity of assets, the management of assets information is simply implemented by Excel program. However, with a rapid expansion of not only the size of each branch but also the number of branches of the university, there is a significant rise in the volume of assets which make it impossible to manage by Excel. Therefore, a construction of asset managing software turns out to be indispensable to help the asset managers handle effectively their tasks. My project develops an application of the asset management system aiming to meet this demand. The asset management system is built to increase the effect of the management and the allocation of training equipment and office facilities in all faculties and departments in five branches of HUI. It also allows monitoring the asset using state over certain periods of time to make necessary changes such as repair, insurance, 5

replacement, supplementation or liquidation to maintain the good condition and sufficient quantities of these assets to meet the demand of university. Besides, this program helps managers estimate the total value of all assets, calculating automatically the amortization of assets during the period from the time of adding to the time of liquidation. 1.3 Technologies used for implementation of the project My project is an application implemented with object-orientated programming technology in Java language and use relational database management system SQL for persisting data. The next chapter will presents more detail about the features of these techniques as well as the reason why I made those choices. 1.4 The project implementing plan table The project is supposed to be accomplished in 3 stages: Analyzing and designing database stage Collecting data Analysis requirement of the application Design relational database model for application. Researching stage: Studying the Object Relational Mapping technique, JPA and Hibernate Developing stage: Developing the application with Java and Object Relational Mapping technique. N 0 Contents Starting date Finishing date Analyzing and designing database 1 Making plan for the project 01/07/2011 05/07/2011 2 3 1. Requirements for the application 2. Analyzing and designing database. Collecting Data Analyzing data Designing relational database Studying the Mapping technique Overview ORM Research stage Object Relational 06/07/2011 01/08/2011 02/08/2011 02/08/2011 6

4 ORM technique ORM with Hibernate JPA Programming Model Developing stage 1. Creating a login form 2. Building a menu system 3. Adding modules: Branch management Department management 03/08/2011 30/11/2011 Provider management Category management Employees management Asset management Final Report 01/12/2011 31/12/2011 Table 1: The project implementing plan table 7

CHAPTER 2. FEATURES OF TECHNOLOGY 2.1 Object relational mapping (ORM)[1] My project is an application implemented with object-orientated programming technology in Java language and use relational database management system SQL for persisting data. However, the object-oriented paradigm and the relational database paradigm are two fundamentally different models, causing a conceptual gap which is called object relational impedance mismatch. To solve this problem, I and my supervisor decided to use object relational mapping (ORM), a technology used for integrating object programming languages with relational database access. This chapter will be continued with the presentation more detailed about impedance mismatch, how ORM helps solve the disparities between domain model and relational model, and why we chose this approach by comparing with other existing approaches. 2.1.1 Impedance mismatch As I mentioned above, the impedance mismatch is the incompatibility between the object-oriented approach for application design and the relational model for database design. This problem is caused by some reasons. The object paradigm is based on software engineering principles such as coupling, cohesion, and encapsulation, whereas the relational paradigm is based on mathematical principles. Furthermore, the object paradigm plays the role in building operations of objects that have both data and behavior, whereas the relational paradigm is used to store data in tabular form, concentrating on data and its relationship. So that to enable objects to be saved to and retrieved from relational database, it is necessary to map the object model to the data model. ORM is one of the approaches can meet this demand. 2.1.2 What is ORM? ORM is a technique that helps convert data between type systems in relational database and object-oriented programming languages. It persist application objects to the tables in a relational database. In addition, ORM provides functionality to perform complete four basic operations of persistent storage create, read, update and 8

delete (CRUD) and object-oriented querying, supports metadata mapping and helps in the transaction management of the application. 2.1.3 Why choosing ORM? We decided to use ORM because the ORM frameworks present many advantages. Firstly, it automates the object-to-table and table-to-object conversion. This contributes to the simplification of development process, leading to a reduction of time and costs due to the reduction of hand-coding. Secondly, ORM tools provide an object oriented query language which helps developers concentrate on the business logic of the application rather than repetitive CRUD logic. Besides, when there are any changes to the object model, the ORM will automatically use the updated structure for retrievals and updates. It also supports multiple users to update the same data simultaneously. Nowadays, besides ORM there are some other approaches which also provide persistence for objects using relational databases such as Call-Level application programming interfaces or SQL query mapping frameworks. Each technique has its own advantages as well as disadvantages. The Call-Level API approach has low overhead and attain a highest level of control over the details of database connection. However, it requires a lot effort to write detailed code which is seldom reused. The developers should have a wide knowledge about DBMS capabilities and the database schema. Being unable to generate SQL code automatically is another significant weakness. For SQL Query mapping framework, it can give direct access to all DBMS capabilities provided through SQL and able to map easily to the legacy database schema. Nevertheless, there are also some flaws that need to be considered. Besides those similar to Call-Level API approach such as the problem of SQL code, having more overhead, and required understanding about DBMS, it cannot provide transparent persistence. We chose ORM because it appears to be the most predominant. With ORM, we don t have to face the above problems, excepting the fact that it has more overhead. Comparing to the other two techniques, ORM provides the highest level of transparent persistence and its implementation of persistence is fully separated from the rest of the code. 9

2.2 Java Persistence API (JPA) [2] Based on ORM theoretical foundation, it is my understanding that now there are two ORM frameworks adopted for data persistence on Java platforms: JDBC and JPA. In this project, we decided to use JPA for the following reasons. Up to now, JDBC (Java Database Connectivity) API has been traditionally used in Java applications for persist data into relational databases. It can handle large amounts of data, having mechanisms to ensure data integrity, supporting concurrent access to database. However, the developer is required to write intensive code to implement the business logic along with SQL sentences. To optimize the JDBC performance, it is necessary to program connection pooling and data caching. Moreover, JDBC does not duplicate serialization's ease of use and the relational paradigm used by JDBC was not designed for storing objects. Therefore, we made the choice of using Java Persistence API (JPA) since it presents more advantages in the persistence mechanisms. JPA is the standard Java API for the management of persistence and object relational mapping. In the advent of JPA, the programmers are relieved from writing intensive and complicated code. It supports the large data sets, data consistency, concurrent use, and query capabilities of JDBC. JPA also allows the use of advanced object-oriented concepts such as inheritance. 2.3 Hibernate[3] There are many open sources ORM tools used for the ORM implementation such as OpenJPA, Top Link, Eclips link and Hibernate. Most of these tools are persistence frameworks that provide a layer of abstraction between the Java application and the database. Those tools enable at least the basic database operations like creating, reading, updating, and deleting (CRUD). Among these tools, my project uses Hibernate because Hibernate is the most widely used Java ORM tool. Hibernate is a full Object-Relational Mapping (ORM) tool for JAVA. Hibernate helps mapping the objects and their relations into a database. It lets developer persistent classes including association, inheritance, and polymorphism. Hibernate not only takes care of the mapping from Java classes to database tables, but also provides data query and retrieval facilities and significantly reduce time spent with manual data handling in SQL and JDBC. It well supports some relationships among different layers of Java such as one-to-many, many-to-many as well as the association or inheritance relationships among objects. Besides, Hibernate allows 10

users to define their own types of stored data and supports many others mapping mechanisms such as enum, collection, mapping a single attribute for many tables. Nowadays, Hibernate is used in many frameworks such as spring, struts, tabestry or webwork. It is a useful tool not only for Java developers but for those who work with.net technology (Nhibernate) as well. Hibernate can run in many different environments from single application to those of commercial Java which use servlet container, application server and EJB container. 11

CHAPTER 3. ANALYSIS AND DESIGN DATABASE This chapter mention about the users of this application and their requirements. Basing on user requirements, I then present the information necessary for building the database as well as the function and non-function requirement of the application. Finally, I describe detailed steps of database designing. [4] 3.1 Requirement collection and analysis 3.1.1 Requirements of users The database for AMS application is established based on the demanding of users. AMS is required to be able to manage the following items: - Information about the assets: asset value, classified group, guarantee period, expiry date, current using state (being in use or stored) - Information about the providers (necessary for the guarantee or demanding to supply more) - Information about the producers (to clarify if they are prestigious of certain products) - Asset distribution (the asset is allocated to which branch, which department, which classroom) - Information about the branches, the department, the classroom, the staffs who are responsible for the asset management - Asset bills (to estimate the guarantee period, the expiry date, liquidation date, and amortization) Besides that, AMS must be ready to provide the reports of the total asset value or asset statistic according to branch, department, or asset group at any time when the user needs. AMS must also be kept in secret. 12

3.1.2 Asset processing Figure 1: Asset processing AMS manages the processing of assets information from the time an asset is added to the time it is liquidated, including the stages of newly adding, distribution, inventory, repair, innovation, and liquidation. 3.1.3 Application users AMS is an application used for the asset management of the whole system of HUI. It will help the managers of this university monitor the asset using state. The system admin authorizes the people who are in charge of asset management. First, they are those who work in administration department, using this application to update asset information and report to their seniors the requirements of repair or replacement as well as the new state after making any changes. Therefore, based on this application they can maintain the best availability of all equipment served for the teaching and studying activities in the university. A small example about a function of this program is that if there is a requirement of a class with 100 students, needing two projectors, the AMS can list all the rooms which meet this requirement. The principal and vice principals, through this application, can make the final decision of asset innovation, adding, replacement or liquidation according to the reports sent by the administration staffs. Besides, the dean or vice deans of each department also have the right to use this system to manage internal assets, and then give necessary demands or suggestions of changes. 13

3.1.4 Data requirements From the above requirements collection and analysis, the data of HUI s assets is presented in database in the following manner. AMS manages the information of every branch. Each branch contains one or more departments; each department has many employees; each employee belongs to a particular department of a branch and may have many rights in the application system; each type of right can be assigned to many employees. AMS manages the assets according to their types; each type of asset is provided by many providers; each provider can provide many types of asset. Asset is classified into groups; each group contains many types; each type belongs to only one group. Information of manufacturers is also managed by AMS. Each manufacturer produces many assets; each asset is produced by one manufacturer. When a new asset is added, this system will manage the information of its insurance state. The assets are distributed to the rooms of each department in each branch. AMS permits the dean of each department to monitor and manage the assets of their own department, planning for the necessary repair, innovation or supplementation. Each department manages many assets; each asset is under the control of one department. The department of each branch manages their own asset according to rooms. Each department has many rooms; each room belongs to one department of a specific branch. Each room contains many assets; each asset is located in one room. 3.2 Functional requirement AMS is built to help the managers of HUI to monitor the asset using state, planning for necessary repair or replacement, so that the researching, teaching and studying in the university can be served with the best asset system. Based on those purposes, AMS must be able to implement the following functions: Managing the users: the log-in process, password changing, authorizing the access, adding new users, modifying user information and managing the employees of each agent who are responsible for the asset management Managing data: data backup and restore process 14

Managing the asset information of university, including manufacturers, providers, adding date, value and quantity of each asset type, expired date, amortization during the time of using Managing the bill of adding or removing the assets Managing the quantity of assets of each department of each branch, monitoring the using condition of each agent Managing the list of assets which need to be liquidated or replaced Calculating the total value of asset as a particular time Outputting reports: Catalogue report Asset list report Asset inspection report Asset repair and guarantee report Innovation: Asset breaking down state informing form Liquidation: Asset liquidation report 3.3 Non-functional requirement In this section, I would like to mention about the factors that are not related to the specific functional requirements of the program. First of all, it is about the operation of the program. Because five branches of HUI access to this program concurrently, the system must be developed to operate stably and reliably. Besides, the application manages a huge volume of database, so that the database must be suitable for fast growing data. The next point is that there are many functions and reports in this program. Therefore, the graphical user interface is another key element that should be paid attention. Being user-friendly and easy-to-use are the necessary features which the interface must have. In addition, the reports in this program must display enough columns and information that the user need for making the statistics of the status of asset, etc Finally, only the people who have responsibility of managing the assets have the privilege to access the system. 15

3.4 Use cases of HUI database The users of this application include the user admin, the branch managers and the department managers who are authorized by the admin. 3.4.1 Use cases of user admin After logging in successfully, the user admin is responsible for system administration, including security and data management. In the session of security management, the user admin manages the accounts and authorizes users to access and manipulate the application. In the other session, he or she manages data by implementing data backup and restoring. 3.4.2 Use cases of branch managers: Figure 2: Using cases of the User Admin The branch manager manages the asset supplementation, transfer, and distribution, deletion of the liquidated assets, value statistic, and amortization calculation. After log in successfully, the branch managers can manipulate the following functions: 16

Managing assets: Adding new asset Updating asset information Estimating the total value of assets Implementing asset inventory, demanding necessary repair, insurance or liquidation Distributing assets Managing the contracts of asset purchase and insurance Figure 3: Using cases of the branch manager 3.4.3 Use cases of department managers The department managers monitor the assets using to demand any necessary repair, innovation or replacement. After log in successfully, the department managers can monitor the assets of their own department: o Updating the status of assets o Demanding the any necessary repair, innovation or replacement o Reporting the using condition 17

3.4.4 Sequence diagram Figure 4: Use case for department manager 3.5 Conceptual database design Figure 5: Sequence diagram for application 3.5.1 The ER schema diagram for the AMS database. 18

From the data requirements above, the entity relational diagram for AMS database is designed as the following Manufacturer 1 Invoice * belong 1 Provider Produce * have * Asset * * * * * belong Ensure 1 1 Room Ensure belon * 1 Category Belong * * Department Branch * * Work Account 1 have 1 * Employee 1 * Trace * have * Privilege Figure 6: ER diagram for database 19

3.5.2 Class diagram Class diagrams can be considered as an alternative notation to ER diagrams. In this diagram, there are two types of relationships: association and aggregation to represent a relationship between a whole object and its component parts, and it has a distinct diagrammatic notation. Based on the analyses above, the class diagram of the application is constructed as the following: Figure 7: The class diagram for AMS 3.5.3 Relational Database model of AMS In this section, we describe some necessary constraint. We also show all of entities and relationships between them. Base on the functional requirements, we design a database relational model in SQL as follow Figure 8: Relational Database model in SQL 20

21 Account EmployeeID UserName Password isdisable Asset AssetID ChildAssetID AssetName PurchasedDate CurrentValue AmountPaid SerialNumber RoomID CategoryID ModelNum Size WarrantyType WarrantyExpire NumberMade Color image InsurerID StatusID ManufactureID EmployeeID NumberOfYearToUse ValueToSellWaste Description IsDeleted Branch BranchID BranchName Website Phone Address City Email Fax Region IsMainBranch Description IsDeleted Category CategoryID CategoryName NumberOrCode image Description IsDeleted Department DepartmentID DepartmentName AbbreviationName image Description IsDeleted DeptBranch BranchID DeparmentID Description IsDeleted Employee EmployeeID PositionName Title FirstName MiddleName LastName BirthDay Address City HomePhone CellPhone Email BranchID DepartmentID Description IsDeleted EmployeeRight RightID EmployeeID Description IsDeleted Insurer InsurerID InsurerName WebSite ContactName ContactTitle Phone Address City Email Fax Description IsDeleted Manufacturer ManufactureID ManufactureName WebSite ContactName ContactTitle Phone Address City Email Fax Description IsDeleted Provider ProviderID ProviderName WebSite Phone ContactName ContactTitle Address City Email Fax Description IsDeleted Room RoomID RoomName BranchID DepartmentID Description IsDeleted AssetStatus StatusID StatusName Description IsDeleted Invoice OrderID OrderDate DeliveryDate ProviderID EmployeeID Description IsDeleted InvoiceDetails OrderID AssetID Quantity UnitPrice Description IsDeleted Privilege RightID Access Description IsDeleted Trace LogID EmployeeID LogonTime LogoutTIme Actions

CHAPTER 4. IMPLEMENTATION OF APPLICATION Implementation of the project is the next phase of the project. In this chapter, I how describe how the application is organized, how the data is processed, and the list of implemented modules. 4.1 Structure of the application The application is build based on multi-tier model, we organized the application by folder structure: Folder named AssetManagementSystem has some package as listed below: Hui.edu.vn.asm.jpa: This package contains objects. Each of them is corresponded to a table in database. For instance, table Asset which is used to store information of Asset will be mapped to an entity called Entity Asset. Each entity has its own attributes and methods. @Entity public class Asset implements Serializable { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name="AssetID") private int assetid; @Column(name="AssetName") private String assetname; public int getassetid() { return this.assetid; } public void setassetid(int assetid) { this.assetid = assetid; } public int getamountpaid() { return this.amountpaid; } } 22

Hui.edu.vn.business: This package can be considered as Business logic Layer in 3- tier model. It contains methods that help Business Layer which we will mention below to connect the data and perform required actions related to accessing database. It plays a role in persisting database basing on EntityManager Factory. public Asset getsingleresult(int assetid) { em.gettransaction().begin(); Query que=em.createnamedquery("asset.findbyassetid"); que.setparameter("assetid", assetid); Asset asset=(asset)que.getsingleresult(); em.gettransaction().commit(); return asset; } Hui.edu.vn.controler: This package contains the class that is used to control the requests of the presentation layer. It creates all events for user interface (view layer). Hui.edu.vn.view: This package contains user controls. Each of them is actual form. The form is a layout of controls like textbox, dropdown list box and so on. These forms are used for user to input the data or represent information to user. This package is also contains some others like: images illustrate. This package can be considered as Presentation Layer. 4.2 Data processing My project is a JPA application, using the technology of JPA and Hibernate to process data. Each object is considered as entity which is stored in a relational database. An entity defines a table in a relational database in the manner which each instance of an entity corresponds to a row in that table. The entity is managed by the EntityManager, a standard API for performing CRUD (create, read, update, and delete) or persistence operations for entities. Each entity includes four states, including New, Managed, Removed and Detached states. The new state of an entity is indicated by the new() operator. The entity instance is in the managed state when it has a persistent identity and is associated with a persistence context, indicated by persist() operator. Being in the detached state, the entity instance is not associated with a persistent context. The detached state is brought back to the managed state by 23

the merge() method. When the EntityManager calls remove() method, the entity instance is deleted and transferred from managed to removed state. To retrieve and manipulate entities, Java Persistence Query Language (JPQL) is used. 4.3 Functional of the application The application consists of three modules as following: 1. System Information User management Data management System configuration 2. Catalogue System Asset group catalogue Updating, adding, deleting Asset catalogue Branch distribution Department distribution Room distribution Automatic calculation of amortization Updating, adding, deleting Finding the list of assets according to branches, departments and rooms Provider catalogue Updating, adding, deleting Manufacturer catalogue Updating, adding, deleting Employee catalogue Updating, adding, deleting Insurance catalogue 3. Report Updating, adding, deleting General statistic of assets according to branch, department, room and asset type 24

Asset transfer report New asset requirement report Current asset value report Asset liquidation report Asset insurance and repair report Asset listing in accordance with the inventory agent List of excessive asset after being inventoried 25

CHAPTER 5. CONCLUSION AND IMPROVEMENT 5.1 Conclusion In the tendency of expanding and innovation of HUI, the number of assets possessed by university is increasing day by day. Facing with a demand of asset management, there need to be application software which supports the managers to effectively handle the managing and using all the assets of the university. The full project of HUI asset management system is created to meet this requirement. My work is a part of this full project, implementing some basic functions of the application. They includes analyzing and designing database, implementing some modules which allow managing the asset according to branches, departments, providers, manufacturers, employee and categories. Through this project, I have had a good chance to study more about Java language, ORM and Hibernate JPA on Eclipse which help me to broaden my knowledge and support a lot in my career as a teacher. I want to show my gratefulness to Ms. Ann Dicky and Mr Pham Minh Tung who helped me accomplish this project. 5.2 Improvement After my work, the rest of this project will continued to be developed by other members with the following modules 1. System Information User management Data management System configuration 2. Report General statistic of assets according to branch, department, room, asset type Asset transfer report New asset requirement report Current asset value report Asset liquidation report Asset insurance and repair report Asset listing in accordance with the inventory agent 26

List of excessive asset after being inventoried Right after this project is accomplished successfully, it will be applied in the management system of HUI. 27

APPENDIX 1. HIBERNATE AND JPA 1.1. Hibernate Architecture Hibernate creates a layer between Database and the Application. Hibernate uses the database from Hibernate Properties file, performing the automatic mapping on the properties defined in hbm XML file to define for particular Java object or Hibernate Annotations. Hibernate creates persistent objects, along with XML mapping documents to persist objects to the database layer. Figure 9: Hibernate architecture 1.2. JPA using Hibernate Annotations There are three major parts of JPA: Entities: persistent objects which are stored in a relational database The EntityManager API: a standard API for performing CRUD (create, read, update, and delete)/persistence operations for entities The Java Persistence Query Language (JPQL): A SQL-like language used to retrieve and manipulate entities 1.2.1. Entities An entity is regarded as a persistence domain object. It defines a table in a relational database in the manner which each instance of an entity corresponds to a row in that table. An entity refers to a logical collection of data that can be stored or retrieved. The entity class is annotated with the @Entity annotation. The entity class must be a top-level class, not the final, as the following example. @Entity public class Asset implements Serializable { } 28

1.2.2. Primary Keys in Entities Each entity has its own primary key to identify its distinction. The primary key is either a simple or composite primary key. To be a simple primary key, the primary key must correspond to a single persistent property of the entity class. The @Id annotation is used to denote a simple primary key. Consider the following example @Id @Column(name="AssetID") private int assetid; If a primary key is a composite primary key, it must be composed of either a single persistent property or a set of single persistent properties. Composite primary keys use javax.persistence.idclass and javax.persistence.embededid. 1.2.3. Entity Relationships The object-oriented domain model consists of entities and relationships among entities. There are four entity relationships: one-to-one, one-to-many, many-to-one, and many-to-many. One-to-one: Each entity instance is mapped to a single instance of another entity. One-to-one relationship uses the javax.persistence.onetoone annotation on the corresponding persistent field or property. @OneToOne @JoinColumn(name="EmployeeID") private Employee employee; public Account() { } One-to-many and many-to-one: An entity instance is related to many instances of other entities. This relationship uses javax.persistence.onetomany and javax.persistence.manytoone annotation on the corresponding field or property. @OneToMany(mappedBy="employee") private Set<EmployeeRight> employeerights; 29

Many-to-many: A multiple instances of an entity have the mapping to a multiple instances of the other entity. Many-to-many relationship uses the javax.persistence.manytomany annotation corresponding to the field or property. Cascade Deletes and Relationships: Entities which have the relationships are dependent on other entities in the relationship. For example, a line item is part of an order, and if the order is deleted, then the line item should also be deleted; use the element cascade=remove element to delete the cascade relationships specified for @OneToOne and OneToMany relationship. 1.2.4. Inheritance relationship Super classes: An entity may inherit from a super class which provides persistent entity state and mapping information. Mapping super classes are declared by using javax.persistence.mappedsuperclass annotation to specify the class. Inheritance relationship: Entities can have inheritance relationship. There are three inheritance mapping strategies to map entity inheritance to database tables, using the annotation @Inheritance (..): Single table, Joined subclass, Table per class. 1.3. Managing entities 1.3.1. Persistence context A persistence context is a set of entity instances in which for any persistent entity identity there is a unique entity instance. Within the persistence context, the entity instances and their life cycle is managed by a particular EntityManager. 1.3.2. EntityManager EntityManager API is used to create and remove persistent entity instances. The set of entities which can be managed by a given EntityManager instance is defined by a persistence unit. EntityManagers perform the actions that affect the lifecycle state of entity instances. Persistence unit: defines the set of all classes which are related or grouped by the application, and which must be collocated in their mapping to a single database. A persistence unit is defined by persistence.xml file that resides in the META-INF directory 30

<?xml version="1.0" encoding="utf-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> <persistence-unit name="assetmanagmentsystem"> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.sqlserverdialect" /> <property name="hibernate.connection.driver_class" value="com.microsoft.sqlserver.jdbc.sqlserverdriver" /> <property name="hibernate.connection.url" value="jdbc:sqlserver://localhost:1433;databasename=assetmanagment" /> <property name="hibernate.connection.username" value="sa" /> <property name="hibernate.connection.password" value="12345678" /> <property name="hibernate.hbm2ddl.auto" value="none" /> </properties> </persistence-unit></persistence> States of entity instances: EntityManager manages lifecycle state of entity instances. Each entity includes four states: New: With new() operator, it is indicated that the entity instance is in the new state, having no persistent identity and being unassociated with a persistent context. This state is lost through a garbage collection process, when it has no reference from any other objects. The persist() method transfers the entity instance from the new state to the managed state 31

Figure 10: State of entity instances 1 Managed: The entity instance is in the managed state when it has a persistent identity and is associated with a persistence context. It has a representation in the database and has a primary key value set as its database identifier. This state transfers from managed to detach when the persistence context ends. Detached: Being in this state, the entity instance is not associated with a persistent context. Its state is no longer guaranteed to be synchronized with the database state. The detached state is brought back to the managed state by the merge() method. Removed: When the EntityManager calls remove() method, the entity instance is deleted and transferred from managed to removed state. 1.4. The Java Persistence Query Language (JPQL): The Java Persistence query language allows defining queries over entities and their persistent state. public List<Category>getResultList() { em.gettransaction().begin(); Query que=em.createnamedquery("category.findbyisdeleted"); que.setparameter("isdeleted", new Integer(0)); List<Category> catlist=que.getresultlist(); IMPLEMENTATION em.gettransaction().commit(); return catlist; } Based on the requirements at the beginning, ASM application has implemented the basic functions of asset managing of HUI 1 ORM Object Relational Mapping author: Arvo Lipitsäinen Dpt. of Business Information Technology, Haaga-Helia University of Applied Sciences, Helsinki, Finland 32

APPENDIX 2. INSTALLATION GUIDE 2.1. System requirements: The computer must be installed with Java Runtime Environments The host computer must have the SQL server 2.2. Restore database Restore file AssetManagementSystem.Bak in SQL server User name: sa Password: 12345678 Run file AssetManagementSystem.Jar 33

APPENDIX 3. HUI ASSET DATABASE STRUCTURE Based on the analyses above, the database for this application is designed with the following tables: Account Fields Type Allow Null Default Value Primary Key EmployeeID bigin No Yes UserName nvarchar No Password nvarchar No IsDisable int No Trace Fields Type Allow Null Default Value Primary Key LogID bigint No Yes EmployeeID bigint no LogonTime datetime No LogoutTime datetime no Action Ntext yes Employees Fields Type Allow Null Default Value Primary Key EmployeeID bigint No Yes PositionName nvarchar(250) No Title nvarchar(250) Yes FirstName nvarchar(50) No MiddleName nvarchar(250) No LastName nvarchar(50) No BirthDay DateTime No Address nvarchar(250) No City nvarchar(250) No HomePhone nvarchar(250) yes CellPhone nvarchar(250) yes Email nvarchar(250) yes BranchID DepartmentID int int Description nvarchar(250) yes IsDeleted int No EmployeeRight Fields Type Allow Null Default Value Primary Key RightID int No Yes EmployeeID bigint No Yes Description nvarchar(250) yes IsDeleted int No Branch Fields Type Allow Null Default Value Primary Key BranchID int No Yes BranchName Nvarchar(30) No 34

Address Nvarchar No PhoneNumber Nvarchar(14) No Email Nvarchar(30) No Fax Nvarchar(30) No Region Nvarchar(50) No IsMainBranch Int No Description Nvarchar(255) yes IsDeleted int No Department Fields Type Allow Null Default Value Primary Key DepartmentID int No Yes DepartmentName nvarchar(50) No AbbreviationName nvarchar(50) No Image Nvarchar(255) yes Description Nvarchar(250) yes IsDeleted int No DepBranch Fields Type Allow Null Default Value Primary Key BranchID int No Yes DepartmentID int No Description Nvarchar(250) yes IsDeleted int No Room Fields Type Allow Null Default Value Primary Key RoomID int No Yes RoomName nvarchar(50) No BranchID int No DepartmentID int No Description Nvarchar(255) yes IsDeleted int No Manufacturers Fields Type Allow Null Default Value Primary Key ManufactureID int No Yes ManufactureName nvarchar(50) No WebSite nvarchar(50) Yes ContactName nvarchar(250) Yes Phone nvarchar(50) Yes Address nvarchar(50) Yes City nvarchar(50) Yes Fax nvarchar(50) Yes Description nvarchar(250) Yes IsDeleted int No Insurers Fields Type Allow Null Default Value Primary Key 35

InsurerID int No Yes InsurerName nvarchar(50) No WebSite nvarchar(50) yes ContactName nvarchar(50) No Phone nvarchar(50) No Address nvarchar(50) No City nvarchar(50) No Fax nvarchar(50) No Description nvarchar(250) yes IsDeleted int No Categories Fields Type Allow Null Default Value Primary Key CategoryID int No Yes CategoryName nvarchar(50) No Image nvarchar(50) yes NumberOrCode tnvarchar(50) yes Description nvarchar(50) yes IsDeleted int No Status Fields Type Allow Null Default Value Primary Key StatusID int No Yes StatusName nvarchar(50) No Description nvarchar(50) yes IsDeleted int No Assets Fields Type Allow Null Default Value Primary Key AssetID int No Yes ChildAssetID int Yes AssetName nvarchar No PurchasedDate DateTime No CurrentValue int No AmountPaid int No SerialNumber nvarchar No RoomID int No CategoryID int No ModelNum Nvarchar(255) No Size Nvarchar(50) No WarrantyType Nvarchar(50) No WarrantyExpire DateTime No NumberMade Nvarchar(50) No Color Nvarchar(50) No image Nvarchar(500) No InsurerID int no StatusID Int No ManufactureID Int no 36

EmployeeID Int no NumberofYeartouse int no ValuetoSellWaste Int No Description Nvarchar(255) yes IsDeleted Int No Invoice Fields Type Allow Null Default Value Primary Key OrderID Nvarchar(10) No Yes OrderDate DateTime no DeliveryDate DateTime No ProviderID int no EmployeeID bigint no Description nvarchar(255) yes IsDeleted int No InvoiceDetail Fields Type Allow Null Default Value Primary Key OderID text No Yes AssetID Number Yes Yes Quantity Number No UnitPrice Currency Yes Description text No IsDeleted Number No Provider Fields Type Allow Null Default Value Primary Key ProviderID int No Yes ProviderName nvarchar(50) No WebSite nvarchar(50) No ContactName nvarchar(50) No Phone nvarchar(14) No Address nvarchar(50) No City nvarchar(50) No Fax nvarchar(50) No Description nvarchar(250) Yes IsDeleted int No Privilege Fields Type Allow Null Default Value Primary Key RightID bigint No Yes Access text Yes Description text Yes IsDeleted Number Yes 37

APPENDIX 4. DEMO APPLICATION The users after logging in under the authorization of the system admin will be able to manipulating the following functions 4.1. Login window Login widow allow users to login to the system User Name: xuanhien Password: hoilamgi Remember password: if is checked then system remember user name and password for next time login. 4.2. Main window Figure 11: Log in window The following figure illustrates the main interface of the system. This is the window where the users begin manipulating the functions of the application. Figure 12: The main window Operations can be implemented in the system: Branch management: managing information of the branch using assets of university. According to his or her authorization, the user can add, update information or delete the branches. 38

Figure 13: The Branch management window Provider management: managing information of the Providers provide assets of university. According to his or her authorization, the user can add, update information or delete the provider. Figure 14: The Provider management window Employee management: managing information of the employee involved in using and managing the assets. The user can add, update or delete information of the employee 39

Figure 15: The Employee management window Asset management: Add button: Adding new assets. With this function, the users are also able to assign the asset managing responsibilities and distribute the assets to branches, departments and rooms. Update button: Updating asset information Save button: Save the information of the asset after update or add new Delete button: Delete an asset Search button: Finding an asset basing on the assetid Filter rom by: display the asset list according to the room, branches or department. Figure 16: The Asset management window 40

Tab images: Display the image of asset. Figure 17: The Asset management window Tab Depreciation: Calculating automatically the amortization each year of each asset Figure 18: The Asset management window 41

APPENDIX 5. ECLIPSE WORKING WITH HIBERNATE JPA ON To work with Hibernate JPA on Eclipse we perform the following steps: Create new JPA Project by: at working window of Eeclipse, click JPA button File New JPA Project Enter Project name Next Select User library: Hibernate Finish 42

Select Add connection Finish 43

Select SQL Server Next 44

Create a mapping JPA Entities from table: Right click on src folder and select New JPA Entities from tables. Select the tables in database Next 45

Edit the table association Next 46

Specify Package and source folder Next 47

Customize the individual entities Finish 48

REFERENCES [1] Ambler, S. 2006. Mapping Objects to Relational Databases: O/R Mapping in Detail. Available at www.agiledata.org/essays/mappingobjects.html. (Accessed September 19,2009). Bauer, C., and G. King. 2006. Java Persistence with Hibernate. Greenwich, CT: Manning. [2] Java Persistence API (JPA): Java Persistence API (JPA): Mapping Sang Shin Sang Shin Java Technology Evangelist Java Technology Evangelist Sun Microsystems, Inc. Sun Microsystems, Inc. javapassion.com javapassion.com [3] Hibernate Reference Documentation-Version: 3.2 cr1 [4] Fundamentals_of_Database_Systems 4th_Edition_ 49