Skip to content

refactor(recommendations): RecommendationClient API + handler/builder cleanup #65

@Schmarvinius

Description

@Schmarvinius

Scope: API redesign + multiple correctness/quality fixes in one module. Could split if too big.

  • Redesign RecommendationClient.predict to separate prediction row from context rows:
    List predict(CdsData predictionRow, List contextRows,
    List predictionColumns, String indexColumn);
  • Add public constant RecommendationClient.PREDICT = "[PREDICT]"; use everywhere (RptInferenceClient, MockRecommendationClient, RecommendationContextBuilder).
  • Decouple from RPT-1 specifics: move compound-key handling, SYNTHETIC_KEY_COLUMN assembly, and "row assembly" out of RecommendationContextBuilder into RptInferenceClient.
  • Register RecommendationClient as a CAP service so apps can override its on-handler (could be tracked as follow-up if too large).
  • Drop @FunctionalInterface on RecommendationClientResolver.
  • Rename RptInferenceClient.api → rpt. Extract a toSdkRow(...) helper method.
  • Replace MANAGED_FIELDS set with annotation-driven exclusion: @Core.Computed, @readonly.
  • FioriRecommendationHandler fixes:
    • Use a reliable IsActiveEntity check (current substring match is unsafe; only works when IsActiveEntity is selected).
    • Skip context query early if predictionColumns is empty.
    • Predict only columns where currentRow.get(c) == null.
    • Resolve PersistenceService via DI, not lookup.
    • Extract "SAP_Recommendations" as constant.
    • Reduce log level from info to trace (or drop).
  • RecommendationContextBuilder fixes:
    • Throw / suppress predictions when key cannot be determined (drop orElse("ID")).
    • Use Set selectColumns to dedupe.
    • Drop the unnecessary ORDER BY (or document its purpose).
    • Verify whether the prediction row is implicitly excluded; otherwise exclude it explicitly. Add tests.
    • Use instanceof CdsSimpleType st && SUPPORTED_CONTEXT_TYPES.contains(st.getType()).
    • Replace '\0' synthetic-key separator with a documented & well-tested strategy.
    • Don't react on @cds.odata.valuelist : false.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions