Codota Logo
ImportRules
Code IndexAdd Codota to your IDE (free)

How to use
ImportRules
in
org.pentaho.di.imp

Best Java code snippets using org.pentaho.di.imp.ImportRules (Showing top 20 results out of 315)

  • Common ways to obtain ImportRules
private void myMethod () {
ImportRules i =
  • Codota Iconnew ImportRules()
  • Smart code suggestions by Codota
}
origin: pentaho/pentaho-kettle

public RepositoryImportProgressDialog( Shell parent, int style, Repository rep, String fileDirectory,
 String[] filenames, RepositoryDirectoryInterface baseDirectory, String versionComment ) {
 this( parent, style, rep, fileDirectory, filenames, baseDirectory, versionComment, new ImportRules() );
}
origin: pentaho/pentaho-kettle

/**
 * Perform a deep clone
 *
 * @return a deep copy of the all the import rules.
 */
@Override
public ImportRules clone() {
 ImportRules importRules = new ImportRules();
 for ( ImportRuleInterface rule : rules ) {
  importRules.getRules().add( rule.clone() );
 }
 return importRules;
}
origin: pentaho/pentaho-kettle

public ImportRulesDialog( Shell parentShell, ImportRules importRules ) {
 super( parentShell );
 this.parentShell = parentShell;
 this.originalRules = importRules;
 this.importRules = importRules.clone();
 this.props = PropsUI.getInstance();
 this.display = parentShell.getDisplay();
}
origin: pentaho/pentaho-kettle

public static void main( String[] args ) throws Exception {
 Display display = new Display();
 KettleEnvironment.init();
 PropsUI.init( display, PropsUI.TYPE_PROPERTIES_SPOON );
 Shell shell = new Shell( display );
 ImportRules importRules = new ImportRules();
 importRules.loadXML( XMLHandler.getSubNode(
  XMLHandler.loadXMLFile( "bin/import-rules.xml" ), ImportRules.XML_TAG ) );
 ImportRulesDialog dialog = new ImportRulesDialog( shell, importRules );
 if ( dialog.open() ) {
  for ( ImportRuleInterface rule : importRules.getRules() ) {
   System.out.println( " - " + rule.toString() );
  }
 }
}
origin: pentaho/pentaho-kettle

private ImportRules getImportRules() {
 ImportRules imp = new ImportRules();
 List<ImportRuleInterface> impRules = new ArrayList<ImportRuleInterface>( 1 );
 JobHasDescriptionImportRule rule = new JobHasDescriptionImportRule();
 rule.setEnabled( true );
 rule.setMinLength( 19000 );
 impRules.add( rule );
 TransformationHasDescriptionImportRule trRule = new TransformationHasDescriptionImportRule() {
  public String toString() {
   return "stub to avoid call to Plugin registry";
  }
 };
 trRule.setEnabled( true );
 trRule.setMinLength( 19001 );
 impRules.add( trRule );
 imp.setRules( impRules );
 return imp;
}
origin: pentaho/pentaho-kettle

@Override
public void setImportRulesToValidate( ImportRules importRules ) {
 this.importRules = importRules;
 hasRules = ( importRules != null && !importRules.getRules().isEmpty() );
}
origin: pentaho/pentaho-kettle

private List<ImportValidationFeedback> validateObject( Object subject, boolean boolFeedback ) throws KettleException {
 if ( !hasRules ) {
  return Collections.emptyList();
 }
 if ( !boolFeedback ) {
  // this is call from Pan, job Executor or somthing else - we should throw
  // exception if one or more export rules is viloated.
  RepositoryImporter.validateImportedElement( importRules, subject );
 }
 List<ImportValidationFeedback> feedback = importRules.verifyRules( subject );
 List<ImportValidationFeedback> errors = new ArrayList<ImportValidationFeedback>( feedback.size() );
 for ( ImportValidationFeedback res : feedback ) {
  if ( res.isError() ) {
   errors.add( res );
  }
 }
 return errors;
}
origin: pentaho/pentaho-kettle

/**
 * Save the rules to an XML file
 */
protected void exportRules() {
 syncUIWithData();
 FileDialog dialog = new FileDialog( shell, SWT.SAVE );
 dialog.setFilterExtensions( new String[] { "*.xml;*.XML", "*" } );
 dialog.setFilterNames( new String[] {
  BaseMessages.getString( PKG, "System.FileType.XMLFiles" ),
  BaseMessages.getString( PKG, "System.FileType.AllFiles" ) } );
 if ( dialog.open() != null ) {
  String filename = dialog.getFilterPath() + System.getProperty( "file.separator" ) + dialog.getFileName();
  FileWriter fileWriter = null;
  try {
   fileWriter = new FileWriter( filename );
   fileWriter.write( XMLHandler.getXMLHeader() );
   fileWriter.write( importRules.getXML() );
  } catch ( Exception e ) {
   new ErrorDialog( shell, "Error", "There was an error while exporting to file '" + filename + "'", e );
  } finally {
   try {
    fileWriter.close();
   } catch ( Exception e ) {
    new ErrorDialog( shell, "Error", "There was an error closing file '" + filename + "'", e );
   }
  }
 }
}
origin: pentaho/pentaho-kettle

if ( !importRules.getRules().isEmpty() ) {
 MessageBox box =
  new MessageBox( shell, SWT.ICON_WARNING | SWT.APPLICATION_MODAL | SWT.SHEET | SWT.YES | SWT.NO );
 String filename = dialog.getFilterPath() + System.getProperty( "file.separator" ) + dialog.getFileName();
 ImportRules newRules = new ImportRules();
 try {
  newRules.loadXML( XMLHandler.getSubNode( XMLHandler.loadXMLFile( filename ), ImportRules.XML_TAG ) );
  importRules = newRules;
origin: pentaho/pentaho-kettle

protected void getInfo( ImportRules ir ) {
 ir.getRules().clear();
 for ( int i = 0; i < importRules.getRules().size(); i++ ) {
  ImportRuleInterface rule = importRules.getRules().get( i );
  ImportRuleCompositeInterface importRuleComposite = compositesList.get( i );
  TableItem tableItem = table.getItem( i );
  importRuleComposite.getCompositeData( rule );
  rule.setEnabled( tableItem.getChecked() );
  ir.getRules().add( rule );
 }
}
origin: pentaho/pentaho-kettle

/**
 * Validates the repository element that is about to get imported against the list of import rules.
 *
 * @param importRules
 *          import rules to validate against.
 * @param subject
 * @throws KettleException
 */
public static void validateImportedElement( ImportRules importRules, Object subject ) throws KettleException {
 List<ImportValidationFeedback> feedback = importRules.verifyRules( subject );
 List<ImportValidationFeedback> errors = ImportValidationFeedback.getErrors( feedback );
 if ( !errors.isEmpty() ) {
  StringBuilder message =
    new StringBuilder( BaseMessages.getString( PKG, "RepositoryImporter.ValidationFailed.Message", subject
      .toString() ) );
  message.append( Const.CR );
  for ( ImportValidationFeedback error : errors ) {
   message.append( " - " );
   message.append( error.toString() );
   message.append( Const.CR );
  }
  throw new KettleException( message.toString() );
 }
}
origin: pentaho/pentaho-kettle

ImportRules importRules = new ImportRules();
String rulesFile = optionRules.toString();
  Document document = XMLHandler.loadXMLFile( rulesFile );
  Node rulesNode = XMLHandler.getSubNode( document, ImportRules.XML_TAG );
  importRules.loadXML( rulesNode );
  log.logMinimal( BaseMessages.getString( PKG, "Import.Log.RulesLoaded", rulesFile, Integer.toString(
   importRules.getRules().size() ) ) );
  for ( ImportRuleInterface rule : importRules.getRules() ) {
   log.logBasic( " - " + rule.toString() );
origin: pentaho/pentaho-kettle

public RepositoryExportProgressDialog( Shell shell, Repository rep, RepositoryDirectoryInterface dir,
  String filename ) {
 this( shell, rep, dir, filename, new ImportRules() );
}
origin: pentaho/pentaho-kettle

for ( ImportRuleInterface rule : importRules.getRules() ) {
 if ( rule.isUnique() ) {
   rule.setId( plugin.getIds()[0] );
   ImportRules newRules = new ImportRules();
   getInfo( newRules );
   newRules.getRules().add( rule );
   importRules = newRules;
origin: pentaho/pentaho-kettle

public String getXML() {
 StringBuilder xml = new StringBuilder();
 xml.append( XMLHandler.openTag( XML_TAG ) ).append( Const.CR ).append( Const.CR );
 for ( ImportRuleInterface rule : getRules() ) {
  PluginInterface plugin = PluginRegistry.getInstance().getPlugin( ImportRulePluginType.class, rule.getId() );
  xml.append( "<!-- " ).append( plugin.getName() ).append( " : " ).append( plugin.getDescription() ).append(
   Const.CR ).append( " -->" ).append( Const.CR );
  xml.append( rule.getXML() );
  xml.append( Const.CR ).append( Const.CR );
 }
 xml.append( XMLHandler.closeTag( XML_TAG ) );
 return xml.toString();
}
origin: pentaho/pentaho-kettle

private boolean toExport( AbstractMeta meta ) {
 boolean shouldExport = true;
 List<ImportValidationFeedback> feedback = importRules.verifyRules( meta );
 List<ImportValidationFeedback> errors = ImportValidationFeedback.getErrors( feedback );
 if ( !errors.isEmpty() ) {
  shouldExport = false;
  log.logError( BaseMessages.getString( PKG, "PurRepositoryExporter.ERROR_EXPORT_ITEM", meta.getName() ) ); //$NON-NLS-1$
  for ( ImportValidationFeedback error : errors ) {
   log.logError( BaseMessages.getString( PKG, "PurRepositoryExporter.ERROR_EXPORT_ITEM_RULE", error.toString() ) ); //$NON-NLS-1$
  }
 }
 return shouldExport;
}
origin: pentaho/pentaho-kettle

public RepositoryImporter( Repository repository, LogChannelInterface log ) {
 this( repository, new ImportRules(), Collections.<String>emptyList(), log );
}
origin: pentaho/pentaho-kettle

public void removeRule() {
 MessageBox box =
  new MessageBox( shell, SWT.ICON_WARNING | SWT.APPLICATION_MODAL | SWT.SHEET | SWT.YES | SWT.NO );
 box.setText( "Warning" );
 box.setMessage( "Are you sure you want to remove the selected rules from the list?" );
 int answer = box.open();
 if ( answer != SWT.YES ) {
  return;
 }
 int[] indices = table.getSelectionIndices();
 Arrays.sort( indices );
 for ( int i = indices.length - 1; i >= 0; i-- ) {
  importRules.getRules().remove( indices[i] );
 }
 // Refresh the whole list..
 //
 getCompositesData();
}
origin: pentaho/pentaho-kettle

public RepositoryImporter( Repository repository ) {
 this( repository, new ImportRules(), new ArrayList<String>() );
}
origin: pentaho/pentaho-kettle

public void loadXML( Node rulesNode ) throws KettleException {
 List<Node> ruleNodes = XMLHandler.getNodes( rulesNode, BaseImportRule.XML_TAG );
 for ( Node ruleNode : ruleNodes ) {
  String id = XMLHandler.getTagValue( ruleNode, "id" );
  PluginRegistry registry = PluginRegistry.getInstance();
  PluginInterface plugin = registry.findPluginWithId( ImportRulePluginType.class, id );
  if ( plugin == null ) {
   throw new KettleException( "The import rule of type '"
    + id + "' could not be found in the plugin registry." );
  }
  ImportRuleInterface rule = (ImportRuleInterface) registry.loadClass( plugin );
  rule.loadXML( ruleNode );
  getRules().add( rule );
 }
}
org.pentaho.di.impImportRules

Most used methods

  • <init>
  • getRules
  • loadXML
  • verifyRules
  • clone
    Perform a deep clone
  • getXML
  • setRules

Popular in Java

  • Creating JSON documents from java classes using gson
  • getExternalFilesDir (Context)
  • setScale (BigDecimal)
  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • Kernel (java.awt.image)
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • BigInteger (java.math)
    Immutable arbitrary-precision integers. All operations behave as if BigIntegers were represented in
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • ImageIO (javax.imageio)
  • JTextField (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now