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

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:

Related

Handling validations of required fields of a map inside a list in 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>

NHibernate converting string parameters to nvarchar instead of varchar. How can I stop this?

I have a class mapped to a view and am searching on first and last names in order to search for patient records. The view ultimately looks at the first and last name fields on the patient table (possibly others as well depending on input). When the criteria converts to SQL, it's entering my strings as nvarchar parameters. I've already used type="AnsiString" and length="50" on my mapping, but it still is converting these to nvarchar, which is causing a performance hit on my query.
<class name="PatientSearchResult" table="vw_PatientSearch" mutable="false" >
<id name="Id" type="Guid" column="PatientId"/>
<property name="MedicalRecordNumber" type="AnsiString" length="50" />
<property name="Title" />
<property name="FirstName" type="AnsiString" length="50" />
<property name="MiddleName" />
<property name="LastName" type="AnsiString" length="50" />
<property name="Nickname" />
<property name="Suffix" />
<property name="DateOfBirth" />
<property name="IsRestricted" />
<property name="IsDeleted" />
<component name="Address">
<property name="StreetAddress1" />
<property name="StreetAddress2" />
<property name="City" />
<property name="State" />
<property name="PostalCode" />
</component>
</class>
SQL Profiler is showing the output SQL as using nvarchar parameters and prefixing all of my strings with N to cast them.
Am I missing something? Is there anything else that needs to be done on the criteria or the mapping? Additionally, the length of the parameters is not a constant 50 either. I am using NHibernate 2.1.
Try using the sql-type attribute in your mappings:
<property name="FirstName" length="50" />
<column sql-type="varchar(50)" />
</property>
What performance issues are you having? It seems unlikely to me that treating strings as unicode would affect performance all that much.
Try this
<property name="FirstName" length="50">
<column name="first_name" sql-type="varchar(50)" />
</property>

NHibernate mapping with custom loader doesn't work

I have a class mapped with NHibernate and I'm trying to use a custom sql-query for loading. Special thing is that it uses a composite-id but I would expect that that's not a problem here.
Here's a simplified version of the mapping:
<class name="Person" mutable="false">
<composite-id>
<key-property name="PropertyA" column="propA" type="int" />
<key-property name="PropertyB" column="propB" type="string" />
</composite-id>
<property name="PropertyC" column="propC" type="datetime" />
<loader query-ref="loadPersons" />
</class>
<sql-query name="loadPersons">
<return class="PV" />
<![CDATA[
SELECT propA, propB, propC FROM MyPersons
]]>
</sql-query>
The problem is that the loader is completely ignored. The query sent to the database is completely generated as if the <loader> element would not be there:
SELECT this_.propA, this_.propB, this_.propC FROM Person this_
This obviously results in the error: table or view does not exist (because 'Person' is just our clean name).
Anyone knows if this is related to the composite-id or is there another reason why loader would be ignored?
Please note that there may be an error in returning the data as well. I've seen there's a special alias-syntax for that but I can't figure that out before the loader is actually doing something...
I know this is a very old question, but I was looking for the answer and came up with something. You use a query, wrapped in parentheses, as the table. It's a little ugly, but it works for me:
<class name="Person" mutable="false" table="(SELECT propA, propB, propC FROM MyPersons)">
<composite-id>
<key-property name="PropertyA" column="propA" type="int" />
<key-property name="PropertyB" column="propB" type="string" />
</composite-id>
<property name="PropertyC" column="propC" type="datetime" />
</class>

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>

NHibernate - Populate a single property from a stored procedure

Currently have the following mapping file:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="NHibernateHelpers"
assembly="App_Code.NHibernateHelpers">
<class name="NHibernateHelpers.Fixture, App_Code" table="Fixture_Lists">
<id name="Id" column="UniqRefNo">
<generator class="guid" />
</id>
<property name="Date" column="FixDate"/>
<property name="HomeTeamId" column="HomeId"/>
<property name="HomeTeamName" column="Home_Team"/>
<property name="AwayTeamId" column="AwayId"/>
<property name="AwayTeamName" column="Away_Team"/>
<property name="Kickoff" column="Kickoff"/>
<bag name="Goals">
<key column="FixID" />
<one-to-many class="NHibernateHelpers.Goal, App_Code"/>
</bag>
<bag name="Bookings">
<key column="FixID" />
<one-to-many class="NHibernateHelpers.Booking, App_Code"/>
</bag>
<many-to-one name="HomeTeam" class="NHibernateHelpers.Team" column="HomeId" />
<many-to-one name="AwayTeam" class="NHibernateHelpers.Team" column="AwayId" />
<many-to-one name="Division" class="NHibernateHelpers.Division" column="Div_Comp" />
<property name="HomeFullTimeScoreCode" column="Home_FT_Score"/>
<property name="AwayFullTimeScoreCode" column="Away_FT_Score"/>
</class>
</hibernate-mapping>
Which maps nicely to the legacy database I have inherited, but I would like to add a property named "MatchTime" that contains the output of the stored procedure:
EXEC GetMatchTime #FixtureId = :Id
where :Id is the Id of the current Fixture object.
Is this possible in the mapping file?
Little kludgy -- but what about not converting the sp to functions, but creating new functions and using them as wrappers around the existing sp? You can add the Id to the function, and have it pass it to the stored procedure, grab the results of executing the sp, and pass them back.
http://sqlblog.com/blogs/denis_gobo/archive/2008/05/08/6703.aspx
You may have to tweak the parameter a little, but it should work (Id matches up with the name of Fixture.Id):
<property name='MatchTime' formula='(EXEC GetMatchTime Id)'/>
http://ayende.com/Blog/archive/2006/12/26/LocalizingNHibernateContextualParameters.aspx
#Watson
The contents of the formula are added as a sub-query by NHibernate so the resulting SQL ends up looks something like:
SELECT FieldA, FieldB, FieldC, ( EXEC GetMatchTime Id ) FROM Fixture_Lists
Which unfortunately fails due to stored procedures not being allowed as a sub-query.
I could convert the stored procedure to a function but there are many of them, and it could potentially break legacy code.