Hi,

A while back, we discussed the problem with oAW resolving objects with the
same name in different modules:
http://www.nabble.com/-Sculptor--resolving-references-to-domain-objects-with-same-name-in-different-modules-td19152982s17564.html

Since I know about this issue, I simply don't name objects with the same
name in my application.  The problem now is that some of my users are
importing applications where they are not familiar with the names of all the
objects inside that application, so they are accidentally creating objects
with the same name.  

To solve that problem, I want to add a "check" that validates when the user
tries to define an object with a name that already exists.  So in
Checks.chk, I added:

context DslSimpleDomainObject if name != null
        ERROR "Duplicate name.  There is already an existing object with this
name." :
        this.domainObjectsForName(name).size <= 1;

And in Extensions.ext, I added:
/**
 * Return all the domain objects with the given name.
 */
 List[DslDomainObject]
domainObjectsForName(sculptordsl::DslSimpleDomainObject this, String name) :
        allElements().typeSelect(DslSimpleDomainObject).select(d | d.name == 
name);

This works now.  However, when I was working on this function, I noticed a
few things:

1.  I originally called allDomainObjects() instead of allElements(), but I
found that that function only seems to return domain objects inside the same
design file.  It could not find duplicate objects defined in an imported
file.  I am not sure if this behavior is intentional or not.  If it is, the
name of the function seems kind of misleading.  If not, perhaps that
function should call allElements() instead?  I am thinking that the function
doesn't call allElements() because we didn't have that until recently.  This
also applies to the other allEntities and allServices functions.

2.  I would like to be able to do the same validation for Services and
Repositories.  I know that I can copy and paste the domainObjectsForName()
function that I wrote and replace the type, but is there a more generic way
to write the function?  Just wondering.

Thanks,
Polly
-- 
View this message in context: 
http://www.nabble.com/-Sculptor--Duplicate-name-validation-tp20901565s17564p20901565.html
Sent from the Fornax-Platform mailing list archive at Nabble.com.


------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Fornax-developer mailing list
Fornax-developer@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fornax-developer

Reply via email to