How to specify a SmartREST 2.0 template with fragment/series name given by user - cumulocity

How can I define a custom SmartREST 2.0 template which behaves like the pre-defined static template 200 for creating measurements?
My goal is that the user can pass the name of fragment and series via MQTT to add generic properties.
I can only find documentation/examples for measurement creation where fragment and series are hard coded in the SmartREST template.

SmartREST 2.0 does not provide functionality to set keys as payload parameters. In general I would recommend making SmartREST templates as specific as possible. This saves transfer data volume and makes configuration more granular.
SmartREST 1.0 provides the functionality you are looking for. It provides full access to the associated JSON structure. Unfortunately this flexibility comes with the downside that it is only available though API and not via user interface. See here: https://cumulocity.com/guides/reference/smartrest/ and here: https://cumulocity.com/guides/device-sdk/mqtt/#smartrest-1

Related

Shopware 6 add entity extension fields to admin search

I wonder how to make some fields of an entity extension searchable in the administration through the "/api/search/my-entity" api-endpoint. By default they are not considered during search as it looks like.
I found the answer by debugging the search-endpoint:
The association-Field of the EntityExtension needs to have a SearchRanking-flag:
...->addFlags(new SearchRanking(SearchRanking::ASSOCIATION_SEARCH_RANKING))
Then you can add SearchRanking-flags in the EntityExtensionDefinition as you like, e.g.:
(new StringField('test', 'test'))->addFlags(new SearchRanking(SearchRanking::HIGH_SEARCH_RANKING)),
After that the fields are searchable via the search-endpoint :)
As far as the API is concerned, search functionality should automatically be generated following your custom entity definitions.
When it comes to facilitate Admin search for your entity, you need to add some code to the administration component as described in the docs: https://developer.shopware.com/docs/guides/plugins/plugins/administration/search-custom-data (even though it looks not fully up-to-date w.r.t to the current Shopware versions).

Extend backend models (Data/DTO) and sync with Spartacus

What is the approach if want to add a new attribute to the Product(Model/Data/DTO) in SAP Commerce Cloud and
wanna to access it in Spartacus (using Spartacus ProductService)?
How to introduce the attribute to the Product model in Spartacus and get it populated with the value from the backend?
This question can be seen as a general question how to apply this requirement to all models and keeping the models in sync between backend and frontend.
Thank you in advance.
In order to fetch additional attributes, you can configure the endpoint. See https://sap.github.io/cloud-commerce-spartacus-storefront-docs/connecting-to-other-systems/#configuring-endpoints for more information. There's no need to convert (normalize) the data necessarily, but you could do this as well. This is covered in the same documentation. And you could even replace the standard OCC adapters by a custom adapter if you need to adapt a 3rd party backend.
Once the data is loaded from the backend, it will be stored in the central store, and exposed by the facade without limitation. You might however want to enhance the default typing, in order to benefit from type-safety and not fallback to any. You can do this with the following:
// intro custom typing
interface CustomProduct extends Product {
customAttribute?: string;
}
// use typing for the observed data
product$: Observable<CustomProduct> = this.currentProductService.getProduct()

Is there a (documented) way to get attributes from the data point library via API?

In cumulocity cockpit you can specify data point attributes like a display name, unit, value range etc in a so called "data point library". I wonder how I can use these attributes when developing custom dashboard widgets.
I figured out that there is a fragmentType c8y_Kpi for API requests and a class called c8yKpi in the JS client lib which provides all necessary functions. It works fine in my custom widets, but the API/JS class are not documented.
Is there any (official, documented, supported) way to request attributes from the "data point library" via API or JS client library?
These kind of "internal" structures are not documented officially but like you already did you can of course use them in your code.
The risk coming with using undocumented structures are that they might change and then you would need to adapt your code.
Like you already found out yourself the way to get them on API is to call inventory with fragmentType=c8y_Kpi
/inventory/managedObjects?fragmentType=c8y_Kpi
No: currently there is no official, documented and support API for accessing the data point library.

How to retrieve Salesforce Page Layout Field Properties via API?

Context:
The Web interface coded in .NET (Grantee Portal for nonprofits applying for grants) is pulling information from the Salesforce Page Layout.
The Salesforce user we use to connect the Web interface with Salesforce via API has 'view all and edit all' rights
Issue:
As it is now, if a field is defined as Read-Only on the Page Layout in Salesforce, it is still editable on the web page (the Salesforce User we use has to have 'view all and edit all' rights)
What we are trying to achieve:
IF a field is defined as Read-Only on the Salesforce Page Layout
THEN the same field should be Read-Only on the Web interface page
Question:
To achieve the above, I guess that I need to fetch the field property for the Page Layout via API. Any ideas on how to do so?
Thank you!
Izumi.
You'll need Metadata API (the set of webservices that let you add new objects, fields, picklist values or even create classes & run unit tests).
Here's the API Guide: http://www.salesforce.com/us/developer/docs/api_meta/index.htm
Depending on how often you modify layouts you might decide "screw it, I'll just use Eclipse IDE". In that case you'd download all page layouts (they're XML files), point your C# app to them and let the magic happen.
Slightly more advanced is to use Migration Tool (Ant / Java based application that can be scripted for periodic download of same stuff).
Super advanced would be to use this API guide to write it in C#. It's not rocket science (here's the specification for Page Layout object and here's the Java sample code for the operation that retrieves the metadata... sorry, no C#). Actually you might be better off looking at this example though: http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_describelayout.htm
Seeing that you'll probably want to cache this info somewhere anyway (I can't imagine your user coming to your page, having to wait for the webservice callout to complete, then having his UI rendered) - pick your poison.
Or share the work within the team (1 person kicks off with files downloaded with Eclipse, other tries to figure out the C# code to retrieve them on demand).

Semantic store and entity hub

I am working on a content platform that should provide semantic features such as querying with SPARQL and providing rdf documents for the contained content.
I would be very thankful for some
clarification on the following
questions:
Did I get that right, that an entity
hub can connect several semantic
stores to a single point of access?
And if not, what is the difference
between a semantic store and an
entity hub?
What frameworks would you use to
store content documents as well as
their semantic annotation?
It is important for the solution to be able to later on retrieve the document (html page / docs such as pdf, doc,...) and their annotated version.
Thanks in advance,
Chris
The only Entityhub term that I know is belong to Apache Stanbol project. And here is a paragraph from the original documentation explaining what Entityhub does:
The Entityhub provides two main services. The Entityhub provides the
connection to external linked open data sites as well as using indexes
of them locally. Its services allow to manage a network of sites to
consume entity information and to manage entities locally.
Entityhub documentation:
http://incubator.apache.org/stanbol/docs/trunk/entityhub.html
Enhancer component of Apache Stanbol provides extracting external entities related with the submitted content using the linked open data sites managed by Entityhub. These enhancements of contents are formed as RDF data. Then, it is also possible to store those content items in Apache Stanbol and run SPARQL queries on top of RDF enhancements. Contenthub component of Apache Stanbol also provides faceted search functionality over the submitted content items.
Documentation of Apache Stanbol:
http://incubator.apache.org/stanbol/docs/trunk/
Access to running demos:
http://dev.iks-project.eu/
You can also ask your further questions to stanbol-dev AT incubator.apache.org.
Alternative suggestion...
Drupal 7 has in-built RDFa support for annotation and is more of a general purpose CMS than Semantic MediaWiki
In more detail...
I'm not really sure what you mean by entity hub, where are you getting that definition from or what do you mean by it?
Yes one can easily write a system that connects to multiple semantic stores, given the context of your question I assume you are referring to RDF Triple Stores?
Any decent CMS should be assigning documents some form of unique/persistent ID to documents so even if the system you go with does not support semantic annotation natively you could build your own extension for this. The extension would simply store annotations against the documents ID in whatever storage layer you chose (I'd assume a Triple Store would be appropriate) and then you can build appropriate query and presentation layers for querying and viewing this data as required.
http://semantic-mediawiki.org/wiki/Semantic_MediaWiki
Apache Stanbol
Do you want to implement a traditional CMS extended with some Semantic capabilities, or do you want to build a Semantic CMS? It could look the same, but actually both a two completely opposite approaches.
It is important for the solution to be able to later on retrieve the document (html page / docs such as pdf, doc,...) and their annotated version.
You can integrate Apache Stanbol with a JCR/CMIS compliant CMS like Alfresco. To get custom annotations, I suggest creating your own custom enhancement engine (maven archetype) based on your domain and adding it to the enhancement engine chain.
https://stanbol.apache.org/docs/trunk/components/enhancer/
One this is done, you can use the REST API endpoints provided by Stanbol to retrieve the results in RDF/Turtle format.