Package org.olat.properties

Examples of org.olat.properties.Property


  public Quota getCustomQuota(String path) {
    if (defaultQuotas == null) {
      throw new OLATRuntimeException(QuotaManagerImpl.class, "Quota manager has not been initialized properly! Must call init() first.", null);
    }
    PropertyManager pm = PropertyManager.getInstance();
    Property p = pm.findProperty(null, null, quotaResource, QUOTA_CATEGORY, path);
    if (p == null) return null;
    else return parseQuota(p);
  }
View Full Code Here


  public void setCustomQuotaKB(Quota quota) {
    if (defaultQuotas == null) {
      throw new OLATRuntimeException(QuotaManagerImpl.class, "Quota manager has not been initialized properly! Must call init() first.", null);
    }
    PropertyManager pm = PropertyManager.getInstance();
    Property p = pm.findProperty(null, null, quotaResource, QUOTA_CATEGORY, quota.getPath());
    if (p == null) { // create new entry
      p = pm.createPropertyInstance(null, null, quotaResource, QUOTA_CATEGORY, quota.getPath(), null, null, assembleQuota(quota), null);
      pm.saveProperty(p);
    } else {
      p.setStringValue(assembleQuota(quota));
      pm.updateProperty(p);
    }
    // if the quota is a default quota, rebuild the default quota list
    if (quota.getPath().startsWith(QuotaConstants.IDENTIFIER_DEFAULT)) {
      initDefaultQuotas();
View Full Code Here

    // do not allow to delete default quotas!
    if (quota.getPath().startsWith(QuotaConstants.IDENTIFIER_DEFAULT)) {
      return false;
    }
    PropertyManager pm = PropertyManager.getInstance();
    Property p = pm.findProperty(null, null, quotaResource, QUOTA_CATEGORY, quota.getPath());
    if (p != null) pm.deleteProperty(p);
    return true;
  }
View Full Code Here

    List results = new ArrayList();
    PropertyManager pm = PropertyManager.getInstance();
    List props = pm.listProperties(null, null, quotaResource, QUOTA_CATEGORY, null);
    if (props == null || props.size() == 0) return results;
    for (Iterator iter = props.iterator(); iter.hasNext();) {
      Property prop = (Property) iter.next();
      results.add(parseQuota(prop));
    }
    return results;
  }
View Full Code Here

    //if (node == null) return new Double(Double.NEGATIVE_INFINITY);

    CoursePropertyManager pm = getUserCourseEnv().getCourseEnvironment().getCoursePropertyManager();
    Identity identity = getUserCourseEnv().getIdentityEnvironment().getIdentity();
   
    Property recentTime = pm.findCourseNodeProperty(node,
        identity, null, ENCourseNode.PROPERTY_RECENT_ENROLLMENT_DATE);

    if (recentTime != null) {
      String firstTimeMillis = recentTime.getStringValue();
      return Double.valueOf(firstTimeMillis);
    }
    else {
      // what to do in case of no date available??? -> return date in the future
      return new Double(Double.POSITIVE_INFINITY);
View Full Code Here

  /**
   * @see org.olat.core.gui.components.table.TableDataModel#getValueAt(int, int)
   */
  public final Object getValueAt(int row, int col) {
    Property p = (Property) getObject(row);
    switch (col) {
      case 0 :
        String cat = p.getCategory();
        return (cat == null ? "n/a" : cat);
      case 1 :
        BusinessGroup grp = p.getGrp();
        return (grp == null ? "n/a" : grp.getKey().toString());
      case 2 :
        String resType = p.getResourceTypeName();
        return (resType == null ? "n/a" : resType);
      case 3 :
        String name = p.getName();
        return (name == null ? "n/a" : name);
      case 4 :
        Float floatvalue = p.getFloatValue();
        Long longvalue = p.getLongValue();
        String stringvalue = p.getStringValue();
        String textvalue = p.getTextValue();
        String val;
        if (floatvalue != null)
          val = floatvalue.toString();
        else if (longvalue != null)
          val = longvalue.toString();
        else if (stringvalue != null)
          val = stringvalue;
        else if (textvalue != null)
          val = textvalue;
        else val = "n/a";
        return val;
      case 5 :
        Date dateCD = p.getCreationDate();
        return (dateCD == null ? new Date() : dateCD);
      case 6 :
        Date dateLM = p.getLastModified();
        return (dateLM == null ? new Date() : dateLM);
      default :
        return "error";
    }
  }
View Full Code Here

        // or has been invalidated (in cluster mode when puts occurred from an other node for the same cache)
        m = new HashMap<String, Serializable>();
        // load data
        List properties = loadPropertiesFor(identity);
        for (Iterator iter = properties.iterator(); iter.hasNext();) {
          Property property = (Property) iter.next();
          addPropertyToCache(m, property);
        }
        // we use a putSilent here (no invalidation notifications to other cluster nodes), since
        // we did not generate new data, but simply asked to reload it.
        if (prepareForNewData) {
View Full Code Here

   * @param coursePropManager
   */
  void saveNodeScore(CourseNode courseNode, Identity identity, Identity assessedIdentity, Float score, CoursePropertyManager coursePropManager) {
    // olat:::: introduce a createOrUpdate method in the cpm and also if applicable in the general propertymanager
    if (score != null) {
      Property scoreProperty = coursePropManager.findCourseNodeProperty(courseNode, assessedIdentity, null, SCORE);
      if (scoreProperty == null) {
        scoreProperty = coursePropManager.createCourseNodePropertyInstance(courseNode, assessedIdentity, null, SCORE, score, null, null, null);
        coursePropManager.saveProperty(scoreProperty);
      } else {
        scoreProperty.setFloatValue(score);
        coursePropManager.updateProperty(scoreProperty);
      }
      // add to cache
      putPropertyIntoCache(assessedIdentity, scoreProperty);
    }
View Full Code Here

    // But it seems like this mechanism is a bit unobvious and might well be worth some refactoring...
    ICourse course = CourseFactory.loadCourse(ores);
    final CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
    CoordinatorManager.getCoordinator().getSyncer().doInSync(createOLATResourceableForLocking(assessedIdentity), new SyncerExecutor(){
      public void execute() {
        Property attemptsProperty = cpm.findCourseNodeProperty(courseNode, assessedIdentity, null, ATTEMPTS);
        if (attemptsProperty == null) {
          attemptsProperty = cpm.createCourseNodePropertyInstance(courseNode, assessedIdentity, null, ATTEMPTS,
              null, new Long(attempts.intValue()), null, null);
          cpm.saveProperty(attemptsProperty);
        } else {
          attemptsProperty.setLongValue(new Long(attempts.intValue()));
          cpm.updateProperty(attemptsProperty);
        }
        // add to cache
        putPropertyIntoCache(assessedIdentity, attemptsProperty);
      }
View Full Code Here

   * @param assessedIdentity
   * @param passed
   * @param coursePropManager
   */
  void saveNodePassed(CourseNode courseNode, Identity identity, Identity assessedIdentity, Boolean passed, CoursePropertyManager coursePropManager) {   
      Property passedProperty = coursePropManager.findCourseNodeProperty(courseNode, assessedIdentity, null, PASSED);
      if (passedProperty == null && passed!=null) {         
        String pass = passed.toString();
        passedProperty = coursePropManager.createCourseNodePropertyInstance(courseNode, assessedIdentity, null, PASSED, null, null, pass, null);
        coursePropManager.saveProperty(passedProperty);          
      } else if (passedProperty!=null){
        if (passed!=null) {
        passedProperty.setStringValue(passed.toString());
        coursePropManager.updateProperty(passedProperty);
        } else {
          removePropertyFromCache(assessedIdentity,passedProperty);
          coursePropManager.deleteProperty(passedProperty);
        }
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.