Class AiDictionaryWebScript

java.lang.Object
org.springframework.extensions.webscripts.AbstractWebScript
fr.becpg.repo.web.scripts.remote.ai.AiDictionaryWebScript
All Implemented Interfaces:
org.springframework.extensions.webscripts.WebScript

public class AiDictionaryWebScript extends org.springframework.extensions.webscripts.AbstractWebScript

AI-shaped data dictionary (/becpg/remote/ai/dictionary).

Returns a flat, AI-friendly view of the per-tenant content model so becpg-ai can resolve field/type names from intent and validate them (anti-hallucination), including the tenant's custom fields. This is the server-driven replacement for the static field/type embeddings baked into the becpg-ai image.

  • ?type=ns:type → the type title plus its fields (name, title, dataType, mandatory) and associations (name, title, targetType).
  • no parameter → the list of entity types (subtypes of bcpg:entityV2).
Cheap by design: everything comes from the compiled (in-memory, cached) data model — no Solr/DB queries.
Author:
matthieu
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.springframework.extensions.webscripts.AbstractWebScript

    org.springframework.extensions.webscripts.AbstractWebScript.ScriptDetails
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private org.alfresco.service.cmr.dictionary.DictionaryService
     
     
    private org.alfresco.service.namespace.NamespaceService
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private Map<org.alfresco.service.namespace.QName,org.alfresco.service.cmr.dictionary.AssociationDefinition>
    allAssociations(org.alfresco.service.cmr.dictionary.ClassDefinition classDef)
     
    private Map<org.alfresco.service.namespace.QName,org.alfresco.service.cmr.dictionary.PropertyDefinition>
    allProperties(org.alfresco.service.cmr.dictionary.ClassDefinition classDef)
    The full default field set of a type: its own properties plus the properties of its default aspects (mirrors how JsonSchemaEntityVisitor builds an entity schema).
    private org.json.JSONArray
    Distinct union of properties (type + default aspects) across all entity types (subtypes of bcpg:entityV2), deduplicated by name — the lexical corpus for intent → field resolution.
    private org.json.JSONArray
    buildAssociations(org.alfresco.service.cmr.dictionary.ClassDefinition classDef)
     
    private org.json.JSONArray
    buildFields(org.alfresco.service.cmr.dictionary.ClassDefinition classDef)
     
    private org.json.JSONArray
     
    void
    execute(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse resp)
    private org.json.JSONObject
    fieldEntry(org.alfresco.service.cmr.dictionary.PropertyDefinition prop, boolean withMandatory)
     
    void
    setDictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService)
    Setter for the field dictionaryService.
    void
    Setter for the field entityDictionaryService.
    void
    setNamespaceService(org.alfresco.service.namespace.NamespaceService namespaceService)
    Setter for the field namespaceService.

    Methods inherited from class org.springframework.extensions.webscripts.AbstractWebScript

    addModuleBundleToCache, checkModuleBundleCache, createArgs, createArgsM, createHeaders, createHeadersM, createScriptParameters, createStatusException, createTemplateParameters, executeScript, getContainer, getDescription, getExecuteScript, getResources, getStatusTemplate, init, renderString, renderString, renderTemplate, sendStatus, setURLModelFactory, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • dictionaryService

      private org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService
    • entityDictionaryService

      private EntityDictionaryService entityDictionaryService
    • namespaceService

      private org.alfresco.service.namespace.NamespaceService namespaceService
  • Constructor Details

    • AiDictionaryWebScript

      public AiDictionaryWebScript()
  • Method Details

    • execute

      public void execute(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse resp) throws IOException
      Throws:
      IOException
    • buildTypes

      private org.json.JSONArray buildTypes() throws org.json.JSONException
      Throws:
      org.json.JSONException
    • allProperties

      private Map<org.alfresco.service.namespace.QName,org.alfresco.service.cmr.dictionary.PropertyDefinition> allProperties(org.alfresco.service.cmr.dictionary.ClassDefinition classDef)
      The full default field set of a type: its own properties plus the properties of its default aspects (mirrors how JsonSchemaEntityVisitor builds an entity schema). In-memory model lookups only.
    • allAssociations

      private Map<org.alfresco.service.namespace.QName,org.alfresco.service.cmr.dictionary.AssociationDefinition> allAssociations(org.alfresco.service.cmr.dictionary.ClassDefinition classDef)
    • buildAllFields

      private org.json.JSONArray buildAllFields() throws org.json.JSONException
      Distinct union of properties (type + default aspects) across all entity types (subtypes of bcpg:entityV2), deduplicated by name — the lexical corpus for intent → field resolution. In-memory (compiled model), so cheap; bounded by the data model and cached client-side per tenant.
      Throws:
      org.json.JSONException
    • buildFields

      private org.json.JSONArray buildFields(org.alfresco.service.cmr.dictionary.ClassDefinition classDef) throws org.json.JSONException
      Throws:
      org.json.JSONException
    • fieldEntry

      private org.json.JSONObject fieldEntry(org.alfresco.service.cmr.dictionary.PropertyDefinition prop, boolean withMandatory) throws org.json.JSONException
      Throws:
      org.json.JSONException
    • buildAssociations

      private org.json.JSONArray buildAssociations(org.alfresco.service.cmr.dictionary.ClassDefinition classDef) throws org.json.JSONException
      Throws:
      org.json.JSONException
    • setDictionaryService

      public void setDictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService)

      Setter for the field dictionaryService.

      Parameters:
      dictionaryService - a DictionaryService object
    • setEntityDictionaryService

      public void setEntityDictionaryService(EntityDictionaryService entityDictionaryService)

      Setter for the field entityDictionaryService.

      Parameters:
      entityDictionaryService - a EntityDictionaryService object
    • setNamespaceService

      public void setNamespaceService(org.alfresco.service.namespace.NamespaceService namespaceService)

      Setter for the field namespaceService.

      Parameters:
      namespaceService - a NamespaceService object