Next: About this document ...
Up: entidades-e-servicos
Previous: Requisitos
module VideoRentalStore {
enum MediaType {VHS, DVD};
struct Date { short day; short month; short year; };
// Forward interface declarations
interface Movie;
interface MovieCopy;
interface Customer;
// Auxiliary sequence definitions
typedef sequence<string> StringList;
typedef sequence<Movie> MovieList;
typedef sequence<MovieCopy> MovieCopyList;
typedef sequence<Customer> CustomerList;
// Exception definitions
exception CreateException { string detail; };
exception RemoveException { string detail; };
exception NotFoundException { };
exception AlreadyRentedException { };
exception NotRentedException { };
// Definitions of entity interfaces (Movie, MovieCopy and Customer)
// and their corresponding home (factory and finder) interfaces
interface Movie {
long getId();
string getName(); // movie name
string getDirector(); // name of director
StringList getGenre(); // list of genre names (comedy, action, etc)
StringList getCast(); // list of actor/actress names
short getYear(); // production year
short getDuration(); // movie duration in minutes
MovieCopyList getCopies(); // the copies of this movie
};
interface MovieHome {
Movie create(in long Id,
in string name,
in string Director,
in StringList genre,
in StringList cast,
in short year,
in short duration)
raises(CreateException);
void remove(in long id)
raises(RemoveException);
Movie findById(in long id)
raises(NotFoundException);
MovieList findByName(in string name);
MovieList findByDirector(in string director);
};
interface MovieCopy {
long getId();
Movie getMovie();
MediaType getMediaType();
boolean isRented();
void rentTo(in Customer customer,
in Date returnDate)
raises(AlreadyRentedException);
void unrent()
raises(NotRentedException);
Customer getTaker()
raises(NotRentedException);
Date getReturnDate()
raises(NotRentedException);
};
interface MovieCopyHome {
MovieCopy create(in long id,
in Movie movie,
in MediaType mediaType)
raises(CreateException);
void remove(in long id)
raises(RemoveException);
MovieCopy findById(in long id)
raises(NotFoundException);
MovieCopyList findByMovieIdAndMediaType(in long movieId,
in MediaType mediaType);
};
interface Customer {
long getId();
string getName();
string getPhone();
void setPhone(in string phone);
MovieCopyList getTakenMovieCopies();
};
interface CustomerHome {
Customer create(in long id,
in string name,
in string phone)
raises(CreateException);
void remove(in long id)
raises(RemoveException);
Customer findById(in long id)
raises(NotFoundException);
CustomerList findByName(in string name);
CustomerList findByPhone(in string phone);
};
// Additional structure and sequence definitions for service interface
struct RentedMovieCopyInfo {
long movieCopyId;
string customerName;
string customerPhone;
Date returnDate;
};
typedef sequence<RentedMovieCopyInfo> RentedMovieCopies;
struct MovieInfo {
long id;
string name;
string director;
StringList genre;
StringList cast;
short year; // production year
short duration; // movie duration in minutes
short inStoreCopies;
RentedMovieCopies rentedCopies;
};
typedef sequence<MovieInfo> MatchingMovies;
// Additional exception definitions for service interface
exception InvalidMovieCopyIdException { };
exception InvalidCustomerIdException { };
// Definition of service interface
interface RentalService {
MovieInfo findMovieById(in long id)
raises(NotFoundException);
MatchingMovies findMovieByName(in string name);
MatchingMovies findMovieByDirector(in string name);
MatchingMovies findMovieByGenreAndYear(in string genre,
in short year);
void startRental(in long movieCopyId,
in long customerId,
in Date returnDate)
raises(InvalidMovieCopyIdException,
AlreadyRentedException,
InvalidCustomerIdException);
void endRental(in long movieCopyId)
raises(InvalidMovieCopyIdException,
NotRentedException);
};
};
Francisco Reverbel
2006-04-18