private void getParameters(TransMeta inputTransMeta) { try { if (inputTransMeta == null) { JobEntryTrans jet = new JobEntryTrans(); getInfo(jet); inputTransMeta = jet.getTransMeta(rep, metaStore, jobMeta); } String[] parameters = inputTransMeta.listParameters(); String[] existing = wParameters.getItems(1); for (int i = 0; i < parameters.length; i++) { if (Const.indexOfString(parameters[i], existing) < 0) { TableItem item = new TableItem(wParameters.table, SWT.NONE); item.setText(1, parameters[i]); } } wParameters.removeEmptyRows(); wParameters.setRowNums(); wParameters.optWidth(true); } catch (Exception e) { new ErrorDialog( shell, BaseMessages.getString( PKG, "JobEntryTransDialog.Exception.UnableToLoadTransformation.Title"), BaseMessages.getString( PKG, "JobEntryTransDialog.Exception.UnableToLoadTransformation.Message"), e); } }
private void patchJobEntries(JobMeta jobMeta) { for (JobEntryCopy copy : jobMeta.getJobCopies()) { if (copy.isTransformation()) { JobEntryTrans entry = (JobEntryTrans) copy.getEntry(); if (entry.getSpecificationMethod() == ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME) { if (transDirOverride != null) { entry.setDirectory(transDirOverride); continue; } String entryPath = resolvePath(baseDirectory.getPath(), entry.getDirectory()); entry.setDirectory(entryPath); } } if (copy.isJob()) { JobEntryJob entry = (JobEntryJob) copy.getEntry(); if (entry.getSpecificationMethod() == ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME) { if (jobDirOverride != null) { entry.setDirectory(jobDirOverride); continue; } String entryPath = resolvePath(baseDirectory.getPath(), entry.getDirectory()); entry.setDirectory(entryPath); } } } }
private JobMeta processLinkedTrans(JobMeta jobMeta) { for (int i = 0; i < jobMeta.nrJobEntries(); i++) { JobEntryCopy jec = jobMeta.getJobEntry(i); if (jec.getEntry() instanceof JobEntryTrans) { JobEntryTrans jet = (JobEntryTrans) jec.getEntry(); jet.setSpecificationMethod(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME); String filename = jet.getFilename(); String jobname = filename.substring(filename.lastIndexOf("/") + 1, filename.lastIndexOf('.')); String directory = filename.substring(0, filename.lastIndexOf("/")); jet.setTransname(jobname); jet.setDirectory(directory); jobMeta.setJobEntry(i, jec); } } return jobMeta; }
public void getUsedArguments( JobMeta jobMeta, String[] commandLineArguments, IMetaStore metaStore) { for (JobEntryCopy jobEntryCopy : jobMeta.jobcopies) { if (jobEntryCopy.isTransformation()) { JobEntryTrans jobEntryTrans = (JobEntryTrans) jobEntryCopy.getEntry(); try { TransMeta transMeta = jobEntryTrans.getTransMeta(repository, metaStore, jobMeta); Map<String, String> map = transMeta.getUsedArguments(commandLineArguments); for (String key : map.keySet()) { String value = map.get(key); if (!arguments.containsKey(key)) { arguments.put(key, value); } } } catch (KettleException ke) { log.logBasic(ke.getMessage(), ke); } } } }
protected void ok() { if (Utils.isEmpty(wName.getText())) { MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR); mb.setText(BaseMessages.getString(PKG, "System.StepJobEntryNameMissing.Title")); mb.setMessage(BaseMessages.getString(PKG, "System.JobEntryNameMissing.Msg")); mb.open(); return; } jobEntry.setName(wName.getText()); try { getInfo(jobEntry); jobEntry.setChanged(); dispose(); } catch (KettleException e) { new ErrorDialog( shell, BaseMessages.getString(PKG, "JobTrans.Dialog.ErrorShowingTransformation.Title"), BaseMessages.getString(PKG, "JobTrans.Dialog.ErrorShowingTransformation.Message"), e); } }
public JobEntryInterface open() { Shell parent = getParent(); display = parent.getDisplay(); shell = new Shell(parent, props.getJobsDialogStyle()); props.setLook(shell); JobDialog.setShellImage(shell, jobEntry); backupChanged = jobEntry.hasChanged(); createElements(); // Detect [X] or ALT-F4 or something that kills this window... shell.addShellListener( new ShellAdapter() { public void shellClosed(ShellEvent e) { cancel(); } }); getData(); setActive(); BaseStepDialog.setSize(shell); int width = 750; int height = Const.isWindows() ? 730 : 720; shell.setSize(width, height); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return jobEntry; }
private void getInfo(JobEntryTrans jet) throws KettleException { jet.setName(wName.getText()); if (rep != null) { specificationMethod = ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME; } else { specificationMethod = ObjectLocationSpecificationMethod.FILENAME; } jet.setSpecificationMethod(specificationMethod); switch (specificationMethod) { case FILENAME: jet.setFileName(wPath.getText()); if (jet.getFilename().isEmpty()) { throw new KettleException( BaseMessages.getString(PKG, "JobTrans.Dialog.Exception.NoValidMappingDetailsFound")); } jet.setDirectory(null); jet.setTransname(null); jet.setTransObjectId(null); break; case REPOSITORY_BY_NAME: String transPath = wPath.getText(); String transName = transPath; String directory = ""; int index = transPath.lastIndexOf("/"); if (index != -1) { transName = transPath.substring(index + 1); directory = transPath.substring(0, index); } jet.setDirectory(directory); if (jet.getDirectory().isEmpty()) { throw new KettleException( BaseMessages.getString( PKG, "JobTrans.Dialog.Exception.UnableToFindRepositoryDirectory")); } jet.setTransname(transName); jet.setFileName(null); jet.setTransObjectId(null); break; default: break; } int nritems = wFields.nrNonEmpty(); int nr = 0; for (int i = 0; i < nritems; i++) { String arg = wFields.getNonEmpty(i).getText(1); if (arg != null && arg.length() != 0) { nr++; } } jet.arguments = new String[nr]; nr = 0; for (int i = 0; i < nritems; i++) { String arg = wFields.getNonEmpty(i).getText(1); if (arg != null && arg.length() != 0) { jet.arguments[nr] = arg; nr++; } } // Do the parameters nritems = wParameters.nrNonEmpty(); nr = 0; for (int i = 0; i < nritems; i++) { String param = wParameters.getNonEmpty(i).getText(1); if (param != null && param.length() != 0) { nr++; } } jet.parameters = new String[nr]; jet.parameterFieldNames = new String[nr]; jet.parameterValues = new String[nr]; nr = 0; for (int i = 0; i < nritems; i++) { String param = wParameters.getNonEmpty(i).getText(1); String fieldName = wParameters.getNonEmpty(i).getText(2); String value = wParameters.getNonEmpty(i).getText(3); jet.parameters[nr] = param; if (!Utils.isEmpty(Const.trim(fieldName))) { jet.parameterFieldNames[nr] = fieldName; } else { jet.parameterFieldNames[nr] = ""; } if (!Utils.isEmpty(Const.trim(value))) { jet.parameterValues[nr] = value; } else { jet.parameterValues[nr] = ""; } nr++; } jet.setPassingAllParameters(wPassParams.getSelection()); jet.logfile = wLogfile.getText(); jet.logext = wLogext.getText(); if (wLoglevel.getSelectionIndex() >= 0) { jet.logFileLevel = LogLevel.values()[wLoglevel.getSelectionIndex()]; } else { jet.logFileLevel = LogLevel.BASIC; } jet.argFromPrevious = wPrevious.getSelection(); jet.paramsFromPrevious = wPrevToParams.getSelection(); jet.execPerRow = wEveryRow.getSelection(); jet.setLogfile = wSetLogfile.getSelection(); jet.addDate = wAddDate.getSelection(); jet.addTime = wAddTime.getSelection(); jet.clearResultRows = wClearRows.getSelection(); jet.clearResultFiles = wClearFiles.getSelection(); jet.setClustering(wCluster.getSelection()); jet.setLoggingRemoteWork(wLogRemoteWork.getSelection()); jet.createParentFolder = wCreateParentFolder.getSelection(); jet.setRemoteSlaveServerName(wSlaveServer.getText()); jet.setAppendLogfile = wAppendLogfile.getSelection(); jet.setWaitingToFinish(wWaitingToFinish.getSelection()); jet.setFollowingAbortRemotely(wFollowingAbortRemotely.getSelection()); }
protected void cancel() { jobEntry.setChanged(backupChanged); jobEntry = null; dispose(); }
public void getData() { wName.setText(Const.NVL(jobEntry.getName(), "")); specificationMethod = jobEntry.getSpecificationMethod(); switch (specificationMethod) { case FILENAME: wPath.setText(Const.NVL(jobEntry.getFilename(), "")); break; case REPOSITORY_BY_NAME: String fullPath = Const.NVL(jobEntry.getDirectory(), "") + "/" + Const.NVL(jobEntry.getTransname(), ""); wPath.setText(fullPath); break; case REPOSITORY_BY_REFERENCE: referenceObjectId = jobEntry.getTransObjectId(); if (rep != null && jobEntry.getTransObjectId() != null) { getByReferenceData(jobEntry.getTransObjectId()); } break; default: break; } // Arguments if (jobEntry.arguments != null) { for (int i = 0; i < jobEntry.arguments.length; i++) { TableItem ti = wFields.table.getItem(i); if (jobEntry.arguments[i] != null) { ti.setText(1, jobEntry.arguments[i]); } } wFields.setRowNums(); wFields.optWidth(true); } // Parameters if (jobEntry.parameters != null) { for (int i = 0; i < jobEntry.parameters.length; i++) { TableItem ti = wParameters.table.getItem(i); if (!Utils.isEmpty(jobEntry.parameters[i])) { ti.setText(1, Const.NVL(jobEntry.parameters[i], "")); ti.setText(2, Const.NVL(jobEntry.parameterFieldNames[i], "")); ti.setText(3, Const.NVL(jobEntry.parameterValues[i], "")); } } wParameters.setRowNums(); wParameters.optWidth(true); } wPassParams.setSelection(jobEntry.isPassingAllParameters()); if (jobEntry.logfile != null) { wLogfile.setText(jobEntry.logfile); } if (jobEntry.logext != null) { wLogext.setText(jobEntry.logext); } wPrevious.setSelection(jobEntry.argFromPrevious); wPrevToParams.setSelection(jobEntry.paramsFromPrevious); wEveryRow.setSelection(jobEntry.execPerRow); wSetLogfile.setSelection(jobEntry.setLogfile); wAddDate.setSelection(jobEntry.addDate); wAddTime.setSelection(jobEntry.addTime); wClearRows.setSelection(jobEntry.clearResultRows); wClearFiles.setSelection(jobEntry.clearResultFiles); if (jobEntry.isClustering()) { wCluster.setSelection(true); } else if (jobEntry.getRemoteSlaveServerName() != null && !Utils.isEmpty(jobEntry.getRemoteSlaveServerName())) { wbServer.setSelection(true); } else { wbLocal.setSelection(true); } wLogRemoteWork.setSelection(jobEntry.isLoggingRemoteWork()); if (jobEntry.getRemoteSlaveServerName() != null) { wSlaveServer.setText(jobEntry.getRemoteSlaveServerName()); } wWaitingToFinish.setSelection(jobEntry.isWaitingToFinish()); wFollowingAbortRemotely.setSelection(jobEntry.isFollowingAbortRemotely()); wAppendLogfile.setSelection(jobEntry.setAppendLogfile); wbLogFilename.setSelection(jobEntry.setAppendLogfile); wCreateParentFolder.setSelection(jobEntry.createParentFolder); if (jobEntry.logFileLevel != null) { wLoglevel.select(jobEntry.logFileLevel.getLevel()); } }