Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

UNIVERSITY OF MAURITIUS

FACULTY OF INFORMATION, COMMUNICATION AND DIGITAL TECHNOLOGIES

SECOND SEMESTER EXAMINATIONS

MAY 2018

PROGRAMME BSc (Hons) Information Systems– Level 3

MODULE NAME Enterprise Application Development

DATE ………………….2018 MODULE CODE CSE3073Y

TIME ………… Hrs DURATION 3 Hours

NO. OF 5 NO. OF QUESTIONS TO 4


QUESTIONS SET BE ATTEMPTED

INSTRUCTIONS TO CANDIDATES

The question paper consists of 5 questions.

Answer ANY 4 Questions


CSE 3073Y- ENTERPRISE APPLICATION DEVELOPMENT

Answer ANY 4 questions

Question 1

(a) In the Java Enterprise Edition (Java EE) multi-tiered application, the functionality of
the application is separated into isolated functional areas, called tiers: Client, Middle
and Data.

(i) Briefly explain why a multi-tier architecture is better than a 2-tier architecture.
[3 Marks]

(ii) Java EE application development concentrates on the middle tier to make


enterprise application management easier, more robust, and more secure.
Explain how this is achieved in the middle tier?
[4 Marks]

(iii) Outline THREE technologies used in the Java EE middle tier.


[3 Marks]

(b) Your services have been sought for the development of a Monthly Tax Calculator to
be used by the Finance Section to determine the monthly tax amount for each
employee. The system is illustrated in Figure 1. The user enters the monthly salary
of the employee and his/her category. The different categories are shown in Table 1,
together with the respective threshold amount. The monthly tax is then calculated as
follows:
Tax = 0.15 x ((13 x monthly salary) – threshold)
12

Figure 1
(continued next page)
Page 1 of 10
CSE 3073Y- ENTERPRISE APPLICATION DEVELOPMENT

Category Description Threshold


A Individual with no dependent 300,000
B Individual with 1 dependent 410,000
C Individual with 2 dependents 475,000
D Individual with 3 or more dependents 520,000
Table 1
(i) Create a stateless session bean TaxCalculator that implements the
CalculateThreshold and the CalculateTax methods. The signatures of the
methods are given below:
public int CalculateThreshold(String category)
public double CalculateTax(int threshold, double salary)

[7 marks]
(ii) The index.jsp page (Figure 1) uses the stateless session bean, TaxCalculator,
implemented in part (i) to compute and display the threshold and the tax
payable on the same page. Implement the JSP page, index.jsp. You may
disregard the tabular arrangement of the page.
[8 marks]
(Total: 25 marks)
Question 2
(a) The Java EE platform supports a number of authentication mechanisms. Briefly
describe two such authentication mechanisms.

[3 marks]
(b) The availability of an Enterprise JavaBean for use in a JSP application is defined
as the scope of that bean. There exist four different scopes for an Enterprise
JavaBean. Differentiate between these four possible scopes.

[4 marks]
(c) Your friend, the owner of a small business MauLaptop which deals in IT
equipment, is seeking your help for the development of an Online System (OS)
that will enable him to manage his stock of laptops. You decided to create an
online system based on PostgreSQL and JSP. Details that need to be kept about
the laptops in the Laptop table are:
 Model (e.g. HP Pavilion)
 Price (e.g. 28000.00)
 Storage-GB (e.g. 1000)
 RAM-GB (e.g. 16)
 Quantity (e.g. 25)
(continued next page)
Page 2 of 10
CSE 3073Y- ENTERPRISE APPLICATION DEVELOPMENT

(i) Create an entity bean, Laptop.java, that you would use to act as an
intermediary between the online application and the PostgreSQL database.
[5 marks]
(ii) You create the following page (Figure 2) that is used to search for existing
laptops.

Figure 2 – view.jsp

The Online System consists of a Manager class, LaptopManager.java that implements the
related CRUD functions.
Assuming that the:
 name of the database is OS and is hosted on localhost,
 table name is laptop and its primary key is model,
 the login is guest and password is guest,
 field names of the laptop table are the same as the attributes of your above
Laptop Entity bean,

Give your implementation of the method findLaptop. Its signature is given below:

public Laptop findLaptop(String model)


[7 marks]

(iii) Give your implementation of view.jsp. The message “Laptop NOT found” is
displayed in the case the model cannot be found in the database. You may
disregard the tabular arrangement of the page.
[6 marks]
(Total: 25 marks)
(continued next page)
Page 3 of 10
CSE 3073Y- ENTERPRISE APPLICATION DEVELOPMENT

Question 3
(a) Briefly describe and differentiate between traditional IT and the three different types
of Cloud Computing services: Software as a Service (SaaS), Platform as a Service
(PaaS) and Infrastructure as a Service (IaaS).
[4 marks]

(b) By using suitable examples, compare and contrast Manual Validation and Explicit
Automatic Validation as supported by JavaServer Faces.
[4 marks]

(c) As expected, the UoM Students Union will be organising its end of academic year
party in June. They have contacted you to develop a system that can help them in
the sale of foodstuff on this occasion. You propose the following responsive JSF
application (Figure 3) which uses the PrimeFaces component library.

Figure 3 – eoy.xhtml

(continued next page)

Page 4 of 10
CSE 3073Y- ENTERPRISE APPLICATION DEVELOPMENT

The Students Union has requested you to use the below pricing policy for
implementing the application.

Type Student Staff


Meal
Magic Platter 200 300
Chinese Soup 150 200
Noodles 150 175
Fried Rice 140 160

Optionally and against additional payment, there are top ups that may be added to
the meal, as shown in the table below. The same prices are applicable for both
students and staff.
Top Up Price (Rs)
Chicken 40
Eggs 30
Prawns 50

(i) Implement the Managed Bean Pricing.java which is the backbone of the above page.
You may skip the getters and setters for the class.
[7 marks]

(ii) Give your implementation of eoy.xhtml. The page uses AJAX to allow it to be
responsive. You may disregard the tabular arrangement of the page.
[10 marks]
(Total: 25 Marks)

(continued next page)

Page 5 of 10
CSE 3073Y- ENTERPRISE APPLICATION DEVELOPMENT

Question 4

The Faculty is embarking on a new initiative to reward brilliant full-time students (aged
between 18 and 25 inclusive) who have a CPA between 70 and 100 inclusive by
publishing the yearly Dean’s Merit List. Your help is required to help to create the
Dean’s Merit list using Hibernate and Data Table technologies. The Dean also requires
that the application implements necessary validations to ensure that the list is accurate.
E.g. a valid student is a 7-digit number as shown below. A design of the proposed
system, meritoriousStudents.jsp, is given in Figure 4.

Figure 4 – meritoriousStudents.jsp
The above proposal uses manual validations whereby error messages, if any, appear in
the footer of the data table. The system uses a managed bean, StudentController.java, as
the backbone of the JSF meritoriousStudents.jsp. The managed bean,
StudentController.java, interacts with a stateless session bean, StudentManager.java which
uses Hibernate framework to implement the functions: addStudent(), deleteStudent() and
getAllStudents(). Their signatures are given below:

public int addStudent(int id, String name, int age, double cpa)

public void deleteStudent(int id)

public ArrayList<Student> getAllStudents()

(continued next page)

Page 6 of 10
CSE 3073Y- ENTERPRISE APPLICATION DEVELOPMENT

Part of the managed bean, StudentController.java, is given below:

package ems;

import java.util.ArrayList;

public class StudentController {

String id;
int numericId;

String name;

String age;
int numericAge;

String cpa;
double numericCpa;

private ArrayList<String> errorMessages;

public String getId() { return id; }

public void setId(String id) {


this.id = id;
try{ this.numericId = Integer.parseInt(id);
} catch(NumberFormatException nfe) {}
}

public int getNumericId() { return numericId; }

public String getName() { return name; }

public void setName(String name) {this.name = name; }

public String getAge() { return age; }

public void setAge(String age) {


this.age = age;
try{ this.numericAge = Integer.parseInt(age);
} catch(NumberFormatException nfe) {}
}

public int getNumericAge() { return numericAge; }

public String getCpa() { return cpa; }

public void setCpa(String cpa) {


this.cpa = cpa;
try{ this.numericCpa = Double.parseDouble(cpa);
} catch(NumberFormatException nfe) {}
}

public double getNumericCpa() { return numericCpa; }


(continued next page)
Page 7 of 10
CSE 3073Y- ENTERPRISE APPLICATION DEVELOPMENT

public String addStudent() throws Exception{

// implementation missing
}

public String getErrorMessages() {


String messageList;
if ((errorMessages == null) ||(errorMessages.size() == 0))
messageList = "";
else {

messageList = "<FONT COLOR=RED><B><UL>";


for (int i=0;i<errorMessages.size();i++){
messageList = messageList + "<LI>" +
errorMessages.get(i) + "\n";
}

messageList = messageList+ "</UL></B></FONT>";


}
return messageList;
}

public ArrayList<Student> getAllStudents() throws Exception{


StudentManager studMgr = new StudentManager();
return studMgr.getAllStudents();
}

public String deleteStudent(Student myStud) throws Exception{


StudentManager studMgr = new StudentManager();
studMgr.deleteStudent(myStud.getId());
return "delete";
}
}

(a) Complete the implementation of the managed bean, StudentController.java, by


implementing the missing action controller method, addStudent(). The addStudent()
function should implement the following validations (as in figure 4) and save the
corresponding error messages, if any, in the arraylist:
 Student ID is not valid
 Name cannot be blank
 Age should be between 18 and 25 inclusive
 CPA should be between 70 and 100 inclusive
[8 marks]

(continued next page)

Page 8 of 10
CSE 3073Y- ENTERPRISE APPLICATION DEVELOPMENT

(b) The Manager class, StudentManager.java, implements the addStudent function, the
signature of which has been given above. Assuming that the sessionFactory object
has already been instantiated, implement the addStudent function that uses the
Hibernate framework to persist records in the database table. Assume the entity
class Student with appropriate attributes and accessors already exist.
[7 marks]

(c) The JSF page meritoriousStudents.jsp uses a data table to display all students and also
to delete students as shown in figure 4. At the same time, it provides for
corresponding textboxes in the footer of each column to enable the addition of new
students. Implement the meritoriousStudents.jsp page.
[10 marks]
(Total: 25 marks)
Question 5

(a) One of the most important principles on which REpresentational State Transfer
(REST) is based is “Uniform Interface”. Describe this principle.

[4 marks]

(b) John Smith is the owner of a hardware shop that sells construction items to its
customers. He is currently using a Java application to control the sale and stock of
his materials. To further expand his business, John Smith is considering to open two
more shops around the island. He has hired you as consultant to demonstrate the
suitability of RESTful web services for managing the sales of his items in the three
stores. You decided to create a prototype to show Mr Smith how the system will
work. You create the following Item model with its getters and setters.

public class Item {

private int id;


private String description;
private double quantity;

public Item() {
}

public Item(int id, String item, double quantity) {


this.id = id;
this.description = item;
this.quantity = quantity;
}
// Getters & Setters

(continued next page)


Page 9 of 10
CSE 3073Y- ENTERPRISE APPLICATION DEVELOPMENT

Your prototype contains an ItemService class that uses a hashmap instead of a database.
The ItemService class implements the CRUD (create, retrieve, update, delete)
functionalities on this hashmap. Part of the ItemService class is shown below:

public class ItemService {


HashMap <Integer, Item> items = new HashMap<>();

public ItemService(){
items.put(1, new Item(1,"Bricks", 500));
items.put(2, new Item(2,"Cement", 25));
items.put(3, new Item(3,"Iron", 50));
}

public List<Item> getAllItems(){


return new ArrayList<Item>(items.values());
}

(i) Complete the implementation of the ItemService class by giving the four methods
necessary for the CRUD functionalities.
[8 marks]

The ItemResource class uses HTTP methods to map the CRUD operations to HTTP
requests with the root resource being exposed at “items” path. Part of the ItemResource
class is given below.
@Path("/items")
public class ItemResource {

static ItemService is = new ItemService();

@GET
@Produces(MediaType.APPLICATION_XML)
public List<Item> getAllItems(){
return is.getAllItems();
}

(ii) Complete the implementation of the ItemResource class.


[8 marks]

(iii) Write a function DeleteItem that can be used in Mr Smith’s Java application to
delete an item through the web service.

Assume the following:


 URI for the Item Resource is: http://localhost:8080/HardwareShop/items
 Signature of DeleteItem is:
public static void TestDeleteMessage(int id)
[5 marks]
(Total:20 Marks)
END OF QUESTION PAPER

Page 10 of 10

You might also like