Date: Tue, 5 Feb 2008 10:40:15 -0500
Subject: [trails-dev] HardOneToOne and
HibernateDescriptorDecorator
Guys,
Last we left this, I had developed annotations specifically
@Retention
(RetentionPolicy.
RUNTIME
)
@Target
( { ElementType.
FIELD
, ElementType.
METHOD
})
@DescriptorAnnotation
(HardOneToOneAnnotationHandler.
class
)
public
@interface
HardOneToOne
{
public
enum
Identity {
OWNER
,
ASSOCIATION
}
public
Identity identity()
default
Identity.
ASSOCIATION
;
}
public
class
HardOneToOneAnnotationHandler
extends
AbstractAnnotationHandler
implements
DescriptorAnnotationHandler<
HardOneToOne
, IPropertyDescriptor>
{
public
HardOneToOneAnnotationHandler()
{
super
();
}
public
IPropertyDescriptor decorateFromAnnotation(
HardOneToOne
propertyDescriptorAnno,
IPropertyDescriptor descriptorReference)
{
if
(propertyDescriptorAnno.identity() ==
org.trails.descriptor.annotation.
HardOneToOne
.Identity.
OWNER
)
{
OwningObjectReferenceDescriptor
owningObjectReferenceDescriptor =
new
OwningObjectReferenceDescriptor();
Class type =
descriptorReference.getPropertyType();
String inverseProperty =
descriptorReference.getName();
owningObjectReferenceDescriptor.setInverseProperty(inverseProperty);
setPropertiesFromAnnotation(propertyDescriptorAnno,
owningObjectReferenceDescriptor);
descriptorReference.addExtension(OwningObjectReferenceDescriptor.
class
.getName(),
owningObjectReferenceDescriptor);
}
return
descriptorReference;
}
}
Now I cooperated fully with your requests but it seems
nothing is good enough. I agreed to move these out of core 'per
Alejandro request' and I did that moving them into the roster demo
and for usage with any trails application in THAT CAPACITY.
Now the latest code base has logic removed (by Alejandro)
says HibernateDescriptor is not even allowed to operate these? The
rationale for this is grown wrong and equates to wrong and personal
imateur trails dynasty power trip.
How am I suppose to operate these now? Alejandro deleted the
descriptor decorator logic I developed in revision 773 for
HibernateDescriptorDecorator. Whats going on?
Is there some prejudice against OneToOne? Why shouldn't I
feel that it is moreso towards me and my ease/capability to operate
this codebase? Thats just to be fair...
Where do I put the logic below so I can decorate the
descriptor? (logic below). What if your features were continually
being sniped by some person who has despot control? Wouldn't you
start to think that someone wants you off the project because they
are scared of being outperformed? The patterns speak for themself.
I do know that OneToOne is a natural progression in the
natural world. It has it's place rightfully. Why is that being
blocked? Explain...
Or better... will someone please offer a fair trails solution
for these annotations.
Thank You.
Best regards
Ken in nashua
HibernateDescriptorDecorator.JAVA:
decorateAssociationDescriptor
/**
* Check identity owner/association
*/
if
(readMethod.isAnnotationPresent(org.trails.descriptor.annotation.HardOneToOne.class))
{
OwningObjectReferenceDescriptor
owningObjectReferenceDescriptor = new
OwningObjectReferenceDescriptor();
org.trails.descriptor.annotation.HardOneToOne.Identity
identity = readMethod.getAnnotation(
org.trails.descriptor.annotation.HardOneToOne.class).identity();
if (identity ==
org.trails.descriptor.annotation.HardOneToOne.Identity.OWNER)
{
inverseProperty =
descriptor.getName();
if (inverseProperty.equals(""))
{
// find inverse property
for ognl usage
//
http://forums.hibernate.org/viewtopic.php?t=974287&sid=12d018b08dffe07e263652190cfc4e60
// Caution... this does
not support multiple
// class references
across the OneToOne relationship
Class returnType =
readMethod.getReturnType();
for (int i = 0; i <
returnType.getDeclaredMethods().length; i++)
{
if
(returnType.getDeclaredMethods()[i].getReturnType().equals(
propertyField.getDeclaringClass()))
{
Method
theProperty = returnType.getDeclaredMethods()[i];
/* strips
preceding 'get' */
inverseProperty
= theProperty.getName().substring(3).toLowerCase();
break;
}
}
}
owningObjectReferenceDescriptor.setInverseProperty(inverseProperty);
descriptorReference.addExtension(OwningObjectReferenceDescriptor.class.getName(),
owningObjectReferenceDescriptor);
}
}
Shed those extra pounds with MSN and The Biggest Loser!
Learn more.