Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Jasper Reports] Print relations for each view in model #510

Closed
NickTononi opened this issue Aug 6, 2019 · 16 comments
Closed

[Jasper Reports] Print relations for each view in model #510

NickTononi opened this issue Aug 6, 2019 · 16 comments

Comments

@NickTononi
Copy link

Hello,
I edited the archi code and model to add this feature.

This feature allows to see the relations associated with a view.

I'm attaching a generated report after the changes I made.
report-with-relations-per-view.pdf

Is this a feature that might come handy?

@Phillipus
Copy link
Member

Hi Nick, thanks for the submssion.

This could be an optional feature of the Japer Reports.

Some of the proposed changes to the code are a bit more problematic:

  • We can't modify the Property class as this is generated by core EMF. One should use the factory method to return a IProperty class instead.
  • ElementsDataSource - setting the concepts shouldn't really be done, as this class's function is to return concepts for a context (model or folder)
  • I need to look closer at the proposed changes to the other java classes as these seem to have a lot of impact and would require unit tests as well

I'll look a bit deeper, but I'm sure this could be done in a simpler way.

That's not to disparage your changes. :-) It's just I that I need to see if the DataSource API could be modified in a better way to return relationships.

@NickTononi
Copy link
Author

NickTononi commented Aug 6, 2019

Hi Phillipus,
thanks for the feedback!
I just needed that feature so I made the most simple changes just to achieve the result without thinking about impacts in the whole project.

Wanted to share with you guys to see if this could be done in a more clean and efficient way than I did.

@Phillipus
Copy link
Member

Hi Nick, yes I thought that. :-)

My comments are not criticisms, just code comments. So thanks for sharing. :-)

I'll take a look at it soon.

@Phillipus
Copy link
Member

We probably need a new class like ViewChildrenDataSource but for relations.

@Phillipus
Copy link
Member

Phillipus commented Aug 9, 2019

@NickTononi

IF we look at how the ArchiMate elements are returned for a View we see that these are in the ViewChildrenDataSource class returned by ViewModelDataSource#getChildElementsDataSource().

So, I've created a new class ViewRelationsDataSource accessed from ViewModelDataSource#getChildRelationsDataSource().

The ViewRelationsDataSource returns relations. So all information (name, type, source, target, properties) can be accessed from the relation,

This is in the git branch "jasper-viewrelations". If you like, you could test this. Of course, it will mean re-doing your *.jrxml file.

@Phillipus Phillipus changed the title [Feature] Print relations for each view in model [Jasper Reports] Print relations for each view in model Aug 9, 2019
@Phillipus
Copy link
Member

Once we've had more testing of the new method ViewModelDataSource#getChildRelationsDataSource() we can add it to the master branch and *.jrxml files can call it.

@Phillipus
Copy link
Member

Phillipus commented Aug 19, 2019

The changes to the ViewRelationsDataSource have now been merged into the master branch.

@NickTononi If you want to use this API in your *.jrxml file feel free to try it.

@NickTononi
Copy link
Author

Works like a charm, thanks for merging into master branch.

Does this mean that the next Archi release will support this feature?

@Phillipus
Copy link
Member

Does this mean that the next Archi release will support this feature?

Yes.

@Phillipus
Copy link
Member

But the jrxml file is unchanged. That is a separate issue.

@NickTononi
Copy link
Author

NickTononi commented Aug 26, 2019

I made a mistake while testing before, I added a simple subreport inside the jrxml and now I get the following error:
jasperError

Just added the following to view.jrxml:

<subreport>
				<reportElement positionType="Float" isPrintRepeatedValues="false" x="0" y="120" width="515" height="50" isRemoveLineWhenBlank="true"/>
				<subreportParameter name="VIEW_DETAILED">
					<subreportParameterExpression><![CDATA[$V{VIEW_DETAILED}]]></subreportParameterExpression>
				</subreportParameter>
				<subreportParameter name="REPORT_PATH">
					<subreportParameterExpression><![CDATA[$P{REPORT_PATH}]]></subreportParameterExpression>
				</subreportParameter>
                <subreportParameter name="REPORT_RESOURCE_BUNDLE">
                    <subreportParameterExpression><![CDATA[$P{REPORT_RESOURCE_BUNDLE}]]></subreportParameterExpression>
                </subreportParameter>
				<subreportParameter name="TITLE">
					<subreportParameterExpression><![CDATA["View Relations"]]></subreportParameterExpression>
				</subreportParameter>
				<dataSourceExpression><![CDATA[((com.archimatetool.jasperreports.data.ViewModelDataSource)$P{REPORT_DATA_SOURCE}).getChildRelationsDataSource()]]></dataSourceExpression>
				<subreportExpression><![CDATA[$P{elements_report}]]></subreportExpression>
			</subreport>

I'm attaching the jrxml file.

view.jrxml.txt

I don't get the error here, do you think this is somehow related to the new added method?

@NickTononi NickTononi reopened this Aug 26, 2019
@Phillipus
Copy link
Member

getChildRelationsDataSource() follows exactly the same structure and pattern as getChildElementsDataSource() so I can't see how it would cause an error if used in the same way.

Suggest setting a debug breakpoint and seeing what's wrong.

@Phillipus
Copy link
Member

The error in Eclipse is:

Caused by: java.lang.ClassCastException: class com.archimatetool.jasperreports.data.ViewRelationsDataSource cannot be cast to class com.archimatetool.jasperreports.data.ElementsDataSource

So looks like your jrxml file needs changing?

@Phillipus
Copy link
Member

Phillipus commented Aug 26, 2019

Probably because it is using the elements.jrxml sub-report. You might need to modify that one to handle relations and a ViewRelationsDataSource?

I suspect that a sub-report (elements.jrxml perhaps) is set up for ElementsDataSource but not for ViewRelationsDataSource

At the data level we know that ViewRelationsDataSource is returning the right data set but the jrxml files need to be changed to handle it.

Perhaps you might need a new sub-report type relations.jrxml?

@NickTononi
Copy link
Author

NickTononi commented Aug 26, 2019

I now edited the jrxml file in order to use the feature.
I forked the repo adding the custom template.

And here is the resulting report:
report-relations-view.pdf

Thanks for your hints and suggestions on this one.

@Phillipus
Copy link
Member

@NickTononi There may be a change to this. See #518

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants