Package org.pentaho.metadata.util

Examples of org.pentaho.metadata.util.XmiParser


    {
      final InputStream stream = createStream(resourceManager, contextKey, xmiFile);
      try
      {
        final InMemoryMetadataDomainRepository repo = new InMemoryMetadataDomainRepository();
        final XmiParser parser = new XmiParser();
        final Domain domain = parser.parseXmi(stream);
        domain.setId(domainId);
        repo.storeDomain(domain, true);
        return repo;
      }
      finally
View Full Code Here


      throw new ResourceLoadingException("Your resource-key must have a domain-id factory key defined.");
    }
    try
    {
      final InMemoryMetadataDomainRepository repo = new InMemoryMetadataDomainRepository();
      final XmiParser parser = new XmiParser();
      final Domain domain = parser.parseXmi(stream);
      domain.setId(String.valueOf(o));
      repo.storeDomain(domain, true);
      return new SimpleResource(key, repo, IMetadataDomainRepository.class, version);
    }
    catch (ResourceCreationException e)
View Full Code Here

      {
        final InputStream stream = createStream(resourceManager, contextKey, xmiFile);
        try
        {
          final InMemoryMetadataDomainRepository repo = new InMemoryMetadataDomainRepository();
          final XmiParser parser = new XmiParser();
          final Domain domain = parser.parseXmi(stream);
          // add a couple of agg types to the quantity ordered physical column
          final IPhysicalTable table = ((SqlPhysicalModel) domain.getPhysicalModels().get(0)).getPhysicalTables().get(7);
          final IPhysicalColumn col = table.getPhysicalColumns().get(3);
          final List<AggregationType> list = new ArrayList<AggregationType>();
          list.add(AggregationType.SUM);
View Full Code Here

  private InputStream StripDswFromStream( InputStream inputStream ) throws Exception {
    // Check if this is valid xml
    InputStream inputStream2 = null;
    String xmi = null;
    XmiParser xmiParser = new XmiParser();
    try {
      byte[] is = IOUtils.toByteArray( inputStream );
      xmi = new String( is, "UTF-8" );

      // now, try to see if the xmi can be parsed (ie, check if it's valid xmi)
      Domain domain = xmiParser.parseXmi( new java.io.ByteArrayInputStream( is ) );

      boolean changed = false;
      if ( domain.getLogicalModels().size() > 1 ) {
        Iterator<LogicalModel> iterator = domain.getLogicalModels().iterator();
        while ( iterator.hasNext() ) {
          LogicalModel logicalModel = iterator.next();
          Object property = logicalModel.getProperty( DSW_SOURCE_PROPERTY ); //$NON-NLS-1$
          if ( property != null ) {
            // This metadata file came from a DataSourceWizard, it may have embedded mondrian schema
            // that would incorrectly inform the system that there is mondrian schema attached. By
            // definition we only want to import the metadata portion.
            if ( logicalModel.getProperty( logicalModel.PROPERTY_OLAP_DIMS ) != null ) {
              // This logical model is an Olap model that needs to be removed from metadata
              iterator.remove();
            } else {
              // Remove properties that make this a DSW
              logicalModel.removeChildProperty( DSW_SOURCE_PROPERTY );
              logicalModel.removeChildProperty( "AGILE_BI_VERSION" );
            }
            changed = true;
          }
        }
        if ( changed ) {
          // The model was modified, regenerate the xml
          xmi = xmiParser.generateXmi( domain );
        }
      }

      // xmi is valid. Create a new inputstream for the actual import action.
      inputStream2 = new java.io.ByteArrayInputStream( xmi.getBytes( "UTF-8" ) );
View Full Code Here

  protected void setRepository( final IUnifiedRepository repository ) {
    this.repository = repository;
  }

  protected void setXmiParser( final XmiParser xmiParser ) {
    this.xmiParser = ( xmiParser != null ? xmiParser : new XmiParser() );
  }
View Full Code Here

    } catch ( Exception success ) {
      //ignored
    }

    final RepositoryUtils repositoryUtils = new RepositoryUtils( repository );
    final XmiParser xmiParser = new XmiParser();
    final LocalizationUtil localizationUtil = new LocalizationUtil();
    final PentahoMetadataDomainRepository repo =
        createDomainRepository( repository, repositoryUtils, xmiParser, localizationUtil );
    assertEquals( repository, repo.getRepository() );
    assertEquals( repositoryUtils, repo.getRepositoryUtils() );
View Full Code Here

    domainRepository.toString( repository.getFile( "/etc/metadata" ) );
  }

  public void testLoadLocaleStrings() throws Exception {
    // Add a domain with no external locale information
    domainRepository.setXmiParser( new XmiParser() );
    final Domain steelWheels = loadDomain( STEEL_WHEELS, "./steel-wheels.xmi" );
    domainRepository.storeDomain( steelWheels, true );

    final int initialLocaleSize = steelWheels.getLocaleCodes().length;
    assertEquals( initialLocaleSize, steelWheels.getLocales().size() );
View Full Code Here

    assertEquals( newLocaleSize, steelWheels.getLocales().size() );
  }

  public void testSetXmiParser() throws Exception {
    domainRepository.setXmiParser( null );
    domainRepository.setXmiParser( new XmiParser() );
  }
View Full Code Here

   * @return
   * @throws Exception
   */
  private static final Domain loadDomain( final String domainId, final String domainFile ) throws Exception {
    final InputStream in = PentahoMetadataDomainRepositoryTest.class.getResourceAsStream( domainFile );
    final XmiParser parser = new XmiParser();
    final Domain domain = parser.parseXmi( in );
    domain.setId( domainId );
    IOUtils.closeQuietly( in );
    return domain;
  }
View Full Code Here

TOP

Related Classes of org.pentaho.metadata.util.XmiParser

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.