Enterprise Java Development@TOPIC@

Chapter 17. Project 1 Technical Details

17.1. Database Schema
17.1.1. eLeague Candidate Database Schema
17.1.2. eClub Candidate Database Schema
17.2. Business Objects
17.2.1. eLeague Candidate Business Objects
17.2.2. eClub Candidate Business Objects
17.3. Validation API
17.4. eLeague Ingest
17.5. Data Access Objects (DAOs)
17.5.1. eLeague DAOs
17.5.2. eClub DAOs
17.6. SQL Tuning (Indexes)
17.7. Business Logic
17.7.1. eLeague Business Logic
17.7.2. eClub Business Logic

Note

There are a lot of technical details presented with this specification. This is done to provide clarity and a starting point for design discussion. However, it is not done so to specify specific class or method naming, project layout, or order of work. You are free to make many technical adjustments to the ideas presented. Implementation of the end-to-end scenario is the primary requirement.

Tip

This project provides an obvious opportunity to use compound business primary keys and the documentation below depicts some of the ramifications in doing so. Synthetic, single value primary keys are permitted in your solution without penalty. Single value primary keys are much easier and should be the first choice if you have limited experience and limited time to work with the more complex primary key and foreign key mechanism.

Design 2 sets of database schema that account for the following information. Although we will deploy the 2 database schemas to the same database for the project, they should be designed to be independently deployed to separate databases. eLeague and eClub are two independent applications. This will primarily affect your attempt re-use tables or to make primary key assumptions between the two.


Design a table to hold contest information. Contents are scheduled at venues for a home and away team. They are for a specific date, start and end time, and should never overlap with another contest for the same venue. Contests are always for teams in the same division.




Add validation API declarations to your business objects as appropriate. This need not be extensive or exhaustive. Just do enough to show use of declarative validation as a part of your application.

Design and implement a mechanism to ingest a starting state for eLeague based on a provided data file and parser. You will implement two primary sets of classes to support this requirement; the DAO(s) and an Ingestor.


Note

Please ignore references in the diagrams that call out use of JDBC. All DAOs can be implemented exclusively with JPA for this assignment.

Design and implement a DAO layer that will map the business objects between the object model and the database using the Java Persistence API (JPA). These DAOs will support all standard CRUD operations and can optionally implement the same interface as other potential DAO implementations. The implementation can make liberal use of JPA @Annotations, descriptor files, or a combination of both. Your interface should encapsulate the fact that an EntityManager is being used and the same EntityManager should be shared among other DAOs in the same Thread. Your DAOs should not attempt to control the transaction or they will NOT be portable to the EJB tier.

Add tuning to your database schema by augmenting the DDL files with indexes for foreign keys, joins, and where clauses. This need not be extensive or exhaustive. Just do enough to show that proper data model and database tuning is part of the overall enterprise development process.

Design an initial business interface and business logic for the applications. The core O/R mapping work will be done by the DAOs. However, it is the ultimate responsibility of these business logic implementations that either it or the business objects enforce the business rules of the application. The DAOs only perform O/R mapping and do not enforce such things as business ordering. The business logic is assumed to work within the context of a single, externally controlled transaction. Do not attempt to control the transaction of the EntityManager within these objects or you will NOT be portable to the EJB tier (without extra work). You need only implement the behavior required to implement the end-to-end use case listed in the testing section. Some of the anticipated methods are listed below.


LeagueMgmt/LeagueMgmtImpl

Encapsulate the actions required to create Clubs and manage Seasons and Divisions.

  1. addSeason - league coordinators will need to create a new season for the league. The league cannot have 2 or more concurrent seasons and will know the most current season, if any.

  2. addDivision - league coordinators will need to add divisions for a season. Club coordinators will be assigning their teams to the league's divisions for a season.

  3. getDivisions - users will need to know which divisions exist for the most current season. There will also need to be the capability to get historical information for previous seasons.

  4. createClub - league coordinators will need to create new clubs for the league. Once the club has been created, ClubMgmt can be used to perform management of the club details.

  5. assignTeamDivision - clubs will have to assign their teams to divisions after the league has created them for an upcoming season.

  6. getDivisionStandings - users will want to get divisional standings information for the most current season. This would normally consist of an ordered list of teams based on wins (you can ignore ties) and their win, loss, tie totals. Note that this may involve the creation of a transient object that is calculated on-demand by business objects and may not be persisted in the database. There will also need to be the capability to get historical information for previous seasons.

  7. getTeam - regular users and team/club officials will need to obtain team points of contact, schedule, and contest results for the most current season. There will also need to be the capability to get historical information for previous seasons.

ClubMgmt/ClubMgmtImpl

Encapsulate the actions required to manage Venues and Teams.

  1. addVenue - you will need to create one or more venues for the league to schedule contests for your club. The only thing that the club manages for the venue is keeping directional information up to date.

  2. addTeam - you will need to create teams that play for the club. Note that clubs span multiple seasons/divisions and may even sit out a season. Therefore, teams are usually added first and then later assigned to divisions.

  3. updateTeamContact - clubs and teams will need to update points of contact information.

ContestMgmt/ContestMgmtImpl

Encapsulate the actions required to schedule and manage contests between teams within the league.

  1. scheduleSeason - league officials will need to create a home and away schedule for each team in the division with each team playing each other at least once and possibly more (for smaller divisions), up to a specified number (default to 10) number of games. Your scheduling can be extremely simple as long as it does not schedule conflicting contests. Ideally a team would not play more than once on a single day and you might want to limit contests to a specific set of days of the week. However, the fact that you have placed the scheduling within the correct architectural area is the key point. How simple you make the algorithm is totally up to you and will not impact your grade. You may decide how much scheduling gets done by the business object(s) and how much gets done by the business logic.

  2. reportScore - division coordinators will need to be able to report the results of a contest.

LeagueTestUtil/LeagueTestUtilImpl

A useful tool during testing that encapsulates how to get the application back into a known state prior to running a test or to inspect values not normally exposed through the normal business interfaces.

  1. resetAll - sanely take the state of the system down to a coldstart.

  2. populate - you might want the database populated with a known state prior to running a test. This may delegate to the LeagueIngestor.

  3. get/doXXX - methods that are unsafe for the actual business logic, but are needed for development and test.

LeagueIngestor

The Ingestor written as a part of a separate requirement is also logically considered part of this tier.

  1. ingest - point an externally provided parser at a set of test data and use the DAOs to populate the system to a known state.


Note

Keep in mind that this project has two notions of a club. From the league's perpective it manages schedules, scores, and high level contact information for teams within a club. From the club's perspective, there is the need to manage coaches, players, and parents associated with the team. For that reason -- I am calling the club an organization here to avoid some confusion.

MemberMgmt/MemberMgmtImpl

Encapsulates the actions required to manage individuals registering with the club.

  1. createParent - parents will need to be able to register with the club.

  2. createPlayer - parents will need the ability to register their minors as players. All players will need at least one parent.

  3. addCoachRole - coaches will need to be able to register with the club. It is common that a coach is also a parent.

  4. getIndividual, Player, and Coach - created individuals will need to be retrieved.

OrgMgmt/OrgMgmtImpl

Encapsulate the actions required to create teams and get team information. Some of this information will come from contacting eLeague in future projects.

  1. createTeam - club officials will need to create teams.

  2. assignPlayers - club officials will need to assign players to teams

  3. assignCoach - club officials will need the ability to assign a coach to a team

  4. assignManager - club officials will need to ability to assign a manager to a team

  5. getTeamRoster - users assigned to a team will need the ability to get the roster for team. Rosters contain coach, manager, player, and parent information.

  6. getTeamSchedule - users will need the ability to get the schedule for a team for the most current season. This information will come from eLeague in a future project. Team schedules should have contest dates, venue, and scores.

ClubTestUtil/ClubTestUtilImpl

A useful tool during testing that encapsulates how to get the application back into a known state prior to running a test or to inspect values not normally exposed through the normal business interfaces.

  1. resetAll - sanely take the state of the system down to a coldstart.

  2. populate - it may be helpful to return the database to a known populated state between tests.

  3. get/doXXX - methods that are unsafe for the actual business logic, but are needed for development and test.