Package org.cast.isi.data

Examples of org.cast.isi.data.FeedbackMessage


      private static final long serialVersionUID = 1L;
     
      @Override
      public void onSubmit() {
        super.onSubmit();
        FeedbackMessage m = getModelObject();
        User student;

        m.setAuthor(ISISession.get().getUser());
        m.setTimestamp(new Date());
        if (m.getAuthor().getRole().equals(Role.STUDENT)) {
          student = ISISession.get().getUser();
          sectionService.adjustMessageCount(student, ((ISIStandardPage) getPage()).getLoc(), Role.STUDENT, 1);
        } else {
          student = ISISession.get().getStudent();
          sectionService.adjustMessageCount(student, ((ISIStandardPage) getPage()).getLoc(), m.getAuthor().getRole(), 1);
        }
        m.setStudent(student);
        m.setPrompt(promptM.getObject());
        m.setLocation(((ISIStandardPage) getPage()).getLoc().getLocation());
        m.setUnread(true);
        m.setVisible(true);
        Databinder.getHibernateSession().save(m);
        cwmService.flushChanges();
        eventService.saveEvent("message:sent", String.valueOf(m.getId()), ((ISIStandardPage) getPage()).getPageName());
      }
     
      @Override
      public boolean isVisible() {
        return !ISISession.get().getUser().hasRole(Role.RESEARCHER); // Researchers cannot send messages
      }
    };
    form.setOutputMarkupPlaceholderTag(true);
    TextArea<String> messageField = new TextArea<String>("message");
    messageField.setRequired(true);
    form.add(messageField);
    form.add(new FormComponentLabel("messageLabel", messageField));
    final FeedbackPanel feedbackPanel = new ComponentFeedbackPanel("feedbackPanel", form);
    feedbackPanel.setOutputMarkupPlaceholderTag(true);
    form.add(feedbackPanel);
    AjaxSubmitLink sendLink = new AjaxSubmitLink("send") {
      private static final long serialVersionUID = 1L;

      @Override
      protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
        messageList.add(0, (FeedbackMessage) form.getModelObject());
        form.setDefaultModel(new CompoundPropertyModel<FeedbackMessage>(new FeedbackMessage()));
        if (target != null) {
          target.addComponent(form);
          target.addComponent(responseContainer);
          target.addComponent(callingButton);
        }
      }
     
      @Override
      protected void onError(AjaxRequestTarget target, Form<?> form) {
        form.error("Please type a message.");
        if (target != null)
          target.addComponent(feedbackPanel);
      }   
    };
    form.add(sendLink);
    sidebarDialog.getBodyContainer().add(form);
   
    responses = new ListView<FeedbackMessage>("responses", new FeedbackListModel()) {
      private static final long serialVersionUID = 1L;

      @Override
      protected void populateItem(ListItem<FeedbackMessage> item) {
        final FeedbackMessage m = (FeedbackMessage) item.getModelObject();
        item.add(new Label("date", DateFormat.getDateInstance(DateFormat.MEDIUM).format(m.getTimestamp())));
        item.add(new Label("time", DateFormat.getTimeInstance(DateFormat.MEDIUM).format(m.getTimestamp())));
        item.add(new Label("name", m.getAuthor().getFullName()));
        item.add(new Label("message", m.getMessage()));

        // Delete Dialog
        AjaxDeletePersistedObjectDialog<FeedbackMessage> dialog = new AjaxDeletePersistedObjectDialog<FeedbackMessage>("deleteModal", new Model<FeedbackMessage>(m)) {
          private static final long serialVersionUID = 1L;
         
          @SuppressWarnings("unchecked")
          @Override
          protected void deleteObject(AjaxRequestTarget target) {
            FeedbackMessage m = (FeedbackMessage) getDefaultModelObject();
            ISIResponseService.get().deleteFeedbackMessage((IModel<FeedbackMessage>) getDefaultModel());
            messageList.remove(m);
            if (m.isUnread()) {
              if (m.getAuthor().getRole().equals(Role.STUDENT)) {
                sectionService.adjustMessageCount(m.getStudent(), ((ISIStandardPage) getPage()).getLoc(), Role.STUDENT, -1);
              } else {
                sectionService.adjustMessageCount(m.getStudent(), ((ISIStandardPage) getPage()).getLoc(), m.getAuthor().getRole(), -1);
              }
            }
            target.addComponent(responseContainer);       
            target.addComponent(callingButton);       
            target.addChildren(getPage(), IDisplayFeedbackStatus.class);
          }
        };
        dialog.setObjectName("Feedback Message");
        item.add(dialog);
       
        // Delete Link
        item.add(new WebMarkupContainer("delete").add(dialog.getClickToOpenBehavior())
          .setVisible(ISISession.get().getUser().equals(m.getAuthor())));

        if (m.getAuthor().getRole().equals(Role.STUDENT)) {
          item.add(new SimpleAttributeModifier("class", "respStudent"));
        } else if (m.getAuthor().getRole().equals(Role.TEACHER)){
          item.add(new SimpleAttributeModifier("class", "respTeacher"));
        }
      }     
    };
    responseContainer = new WebMarkupContainer("responseContainer");
View Full Code Here


    sidebarDialog.getBodyContainer().add(responseContainer);
  }
 
 
  public void clearFeedbackMessageForm() {
    form.setDefaultModel(new CompoundPropertyModel<FeedbackMessage>(new FeedbackMessage()));   
  }
View Full Code Here

 
  /* (non-Javadoc)
   * @see org.cast.isi.service.IISIResponseService#deleteFeedbackMessage(org.apache.wicket.model.IModel)
   */
  public void deleteFeedbackMessage(IModel<FeedbackMessage> mFeedbackMessage) {
    FeedbackMessage feedbackMessage = mFeedbackMessage.getObject();
    feedbackMessage.setVisible(false);
    Databinder.getHibernateSession().update(feedbackMessage);
    cwmService.flushChanges();
    eventService.saveEvent("feedback:delete", "Message Id: " + feedbackMessage.getId(), null);
  }
View Full Code Here

  /* (non-Javadoc)
   * @see org.cast.isi.service.IISIResponseService#updateFeedbackMessage(org.apache.wicket.model.IModel, org.apache.wicket.Page)
   */
  public void updateFeedbackMessage(IModel<FeedbackMessage> mFeedbackMessage, Page page) {
    FeedbackMessage feedbackMessage = mFeedbackMessage.getObject();
    Databinder.getHibernateSession().update(feedbackMessage);
    cwmService.flushChanges();
    String pageName = page instanceof ISIBasePage ? ((ISIBasePage)page).getPageName() : null;
    eventService.saveEvent("message:view", "Message Id: " + String.valueOf(feedbackMessage.getId()), pageName);
  }
View Full Code Here

    q.setParameterList("locationList", locations);
    q.setMaxResults(1);
    q.setCacheable(true);
    if (q.list().isEmpty())
      return null;
    FeedbackMessage m = (FeedbackMessage) q.list().get(0);
    return m.getLocation();
  }
View Full Code Here

TOP

Related Classes of org.cast.isi.data.FeedbackMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.