-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Matt Casters
committed
Feb 2, 2014
1 parent
3ffd328
commit e28acd7
Showing
17 changed files
with
3,835 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>pentaho-kettle-compare-fields-plugin</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
project.revision=1.1.0 | ||
ivy.artifact.group=pentaho-kettle | ||
ivy.artifact.id=pentaho-kettle-compare-fields-plugin | ||
impl.vendor=Pentaho Corporation | ||
impl.title=Kettle Compare Fields step plugin | ||
impl.productID=${ivy.artifact.id} | ||
dev-lib.dir=dev-lib | ||
|
||
dependency.kettle.revision=TRUNK-SNAPSHOT | ||
dependency.pentaho-xul.revision=TRUNK-SNAPSHOT | ||
dependency.pentaho-metastore.revision=TRUNK-SNAPSHOT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<!--=========================================================================== | ||
This is the build file for the Pentaho Data Integration (Kettle) Compare Fields plugin. | ||
This build file will use the subfloor.xml file as the default build | ||
process and should only override the tasks that need to differ from | ||
the common build file. | ||
See common_build.xml for more details | ||
============================================================================--> | ||
<project name="pentaho-kettle-compare-fields-plugin" basedir="." default="default" xmlns:ivy="antlib:org.apache.ivy.ant"> | ||
|
||
|
||
<description> | ||
This build file is used to create the Pentaho Kettle compare fields step plugin | ||
</description> | ||
|
||
<!-- The continuous target is used by CI ... this is the list of --> | ||
<!-- tasks that the CI machine will run. --> | ||
<!-- DO NOT change the CI machine's ant task .. change this list --> | ||
<target name="continuous" depends="clean-all,resolve,publish" /> | ||
|
||
<!-- Import the common_build.xml file which contains all the default tasks --> | ||
<import file="build-res/subfloor-pkg.xml" /> | ||
|
||
<!-- | ||
AS STATED ABOVE, THE ONLY TASKS THAT SHOULD EXIST IN THIS BUILD FILE ARE | ||
THE TASKS THAT NEED TO DIFFER FROM THE DEFAULT IMPLEMENTATION OF THE TASKS | ||
FOUND IN common_build.xml. | ||
--> | ||
<target name="default" depends="clean-all,resolve,dist" /> | ||
|
||
<target name="create-dot-classpath" depends="resolve,subfloor.create-dot-classpath" /> | ||
|
||
<target name="stage" depends="jar" description="generate all the kettle plugin jars"> | ||
|
||
<echo>Staging the Kettle plugin ${ivy.artifact.id} ...</echo> | ||
|
||
<!-- copy plugin jar --> | ||
<mkdir dir="bin/stage/${ivy.artifact.id}" /> | ||
<copy todir="bin/stage/${ivy.artifact.id}" file="dist/${ivy.artifact.id}-${project.revision}.jar" /> | ||
<copy todir="bin/stage/${ivy.artifact.id}" file="resources/version.xml" /> | ||
|
||
<!-- external libs (jdbc etc) --> | ||
<mkdir dir="bin/stage/${ivy.artifact.id}/lib" /> | ||
<if> | ||
<available file="lib" type="dir" /> | ||
<then> | ||
<echo>Copying files from lib....</echo> | ||
<copy todir="bin/stage/${ivy.artifact.id}/lib"> | ||
<fileset dir="lib" includes="**/*" /> | ||
</copy> | ||
</then> | ||
</if> | ||
|
||
<!-- any other res files --> | ||
<if> | ||
<available file="res" /> | ||
<then> | ||
<copy todir="bin/stage/${ivy.artifact.id}"> | ||
<fileset dir="res" includes="**/*" excludes="**/.vpn" /> | ||
</copy> | ||
</then> | ||
</if> | ||
|
||
<!-- Update the version.xml with the current version of this plugin --> | ||
<if> | ||
<available file="bin/stage/${ivy.artifact.id}/version.xml" /> | ||
<then> | ||
<replace file="bin/stage/${ivy.artifact.id}/version.xml" token="@TRUNK@" value="${project.revision}" /> | ||
</then> | ||
</if> | ||
</target> | ||
|
||
<!--======================================================================= | ||
resolve-dev | ||
Resolves for development and compilation. | ||
=====================================================================--> | ||
<target name="resolve-dev" depends="install-ivy"> | ||
<ivy:resolve file="${ivyfile}" conf="dev" /> | ||
<ivy:retrieve conf="dev" pattern="${dev-lib.dir}/[module]-[revision](-[classifier]).[ext]" /> | ||
<touch file="${dev-lib.dir}/.kettle-ignore" /> | ||
</target> | ||
|
||
<target name="resolve" depends="subfloor.resolve,resolve-dev" /> | ||
<target name="package" depends="stage" description="generate all the kettle plugin jars"> | ||
<echo>Creating the Kettle plugin zip for ${ivy.artifact.id} ...</echo> | ||
<zip destfile="dist/${ivy.artifact.id}-${project.revision}.zip" basedir="bin/stage" includes="**/*" excludes="**/dev-lib/*" /> | ||
</target> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ivy-module version="2.0" xmlns:m="http://ant.apache.org/ivy/maven"> | ||
<info organisation="pentaho-kettle" module="${ivy.artifact.id}" revision="${dependency.kettle.revision}" /> | ||
|
||
<configurations> | ||
<conf name="default"/> | ||
<conf name="dev"/> | ||
<conf name="test" visibility="private"/> | ||
<conf name="source"/> | ||
<conf name="zip"/> | ||
</configurations> | ||
|
||
<!-- | ||
<publications> | ||
<artifact name="${ivy.artifact.id}" type="jar" conf="dev"/> | ||
<artifact name="${ivy.artifact.id}" type="zip" conf="zip" /> | ||
<artifact name="${ivy.artifact.id}" m:classifier="sources" type="source" ext="jar" conf="source"/> | ||
<artifact name="${ivy.artifact.id}" m:classifier="sources" type="source" ext="zip" conf="source"/> | ||
</publications> | ||
--> | ||
|
||
<dependencies defaultconf="default->default"> | ||
|
||
<dependency org="commons-vfs" name="commons-vfs" rev="20091118-pentaho" transitive="false" conf="dev->default" /> | ||
<dependency org="pentaho" name="metastore" rev="${dependency.pentaho-metastore.revision}" changing="true" conf="dev->default" /> | ||
|
||
<dependency org="pentaho-kettle" name="kettle-core" rev="${dependency.kettle.revision}" conf="dev->default" transitive="false"/> | ||
<dependency org="pentaho-kettle" name="kettle-engine" rev="${dependency.kettle.revision}" conf="dev->default" transitive="false"/> | ||
<dependency org="pentaho-kettle" name="kettle-ui-swt" rev="${dependency.kettle.revision}" conf="dev->default" transitive="false"/> | ||
|
||
<!-- SWT it required to compile any version of any architecture will work --> | ||
<dependency org="org.eclipse.swt" name="swt-linux-x86_64" rev="3.7" conf="dev->default" transitive="false"/> | ||
|
||
<dependency org="junit" name="junit" rev="4.7" conf="test->default"/> | ||
</dependencies> | ||
</ivy-module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ivysettings> | ||
<properties environment="env" /> | ||
<property name="ivy.local.default.root" value="${ivy.default.ivy.user.dir}/local" override="true" /> | ||
<property name="ivy.local.default.artifact.pattern" value="[organisation]/[module]/[revision]/[type]s/[artifact]-[revision].[ext]" | ||
override="false" /> | ||
|
||
<settings defaultResolver="pentaho-chained-resolver" /> | ||
<include url="${ivy.default.settings.dir}/ivysettings-public.xml" /> | ||
<include url="${ivy.default.settings.dir}/ivysettings-local.xml" /> | ||
<resolvers> | ||
<chain name="pentaho-chained-resolver"> | ||
<resolver ref="local" /> | ||
<dual name="pentaho"> | ||
<url name="pentaho-ivy"> | ||
<ivy pattern="http://repo.pentaho.org/artifactory/repo/[organisation]/[module]/[revision]/[module]-[revision].ivy.xml" /> | ||
</url> | ||
<ibiblio name="pentaho-mvn" m2compatible="true" root="http://repo.pentaho.org/artifactory/repo" /> | ||
</dual> | ||
<resolver ref="public" /> | ||
<ibiblio name="java-net-maven2" root="http://download.java.net/maven/2/" m2compatible="true" /> | ||
</chain> | ||
</resolvers> | ||
<caches lockStrategy="artifact-lock" resolutionCacheDir="${ivy.default.ivy.user.dir}/resol-cache${env.EXECUTOR_NUMBER}" /> | ||
</ivysettings> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ivy-module version="2.0" xmlns:m="http://ant.apache.org/ivy/maven"> | ||
<info organisation="${ivy.artifact.group}" module="${ivy.artifact.id}" revision="${project.revision}" /> | ||
<configurations> | ||
<conf name="default" /> | ||
</configurations> | ||
|
||
<publications> | ||
<artifact name="${ivy.artifact.id}" type="zip" /> | ||
<artifact name="${ivy.artifact.id}" type="jar" /> | ||
<artifact name="${ivy.artifact.id}" m:classifier="sources" type="source" ext="jar"/> | ||
<artifact name="${ivy.artifact.id}" m:classifier="sources" type="source" ext="zip"/> | ||
</publications> | ||
|
||
<dependencies defaultconf="default->default"> | ||
</dependencies> | ||
</ivy-module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<version branch='GA'>@TRUNK@</version> |
109 changes: 109 additions & 0 deletions
109
src/org/pentaho/di/trans/steps/comparefields/CompareField.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package org.pentaho.di.trans.steps.comparefields; | ||
|
||
import org.pentaho.di.core.Const; | ||
import org.pentaho.di.core.exception.KettleException; | ||
import org.pentaho.di.core.row.RowMetaInterface; | ||
import org.pentaho.di.core.xml.XMLHandler; | ||
import org.pentaho.di.i18n.BaseMessages; | ||
import org.pentaho.di.repository.ObjectId; | ||
import org.pentaho.di.repository.Repository; | ||
import org.w3c.dom.Node; | ||
|
||
public class CompareField { | ||
private static Class<?> PKG = CompareField.class; // for i18n purposes, needed by Translator2!! | ||
|
||
public static final String XML_TAG = "field"; | ||
public static final String CODE_REFERENCE_FIELD = "reference_field"; | ||
public static final String CODE_COMPARE_FIELD = "compare_field"; | ||
public static final String CODE_IGNORE_CASE = "ignore_case"; | ||
|
||
private String referenceFieldname; | ||
private String compareFieldname; | ||
|
||
public CompareField( String referenceFieldname, String compareFieldname, boolean ignoringCase ) { | ||
super(); | ||
this.referenceFieldname = referenceFieldname; | ||
this.compareFieldname = compareFieldname; | ||
} | ||
|
||
public String getXML() { | ||
StringBuilder xml = new StringBuilder(); | ||
xml.append( XMLHandler.openTag( XML_TAG ) ); | ||
xml.append( XMLHandler.addTagValue( CODE_REFERENCE_FIELD, referenceFieldname ) ); | ||
xml.append( XMLHandler.addTagValue( CODE_COMPARE_FIELD, compareFieldname ) ); | ||
xml.append( XMLHandler.closeTag( XML_TAG ) ); | ||
return xml.toString(); | ||
} | ||
|
||
public CompareField( Node fieldNode ) { | ||
referenceFieldname = XMLHandler.getTagValue( fieldNode, CODE_REFERENCE_FIELD ); | ||
compareFieldname = XMLHandler.getTagValue( fieldNode, CODE_COMPARE_FIELD ); | ||
} | ||
|
||
public void saveRep( Repository repository, ObjectId transformationId, ObjectId stepId, int fieldNr ) | ||
throws KettleException { | ||
repository.saveStepAttribute( transformationId, stepId, fieldNr, CODE_REFERENCE_FIELD, referenceFieldname ); | ||
repository.saveStepAttribute( transformationId, stepId, fieldNr, CODE_COMPARE_FIELD, compareFieldname ); | ||
} | ||
|
||
public CompareField( Repository repository, ObjectId stepId, int fieldNr ) throws KettleException { | ||
referenceFieldname = repository.getStepAttributeString( stepId, fieldNr, CODE_REFERENCE_FIELD ); | ||
compareFieldname = repository.getStepAttributeString( stepId, fieldNr, CODE_COMPARE_FIELD ); | ||
} | ||
|
||
private volatile int referenceFieldIndex; | ||
private volatile int compareFieldIndex; | ||
|
||
public void index( RowMetaInterface rowMeta ) throws KettleException { | ||
|
||
if ( Const.isEmpty( referenceFieldname ) ) { | ||
throw new KettleException( BaseMessages.getString( PKG, "CompareField.Error.EmptyReferenceField" ) ); | ||
} | ||
referenceFieldIndex = rowMeta.indexOfValue( referenceFieldname ); | ||
if ( referenceFieldIndex < 0 ) { | ||
throw new KettleException( | ||
BaseMessages.getString( PKG, "CompareField.Error.ReferenceFieldNotFound", referenceFieldname ) ); | ||
} | ||
if ( Const.isEmpty( compareFieldname ) ) { | ||
throw new KettleException( | ||
BaseMessages.getString( PKG, "CompareField.Error.CompareFieldEmpty", referenceFieldname ) ); | ||
} | ||
compareFieldIndex = rowMeta.indexOfValue( compareFieldname ); | ||
if ( compareFieldIndex < 0 ) { | ||
throw new KettleException( | ||
BaseMessages.getString( PKG, "CompareField.Error.CompareFieldNotFound", compareFieldname ) ); | ||
} | ||
} | ||
|
||
public String getReferenceFieldname() { | ||
return referenceFieldname; | ||
} | ||
|
||
public void setReferenceFieldname( String referenceFieldname ) { | ||
this.referenceFieldname = referenceFieldname; | ||
} | ||
|
||
public String getCompareFieldname() { | ||
return compareFieldname; | ||
} | ||
|
||
public void setCompareFieldname( String compareFieldname ) { | ||
this.compareFieldname = compareFieldname; | ||
} | ||
|
||
public int getReferenceFieldIndex() { | ||
return referenceFieldIndex; | ||
} | ||
|
||
public void setReferenceFieldIndex( int referenceFieldIndex ) { | ||
this.referenceFieldIndex = referenceFieldIndex; | ||
} | ||
|
||
public int getCompareFieldIndex() { | ||
return compareFieldIndex; | ||
} | ||
|
||
public void setCompareFieldIndex( int compareFieldIndex ) { | ||
this.compareFieldIndex = compareFieldIndex; | ||
} | ||
} |
Oops, something went wrong.