1. How can we expose the setID to set the ID Manually.
2. How can we turn off Auto Generation of the ID within Sculptor. At present IDs are automatically generated with GeneratorType.AUTO.
package generator
import org.sculptor.generator.template.domain.DomainObjectAttributeTmpl
import sculptormetamodel.Attribute
class DomainObjectAtrributeTmplOverride extends DomainObjectAttributeTmpl {
new(DomainObjectAttributeTmpl next) {
super(next)
}
override String idPropertySetter(Attribute it) {
'''
/**
* The id is not intended to be changed or assigned manually, but
* for test purpose it is allowed to assign the id.
*/
public void set«name.toFirstUpper()»(it.getTypeName() «name») {
if ((this.«name» != null) && !this.«name».equals(«name»)) {
throw new IllegalArgumentException("Not allowed to change the id property.");
}
this.«name» = «name»;
}
'''
}
}
Taskize Limited - Innovative solutions for Financial Services Technology.Registered address: 33 Cannon Street, London, EC4M 5SB. Registered in England No. 7921239. This message may contain information that is privileged or confidential. If you are not the intended recipient please delete it and inform the sender immediately.--
You received this message because you are subscribed to a topic in the Google Groups "Sculptor Generator" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sculptorgenerator/SOhuxfDM-Cg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sculptorgenera...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
package generator
import com.google.inject.Inject
import org.sculptor.generator.chain.ChainOverride
import org.sculptor.generator.template.domain.DomainObjectAttributeAnnotationTmpl
import org.sculptor.generator.template.domain.DomainObjectAttributeTmpl
import sculptormetamodel.Attribute
@ChainOverride
class DomainObjectAttributeTmplOverride extends DomainObjectAttributeTmpl {
@Inject private var DomainObjectAttributeAnnotationTmpl domainObjectAttributeAnnotationTmpl
new(DomainObjectAttributeTmpl next) {
super(next)
}
override String idPropertySetter(Attribute it) {
'''
«domainObjectAttributeAnnotationTmpl.propertySetterAnnotations(it)»
public void set«name.toFirstUpper()»(«it.getTypeName()» «name») {
For some reason the method getTypeName is not available on Attribute it....
@Inject extension HelperBase helperBase
Ok. Getting further...For some reason the method getTypeName is not available on Attribute it....But it clearly is for the DomainIbjectAttributeTmpl idPropertySetter(Attribute it)...Any ideas why?
Full class below.package generator
import com.google.inject.Inject
import org.sculptor.generator.chain.ChainOverride
import org.sculptor.generator.template.domain.DomainObjectAttributeAnnotationTmpl
import org.sculptor.generator.template.domain.DomainObjectAttributeTmpl
import sculptormetamodel.Attribute
@ChainOverride
class DomainObjectAttributeTmplOverride extends DomainObjectAttributeTmpl {
@Inject private var DomainObjectAttributeAnnotationTmpl domainObjectAttributeAnnotationTmpl
new(DomainObjectAttributeTmpl next) {
super(next)
}
override String idPropertySetter(Attribute it) {
'''
«domainObjectAttributeAnnotationTmpl.propertySetterAnnotations(it)»
public void set«name.toFirstUpper()»(«it.getTypeName()» «name») {
if ((this.«name» != null) && !this.«name».equals(«name»)) {
throw new IllegalArgumentException("Not allowed to change the id property.");
}
this.«name» = «name»;
}
'''
}
}
On 20 October 2015 at 17:41, Richard Walsh richard.walsh wrote:
Ok. Getting further...For some reason the method getTypeName is not available on Attribute it....But it clearly is for the DomainIbjectAttributeTmpl idPropertySetter(Attribute it)...Any ideas why?
package generator;
import com.google.inject.Inject
import org.sculptor.generator.chain.ChainOverride
import org.sculptor.generator.ext.DbHelper
import org.sculptor.generator.ext.Properties
import org.sculptor.generator.template.domain.DomainObjectAttributeAnnotationTmpl
import sculptormetamodel.Attribute
@ChainOverride
public class DomainObjectAttributeAnnotationTmplOverride extends DomainObjectAttributeAnnotationTmpl {
@Inject extension DbHelper dbHelper
@Inject extension Properties properties
override String idAnnotations(Attribute it) {
'''
«IF isJpaProviderAppEngine()»
@javax.persistence.GeneratedValue(strategy = javax.persistence.GenerationType.IDENTITY)
«ELSE»
@javax.persistence.GeneratedValue(strategy = javax.persistence.GenerationType.AUTO)
@javax.persistence.GeneratedValue(strategy = GenerationType.AUTO, generator="hibernate_sequence")
@javax.persistence.SequenceGenerator(name = "hibernate_sequence", sequenceName = "«it.name»")
«ENDIF»
@javax.persistence.Column(name="«it.getDatabaseName()»")
'''
}
}
--
You received this message because you are subscribed to a topic in the Google Groups "Sculptor Generator" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sculptorgenerator/SOhuxfDM-Cg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sculptorgenera...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
package generator;
import com.google.inject.Inject
import org.sculptor.generator.chain.ChainOverride
import org.sculptor.generator.ext.DbHelper
import org.sculptor.generator.ext.Properties
import org.sculptor.generator.template.domain.DomainObjectAttributeAnnotationTmpl
import sculptormetamodel.Attribute
@ChainOverride
public class DomainObjectAttributeAnnotationTmplOverride extends DomainObjectAttributeAnnotationTmpl {
@Inject extension DbHelper dbHelper
@Inject extension Properties properties
override String idAnnotations(Attribute it) {
'''
«IF isJpaProviderAppEngine()»
@javax.persistence.GeneratedValue(strategy = javax.persistence.GenerationType.IDENTITY)
«ELSE»
@javax.persistence.GeneratedValue(strategy = GenerationType.AUTO, generator="hibernate_sequence")
What is the best way to debug this?