How to avoid additional request for model data assigned to "dataSources"? (Component-preload.js) - sapui5

I'm defining a JSON data source in my manifest.json as follows (only relevant parts shown):
{
"_version": "1.8.0",
"sap.app": {
"id": "myAppID",
"dataSources": {
"application_datasource": {
"uri": "/model/application.json",
"type": "JSON"
}
}
}
},
"sap.ui5": {
"models": {
"application": {
"type": "sap.ui.model.json.JSONModel",
"dataSource": "application_datasource"
}
}
}
This works quite well; the JSON is loaded from the webserver.
When using the UI5-Tooling to build the app, I can see that the /model/application.json is actually included in the Component-preload.js under the key "/myAppID/model/application.json".
When loading the application from the dist-folder, the app still hits the webserver for the /model/application.json and is not pulling it from the Component-preload.js.
What am I missing here to make it use the already in memory existing data? As far as I can see, the manifest.json itself is already pulled from the Component-preload.js.

Related

Azure Data Factory Copy Data activity - Use variables/expressions in mapping to dynamically select correct incoming column

I have the below mappings for a Copy activity in ADF:
"translator": {
"type": "TabularTranslator",
"mappings": [
{
"source": {
"path": "$['id']"
},
"sink": {
"name": "TicketID"
}
},
{
"source": {
"path": "$['summary']"
},
"sink": {
"name": "TicketSummary"
}
},
{
"source": {
"path": "$['status']['name']"
},
"sink": {
"name": "TicketStatus"
}
},
{
"source": {
"path": "$['company']['identifier']"
},
"sink": {
"name": "CustomerAccountNumber"
}
},
{
"source": {
"path": "$['company']['name']"
},
"sink": {
"name": "CustomerName"
}
},
{
"source": {
"path": "$['customFields'][74]['value']"
},
"sink": {
"name": "Landlord"
}
},
{
"source": {
"path": "$['customFields'][75]['value']"
},
"sink": {
"name": "Building"
}
}
],
"collectionReference": "",
"mapComplexValuesToString": false
}
The challenge I need to overcome is that the array indexes of the custom fields of the last two sources might change. So I've created an Azure Function which calculates the correct array index. However I can't work out how to use the Azure Function output value in the source path string - I have tried to refer to it using an expression like #activity('Get Building Field Index').output but as it's expecting a JSON path, this doesn't work and produces an error:
JSON path $['customFields'][#activity('Get Building Field Index').outputS]['value'] is invalid.
Is there a different way to achieve what I am trying to do?
Thanks in advance
I have a slightly similar scenario that you might be able to work with.
First, I have a JSON file that is emitted that I then access with Synapse/ADF with Lookup.
I next have a For each activity that runs a copy data activity.
The for each activity receives my Lookup and makes my JSON usable, by setting the following in the For each's Settings like so:
#activity('Lookup').output.firstRow.childItems
My JSON roughly looks as follows:
{"childItems": [
{"subpath": "path/to/folder",
"filename": "filename.parquet",
"subfolder": "subfolder",
"outfolder": "subfolder",
"origin": "A"}]}
So this means in my copy data activity within the for each activity, I can access the parameters of my JSON like so:
#item()['subpath']
#item()['filename']
#item()['folder']
.. etc
Edit:
Adding some screen caps of the parameterization:
https://i.stack.imgur.com/aHpWk.png

MongoDB automatic (implicit) CSFLE broken with Micronaut 3

I've recently updated my app from Micronaut 2 to Micronaut 3, and as a result all Mongo automatic CSFLE encryption/decryption has stopped working.
If I create a ClientEncryption object and manually decrypt the field, that works, and the logging shows that it is fetching KMS and key information needed to decrypt it:
INFO org.mongodb.driver.client - executeStateMachine: READY
INFO org.mongodb.driver.client - executeStateMachine: NEED_MONGO_KEYS
INFO org.mongodb.driver.client - executeStateMachine: NEED_KMS
// manual decryption result here
But for the automatic process, it just prints the READY state only, and no encryption/decryption takes place.
Is there any examples showing automatic CSFLE working with Micronaut 3, or has anyone run into this issue? Could this be a bug with Micronaut 3?
The two relevant dependencies in the Micronaut 3 upgrade are:
implementation "io.micronaut.mongodb:micronaut-mongo-reactive:4.2.0" // driver
implementation "org.mongodb:mongodb-crypt:1.5.2" // uses libmongocrypt
and the mongodb-enterprise-cryptd v5.0.6 binary is installed on the ubuntu:20.04 OS that we're running the app on. The mongocryptdSpawnPath extra options property in the Mongo connection is pointed at the location of the installation.
Server version: Enterprise 4.2.21
I can't give exact schemaMap and DB details, but here is a similar one generated by the same code, for a DB called zoo and two collections using CSFLE called dogAnimals and catAnimals.
sample dogAnimals document:
{
"basicDetails": {
"dogName":"Barney", // should be encrypted
"age":5,
},
"furtherDetails": {
"dogBreedInfo": { // should be encrypted
"breedName": "Golden Retriever",
"averageLifeSpanInYears": 20
}
}
}
sample catAnimals document:
{
"catName":"Mrs Miggins", // should be encrypted
"age":2,
"catFacts": {
"favouriteHuman": "Robert Bingley", // should be encrypted
"mood": "snob"
}
}
Matching schemaMap:
{
"zoo.dogAnimals": {
"bsonType": "object",
"encryptMetadata": {
"keyId": [
{
"$binary": {
"base64": "12345678",
"subType": "04"
}
}
]
},
"properties": {
"basicDetails": {
"bsonType": "object",
"properties": {
"dogName": {
"encrypt": {
"bsonType": "string",
"algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"
}
}
}
},
"futherDetails": {
"bsonType": "object",
"properties": {
"dogBreedInfo": {
"encrypt": {
"bsonType": "object",
"algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Random"
}
}
}
}
}
},
"zoo.catAnimals": {
"bsonType": "object",
"encryptMetadata": {
"keyId": [
{
"$binary": {
"base64": "12345678",
"subType": "04"
}
}
]
},
"properties": {
"catName": {
"encrypt": {
"bsonType": "string",
"algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Random"
}
},
"catFacts": {
"bsonType": "object",
"properties": {
"favouriteHuman": {
"encrypt": {
"bsonType": "string",
"algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Random"
}
}
}
}
}
}
}
Writing as answer since it's quite big.
But for the automatic process, it just prints the READY state only
AFAIK, this doesn't say a lot since this information can be cached from previous attempts (if it's not first run).
I've tried your above documents and schemaMap and it encrypts 3 fields from 4 your cases with auto encryption, but it doesn't work with dogs.furtherDetails, because you have a typo: furtherDetails vs futherDetails. So make sure there are no other typos in your schemaMap.
After much debugging it turns out the JNA library being used is not invoking the crypto binaries correctly, so it sounds like a bug. Will report this to Mongo and see if they can help fix this....

API Management API Schema-Definition create - Multiple definitions under 1 schema at a time

I am trying to use the REST API PUT call to
https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiName}/schemas/{schemaId}?api-version=2021-01-01-preview
as an equivalent powershell cmdlet doesn't function as expected for adding schema-definitions. But the problem is even with REST API call, it is able to add one definition at a time. If my schema has more than 1 definition, when I fire the 2nd and subsequent PUT call it overwrites the previously written definition, and finally only 1 definition remains. Tried adding the If-Match to Request Header on 2nd and subsequent calls too, but in vain.
Tried adding multiple definitions under "schemas" as array of json, but even if that creates multiple definitions in 1 go, the DefinitionName are 0, 1, 2, 3 etc. and not actual names given in the input json body.
Multiple Definition Sample below -
"properties": {
"contentType": "application/vnd.oai.openapi.components+json",
"document": {
"components": {
"schemas": [
{
"Definition1": {
"type": "object",
"properties": {
"String1": {
"type": "string"
}
}
},
"Definition2": {
"type": "object",
"properties": {
"String2": {
"type": "integer"
}
}
}
}
]**
}
}
}
}
Does the PUT call allow putting definitions at once and if so, how?
Found the issue in the JSON being PUT on the REST API request.
The multiple definition json has to be like this -
{
"properties": {
"contentType": "application/vnd.oai.openapi.components+json",
"document": {
"components": {
"schemas": {
"Definition1": {
"type": "object",
"properties": {
"String1": {
"type": "string"
}
}
},
"Definition2": {
"type": "object",
"properties": {
"String2": {
"type": "integer"
}
}
}
}
}
}
}
}
The definitions given under "schemas" need not be put inside []. Just specify as per the above json structuring and we should be good.

Cannot read property 'read' of undefined [duplicate]

This question already has answers here:
Global Model Not Accesible
(4 answers)
How to get model on onInit?
(2 answers)
Closed 18 days ago.
I created a mockserver for testing purpose on my sapui5 app.
The definition of the dataSources structure in the manifest.json file looks as following:
"dataSources": {
"NorthwindService": {
"uri": "/",
"type": "OData",
"settings": {
"odataVersion": "2.0",
"localUri": "localService/metadata.xml"
}
}
}
and the model definition:
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "ch.app.northwind.i18n.i18n"
}
},
"northwind": {
"uri": "",
"type": "sap.ui.model.odata.v2.ODataModel",
"settings": {
"defaultOperationMode": "Server",
"defaultBindingMode": "OneWay",
"defaultCountMode": "Request"
},
"dataSource": "NorthwindService",
"preload": true
}
},
calling the model controller:
this.getView().getModel("northwind")
.read("/Customers/$count", {
success: function(oData) {
jQuery.sap.log.info(oData);
},
error: function(oError) {
jQuery.sap.log.info(oError);
}
});
It complains:
Overview.controller.js?eval:29 Uncaught (in promise) TypeError: Cannot read property 'read' of undefined
at f.queryTotalCustomers (Overview.controller.js?eval:29)
at f.onInit (Overview.controller.js?eval:12)
at f.a.fireEvent (EventProvider-dbg.js:228)
at f.a.fireEvent (Element-dbg.js:431)
at f.fireAfterInit (ManagedObjectMetadata-dbg.js:568)
at r (Component-dbg.js:162)
at f.h.runAsOwner (Component-dbg.js:549)
at P (View-dbg.js:429)
at eval (View-dbg.js:467)
What am I doing wrong?
First of all: do not set '/' or empty URI for your data source and model. Give them a path you like, different than that.
'/' is reserved for the main page, or the index.html
Second, make sure get your model once it is instantiated and no before. Probably you are getting the model in the onInit event, when it is not ready yet. Use another event or set an event handler for the 'metadataLoaded' event of your model.

How do I add SAP Gateway services to an existing SAP WEB IDE Project?

I've imported a SAP WEB IDE project from SAP Build....
All looks great, but now I need to add in my Gateway services to handle oData etc.
I've setup my SAP Cloud Connector to and Destinations.
How specifically do I add these as all tutorials seems to start by including the service as part of a template.
You have to do some steps to make this work:
implement the service definition in your manifest.json file:
"sap.app": {
[...],
"dataSources": {
"mainService": {
"uri": "/your/path/to/service",
"type": "OData",
"settings": {
"odataVersion": "2.0",
"localUri": "localService/metadata.xml"
}
}
},
[...]
},
implement the model definition in your manifest.json file:
"models": {
[...],
"": {
"dataSource": "mainService",
"settings": {
"metadataUrlParams": {
"sap-documentation": "heading"
},
"defaultBindingMode": "TwoWay"
}
}
},
You can go to the New>oData service menu from the project and create it that way too.