public String getMethodDescription() { if ( methodType != PARTITIONING_METHOD_SPECIAL ) { return methodDescriptions[methodType]; } else { return partitioner.getDescription(); } }
public String getXML() { StringBuilder xml = new StringBuilder( 150 ); xml.append( " " ).append( XMLHandler.openTag( "partitioning" ) ).append( Const.CR ); xml.append( " " ).append( XMLHandler.addTagValue( "method", getMethodCode() ) ); xml.append( " " ).append( XMLHandler.addTagValue( "schema_name", partitionSchema != null ? partitionSchema.getName() : "" ) ); if ( partitioner != null ) { xml.append( partitioner.getXML() ); } xml.append( " " ).append( XMLHandler.closeTag( "partitioning" ) ).append( Const.CR ); return xml.toString(); }
public Partitioner clone() { Partitioner partitioner = getInstance(); partitioner.setId( id ); partitioner.setDescription( description ); partitioner.setMeta( meta ); return partitioner; }
public Partitioner getInstance() { Partitioner partitioner = new ModPartitioner(); partitioner.setId( getId() ); partitioner.setDescription( getDescription() ); return partitioner; }
public void testRepoRoundTrip() throws KettleException { T metaToSave = createMeta(); Map<String, FieldLoadSaveValidator<?>> validatorMap = createValidatorMapAndInvokeSetters( repoAttributes, metaToSave ); T metaLoaded = createMeta(); Repository rep = new MemoryRepository(); metaToSave.saveRep( rep, null, null ); metaLoaded.loadRep( rep, null ); validateLoadedMeta( repoAttributes, validatorMap, metaToSave, metaLoaded ); }
public void testXmlRoundTrip() throws KettleException { T metaToSave = createMeta(); Map<String, FieldLoadSaveValidator<?>> validatorMap = createValidatorMapAndInvokeSetters( xmlAttributes, metaToSave ); T metaLoaded = createMeta(); String xml = "<step>" + metaToSave.getXML() + "</step>"; InputStream is = new ByteArrayInputStream( xml.getBytes() ); metaLoaded.loadXML( XMLHandler.getSubNode( XMLHandler.loadXMLFile( is, null, false, false ), "step" ) ); validateLoadedMeta( xmlAttributes, validatorMap, metaToSave, metaLoaded ); }
public StepPartitioningMeta loadStepPartitioningMeta( ObjectId id_step ) throws KettleException { StepPartitioningMeta stepPartitioningMeta = new StepPartitioningMeta(); stepPartitioningMeta.setPartitionSchemaName( repository .getStepAttributeString( id_step, "PARTITIONING_SCHEMA" ) ); String methodCode = repository.getStepAttributeString( id_step, "PARTITIONING_METHOD" ); stepPartitioningMeta.setMethod( StepPartitioningMeta.getMethod( methodCode ) ); if ( stepPartitioningMeta.getPartitioner() != null ) { stepPartitioningMeta.getPartitioner().loadRep( repository, id_step ); } stepPartitioningMeta.hasChanged( true ); return stepPartitioningMeta; }
/** * Saves partitioning properties in the repository for the given step. * * @param meta * the partitioning metadata to store. * @param id_transformation * the ID of the transformation * @param id_step * the ID of the step * @throws KettleDatabaseException * In case anything goes wrong * */ public void saveStepPartitioningMeta( StepPartitioningMeta meta, ObjectId id_transformation, ObjectId id_step ) throws KettleException { repository.saveStepAttribute( id_transformation, id_step, "PARTITIONING_SCHEMA", meta.getPartitionSchema() != null ? meta .getPartitionSchema().getName() : "" ); // selected schema repository.saveStepAttribute( id_transformation, id_step, "PARTITIONING_METHOD", meta.getMethodCode() ); if ( meta.getPartitioner() != null ) { meta.getPartitioner().saveRep( repository, id_transformation, id_step ); } }
public void createPartitioner( String method ) throws KettlePluginException { methodType = getMethodType( method ); switch ( methodType ) { case PARTITIONING_METHOD_SPECIAL: { PluginRegistry registry = PluginRegistry.getInstance(); PluginInterface plugin = registry.findPluginWithId( PartitionerPluginType.class, method ); partitioner = (Partitioner) registry.loadClass( plugin ); partitioner.setId( plugin.getIds()[0] ); break; } case PARTITIONING_METHOD_NONE: default: partitioner = null; } if ( partitioner != null ) { partitioner.setMeta( this ); } }
public StepPartitioningMeta clone() { try { StepPartitioningMeta stepPartitioningMeta = new StepPartitioningMeta( method, partitionSchema != null ? (PartitionSchema) partitionSchema.clone() : null ); stepPartitioningMeta.partitionSchemaName = partitionSchemaName; stepPartitioningMeta.setMethodType( methodType ); stepPartitioningMeta.setPartitioner( partitioner == null ? null : partitioner.clone() ); return stepPartitioningMeta; } catch ( KettlePluginException e ) { throw new RuntimeException( "Unable to load partitioning plugin", e ); } }
public StepPartitioningMeta( Node partitioningMethodNode ) throws KettleException { this(); setMethod( getMethod( XMLHandler.getTagValue( partitioningMethodNode, "method" ) ) ); partitionSchemaName = XMLHandler.getTagValue( partitioningMethodNode, "schema_name" ); hasChanged = false; if ( partitioner != null ) { partitioner.loadXML( partitioningMethodNode ); } }
public StepDialogInterface getPartitionerDialog( StepMeta stepMeta, StepPartitioningMeta partitioningMeta, TransMeta transMeta ) throws KettleException { Partitioner partitioner = partitioningMeta.getPartitioner(); String dialogClassName = partitioner.getDialogClassName(); Class<?> dialogClass; Class<?>[] paramClasses = new Class<?>[] { Shell.class, StepMeta.class, StepPartitioningMeta.class, TransMeta.class }; Object[] paramArgs = new Object[] { spoon.getShell(), stepMeta, partitioningMeta, transMeta }; Constructor<?> dialogConstructor; try { dialogClass = partitioner.getClass().getClassLoader().loadClass( dialogClassName ); dialogConstructor = dialogClass.getConstructor( paramClasses ); return (StepDialogInterface) dialogConstructor.newInstance( paramArgs ); } catch ( Exception e ) { // try the old way for compatibility Method method; try { Class<?>[] sig = new Class<?>[] { Shell.class, StepMetaInterface.class, TransMeta.class }; method = stepMeta.getClass().getDeclaredMethod( "getDialog", sig ); if ( method != null ) { return (StepDialogInterface) method.invoke( stepMeta, new Object[] { spoon.getShell(), stepMeta, transMeta } ); } } catch ( Throwable ignored ) { } throw new KettleException( e ); } }
/** * The getInstance() method is part of the Partitioner interface and should return * a new instance of the partitioner, taking over the id and description from the * object it is called on. */ public Partitioner getInstance() { Partitioner partitioner = new DemoPartitioner(); partitioner.setId( getId() ); partitioner.setDescription( getDescription() ); return partitioner; }
if ( stepPartitioningMeta.getPartitioner() != null ) { proxy = new RepositoryProxy( stepNode.getNode( NODE_PARTITIONER_CUSTOM ) ); stepPartitioningMeta.getPartitioner().loadRep( proxy, null );
DataNode partitionerCustomNode = new DataNode( NODE_PARTITIONER_CUSTOM ); proxy = new RepositoryProxy( partitionerCustomNode ); partitioningMeta.getPartitioner().saveRep( proxy, null, null ); stepNode.addNode( partitionerCustomNode );
protected void testClone() { T metaToSave = createMeta(); Map<String, FieldLoadSaveValidator<?>> validatorMap = createValidatorMapAndInvokeSetters( xmlAttributes, metaToSave ); @SuppressWarnings( "unchecked" ) T metaLoaded = (T) metaToSave.clone(); validateLoadedMeta( xmlAttributes, validatorMap, metaToSave, metaLoaded ); } }
@Override public String toString() { String description; if ( partitioner != null ) { description = partitioner.getDescription(); } else { description = getMethodDescription(); } if ( partitionSchema != null ) { description += " / " + partitionSchema.toString(); } return description; }
public ModPartitionerDialog( Shell parent, StepMeta stepMeta, StepPartitioningMeta partitioningMeta, TransMeta transMeta ) { super( parent, (BaseStepMeta) stepMeta.getStepMetaInterface(), transMeta, partitioningMeta .getPartitioner().getDescription() ); this.stepMeta = stepMeta; this.partitioningMeta = partitioningMeta; partitioner = (ModPartitioner) partitioningMeta.getPartitioner(); fieldName = partitioner.getFieldName(); }
public DemoPartitionerDialog( Shell parent, StepMeta stepMeta, StepPartitioningMeta partitioningMeta, TransMeta transMeta ) { super( parent, (BaseStepMeta) stepMeta.getStepMetaInterface(), transMeta, partitioningMeta.getPartitioner().getDescription() ); this.stepMeta = stepMeta; this.partitioningMeta = partitioningMeta; partitioner = (DemoPartitioner) partitioningMeta.getPartitioner(); fieldName = partitioner.getFieldName(); }