[Sculpture 3] Model transformation

47 views
Skip to first unread message

Alessio D'Innocenti

unread,
Nov 19, 2013, 8:30:39 PM11/19/13
to fornax-...@googlegroups.com
Hi all, 
I'm not sure I'm in the right place for that, but I would like to know if there is a way to customize model transformation in a way similar to template overriding (@ChainOverride).
I need to remove unuseful (for my project) stuff from DomainEvent and CommandEvent such as "occurred" and "recorded" properties (maybe overriding modifyDomainEvent and modifyCommandEvent). I tried throght AOP too, but unsuccessfully.

Thank for your work and for your help
Alessio

Pavel Tavoda

unread,
Nov 20, 2013, 7:56:27 AM11/20/13
to fornax-...@googlegroups.com
You need separate project (let's call it YOUR-GEN-PROJECT) - if you need I can send you 'template'.
Than in src/main/java/generator/SpecialCases.xtend you can have for example something like this:
It's using simple naming convention - name have to be "OriginalTmpl" + "Override" and you need @ChainOverride annotation.
___________________________________________________________________
package generator

import org.sculptor.generator.util.CamelCaseConverter
import org.sculptor.generator.chain.ChainOverride
import org.sculptor.generator.template.jpa.JPATmpl
import org.sculptor.generator.template.service.ServiceTmpl
import sculptormetamodel.Application
import sculptormetamodel.Service

@ChainOverride
class JPATmplOverride extends JPATmpl {

override String persistenceUnitAnnotatedClasses(Application it, String unitName) {
next.persistenceUnitAnnotatedClasses(it, unitName) + '''
<!-- smartclient classes -->
<class>sk.f4s.albiq.process.domain.AlbiqProcess</class>
<class>sk.f4s.albiq.service.domain.Users</class>
'''
}

}


@ChainOverride
class ServiceTmplOverride extends ServiceTmpl {
  override String springServiceAnnotation(Service service) {
'''@org.springframework.security.access.annotation.Secured("ROLE_�CamelCaseConverter::camelCaseToUnderscore(service.name).toUpperCase()�")
'''
+ next.springServiceAnnotation(service)
}
}

And in service project you need to setup generator plugin like:
<plugin>
<groupId>org.sculptorgenerator</groupId>
<artifactId>sculptor-maven-plugin</artifactId>
<version>${sculptor.version}</version>
<executions>
<execution>
<id>cleanup</id>
<goals>
<goal>clean</goal>
</goals>
</execution>
<execution>
<id>code-generation</id>
<goals><goal>generate</goal></goals>
</execution>
</executions>
<configuration>
<verbose>true</verbose>
</configuration>
<dependencies>
<dependency>
<groupId>COM.YOUR.COMPANY</groupId>
<artifactId>YOUR-GEN-PROJECT</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>

Regards

Pavel

Alessio D'Innocenti

unread,
Nov 20, 2013, 12:40:18 PM11/20/13
to fornax-...@googlegroups.com
Thank you for you quick replay and for your time, of course.
That's ok. I already saw how to do this in mongo-db example from github repository.
No problem in overriding templates, I tested following the example and it works pretty well.

However I need to do something like this:
import sculptor
metamodel; around transformation::Transformation::modifyDomainEvent(DomainEvent event)  :
    null;

My purpose is to add no other property other than provided ones on domain event (and command event as well).

Thanks

Pavel Tavoda

unread,
Nov 21, 2013, 5:04:40 PM11/21/13
to fornax-...@googlegroups.com
Transformation is not @ChainOverridable. I will check tomorrow why. This mean for now it's not possible.

Thanks

Pavel

Alessio D'Innocenti

unread,
Nov 25, 2013, 1:38:50 PM11/25/13
to fornax-...@googlegroups.com
Thank you again.

Is there a workaround to achieve the same result at moment?

Pavel Tavoda

unread,
Nov 29, 2013, 7:24:38 AM11/29/13
to fornax-...@googlegroups.com
Sorry I was busy last days. Only option is to download and compile yourself with @ChainOverridable, or wait some days. I will do it today.

Pavel

Alessio D'Innocenti

unread,
Nov 29, 2013, 8:21:55 AM11/29/13
to fornax-...@googlegroups.com
It's ok.Thank you for the reply.
I think I'll wait for that :)



JDK - Innovation for Results 
Alessio D'Innocenti Facebook Google Plus LinkedIn
  


2013/11/29 Pavel Tavoda <pavel....@gmail.com>

--
You received this message because you are subscribed to a topic in the Google Groups "Fornax-Platform" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/fornax-platform/aWHsIUMQz3U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to fornax-platfo...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Torsten Juergeleit

unread,
Nov 29, 2013, 8:43:22 AM11/29/13
to fornax-...@googlegroups.com
> compile yourself with @ChainOverridable

I tried it but to no avail :-(
Details can be found in the corresponding ticket.

/Torsten
Reply all
Reply to author
Forward
0 new messages