Hi,
My $0.02:
For the common case where the search should be done by one or more attributes from an entity, wouldn't it be easier to use a <<SearchField>> on each of them ?
The transform should then generate all the query stuff automatically.
Another approach that I've experimented with on AndroMDA 2.x was to
define stereotypes for CRUD actions. In the model, if I want an entity to be
"searchable", I add an empty (no ops, no attrs) class whith a 1-1 relationship
to an entity class, navigable from the <<SearchAction>> to the <<Entity>>.
The transform uses this relationship to generate the UI artifacts (form,page,
resources and struts action).
Wouter Zoons wrote:
hi Stefan,
what I do in this case is the following:
1. model an entity operation, such as findByCriteria(SearchCriteria searchCriteria), where the argument is a value object 2. make sure this operation is classifier scoped (underlined in UML diagrams) 3. generate code 4. you'll see this operation in <YourDAO>Impl 5. implement it using Hibernate criteria, like this (sample taken from a AndroMDA-Spring implementation):
------------------------------------------------------ final Session session = getSession(); Criteria articleCriteria = getHibernateTemplate().createCriteria(session, ArticleImpl.class);
if (StringUtils.isNotBlank(searchCriteria.getBarCode())) { articleCriteria.add(Expression.eq("barCode", searchCriteria.getBarCode())); }
if (searchCriteria.getType() != null) { Criteria typeCriteria = articleCriteria.createCriteria("type"); typeCriteria.add(Expression.eq("id", searchCriteria.getType())); }
List list = articleCriteria.list(); this.closeSessionIfNecessary(session);
toArticleListItem(list); return list; ------------------------------------------------------
I think you get the idea .. there are different ways of course, depending on the underlying technology (in this case Spring using Hibernate)
anyway, I think this could be part of the generation process .. I will have to confer with Chad, but it *is* common functionality that could/should be handled by the transformation
could you file an issue for it in JIRA ? do it under the Spring cartridge and assign it to me
thanks -- Wouter
Hi everyone,
we currently work on a very common functionality: A search dialog with about 15 attributes. If an attribute was entered in the dialog it should be considered as a parameter for the search. As I said, this is a very common functionality and we try to figure out a clever way of implementation. So we thought about modelling this type of search by creating a ValueObject containing the search-parameters. A finder-method on the spring-service and a (static) one on the spring-entity take this ValueObject as parameter. The spring-service delegates the call to the entity's DAO which dynamicly builds the query using Hibernate's Criteria API. Do you recon this is a good way of implementation?
Thanks a lot for your input. Regards Stefan.
------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_ide95&alloc_id396&op=click _______________________________________________ Andromda-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/andromda-user
------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Andromda-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/andromda-user
