コード例 #1
0
ファイル: StatusManager.java プロジェクト: YaqubGhazi/olat
  /**
   * 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
ファイル: StatusManager.java プロジェクト: YaqubGhazi/olat
  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);
    }
  }