@ui5/task-adaptation
Version:
Custom task for ui5-builder which allows building UI5 Flexibility Adaptation Projects for SAP BTP, Cloud Foundry environment
45 lines • 1.87 kB
JavaScript
import ConvertV2ToV4 from "../transformers/convertV2ToV4.js";
import DataSource from "./dataSource.js";
import MakeAnnotationNamespaceUnique from "../transformers/makeAnnotationNamespaceUnique.js";
import RemoveAllSchemaNodesExceptAnnotations from "../transformers/removeAllSchemaNodesExceptAnnotations.js";
import TraverseReferences from "../transformers/traverseReferences.js";
import { getUniqueName } from "../../util/commonUtil.js";
export default class DataSourceOData extends DataSource {
dataSourceJson;
constructor(name, uri, dataSourceJson) {
super(name, uri);
this.dataSourceJson = dataSourceJson;
this.jsonTransformers = [
new TraverseReferences(),
new ConvertV2ToV4(),
new RemoveAllSchemaNodesExceptAnnotations(),
new MakeAnnotationNamespaceUnique()
];
}
updateManifest(manifestDataSources) {
this.getSettings().ignoreAnnotationsFromMetadata = true;
this.addNewODataAnnotation(manifestDataSources);
}
addNewODataAnnotation(manifestDataSources) {
const newAnnotationNameTemplate = `annotation_${this.name}`;
let newAnnotationName = getUniqueName(Object.keys(manifestDataSources), newAnnotationNameTemplate);
this.getAnnotations().unshift(newAnnotationName);
manifestDataSources[newAnnotationName] = {
type: "ODataAnnotation",
uri: this.getFilename()
};
}
getSettings() {
if (this.dataSourceJson.settings == null) {
this.dataSourceJson.settings = {};
}
return this.dataSourceJson.settings;
}
getAnnotations() {
if (this.getSettings().annotations == null) {
this.getSettings().annotations = [];
}
return this.getSettings().annotations;
}
}
//# sourceMappingURL=dataSourceOData.js.map