use of org.pentaho.di.ui.core.dialog.EnterSearchDialog in project pentaho-kettle by pentaho.
the class Spoon method searchMetaData.
/**
* Search the transformation meta-data.
*/
public void searchMetaData() {
TransMeta[] transMetas = getLoadedTransformations();
JobMeta[] jobMetas = getLoadedJobs();
if ((transMetas == null || transMetas.length == 0) && (jobMetas == null || jobMetas.length == 0)) {
return;
}
EnterSearchDialog esd = new EnterSearchDialog(shell);
if (!esd.open()) {
return;
}
List<Object[]> rows = new ArrayList<>();
for (TransMeta transMeta : transMetas) {
String filter = esd.getFilterString();
if (filter != null) {
filter = filter.toUpperCase();
}
List<StringSearchResult> stringList = transMeta.getStringList(esd.isSearchingSteps(), esd.isSearchingDatabases(), esd.isSearchingNotes());
for (StringSearchResult result : stringList) {
boolean add = Utils.isEmpty(filter);
if (filter != null && result.getString().toUpperCase().contains(filter)) {
add = true;
}
if (filter != null && result.getFieldName().toUpperCase().contains(filter)) {
add = true;
}
if (filter != null && result.getParentObject().toString().toUpperCase().contains(filter)) {
add = true;
}
if (filter != null && result.getGrandParentObject().toString().toUpperCase().contains(filter)) {
add = true;
}
if (add) {
rows.add(result.toRow());
}
}
}
for (JobMeta jobMeta : jobMetas) {
String filter = esd.getFilterString();
if (filter != null) {
filter = filter.toUpperCase();
}
List<StringSearchResult> stringList = jobMeta.getStringList(esd.isSearchingSteps(), esd.isSearchingDatabases(), esd.isSearchingNotes());
for (StringSearchResult result : stringList) {
boolean add = Utils.isEmpty(filter);
if (filter != null && result.getString().toUpperCase().contains(filter)) {
add = true;
}
if (filter != null && result.getFieldName().toUpperCase().contains(filter)) {
add = true;
}
if (filter != null && result.getParentObject().toString().toUpperCase().contains(filter)) {
add = true;
}
if (filter != null && result.getGrandParentObject().toString().toUpperCase().contains(filter)) {
add = true;
}
if (add) {
rows.add(result.toRow());
}
}
}
if (rows.size() != 0) {
PreviewRowsDialog prd = new PreviewRowsDialog(shell, Variables.getADefaultVariableSpace(), SWT.NONE, BaseMessages.getString(PKG, "Spoon.StringSearchResult.Subtitle"), StringSearchResult.getResultRowMeta(), rows);
String title = BaseMessages.getString(PKG, "Spoon.StringSearchResult.Title");
String message = BaseMessages.getString(PKG, "Spoon.StringSearchResult.Message");
prd.setTitleMessage(title, message);
prd.open();
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
mb.setMessage(BaseMessages.getString(PKG, "Spoon.Dialog.NothingFound.Message"));
// Sorry!
mb.setText(BaseMessages.getString(PKG, "Spoon.Dialog.NothingFound.Title"));
mb.open();
}
}
Aggregations