Page 1 of 1

Posted: Wed Nov 14, 2012 10:11 am
by chetan.c
Hi,

In the beginning of the code,can you show us what is the package and class you are pointing to.

Like this.. http://tinyurl.com/d8sgf6n.


Thanks,
Chetan.C

Posted: Wed Nov 14, 2012 10:23 am
by sneha123
sample code i took from dsxchange only


package SampleJavaPlugIns;

import com.ascentialsoftware.jds.Row;
import com.ascentialsoftware.jds.Stage;
import com.ascentialsoftware.jds.Column;
/* import com.ascentialsoftware.tr4j.*;

/**
* @author eostic
*
* DataStage PlugIn Development
*
* Ernie Ostic
* Ascential Software
*
* This class is based on one of the samples in the javadocs written by ASCL engineering.
*
* It has then been customized to test additional calls supported by the java plugin API,
* and illustrate how the plugin can "discover" how it is being used in the job. It certainly does NOT
* exercise every possible call, nor explore all the things, such as reference links, etc.
* that can be performed with javaPack. However, it is helpful in validating that the plugins
* are working and provides another baseline example.
*
* NO WARRANTIES OR VALIDATED TECHNIQUES IMPLIED BY THIS CODE. USE THIS AT YOUR OWN RISK AND FOR
* EDUCATIONAL AND LEARNING PURPOSES ONLY.
*
*/
public class ExamineRows extends Stage {

public void initialize()
{

//*------------------------------------------------------------------------------------*
// What kind of Links do I have (am I being invoked with)...ie what type of Stage
//
// a JavaTransformer Stage would typically have Input -and- Output links...
//*------------------------------------------------------------------------------------*

/* trace("initialization analysis");
if (hasInputLink()) {warn("Input Link Found"); }
if (hasOutputLink()) {warn("Output Link Found"); }
if (hasReferenceLink()) {warn("Reference Link Found"); }
if (hasRejectLink()) {warn("Reject Link Found"); } */

//Ultimately, determining link types should trigger branching to different parts of the code,
//depending on what type of operation we're expected to be coding for...source/target/transform.
//This way a java developer could (in theory, but less likely in reality) write a very "generic" class
//that would work in many situations, perhaps having it's "function" passed in as a property

//*------------------------------------------------------------------------------------*
// Obtain user properties from the generic "box" property of the plugin GUI
//*------------------------------------------------------------------------------------*

String UserProperties=getUserProperties();

//*------------------------------------------------------------------------------------*
//write values of the user properties to the DS log as info message
//*------------------------------------------------------------------------------------*
//* info (UserProperties);
trace("For the first row list the column names and their SQL data types.");

if (isTraceOn()) {
trace("Trace is on");
}
//*------------------------------------------------------------------------------------*
// Trace works, but only if the user, in the Director, selects the third radio button
// for "Subroutine Calls" ...IN COMBINATION with any additional radio button of the 4.
//*------------------------------------------------------------------------------------*

trace("Tracing has been turned on"); //only appears if tracing is on from Director
}



int rowNumber;
int outColNumber;

public int process()
{
// Read a row, convert all its columns to upper case,
// and write the result. If any column of the input row
// contains the character '*', the row is rejected.


Row inputRow = readRow();

trace("Java class just received a row...");

rowNumber = rowNumber + 1;

if (inputRow == null) {
return OUTPUT_STATUS_END_OF_DATA;
}

boolean reject = false;
int columnCount = inputRow.getColumnCount();
Row outputRow = createOutputRow();


for (int columnNumber = 0; columnNumber < columnCount; columnNumber++) {
String value = inputRow.getValueAsString(columnNumber);


if (rowNumber == 1)
{

Column MetaDataForMyColumn = inputRow.getColumn(columnNumber);
String colName = MetaDataForMyColumn.getName();
int colSQLType=MetaDataForMyColumn.getSQLType();
String colSQLTypeName=Column.getSQLTypeName(colSQLType);


trace(colName);
trace(colSQLTypeName);


}
//*--------------------------------------------------------------------------------------------------------------
// "reject" any rows that have asterisks [these will go down a link that the DS developer marks as "reject" link
//*--------------------------------------------------------------------------------------------------------------

outColNumber=columnNumber;

if (value.indexOf("*") >=0) {
reject = true;
// warn("Value found with Asterisk. Reject the row");
outputRow.setValueAsString(outColNumber, value);
} else {
outputRow.setValueAsString(outColNumber, value.toUpperCase());
}
}

if (reject) {
rejectRow(outputRow);
} else {
writeRow(outputRow);
}
return OUTPUT_STATUS_READY;
}

}

Posted: Wed Nov 14, 2012 11:42 am
by chetan.c
Hi,


Create a folder "SampleJavaPlugIns" in the directory of your present class file location.
Your class file should be present inside the "SampleJavaPlugIns" folder.




Thanks,
Chetan.C

Posted: Wed Nov 14, 2012 2:15 pm
by eostic
The details of how to do this are in an annotation in the Job sample itself...load the .dsx that you downloaded with the source ...there is an annotation box that outlines how deep to specify the classpath based on whether you are using a .jar or an independent simple class file as in the example.

Ernie

Posted: Wed Nov 14, 2012 4:33 pm
by lstsaur
Actucally your class name is ExamineRows not the SampleJavaPlugIns.ExamineRows. SampleJavaPlugIns is your package's name. So just type "ExmineRows" (without quotes) in the Transformer Class Name box.

Posted: Wed Nov 14, 2012 4:55 pm
by chulett
Or just read the annotation. :wink:

Posted: Thu Nov 15, 2012 5:52 am
by sneha123
awesome
Thanks Guys it is done now

Java Transformer sample job

Posted: Wed Sep 18, 2013 1:07 pm
by eq8547
Hi Ernie,

Can you please let me know where I can find the dsx file of the Job sample you mentioned above.

I'm encountering the same java.lang.ClassNotFoundException issue.

Thanks,
Edgar

Posted: Wed Sep 18, 2013 1:28 pm
by eostic
Probably should be a new thread, but see if you can download it at www.dsrealtime.com . Look in the table of contents (link at upper right) for posts on java. Some people have had issues downloading it. You have to rename it after you download (see the post).

Ernie