Open kjose90 opened 1 month ago
This TBI update focuses on enhancing the functionality of OData Service Writer to support the generation of annotations.cds files into Fiori Elements applications.
OData Service Writer Update:
async function generate(basePath: string, service: OdataService, fs?: Editor): Promise<Editor>
UpdateCdsFiles
Function:
using IncidentService as service from "../../srv/incidentservice'; to projects's annotations.cds"
using from './project1/annotations';
to the below files
Example of Annotations.cds Files:
path path/app/projectName/annotations.cds
adds annotation config `using from './project1/annotations';`
Example of services.cds Files:
path path/app/projectName/services.cds
using from './incidents/annotations';
using from '../srv/common';
annotate IncidentService.Incidents with {
ID @UI.Hidden : true
};
Annotation.cds Witing Logic
if(service.type === ServiceType.CDS) {
// If the service type is CDS, the writer updates the annotations.cds file.
updateCdsFiles(fs, capService, projectName);
}
// updates the Manifest.json file.
updateManifest(basePath, service, fs, templateRoot);
Writing Annotations.cds File in OData Service Writers:
Required Information:
serviceCdsPath
: Path to the service's CDS file
projectPath
: Path to the project directory
appPath
: Path to the application directory
serviceName
: Name of the service being integrated
Question: Does it make sense to add this information to update cds files to the current ODataService interface?
export interface OdataService {
url?: string;
client?: string;
destination?: {
name: string;
instance?: string;
};
type?: ServiceType;
path?: string;
version: OdataVersion;
name?: string;
model?: string;
metadata?: string;
annotations?: {
name?: string;
technicalName: string;
xml: string;
};
localAnnotationsName?: string; // The name used in the manifest.json and as the filename for local annotations
previewSettings?: Partial<ProxyBackend>;
}
UpdateManifest Function:
EnhanceData Function:
Sets default annotations name for a given service. code
/**
Sets the default annotations name for a given service.
If the service annotations name is not defined or empty, it creates a default annotations name
from the technicalName by replacing all '/' characters with '' and removing the leading ''.
@param {OdataService} service - The service object whose annotations name needs to be set or modified. */ function setDefaultAnnotationsName(service: OdataService): void { if(service.type === serviceType.CDS) return if (service.annotations?.technicalName && !service.annotations.name) { service.annotations.name = service.annotations?.technicalName?.replace(/\//g, '')?.replace(/^/, ''); } } /**
Enhances the provided OData service object with path, name and model information.
Directly modifies the passed object reference.
@param {OdataService} service - the OData service object */ export function enhanceData(service: OdataService): void { //... setDefaultAnnotationsName(service); //... }
Can we move this code from here to odata service writer so we can use server type to decide weather to add local annotations. It will all remain grouped in odata service writers itself.
Enhancing OData Service Writer for Annotations.cds Support
Value
Integrating logic to accommodate annotation.cds within the odata service writer would prevent inadvertent removal of CDS-related functionalities during the application writing stage.
Architecture Elaboration
Does it requires architecture elaboration?
Notes
Tasks