Package org.olat.properties

Examples of org.olat.properties.Property


   *
   * @param courseId
   * @param courseNodeId
   */
  public void deleteProperty(Long courseId, String courseNodeId) {
    Property prop = findProperty(courseId, courseNodeId);
    PropertyManager propMrg = PropertyManager.getInstance();
    if (prop != null) propMrg.deleteProperty(prop);
  }
View Full Code Here


        prop.setStringValue(Boolean.TRUE.toString());
        pm.updateProperty(prop);
        return;
      }
    }
    Property prop = pm.createPropertyInstance(ureq.getIdentity(), null, null, PROPERTY_CAT, ctrlName, null, null, "true", null);
    pm.saveProperty(prop);
  }
View Full Code Here

                // let's quit quickly ;)
                return;
              }
              // load comic start date only once
              PropertyManager pm = PropertyManager.getInstance();
              Property p = pm.findProperty(null, null, null, PROPERTY_CATEGORY, PROPERTY_NAME);
              if (p == null) {
                // wow first time ever, save current date
                p = pm.createPropertyInstance(null, null, null, PROPERTY_CATEGORY, PROPERTY_NAME, null, null, null, null);
                pm.saveProperty(p);
              }
              comicStartDate = p.getCreationDate().getTime();
            }
           
          });
    }
View Full Code Here

    DB db = DBFactory.getInstance();
    String propertyKey = "testRollback-1";
    String testValue = "testRollback-1";
    try {
      PropertyManager pm = PropertyManager.getInstance();
      Property p1 = pm.createPropertyInstance(null, null, null, null, propertyKey, null, null, testValue, null);
      pm.saveProperty(p1);
      String propertyKey2 = "testRollback-2";
      String testValue2 = "testRollback-2";
      // name is null => generated DB error => rollback
      Property p2 = pm.createPropertyInstance(null, null, null, null, null, null, null, testValue2, null);
      pm.saveProperty(p2);
      fail("Should generate error for rollback.");
    } catch (Exception ex) {
      db.closeSession();
    }
    // check if p1 is rollbacked
    db = DBFactory.getInstance();
    PropertyManager pm = PropertyManager.getInstance();
    Property p =pm.findProperty(null, null, null, null, propertyKey);
    this.assertNull("Property.save is NOT rollbacked", p);
  }
View Full Code Here

    String propertyKey3 = "testMixed-3";
    String testValue3 = "testMixed-3";
    try {
      // outside of transaction
      PropertyManager pm = PropertyManager.getInstance();
      Property p1 = pm.createPropertyInstance(null, null, null, null, propertyKey1, null, null, testValue1, null);
      pm.saveProperty(p1);
      // inside of transaction
      Property p2 = pm.createPropertyInstance(null, null, null, null, propertyKey2, null, null, testValue2, null);
      pm.saveProperty(p2);
      // name is null => generated DB error => rollback
      Property p3 = pm.createPropertyInstance(null, null, null, null, null, null, null, testValue3, null);
      pm.saveProperty(p3);
      fail("Should generate error for rollback.");
      db.closeSession();
    } catch (Exception ex) {
      db.closeSession();
    }
    // check if p1&p2 is rollbacked
    PropertyManager pm = PropertyManager.getInstance();
    Property p_1 =pm.findProperty(null, null, null, null, propertyKey1);
    this.assertNull("Property1 is NOT rollbacked", p_1);
    Property p_2 =pm.findProperty(null, null, null, null, propertyKey2);
    this.assertNull("Property2 is NOT rollbacked", p_2);
  }
View Full Code Here

    String testValue2 = "testNonTransactional-2";
    String propertyKey3 = "testNonTransactional-3";
    String testValue3 = "testNonTransactional-3";
    try {
      PropertyManager pm = PropertyManager.getInstance();
      Property p1 = pm.createPropertyInstance(null, null, null, null, propertyKey1, null, null, testValue1, null);
      pm.saveProperty(p1);
      Property p2 = pm.createPropertyInstance(null, null, null, null, propertyKey2, null, null, testValue2, null);
      pm.saveProperty(p2);
      // name is null => generated DB error => rollback ?
      Property p3 = pm.createPropertyInstance(null, null, null, null, null, null, null, testValue3, null);
      pm.saveProperty(p3);
      fail("Should generate error for rollback.");
      db.closeSession();
    } catch (Exception ex) {
      db.closeSession();
    }
    // check if p1 & p2 is NOT rollbacked
    PropertyManager pm = PropertyManager.getInstance();
    Property p_1 =pm.findProperty(null, null, null, null, propertyKey1);
    this.assertNull("Property1 is NOT rollbacked", p_1);
    Property p_2 =pm.findProperty(null, null, null, null, propertyKey2);
    this.assertNull("Property2 is NOT rollbacked", p_2);
  }
View Full Code Here

      for (int loopCounter=0; loopCounter<loops; loopCounter++) {
        String propertyKey = "testDbPerfKey-" + loopCounter;
        DB db = DBFactory.getInstance();
        PropertyManager pm = PropertyManager.getInstance();
        String testValue = "testDbPerfValue-" + loopCounter;
        Property p = pm.createPropertyInstance(null, null, null, null, propertyKey, null, null, testValue, null);
        pm.saveProperty(p);
        // forget session cache etc.
        db.closeSession();
        pm.deleteProperty(p);
      }
      long endTime = System.currentTimeMillis();
      timeWithoutTransction = endTime - startTime;
      Tracing.logInfo("testDbPerf without transaction takes :" + timeWithoutTransction + "ms", this.getClass());
    } catch (Exception ex) {
      fail("Exception in testDbPerf without transaction ex="+ ex);
    }
   
    try {
      long startTime = System.currentTimeMillis();
      for (int loopCounter=0; loopCounter<loops; loopCounter++) { 
        String propertyKey = "testDbPerfKey-" + loopCounter;
        DB db = DBFactory.getInstance();
        PropertyManager pm = PropertyManager.getInstance();
        String testValue = "testDbPerfValue-" + loopCounter;
        Property p = pm.createPropertyInstance(null, null, null, null, propertyKey, null, null, testValue, null);
        pm.saveProperty(p);
        // forget session cache etc.
        db.closeSession();
        db = DBFactory.getInstance();
        pm.deleteProperty(p);
View Full Code Here

    //FIXME:fj: move this test to the db module
   
    DB db = DBFactory.getInstance();
    PropertyManager pm = PropertyManager.getInstance();
    String unicodetest = "a-greek a\u03E2a\u03EAa\u03E8 arab \u0630a\u0631 chinese:\u3150a\u3151a\u3152a\u3153a\u3173a\u3110-z";
    Property p = pm.createPropertyInstance(null, null, null, null, "superbluberkey", null, null, unicodetest, null);
    pm.saveProperty(p);
    // forget session cache etc.
    db.closeSession();
   
    Property p2 = pm.findProperty(null, null, null, null, "superbluberkey");
    String lStr = p2.getStringValue();
    assertEquals(unicodetest, lStr);
   
  }
View Full Code Here

   
  }

  public void testFindObject() {
    // 1. create a property to have an object 
    Property p = PropertyManager.getInstance().createPropertyInstance(null, null, null, null, "testFindObject", null, null, "testFindObject_Value", null);
    PropertyManager.getInstance().saveProperty(p);
    long propertyKey = p.getKey();
    // forget session cache etc.
    DBFactory.getInstance().closeSession();
    // 2. try to find object
    Object testObject = DBFactory.getInstance().findObject(Property.class, propertyKey);
    assertNotNull(testObject);
View Full Code Here

    PropertyManager pm = PropertyManager.getInstance();
    String derivedLockString = OresHelper.createStringRepresenting(ores, locksubkey);
    long aqTime;
    Identity lockOwner;
    boolean success;
    Property p;

    p = pm.findProperty(null, null, null, CATEGORY_PERSISTENTLOCK, derivedLockString);
    if (p == null) {
      // no persistent lock acquired yet
      // save a property: cat = o_lock, key = derivedLockString, Longvalue = key
      // of identity acquiring the lock
      Property newp = pm.createPropertyInstance(null, null, null, CATEGORY_PERSISTENTLOCK, derivedLockString, null, ident.getKey(), null,
          null);
      pm.saveProperty(newp);
      aqTime = System.currentTimeMillis();
      lockOwner = ident;
      success = true;
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.