当前位置: 首页>>代码示例>>Java>>正文


Java RepositoryElementInterface.setObjectId方法代码示例

本文整理汇总了Java中org.pentaho.di.repository.RepositoryElementInterface.setObjectId方法的典型用法代码示例。如果您正苦于以下问题:Java RepositoryElementInterface.setObjectId方法的具体用法?Java RepositoryElementInterface.setObjectId怎么用?Java RepositoryElementInterface.setObjectId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.pentaho.di.repository.RepositoryElementInterface的用法示例。


在下文中一共展示了RepositoryElementInterface.setObjectId方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: save

import org.pentaho.di.repository.RepositoryElementInterface; //导入方法依赖的package包/类
public void save(RepositoryElementInterface repositoryElement, String versionComment, ProgressMonitorListener monitor, ObjectId parentId, boolean used) throws KettleException {
	try {
		if (!(repositoryElement instanceof XMLInterface) && !(repositoryElement instanceof SharedObjectInterface)) {
			throw new KettleException("Class ["+repositoryElement.getClass().getName()+"] needs to implement the XML Interface in order to save it to disk");
		}
		
		if (!Const.isEmpty(versionComment)) {
			insertLogEntry(versionComment);
		}
		
		ObjectId objectId = new StringObjectId(calcObjectId(repositoryElement));
		
		FileObject fileObject = getFileObject(repositoryElement);
		
		String xml = ((XMLInterface)repositoryElement).getXML();
		
		OutputStream os = KettleVFS.getOutputStream(fileObject, false);
		os.write(xml.getBytes(Const.XML_ENCODING));
		os.close();
		
		if (repositoryElement instanceof ChangedFlagInterface) {
		  ((ChangedFlagInterface)repositoryElement).clearChanged();
		}
		
		// See if the element was already saved in the repository.
		// If the object ID is different, then we created an extra copy.
		// If so, we need to now remove the old file to prevent us from having multiple copies.
		//
		if (repositoryElement.getObjectId()!=null && !repositoryElement.getObjectId().equals(objectId)) {
			delObject(repositoryElement.getObjectId());
		}

		repositoryElement.setObjectId(objectId);
	} catch(Exception e) {
		throw new KettleException("Unable to save repository element ["+repositoryElement+"] to XML file : "+calcFilename(repositoryElement), e);
	}
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:38,代码来源:KettleFileRepository.java

示例2: saveRepositoryElement

import org.pentaho.di.repository.RepositoryElementInterface; //导入方法依赖的package包/类
protected void saveRepositoryElement( RepositoryElementInterface element, String versionComment,
                                      ITransformer transformer, Serializable elementsFolderId )
  throws KettleException {

  boolean isUpdate = ( element.getObjectId() != null );
  RepositoryFile file;
  if ( isUpdate ) {
    file = pur.getFileById( element.getObjectId().getId() );
    // update title & description
    file =
        new RepositoryFile.Builder( file ).title( RepositoryFile.DEFAULT_LOCALE, element.getName() ).description(
            RepositoryFile.DEFAULT_LOCALE, Const.NVL( element.getDescription(), "" ) ).build();

    // first rename, it is safe as only a name is changed, but not a path
    renameIfNecessary( element, file );
    file =
        pur.updateFile( file,
            new NodeRepositoryFileData( transformer.elementToDataNode( element ) ), versionComment );
  } else {
    file =
        new RepositoryFile.Builder(
            checkAndSanitize( element.getName() + element.getRepositoryElementType().getExtension() ) )
            .title( RepositoryFile.DEFAULT_LOCALE, element.getName() )
            .description( RepositoryFile.DEFAULT_LOCALE, Const.NVL( element.getDescription(), "" ) ).versioned(
                VERSION_SHARED_OBJECTS ).build();
    file =
        pur
            .createFile( elementsFolderId, file, new NodeRepositoryFileData( transformer.elementToDataNode( element ) ),
                versionComment );
  }
  // side effects
  ObjectId objectId = new StringObjectId( file.getId().toString() );
  element.setObjectId( objectId );
  element.setObjectRevision( getObjectRevision( objectId, null ) );
  if ( element instanceof ChangedFlagInterface ) {
    ( (ChangedFlagInterface) element ).clearChanged();
  }
  updateSharedObjectCache( element );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:40,代码来源:PurRepository.java

示例3: savePartitionSchema

import org.pentaho.di.repository.RepositoryElementInterface; //导入方法依赖的package包/类
protected void savePartitionSchema( final RepositoryElementInterface element, final String versionComment,
                                    Calendar versionDate ) {
  try {
    // Even if the object id is null, we still have to check if the element is not present in the PUR
    // For example, if we import data from an XML file and there is a element with the same name in it.
    //
    if ( element.getObjectId() == null ) {
      element.setObjectId( getPartitionSchemaID( element.getName() ) );
    }

    saveRepositoryElement( element, versionComment, partitionSchemaTransformer, getPartitionSchemaParentFolderId() );
  } catch ( KettleException ke ) {
    ke.printStackTrace();
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:16,代码来源:PurRepository.java

示例4: saveSlaveServer

import org.pentaho.di.repository.RepositoryElementInterface; //导入方法依赖的package包/类
protected void saveSlaveServer( final RepositoryElementInterface element, final String versionComment,
                                Calendar versionDate ) throws KettleException {
  try {
    // Even if the object id is null, we still have to check if the element is not present in the PUR
    // For example, if we import data from an XML file and there is a element with the same name in it.
    //
    if ( element.getObjectId() == null ) {
      element.setObjectId( getSlaveID( element.getName() ) );
    }

    saveRepositoryElement( element, versionComment, slaveTransformer, getSlaveServerParentFolderId() );
  } catch ( KettleException ke ) {
    ke.printStackTrace();
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:16,代码来源:PurRepository.java

示例5: saveClusterSchema

import org.pentaho.di.repository.RepositoryElementInterface; //导入方法依赖的package包/类
protected void saveClusterSchema( final RepositoryElementInterface element, final String versionComment,
                                  Calendar versionDate ) {
  try {
    // Even if the object id is null, we still have to check if the element is not present in the PUR
    // For example, if we import data from an XML file and there is a element with the same name in it.
    //
    if ( element.getObjectId() == null ) {
      element.setObjectId( getClusterID( element.getName() ) );
    }

    saveRepositoryElement( element, versionComment, clusterTransformer, getClusterSchemaParentFolderId() );
  } catch ( KettleException ke ) {
    ke.printStackTrace();
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:16,代码来源:PurRepository.java

示例6: save

import org.pentaho.di.repository.RepositoryElementInterface; //导入方法依赖的package包/类
public void save(RepositoryElementInterface repositoryElement, String versionComment, ProgressMonitorListener monitor, ObjectId parentId, boolean used) throws KettleException {
	try {
		if (!(repositoryElement instanceof XMLInterface) && !(repositoryElement instanceof SharedObjectInterface)) {
			throw new KettleException("Class ["+repositoryElement.getClass().getName()+"] needs to implement the XML Interface in order to save it to disk");
		}
		
		if (!Const.isEmpty(versionComment)) {
			insertLogEntry("Save repository element : "+repositoryElement.toString()+" : "+versionComment);
		}
		
		ObjectId objectId = new StringObjectId(calcObjectId(repositoryElement));
		
		FileObject fileObject = getFileObject(repositoryElement);
		
		String xml = ((XMLInterface)repositoryElement).getXML();
		
		OutputStream os = KettleVFS.getOutputStream(fileObject, false);
		os.write(xml.getBytes(Const.XML_ENCODING));
		os.close();
		
		if (repositoryElement instanceof ChangedFlagInterface) {
		  ((ChangedFlagInterface)repositoryElement).clearChanged();
		}
		
		// See if the element was already saved in the repository.
		// If the object ID is different, then we created an extra copy.
		// If so, we need to now remove the old file to prevent us from having multiple copies.
		//
		if (repositoryElement.getObjectId()!=null && !repositoryElement.getObjectId().equals(objectId)) {
			delObject(repositoryElement.getObjectId());
		}
		
		// See if this is a transformation & if the transformation has a defined data service.
		// If so, we want to store a separate .das (DAta Service) file for performance reasons.
		//
		if (repositoryElement instanceof TransMeta) {
      FileObject dasFile = KettleVFS.getFileObject(calcFilename(repositoryElement.getRepositoryDirectory(), repositoryElement.getName(), EXT_DATA_SERVICE));

      // Remove possible old file
      //
      if (dasFile.exists()) {
        dasFile.delete();
      }
      TransMeta transMeta = (TransMeta)repositoryElement;
		  if (transMeta.getDataService().isDefined()) {
		    // Write new data service file
		    //
		    xml = transMeta.getDataService().getXML();
	      os = KettleVFS.getOutputStream(dasFile, false);
         os.write(XMLHandler.getXMLHeader().getBytes(Const.XML_ENCODING));
	      os.write(xml.getBytes(Const.XML_ENCODING));
	      os.close();
		  }
		}
		

		repositoryElement.setObjectId(objectId);
	} catch(Exception e) {
		throw new KettleException("Unable to save repository element ["+repositoryElement+"] to XML file : "+calcFilename(repositoryElement), e);
	}
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:62,代码来源:KettleFileRepository.java

示例7: save

import org.pentaho.di.repository.RepositoryElementInterface; //导入方法依赖的package包/类
public void save( RepositoryElementInterface repositoryElement, String versionComment,
  ProgressMonitorListener monitor, ObjectId parentId, boolean used ) throws KettleException {
  try {
    if ( !( repositoryElement instanceof XMLInterface )
      && !( repositoryElement instanceof SharedObjectInterface ) ) {
      throw new KettleException( "Class ["
        + repositoryElement.getClass().getName()
        + "] needs to implement the XML Interface in order to save it to disk" );
    }

    if ( !Utils.isEmpty( versionComment ) ) {
      insertLogEntry( "Save repository element : " + repositoryElement.toString() + " : " + versionComment );
    }

    ObjectId objectId = new StringObjectId( calcObjectId( repositoryElement ) );

    FileObject fileObject = getFileObject( repositoryElement );

    String xml = ( (XMLInterface) repositoryElement ).getXML();

    OutputStream os = KettleVFS.getOutputStream( fileObject, false );
    os.write( xml.getBytes( Const.XML_ENCODING ) );
    os.close();

    if ( repositoryElement instanceof ChangedFlagInterface ) {
      ( (ChangedFlagInterface) repositoryElement ).clearChanged();
    }

    // See if the element was already saved in the repository.
    // If the object ID is different, then we created an extra copy.
    // If so, we need to now remove the old file to prevent us from having multiple copies.
    //
    if ( repositoryElement.getObjectId() != null && !repositoryElement.getObjectId().equals( objectId ) ) {
      delObject( repositoryElement.getObjectId() );
    }

    repositoryElement.setObjectId( objectId );

    // Finally, see if there are external objects that need to be stored or updated in the MetaStore
    //
    if ( repositoryElement instanceof TransMeta ) {
      ( (TransMeta) repositoryElement ).saveMetaStoreObjects( this, metaStore );
    }
    if ( repositoryElement instanceof JobMeta ) {
      ( (JobMeta) repositoryElement ).saveMetaStoreObjects( this, metaStore );
    }

  } catch ( Exception e ) {
    throw new KettleException( "Unable to save repository element ["
      + repositoryElement + "] to XML file : " + calcFilename( repositoryElement ), e );
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:53,代码来源:KettleFileRepository.java

示例8: saveDatabaseMeta

import org.pentaho.di.repository.RepositoryElementInterface; //导入方法依赖的package包/类
protected void saveDatabaseMeta( final RepositoryElementInterface element, final String versionComment,
                                 Calendar versionDate ) throws KettleException {
  try {
    // Even if the object id is null, we still have to check if the element is not present in the PUR
    // For example, if we import data from an XML file and there is a element with the same name in it.
    //
    if ( element.getObjectId() == null ) {
      element.setObjectId( getDatabaseID( element.getName() ) );
    }

    boolean isUpdate = element.getObjectId() != null;
    RepositoryFile file = null;
    if ( isUpdate ) {
      file = pur.getFileById( element.getObjectId().getId() );

      // update title
      final String title = ( (DatabaseMeta) element ).getDisplayName();
      Date modifiedDate = null;
      if ( versionDate != null && versionDate.getTime() != null ) {
        modifiedDate = versionDate.getTime();
      } else {
        modifiedDate = new Date();
      }
      file = new RepositoryFile.Builder( file ).title( RepositoryFile.DEFAULT_LOCALE, title )
        .lastModificationDate( modifiedDate ).build();
      renameIfNecessary( element, file );
      file =
          pur.updateFile( file, new NodeRepositoryFileData( databaseMetaTransformer.elementToDataNode( element ) ),
              versionComment );
    } else {
      Date createdDate = null;
      if ( versionDate != null && versionDate.getTime() != null ) {
        createdDate = versionDate.getTime();
      } else {
        createdDate = new Date();
      }
      file =
          new RepositoryFile.Builder(
              checkAndSanitize( RepositoryFilenameUtils.escape( element.getName(), pur.getReservedChars() )
                  + RepositoryObjectType.DATABASE.getExtension() ) ).title( RepositoryFile.DEFAULT_LOCALE,
              element.getName() ).createdDate( createdDate ).versioned( VERSION_SHARED_OBJECTS ).build();
      file =
          pur.createFile( getDatabaseMetaParentFolderId(), file,
              new NodeRepositoryFileData( databaseMetaTransformer.elementToDataNode( element ) ), versionComment );
    }
    // side effects
    ObjectId objectId = new StringObjectId( file.getId().toString() );
    element.setObjectId( objectId );
    element.setObjectRevision( getObjectRevision( objectId, null ) );
    if ( element instanceof ChangedFlagInterface ) {
      ( (ChangedFlagInterface) element ).clearChanged();
    }
    updateSharedObjectCache( element );
  } catch ( Exception e ) {
    // determine if there is an "access denied" issue and throw a nicer error message.
    if ( e.getMessage().indexOf( "access denied" ) >= 0 ) {
      throw new KettleException(
          BaseMessages.getString( PKG, "PurRepository.ERROR_0004_DATABASE_UPDATE_ACCESS_DENIED", element.getName() ),
          e );
    }
  }

}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:64,代码来源:PurRepository.java


注:本文中的org.pentaho.di.repository.RepositoryElementInterface.setObjectId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。