How to configure the SmartClient DataSource with serverType Hibernate to select only the required fields? - smartclient

I'm working with SmartClient release 8.3.
I configured this DataSource:
<DataSource ID="example"
serverType="hibernate"
dropExtraFields="true"
beanClassName="com.msp.dao.entities.Status">
<fields>
<field name="id"/>
<field name="name"/>
</fields>
</DataSource>
and I'm using ListGrid to view the results.
For some reason the HQL query that is being generated select the entire entity instead of the selected fields.
This is the generated HQL Query: select _status from com.msp.dao.entities.Status _status
I want it to be generated like that: select _status.id, _status.name from com.msp.dao.entities.Status _status
Thank you

You should use OperationBinding.outputs. But only from release 9 they will support it.

Related

sql modify XML node

I'm trying to modify xml attribute in my table:
XML:
<root>
<object name="111">
<fields>
<field name="1">False</ofield>
<field name="VIN">123</field>
</fields>
</object>
</root>
UPDATE wftable
SET XML.modify('replace value of
(root/object[#name="111"]/fields/field/#name[.="VIN"])[1]
with "testNumber"')
WHERE id = 20889436
But I get as a result
<field name="testNumber">123</field>
Actually I just want to update xml node like this:
<field name="VIN">testNumber</field>
How can I modify my UPDATE query?
You need to specify the text() node of field as the node you want to update.
replace value of
(root/object[#name="111"]/fields/field[#name="VIN"]/text())[1]
with "testNumber"

Extracting XML Data with SQL

I have the following XML data stored in a SQL table
<CustomFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.kaseya.com/vsa/2007/12/ServiceDeskDefinition.xsd">
<Field fieldName="ChangeRequest">No</Field>
<Field fieldName="ProblemRecord">No</Field>
<Field fieldName="Source">Email</Field>
<Field fieldName="KB_Article">No</Field>
<Field fieldName="OptimusRef">264692</Field>
<Field fieldName="TimeSpentOnTicket">0.25</Field>
<Field fieldName="PONumber" />
<Field fieldName="ResourceAssignedEngineer" />
What I would like to do is select the TimeSpentOnTicket Value form a stored procedure.
Any ideas how I can do this?
The problem here is your XML. It's invalid, so there's not really a way do search it until you fix it. A simple way to check this is using an online tool like the one at W3Schools. Another issue that I see is that the namespace (xmlns) that you reference no longer exists. I think this will mess up Postgres as well, but I'm not 100% on that. You might to have to filter that out when ingesting. However, after fixing the XML, it's pretty easy to get things out using XPath within the appropriate XML function.
For example, using the following table:
CREATE TABLE BLA.TEMPTABLE (ID INT, MYXML XML)
Then, insert a valid version of your XML:
INSERT INTO BLA.TEMPTABLE ( ID, MYXML )
SELECT 1 as ID,
'<?xml version="1.0" encoding="UTF-8"?>
<CustomFields>
<Field fieldName="ChangeRequest">No</Field>
<Field fieldName="ProblemRecord">No</Field>
<Field fieldName="Source">Email</Field>
<Field fieldName="KB_Article">No</Field>
<Field fieldName="OptimusRef">264692</Field>
<Field fieldName="TimeSpentOnTicket">0.25</Field>
<Field fieldName="PONumber" />
<Field fieldName="ResourceAssignedEngineer" />
</CustomFields>' as MYXML
Then, to query it back out, you can do something like the following (you can test your XPath with a tool like this, if you need to):
SELECT
tt.ID,
tt.MYXML,
XPATH('/CustomFields//Field[#fieldName=''TimeSpentOnTicket'']/text()', tt.MYXML)
FROM
BLA.TEMPTABLE tt

Mule ESB: Issue w/ XML generated from MapsToXML input to DataMapper

I have a JDBC outbound endpoint that after performing Map To XML transformation, gives out XML in the following format:
<?xml version="1.0" encoding="UTF-8"?>
<table>
<record>
<field name="DESTINATION" type="java.lang.String">SFO</field>
<field name="PRICE" type="java.lang.String">500</field>
<field name="ID" type="java.lang.Integer">2</field>
</record>
</table>
The problem is that when I try to generate the schema for this XML for use in the datamapper , the fields that are generated from this are not usable (it only shows field , In the mapping file I get this message when I try to hover over it :
'The attribute cannot be dragged since it does not belong to 'Current Element Mapping'
How do I use my XML so that I can map those fields to either another CSV, database or some other entity?
Why not trying to map (via DataMapper) Map object directly to CSV or anything you'd like ? If you need this intermediary XML format, you can also use DataMapper for the initial Map->XML mapping and configure the way you want it to look like (instead using MapsToXML).

How to update a lookup field using a web service

I have a Nintex workflow and I am using a "Call Web Service" action to add a new list item in another site. I want to update a lookup field in the destination list from a lookup field in the source list. This is my CAML query
<UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>Kaizen Blast Objectives</listName>
<updates>
<Batch OnError="Continue" ListVersion="1" ViewName="">
<Method ID="1" Cmd="New">
<Field Name="ID">New</Field>
<Field Name="Title">{ItemProperty:Title}</Field>
<Field Name="Event_x0020_Driver">{ItemProperty:Event_x0020_Driver}</Field>
<Field Name="Problem_x0020_Statement">{ItemProperty:Problem_x0020_Statement}</Field>
<Field Name="Group1">{ItemProperty:Group}</Field>
</Method>
</Batch>
</updates>
</UpdateListItems>
"Group1" is a lookup field in the destination list and "Group" ({ItemProperty:Group}) is a lookup field in the source list.
A simple assignment like I have doesn't seem to work.
EDIT
The lookup field in the destination list is a site column.
Any ideas?
I figured it out. When updating a lookup field the format has to be id;#value. This is true even if the source and the destination fields are of the same data type.

What is the use of "multiValued" field type in Solr?

I'm new to Apache Solr. Even after reading the documentation part, I'm finding it difficult to clearly understand the functionality and use of the multiValued field type property.
What internally Solr does/treats/handles a field that is marked as multiValued?
What is the difference in indexing in Solr between a field that is multiValued and those that are not?
Can somebody explain with some good example?
Doc says:
multiValued=true|false
True if this
field may contain multiple values per
document, i.e. if it can appear
multiple times in a document
A multivalued field is useful when there are more than one value present for the field. An easy example would be tags, there can be multiple tags that need to be indexed. so if we have tags field as multivalued then solr response will return a list instead of a string value. One point to note is that you need to submit multiple lines for each value of the tags like:
<field name="tags">tag1</tags>
<field name="tags">tag2</tags>
...
<field name="tags">tagn</tags>
Once you have all the values index you can search or filter results by any value, e,g. you can find all documents with tag1 using query like
q=tags:tag1
or use the tags to filter out results like
q=query&fq=tags:tag1
multiValued defined in the schema whether the field is allowed to have more than one value.
For instance:
if I have a fieldType called ID which is multiValued=false indexing a document such as this:
doc {
id : [ 1, 2]
...
}
would cause an exception to be thrown in the indexing thread and the document will not be indexed (schema validation will fail).
On the other hand if I do have multiple values for a field I would want to set multiValued=true in order to guarantee that indexing is done correctly, for example:
doc {
id : 1
keywords: [ hello, world ]
...
}
In this case you would define "keywords" as a multiValued field.
I use multiple value fields only with copyfields, so think this way, say all fields will be single valued unless it's a copyfield, for example I have following fields:
<field name="id" type="string" indexed="true" stored="true"/>
<field name="name" type="string" indexed="true" stored="true"/>
<field name="subject" type="string" indexed="true" stored="true"/>
<field name="location" type="string" indexed="true" stored="true"/>
I want to query one field only and possibly to search all 4 fields above, then we need to use copyfield. first to create a new field call 'all', then copy everything into 'all'
<field name="all" type="text" indexed="true" stored="true" multiValued="true"/>
<copyField source="*" dest="all"/>
Now field 'all' need to be multi-valued.