I have to use JasperReports but i'm struggling with getting the data out.
Here is my Java side declaration:
Map<String, List<TransactionBean>> shCredits = new HashMap<String, List<TransactionBean>>();
In the declared HashMap, I store clients, who have transactions.
I passed this HashMap to the report for listing the transactions group by clients.
Here is the JR side:
<parameter name="shareHolderCreditBeans" class="java.util.HashMap">
<defaultValueExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}.get("shCreditBeans")]]></defaultValueExpression>
</parameter>
<parameter name="credits" class="java.util.List">
<defaultValueExpression><![CDATA[$P{shareHolderCreditBeans}.get("12")]]></defaultValueExpression>
</parameter>
...
<field name="clientId" class="java.lang.String">
<fieldDescription><![CDATA[clientId]]></fieldDescription>
</field>
My problem is that if I use hardcoded key ("12") in 'credits' parameter, i can get the client transaction list. I'm also able to use the clientId field in a textField, but not as a key like:
$P{shareHolderCreditBeans}.get($F{clientId})
If i do this it returns with null.
Is it the right way, using field as parameter key?
Please let me know if I am not clear enough about describing this issue
Finally, I could resolve it with casting:
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource((java.util.List)($P{shareHolderCreditBeans}.get($F{clientId})))]]></dataSourceExpression>
Related
I have introduced two new fields inside Alfresco using Model manager, those fields are List of values. After I run the application, and try to edit a file that contains those fields I get this:
The reason is not familiar to me, because this is not my first time that I create new fields, and before everything was ok.
If I add some values to be saved, then it is ok. I suppose that there is a connection with a database, but I am not sure.
This is the code:
<field id="adadoc:regions" set='regionsAndCountries'>
<control template="/org/alfresco/components/form/controls/select-many-regions.ftl">
<control-param name="mode">and</control-param>
<control-param name="style">width:325px</control-param>
</control>
</field>
<field id="adadoc:countries" set='regionsAndCountries' >
<control template="/org/alfresco/components/form/controls/select-many-countries.ftl">
<control-param name="mode">and</control-param>
<control-param name="style">width:325px</control-param>
</control>
</field>
What could be the problem?
I'm trying to update existing defects using REST in HP ALM. Updating LookUpLists is easy, and i succeded in doing so. But there are UserLists type lists, which i can't update in the same way i update lookuplists, it always returns internal server error, so there must be a different way to handle them. Did anyone manage to handle updating userlists with rest?If so, can you please help me?
Just checked with UserLists for defect entity on ALM 12.20.
I used the the field 'assigned to' on ALM client.In the REST uses another name of this field - 'owner'.
I performed the next REST API call:
Method: PUT
URL: http://{your_domain}/qcbin/rest/domains/{your_domain}/projects/{your_proj}/defects/{your_defect_id}
Header: Content-Type=application/xml
Body:
<Entity Type="defect">
<Fields>
<Field Name="owner">
<Value>kevin</Value>
</Field>
</Fields>
</Entity>
And I could get this response:
<Entity Type="defect">
<ChildrenCount>
<Value>0</Value>
</ChildrenCount>
<Fields>
<Field Name="owner">
<Value>kevin</Value>
</Field>
......
</Fields>
<RelatedEntities/>
</Entity>
So just check again all what you request to ALM server attentively.
By the way, check that you have appropriate permissions to change values for concrete UserLists fields which you're going to do.
I have wanting to import data from a table and index it using solr..
I am using solr-tomcat admin panel.
But whenever I query it returns to me only the id's and value.
I have also tried adding FIELDS to fl , but that also does not help.
here is my data-config.xml file:
<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://127.0.0.1:3306/{DB_NAME}"
user="{DB_USER}"
password="{DB_PASSS}"
/>
<document>
<entity name="id" query="select s3_location,file_name from video">
<field column="s3_location" name="s3_location"/>
<field column="file_name" name="file_name"/>
</entity>
</document>
</dataConfig>
Is there any way to get the above s3_location and file_name fields also.
You need to specify the actual field names in the fl parameter or use * to indicate all fields. Also, please note that the fields must have been defined with stored=true in your schema.xml file for them to be returned/visible during a query.
fl=id,s3_location,file_name
fl=*
Are you sure you are importing the data at all? If you start with empty index, do you get anything?
The reason I ask is because you are not mapping the id field explicitly. Now, I believe there is implicit mapping of the fields by Jdbc data source based on names, but relying on it is risky when you are just starting.
Otherwise, like Paige said, make sure you defined those fields in your schema and that they are actually stored.
I am mapping two DTO objects through Dozer mapper. I am interested in choosing one value from list and map it to a single field in the destination file.
Is it possible to use mapping like this:
<field>
<a>someList[0]</a>
<b>someVariable</b>
</field>
It seems that b part can have a list[1].value type of approach, but I cannot get it to work when brackets are on a side. Where am I making it wrong?
Actually, you don't need more than suggested
<field>
<a>someList[0]</a>
<b>someVariable</b>
</field>
structure to achieve this. I had the problem other where: I did not call the correct map() function for that mapping on my code. I had several mappings and the map() call to this specific one was missing.
Use the following mapping:
<mapping map-id="collectionMapping" type="one-way">
<class-a>java.util.Collection</class-a>
<class-b>java.util.Collection</class-b>
<field>
<a>this</a>
<b set-method="add(java.lang.Object)" type="iterate">anything</b>
<b-hint>your destination object type</b-hint>
</field>
</mapping>
I've been using Castor these past couple of days to try to get a little serialization going between my Java program and XML in a readable way. Though it has a few faults, Castor's automatic xml generation via reflection is actually very functional. Unfortunately, one thing that seems to be fairly well left out of the examples is dealing with generics. It seems the reflection API does a wonderful job as it is, but as it is inadvertently grabbing a lot of redundant data just because methods start with get___(), I wanted to write my own mapping file to stave this off.
Firstly, it seems altogether fair that in the attributes to a "field" element, one should define "type". However, it does not specify what should be done if this type is abstract or simply an interface. What should I put as the type then?
Secondly, most "collection" type objects specified in Castor (List, Vector, Collection, Set, etc) only require 1 generic type, so specifying "type" as what's inside and "collection="true"" are enough. However, it does not specify what I should do in the case of a collection like a Map, where 2 types are necessary. How can I specify both the key type and value type?
Any help at all would be greatly appreciated!
For the second of my questions:
When specifying something with a Map or a Table, you need to redefine org.exolab.castor.mapping.MapItem within the bind-xml element within your field element. Example taken from here
<class name="some.example.Clazz">
<field name="a-map" get-method="getAMap" set-method="setAMap">
<bind-xml ...>
<class name="org.exolab.castor.mapping.MapItem">
<field name="key" type="java.lang.String">
<bind-xml name="id"/>
</field>
<field name="value" type="com.acme.Foo"/>
</class>
</bind-xml>
</field>
</class>
Also, omit the type attribute from the parent field element.
For my first question, the trick is to NOT specify the type in the field element and allow Castor to infer it by itself. If you have definitions for the classes that could appear there, then it will automatically use those. For example:
<class name="some.example.Clazz">
<!-- can contain condition1 or condition2 elements -->
<field name="condition" collection="arraylist" required="true">
<bind-xml name="condition" node="element" />
</field>
</class>
<class name="some.example.condition1">
<field name="oneField" >
<xml-bind name="fieldOne" />
</field>
</class>
<class name="some.example.condition2">
<field name="anotherField />
<xml-bind name="fieldTwo" />
</field>
</class>
The output of into XML by Castor would use condition1 and condition2 style XML into the "condition" field of Clazz while still referring to its proper instantiation type.