Custom Model Binding - Changing Property type in Post - entity-framework

I am working on a project where i receive objects from a client in a Post body and i map them to a model i created so i can store them in a db. One of the child classes in the body is an attributes class shown below attributes
When i use it in a Post, we have been getting the following data and the value field can be any type. In the end i want them all to be converted to strings Post Body
In my HttpPost in the controller, it fails to convert the json to this type because the one record is a bool. How do i allow multiple types?

Related

Add attribute to multiple created entities with same id pattern

I didn't found in documentation or source code the specifications to add attribute to multiple created entities with same id pattern. Only found the method for add attr to entity one by one (with array), but this method doesn't work (lazy method) when need add attribute to 100+ entities with id pattern (idIot:1, ... , idIot:N).
Any help?
The NGSIv2 method that allows to update several entities at once is POST /v2/op/update. It uses as parameter an array of entities:
entities, an array of entities, each entity specified using the JSON entity representation format (described in the section "JSON Entity Representation").
and in the cited "JSON Entity Respresentation" section we have:
An entity is represented by a JSON object with the following syntax:
The entity id is specified by the object's id property, whose value is a string containing the entity id.
The entity type is specified by the object's type property, whose value is a string containing the entity's type name.
Entity attributes are specified by additional properties, whose names are the name of the attribute and whose representation is described in the "JSON Attribute Representation" section below. Obviously, id and type are not allowed to be used as attribute names.
Thus, in conclusion, you cannot use a pattern of entities to update.
However, this has an easy workaround: you can create a script (or logical function in a wider program) to do that work, basically:
To query Orion with a given pattern, getting a set of entity (taking into account pagination, if the number of entities is large).
To update all these entities with POST /v2/op/update (taking into account doing it in batches, as there is a limit of 1MB in Orion request, if the number of entities to update is large).
You can have a look to this script, which works in this way (although in this case is to delete a set of entities instead of updating an attribute).

How can I post the custom field to Workfront through workfront REST API

In workfront, we want to create a custom form(custom fields) for an Issue. How can I use Workfront REST API to do a POST request and create the custom fields in a custom form for that issue in workfront?
https://developers.workfront.com/api-docs/api-explorer/
You POST the same as you would to a system field. Simply prefix the field name with DE:.
attask/api-internal//user/xxxxxxxxx?DE:foo=bar
The above sets the field 'foo' to the string 'bar'.
If the custom field is not present on the object (not on a custom form already attached) then you will first need to attach one.
attask/api-internal/user/xxxxxxxxxx?updates={objectCategories:[{categoryID:`"customformUUID`",categoryOrder:0,objCode:`"CTGY`"}]}

value vs. data in Symfony Forms - What is the difference and how to control the content?

what is the difference between the two fields data and value in Symfony Forms?
I have created a custom Form Type for my custom Task class which works fine in all my forms. To understand the internal workflow behind form better, I have observed the operation by adding some {{ dump(...) }}statements to my Twig files.
In all my forms the value and data fields of my Task type both hold the same information: A reference to the Task object.
However I have recognized, that some third party Form Types have different values for the two value and data fields: While the data fields holds a reference the underlying object the value field just contains an ID of this object (member field of the object). How is this achieved?
What exactly is the purpose of these two fields?
What is the difference between them?
How do I control/chance the content of
value field while still having the object reference in the data
field?

How to call inteface of intermediate class

Currently in my application i have such a classes:
Tag
Post which implements ITagAble/TagAbleInterface
Link which implements ITagAble/TagAbleInterface
I want my service to be working on interfaces. And also i have intermediate classes to map my post_tag and link_tag from database:
PostTag which contains post object and tag object and maybe date of added tag
LinkTag which contains link object and tag object and maybe date of added tag
So how to call interface of PostTag and LinkTag ? It's only gonna have some (same)method to set proper post or link object and date.
You should not have these intermediate classes. Those are a side effect of a relational database. You should not replicate the database structure in the class structure.
A Post and a Link should have a collection of Tags, Tags should have no relation to a ITagAble.

Create a model instance with a collection property set in SailsJS

I am working on a project using SailsJS as backend. In its waterline data model, I defined a model Abc. Abc has a property, images, which is a collection. Each value in images is an id of an instance of a different Image model.
When I post an object to '/abc', with images property of the object set to be a string containing ids of images, such as '1,2', the Abc instance creation process works, as shown by results of subsequent GET requests.
In current settings, when the 'POST /abc' process works, the newly created abc instance will be returned as server response.
POST /abc?property1=' '&property2=' '&images='1,2'...
server response:
{ id: 1000, property1=' ', property2=' ', ....}
However, server response does not contain populated images properties.
How can I request server to return populated images property for the newly created abc instance in its response?
You're probably should define afterCreate callback in your model. It is invoked each time when you use Model.create() with newly created record as first parameter. You can specify there anything that you want your model to return when you create new record.