modelfacade.java
来自「SUN公司发布的SmartTicket 2.0蓝图」· Java 代码 · 共 479 行 · 第 1/2 页
JAVA
479 行
public Theater[] getCachedTheaters(String zipCode) throws ApplicationException { return localModel.getCachedTheaters(zipCode); } public Theater[] getPersistedTheaters(String zipCode) throws ApplicationException { return localModel.getPersistedTheaters(zipCode); } public Theater[] getCachedAndPersistedTheaters(String zipCode) throws ApplicationException { return localModel.getTheaters(zipCode); } public void cleanup() throws ApplicationException { localModel.cleanup(); return; } public void persistTheaterSchedule(Theater theater) throws ApplicationException { try { remoteModel.downloadTheaterSchedule(theater); } catch (ModelException me) { throw new ApplicationException(errorMessageCodeMap[me.getCauseCode()]); } return; } public Reservation reserveSeats(String theaterKey, String movieKey, int[] showTime, Seat[] seats) throws ApplicationException { try { return remoteModel.reserveSeats(theaterKey, movieKey, showTime, seats); } catch (ModelException me) { throw new ApplicationException(errorMessageCodeMap[me.getCauseCode()]); } } public void purchaseTickets(Reservation reservation) throws ApplicationException { try { remoteModel.purchaseTickets(reservation.getId()); localModel.addMovieRating(new MovieRating(remoteModel.getMovie(reservation.getMovieId()), reservation.getShowTime())); } catch (ModelException me) { throw new ApplicationException(errorMessageCodeMap[me.getCauseCode()]); } return; } public void cancelSeatReservation(Reservation reservation) throws ApplicationException { try { remoteModel.cancelSeatReservation(reservation.getId()); } catch (ModelException me) { throw new ApplicationException(errorMessageCodeMap[me.getCauseCode()]); } return; } public void synchronizeMovieRatings(int conflictResolutionStrategyId) throws ApplicationException { try { syncAgent.synchronizeMovieRatings(conflictResolutionStrategyId); return; } catch (ModelException me) { throw new ApplicationException(errorMessageCodeMap[me.getCauseCode()]); } } public MovieRating[][] synchronizeMovieRatings() throws ApplicationException { try { return syncAgent.synchronizeMovieRatings(); } catch (ModelException me) { throw new ApplicationException(errorMessageCodeMap[me.getCauseCode()]); } } public void commitMovieRatings(MovieRating[] resolvedMovieRatings) throws ApplicationException { try { syncAgent.commitMovieRatings(resolvedMovieRatings); } catch (ModelException me) { throw new ApplicationException(errorMessageCodeMap[me.getCauseCode()]); } return; } public String[] getLocales() throws ApplicationException { try { return remoteModel.getLocales(); } catch (ModelException me) { throw new ApplicationException(errorMessageCodeMap[me.getCauseCode()]); } } public void setLocale(String locale) throws ApplicationException { setLocale(locale, true); return; } public void setLocale(String locale, boolean overwrite) throws ApplicationException { IndexedResourceBundle errorBundle; if (!overwrite) { errorBundle = localModel.getResourceBundle(BASE_NAME_ERROR_RESOURCES); if (errorBundle != null) { this.locale = errorBundle.getLocale(); } else { this.locale = locale; } } else { this.locale = locale; } errorBundle = getResourceBundle(BASE_NAME_ERROR_RESOURCES); ApplicationException.setResourceBundle(errorBundle); return; } public IndexedResourceBundle getResourceBundle(String baseName) throws ApplicationException { IndexedResourceBundle resourceBundle = localModel.getResourceBundle(baseName); if (resourceBundle == null ||!resourceBundle.getLocale().equals(locale)) { try { InputStream stream = getClass().getResourceAsStream(makeResourceBundleName(baseName, locale)); resourceBundle = stream != null ? IndexedResourceBundle.getBundleFromPropertyFile(locale, stream) : null; if (resourceBundle != null) { return resourceBundle; } } catch (IOException ioe) { resourceBundle = null; } // if (resourceBundle == null) { try { resourceBundle = remoteModel.getResourceBundle(baseName, locale); } catch (ModelException me) { throw new ApplicationException(errorMessageCodeMap[me.getCauseCode()]); } // } localModel.setResourceBundle(baseName, resourceBundle); } return resourceBundle; } private String makeResourceBundleName(String baseName, String locale) { return new StringBuffer(L10N_ROOT_DIR).append(baseName).append("_").append(locale).append(".properties").toString(); } public void addRecommendationMovieRating(MovieRating rating) throws ApplicationException { localModel.addMovieRating(rating); return; } public void sendRecommendation(String message, MovieRating rating) throws ApplicationException { RecommendationRecipient[] recipients = localModel.getRecommendationRecipients(); String[] addresses = new String[recipients.length]; for (int i = 0; i < addresses.length; i++) { addresses[i] = recipients[i].getSMSCAddress(); } rating.setAuthor(getAccountInfo().getUserName()); messagingAgent.sendRecommendation(message, rating, addresses); return; } public void receiveRecommendation(RecommendationReceiver receiver) throws ApplicationException { messagingAgent.receiveRecommendation(receiver); return; } public RecommendationRecipient[] getRecommendationRecipients() throws ApplicationException { return localModel.getRecommendationRecipients(); } public void addRecommendationRecipient(String userName) throws ApplicationException { try { String smscAddress = remoteModel.getSMSCAddress(userName); RecommendationRecipient recipient = new RecommendationRecipient(userName, smscAddress); localModel.setRecommendationRecipient(recipient); return; } catch (ModelException me) { throw new ApplicationException(errorMessageCodeMap[me.getCauseCode()]); } } public void deleteRecommendationRecipient(String userName) throws ApplicationException { localModel.deleteRecommendationRecipient(userName); return; } }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?