Hi, Dan.

We are implementing some BDD tests. And we have the need to always write custom 
spec transformers (one for each domain entity class) like this one:

public class ETO  {
    private ETO() {}
...

   public static class Party extends 
NullRecognizingTransformer<org.estatio.dom.party.Party> {
        @Override
        public org.estatio.dom.party.Party transformNonNull(String id) {
            try {
                return ScenarioExecution.current().getVar("party", id, 
org.estatio.dom.party.Party.class);
            } catch(IllegalStateException e) {
                return 
ScenarioExecution.current().service(Parties.class).findPartyByReferenceOrName(id);
            }
        }
    }


If we had an annotation like 
"@IsisRepository(org.estatio.dom.party.Party.class)" for annotating the Party's 
repository, the previous transformer could be "generalized" (previously 
searching also for a var on the Scenario context with the class name in 
camelCase).

Obviously, if none is found it should be mandatory to declare a transformer.

There could be also other scenarios where could be useful to be able to know 
what's the repository for a given domain entity class. Sure you can think about 
more.

The container (or any other Isis class) could have a method for returning the 
proper repository for a class.

What do you think? Could it be useful? Any problems derived from it?

Thanks,

Oscar




 


Reply via email to