My favorites | Sign in
Project Home Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions

Issue 3 attachment: relateToSameType.patch.txt (3.9 KB)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Index: src/main/java/org/springframework/roo/addon/graph/Direction.java
===================================================================
--- src/main/java/org/springframework/roo/addon/graph/Direction.java (revision 396)
+++ src/main/java/org/springframework/roo/addon/graph/Direction.java (working copy)
@@ -5,5 +5,5 @@
* @since 27.08.2010
*/
public enum Direction {
- INCOMING, OUTGOING
+ INCOMING, OUTGOING, BOTH
}
Index: src/main/java/org/springframework/roo/addon/graph/GraphMetadata.java
===================================================================
--- src/main/java/org/springframework/roo/addon/graph/GraphMetadata.java (revision 396)
+++ src/main/java/org/springframework/roo/addon/graph/GraphMetadata.java (working copy)
@@ -12,6 +12,7 @@
import java.io.File;
import java.lang.reflect.Modifier;
import java.util.*;
+import java.util.logging.Logger;

import javax.annotation.Resource;

@@ -33,10 +34,13 @@
public abstract class GraphMetadata extends
BuildingItdTypeDetailsProvidingMetadataItem
{
+ private static final Logger LOG = Logger.getLogger(GraphMetadata.class.getName());
+
private static final String PROVIDES_TYPE_STRING = GraphMetadata.class.getName();
static final String PROVIDES_TYPE = MetadataIdentificationUtils.create( PROVIDES_TYPE_STRING );
private final Type type;

+
private GraphMetadata(final String identifier, final JavaType aspectName,
final PhysicalTypeMetadata governorPhysicalTypeMetadata,
final ClassOrInterfaceTypeDetails governorTypeDetails,
@@ -181,13 +185,32 @@
).add(getId(), builder);
}
private JavaType getOtherNodeType(final ClassOrInterfaceTypeDetails relationshipType) {
+ JavaType startNode = null;
+ JavaType endNode = null;
for (final FieldMetadata fieldMetadata : relationshipType.getDeclaredFields()) {
for (final AnnotationMetadata annotationMetadata : fieldMetadata.getAnnotations()) {
if (annotationMetadata.getAnnotationType().equals(Type.Annotations.StartNode) || annotationMetadata.getAnnotationType().equals(Type.Annotations.EndNode)) {
- if (!fieldMetadata.getFieldType().equals(getJavaType())) return fieldMetadata.getFieldType();
+ JavaType fieldType = fieldMetadata.getFieldType();
+ if (!fieldType.equals(getJavaType())) {
+ return fieldType;
+ } else if(annotationMetadata.getAnnotationType().equals(Type.Annotations.StartNode)){
+ if(startNode!=null) {
+ throw new IllegalStateException("Relationship "+relationshipType.getName().getFullyQualifiedTypeName() +" shouldn't contain two fields annotated with @StartNode");
+ }
+ startNode = fieldType;
+ } else if(annotationMetadata.getAnnotationType().equals(Type.Annotations.EndNode)){
+ if(endNode!=null) {
+ throw new IllegalStateException("Relationship "+relationshipType.getName().getFullyQualifiedTypeName() +" shouldn't contain two fields annotated with @EndNode");
+ }
+ endNode = fieldType;
+ }
}
}
}
+ if(startNode != null && endNode != null && startNode.equals(endNode)) {
+ LOG.warning("StartNode and EndNode types are same in Relationship "+relationshipType.getName().getFullyQualifiedTypeName());
+ return startNode;
+ }
throw new IllegalStateException("Other NodeEntity to "+getJavaType()+" not found in relationship "+relationshipType);
}
};
Powered by Google Project Hosting