AEM not able to use Content Fragment variations in a Fragment reference data types - aem

I don't see an option to select a Content fragment variation to be used with fragment reference data type. Wondering if I'm missing something or if any other data type that can use Content fragment variations.

You can't select a specific variation directly in the picker. The intent of the CF is supposed to be more holistic to include all variations, then allow the consumer to determine what variation fits the need.
If you do need a specific variation, and you have them consistently named, you could add a field to name which variation should be included. Then the query could filter based on that provided value so that it can inform the consumer which of the _variations to use.

Related

When using Virtual Documents how can a template be used with different report parameters?

I'm using a virtual document structure generated by a script to create a document from EA, and I'm trying to use the same template fragment several times with different elements and different headings.
For example, I have an element which describes the input data to one program, and the output data to another program, so I can't really store the information in the element I'm documenting.
Where it is the input, I want one heading (and similar references within the template), and where it is output I want different values for the headings.
I've tried using the ReportTitle tagged value in the individual <model document> element, but this appears to be ignored and only the <report package> value is used throughout (which makes me wonder why they are there in the first place).
While I could create multiple templates all referring to the same fragment and hard-code the different headings, but that is messy, and as I already have fragments within fragments so it could result in a lot of almost identical templates and fragments. Variables that I can set for each <model document> would be much preferable.
Has anyone got a better approach than this? Thanks!
I don't think there's an easy solution.
If there is a way to determine based on the element, package, or diagram ID whether you should use one title or the other then you could use a script or SQL fragment to return the correct title.
If that is not the case I guess the only possibility is to hardcode the different titles in your templates.
In order to avoid too much duplication you could create a template with only the title and use that on a model document. Since you are generating the modeldocuments by a script anyway that doesn't cost any user time.

A way of describing both setup price and ongoing price in schema.org services

So i'm setting up my ld+json structured data, using Schema.org schemas. I am adding products with Offers but they only have a single price parameter.
I also looked at PriceSpecification too, but there is only "range" and "price".
Should I use 2 PriceSpecifications (or 2 Offers?) with visibly different names, or is there another option I haven't come across? Don't want search engines to get confused.
Thanks for any help.
You can use multiple PriceSpecifications. However "typically, only the subclasses of this type are used for markup." UnitPriceSpecification would be the best fit, or the setup price can be of type DeliveryChargeSpecification.
Alternatively, you can use a single CompoundPriceSpecification with multiple priceComponent properties, each of type UnitPriceSpecification. "The name property of the attached unit price specification for indicating the dimension of a price component"

How do I create a validator for a single collection?

I need to build a custom id validator that will apply to a single collection, whose id will always be pre-defined (won't need a generator).
In the docs about id generators, it's written:
Currently the configuration of the custom generator applies to every resources (buckets, groups, collections, records). This tiny limitation can easily be fixed, don’t hesitate to get in touch with us!
But there is nothing documented about id validation.
So, how do I:
Implement an id validator, that
Will apply to one collection only?
By default cliquet uses a generator which accepts the following regular expression r'^[a-zA-Z0-9][a-zA-Z0-9_-]*$' (All letters and numbers + underscore and "-").
Before you chose to have a different ID validation mechanism, ensure you really need to.
Now, if that's not enough, you would need to select the proper validator depending on some configuration or already existing values, but this is not implemented in cliquet / kinto.
https://github.com/mozilla-services/cliquet/blob/master/cliquet/resource/init.py#L147 is probably a good place to look at / start with.

Does order matter? Adding an AlternateView to MailMessage.AlternateViews

I vaguely recall reading -somewhere- that the order in which an AlternateView is added to the MailMessage.AlternateViews collection matters when determining which AlternateView should be displayed. I recall it being based on the ability to display the message and, if the device doesn't support HTML for example, fallback to HTML. Unfortunately, I can't find the original article nor any other article mentioning how this should work.
Does the order in which an AlternateView gets added to the MailMessage.AlternateViews collection matter? If so, how does it work? Any documentation?
The order is important, according to RFC1521 - MIME (Multipurpose Internet Mail Extensions).
In general, user agents that compose multipart/alternative entities
must place the body parts in increasing order of preference, that is,
with the preferred format last
MailMessage.Attachments does use the order you add them in - so make sure the views are added to that collection in the correct order, with lowest priority first and the preferred (probably text/html) view last.

REST best practice for getting a subset list

I read the article at REST - complex applications and it answers some of my questions, but not all.
I am designing my first REST application and need to return "subset" lists to GET requests. Which of the following is more "RESTful"?
/patients;listType=appointments;date=2010-02-22;user_id=1234
or
/patients/appointments-list;date=2010-02-22;user_id=1234
or even
/appointments/2010-02-22/patients;user_id=1234
There will be about a dozen different lists that I need to return. In some of these, there will be several filtering parameters and I don't want to have big 'if' statements in my server code to select the subsets based on which parameters are present. For example, I might need all patients for a specific doctor where the covering doctor is another and the primary doctor is yet another. I could select with
/patients;rounds=true;specific_id=xxxx;covering_id=yyyy;primary_id=zzzz
but that would require complicated branching logic to get the right list, where asking for a specific subset (rounds-list) will achieve that same thing.
Note that I need to use matrix parameters instead of query parameters because I need to do filtering at several levels of the URL. The framework I am using (RestEasy), fully supports matrix parameters.
Ralph,
the particular URI patterns are orthogonal to the question how RESTful your application will be.
What matters with regard to RESTfulness is that the client discovers how to construct the URIs at runtime. This can be achieved either with forms or URI templates. Both hypermedia controls tell the client what parameters can be used and where to put them in the URI.
For this to work RESTfully, client and server must know the possible parameters at design time. This is usually achieved by making them part of the specification of the link relationship.
You might for example define a 'my-subset' link relation to have the meaning of linking to subsets of collections and with it you would define the following parameters:
listType, date, userID.
In a link template that spec could be used as
<link rel="my-subset' template="/{listType}/{date}/patients;user_id={userID}"/>
Note how the actual parameter name in the URI is decoupled from the specified parameter name. The value for userID is late-bound to the URI parameter user_id.
This makes it possible for the URI parameter name to change without affecting the client.
You can look at OpenSearch description documents (http://www.opensearch.org) to see how this is done in practice.
Actually, you should be able to leverage OpenSearch quite a bit for your use case. Especially the ability to predefine queries would allow you to describe particular subsets in your 'forms'.
But see for yourself and then ask back again :-)
Jan
I would recommend that you use this URL structure:
/appointments;user_id=1234;date=2010-02-22
Why? I chose /appointments because it is simple and clear. (If you have more than one kind of appointment, let me know in the comments and I can adjust my answer.) I chose the semicolons because they don't imply hierarchy between user_id and date.
One more thing, there is no reason why you should limit yourself to just one URL. It is just fine to have multiple URL structures that refer to the same resource. So you might also use:
/users/1234/appointments;date=2010-02-22
To return a similar result.
That said, I would not recommend using /dates/2010-02-22/appointments;user_id=1234. Why? I don't think, in practice, that /dates refers to a resource. Date is an attribute of an appointment but is not a noun on its own (i.e. it is not a first-class kind of thing).
I can relate to what David James answered.
The format of your URIs can be like he suggested:
/appointments;user_id=1234;date=2010-02-22
and / or
/users/1234/appointments;date=2010-02-22
while still maintaining the discoverability (at runtime) of your resource's URIs (like Jan Algermissen suggested).