@Test
  public void testGetStatuses() {
    query.setAttribute(SonarQuery.STATUSES, "OPEN");
    assertThat(SonarQuery.getStatuses(query), is(new String[] {"OPEN"}));

    query.setAttribute(SonarQuery.STATUSES, "OPEN,REOPENED");
    assertThat(SonarQuery.getStatuses(query), is(new String[] {"OPEN", "REOPENED"}));
  }
  @Test
  public void testGetSeverities() {
    query.setAttribute(SonarQuery.SEVERITIES, "BLOCKER");
    assertThat(SonarQuery.getSeverities(query), is(new String[] {"BLOCKER"}));

    query.setAttribute(SonarQuery.SEVERITIES, "BLOCKER,MAJOR");
    assertThat(SonarQuery.getSeverities(query), is(new String[] {"BLOCKER", "MAJOR"}));
  }
 @SuppressWarnings("restriction")
 private static boolean hasQueryWithTitle(TaskRepository repository, String title) {
   Set<org.eclipse.mylyn.internal.tasks.core.RepositoryQuery> queries =
       org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin.getTaskList()
           .getRepositoryQueries(repository.getRepositoryUrl());
   for (IRepositoryQuery query : queries) {
     if (query.getSummary().equals(title)) {
       return true;
     }
   }
   return false;
 }
Beispiel #4
0
  public RTQueryPage(TaskRepository taskRepository, IRepositoryQuery query) {
    super("Enter query parameters", taskRepository, query);

    try {
      urls = URLFactory.create(taskRepository.getRepositoryUrl());
    } catch (MalformedURLException e) {
      throw new RuntimeException(e);
    }

    if (query != null) {
      this.titleString = query.getSummary();
      this.queryString = query.getAttribute(RequestTrackerTaskDataHandler.QUERY_ID);
    }
  }
  @Test
  public void testGetAssignee() {
    try {
      SonarQuery.getAssignee(query, "foo");
    } catch (IllegalStateException e) {
      // expected
    }

    query.setAttribute(SonarQuery.ASSIGNEE, SonarQuery.ANY_USER);
    assertThat(SonarQuery.getAssignee(query, "foo"), nullValue());

    query.setAttribute(SonarQuery.ASSIGNEE, SonarQuery.UNASSIGNED);
    assertThat(SonarQuery.getAssignee(query, "foo"), is(new String[] {""}));

    query.setAttribute(SonarQuery.ASSIGNEE, SonarQuery.CURRENT_USER);
    assertThat(SonarQuery.getAssignee(query, "foo"), is(new String[] {"foo"}));

    query.setAttribute(SonarQuery.ASSIGNEE, SonarQuery.SPECIFIED_USER);
    query.setAttribute(SonarQuery.ASSIGNEE_USER, "bar");
    assertThat(SonarQuery.getAssignee(query, "foo"), is(new String[] {"bar"}));
  }
  /** test for bug 335278: enhance search result handler to handle additional attributes */
  public void testQueryRealName_Bug335278() throws Exception {
    IRepositoryQuery query =
        new RepositoryQuery(BugzillaFixture.current().getConnectorKind(), "query");
    UrlBuilder urlBuilder =
        UrlBuilder.build(BugzillaFixture.current().repository()).append("/buglist.cgi");

    urlBuilder.parameter(
        "columnlist",
        "bug_severity,priority,assigned_to,bug_status,resolution,short_desc,changeddate,reporter,assigned_to_realname,reporter_realname,product,component");
    query.setUrl(urlBuilder.toString());

    final Set<TaskData> returnedData = new HashSet<TaskData>();
    TaskDataCollector collector =
        new TaskDataCollector() {

          @Override
          public void accept(TaskData taskData) {
            returnedData.add(taskData);
          }
        };
    TaskAttributeMapper mapper =
        BugzillaFixture.current()
            .connector()
            .getTaskDataHandler()
            .getAttributeMapper(BugzillaFixture.current().repository());

    client.getSearchHits(query, collector, mapper, new NullProgressMonitor());

    assertTrue(returnedData.size() > 0);
    for (TaskData taskData : returnedData) {
      TaskAttribute reporterName =
          taskData.getRoot().getAttribute(BugzillaAttribute.REPORTER_NAME.getKey());
      TaskAttribute assignedToName =
          taskData.getRoot().getAttribute(BugzillaAttribute.ASSIGNED_TO_NAME.getKey());
      assertHasValue(reporterName);
      assertHasValue(assignedToName);
    }
  }
 @Override
 public void applyTo(IRepositoryQuery query) {
   query.setSummary(getQueryTitle());
   query.setAttribute(WebRepositoryConnector.KEY_QUERY_TEMPLATE, queryUrlText.getText());
   query.setAttribute(WebRepositoryConnector.KEY_QUERY_PATTERN, queryPatternText.getText());
   query.setAttribute(
       WebRepositoryConnector.KEY_TASK_PREFIX,
       getTaskRepository().getProperty(WebRepositoryConnector.PROPERTY_TASK_URL));
   Map<String, String> params = parametersEditor.getParameters();
   query.setUrl(
       WebRepositoryConnector.evaluateParams(queryUrlText.getText(), params, getTaskRepository()));
   for (Map.Entry<String, String> entry : params.entrySet()) {
     query.setAttribute(entry.getKey(), entry.getValue());
   }
 }
 /**
  * @see
  *     org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector#performQuery(org.eclipse.mylyn.tasks.core.TaskRepository,
  *     org.eclipse.mylyn.tasks.core.IRepositoryQuery,
  *     org.eclipse.mylyn.tasks.core.data.TaskDataCollector,
  *     org.eclipse.mylyn.tasks.core.sync.ISynchronizationSession,
  *     org.eclipse.core.runtime.IProgressMonitor)
  */
 public IStatus performQuery(
     TaskRepository repository,
     IRepositoryQuery query,
     TaskDataCollector collector,
     ISynchronizationSession session,
     IProgressMonitor monitor) {
   IStatus status = Status.OK_STATUS;
   GistService service = new GistService(createClient(repository));
   String user = query.getAttribute(IGistQueryConstants.USER);
   try {
     TaskAttributeMapper mapper = dataHandler.getAttributeMapper(repository);
     for (Gist gist : service.getGists(user)) {
       TaskData data = new TaskData(mapper, getConnectorKind(), repository.getUrl(), gist.getId());
       data.setPartial(true);
       dataHandler.fillTaskData(repository, data, gist);
       collector.accept(data);
     }
   } catch (IOException e) {
     status = GitHub.createWrappedStatus(e);
   }
   return status;
 }
  public void createControl(Composite parent) {
    final Composite composite = new Composite(parent, SWT.NONE);
    GridLayout gridLayout = new GridLayout();
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    gridLayout.verticalSpacing = 0;
    gridLayout.numColumns = 1;
    composite.setLayout(gridLayout);

    if (!inSearchContainer()) {
      createTitleGroup(composite);
    }

    parametersEditor = new ParametersEditor(composite, SWT.NONE);
    GridData gridData1 = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData1.minimumHeight = 90;
    parametersEditor.setLayoutData(gridData1);

    ExpandableComposite expComposite =
        toolkit.createExpandableComposite(
            composite, ExpandableComposite.COMPACT | ExpandableComposite.TWISTIE);
    expComposite.setFont(parent.getFont());
    GridData gridData_1 = new GridData(SWT.FILL, SWT.FILL, true, false);
    gridData_1.heightHint = 150;
    gridData_1.minimumHeight = 150;
    expComposite.setLayoutData(gridData_1);
    expComposite.setBackground(parent.getBackground());
    expComposite.setText(Messages.WebQueryWizardPage_Advanced_Configuration);
    expComposite.addExpansionListener(
        new ExpansionAdapter() {
          @Override
          public void expansionStateChanged(ExpansionEvent e) {
            getControl().getShell().pack();
          }
        });
    toolkit.paintBordersFor(expComposite);

    Composite composite1 = toolkit.createComposite(expComposite, SWT.BORDER);
    composite1.setLayout(new GridLayout(3, false));
    expComposite.setClient(composite1);

    toolkit.createLabel(composite1, Messages.WebQueryWizardPage_Query_URL_, SWT.NONE);

    queryUrlText = new Text(composite1, SWT.BORDER);
    final GridData gridData_2 = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gridData_2.widthHint = 200;
    queryUrlText.setLayoutData(gridData_2);
    queryUrlText.addModifyListener(
        new ModifyListener() {
          public void modifyText(final ModifyEvent e) {
            webPage = null;
          }
        });
    decorations.add(
        WebContentProposalProvider.createDecoration(queryUrlText, parametersEditor, false));

    Button button = new Button(composite1, SWT.NONE);
    button.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    button.setText(Messages.WebQueryWizardPage_Open);
    button.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            openBrowser();
          }
        });

    Label queryPatternLabel =
        toolkit.createLabel(composite1, Messages.WebQueryWizardPage_Query_Pattern_, SWT.NONE);
    queryPatternLabel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));

    queryPatternText = new Text(composite1, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.WRAP);
    GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false);
    gridData.widthHint = 200;
    gridData.heightHint = 60;
    queryPatternText.setLayoutData(gridData);
    decorations.add(
        WebContentProposalProvider.createDecoration(queryPatternText, parametersEditor, true));

    Button preview = new Button(composite1, SWT.NONE);
    preview.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
    preview.setText(Messages.WebQueryWizardPage_Preview);
    preview.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent e) {
            webPage = null;
            updatePreview();
          }
        });

    previewTable = new TableViewer(composite1, SWT.BORDER);
    // previewTable = new Table(composite1, SWT.BORDER);
    GridData gridData2 = new GridData(SWT.FILL, SWT.FILL, false, true, 3, 1);
    gridData2.heightHint = 60;

    Table table = previewTable.getTable();
    table.setLayoutData(gridData2);
    table.setLinesVisible(true);
    table.setHeaderVisible(true);

    TableColumn colId = new TableColumn(table, SWT.NONE);
    colId.setWidth(100);
    colId.setText(Messages.WebQueryWizardPage_Id);

    TableColumn colDescription = new TableColumn(table, SWT.NONE);
    colDescription.setWidth(200);
    colDescription.setText(Messages.WebQueryWizardPage_Description);

    TableColumn colStatus = new TableColumn(table, SWT.NONE);
    colStatus.setText(Messages.WebQueryWizardPage_Status);
    colStatus.setWidth(80);

    TableColumn colType = new TableColumn(table, SWT.NONE);
    colType.setText(Messages.WebQueryWizardPage_Type);
    colType.setWidth(80);

    TableColumn colOwner = new TableColumn(table, SWT.NONE);
    colOwner.setText(Messages.WebQueryWizardPage_Owner);
    colOwner.setWidth(120);

    previewTable.setColumnProperties(
        new String[] {
          "Id", "Description", "Status", "Type", "Owner"
        }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    previewTable.setContentProvider(
        new IStructuredContentProvider() {

          public void dispose() {}

          public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}

          public Object[] getElements(Object inputElement) {
            if (inputElement instanceof Collection<?>) {
              return ((Collection<?>) inputElement).toArray();
            }
            return new Object[0];
          }
        });

    previewTable.setLabelProvider(
        new ITableLabelProvider() {

          public String getColumnText(Object element, int columnIndex) {
            TaskMapper task = (TaskMapper) element;
            switch (columnIndex) {
              case 0:
                return task.getTaskData().getTaskId();
              case 1:
                return task.getSummary();
              case 2:
                return task.getCompletionDate() != null
                    ? Messages.WebQueryWizardPage_complete
                    : Messages.WebQueryWizardPage_incomplete;
              case 3:
                return task.getTaskKind();
              case 4:
                return task.getOwner();
            }
            return null;
          }

          public Image getColumnImage(Object element, int columnIndex) {
            return null;
          }

          public void addListener(ILabelProviderListener listener) {}

          public void dispose() {}

          public boolean isLabelProperty(Object element, String property) {
            return false;
          }

          public void removeListener(ILabelProviderListener listener) {}
        });

    setControl(composite);

    LinkedHashMap<String, String> vars = new LinkedHashMap<String, String>();
    Map<String, String> params = new LinkedHashMap<String, String>();
    if (getTaskRepository() != null) {
      queryUrlText.setText(
          addVars(
              vars, getTaskRepository().getProperty(WebRepositoryConnector.PROPERTY_QUERY_URL)));
      queryPatternText.setText(
          addVars(
              vars, getTaskRepository().getProperty(WebRepositoryConnector.PROPERTY_QUERY_REGEXP)));

      oldProperties = getTaskRepository().getProperties();
      params.putAll(oldProperties);
    }
    IRepositoryQuery query = getQuery();
    if (query != null) {
      setTitle(query.getSummary());
      queryUrlText.setText(
          addVars(vars, query.getAttribute(WebRepositoryConnector.KEY_QUERY_TEMPLATE)));
      queryPatternText.setText(
          addVars(vars, query.getAttribute(WebRepositoryConnector.KEY_QUERY_PATTERN)));
      params.putAll(WebRepositoryConnector.getQueryParams(query));
    }
    parametersEditor.addParams(params, vars);

    Dialog.applyDialogFont(composite);
  }
Beispiel #10
0
 @Override
 public void applyTo(IRepositoryQuery query) {
   query.setAttribute(RequestTrackerTaskDataHandler.QUERY_ID, queryString);
   query.setUrl(urls.getBrowseTicketSearchUrl(queryString));
   query.setSummary(getQueryTitle());
 }
Beispiel #11
0
 @Override
 void saveQueryParameters(IRepositoryQuery query) {
   query.setAttribute(ATTR_FILTER_ID, filterID.toString());
 }
Beispiel #12
0
 @Override
 void loadQueryParameters(IRepositoryQuery query) {
   String fid = query.getAttribute(ATTR_FILTER_ID);
   filterID = FilterID.valueOf(fid);
 }