14 package cz.vutbr.fit.knot.annotations.web;
22 import java.io.Serializable;
23 import java.util.List;
24 import java.util.logging.Level;
25 import java.util.logging.Logger;
26 import javax.faces.bean.ManagedBean;
27 import javax.faces.bean.ViewScoped;
81 subscribedItem = SessionManager.getSession().getEditedSubscription();
84 subscribedItem.setStoryScopeId(SessionManager.getSession().getEditedStoryScope().getId());
92 if (backup.
getId() != subscribedItem.getId()) {
116 this.subscriptionType = annotType;
127 subscribedItem = SessionManager.getSession().getEditedSubscription();
130 subscribedItem.setStoryScopeId(SessionManager.getSession().getEditedStoryScope().getId());
138 if (backup.
getId() != subscribedItem.getId()) {
146 annotURI = SessionManager.getSession().getAnnotationTypeAddress();
148 if(
annotURI == null && backup != null) {
164 Object[] params = {
"id",tempItem.getAnnotationType().getId()};
165 @SuppressWarnings(
"unchecked")
166 List<AnnotType> list = AppBean.getPersistenceManager().queryDB(
"AnnotType.findById",params);
168 errorMessage = MessageProvider.getMessage(
"ssSubsEditTypeNotFound");
193 subscribedItem = SessionManager.getSession().getEditedSubscription();
196 subscribedItem.setStoryScopeId(SessionManager.getSession().getEditedStoryScope().getId());
204 if (backup.
getId() != subscribedItem.getId()) {
210 sourceURI = SessionManager.getSession().getSaveSourceUri();
212 if(
sourceURI == null && backup != null) {
239 subscribedItem = SessionManager.getSession().getEditedSubscription();
246 if (backup.
getId() != subscribedItem.getId()) {
254 userLogin = SessionManager.getSession().getSaveUserLogin();
256 if(
userLogin == null && backup != null) {
267 if(tempItem.
getUser() == null){
272 Object[] params = {
"id",tempItem.getUser().getId()};
273 @SuppressWarnings(
"unchecked")
274 List<User> list = AppBean.getPersistenceManager().queryDB(
"User.findById",params);
276 errorMessage = MessageProvider.getMessage(
"ssSubsEditUserNotFound");
291 this.userLogin = userURI;
336 boolean isErrorOccured =
false;
341 @SuppressWarnings(
"unchecked")
342 List<AnnotType> list = AppBean.getPersistenceManager().queryDB(
"AnnotType.findByUri",params);
343 if(list == null || list.isEmpty()){
344 errorMessage += MessageProvider.getMessage(
"ssSubsCantFindType");
345 isErrorOccured =
true;
347 subscribedItem.setAnnotationType(list.get(0));
350 subscribedItem.setAnnotationType(null);
355 @SuppressWarnings(
"unchecked")
356 List<User> list = AppBean.getPersistenceManager().queryDB(
"User.findByLogin",params);
357 if(list == null || list.isEmpty()){
358 errorMessage += MessageProvider.getMessage(
"ssSubsCantFindUser");
359 isErrorOccured =
true;
361 subscribedItem.setUser(list.get(0));
364 subscribedItem.setUser(null);
370 subscribedItem.setSource(null);
374 errorMessage += MessageProvider.getMessage(
"ssSubsTypeIncorrect");
375 isErrorOccured =
true;
388 if(editedStoryScope == null){
389 errorMessage = MessageProvider.getMessage(
"ssSubsCantReachSS");
391 String msg =
"Can't reach edited StoryScope.";
392 Logger.getLogger(EditSubscriptions.class.getName()).log(Level.SEVERE, msg);
399 subscribedItem.setStoryScopeId(editedStoryScope.getId());
403 errorMessage = MessageProvider.getMessage(
"ssSubsEditDatabaseFailure");
405 String msg =
"Persisting of changes in subscribed item for StoryScope account failed.";
406 Logger.getLogger(EditSubscriptions.class.getName()).log(Level.SEVERE, msg);
413 SessionManager.getSession().setAnnotationTypeAddress(null);
414 SessionManager.getSession().setSaveUserLogin(null);
415 SessionManager.getSession().setSaveSubscriptionType(null);
416 SessionManager.getSession().setSaveSourceUri(null);
417 SessionManager.getSession().setEditedSubscription(null);
427 boolean isErrorOccured =
false;
435 @SuppressWarnings(
"unchecked")
436 List<AnnotType> list = AppBean.getPersistenceManager().queryDB(
"AnnotType.findByUri",params);
437 if(list == null || list.isEmpty()){
439 errorMessage += MessageProvider.getMessage(
"ssSubsCantFindType");
440 isErrorOccured =
true;
443 subscribedItem.setAnnotationType(list.get(0));
451 @SuppressWarnings(
"unchecked")
452 List<User> list = AppBean.getPersistenceManager().queryDB(
"User.findByLogin",params);
453 if(list == null || list.isEmpty()){
455 errorMessage += MessageProvider.getMessage(
"ssSubsCantFindUser");
456 isErrorOccured =
true;
459 subscribedItem.setUser(list.get(0));
471 errorMessage += MessageProvider.getMessage(
"ssSubsTypeIncorrect");
472 isErrorOccured =
true;
484 if(editedStoryScope == null){
485 errorMessage = MessageProvider.getMessage(
"ssSubsCantReachSS");
487 String msg =
"Can't reach edited StoryScope.";
488 Logger.getLogger(EditSubscriptions.class.getName()).log(Level.SEVERE, msg);
494 subscribedItem.setStoryScopeId(editedStoryScope.getId());
497 errorMessage = MessageProvider.getMessage(
"ssSubsAddDatabaseFailure");
499 String msg =
"Persisting of new subscription for StoryScope account failed.";
500 Logger.getLogger(EditSubscriptions.class.getName()).log(Level.SEVERE, msg);
505 SessionManager.getSession().setAnnotationTypeAddress(null);
506 SessionManager.getSession().setSaveUserLogin(null);
507 SessionManager.getSession().setSaveSubscriptionType(null);
508 SessionManager.getSession().setSaveSourceUri(null);
509 SessionManager.getSession().setEditedSubscription(null);
520 errorMessage = MessageProvider.getMessage(
"ssSubsDeleteDatabaseFailure");
522 String msg =
"DB failure during deleting of Subscribtion form StoryScope account.";
523 Logger.getLogger(EditSubscriptions.class.getName()).log(Level.SEVERE, msg);
529 SessionManager.getSession().setAnnotationTypeAddress(null);
530 SessionManager.getSession().setSaveUserLogin(null);
531 SessionManager.getSession().setSaveSubscriptionType(null);
532 SessionManager.getSession().setSaveSourceUri(null);
533 SessionManager.getSession().setFormBackup(null);
534 SessionManager.getSession().setEditedSubscription(null);
544 SessionManager.getSession().setAnnotationTypeAddress(null);
545 if(
subscribedItem == null) SessionManager.getSession().setComeFrom(
"editSubscription");
546 else SessionManager.getSession().setComeFrom(
"addSubscription");
547 SessionManager.getSession().setSaveUserLogin(
userLogin);
549 SessionManager.getSession().setSaveSourceUri(
sourceURI);
559 SessionManager.getSession().setAnnotationTypeAddress(null);
560 SessionManager.getSession().setSaveUserLogin(null);
561 SessionManager.getSession().setSaveSubscriptionType(null);
562 SessionManager.getSession().setSaveSourceUri(null);
563 SessionManager.getSession().setFormBackup(null);
564 SessionManager.getSession().setEditedSubscription(null);
void setAnnotURI(String annotURI)
static WebSession getSession()
void setSourceURI(String sourceURI)
Integer getSubscriptionType()
static final int SUBSCRIBED
Class for manipulating with session.
Class representing StoryScope for needs of SEC Interface.
Singleton for storing global variables.
SubscribedItem subscribedItem
static final int UNSUBSCRIBED
void setSubscriptionType(Integer annotType)
static final int LOG_LEVEL
Class representing type of annotation.
Class representing item of subscripted or unsubscripted sources list.
Backbean for pages for adding, editing and deleting of StoryScope's subscriptions.
void setSubscribedItem(SubscribedItem subscribedItem)
void setUserLogin(String userURI)
static PersistM getPersistenceManager()
void setErrorMessage(String errorMessage)
static final int LOG_LEVEL_SERVER_ERRORS
StoryScope editedStoryScope
AnnotType getAnnotationType()
SubscribedItem getSubscribedItem()