How to define a translator for an Integration Object Item Attribute -Hybris - integration

How can we define a translator for an Integration Object Item Attribute in SAP Commerce?
Below screenshot is a sample Integration Object Item Attribute definition.
Is it possible to define a translator for an attribute let us say attribute available in StockLevel. When the inbound requests inserts Integration Object data through odata2webservices API Post calls, the translator should get invoked and executes some business logic and updates the value of attribute (available)

You can try to create custom Populator (see: DefaultCollectionType2MapPopulator) and insert it into the defaultItemToIntegrationObjectMapConverter. It is important to implement the isApplicable() method correctly.

Related

How to GET only custom Field Names from Azure Form Recognizer API?

I trained a Custom Form Recognizer Model. It tests great. But I can't find the API endpoint to call that returns ONLY the key/value pairs for the form I sent the model to analyze.
Example:
I trained a custom model to find First name and Last name only
When I POST a PDF to the endpoint:
https://{my-project}.cognitiveservices.azure.com/formrecognizer/documentModels/{my-model}:analyze?api-version=2022-08-31
Then view JSON from the Operation-Location header:
https://form-rec-ocr-test.cognitiveservices.azure.com/formrecognizer/documentModels/{model-name}/analyzeResults/{GUID}?api-version=2022-08-31
I get aaaaallll the text on the submitted PDF instead of only the First name and Last name fields. I just want the key/value pairs to insert them into a table.
What is the correct API endpoint to call? The API docs here are focused on pre-build models instead of Custom Models.
For some reason, this was not lined out in any documentation I came across. Found the answer in this video #36:30.
The data was in the original JSON object, just at line 3300 under the document node.
Would simplify things if the Form Recognizer API could return ONLY the document array by defining a simple query parameter.

How to define custom handling for a response class in Spring doc?

I've been using arrow-kt and spring together a lot lately. I've actually constructed a bridge between the two with several key features, one of which is a spring controller that returns an Either will automatically unwrap it and either handle the exception (Left) or return the result (Right). My long term goal is to publish this as a library.
My latest obstacle is Swagger, or more accurately springdoc openapi. Obviously it is seeing the Either, but i want it to show only the Right value as the success response type. While I know there are annotations where I can set the response model on each controller method individually, I'm trying to avoid this.
My real goal is to setup some global converter so that wherever Swagger sees an Either it will automatically unpack this. I'm just not super familiar with the customization API in Spring doc, and everything I Google just points me to the ApiResponse annotation solution.
How can I define default handling for this type of response?

Is there a way to access entity value metadata in Watson Assistant using the JSON editor or SPEL

I'm attempting to define some relationships between entity values, using metadata.
I've uploaded metadata to an entity value using the Watson API v1. When I list the entities through the same API I can see the metadata. I have not been able to access the metadata from Watson Assistant though.
As a test I changed the entity value and checked through Watson Assistant it was changed, so I know I'm working with the correct workspace. I've also checked the entity using the JSON editor to verify it was defined and tried assigning the entity to a context variable.
I've tried several methods including:
#Room.building, #Room.metadata.building, entities['Room']?metadata?.building, entities['Room']?.building (all within the < ? tags). Using #Room and entities['Room']?.value returns the entity value correctly. It's accessing the metadata where it fails.
The metadata for building should not be returning null, but I"m either receiving a null or, depending on how I'm attempting to retrieve the value, a SPEL exception - no property on undefined.
Unfortunately, it is not possible to access metadata defined on user entities in the WA runtime at this moment. The metadata are only returned when making the direct API call. You could use cloud functions call though to get the metadata in WA although that is not ideal either.

Can't store attribute's value with properly type using IoTAgentUL

I need to store the values of devices' attributes with the right type in OrionCB's MongoDB.
As I was unable to perform that I dived into the code and found that IoTAgentUL (as well as IoTAgentJSON) uses OrionCB's API v1 instead of API v2.
As I can see API v1's updateContext sends data to MongoDB without it's type, so every measure is stored as text.
In the other hand I found that API v2's update entity send data to MongoDB with it's type. It produces that I can store attribute's values with it's type which benefits me when manipulating data (i.e. creating indexes, sorting, etc).
My question is if is there any workaround to solve this using the current implementations of IoT Agents.
The only workaround I can imagine is, once entities are automatically created by the IoT Agents, to update the type of such entities by your own. I mean, AFAIK, you can update both the value and the type of an entity.
In more details, I can think on a script that subscribes for all entities of certain type (those created by the agents). Then, when an entity is created this is notified to the script, which automatically updates the type of the entity's attributes.
Please observe you only need to modify the attribute's types once, just when the entities are created, not when an entity's attribute is updated; thus, something like an array or cache of already modified entities is needed in your script.

Custom validation rules entered by a user for an object

In my current project we have the following list of requirements for one of our microservices:
Any object can have the list of custom validation rules and validation rules might differ between objects (it might even be that an object has the list of unique validation rules)
Those custom validation rules can be configured from UI by a user who created initial version of the object
Any time when some specific events happen with the object(changes and updates) we need to verify that the changes do not violate any of custom validation rules entered in the beginning
We also should have the list of standard checks like date range checks, number of some items and elements in the object
For now we are going to save all of this validation rules for objects either
as JSON object that will contain details of validation rule
or serialized Groovy object (*Validator)
In both cases it will be saved in database and used any time when it is needed to go throught the list of validations rules and execute them.
I am not sure that both options are the best and may be there are some other ways to implement it. Do you know any patterns or approaches that can help to implement custom validation rules?
Thank you
For custom validations implementation I'd suggest you to use Java validation API. It's very powerful in conjunction with validation groups.
You initialize beans / appropriate POJO instances based on the user inputs, and then simply call validations like: Validator.validate(T object, java.lang.Class... groups)