Package org.olat.properties

Examples of org.olat.properties.Property


  public String getAnonymizedUserName(Identity identity) {
    synchronized (anonymizerMap) {
      String anonymizedName = (String) anonymizerMap.get(identity.getName());
      if (anonymizedName == null) {
        // try to fetch from course properties
        Property anonymizedProperty = pm.findProperty(identity, null, "Anonymizing", "AnonymizedUserName");
        if (anonymizedProperty == null) {
          // not found - create a new anonymized name
          anonymizedName = "RANDOM-" + random.nextInt(100000000);
          // add as course properties
          anonymizedProperty = pm.createPropertyInstance(identity, null, "Anonymizing", "AnonymizedUserName", null, null, anonymizedName,
              null);
          pm.saveProperty(anonymizedProperty);
        } else {
          // property found - use property value from there
          anonymizedName = anonymizedProperty.getStringValue();
        }
        anonymizerMap.put(identity.getName(), anonymizedName);
      }
      return anonymizedName;
    }
View Full Code Here


    final CoursePropertyManager cpm = userCourseEnv.getCourseEnvironment().getCoursePropertyManager();
    final CourseNode thisCourseNode = this;
    Forum theForum = null;
   
    Codepoint.codepoint(FOCourseNode.class, "findCourseNodeProperty")
    Property forumKeyProp = cpm.findCourseNodeProperty(thisCourseNode, null, null, FORUM_KEY);
    //System.out.println("System.out.println - findCourseNodeProperty");
    if(forumKeyProp!=null) {
      // Forum does already exist, load forum with key from properties
      Long forumKey = forumKeyProp.getLongValue();
      theForum = fom.loadForum(forumKey);
      if (theForum == null) { throw new OLATRuntimeException(FOCourseNode.class, "Tried to load forum with key " + forumKey.longValue() + " in course "
        + userCourseEnv.getCourseEnvironment().getCourseResourceableId() + " for node " + thisCourseNode.getIdent()
        + " as defined in course node property but forum manager could not load forum.", null); }
    } else {
      //creates resourceable from FOCourseNode.class and the current node id as key
      OLATResourceable courseNodeResourceable = OresHelper.createOLATResourceableInstance(FOCourseNode.class, new Long(this.getIdent()));
      Codepoint.codepoint(FOCourseNode.class, "beforeDoInSync");   
      //System.out.println("System.out.println - beforeDoInSync");
      //o_clusterOK by:ld
      theForum = CoordinatorManager.getCoordinator().getSyncer().doInSync(courseNodeResourceable, new SyncerCallback<Forum>(){
        public Forum execute() {
        Forum forum = null;
        Long forumKey;             
        Codepoint.codepoint(FOCourseNode.class,"doInSync");
        //System.out.println("Codepoint - doInSync");
        Property forumKeyProperty = cpm.findCourseNodeProperty(thisCourseNode, null, null, FORUM_KEY);       
        if (forumKeyProperty == null) {
          // First call of forum, create new forum and save forum key as property         
          forum = fom.addAForum();
          forumKey = forum.getKey();
          forumKeyProperty = cpm.createCourseNodePropertyInstance(thisCourseNode, null, null, FORUM_KEY, null, forumKey, null, null);
          cpm.saveProperty(forumKeyProperty)
          //System.out.println("Forum added");
        } else {
          // Forum does already exist, load forum with key from properties
          forumKey = forumKeyProperty.getLongValue();
          forum = fom.loadForum(forumKey);
          if (forum == null) { throw new OLATRuntimeException(FOCourseNode.class, "Tried to load forum with key " + forumKey.longValue() + " in course "
              + userCourseEnv.getCourseEnvironment().getCourseResourceableId() + " for node " + thisCourseNode.getIdent()
              + " as defined in course node property but forum manager could not load forum.", null); }
          }
View Full Code Here

   *
   * @see org.olat.course.nodes.CourseNode#archiveNodeData(java.util.Locale, org.olat.course.ICourse, java.io.File, java.lang.String)
   */
  public void archiveNodeData(Locale locale, ICourse course, File exportDirectory, String charset) {
    CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
    Property forumKeyProperty = cpm.findCourseNodeProperty(this, null, null, FORUM_KEY);
    if(forumKeyProperty != null){
      Long forumKey = forumKeyProperty.getLongValue();
      String forumName = Formatter.makeStringFilesystemSave(this.getShortTitle());

      // append export timestamp to avoid overwriting previous export
      Date tmp = new Date(System.currentTimeMillis());
      java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH_mm_ss_SSS");
View Full Code Here

   * @see org.olat.course.nodes.CourseNode#informOnDelete(org.olat.core.gui.UserRequest,
   *      org.olat.course.ICourse)
   */
  public String informOnDelete(Locale locale, ICourse course) {
    CoursePropertyManager cpm = PersistingCoursePropertyManager.getInstance(course);
    Property forumKeyProperty = cpm.findCourseNodeProperty(this, null, null, FORUM_KEY);
    if (forumKeyProperty == null) return null; // no forum created yet
    return new PackageTranslator(PACKAGE_FO, locale).translate("warn.forumdelete");
  }
View Full Code Here

    SubscriptionContext forumSubContext = CourseModule.createTechnicalSubscriptionContext(course.getCourseEnvironment(), this);
    NotificationsManager.getInstance().delete(forumSubContext);

    // delete the forum, if there is one (is created on demand only)
    CoursePropertyManager cpm = PersistingCoursePropertyManager.getInstance(course);
    Property forumKeyProperty = cpm.findCourseNodeProperty(this, null, null, FORUM_KEY);
    if (forumKeyProperty == null) return; // no forum created yet
    Long forumKey = forumKeyProperty.getLongValue();
    ForumManager.getInstance().deleteForum(forumKey); // delete the forum
    cpm.deleteProperty(forumKeyProperty); // delete the property
  }
View Full Code Here

  /**
   * @see org.olat.user.UserManager#setUserCharset(org.olat.core.id.Identity, java.lang.String)
   */
  public void setUserCharset(Identity identity, String charset){
      PropertyManager pm = PropertyManager.getInstance();
      Property p = pm.findProperty(identity, null, null, null, CHARSET);
     
      if(p != null){
          p.setStringValue(charset);
          pm.updateProperty(p);
    } else {
          Property newP = pm.createUserPropertyInstance(identity, null, CHARSET, null, null, charset, null);
          pm.saveProperty(newP);
      }
  }
View Full Code Here

   */
  public String getUserCharset(Identity identity){
     String charset;
     charset = WebappHelper.getDefaultCharset();
     PropertyManager pm = PropertyManager.getInstance();
     Property p = pm.findProperty(identity, null, null, null, CHARSET);
     if(p != null){
         charset = p.getStringValue();
      // if after migration the system does not support the charset choosen by a
      // user
         // (a rather rare case)
         if(!Charset.isSupported(charset)){
             charset = WebappHelper.getDefaultCharset();
View Full Code Here

  /**
   * @see org.olat.course.properties.CoursePropertyManager#createCourseNodePropertyInstance(org.olat.course.nodes.CourseNode, org.olat.core.id.Identity, org.olat.group.BusinessGroup, java.lang.String, java.lang.Float, java.lang.Long, java.lang.String, java.lang.String)
   */
  public Property createCourseNodePropertyInstance(CourseNode node, Identity identity, BusinessGroup group, String name, Float floatValue,
      Long longValue, String stringValue, String textValue) {
    Property p = PropertyManager.getInstance().createProperty();
    p.setCategory(buildCourseNodePropertyCategory(node));
    p.setIdentity(identity);
    p.setGrp(null);
    p.setName(name);
    p.setLongValue(longValue);
    p.setFloatValue(floatValue);
    p.setStringValue(stringValue);
    p.setTextValue(textValue);
    return p;
  }
View Full Code Here

   * @see org.olat.course.properties.CoursePropertyManager#deleteProperty(org.olat.properties.Property)
   */
  public void deleteProperty(Property p) {
    List propertyList = getListOfProperties(p);
    for (int i=0; i < propertyList.size(); i++) {
      Property propertyElement = (Property)propertyList.get(i);
      if (propertyElement.getLongValue().equals(p.getLongValue())
          && propertyElement.getFloatValue().equals(p.getFloatValue())
          && propertyElement.getStringValue().equals(p.getStringValue())
          && propertyElement.getTextValue().equals(p.getTextValue())) {
        propertyList.remove(i);
        break;
      }
    }
  }
View Full Code Here

* setting mechanism, see method below
* @param tokenPropertyName
*/
  private void initializeSystemTokenProperty(String tokenPropertyName) {
    PropertyManager pm = PropertyManager.getInstance();
    Property p = pm.findProperty(null, null, null, SYSTEM_PROPERTY_CATEGORY, tokenPropertyName);
    if (p == null) {
      String token = RandomStringUtils.randomAlphanumeric(8);
      p = pm.createPropertyInstance(null, null, null, SYSTEM_PROPERTY_CATEGORY, tokenPropertyName, null, null, token, null);
      pm.saveProperty(p);
    }
View Full Code Here

TOP

Related Classes of org.olat.properties.Property

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.