예제 #1
0
  /**
   * Initializes the user profile with the data from the database
   *
   * @param ident The current Subject
   */
  public void loadStatusFormData(
      final StatusForm statusForm,
      final CourseNode node,
      final UserCourseEnvironment userCourseEnv) {
    final Identity identity = userCourseEnv.getIdentityEnvironment().getIdentity();
    final CoursePropertyManager cpm =
        userCourseEnv.getCourseEnvironment().getCoursePropertyManager();
    PropertyImpl statusProperty;

    statusProperty = cpm.findCourseNodeProperty(node, identity, null, PROPERTY_KEY_STATUS);
    if (statusProperty == null) {
      // found no status property => init DEFAULT value
      statusForm.setSelectedStatus(STATUS_VALUE_INITIAL);
    } else {
      final String value = statusProperty.getStringValue();
      statusForm.setSelectedStatus(value);
    }
  }
예제 #2
0
  public void saveStatusFormData(
      final StatusForm statusForm,
      final CourseNode node,
      final UserCourseEnvironment userCourseEnv) {
    final Identity identity = userCourseEnv.getIdentityEnvironment().getIdentity();
    final String selectedKey = statusForm.getSelectedStatus();

    final CoursePropertyManager cpm =
        userCourseEnv.getCourseEnvironment().getCoursePropertyManager();
    PropertyImpl statusProperty;

    statusProperty = cpm.findCourseNodeProperty(node, identity, null, PROPERTY_KEY_STATUS);
    if (statusProperty == null) {
      statusProperty =
          cpm.createCourseNodePropertyInstance(
              node, identity, null, PROPERTY_KEY_STATUS, null, null, selectedKey, null);
      cpm.saveProperty(statusProperty);
    } else {
      statusProperty.setStringValue(selectedKey);
      cpm.updateProperty(statusProperty);
    }
  }