use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.
the class BaseJobServlet method copyJobParameters.
private void copyJobParameters(Job job, Map<String, String> params) throws UnknownParamException {
JobMeta jobMeta = job.getJobMeta();
// Also copy the parameters over...
job.copyParametersFrom(jobMeta);
job.clearParameters();
String[] parameterNames = job.listParameters();
for (String parameterName : parameterNames) {
// Grab the parameter value set in the job entry
String thisValue = params.get(parameterName);
if (!StringUtils.isBlank(thisValue)) {
// Set the value as specified by the user in the job entry
jobMeta.setParameterValue(parameterName, thisValue);
}
}
jobMeta.activateParameters();
}
use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.
the class ExecuteJobServlet method loadJob.
private JobMeta loadJob(Repository repository, String job) throws KettleException {
if (repository == null) {
// Without a repository it's a filename --> file:///foo/bar/job.kjb
//
JobMeta jobMeta = new JobMeta(job, repository);
return jobMeta;
} else {
// With a repository we need to load it from /foo/bar/Job
// We need to extract the folder name from the path in front of the name...
//
String directoryPath;
String name;
int lastSlash = job.lastIndexOf(RepositoryDirectory.DIRECTORY_SEPARATOR);
if (lastSlash < 0) {
directoryPath = "/";
name = job;
} else {
directoryPath = job.substring(0, lastSlash);
name = job.substring(lastSlash + 1);
}
RepositoryDirectoryInterface directory = repository.loadRepositoryDirectoryTree().findDirectory(directoryPath);
if (directory == null) {
throw new KettleException("Unable to find directory path '" + directoryPath + "' in the repository");
}
ObjectId jobID = repository.getJobId(name, directory);
if (jobID == null) {
throw new KettleException("Unable to find job '" + name + "' in directory :" + directory);
}
JobMeta jobMeta = repository.loadJob(jobID, null);
return jobMeta;
}
}
use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.
the class RegisterPackageServlet method generateBody.
@Override
WebResult generateBody(HttpServletRequest request, HttpServletResponse response, boolean useXML) throws KettleException, IOException {
FileObject tempFile = KettleVFS.createTempFile("export", ".zip", System.getProperty("java.io.tmpdir"));
OutputStream out = KettleVFS.getOutputStream(tempFile, false);
IOUtils.copy(request.getInputStream(), out);
out.flush();
IOUtils.closeQuietly(out);
String archiveUrl = tempFile.getName().toString();
// the resource to load
String load = request.getParameter(PARAMETER_LOAD);
if (!Utils.isEmpty(load)) {
String fileUrl = MessageFormat.format(ZIP_CONT, archiveUrl, load);
boolean isJob = TYPE_JOB.equalsIgnoreCase(request.getParameter(PARAMETER_TYPE));
String resultId;
if (isJob) {
Node node = getConfigNodeFromZIP(archiveUrl, Job.CONFIGURATION_IN_EXPORT_FILENAME, JobExecutionConfiguration.XML_TAG);
JobExecutionConfiguration jobExecutionConfiguration = new JobExecutionConfiguration(node);
JobMeta jobMeta = new JobMeta(fileUrl, jobExecutionConfiguration.getRepository());
JobConfiguration jobConfiguration = new JobConfiguration(jobMeta, jobExecutionConfiguration);
Job job = createJob(jobConfiguration);
resultId = job.getContainerObjectId();
} else {
Node node = getConfigNodeFromZIP(archiveUrl, Trans.CONFIGURATION_IN_EXPORT_FILENAME, TransExecutionConfiguration.XML_TAG);
TransExecutionConfiguration transExecutionConfiguration = new TransExecutionConfiguration(node);
TransMeta transMeta = new TransMeta(fileUrl, transExecutionConfiguration.getRepository());
TransConfiguration transConfiguration = new TransConfiguration(transMeta, transExecutionConfiguration);
Trans trans = createTrans(transConfiguration);
resultId = trans.getContainerObjectId();
}
return new WebResult(WebResult.STRING_OK, fileUrl, resultId);
}
return null;
}
use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.
the class Spoon method shareObject.
protected void shareObject(SharedObjectInterface sharedObject) {
sharedObject.setShared(true);
EngineMetaInterface meta = getActiveMeta();
try {
if (meta != null) {
SharedObjects sharedObjects = null;
if (meta instanceof TransMeta) {
sharedObjects = ((TransMeta) meta).getSharedObjects();
}
if (meta instanceof JobMeta) {
sharedObjects = ((JobMeta) meta).getSharedObjects();
}
if (sharedObjects != null) {
sharedObjects.storeObject(sharedObject);
sharedObjects.saveToFile();
}
}
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.ErrorWritingSharedObjects.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorWritingSharedObjects.Message"), e);
}
refreshTree();
}
use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.
the class Spoon method deleteJobEntryCopies.
public void deleteJobEntryCopies() {
final JobMeta jobMeta = (JobMeta) selectionObjectParent;
final JobEntryCopy jobEntry = (JobEntryCopy) selectionObject;
deleteJobEntryCopies(jobMeta, jobEntry);
}
Aggregations