public parseClause()

in src/parsers/clause-parsers.ts [122:148]


    public parseClause(clause: WorkItemQueryClause): string {
        const handling = this.supportedOperationsHandlingMap[clause.operator.referenceName];

        if (handling == null) {
            // Verify operator.
            NotesService.instance.newNote('warning', `The operation '${clause.operator.name}' is not supported by OData. Leaving the clause out of $filter.`);
            return null;
        }

        // Verify fields. There is always a field on the left hand side, and sometimes on the right hand side.
        const lhsMetadata = this.metadata[clause.field.referenceName];
        const rhsMetadata = clause.isFieldValue ? this.metadata[clause.fieldValue.referenceName] : this.metadata[clause.field.referenceName];
        if (lhsMetadata == null || (clause.isFieldValue && rhsMetadata)) {
            NotesService.instance.newNote(
                'warning',
                `There is no OData equivalent property for field ${lhsMetadata == null ? clause.field.referenceName : clause.fieldValue.referenceName}. Leaving the clause out of $filter.`
            );
            return null;
        }

        try {
            return handling.handler(clause);
        } catch (e) {
            NotesService.instance.newNote('warning', `There was a problem parsing the clause for field ${clause.field.referenceName}: ${e.message}. Leaving the clause out of $filter.`);
            return null;
        }
    }