@Test
  public void testGetSearchClauseOneProjectIsFlag() throws Exception {
    final CustomFieldParamsImpl customFieldParams = new CustomFieldParamsImpl();
    customFieldParams.addValue(Collections.singleton("123"));
    final Map<String, Object> map =
        MapBuilder.<String, Object>newBuilder()
            .add(urlParameterName, customFieldParams)
            .add(
                SystemSearchConstants.forProject().getUrlParameter(),
                Collections.singletonList("-1"))
            .toMap();
    FieldValuesHolder values = new FieldValuesHolderImpl(map);
    final AtomicBoolean specialCalled = new AtomicBoolean(false);

    final IndexedInputHelper helper =
        new DefaultIndexedInputHelper<Version>(
            indexInfoResolver,
            operandResolver,
            fieldFlagOperandRegistry,
            searchContextVisibilityChecker) {
          @Override
          public Clause getClauseForNavigatorValues(final String clauseName, final Set values) {
            return null;
          }
        };

    transformer =
        new VersionCustomFieldSearchInputTransformer(
            urlParameterName,
            clauseNames,
            customField,
            indexInfoResolver,
            operandResolver,
            fieldFlagOperandRegistry,
            searchContextVisibilityChecker,
            versionResolver,
            customFieldInputHelper,
            versionManager) {
          @Override
          protected DefaultIndexedInputHelper getDefaultIndexedInputHelper() {
            throw new UnsupportedOperationException(
                "Should not have called through to the special indexed input helper");
          }

          @Override
          protected IndexedInputHelper getIndexedInputHelper() {
            specialCalled.set(true);
            return helper;
          }

          @Override
          protected String getClauseName(final User searcher, final ClauseNames clauseNames) {
            return primaryClauseName;
          }
        };
    replay();

    transformer.getSearchClause(theUser, values);
    assertTrue(specialCalled.get());
  }
 @Nonnull
 public QueryFactoryResult getQuery(
     @Nonnull final QueryCreationContext queryCreationContext,
     @Nonnull final TerminalClause terminalClause) {
   if (SystemSearchConstants.forAttachments()
       .getSupportedOperators()
       .contains(terminalClause.getOperator())) {
     return new QueryFactoryResult(
         new TermQuery(
             new Term(
                 DocumentConstants.ISSUE_ATTACHMENT, getTermText(terminalClause.getOperator()))));
   } else {
     log.debug("Attempt to search attachments when attachments are disabled.");
     return createFalseResult();
   }
 }
示例#3
0
  public ComponentsSearcher(
      VelocityTemplatingEngine templatingEngine,
      VelocityRequestContextFactory contextFactory,
      FieldVisibilityManager fieldVisibilityManager,
      ComponentResolver componentResolver,
      ApplicationProperties applicationProperties,
      ProjectComponentManager componentManager,
      ProjectManager projectManager,
      JqlOperandResolver operandResolver,
      FieldFlagOperandRegistry fieldFlagOperandRegistry,
      PermissionManager permissionManager) {
    final SimpleFieldSearchConstantsWithEmpty searchConstants =
        SystemSearchConstants.forComponent();

    searcherInformation =
        new GenericSearcherInformation<SearchableField>(
            searchConstants.getSearcherId(),
            "common.filters.incomponents",
            Collections.<Class<? extends FieldIndexer>>singletonList(ComponentsIndexer.class),
            fieldReference,
            SearcherGroupType.PROJECT);

    searchRenderer =
        new ComponentSearchRenderer(
            applicationProperties,
            fieldVisibilityManager,
            componentManager,
            projectManager,
            searchConstants,
            searcherInformation.getNameKey(),
            templatingEngine,
            contextFactory,
            permissionManager);

    searchInputTransformer =
        new ComponentSearchInputTransformer(
            searchConstants.getJqlClauseNames(),
            searchConstants.getUrlParameter(),
            operandResolver,
            fieldFlagOperandRegistry,
            componentResolver);
  }
 public FixForVersionRenderer(
     ProjectManager projectManager,
     VersionManager versionManager,
     FieldVisibilityManager fieldVisibilityManager,
     VelocityRequestContextFactory velocityRequestContextFactory,
     ApplicationProperties applicationProperties,
     VelocityTemplatingEngine templatingEngine,
     String searcherNameKey) {
   super(
       SystemSearchConstants.forFixForVersion(),
       searcherNameKey,
       projectManager,
       versionManager,
       velocityRequestContextFactory,
       applicationProperties,
       templatingEngine,
       fieldVisibilityManager,
       true);
   this.velocityRequestContextFactory = velocityRequestContextFactory;
 }
  public PrioritySearcher(
      FieldVisibilityManager fieldVisibilityManager,
      final ConstantsManager constantsManager,
      JqlOperandResolver operandResolver,
      VelocityRequestContextFactory velocityRequestContextFactory,
      ApplicationProperties applicationProperties,
      VelocityManager velocityManager,
      PriorityResolver priorityResolver,
      FieldFlagOperandRegistry fieldFlagOperandRegistry) {
    final IssueConstantInfoResolver<Priority> constantInfoResolver =
        new IssueConstantInfoResolver<Priority>(priorityResolver);
    final SearchContextVisibilityChecker searchContextVisibilityChecker =
        new AlwaysVisibleSearchContextVisibilityChecker();

    final SimpleFieldSearchConstants constants = SystemSearchConstants.forPriority();

    this.searchInformation =
        new GenericSearcherInformation<SearchableField>(
            constants.getSearcherId(),
            "navigator.filter.matchingpriorities",
            Collections.<Class<? extends FieldIndexer>>singletonList(PriorityIndexer.class),
            fieldReference,
            SearcherGroupType.ISSUE);
    this.searchInputTransformer =
        new IssueConstantSearchInputTransformer<Priority>(
            constants.getJqlClauseNames(),
            constantInfoResolver,
            operandResolver,
            fieldFlagOperandRegistry,
            searchContextVisibilityChecker,
            priorityResolver);
    this.searchRenderer =
        new PrioritySearchRenderer(
            searchInformation.getNameKey(),
            constantsManager,
            velocityRequestContextFactory,
            applicationProperties,
            velocityManager,
            fieldVisibilityManager);
  }
 public String getEditHtml(
     final User searcher,
     final SearchContext searchContext,
     final FieldValuesHolder fieldValuesHolder,
     final Map<?, ?> displayParameters,
     final Action action) {
   Map<String, Object> velocityParams =
       getVelocityParams(
           searcher, searchContext, null, fieldValuesHolder, displayParameters, action);
   velocityParams.put(
       "extraOption",
       EasyMap.build(
           "value",
           getI18n(searcher).getText("common.filters.noversion"),
           "key",
           VersionManager.NO_VERSIONS));
   velocityParams.put(
       "selectedValues",
       fieldValuesHolder.get(SystemSearchConstants.forFixForVersion().getUrlParameter()));
   velocityParams.put("selectListOptions", getSelectListOptions(searcher, searchContext));
   return renderEditTemplate("project-constants-searcher-edit.vm", velocityParams);
 }
示例#7
0
  public ReporterSearcher(
      VelocityRequestContextFactory velocityRequestContextFactory,
      VelocityTemplatingEngine templatingEngine,
      ApplicationProperties applicationProperties,
      UserPickerSearchService userPickerSearchService,
      GroupManager groupManager,
      UserManager userManager,
      final PermissionManager permissionManager,
      final FieldVisibilityManager fieldVisibilityManager,
      final UserHistoryManager userHistoryManager) {
    UserFieldSearchConstantsWithEmpty searchConstants = SystemSearchConstants.forReporter();
    final UserFitsNavigatorHelper userFitsNavigatorHelper =
        new UserFitsNavigatorHelper(userPickerSearchService);

    searcherInformation =
        new GenericSearcherInformation<SearchableField>(
            searchConstants.getSearcherId(),
            NAME_KEY,
            Collections.<Class<? extends FieldIndexer>>singletonList(ReporterIndexer.class),
            fieldReference,
            SearcherGroupType.ISSUE);
    searchRenderer =
        new ReporterSearchRenderer(
            NAME_KEY,
            velocityRequestContextFactory,
            applicationProperties,
            templatingEngine,
            userPickerSearchService,
            userManager,
            permissionManager,
            fieldVisibilityManager);
    searchInputTransformer =
        new KickassUserSearchInputTransformer(
            searchConstants,
            userFitsNavigatorHelper,
            groupManager,
            userManager,
            userHistoryManager);
  }
 public ReporterStatisticsMapper(
     UserManager userManager, JiraAuthenticationContext authenticationContext) {
   super(SystemSearchConstants.forReporter(), userManager, authenticationContext);
 }
 public TestFixForVersionRenderer() {
   super(SystemSearchConstants.forFixForVersion().getUrlParameter());
 }
 public String getDocumentFieldId() {
   return SystemSearchConstants.forWorkRatio().getIndexField();
 }
 public String getId() {
   return SystemSearchConstants.forWorkRatio().getFieldId();
 }
 public String getDocumentFieldId() {
   return SystemSearchConstants.forDescription().getIndexField();
 }