Package org.pentaho.platform.api.repository

Examples of org.pentaho.platform.api.repository.IRuntimeRepository


  }

  private IRuntimeElement createChild( boolean persisted ) {
    IRuntimeElement childRuntimeData = null;
    IRuntimeRepository runtimeRepository = PentahoSystem.get( IRuntimeRepository.class, session );
    // the runtime repository is optional
    if ( runtimeRepository != null ) {
      runtimeRepository.setLoggingLevel( loggingLevel );
      childRuntimeData = runtimeRepository.newRuntimeElement( instanceId, "instance", !persisted ); //$NON-NLS-1$
      String childInstanceId = childRuntimeData.getInstanceId();
      // audit the creation of this against the parent instance
      AuditHelper.audit( instanceId, session.getName(), getActionName(), getObjectName(), processId,
          MessageTypes.INSTANCE_START, childInstanceId, "", 0, this ); //$NON-NLS-1$
    }
View Full Code Here


    // The simple runtime is used by the standalone distribution.
    // This provides some simple tests to exercise the code...
    startTest();
    StandaloneSession session =
        new StandaloneSession( Messages.getInstance().getString( "BaseTest.DEBUG_JUNIT_SESSION" ) ); //$NON-NLS-1$
    IRuntimeRepository srr = new SimpleRuntimeRepository();
    srr.setSession( session );
    IRuntimeElement ele1 = srr.loadElementById( "instanceid", null ); //$NON-NLS-1$
    IRuntimeElement ele2 = srr.newRuntimeElement( "parent", "parentType", true ); //$NON-NLS-1$ //$NON-NLS-2$
    IRuntimeElement ele3 = srr.newRuntimeElement( "parentid", "parentType", "solutionId", true ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    SimpleRuntimeElement sre = (SimpleRuntimeElement) srr.loadElementById( "instanceid", null ); //$NON-NLS-1$
    List list = sre.getMessages();
    if ( list != null ) {
      for ( int i = 0; i < list.size(); i++ ) {
        System.out.println( "Message " + ( i + 1 ) + list.get( i ) ); //$NON-NLS-1$
      }

      sre.setParentId( "parentid1" ); //$NON-NLS-1$
      sre.setParentType( "parentidType1" ); //$NON-NLS-1$
      sre.setSolutionId( "solutionId1" ); //$NON-NLS-1$
      sre.setReadOnly( true );
      boolean isReadOnly = sre.getReadOnly();
      String parentId = sre.getParentId();
      String parentIdType = sre.getParentType();
      String solutionId = sre.getSolutionId();
      assertEquals( isReadOnly, true );
      assertEquals( parentId, "parentid1" ); //$NON-NLS-1$
      assertEquals( parentIdType, "parentidType1" ); //$NON-NLS-1$
      assertEquals( solutionId, "solutionId1" ); //$NON-NLS-1$
    }
    int revision = sre.getRevision();
    System.out.println( "Revision Value is" + revision ); //$NON-NLS-1$
    sre.setStringProperty( "parentId", "value" ); //$NON-NLS-1$ //$NON-NLS-2$
    BigDecimal tstBD = new BigDecimal( "2.4" ); //$NON-NLS-1$
    ele2.setBigDecimalProperty( "junkBD", tstBD ); //$NON-NLS-1$
    BigDecimal bd = ele2.getBigDecimalProperty( "junkBD" ); //$NON-NLS-1$
    assertEquals( bd, tstBD );
    Date tstDT = new Date();
    ele3.setDateProperty( "junkDT", tstDT ); //$NON-NLS-1$
    Date dt = ele3.getDateProperty( "junkDT" ); //$NON-NLS-1$
    assertEquals( tstDT, dt );
    List l = new ArrayList();
    l.add( "one" ); //$NON-NLS-1$
    l.add( "two" ); //$NON-NLS-1$
    ele1.setListProperty( "SOMELIST", l ); //$NON-NLS-1$
    assertEquals( ele1.getListProperty( "SOMELIST" ), l ); //$NON-NLS-1$
    Long aLong = new Long( 5 );
    ele2.setLongProperty( "SOMELONG", aLong ); //$NON-NLS-1$
    assertEquals( ele2.getLongProperty( "SOMELONG", null ), aLong ); //$NON-NLS-1$
    assertEquals( ele2.getLongProperty( "SOMELONG", 5 ), 5 ); //$NON-NLS-1$
    Map mapProperty = new HashMap();
    mapProperty.put( "mapKey", "mapValue" ); //$NON-NLS-1$ //$NON-NLS-2$
    ele3.setMapProperty( "SOMEMAP", mapProperty ); //$NON-NLS-1$
    assertEquals( ele3.getMapProperty( "SOMEMAP" ), mapProperty ); //$NON-NLS-1$
    ele1.setStringProperty( "SOMESTRING", "SomeStringValue" ); //$NON-NLS-1$ //$NON-NLS-2$
    assertEquals( ele1.getStringProperty( "SOMESTRING" ), "SomeStringValue" ); //$NON-NLS-1$ //$NON-NLS-2$
    assertEquals( ele2.getStringProperty( "DOESNTEXIST", "SomeDefault" ), "SomeDefault" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    assertNull( ele1.getStringProperty( "DOESNTEXIST" ) ); //$NON-NLS-1$   
    assertNull( ele1.getBigDecimalProperty( "DOESNTEXIST" ) ); //$NON-NLS-1$
    assertNull( ele2.getDateProperty( "DOESNTEXIST" ) ); //$NON-NLS-1$
    assertNull( ele3.getListProperty( "DOESNTEXIST" ) ); //$NON-NLS-1$
    assertEquals( ele2.getLongProperty( "DOESNTEXIST", 2 ), 2 ); //$NON-NLS-1$
    assertEquals( ele2.getLongProperty( "DOESNTEXIST", new Long( 2 ) ), new Long( 2 ) ); //$NON-NLS-1$
    assertEquals( ele1.getBigDecimalProperty( "DOESNTEXIST", new BigDecimal( "0.23" ) ), new BigDecimal( "0.23" ) ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    Date tmpDate = new Date();
    assertEquals( ele1.getDateProperty( "DOESNTEXIST", tmpDate ), tmpDate ); //$NON-NLS-1$
    Set parmNames = ele1.getParameterNames();
    assertNotNull( parmNames );

    assertFalse( srr.usesHibernate() );

    assertEquals( ele2.getParameterType( "SOMELONG" ), "java.lang.Long" ); //$NON-NLS-1$ //$NON-NLS-2$
    assertEquals( ele2.getParentType(), "parentType" ); //$NON-NLS-1$
    assertEquals( ele3.getParentId(), "parentid" ); //$NON-NLS-1$
    assertEquals( ele1.getInstanceId(), "instanceid" ); //$NON-NLS-1$
View Full Code Here

    // create the runtime context object for this operation
    if ( debug ) {
      debug( Messages.getInstance().getString( "SolutionEngine.DEBUG_GETTING_RUNTIME_CONTEXT" ) ); //$NON-NLS-1$
    }
    boolean newInstance = instanceId == null;
    IRuntimeRepository runtimeRepository = null;
    if ( PentahoSystem.getObjectFactory().objectDefined( IRuntimeRepository.class.getSimpleName() ) ) {
      runtimeRepository = PentahoSystem.get( IRuntimeRepository.class, session );
    }

    IRuntimeElement runtimeData;
    if ( runtimeRepository == null ) {
      String id = UUIDUtil.getUUIDAsString();
      runtimeData = new SimpleRuntimeElement( id, session.getId(), IParameterProvider.SCOPE_SESSION );
    } else {
      runtimeRepository.setLoggingLevel( loggingLevel );
      if ( newInstance ) {
        // we need to create runtime data for this execution
        try {
          runtimeData =
              runtimeRepository.newRuntimeElement( session.getId(), IParameterProvider.SCOPE_SESSION, !persisted );
        } catch ( Throwable t ) {
          error( Messages.getInstance().getErrorString( "SolutionEngine.ERROR_0008_INVALID_INSTANCE", instanceId ), t ); //$NON-NLS-1$
          status = IRuntimeContext.RUNTIME_STATUS_SETUP_FAIL;
          return null;
        }
      } else {
        try {
          runtimeData = runtimeRepository.loadElementById( instanceId, null );
        } catch ( Throwable t ) {
          error( Messages.getInstance().getErrorString( "SolutionEngine.ERROR_0008_INVALID_INSTANCE", instanceId ), t ); //$NON-NLS-1$
          status = IRuntimeContext.RUNTIME_STATUS_SETUP_FAIL;
          return null;
        }
View Full Code Here

  @SuppressWarnings( "unused" )
  private void doReadOnlyTest( String elementId ) {
    info( Messages.getInstance().getString( "RUNTIMEREPOTEST.USER_TESTINGREADONLY" ) ); //$NON-NLS-1$
    HibernateUtil.beginTransaction();
    try {
      IRuntimeRepository repo = new RuntimeRepository();
      repo.setSession( getPentahoSession() );
      RuntimeElement baseElement = (RuntimeElement) repo.loadElementById( elementId, null );
      info( Messages.getInstance().getString( "RUNTIMEREPOTEST.USER_SETTINGELEMENTTOREADONLY" ) ); //$NON-NLS-1$
      baseElement.setReadOnly( true );
    } finally {
      HibernateUtil.commitTransaction();
    }
    // Now, the element is read-only.
    // Flush the session and re-load the element to
    // test the "loaded" methods.
    HibernateUtil.flushSession();
    HibernateUtil.clear();
    // Now, reload the element.
    HibernateUtil.beginTransaction();
    try {
      info( Messages.getInstance().getString( "RUNTIMEREPOTEST.USER_LOADINGREADONLY" ) ); //$NON-NLS-1$
      IRuntimeRepository repo = new RuntimeRepository();
      repo.setSession( getPentahoSession() );
      RuntimeElement baseElement = (RuntimeElement) repo.loadElementById( elementId, null );
      boolean caughtException = false;
      try {
        info( Messages.getInstance().getString( "RUNTIMEREPOTEST.USER_TRYINGSETSTRINGPROPERTY" ) ); //$NON-NLS-1$
        baseElement
            .setStringProperty(
View Full Code Here

  }

  @SuppressWarnings( "unused" )
  private void cleanupElement( String elementId ) {
    HibernateUtil.beginTransaction();
    IRuntimeRepository repo = new RuntimeRepository();
    repo.setSession( getPentahoSession() );
    RuntimeElement re = (RuntimeElement) repo.loadElementById( elementId, null );
    HibernateUtil.makeTransient( re );
    HibernateUtil.commitTransaction();
    HibernateUtil.flushSession();
    HibernateUtil.clear();
  }
View Full Code Here

  @SuppressWarnings( "unused" )
  private void modifyAdd( RuntimeElement baseElement ) {
    HibernateUtil.beginTransaction();
    try {
      IRuntimeRepository repo = new RuntimeRepository();
      repo.setSession( getPentahoSession() );
      baseElement
          .setStringProperty(
              Messages.getInstance().getString( "RUNTIMEREPOTEST.MODIFY_NEW_STRING_KEY" ), Messages.getInstance().getString( "RUNTIMEREPOTEST.MODIFY_STRING_VALUE" ) ); //$NON-NLS-1$ //$NON-NLS-2$
    } finally {
      HibernateUtil.commitTransaction();
View Full Code Here

    }
  }

  @SuppressWarnings( "unused" )
  private RuntimeElement createRuntimeElement() {
    IRuntimeRepository repo = new RuntimeRepository();
    repo.setSession( getPentahoSession() );
    RuntimeElement ele = null;
    ele =
        (RuntimeElement) repo
            .newRuntimeElement(
                Messages.getInstance().getString( "RUNTIMEREPOTEST.CREATE_PARENT" ), Messages.getInstance().getString( "RUNTIMEREPOTEST.CREATE_PARENT_TYPE" ), false ); //$NON-NLS-1$ //$NON-NLS-2$
    try {
      assertNotNull( ele );
      info( Messages.getInstance().getString( "RUNTIMEREPOTEST.DEBUG_INSTANCE_ID" ) + ele.getInstanceId() ); //$NON-NLS-1$
View Full Code Here

  }

  @SuppressWarnings( "unused" )
  private void readElementTest( String instanceId ) {
    HibernateUtil.beginTransaction();
    IRuntimeRepository repo = new RuntimeRepository();
    repo.setSession( getPentahoSession() );
    RuntimeElement re = (RuntimeElement) repo.loadElementById( instanceId, null );
    checkValue( Messages.getInstance().getString( "RUNTIMEREPOTEST.SALES_SOLUTION" ), re.getSolutionId() ); //$NON-NLS-1$
    checkValue( longString.toString(), re.getStringProperty( Messages.getInstance().getString(
        "RUNTIMEREPOTEST.LONG_STRING_KEY" ) ) ); //$NON-NLS-1$
    checkValue(
        Messages.getInstance().getString( "RUNTIMEREPOTEST.SHORT_STRING_VALUE" ), re.getStringProperty( Messages.getInstance().getString( "RUNTIMEREPOTEST.SHORT_STRING_KEY" ) ) ); //$NON-NLS-1$ //$NON-NLS-2$
View Full Code Here

TOP

Related Classes of org.pentaho.platform.api.repository.IRuntimeRepository

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.