Handling validations of required fields of a map inside a list in Moqui - moqui

For adding validations for the mandatory fields for a service being developed for a REST API, I am able to use the “required” attribute which validates the fields when set to true. This worked as expected for parameters marked with required=”true”, in a map.
However, for the use-case where I have a list, say, I want my service to take items list as input and would like to validate some required fields for each item, it does not automatically validate the fields with required="true".
I am able to handle this by adding extra logic in the code, but wanted to check if there is a recommended way for this or if anything is missed here which can automatically handle such validations in Moqui?
Example service definition:
<service verb="create" noun="Example">
<in-parameters>
<parameter name="user" type="Map" required="true">
<parameter name="firstName" required="true"/>
<parameter name="lastName" required="true"/>
</parameter>
<!-- Below list does not validate required fields -->
<parameter name="items" type="List" required="true">
<parameter name="itemMap" type="Map" required="true">
<parameter name="name" required="true"/>
<parameter name="description"/>
</parameter>
</parameter>
</in-parameters>
<actions>
...
</actions>
</service>

Related

Can I display in the run-GUI the order of the parameters defined in parameters.xml?

For example, for the following parameters defined in the parameters.xml, can I explicitly define the order of the parameters that they appear in the running GUI?
I do not thing they are ordered alphabetically.
<parameter name="Metabolism_min" displayName="2.1.2 Agent Metabolism (minimum)" type="int" defaultValue="1" />
<parameter name="Metabolism_max" displayName="2.1.2 Agent Metabolism (maximum)" type="int" defaultValue="4" />
<parameter name="InitEndownment_min" displayName="2.1.3 Agent Initial Sugar (minimum)" type="int" defaultValue="50" />
<parameter name="InitEndownment_max" displayName="2.1.3 Agent Initial Sugar (maximum)" type="int" defaultValue="100" />
The way to do this is to use the display name as the ordering. For example, if I wanted to have the minimum values show up above the maximum values, I could do something like:
<parameter name="Metabolism_min" displayName="2.1.2.a Agent Metabolism (minimum)" type="int" defaultValue="1" />
<parameter name="Metabolism_max" displayName="2.1.2.b Agent Metabolism (maximum)" type="int" defaultValue="4" />
<parameter name="InitEndownment_min" displayName="2.1.3.a Agent Initial Sugar (minimum)" type="int" defaultValue="50" />
<parameter name="InitEndownment_max" displayName="2.1.3.b Agent Initial Sugar (maximum)" type="int" defaultValue="100" />
And this would result in the following:

Name of the user who has processed the cube

There is a code piece in which I have to get the username of the user who has processed the cube or has made any changes in the cube structure.
I have searched in the SSAS DMV's, but didn't find what I needed; I only found the last processed time, but not the name of the user.
Any suggestions?
You can track this using an Extended Event. Add the ProgressReportBegin and ProgressReportEnd events which are for processing. These events include the NTUserName and StartTime fields which you can use to find who processed the cube and when. The Extended Event will need to be running when the cube is processed to capture this. The following is an example XMLA command which can be run when connected to your SSAS database in SSMS to create an Extended Event that tracks cube processing and outputs the results to a file. Of course many of these options are just defaults and you may want to make adjustments as necessary.
https://learn.microsoft.com/en-us/sql/analysis-services/instances/monitor-analysis-services-with-sql-server-extended-events?view=sql-server-2017
<Create xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
<ObjectDefinition>
<Trace>
<ID>XE_Cube_Process</ID>
<Name>XE_Cube_Process</Name>
<XEvent xmlns="http://schemas.microsoft.com/analysisservices/2011/engine/300/300">
<event_session name="XE_Cube_Process" dispatchLatency="0" maxEventSize="0" maxMemory="4" memoryPartition="none" eventRetentionMode="AllowSingleEventLoss" trackCausality="true" xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
<event package="AS" name="ProgressReportEnd" />
<event package="AS" name="ProgressReportBegin" />
<target package="package0" name="event_file">
<parameter name="filename" value="C:\Test\XE_Cube_Process.xel" />
<parameter name="max_file_size" value="4096" />
<parameter name="max_rollover_files" value="10" />
<parameter name="increment" value="1024" />
</target>
</event_session>
</XEvent>
</Trace>
</ObjectDefinition>
</Create>

Inheritance: Criterion on entity type and sub class properties

I have a inheritance hierarchy which I have mapped in NHibernate using Table-per-class. My mappping file looks like the one below (lots of properties omitted).
To query this hierarchy, I am building a dynamic DetachedCriteria for Message based on filter input from the user. Messages (of any type in the hierarchy) should be returned to the user in one list.
I would like to build a criteria based on the type of message, ie. the user could specify to get all messages of type SMSMessage or EmailMessage with a ReceivedDate > '2009-01-01'. How would I go about to do that?
In the same query, the user could specify that if the Message is an InternalMessage, it should have Priority = 2. How would I specify such type-specific predicates?
All this is possible to do in LINQ, so I am hoping I can do it in NHibernate as well.
<class name="Message" table="Message" abstract="true" discriminator-value="null">
<id name="MessageId">
<generator class="identity" />
</id>
<discriminator column="Type" type="byte" />
<property name="ParentId" />
<property name="ReceivedDate" />
...
<subclass name="SMSMessage" discriminator-value="0">
<property name="Text" column="Text" />
...
</subclass>
<subclass name="MMSMessage" discriminator-value="1">
<property name="Subject" />
...
</subclass>
<subclass name="EmailMessage" discriminator-value="2">
<property name="BodyPlainText" />
...
</subclass>
<subclass name="InternalMessage" discriminator-value="4">
<property name="Priority" />
...
</subclass>
</class>
I kind of figured this out myself, but in the end I ended up reverting to pure SQL since I hit too many roadblocks with HQL/Criterias. Anyways, I can share how I did this.
Maybe not pretty, but I solved it by adding the discriminator column as a regular property to the top level class in the hierarchy (Message) and employed restrictions against that column.
It turns out that you can specify restrictions against properties for subclasses even in the top-level query, so this was easier than I thought. It was just a matter of specifying the restrictions.

SOAP call with query on result (SSRS, Sharepoint)

I created a report in VS using a shared data source which is connected to a sharepoint list. In the report I created a dataset with a SOAP call to the data source so I get the result from the sharepoint list in a table.
this is the soap call
<Query>
<SoapAction>http://schemas.microsoft.com/sharepoint/soap/GetListItems</SoapAction>
<Method Namespace="http://schemas.microsoft.com/sharepoint/soap/" Name="GetListItems">
<Parameters>
<Parameter Name="listName">
<DefaultValue>{BD8D39B7-FA0B-491D-AC6F-EC9B0978E0CE}</DefaultValue>
</Parameter>
<Parameter Name="viewName">
<DefaultValue>{E2168426-804F-4836-9BE4-DC5F8D08A54F}</DefaultValue>
</Parameter>
<Parameter Name="rowLimit">
<DefaultValue>9999</DefaultValue>
</Parameter>
</Parameters>
</Method>
<ElementPath IgnoreNamespaces="True">*</ElementPath>
</Query>
THis works fine, I have a result which I can show in a report, but I want to have the ability to select a parameter to filter the result on. I have created a parameter and when I preview the Report I see the dropdownbox which I can use to make a selection from the Title field, when I do this it still shows the first record, obviously it doens't work yet (DUH!) because I need to create a query somewhere, But! I have no idea where, I tried to include
<Where>
<Eq>
<FieldRef Name="ows_Title" />
<Value Type="Text">testValue</Value>
</Eq>
</Where>
in the the soap request but it didn't worked... I've searched teh intarwebz but couldn't find any simliar problems... kinda stuck now...any thoughts on this?
EDIT
Here's the query I used according to the blogpost Alex Angas linked.
<Query>
<SoapAction>http://schemas.microsoft.com/sharepoint/soap/GetListItems</SoapAction>
<Method Namespace="http://schemas.microsoft.com/sharepoint/soap/" Name="GetListItems">
<queryOptions></queryOptions>
<query><Query>
<Where>
<Eq>
<FieldRef Name="ows_Title"/>
<Value Type="Text">someValue</Value>
</Eq>
</Where>
</Query></query>
<Parameters>
<Parameter Name="listName">
<DefaultValue>{BD8D39B7-FA0B-491D-AC6F-EC9B0978E0CE}</DefaultValue>
</Parameter>
<Parameter Name="viewName">
<DefaultValue>{E2168426-804F-4836-9BE4-DC5F8D08A54F}</DefaultValue>
</Parameter>
<Parameter Name="rowLimit">
<DefaultValue>9999</DefaultValue>
</Parameter>
</Parameters>
</Method>
<ElementPath IgnoreNamespaces="True">*</ElementPath>
</Query>
I tried to put the new query statement in every possible way in the existing, but it doesn't work at all, I do not get an error though so the code is valid, but I still get an unfiltered list as return... pulling my hair out here!
A post at:
http://social.msdn.microsoft.com/forums/en-US/sqlreportingservices/thread/1562bc7c-8348-441d-8b59-245d70c3d967/
Suggested using this syntax for placement of the <Query> node (this example is to retrieve the item with an ID of 1):
<Query>
<SoapAction>http://schemas.microsoft.com/sharepoint/soap/GetListItems</SoapAction>
<Method Namespace="http://schemas.microsoft.com/sharepoint/soap/" Name="GetListItems">
<Parameters>
<Parameter Name="listName">
<DefaultValue>{CE7A4C2E-D03A-4AF3-BCA3-BA2A0ADCADC7}</DefaultValue>
</Parameter>
<Parameter Name="query" Type="xml">
<DefaultValue>
<Query>
<Where>
<Eq>
<FieldRef Name="ID"/>
<Value Type="Integer">1</Value>
</Eq>
</Where>
</Query>
</DefaultValue>
</Parameter>
</Parameters>
</Method>
<ElementPath IgnoreNamespaces="True">*</ElementPath>
</Query>
However this would give me the following error:
Failed to execute web request for the specified URL
With the following in the details:
Element <Query> of parameter query is missing or invalid
From looking at the SOAP message with Microsoft Network Monitor, it looks as though the <Query> node is getting escaped to <Query> etc, which is why it fails.
However, I was able to get this to work using the method described in Martin Kurek's response at:
http://www.sharepointblogs.com/dwise/archive/2007/11/28/connecting-sql-reporting-services-to-a-sharepoint-list-redux.aspx
So, I used this as my query:
<Query>
<SoapAction>http://schemas.microsoft.com/sharepoint/soap/GetListItems</SoapAction>
<Method Namespace="http://schemas.microsoft.com/sharepoint/soap/" Name="GetListItems">
<Parameters>
<Parameter Name="listName">
<DefaultValue>{CE7A4C2E-D03A-4AF3-BCA3-BA2A0ADCADC7}</DefaultValue>
</Parameter>
<Parameter Name="query" Type="xml">
</Parameter>
</Parameters>
</Method>
<ElementPath IgnoreNamespaces="True">*</ElementPath>
</Query>
And then defined a parameter on the dataset named query, with the following value:
<Query><Where><Eq><FieldRef Name="ID"/><Value Type="Integer">1</Value></Eq></Where></Query>
I was also able to make my query dependent on a report parameter, by setting the query dataset parameter to the following expression:
="<Query><Where><Eq><FieldRef Name=""ID""/><Value Type=""Integer"">" &
Parameters!TaskID.Value &
"</Value></Eq></Where></Query>"
See the question and answers for GetListItems Webservice ignores my query filter. This shows you how (and how not to) set up your SOAP call to include a query. You probably need to wrap your query with another <Query></Query>.
You have your FieldRef as
ows_Title
I believe it should just be Title.
When you get results from the SOAP request all your field name will begin with
ows_
Brilliant, thanks. This solution worked for queryOptions also.
In the Query:
<Parameter Name="queryOptions" Type="xml">
</Parameter>
And in the parameters list of the dataset:
Name: queryOptions
Value: <QueryOptions><Folder>Shared Documents/MyFolder</Folder></QueryOptions>

Mapping multiple Values to a Value Object in NHibernate

i'm fairly new to NHibernate and although I'm finding tons of infos on NHibernate mapping on the web, I am too silly to find this piece of information.
So the problem is, i've got the following Model:
this is how I'd like it to look. One clean person that has two Address Properties.
In the database I'd like to persist this in one table.
So the Person row would have a ShippingStreetname and a Streetname Column, the one mapped to ShippingAddress.Streetname and the other to Address.StreetName
I found an article on fluent interfaces, but still haven't figured out how to do this through the XML Configuration.
Thanks in advance!
Update: I found the solution to this by myself. This can be done through the node and works rather straightforward.
To achieve the mapping of Address and ShippingAddress I just had to add the following to the
<component name="Address" class="Address">
<property name="Streetname"></property>
<property name="Zip"></property>
<property name="City"></property>
<property name="Country"></property>
</component>
<component name="ShippingAddress" class="Address">
<property name="Streetname" column="ShippingStreetname" />
<property name="Zip" column="ShippingZip" />
<property name="City" column="ShippingCity" />
<property name="Country" column="ShippingCountry" />
</component>
Ok. I found the solution myself.
The key is the construct in the XML configuration and it works rather nicely.
Here is how it's done:
<component name="Address" class="Address">
<property name="Streetname"></property>
<property name="Zip"></property>
<property name="City"></property>
<property name="Country"></property>
</component>
<component name="ShippingAddress" class="Address">
<property name="Streetname" column="ShippingStreetname" />
<property name="Zip" column="ShippingZip" />
<property name="City" column="ShippingCity" />
<property name="Country" column="ShippingCountry" />
</component>
you could configure this as two relations. e.g.
<many-to-one name="ShippingAddress" class="Yournamespace.Address"/>
<many-to-one name="Address" class="Yournamespace.Address"/>
You dont even need an Id for an address. Just think how expensive is to maintain an Id. You have concurrency problems, you need uniqueness, and so on. This is the aim of the ValueObjects (do not get confused with System.ValueObject see DDD definition for ValueObject). In this case Address is a ValueObject so it does not required an Id. And if you need a collection of Address you map it like a "" see http://www.nhforge.org/doc/nh/en/index.html#collections-ofvalues.