Package org.pentaho.platform.api.repository

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


    }

  }

  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$
    }
    return childRuntimeData;
View Full Code Here


    return childRuntimeData;
  }

  public String createNewInstance( final boolean persisted ) {
    String childInstanceId = null;
    IRuntimeElement childRuntimeData = createChild( persisted );
    if ( childRuntimeData != null ) {
      childInstanceId = childRuntimeData.getInstanceId();
    }
    return childInstanceId;
  }
View Full Code Here

    return createNewInstance( persisted, parameters, false );
  }

  public String createNewInstance( final boolean persisted, final Map parameters, final boolean forceImmediateWrite ) {
    String childInstanceId = null;
    IRuntimeElement childRuntimeData = createChild( persisted );
    if ( childRuntimeData != null ) {

      if ( parameters != null ) {
        Iterator parameterIterator = parameters.keySet().iterator();
        while ( parameterIterator.hasNext() ) {
          String parameterName = (String) parameterIterator.next();
          Object parameterValue = parameters.get( parameterName );
          if ( parameterValue instanceof String ) {
            childRuntimeData.setStringProperty( parameterName, (String) parameterValue );
          } else if ( parameterValue instanceof BigDecimal ) {
            childRuntimeData.setBigDecimalProperty( parameterName, (BigDecimal) parameterValue );
          } else if ( parameterValue instanceof Date ) {
            childRuntimeData.setDateProperty( parameterName, (Date) parameterValue );
          } else if ( parameterValue instanceof List ) {
            childRuntimeData.setListProperty( parameterName, (List) parameterValue );
          } else if ( parameterValue instanceof Long ) {
            childRuntimeData.setLongProperty( parameterName, (Long) parameterValue );
          }
        }
      }
      childInstanceId = childRuntimeData.getInstanceId();
      if ( forceImmediateWrite ) {
        childRuntimeData.forceSave();
      }
    }
    return childInstanceId;
  }
View Full Code Here

    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$

    finishTest();
  }
View Full Code Here

      return true;
    }
    if ( !( other instanceof IRuntimeElement ) ) {
      return false;
    }
    final IRuntimeElement otherRE = (IRuntimeElement) other;
    return this.getInstanceId().equals( otherRE.getInstanceId() );
  }
View Full Code Here

    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 );
View Full Code Here

TOP

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

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.