Package org.pentaho.platform.api.repository2.unified.data.node

Examples of org.pentaho.platform.api.repository2.unified.data.node.DataNode


    NodeRepositoryFileData data = new NodeRepositoryFileData( node );
    return data;
  }

  protected DataNode toDataNode( final DataNodeDto nodeDto ) {
    DataNode node = new DataNode( nodeDto.name );
    node.setId( nodeDto.id );

    for ( DataPropertyDto dtoProp : nodeDto.childProperties ) {
      if ( dtoProp.type == DataPropertyType.BOOLEAN.ordinal() ) {
        node.setProperty( dtoProp.name, Boolean.parseBoolean( dtoProp.value ) );
      } else if ( dtoProp.type == DataPropertyType.DATE.ordinal() ) {
        node.setProperty( dtoProp.name, new Date( Long.parseLong( dtoProp.value ) ) );
      } else if ( dtoProp.type == DataPropertyType.DOUBLE.ordinal() ) {
        node.setProperty( dtoProp.name, Double.parseDouble( dtoProp.value ) );
      } else if ( dtoProp.type == DataPropertyType.LONG.ordinal() ) {
        node.setProperty( dtoProp.name, Long.parseLong( dtoProp.value ) );
      } else if ( dtoProp.type == DataPropertyType.STRING.ordinal() ) {
        node.setProperty( dtoProp.name, dtoProp.value );
      } else if ( dtoProp.type == DataPropertyType.REF.ordinal() ) {
        node.setProperty( dtoProp.name, new DataNodeRef( dtoProp.value ) );
      } else {
        throw new IllegalArgumentException();
      }
    }

    for ( DataNodeDto childNodeDto : nodeDto.childNodes ) {
      node.addNode( toDataNode( childNodeDto ) );
    }

    return node;
  }
View Full Code Here


        new RepositoryFile.Builder( fileId, EXP_DBMETA_NAME + dotKdb ).path(
            databasesFolderPath + RepositoryFile.SEPARATOR + EXP_DBMETA_NAME + dotKdb ).build();
    doReturn( f ).when( repo ).getFile( databasesFolderPath + RepositoryFile.SEPARATOR + EXP_DBMETA_NAME + dotKdb );

    final String EXP_HOST_NAME = "hello";
    DataNode rootNode = new DataNode( "databaseMeta" );
    rootNode.setProperty( "TYPE", "Hypersonic" ); // required
    rootNode.setProperty( "HOST_NAME", EXP_HOST_NAME );
    rootNode.addNode( "attributes" ); // required
    doReturn( new NodeRepositoryFileData( rootNode ) ).when( repo ).getDataForRead( eq( fileId ),
        eq( NodeRepositoryFileData.class ) );

    IDatasourceMgmtService datasourceMgmtService =
        new JcrBackedDatasourceMgmtService( repo, new DatabaseDialectService() );
View Full Code Here

    final String prefix = session.getNamespacePrefix( PentahoJcrConstants.PHO_NS ) + ":"; //$NON-NLS-1$
    final String pattern = prefix + "*"; //$NON-NLS-1$

    String nodeName = JcrStringHelper.fileNameDecode( jcrNode.getName().substring( prefix.length() ) );

    DataNode dataNode = parentDataNode != null ? parentDataNode.addNode( nodeName ) : new DataNode( nodeName );
    dataNode.setId( jcrNode.getIdentifier() );

    PropertyIterator props = jcrNode.getProperties( pattern );
    while ( props.hasNext() ) {
      Property prop = props.nextProperty();
      String propName = JcrStringHelper.fileNameDecode( prop.getName().substring( prefix.length() ) );
      switch ( prop.getType() ) {
        case PropertyType.STRING: {
          dataNode.setProperty( propName, prop.getString() );
          break;
        }
        case PropertyType.BOOLEAN: {
          dataNode.setProperty( propName, prop.getBoolean() );
          break;
        }
        case PropertyType.DOUBLE: {
          dataNode.setProperty( propName, prop.getDouble() );
          break;
        }
        case PropertyType.LONG: {
          dataNode.setProperty( propName, prop.getLong() );
          break;
        }
        case PropertyType.DATE: {
          dataNode.setProperty( propName, prop.getDate().getTime() );
          break;
        }
        case PropertyType.REFERENCE: {
          try {
            dataNode.setProperty( propName, new DataNodeRef( prop.getNode().getIdentifier() ) );
          } catch ( ItemNotFoundException e ) {
            // reference is missing, replace with missing data ref
            // this situation can occur if the user does not have permission to access the reference.
            dataNode.setProperty( propName, new DataNodeRef( DataNodeRef.REF_MISSING ) );
          }
          break;
        }
        default: {
          throw new IllegalArgumentException();
View Full Code Here

          return null;
        }
      }
    }
    // Assert.notNull(content);
    DataNode emptyDataNode = new DataNode( file.getName() );
    emptyDataNode.setProperty( " ", "content" ); //$NON-NLS-1$ //$NON-NLS-2$
    final IRepositoryFileData emptyContent = new NodeRepositoryFileData( emptyDataNode );

    return (RepositoryFile) jcrTemplate.execute( new JcrCallback() {
      @Override
      public Object doInJcr( final Session session ) throws RepositoryException, IOException {
View Full Code Here

  private void process( final FileRecord r, final IRepositoryFileData oldData ) {
    IRepositoryFileData data = r.getData();
    if ( data instanceof SimpleRepositoryFileData ) {
      r.setData( new ReusableSimpleRepositoryFileData( (SimpleRepositoryFileData) data ) );
    } else if ( data instanceof NodeRepositoryFileData ) {
      DataNode node = ( (NodeRepositoryFileData) data ).getNode();
      referralManager.process( r.getFile().getId(), oldData != null ? ( (NodeRepositoryFileData) oldData ).getNode()
          : null, node );
      r.setData( new NodeRepositoryFileData( idManager.process( node ) ) );
    }
  }
View Full Code Here

      } catch ( IOException e ) {
        // Don't care. Just cleaning up.
      }
    }

    final DataNode node = new DataNode( "server" );
    node.setProperty( "name", name );
    node.setProperty( "className", className );
    node.setProperty( "URL", URL );
    node.setProperty( "user", user );
    node.setProperty( "password", password );
    node.setProperty( "properties", xmlProperties );
    NodeRepositoryFileData data = new NodeRepositoryFileData( node );

    final RepositoryFile metadata = repository.getFile( path );

    if ( metadata == null ) {
View Full Code Here

    final String path =
        ETC_MONDRIAN_JCR_FOLDER + RepositoryFile.SEPARATOR + catalog.getName() + RepositoryFile.SEPARATOR + "metadata";
    RepositoryFile metadata = repository.getFile( path );

    String definition = "mondrian:/" + catalog.getName();
    DataNode node = new DataNode( "catalog" );
    node.setProperty( "definition", encodeUrl( definition ) );
    node.setProperty( "datasourceInfo", datasourceInfo );
    NodeRepositoryFileData data = new NodeRepositoryFileData( node );

    if ( metadata == null ) {
      repository.createFile( catalog.getId(), new RepositoryFile.Builder( "metadata" ).build(), data, null );
    } else {
View Full Code Here

  public DatabaseHelper( IDatabaseDialectService databaseDialectService ) {
    this.databaseTypeHelper = new DatabaseTypeHelper( databaseDialectService.getDatabaseTypes() );
  }

  public DataNode databaseConnectionToDataNode( final IDatabaseConnection databaseConnection ) {
    DataNode rootNode = new DataNode( NODE_ROOT );

    // Then the basic db information
    if ( databaseConnection.getDatabaseType() != null ) {
      rootNode.setProperty( PROP_TYPE, databaseConnection.getDatabaseType().getShortName() );
    }
    String port =
        ( "".equals( setNull( databaseConnection.getDatabasePort() ) ) ) ? "0" : databaseConnection.getDatabasePort();
    rootNode.setProperty( PROP_CONTYPE, setNull( databaseConnection.getAccessType().getName() ) );
    rootNode.setProperty( PROP_HOST_NAME, setNull( databaseConnection.getHostname() ) );
    rootNode.setProperty( PROP_DATABASE_NAME, setNull( databaseConnection.getDatabaseName() ) );
    rootNode.setProperty( PROP_PORT, new Long( port ) );
    rootNode.setProperty( PROP_USERNAME, setNull( databaseConnection.getUsername() ) );
    rootNode.setProperty( PROP_PASSWORD, Encr.encryptPasswordIfNotUsingVariables(databaseConnection.getPassword()));
    rootNode.setProperty( PROP_SERVERNAME, setNull( databaseConnection.getInformixServername() ) );
    rootNode.setProperty( PROP_DATA_TBS, setNull( databaseConnection.getDataTablespace() ) );
    rootNode.setProperty( PROP_INDEX_TBS, setNull( databaseConnection.getIndexTablespace() ) );
    rootNode.setProperty( PROP_CONNECT_SQL, setNull( databaseConnection.getConnectSql() ) );
    rootNode.setProperty( PROP_INITIAL_POOL_SIZE, databaseConnection.getInitialPoolSize() );
    rootNode.setProperty( PROP_MAX_POOL_SIZE, databaseConnection.getMaximumPoolSize() );
    rootNode.setProperty( PROP_IS_POOLING, databaseConnection.isUsingConnectionPool() );
    rootNode.setProperty( PROP_IS_FORCING_TO_LOWER, databaseConnection.isForcingIdentifiersToLowerCase() );
    rootNode.setProperty( PROP_IS_FORCING_TO_UPPER, databaseConnection.isForcingIdentifiersToUpperCase() );
    rootNode.setProperty( PROP_IS_QUOTE_FIELDS, databaseConnection.isQuoteAllFields() );
    rootNode.setProperty( PROP_IS_DECIMAL_SEPERATOR, databaseConnection.isUsingDoubleDecimalAsSchemaTableSeparator() );

    // Now store all the attributes set on the database connection...
    DataNode attrNode = rootNode.addNode( NODE_ATTRIBUTES );
    Map<String, String> attributes = databaseConnection.getAttributes();
    Set<String> keys = attributes.keySet();
    for ( String key : keys ) {
      String value = attributes.get( key );
      attrNode.setProperty( key, value );
    }
   
    attrNode.setProperty(ATTRIBUTE_PORT_NUMBER, new Long(port).longValue());

    // Now store the pooling parameters
    attrNode = rootNode.addNode( NODE_POOLING_PROPS );
    attributes = databaseConnection.getConnectionPoolingProperties();
    keys = attributes.keySet();
    for ( String key : keys ) {
      String value = attributes.get( key );
      attrNode.setProperty( key, value );
    }

    // Store the extra options
    attrNode = rootNode.addNode( NODE_EXTRA_OPTIONS );
    attributes = databaseConnection.getExtraOptions();
    for ( String key : attributes.keySet() ) {
      String value = attributes.get( key );
      attrNode.setProperty( key, value );
    }
    return rootNode;
  }
View Full Code Here

    databaseConnection.setForcingIdentifiersToUpperCase( getBoolean( rootNode, PROP_IS_FORCING_TO_UPPER ) );
    databaseConnection.setQuoteAllFields( getBoolean( rootNode, PROP_IS_QUOTE_FIELDS ) );
    databaseConnection.setUsingDoubleDecimalAsSchemaTableSeparator( getBoolean( rootNode, PROP_IS_DECIMAL_SEPERATOR ) );

    // Also, load all the properties we can find...
    DataNode attrNode = rootNode.getNode( NODE_ATTRIBUTES );
    if ( attrNode != null ) {
      for ( DataProperty property : attrNode.getProperties() ) {
        String code = property.getName();
        String attribute = property.getString();
        databaseConnection.getAttributes()
            .put( code, ( attribute == null || attribute.length() == 0 ) ? "" : attribute ); //$NON-NLS-1$
      }
    }

    // Also, load any pooling params
    attrNode = rootNode.getNode( NODE_POOLING_PROPS );
    if ( attrNode != null ) {
      for ( DataProperty property : attrNode.getProperties() ) {
        String code = property.getName();
        String attribute = property.getString();
        databaseConnection.getConnectionPoolingProperties().put( code,
            ( attribute == null || attribute.length() == 0 ) ? "" : attribute ); //$NON-NLS-1$
      }
    }

    // Load extra options
    attrNode = rootNode.getNode( NODE_EXTRA_OPTIONS );
    if ( attrNode != null ) {
      for ( DataProperty property : attrNode.getProperties() ) {
        String code = property.getName();
        String attribute = property.getString();
        databaseConnection.getExtraOptions().put( code,
            ( attribute == null || attribute.length() == 0 ) ? "" : attribute ); //$NON-NLS-1$
      }
View Full Code Here

   * {@code NodeRepositoryFileData} .
   */
  public static void stubGetData( final IUnifiedRepository repo, final String path, final String rootNodeName,
      final PathPropertyPair... pairs ) {
    final String prefix = RepositoryFile.SEPARATOR + rootNodeName;
    DataNode rootNode = new DataNode( rootNodeName );
    for ( PathPropertyPair pair : pairs ) {
      if ( !pair.getPath().startsWith( prefix ) ) {
        throw new IllegalArgumentException( "all paths must have a common prefix" );
      }
      String[] pathSegments = pair.getPath().substring( prefix.length() + 1 ).split( "/" );
View Full Code Here

TOP

Related Classes of org.pentaho.platform.api.repository2.unified.data.node.DataNode

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.