use of org.pentaho.di.core.logging.SimpleLoggingObject in project pentaho-kettle by pentaho.
the class ExecuteTransServlet method doGet.
/**
* <div id="mindtouch">
* <h1>/kettle/executeTrans</h1>
* <a name="GET"></a>
* <h2>GET</h2>
* <p>Executes transformation from the specified repository.
* Connects to the repository provided as a parameter, loads the transformation from it and executes it.
* Empty response is returned or response contains output of an error happened during the transformation execution.
* Response contains <code>ERROR</code> result if error happened during transformation execution.</p>
*
* <p><b>Example Request:</b><br />
* <pre function="syntax.xml">
* GET /kettle/executeTrans/?rep=my_repository&user=my_user&pass=my_password&trans=my_trans&level=INFO
* </pre>
*
* </p>
* <h3>Parameters</h3>
* <table class="pentaho-table">
* <tbody>
* <tr>
* <th>name</th>
* <th>description</th>
* <th>type</th>
* </tr>
* <tr>
* <td>rep</td>
* <td>Repository id to connect to.</td>
* <td>query</td>
* </tr>
* <tr>
* <td>user</td>
* <td>User name to be used to connect to repository.</td>
* <td>query</td>
* </tr>
* <tr>
* <td>pass</td>
* <td>User password to be used to connect to repository.</td>
* <td>query</td>
* </tr>
* <tr>
* <td>trans</td>
* <td>Transfromation name to be loaded and executed.</td>
* <td>query</td>
* </tr>
* <tr>
* <td>level</td>
* <td>Logging level to be used for transformation execution (i.e. Debug).</td>
* <td>query</td>
* </tr>
* <tr>
* <td>*any name*</td>
* <td>All the other parameters will be sent to the transformation for using as variables.
* When necessary you can add custom parameters to the request.
* They will be used to set the transformation variables values..</td>
* <td>query</td>
* </tr>
* </tbody>
* </table>
*
* <h3>Response Body</h3>
*
* <table class="pentaho-table">
* <tbody>
* <tr>
* <td align="right">element:</td>
* <td>(custom)</td>
* </tr>
* <tr>
* <td align="right">media types:</td>
* <td>application/xml</td>
* </tr>
* </tbody>
* </table>
* <p>Response contains error output of the transformation executed or nothing
* if the execution was successful.</p>
*
* <p><b>Example Error Response:</b></p>
* <pre function="syntax.xml">
* <webresult>
* <result>ERROR</result>
* <message>Unexpected error executing the transformation:
* 
org.pentaho.di.core.exception.KettleException:
* 
Unable to find transformation 'dummy-trans.ktr' in directory
* :/home/admin

 at
* org.pentaho.di.www.ExecuteTransServlet.loadTransformation(ExecuteTransServlet.java:214)

* at org.pentaho.di.www.ExecuteTransServlet.doGet(ExecuteTransServlet.java:104)

* at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)

* at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)

* at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)

* at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)

* at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)

* at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)

* at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)

* at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)

* at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)

* at org.mortbay.jetty.Server.handle(Server.java:326)

* at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:536)

* at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:915)

* at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)

* at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)

* at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:405)

* at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)

* at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

* </message>
* <id/>
* </webresult>
* </pre>
*
* <h3>Status Codes</h3>
* <table class="pentaho-table">
* <tbody>
* <tr>
* <th>code</th>
* <th>description</th>
* </tr>
* <tr>
* <td>200</td>
* <td>Request was processed.</td>
* </tr>
* <tr>
* <td>500</td>
* <td>Internal server error occurs during request processing.</td>
* </tr>
* </tbody>
*</table>
*</div>
*/
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (isJettyMode() && !request.getContextPath().startsWith(CONTEXT_PATH)) {
return;
}
if (log.isDebug()) {
logDebug(BaseMessages.getString(PKG, "ExecuteTransServlet.Log.ExecuteTransRequested"));
}
// Options taken from PAN
//
String[] knownOptions = new String[] { "rep", "user", "pass", "trans", "level" };
String repOption = request.getParameter("rep");
String userOption = request.getParameter("user");
String passOption = Encr.decryptPasswordOptionallyEncrypted(request.getParameter("pass"));
String transOption = request.getParameter("trans");
String levelOption = request.getParameter("level");
response.setStatus(HttpServletResponse.SC_OK);
String encoding = System.getProperty("KETTLE_DEFAULT_SERVLET_ENCODING", null);
if (encoding != null && !Utils.isEmpty(encoding.trim())) {
response.setCharacterEncoding(encoding);
response.setContentType("text/html; charset=" + encoding);
}
PrintWriter out = response.getWriter();
try {
final Repository repository = openRepository(repOption, userOption, passOption);
final TransMeta transMeta = loadTransformation(repository, transOption);
// Set the servlet parameters as variables in the transformation
//
String[] parameters = transMeta.listParameters();
Enumeration<?> parameterNames = request.getParameterNames();
while (parameterNames.hasMoreElements()) {
String parameter = (String) parameterNames.nextElement();
String[] values = request.getParameterValues(parameter);
//
if (Const.indexOfString(parameter, knownOptions) < 0) {
//
if (Const.indexOfString(parameter, parameters) < 0) {
transMeta.setVariable(parameter, values[0]);
} else {
transMeta.setParameterValue(parameter, values[0]);
}
}
}
TransExecutionConfiguration transExecutionConfiguration = new TransExecutionConfiguration();
LogLevel logLevel = LogLevel.getLogLevelForCode(levelOption);
transExecutionConfiguration.setLogLevel(logLevel);
TransConfiguration transConfiguration = new TransConfiguration(transMeta, transExecutionConfiguration);
String carteObjectId = UUID.randomUUID().toString();
SimpleLoggingObject servletLoggingObject = new SimpleLoggingObject(CONTEXT_PATH, LoggingObjectType.CARTE, null);
servletLoggingObject.setContainerObjectId(carteObjectId);
servletLoggingObject.setLogLevel(logLevel);
// Create the transformation and store in the list...
//
final Trans trans = new Trans(transMeta, servletLoggingObject);
trans.setRepository(repository);
trans.setSocketRepository(getSocketRepository());
getTransformationMap().addTransformation(transMeta.getName(), carteObjectId, trans, transConfiguration);
trans.setContainerObjectId(carteObjectId);
if (repository != null) {
// The repository connection is open: make sure we disconnect from the repository once we
// are done with this transformation.
//
trans.addTransListener(new TransAdapter() {
public void transFinished(Trans trans) {
repository.disconnect();
}
});
}
// Pass the servlet print writer to the transformation...
//
trans.setServletPrintWriter(out);
trans.setServletReponse(response);
trans.setServletRequest(request);
try {
// Execute the transformation...
//
executeTrans(trans);
out.flush();
} catch (Exception executionException) {
String logging = KettleLogStore.getAppender().getBuffer(trans.getLogChannelId(), false).toString();
throw new KettleException("Error executing transformation: " + logging, executionException);
}
} catch (Exception ex) {
out.println(new WebResult(WebResult.STRING_ERROR, BaseMessages.getString(PKG, "ExecuteTransServlet.Error.UnexpectedError", Const.CR + Const.getStackTracker(ex))));
}
}
use of org.pentaho.di.core.logging.SimpleLoggingObject in project pentaho-kettle by pentaho.
the class SlaveServerConfig method readAutoSequences.
public void readAutoSequences() throws KettleException {
if (autoSequence == null) {
return;
}
Database database = null;
try {
DatabaseMeta databaseMeta = autoSequence.getDatabaseMeta();
LoggingObjectInterface loggingInterface = new SimpleLoggingObject("auto-sequence", LoggingObjectType.GENERAL, null);
database = new Database(loggingInterface, databaseMeta);
database.connect();
String schemaTable = databaseMeta.getQuotedSchemaTableCombination(autoSequence.getSchemaName(), autoSequence.getTableName());
String seqField = databaseMeta.quoteField(autoSequence.getSequenceNameField());
String valueField = databaseMeta.quoteField(autoSequence.getValueField());
String sql = "SELECT " + seqField + ", " + valueField + " FROM " + schemaTable;
List<Object[]> rows = database.getRows(sql, 0);
RowMetaInterface rowMeta = database.getReturnRowMeta();
for (Object[] row : rows) {
// Automatically create a new sequence for each sequence found...
//
String sequenceName = rowMeta.getString(row, seqField, null);
if (!Utils.isEmpty(sequenceName)) {
Long value = rowMeta.getInteger(row, valueField, null);
if (value != null) {
SlaveSequence slaveSequence = new SlaveSequence(sequenceName, value, databaseMeta, autoSequence.getSchemaName(), autoSequence.getTableName(), autoSequence.getSequenceNameField(), autoSequence.getValueField());
slaveSequences.add(slaveSequence);
LogChannel.GENERAL.logBasic("Automatically created slave sequence '" + slaveSequence.getName() + "' with start value " + slaveSequence.getStartValue());
}
}
}
} catch (Exception e) {
throw new KettleException("Unable to automatically configure slave sequences", e);
} finally {
if (database != null) {
database.disconnect();
}
}
}
use of org.pentaho.di.core.logging.SimpleLoggingObject in project pentaho-kettle by pentaho.
the class StartJobServlet method doGet.
/**
* <div id="mindtouch">
* <h1>/kettle/startJob</h1>
* <a name="GET"></a>
* <h2>GET</h2>
* <p>Starts the job. If the job cannot be started, an error is returned.</p>
*
* <p><b>Example Request:</b><br />
* <pre function="syntax.xml">
* GET /kettle/startJob/?name=dummy_job&xml=Y
* </pre>
*
* </p>
* <h3>Parameters</h3>
* <table class="pentaho-table">
* <tbody>
* <tr>
* <th>name</th>
* <th>description</th>
* <th>type</th>
* </tr>
* <tr>
* <td>name</td>
* <td>Name of the job to be executed.</td>
* <td>query</td>
* </tr>
* <tr>
* <td>xml</td>
* <td>Boolean flag which sets the output format required. Use <code>Y</code> to receive XML response.</td>
* <td>boolean, optional</td>
* </tr>
* <tr>
* <td>id</td>
* <td>Carte job ID of the job to be executed. This parameter is optional when xml=Y is used.</td>
* <td>query, optional</td>
* </tr>
* </tbody>
* </table>
*
* <h3>Response Body</h3>
*
* <table class="pentaho-table">
* <tbody>
* <tr>
* <td align="right">text:</td>
* <td>HTML</td>
* </tr>
* <tr>
* <td align="right">media types:</td>
* <td>text/xml, text/html</td>
* </tr>
* </tbody>
* </table>
* <p>Response XML or HTML containing operation result. When using xml=Y <code>result</code> field indicates whether
* operation was successful (<code>OK</code>) or not (<code>ERROR</code>).</p>
*
* <p><b>Example Response:</b></p>
* <pre function="syntax.xml">
* <?xml version="1.0" encoding="UTF-8"?>
* <webresult>
* <result>OK</result>
* <message>Job [dummy_job] was started.</message>
* <id>abd61143-8174-4f27-9037-6b22fbd3e229</id>
* </webresult>
* </pre>
*
* <h3>Status Codes</h3>
* <table class="pentaho-table">
* <tbody>
* <tr>
* <th>code</th>
* <th>description</th>
* </tr>
* <tr>
* <td>200</td>
* <td>Request was processed.</td>
* </tr>
* <tr>
* <td>500</td>
* <td>Internal server error occurs during request processing.</td>
* </tr>
* </tbody>
* </table>
* </div>
*/
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (isJettyMode() && !request.getContextPath().startsWith(CONTEXT_PATH)) {
return;
}
if (log.isDebug()) {
logDebug(BaseMessages.getString(PKG, "StartJobServlet.Log.StartJobRequested"));
}
String jobName = request.getParameter("name");
String id = request.getParameter("id");
boolean useXML = "Y".equalsIgnoreCase(request.getParameter("xml"));
response.setStatus(HttpServletResponse.SC_OK);
PrintWriter out = response.getWriter();
if (useXML) {
response.setContentType("text/xml");
response.setCharacterEncoding(Const.XML_ENCODING);
out.print(XMLHandler.getXMLHeader(Const.XML_ENCODING));
} else {
response.setContentType("text/html;charset=UTF-8");
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>Start job</TITLE>");
out.println("<META http-equiv=\"Refresh\" content=\"2;url=" + convertContextPath(GetStatusServlet.CONTEXT_PATH) + "?name=" + URLEncoder.encode(jobName, "UTF-8") + "\">");
out.println("<META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">");
out.println("</HEAD>");
out.println("<BODY>");
}
try {
// ID is optional...
//
Job job;
CarteObjectEntry entry;
if (Utils.isEmpty(id)) {
// get the first job that matches...
//
entry = getJobMap().getFirstCarteObjectEntry(jobName);
if (entry == null) {
job = null;
} else {
id = entry.getId();
job = getJobMap().getJob(entry);
}
} else {
// Take the ID into account!
//
entry = new CarteObjectEntry(jobName, id);
job = getJobMap().getJob(entry);
}
if (job != null) {
//
if (job.isInitialized() && !job.isActive()) {
//
if (job.getRep() != null && !job.getRep().isConnected()) {
if (job.getRep().getUserInfo() != null) {
job.getRep().connect(job.getRep().getUserInfo().getLogin(), job.getRep().getUserInfo().getPassword());
} else {
job.getRep().connect(null, null);
}
}
cache.remove(job.getLogChannelId());
//
synchronized (this) {
JobConfiguration jobConfiguration = getJobMap().getConfiguration(jobName);
String carteObjectId = UUID.randomUUID().toString();
SimpleLoggingObject servletLoggingObject = new SimpleLoggingObject(CONTEXT_PATH, LoggingObjectType.CARTE, null);
servletLoggingObject.setContainerObjectId(carteObjectId);
Job newJob = new Job(job.getRep(), job.getJobMeta(), servletLoggingObject);
newJob.setLogLevel(job.getLogLevel());
// Discard old log lines from the old job
//
KettleLogStore.discardLines(job.getLogChannelId(), true);
getJobMap().replaceJob(entry, newJob, jobConfiguration);
job = newJob;
}
}
runJob(job);
String message = BaseMessages.getString(PKG, "StartJobServlet.Log.JobStarted", jobName);
if (useXML) {
out.println(new WebResult(WebResult.STRING_OK, message, id).getXML());
} else {
out.println("<H1>" + Encode.forHtml(message) + "</H1>");
out.println("<a href=\"" + convertContextPath(GetJobStatusServlet.CONTEXT_PATH) + "?name=" + URLEncoder.encode(jobName, "UTF-8") + "&id=" + URLEncoder.encode(id, "UTF-8") + "\">" + BaseMessages.getString(PKG, "JobStatusServlet.BackToJobStatusPage") + "</a><p>");
}
} else {
String message = BaseMessages.getString(PKG, "StartJobServlet.Log.SpecifiedJobNotFound", jobName);
if (useXML) {
out.println(new WebResult(WebResult.STRING_ERROR, message));
} else {
out.println("<H1>" + Encode.forHtml(message) + "</H1>");
out.println("<a href=\"" + convertContextPath(GetStatusServlet.CONTEXT_PATH) + "\">" + BaseMessages.getString(PKG, "TransStatusServlet.BackToStatusPage") + "</a><p>");
}
}
} catch (Exception ex) {
if (useXML) {
out.println(new WebResult(WebResult.STRING_ERROR, BaseMessages.getString(PKG, "StartJobServlet.Error.UnexpectedError", Const.CR + Const.getStackTracker(ex))));
} else {
out.println("<p>");
out.println("<pre>");
out.println(Encode.forHtml(Const.getStackTracker(ex)));
out.println("</pre>");
}
}
if (!useXML) {
out.println("<p>");
out.println("</BODY>");
out.println("</HTML>");
}
}
use of org.pentaho.di.core.logging.SimpleLoggingObject in project pentaho-kettle by pentaho.
the class StartTransServlet method doGet.
/**
* <div id="mindtouch">
* <h1>/kettle/startTrans</h1>
* <a name="GET"></a>
* <h2>GET</h2>
* <p>Executes transformation previously uploaded to Carte server.</p>
*
* <p><b>Example Request:</b><br />
* <pre function="syntax.xml">
* GET /kettle/startTrans/?name=dummy-trans&xml=Y
* </pre>
*
* </p>
* <h3>Parameters</h3>
* <table class="pentaho-table">
* <tbody>
* <tr>
* <th>name</th>
* <th>description</th>
* <th>type</th>
* </tr>
* <tr>
* <td>name</td>
* <td>Name of the transformation to be executed.</td>
* <td>query</td>
* </tr>
* <tr>
* <td>xml</td>
* <td>Boolean flag which sets the output format required. Use <code>Y</code> to receive XML response.</td>
* <td>boolean, optional</td>
* </tr>
* <tr>
* <td>id</td>
* <td>Carte transformation ID of the transformation to be executed. This parameter is optional when xml=Y is used.</td>
* <td>query, optional</td>
* </tr>
* </tbody>
* </table>
*
* <h3>Response Body</h3>
*
* <table class="pentaho-table">
* <tbody>
* <tr>
* <td align="right">text:</td>
* <td>HTML</td>
* </tr>
* <tr>
* <td align="right">media types:</td>
* <td>text/xml, text/html</td>
* </tr>
* </tbody>
* </table>
* <p>Response XML or HTML containing operation result. When using xml=Y <code>result</code> field indicates whether
* operation was successful (<code>OK</code>) or not (<code>ERROR</code>).</p>
*
* <p><b>Example Response:</b></p>
* <pre function="syntax.xml">
* <?xml version="1.0" encoding="UTF-8"?>
* <webresult>
* <result>OK</result>
* <message>Transformation [dummy-trans] was started.</message>
* <id/>
* </webresult>
* </pre>
*
* <h3>Status Codes</h3>
* <table class="pentaho-table">
* <tbody>
* <tr>
* <th>code</th>
* <th>description</th>
* </tr>
* <tr>
* <td>200</td>
* <td>Request was processed.</td>
* </tr>
* <tr>
* <td>500</td>
* <td>Internal server error occurs during request processing.</td>
* </tr>
* </tbody>
* </table>
* </div>
*/
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (isJettyMode() && !request.getContextPath().startsWith(CONTEXT_PATH)) {
return;
}
if (log.isDebug()) {
logDebug(BaseMessages.getString(PKG, "StartTransServlet.Log.StartTransRequested"));
}
String transName = request.getParameter("name");
String id = request.getParameter("id");
if (StringUtils.isEmpty(transName)) {
transName = "";
}
boolean useXML = "Y".equalsIgnoreCase(request.getParameter("xml"));
response.setStatus(HttpServletResponse.SC_OK);
PrintWriter out = response.getWriter();
if (useXML) {
response.setContentType("text/xml");
response.setCharacterEncoding(Const.XML_ENCODING);
out.print(XMLHandler.getXMLHeader(Const.XML_ENCODING));
} else {
response.setContentType("text/html;charset=UTF-8");
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>" + BaseMessages.getString(PKG, "StartTransServlet.Log.StartOfTrans") + "</TITLE>");
out.println("<META http-equiv=\"Refresh\" content=\"2;url=" + convertContextPath(GetTransStatusServlet.CONTEXT_PATH) + "?name=" + URLEncoder.encode(transName, "UTF-8") + "\">");
out.println("<META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">");
out.println("</HEAD>");
out.println("<BODY>");
}
try {
// ID is optional...
//
Trans trans;
CarteObjectEntry entry;
if (Utils.isEmpty(id)) {
// get the first transformation that matches...
//
entry = getTransformationMap().getFirstCarteObjectEntry(transName);
if (entry == null) {
trans = null;
} else {
id = entry.getId();
trans = getTransformationMap().getTransformation(entry);
}
} else {
// Take the ID into account!
//
entry = new CarteObjectEntry(transName, id);
trans = getTransformationMap().getTransformation(entry);
}
if (trans != null) {
cache.remove(trans.getLogChannelId());
// Discard old log lines from old transformation runs
//
KettleLogStore.discardLines(trans.getLogChannelId(), true);
String carteObjectId = UUID.randomUUID().toString();
SimpleLoggingObject servletLoggingObject = new SimpleLoggingObject(CONTEXT_PATH, LoggingObjectType.CARTE, null);
servletLoggingObject.setContainerObjectId(carteObjectId);
servletLoggingObject.setLogLevel(trans.getLogLevel());
trans.setParent(servletLoggingObject);
executeTrans(trans);
String message = BaseMessages.getString(PKG, "StartTransServlet.Log.TransStarted", transName);
if (useXML) {
out.println(new WebResult(WebResult.STRING_OK, message).getXML());
} else {
out.println("<H1>" + Encode.forHtml(message) + "</H1>");
out.println("<a href=\"" + convertContextPath(GetTransStatusServlet.CONTEXT_PATH) + "?name=" + URLEncoder.encode(transName, "UTF-8") + "&id=" + URLEncoder.encode(id, "UTF-8") + "\">" + BaseMessages.getString(PKG, "TransStatusServlet.BackToStatusPage") + "</a><p>");
}
} else {
String message = BaseMessages.getString(PKG, "TransStatusServlet.Log.CoundNotFindSpecTrans", transName);
if (useXML) {
out.println(new WebResult(WebResult.STRING_ERROR, message, id));
} else {
out.println("<H1>" + Encode.forHtml(message) + "</H1>");
out.println("<a href=\"" + convertContextPath(GetStatusServlet.CONTEXT_PATH) + "\">" + BaseMessages.getString(PKG, "TransStatusServlet.BackToStatusPage") + "</a><p>");
}
}
} catch (Exception ex) {
if (useXML) {
out.println(new WebResult(WebResult.STRING_ERROR, BaseMessages.getString(PKG, "StartTransServlet.Error.UnexpectedError", Const.CR + Const.getStackTracker(ex))));
} else {
out.println("<p>");
out.println("<pre>");
out.println(Encode.forHtml(Const.getStackTracker(ex)));
out.println("</pre>");
}
}
if (!useXML) {
out.println("<p>");
out.println("</BODY>");
out.println("</HTML>");
}
}
use of org.pentaho.di.core.logging.SimpleLoggingObject in project pentaho-kettle by pentaho.
the class JobResource method addJob.
@PUT
@Path("/add")
@Produces({ MediaType.APPLICATION_JSON })
public JobStatus addJob(String xml) {
// Parse the XML, create a job configuration
//
// System.out.println(xml);
//
JobConfiguration jobConfiguration;
try {
jobConfiguration = JobConfiguration.fromXML(xml.toString());
JobMeta jobMeta = jobConfiguration.getJobMeta();
JobExecutionConfiguration jobExecutionConfiguration = jobConfiguration.getJobExecutionConfiguration();
jobMeta.setLogLevel(jobExecutionConfiguration.getLogLevel());
jobMeta.injectVariables(jobExecutionConfiguration.getVariables());
// If there was a repository, we know about it at this point in time.
//
final Repository repository = jobConfiguration.getJobExecutionConfiguration().getRepository();
String carteObjectId = UUID.randomUUID().toString();
SimpleLoggingObject servletLoggingObject = new SimpleLoggingObject(getClass().getName(), LoggingObjectType.CARTE, null);
servletLoggingObject.setContainerObjectId(carteObjectId);
servletLoggingObject.setLogLevel(jobExecutionConfiguration.getLogLevel());
// Create the transformation and store in the list...
//
final Job job = new Job(repository, jobMeta, servletLoggingObject);
// Setting variables
//
job.initializeVariablesFrom(null);
job.getJobMeta().setInternalKettleVariables(job);
job.injectVariables(jobConfiguration.getJobExecutionConfiguration().getVariables());
job.setArguments(jobExecutionConfiguration.getArgumentStrings());
// Also copy the parameters over...
//
job.copyParametersFrom(jobMeta);
job.clearParameters();
String[] parameterNames = job.listParameters();
for (int idx = 0; idx < parameterNames.length; idx++) {
// Grab the parameter value set in the job entry
//
String thisValue = jobExecutionConfiguration.getParams().get(parameterNames[idx]);
if (!Utils.isEmpty(thisValue)) {
// Set the value as specified by the user in the job entry
//
jobMeta.setParameterValue(parameterNames[idx], thisValue);
}
}
jobMeta.activateParameters();
job.setSocketRepository(CarteSingleton.getInstance().getSocketRepository());
CarteSingleton.getInstance().getJobMap().addJob(job.getJobname(), carteObjectId, job, jobConfiguration);
//
if (repository != null) {
job.addJobListener(new JobAdapter() {
public void jobFinished(Job job) {
repository.disconnect();
}
});
}
return getJobStatus(carteObjectId);
} catch (KettleException e) {
e.printStackTrace();
}
return null;
}
Aggregations