use of org.pentaho.di.job.entries.missing.MissingEntry in project pentaho-kettle by pentaho.
the class JobMeta method removeJobEntry.
/**
* Removes the job entry.
*
* @param i the i
*/
public void removeJobEntry(int i) {
JobEntryCopy deleted = jobcopies.remove(i);
if (deleted != null) {
// give step a chance to cleanup
deleted.setParentJobMeta(null);
if (deleted.getEntry() instanceof MissingEntry) {
removeMissingEntry((MissingEntry) deleted.getEntry());
}
}
setChanged();
}
use of org.pentaho.di.job.entries.missing.MissingEntry in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryJobEntryDelegate method loadJobEntryCopy.
/**
* Load the chef graphical entry from repository We load type, name & description if no entry can be found.
*
* @param log
* the logging channel
* @param rep
* the Repository
* @param jobId
* The job ID
* @param jobEntryCopyId
* The jobentry copy ID
* @param jobentries
* A list with all jobentries
* @param databases
* A list with all defined databases
*/
public JobEntryCopy loadJobEntryCopy(ObjectId jobId, ObjectId jobEntryCopyId, List<JobEntryInterface> jobentries, List<DatabaseMeta> databases, List<SlaveServer> slaveServers, String jobname) throws KettleException {
JobEntryCopy jobEntryCopy = new JobEntryCopy();
try {
jobEntryCopy.setObjectId(jobEntryCopyId);
// Handle GUI information: nr, location, ...
RowMetaAndData r = getJobEntryCopy(jobEntryCopyId);
if (r != null) {
// These are the jobentry_copy fields...
//
ObjectId jobEntryId = new LongObjectId(r.getInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_ID_JOBENTRY, 0));
ObjectId jobEntryTypeId = new LongObjectId(r.getInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_ID_JOBENTRY_TYPE, 0));
jobEntryCopy.setNr((int) r.getInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_NR, 0));
int locx = (int) r.getInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_GUI_LOCATION_X, 0);
int locy = (int) r.getInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_GUI_LOCATION_Y, 0);
boolean isdrawn = r.getBoolean(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_GUI_DRAW, false);
boolean isparallel = r.getBoolean(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_PARALLEL, false);
// Do we have the jobentry already?
//
jobEntryCopy.setEntry(JobMeta.findJobEntry(jobentries, jobEntryId));
if (jobEntryCopy.getEntry() == null) {
// What type of jobentry do we load now?
// Get the jobentry type code
//
RowMetaAndData rt = getJobEntryType(new LongObjectId(jobEntryTypeId));
if (rt != null) {
String jet_code = rt.getString(KettleDatabaseRepository.FIELD_JOBENTRY_TYPE_CODE, null);
JobEntryInterface jobEntry = null;
PluginRegistry registry = PluginRegistry.getInstance();
PluginInterface jobPlugin = registry.findPluginWithId(JobEntryPluginType.class, jet_code);
if (jobPlugin == null) {
jobEntry = new MissingEntry(jobname, jet_code);
} else {
jobEntry = (JobEntryInterface) registry.loadClass(jobPlugin);
}
if (jobEntry != null) {
jobEntryCopy.setEntry(jobEntry);
//
if (jobEntry instanceof JobEntryBase) {
loadJobEntryBase((JobEntryBase) jobEntry, jobEntryId, databases, slaveServers);
((JobEntryBase) jobEntry).setAttributesMap(loadJobEntryAttributesMap(jobId, jobEntryId));
}
compatibleJobEntryLoadRep(jobEntry, repository, jobEntryTypeId, databases, slaveServers);
jobEntry.loadRep(repository, repository.metaStore, jobEntryId, databases, slaveServers);
jobEntryCopy.getEntry().setObjectId(jobEntryId);
jobentries.add(jobEntryCopy.getEntry());
} else {
throw new KettleException("JobEntryLoader was unable to find Job Entry Plugin with description [" + jet_code + "].");
}
} else {
throw new KettleException("Unable to find Job Entry Type with id=" + jobEntryTypeId + " in the repository");
}
}
jobEntryCopy.setLocation(locx, locy);
jobEntryCopy.setDrawn(isdrawn);
jobEntryCopy.setLaunchingInParallel(isparallel);
return jobEntryCopy;
} else {
throw new KettleException("Unable to find job entry copy in repository with id_jobentry_copy=" + jobEntryCopyId);
}
} catch (KettleDatabaseException dbe) {
throw new KettleException("Unable to load job entry copy from repository with id_jobentry_copy=" + jobEntryCopyId, dbe);
}
}
use of org.pentaho.di.job.entries.missing.MissingEntry in project pentaho-kettle by pentaho.
the class JobDelegate method readJobEntry.
protected JobEntryInterface readJobEntry(DataNode copyNode, JobMeta jobMeta, List<JobEntryInterface> jobentries) throws KettleException {
try {
String name = getString(copyNode, PROP_NAME);
for (JobEntryInterface entry : jobentries) {
if (entry.getName().equalsIgnoreCase(name)) {
// already loaded!
return entry;
}
}
// load the entry from the node
//
String typeId = getString(copyNode, PROP_JOBENTRY_TYPE);
PluginRegistry registry = PluginRegistry.getInstance();
PluginInterface jobPlugin = registry.findPluginWithId(JobEntryPluginType.class, typeId);
JobEntryInterface jobMetaInterface = null;
boolean isMissing = jobPlugin == null;
if (!isMissing) {
jobMetaInterface = (JobEntryInterface) registry.loadClass(jobPlugin);
} else {
MissingEntry missingEntry = new MissingEntry(jobMeta.getName(), typeId);
jobMeta.addMissingEntry(missingEntry);
jobMetaInterface = missingEntry;
}
jobMetaInterface.setName(name);
jobMetaInterface.setDescription(getString(copyNode, PROP_DESCRIPTION));
jobMetaInterface.setObjectId(new StringObjectId(copyNode.getId().toString()));
RepositoryProxy proxy = new RepositoryProxy(copyNode.getNode(NODE_CUSTOM));
// make sure metastore is passed
jobMetaInterface.setMetaStore(jobMeta.getMetaStore());
if (!isMissing) {
compatibleJobEntryLoadRep(jobMetaInterface, proxy, null, jobMeta.getDatabases(), jobMeta.getSlaveServers());
jobMetaInterface.loadRep(proxy, jobMeta.getMetaStore(), null, jobMeta.getDatabases(), jobMeta.getSlaveServers());
}
jobentries.add(jobMetaInterface);
return jobMetaInterface;
} catch (Exception e) {
throw new KettleException("Unable to read job entry interface information from repository", e);
}
}
use of org.pentaho.di.job.entries.missing.MissingEntry in project pentaho-kettle by pentaho.
the class MissingEntryDialog method open.
public JobEntryInterface open() {
this.props = PropsUI.getInstance();
Display display = shellParent.getDisplay();
int margin = Const.MARGIN;
shell = new Shell(shellParent, SWT.DIALOG_TRIM | SWT.CLOSE | SWT.ICON | SWT.APPLICATION_MODAL);
props.setLook(shell);
shell.setImage(GUIResource.getInstance().getImageSpoon());
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginLeft = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setText(BaseMessages.getString(PKG, "MissingEntryDialog.MissingPlugins"));
shell.setLayout(formLayout);
Label image = new Label(shell, SWT.NONE);
props.setLook(image);
Image icon = display.getSystemImage(SWT.ICON_QUESTION);
image.setImage(icon);
FormData imageData = new FormData();
imageData.left = new FormAttachment(0, 5);
imageData.right = new FormAttachment(11, 0);
imageData.top = new FormAttachment(0, 10);
image.setLayoutData(imageData);
Label error = new Label(shell, SWT.WRAP);
props.setLook(error);
error.setText(getErrorMessage(missingEntries, mode));
FormData errorData = new FormData();
errorData.left = new FormAttachment(image, 5);
errorData.right = new FormAttachment(100, -5);
errorData.top = new FormAttachment(0, 10);
error.setLayoutData(errorData);
Label separator = new Label(shell, SWT.WRAP);
props.setLook(separator);
FormData separatorData = new FormData();
separatorData.top = new FormAttachment(error, 10);
separator.setLayoutData(separatorData);
Button closeButton = new Button(shell, SWT.PUSH);
props.setLook(closeButton);
FormData fdClose = new FormData();
fdClose.right = new FormAttachment(98);
fdClose.top = new FormAttachment(separator);
closeButton.setLayoutData(fdClose);
closeButton.setText(BaseMessages.getString(PKG, "MissingEntryDialog.Close"));
closeButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
shell.dispose();
jobEntryResult = null;
}
});
FormData fdSearch = new FormData();
if (this.mode == MISSING_JOB_ENTRIES) {
Button openButton = new Button(shell, SWT.PUSH);
props.setLook(openButton);
FormData fdOpen = new FormData();
fdOpen.right = new FormAttachment(closeButton, -5);
fdOpen.bottom = new FormAttachment(closeButton, 0, SWT.BOTTOM);
openButton.setLayoutData(fdOpen);
openButton.setText(BaseMessages.getString(PKG, "MissingEntryDialog.OpenFile"));
openButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
shell.dispose();
jobEntryResult = new MissingEntry();
}
});
fdSearch.right = new FormAttachment(openButton, -5);
fdSearch.bottom = new FormAttachment(openButton, 0, SWT.BOTTOM);
} else {
fdSearch.right = new FormAttachment(closeButton, -5);
fdSearch.bottom = new FormAttachment(closeButton, 0, SWT.BOTTOM);
}
Button searchButton = new Button(shell, SWT.PUSH);
props.setLook(searchButton);
searchButton.setText(BaseMessages.getString(PKG, "MissingEntryDialog.SearchMarketplace"));
searchButton.setLayoutData(fdSearch);
searchButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
try {
shell.dispose();
Spoon.getInstance().openMarketplace();
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return jobEntryResult;
}
use of org.pentaho.di.job.entries.missing.MissingEntry in project pentaho-kettle by pentaho.
the class MissingEntryDialog method getErrorMessage.
private String getErrorMessage(List<MissingEntry> missingEntries, int mode) {
String message = "";
if (mode == MISSING_JOB_ENTRIES) {
StringBuilder entries = new StringBuilder();
for (MissingEntry entry : missingEntries) {
if (missingEntries.indexOf(entry) == missingEntries.size() - 1) {
entries.append("- " + entry.getName() + " - " + entry.getMissingPluginId() + "\n\n");
} else {
entries.append("- " + entry.getName() + " - " + entry.getMissingPluginId() + "\n");
}
}
message = BaseMessages.getString(PKG, "MissingEntryDialog.MissingJobEntries", entries.toString());
}
if (mode == MISSING_JOB_ENTRY_ID) {
message = BaseMessages.getString(PKG, "MissingEntryDialog.MissingJobEntryId", jobEntryInt.getName() + " - " + ((MissingEntry) jobEntryInt).getMissingPluginId());
}
return message;
}
Aggregations