Package org.cast.cwm.data

Examples of org.cast.cwm.data.User


      this.setOutputMarkupPlaceholderTag(true);
    }

    @Override
    protected void onBeforeRender() {
      User student = ISISession.get().getTargetUserModel().getObject();
      List<FeedbackMessage> messages = responseService.getNotesForPage(student, new ContentLoc(mIsiXmlSection.getObject()).getLocation());
      boolean unread = false;
      for (FeedbackMessage m : messages) {
        if (m.isUnread()
            && ((m.getAuthor().getRole().equals(Role.STUDENT) && teacher) ||
View Full Code Here


      return !success;
    }

    @Override
    protected void onBeforeSave(HibernateObjectModel<User> mUser) {
      User user = mUser.getObject();
      Role userRole = (Role) radioGroup.getDefaultModelObject();
      user.setRole(userRole);
      user.setCreateDate(new Date());
      user.setValid(false);
      user.generateSecurityToken();
      user.setPassword(password.getConvertedInput());
      String url = "/register?username=" + user.getUsername() + "&key=" + user.getSecurityToken();
      if (userRole.equals(Role.STUDENT)) {
        // add user to the default period
        user.getPeriods().clear();
        user.getPeriods().add(ISIApplication.get().getMDefaultPeriod().getObject());       
        ISIEmailService.get().sendXmlEmail(mUser, ISIEmailService.EMAIL_CONFIRM, url);
      } else {
        createDefaultTeacher(user);
        ISIEmailService.get().sendXmlEmail(mUser, ISIEmailService.EMAIL_CONFIRM_TEACHER, url, studentPassword);
      }
View Full Code Here

      periodSet.add(newPeriod);
      user.getPeriods().add(newPeriod);
      newSite.getPeriods().add(newPeriod);     
     
      // a default student must be added to the new period
      User studentUser = UserService.get().newUser();
      studentUser.setRole(Role.STUDENT);
      studentUser.setFirstName("Student");
      studentUser.setLastName(newPeriod.getName());
      studentUser.setUsername(newPeriod.getName());
      studentUser.getPeriods().add(newPeriod);
      studentUser.setValid(true);
      studentUser.setCreateDate(new Date());
     
      // create a random number for the password
      Random randomNumber = new Random();
      Integer studentPasswordInteger = randomNumber.nextInt();
      studentPassword = studentPasswordInteger.toString().substring(0, 6);
      log.debug("this is the student password : {}", studentPassword);
      studentUser.setPassword(studentPassword);     
     
      // add the teacher and the default student to the new default class
      userSet.add(studentUser);
      newPeriod.setUsers(userSet);
View Full Code Here

    if (params != null) {
      String username = params.getString("username");
      String token = params.getString("token");

      if (username != null && token != null) {
        User user = app.getUser(username);
        if (user != null && app.getToken(user).equals(token)) {
          AuthDataSession.get().signIn(user, true);
        }
        setResponsePage(((Application)app).getHomePage());
        setRedirect(true);
View Full Code Here

      if(session.signIn((String)username.getModelObject(), (String)password.getModelObject())){

        eventService.createLoginSession(getRequest());
        eventService.saveLoginEvent();
       
        User user = session.getUser();
        if (!user.isValid()) {
          String notConfirmed = new StringResourceModel("Login.notConfirmed", this, null, "Account not confirmed.").getString();
          error(notConfirmed);
          return;
        }

        // Set default Period
        if (user != null && user.usesPeriods()) {
          session.setCurrentPeriodModel(new HibernateObjectModel<Period>(user.getPeriods().iterator().next()));
          Site currentSite = ISISession.get().getCurrentPeriodModel().getObject().getSite();
          IModel<Site> mCurrentSite = new Model<Site>(currentSite);
          session.setCurrentSiteModel(mCurrentSite);
        }       
View Full Code Here

    }
   
    @Override
    protected void onSubmit() {
      super.onSubmit();
      User currentUser = getModelObject();
      Period currentPeriod = currentUser.getPeriods().first();
      Period newPeriod = periodChoiceMove.getModelObject();
     
      // Ensure that someone else does not have the same first and last name in the destination period
      IModel<User> mOtherUser = UserService.get().getByFullnameFromPeriod(currentUser.getFirstName(), currentUser.getLastName(), periodChoiceMove.getModel());
      boolean error = false;
      if (mOtherUser != null && mOtherUser.getObject() != null && !mOtherUser.getObject().getId().equals(currentUser.getId()) ) {
        error("Move Failed: A student with that name already exists in " + newPeriod.getName() + ". \n");
        error = true;
      } else if (newPeriod == currentPeriod) {
        error("Cannot move student to the same period");
        error = true;     
      }

      if (!error) {
        currentUser.getPeriods().clear();
        currentUser.getPeriods().add(newPeriod);
       
        cwmService.flushChanges();
        eventService.saveEvent("student:periodmove", "Student: " + currentUser.getId() +
            "; From PeriodId " + currentPeriod.getId() + " to PeriodId " + newPeriod.getId(), getPageName());
     

    }   
View Full Code Here

       
    @Override
    protected void onSubmit() {
     
      // Current User being saved
      User student = getModelObject();

      // Are we saving a new user?
      boolean isNewStudent = student.isTransient();

      // Add additional information if the user is new.
      if (isNewStudent) {
        student.setValid(true);
        student.setPeriods(new TreeSet<Period>(Arrays.asList(ISISession.get().getCurrentPeriodModel().getObject())));
        student.setSubjectId(student.getUsername());
        student.setRole(Role.STUDENT);
        Databinder.getHibernateSession().save(student); // Persist the new user
      }
     
      // Store changes to the database
      cwmService.flushChanges();

      // Log event
      String eventType = isNewStudent ? "student:create" : "student:modify";
      eventService.saveEvent(eventType, String.valueOf(student.getId()), getPageName());
    }
View Full Code Here

      }     
    });
   
    // If user comes in with a registration key, confirm their account.
    if (params.containsKey("username") && params.containsKey("key")) {
      User user = UserService.get().getByUsername(params.getString("username")).getObject();
      if (user != null && params.getString("key").equals(user.getSecurityToken())) {
        UserService.get().confirmUser(user);
        ISISession.get().signIn(user, false);
        eventService.createLoginSession(getRequest());
        eventService.saveEvent("user:created", null, null);
        eventService.saveLoginEvent();
View Full Code Here

      userSet.add(mUser.getObject());
      period.setUsers(userSet);
      Databinder.getHibernateSession().save(period);
     
      // Update the teacher to connect with the new period
      User user = mUser.getObject();
      SortedSet<Period> periodSet = new TreeSet<Period>();
      periodSet.addAll(user.getPeriods());
      user.setPeriods(periodSet);
      user.getPeriods().add(period);
      Databinder.getHibernateSession().update(user);
     
      eventService.saveEvent("period:addPeriod", String.valueOf(getModelObject().getId()) + " added by userid " + String.valueOf(user.getId()), null);
    }
View Full Code Here

      ISIPrompt prompt = entry.getKey();
      List<ISIResponse> responses = entry.getValue();
      if (responses.isEmpty())
        return null;
      ISIResponse firstResponse = responses.get(0);
      User user = firstResponse.getUser();
      return scoreForPromptAndUser(prompt, firstResponse, user);
    }
View Full Code Here

TOP

Related Classes of org.cast.cwm.data.User

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.