Search in sources :

Example 1 with SearchJob

use of org.csstudio.trends.databrowser3.archive.SearchJob in project org.csstudio.display.builder by kasemir.

the class SearchJobTest method testSearchJob.

@Test(timeout = 20000)
public void testSearchJob() throws Exception {
    final TestProperties settings = new TestProperties();
    String url = settings.getString("archive_rdb_url");
    if (url == null) {
        System.out.println("Skipped");
        return;
    }
    // final ArchiveReader reader =
    // ArchiveRepository.getInstance().getArchiveReader(url);
    final ArchiveDataSource[] archives = new ArchiveDataSource[] { new ArchiveDataSource(url, 1, "") };
    new SearchJob(archives, "DTL_LLRF:FCM1:*", true) {

        @Override
        protected void receivedChannelInfos(final ChannelInfo[] channels) {
            System.out.println("Found these channels:");
            for (final ChannelInfo channel : channels) System.out.println(channel.getArchiveDataSource().getName() + " - " + channel.getProcessVariable().getName());
            info = "Found " + channels.length + " channels";
            done.countDown();
        }

        @Override
        protected void archiveServerError(final String url, final Exception ex) {
            info = NLS.bind(Messages.ArchiveServerErrorFmt, url, ex.getMessage());
            done.countDown();
        }
    }.schedule();
    // Wait for success or error
    done.await();
    System.out.println(info);
    assertThat(info, notNullValue());
    assertTrue(info.startsWith("Found"));
}
Also used : TestProperties(org.csstudio.apputil.test.TestProperties) ArchiveDataSource(org.csstudio.trends.databrowser3.model.ArchiveDataSource) ChannelInfo(org.csstudio.trends.databrowser3.model.ChannelInfo) Test(org.junit.Test)

Example 2 with SearchJob

use of org.csstudio.trends.databrowser3.archive.SearchJob in project org.csstudio.display.builder by kasemir.

the class SearchView method searchForChannels.

/**
 * Search selected archives for channels, updating the
 *  <code>channel_table</code> with the result
 *  @see #channel_table
 */
private void searchForChannels() {
    final ArchiveDataSource[] archives = archive_gui.getSelectedArchives();
    if (archives == null)
        return;
    final String pattern_txt = pattern.getText().trim();
    // Warn when searching ALL channels
    if (pattern_txt.length() <= 0) {
        MessageDialog.openInformation(pattern.getShell(), Messages.Search, Messages.SearchPatternEmptyMessage);
        // Aborted, move focus to search pattern
        pattern.setFocus();
        return;
    }
    new SearchJob(archives, pattern_txt, !regex.getSelection()) {

        @Override
        protected void receivedChannelInfos(final ChannelInfo[] channels) {
            displayChannelInfos(channels);
        }

        @Override
        protected void archiveServerError(final String url, final Exception ex) {
            handleServerError(url, ex);
        }
    }.schedule();
}
Also used : ArchiveDataSource(org.csstudio.trends.databrowser3.model.ArchiveDataSource) SearchJob(org.csstudio.trends.databrowser3.archive.SearchJob) ChannelInfo(org.csstudio.trends.databrowser3.model.ChannelInfo) PartInitException(org.eclipse.ui.PartInitException) CommandException(org.eclipse.core.commands.common.CommandException)

Aggregations

ArchiveDataSource (org.csstudio.trends.databrowser3.model.ArchiveDataSource)2 ChannelInfo (org.csstudio.trends.databrowser3.model.ChannelInfo)2 TestProperties (org.csstudio.apputil.test.TestProperties)1 SearchJob (org.csstudio.trends.databrowser3.archive.SearchJob)1 CommandException (org.eclipse.core.commands.common.CommandException)1 PartInitException (org.eclipse.ui.PartInitException)1 Test (org.junit.Test)1