Skip to main content

Document Filtering Overview

diagram

applyCurrentDocumentTo Constraint

The applyCurrentDocumentTo constraint property in the sheet configuration restricts query results to items within the current LiveDoc. It can target the root entity type or a downstream (related) entity type.
PropertyTypeDefaultDescription
constraints.applyCurrentDocumentTostringnullEntity type name to apply current document filtering. When set, the specified entity type is filtered to only include items from the same document as the current Polarion document context.

Root Entity Filtering

When applyCurrentDocumentTo matches the root query.from entity type, the filter is applied directly to the primary query:
sources:
  - id: needs
    title: User Needs
    model: rtm
    query:
      from: UserNeed
      where: "<WHERE>"
    constraints:
      applyCurrentDocumentTo: UserNeed
    expand:
      - name: systemRequirements
        title: System Requirements
        expand:
          - name: systemRequirement

Downstream Entity Filtering

When applyCurrentDocumentTo targets a related entity type (not the root), the constraint applies to the downstream entity:
sources:
  - id: needs
    title: User Needs
    model: rtm
    query:
      from: UserNeed
      where: "<WHERE>"
    constraints:
      applyCurrentDocumentTo: SystemRequirement
    expand:
      - name: systemRequirements
        title: System Requirements
        expand:
          - name: systemRequirement
In this example, SystemRequirement entities are filtered to only those within the current document, while UserNeed entities are not document-constrained.

Query Parameters

ParameterTypeDefaultDescription
currentDocstringnullFull document path in folder/name format. Set automatically from the Powersheet widget’s document context.
currentDocConstraintstringnullEntity type name or expansion path that should be document-filtered. Derived from applyCurrentDocumentTo configuration.
document.idstringnullFull document path (folder/name) added as a query parameter for dynamic value resolution.
The query manager automatically injects document context parameters into all queries. These parameters do not need to be set manually in the sheet configuration.

Document Filter Injection

The query manager applies document filtering by injecting predicates into the where clause:
  1. The defaultQueryFragment is computed once from the data source configuration
  2. For each query, the fragment is merged into the query via deep-left merge
  3. If currentDocConstraint matches the query’s from entity type, document.moduleFolder and document.moduleName predicates are injected into the where clause
Injected PredicateLucene EquivalentPurpose
document.moduleFolderdocument.moduleFolder:"Space"Filter by document folder/space
document.moduleNamedocument.moduleName:"DocName"Filter by document name

Document Query Construction

For server-side document resolution, the query engine constructs Lucene queries to find specific documents:
InputFormatExample
Project ID + document pathSpace/DocumentNameRequirements/SystemReqs
Lucene queryproject.id:"proj" AND moduleFolder:"Space" AND moduleName:"DocName"Full resolution query
The document query format expects Space/DocumentName and splits on the slash character to build separate moduleFolder and moduleName predicates. Verify document path formats match your Polarion project structure.

Constraint Propagation

Document constraints from entity types propagate to related navigation properties:
SourcePropagation Rule
Entity type constraintsExtracted from constraint annotations on the entity type
Navigation property constraintsMerged from both the navigation property annotation and the target entity type annotation
Combined resultAND-combined predicate validated against entity type metadata

Domain Model Constraint Configuration

Document constraints can be defined at the entity type level in the domain model YAML:
domainModelTypes:
  SystemRequirement:
    polarionType: systemRequirement
    constraints:
      load:
        document:
          moduleFolder: Requirements
          type: requirements_specification
      pick:
        document:
          moduleFolder: Requirements
          moduleName: Categorized
Constraint TypePurpose
load.documentFilters entities during initial data loading
pick.documentFilters entities in picker dropdown selections
create.documentSets default document values for new entities
See Constraints for full constraint configuration reference.

Complete YAML Example

sources:
  - id: traceability
    title: Requirements Traceability
    model: rtm
    query:
      from: UserNeed
      where: "<WHERE>"
    constraints:
      applyCurrentDocumentTo: UserNeed
    expand:
      - name: systemRequirements
        title: System Requirements
        expand:
          - name: systemRequirement
            expand:
              - name: designRequirements
                expand:
                  - name: designRequirement

columns:
  id:
    width: 80
    sort: asc
  title:
    width: 300
    hasFocus: true
  systemRequirements.systemRequirement.title:
    width: 250
  systemRequirements.systemRequirement.severity:
    width: 100

Source context: PolarionQueryProcessor, QueryManager, QueryFactory, constraints YAML fixtures
Source Code
  • PolarionQueryProcessor.java
  • prod-powersheet-src/com.nextedy.powersheet.client/src/modules/QueryManager/QueryManager.tsx
  • QueryFactory.java
  • prod-powersheet-src/com.nextedy.powersheet.client/cypress/e2e/userFlows/multiple-entity-type-flow.cy.ts
  • prod-powersheet-src/com.nextedy.powersheet.client/cypress/fixtures/models/constraints-base.yaml