use of org.knime.workbench.workflowcoach.data.UpdatableNodeTripleProvider in project knime-core by knime.
the class UpdateJob method run.
/**
* {@inheritDoc}
*/
@Override
protected IStatus run(final IProgressMonitor monitor) {
Exception exception = null;
for (UpdatableNodeTripleProvider ntp : m_providers) {
try {
ntp.update();
} catch (Exception e) {
if (exception == null) {
exception = e;
}
}
}
monitor.done();
if (exception == null) {
m_listener.updateFinished(Optional.empty());
return Status.OK_STATUS;
} else {
m_listener.updateFinished(Optional.of(exception));
// don't return IStatus.ERROR -> otherwise an annoying error message will be opened
return new Status(IStatus.OK, FrameworkUtil.getBundle(getClass()).getSymbolicName(), "Error while updating the statistics for the node recommendations (Workflow Coach).", exception);
}
}
use of org.knime.workbench.workflowcoach.data.UpdatableNodeTripleProvider in project knime-core by knime.
the class WorkflowCoachPreferencePage method onUpate.
/**
* Called when the update button has been pressed.
*/
private void onUpate() {
Display.getDefault().syncExec(() -> {
m_updateButton.setEnabled(false);
m_lastUpdate.setText("Updating ...");
m_lastUpdate.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
setValid(false);
});
// update the currently enabled providers
List<UpdatableNodeTripleProvider> toUpdate = new ArrayList<>();
for (NodeTripleProvider ntp : NodeRecommendationManager.getInstance().getNodeTripleProviders()) {
if (m_checkCommunityProvider.getSelection() && (ntp instanceof CommunityTripleProvider)) {
toUpdate.add((CommunityTripleProvider) ntp);
}
}
UpdateJob.schedule(e -> {
if (e.isPresent()) {
Display.getDefault().syncExec(() -> {
m_updateButton.setEnabled(true);
m_lastUpdate.setText("Update failed.");
setErrorMessage("Error loading the community node recommendations:" + e.get().getMessage() + ". Please check your internet connection.");
if (!m_checkCommunityProvider.getSelection()) {
setValid(true);
}
});
} else {
Display.getDefault().syncExec(() -> {
m_updateButton.setEnabled(true);
m_lastUpdate.setText("Update finished!");
setValid(true);
setErrorMessage(null);
});
}
}, toUpdate, false);
}
use of org.knime.workbench.workflowcoach.data.UpdatableNodeTripleProvider in project knime-core by knime.
the class WorkflowCoachView method updateTripleProviders.
/**
* Updates all updatable and enabled triple providers.
*
* @param requiredOnly if only the enabled triple providers should be updated that require an update in order to
* work
* @param updateListener to get feedback of the updating process
* @param block if <code>true</code> the method will block till the update is finished, otherwise it will return
* immediately after triggering the update job
*/
private void updateTripleProviders(final UpdateListener updateListener, final boolean requiredOnly, final boolean block) {
List<UpdatableNodeTripleProvider> toUpdate = NodeRecommendationManager.getInstance().getNodeTripleProviders().stream().filter(ntp -> {
if (!(ntp instanceof UpdatableNodeTripleProvider)) {
return false;
} else {
UpdatableNodeTripleProvider untp = (UpdatableNodeTripleProvider) ntp;
return ntp.isEnabled() && (!requiredOnly || untp.updateRequired());
}
}).map(ntp -> (UpdatableNodeTripleProvider) ntp).collect(Collectors.toList());
UpdateJob.schedule(updateListener, toUpdate, block);
}
Aggregations