Fornax-Platform
Forum

[Sculptor] Reference class in jar

View: New views
6 Messages — Rating Filter:   Alert me  

[Sculptor] Reference class in jar

by amphoras :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I want to have a domain object that references another class that is:

1.  Not known to Sculptor.
2.  Does not need to be persisted.
3.  Inside a jar.

I know I can put this reference in the hand-coded subclass, but I'd like to map other properties to it (I will extend the DSL) and generate its getter/setter.  How do I create this reference in model.design?  I tried:

com.foo.common.UserInformation userInfo

Which passes validation and even generates correctly in the Base class with an import statement (very cool!), but it throws this exception during generation:

ERROR AbstractExpressionsUsingWorkflowComponent - Error in Component generator of type org.openarchitectureware.xpand2.Generator:
        EvaluationException : java.util.MissingResourceException: Property not found: db.mysql.type.com.foo.common.UserInformation

How do I tell Sculptor to not persist this class?  I tried "!persistent" for the reference, but it doesn't work.

Thanks!
--Polly

Re: [Sculptor] Reference class in jar

by Patrik Nordwall :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

If it was persistent it would be rather easy to add your own type as described in Developer's Guide.
Now it is not, and then I think the easiest is to wrap it inside a not persistent ValueObject like this:

Entity Person {
    - @UserInformationWrapper userInfo
}

ValueObject UserInformationWrapper {
    not persistent
    com.foo.common.UserInformation value
}

An alternative is to use it as you suggested. To get rid of the error you have to add
db.mysql.type.com.foo.common.UserInformation=VARCHAR
in your sculptor-generator.properties
But then you also have to do some special cases to exclude it from from hibernate and ddl generation.

/Patrik

PS. wiki is down, and I don't know why. You have checked out from svn and can read documentation in /fornax-cartridges-sculptor-parent/doc/AdvancedTutorial.pdf

amphoras wrote:
Hi,

I want to have a domain object that references another class that is:

1.  Not known to Sculptor.
2.  Does not need to be persisted.
3.  Inside a jar.

I know I can put this reference in the hand-coded subclass, but I'd like to map other properties to it (I will extend the DSL) and generate its getter/setter.  How do I create this reference in model.design?  I tried:

com.foo.common.UserInformation userInfo

Which passes validation and even generates correctly in the Base class with an import statement (very cool!), but it throws this exception during generation:

ERROR AbstractExpressionsUsingWorkflowComponent - Error in Component generator of type org.openarchitectureware.xpand2.Generator:
        EvaluationException : java.util.MissingResourceException: Property not found: db.mysql.type.com.foo.common.UserInformation

How do I tell Sculptor to not persist this class?  I tried "!persistent" for the reference, but it doesn't work.

Thanks!
--Polly

Re: [Sculptor] Reference class in jar

by amphoras :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hmm, looks like I will have to use the wrapper.  The other method requires too much hard coding in advices to skip the generation of Hibernate and DDL snippets.

Is there a way to use inheritance instead of composition for the wrapper class?  I tried this but it doesn't like the qualified class name after "extends":

ValueObject UserInformation extends com.foo.common.UserInformation {
                        !persistent !immutable
}

Also, I see that you've fixed the wiki.  I'll look in SVN for the documentation next time.  Thanks!  :)

--Polly


Patrik Nordwall wrote:
If it was persistent it would be rather easy to add your own type as described in Developer's Guide.
Now it is not, and then I think the easiest is to wrap it inside a not persistent ValueObject like this:

Entity Person {
    - @UserInformationWrapper userInfo
}

ValueObject UserInformationWrapper {
    not persistent
    com.foo.common.UserInformation value
}

An alternative is to use it as you suggested. To get rid of the error you have to add
db.mysql.type.com.foo.common.UserInformation=VARCHAR
in your sculptor-generator.properties
But then you also have to do some special cases to exclude it from from hibernate and ddl generation.

/Patrik

PS. wiki is down, and I don't know why. You have checked out from svn and can read documentation in /fornax-cartridges-sculptor-parent/doc/AdvancedTutorial.pdf

Re: [Sculptor] Reference class in jar

by Patrik Nordwall :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


amphoras wrote:
Hmm, looks like I will have to use the wrapper.  The other method requires too much hard coding in advices to skip the generation of Hibernate and DDL snippets.

Is there a way to use inheritance instead of composition for the wrapper class?  I tried this but it doesn't like the qualified class name after "extends":

ValueObject UserInformation extends com.foo.common.UserInformation {
                        !persistent !immutable
}
extension of a fully qualified class sounds like a rather useful feature. Maybe you can add a change request in jira if you need that.
http://www.fornax-platform.org/tracker/browse/CSC

Re: [Sculptor] Reference class in jar

by amphoras :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

OK, here is the request:  http://www.fornax-platform.org/tracker/browse/CSC-211

Thanks!

--Polly

Patrik Nordwall wrote:
extension of a fully qualified class sounds like a rather useful feature. Maybe you can add a change request in jira if you need that.
http://www.fornax-platform.org/tracker/browse/CSC

Re: [Sculptor] Reference class in jar

by Patrik Nordwall :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ability to extend a fully qualified class is now implemented in trunk.
LightInTheBox - Buy quality products at wholesale price