How can we use the same Resource with different filters? - admin-on-rest

I have this Resource:
<Resource
options={{label: 'Assets'}}
name="assets"
list={AssetList}
show={AssetShow}
edit={AssetEdit}
create={AssetCreate}
remove={Delete}
icon={AssetsIcon}
/>
And I need to show exactly the same resource but filtered by one of its fields (i.e. type === 'printer' by default, filter being hidden), so that we create a "Printers" CRUD for the Assets:
<Resource
options={{label: 'Assets - Printers'}}
name="assets"
list={AssetList}
show={AssetShow}
edit={AssetEdit}
create={AssetCreate}
remove={Delete}
icon={AssetsIcon}
/>
How can we send a "custom" parameter to the Resource and use this for fetching the resource data with a filter? (and also filter the "create", etc)?

Related

Are FHIR-resource-Logical-Id's MANDATORY for "contained" fhir-resources?

I'm trying to get a clarification
Under the definition of what is a (fhir-resource-logical-id)
https://www.hl7.org/fhir/resource-definitions.html#Resource.id
The comment says:
The only time that a resource does not have an id is when it is being submitted to the server using a create operation.
We have having an internal "debate" on the "contained-reference".
https://build.fhir.org/references.html#contained
Example one from the article:
JSON
{
"resourceType" : "Condition",
"contained": [
{
"resourceType" : "Practitioner",
"id" : "p1",
"name" : [{
"family" : "Person",
"given" : ["Patricia"]
}]
}],
"asserter" : {
"reference" : "#p1"
}
}
XML
<Condition xmlns="http://hl7.org/fhir">
<contained>
<Practitioner>
<id value="p1"/>
<name>
<family value="Person"/>
<given value="Patricia"/>
</name>
</Practitioner>
</contained>
<!-- other attributes -->
<asserter>
<reference value="#p1" />
</asserter>
<!-- other attributes -->
</Condition>
So the "p1" (as the fhir-resource-logical-id) is populated....under the contained resourceType of "Practitioner".
So far, so good.
But there is another example with a comment in the example: (below xml)
<Patient xmlns="http://hl7.org/fhir">
<id value="something"/>
<contained>
<Provenance>
<!-- no id necessary (though still allowed) -->
<target>
<reference value="#"/>
</target>
</Provenance>
</contained>
<!-- other attributes -->
</Patient>
The xml-comment-part is (and I'll refer to this as the "comment-documentation") is:
<!-- no id necessary (though still allowed) -->
We are confused. Is this a "Provenance-ONLY" comment for a contained FHIR resource?
Or does this comment-documentation "
<!-- no id necessary (though still allowed) -->
" .. does this "comment-documentation" apply to any/all "contained" Fhir-Resource(s)?
The "comment-documentation" seems in conflict with the "The only time that a resource does not have an id is when it is being submitted to the server using a create operation" rule.
Another way to put it:
Does the rule "The only time that a resource does not have an id is when it is being submitted to the server using a create operation" (always and always) apply to "contained"-fhir-resources?
Thank you.
I wrote that, and I think I was just wrong when I did - just thinking that it wasn't needed functionally in that context, and didn't check whether it had to be present. This is a case where id is required

Azure Load test does not report data driven urls

I have a simple load test that basically executes a single webtest on a constant load. That webtest is hooked to an xml file data source that contains urls to my entire site.
When I execute the load test from my local environment, the test summary page reports the individual urls in the "Top 5 slowest pages" i.e. "https://mysite.or/page" . But when I execute the same test from Azure (i.e. changed Test run location to VSTS in .testsettings), the links are reported as "https://{{Enviroment}}{{Sitemap.url.loc}}". This seems to be just a reporting issue and I can validate that azure is correctly invoking the urls from the data source. Why would the tests from Azure not report the url constructed from the datasource?
Load Test Summary: Executed from Local
Same test executed on Azure
Webtest:
<?xml version="1.0" encoding="utf-8"?>
<WebTest Name="GenericSitemap" Id="02954e81-f3a7-4c9c-94f5-3a4304f88361" Owner="" Priority="2147483647" Enabled="True" CssProjectStructure="" CssIteration="" Timeout="0" WorkItemIds="" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" Description="" CredentialUserName="" CredentialPassword="" PreAuthenticate="True" Proxy="default" StopOnError="False" RecordedResultFile="" ResultsLocale="">
<Items>
<Request Method="GET" Guid="01c37ffa-92db-42e8-9d25-a042dcd0123d" Version="1.1" Url="https://{{Enviroment}}{{Sitemap.url.loc}}" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="https://{{Enviroment}}{{Sitemap.url.loc}}" ReportingName="" IgnoreHttpStatusCode="False" />
</Items>
<DataSources>
<DataSource Name="Sitemap" Provider="Microsoft.VisualStudio.TestTools.DataSource.XML" Connection="|DataDirectory|\..\Data\sitemap.xml">
<Tables>
<DataSourceTable Name="url" SelectColumns="SelectOnlyBoundColumns" AccessMethod="Random" />
</Tables>
</DataSource>
</DataSources>
<ContextParameters>
<ContextParameter Name="Enviroment" Value="mysite.net" />
</ContextParameters>
</WebTest>
Thanks to #AdrianHHH. I got it working by creating a requestPlugin and setting it on the data driven requests.
Here's my plugin:
[DisplayName("Set Request Params")]
[Description("Fix request urls when run from Azure")]
public class SetRequestParams : WebTestRequestPlugin
{
public override void PreRequest(object sender, PreRequestEventArgs e)
{
e.Request.ReportingName = e.Request.Url;
}
}

Sitecore Custom Index - WARN Could not map index document (field: _uniqueid

I have created my custom Index in Sitecore with FlatDataCrawler.
The Index has been created and I can see my documents in Solr.
The problem is, whenever I'm trying to get those documents in my code I see exception like this:
Object reference not set to an instance of an object.
And in sitecore log file I see this WARN:
ManagedPoolThread #4 14:29:09 INFO Solr Query - ?q=*:*&rows=1000000&fq=_indexname:(products_index)&wt=xml
ManagedPoolThread #4 14:29:09 WARN Could not map index document (field: _uniqueid; Value: fae308d2-233f-4f7f-a4fd-9d880e42ff13) - Object reference not set to an instance of an object.
This is my Index config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:search="http://www.sitecore.net/xmlconfig/search/">
<sitecore role:require="Standalone or ContentManagement" search:require="solr">
<contentSearch>
<configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
<indexes hint="list:AddIndex">
<index id="products_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
<param desc="name">$(id)</param>
<param desc="core">$(id)</param>
<param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" />
<configuration ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration">
<documentOptions type="Sitecore.ContentSearch.SolrProvider.SolrDocumentBuilderOptions, Sitecore.ContentSearch.SolrProvider">
<indexAllFields>false</indexAllFields>
</documentOptions>
</configuration>
<strategies hint="list:AddStrategy">
<strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/manual" />
</strategies>
<locations hint="list:AddCrawler">
<crawler type="Feature.ProductsIndex.Crawlers.CustomOrderCrawler, Feature.ProductsIndex" />
</locations>
</index>
</indexes>
</configuration>
</contentSearch>
</sitecore>
</configuration>
This is my code:
using (var searchContext = ContentSearchManager.GetIndex("products_index").CreateSearchContext())
{
int count = searchContext.GetQueryable<SearchResultItem>().Count(); //This works
var results = searchContext.GetQueryable<SearchResultItem>().ToList(); //Exception here!
}
See in your schema file , if you have
<uniqueKey>_uniqueid</uniqueKey>
<field name="_uniqueid" type="string" indexed="true" required="true" stored="true"/>
if not follow this link populate solr schema , and restart the solr service and then try to rebuild the index

How to create Orbeon custom control XBL with predefined visibility, control name, default value?

I have created a custom control (hidden text box with some predefined value), where I want to set visibility=false(), controlName="Mycustom", default value="This is my custom control" in XBL file. So that whenever we use that custom control from Orbeon Form Builder, it will come with all default values with no need to set anything.
XBL:
<xbl:xbl xmlns:xh="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:saxon="http://saxon.sf.net/"
xmlns:xbl="http://www.w3.org/ns/xbl"
xmlns:exf="http://www.exforms.org/exf/1-0"
xmlns:xxbl="http://orbeon.org/oxf/xml/xbl">
<metadata xmlns="http://orbeon.org/oxf/xml/form-builder">
<display-name lang="en">Epson Custom Controls</display-name>
</metadata>
<xbl:binding id="fr-custom" element="fr|custom" >
<metadata xmlns="http://orbeon.org/oxf/xml/form-builder">
<display-name lang="en">My Custom Control</display-name>
<icon lang="en">
<small-icon>/forms/orbeon/builder/images/input.png</small-icon>
<large-icon>/forms/orbeon/builder/images/input.png</large-icon>
</icon>
<templates>
<bind xxf:whitespace="trim"/>
<view>
<xf:input id="myCustom" ref="" xmlns="">
<xf:label>My Custom lable</xf:label>
<xf:hint ref=""/>
<xf:help ref=""/>
<xf:alert ref=""/>
</xf:input>
</view>
</templates>
</metadata>
</xbl:binding>
</xbl:xbl>
Using above control I want hidden text box with value='This is my custom control' and its control name should be Mycustom.
Update
I have tried with below changes, but it is not working
<templates>
<bind xxf:whitespace="trim" relevant="false()" xxf:default="'This is my custom control'"/>
<view>
<xf:input id="myCustom" ref="" xmlns="">
<xf:label>Success Message</xf:label>
<xf:hint ref=""/>
<xf:help ref=""/>
<xf:alert ref=""/>
</xf:input>
</view>
</templates>
With above changes now its working (control is hidden with some default value).
Can you please let me know how to put if condition
properties-local.xml:
<property as="xs:string" name="oxf.fr.detail.process.save-final-custom.*.*">
require-uploads
then validate-all
then save
if({xxf:instance('fr-form-instance')//customMessage} != null)
{
then success-message(message = "{xxf:instance('fr-form-instance')//customMessage}")
}
recover error-message("database-error")
</property>
Here I want to override this success-message if it properly configured from backed. If it's value is null then want to show OOTB message(don't override).
Update2
Integrated changes in Hybris. below are the changes I have made in Hybris
Create XBL > orbeon > custom > custom.xbl
<bind xxf:whitespace="trim" relevant="false()" xxf:default="'This is my custom control'"/>
Issue :- When we select custom control, it will bind without any lable/message/visibility etc. But if I refresh left control panel then label start appearing on the form. but still default message is not set.
Let's take the items you mentioned one by one:
visibility="false()" – I imagine you're referring to the relevant attribute in XForms, instead of the visibility attribute. (Form Builder calls this "visibility", because this is what it is, but in XForms, the attribute is relevant.) This can be done by having inside the <templates> a <bind relevant="false()"/>.
controlName="Mycustom" – You can't set the id of the control in XBL. (BTW, when using Form Builder, the XForms id is inferred from the control name defined by the form author in Form Builder.) The id is set by whoever uses the control, not whoever defines it, otherwise, for one, this would prevent you from having multiple instances of that control in the form.
default value="This is my custom control" – As in #1 above, you can do this with <bind xxf:default="'This is my custom control'">. Note the added single quotes, as the value of xxf:default is an XPath expression.

Orchard CMS Data Import

I am attempting to import data into Orchard CMS. I have a custom type, made up of parts and fields, and I am using the ImportExport module. I have exported some data from Orchard to ensure the XML schema is correct, but when importing, the only field that seems to be populating is the TitlePart Title. I have randomly generated a GUID for the identifier of each record. Orchard 1.4, ImportExport 1.4.
Example of one item of data:
<Orchard>
<Recipe>
<Name>Data Import</Name>
<Author>myaccount</Author>
</Recipe>
<Data>
<OurPropertiesDivision Id="/Identifier=94eff3237c714f98b021905c33d25ea9" Status="Published">
<LinkField.Link Text="This is a link" Url="http://stackoverflow.com" />
<MediaPickerField.ImageOne Url="~/test.jpg" Width="100" Height="100" />
<MediaPickerField.ImageTwo Url="~/test2.jpg" Width="100" Height="100" />
<MediaPickerField.ImageThree Url="~/test3.jpg" Width="100" Height="100" />
<TitlePart Title="Test Title" />
<CommonPart Owner="/User.UserName=myaccount" CreatedUtc="2012-04-04T23:03:39Z" PublishedUtc="2012-04-04T23:03:39Z" ModifiedUtc="2012-04-04T23:03:39Z" />
<IdentityPart Identifier="94eff3237c714f98b021905c33d25ea9" />
</OurPropertiesDivision>
</Data>
</Orchard>
This results in the following when looking at the imported entry:
Content list:
Edit screen:
The only field that is making it through the import is the TitlePart. How can I make this work in a way that I can bulk insert any type of field or part with data? I would also like to capture the Container for the Containable part.
EDIT: Adding content type metadata
<?xml version="1.0"?>
<!--Exported from Orchard-->
-<Orchard>
-<Recipe>
<Name>Generated by Orchard.ImportExport</Name>
<Author>myaccount</Author>
</Recipe> -<Metadata>
-<Types>
-<OurPropertiesDivision DisplayName="Our Properties - Division" ContentTypeSettings.Draftable="True" ContentTypeSettings.Creatable="True">
<CommonPart DateEditorSettings.ShowDateEditor="False" OwnerEditorSettings.ShowOwnerEditor="False"/>
<TitlePart/>
<OurPropertiesDivision/>
<ContainablePart/>
<IdentityPart/>
</OurPropertiesDivision>
</Types> -<Parts>
<CommonPart ContentPartSettings.Attachable="True"/> <TitlePart ContentPartSettings.Attachable="True"/> -<OurPropertiesDivision ContentPartSettings.Attachable="True">
<ImageOne.MediaPickerField DisplayName="Image One" MediaPickerFieldSettings.Required="False" HtmlFieldSettings.FlavorDefault="html"/>
<ImageTwo.MediaPickerField DisplayName="Image Two" MediaPickerFieldSettings.Required="False" HtmlFieldSettings.FlavorDefault="html"/>
<ImageThree.MediaPickerField DisplayName="Image Three" MediaPickerFieldSettings.Required="False" HtmlFieldSettings.FlavorDefault="html"/>
<Content.HtmlField DisplayName="Content" HtmlFieldSettings.FlavorDefault="html"/>
<Link.LinkField DisplayName="Link" HtmlFieldSettings.FlavorDefault="html" LinkFieldSettings.LinkTextMode="Required" LinkFieldSettings.TargetMode="NewWindow" LinkFieldSettings.Required="True"/>
</OurPropertiesDivision> <ContainablePart ContentPartSettings.Attachable="True"/> <IdentityPart ContentPartSettings.Attachable="True"/>
</Parts>
</Metadata>
</Orchard>
I ended up analyzing the database inserts generated by the admin, and manually importing the data in SQL.

Resources