Author: vyemialyanchyk
Date: 2008-12-16 08:55:21 -0500 (Tue, 16 Dec 2008)
New Revision: 12623
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/AnnotStyle.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/fields/
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/fields/Document.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/fields/Foto.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/fields/Passport.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/fields/Person.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/fields/Staff.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/getters/
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/getters/Document.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/getters/Foto.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/getters/Passport.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/getters/Person.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/getters/Staff.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Document.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Foto.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Passport.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Person.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Staff.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Document.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Foto.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Passport.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Person.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Staff.java
Removed:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/Document.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/Foto.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/Passport.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/Person.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/Staff.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/Document.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/Foto.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/Passport.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/Person.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/Staff.java
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUiMessages.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUiMessages.properties
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionDelegate.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionPulldownDelegate.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/AllEntitiesInfoCollector.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/CollectEntityInfo.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/EntityInfo.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/JPAConst.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/RefEntityInfo.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/RefFieldInfo.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/RefType.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/Utils.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/AllEntitiesProcessor.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/ProcessEntityInfo.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/TestUtilsCommon.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/JPAMapTest.java
Log:
JBIDE-3199
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUiMessages.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUiMessages.java 2008-12-16
13:53:24 UTC (rev 12622)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUiMessages.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -6,6 +6,10 @@
private static final String BUNDLE_NAME =
"org.hibernate.eclipse.jdt.ui.internal.JdtUiMessages"; //$NON-NLS-1$
public static String AllEntitiesProcessor_header;
public static String AllEntitiesProcessor_message;
+ public static String AllEntitiesProcessor_setup_annotation_generation_preference;
+ public static String AllEntitiesProcessor_annotate_fields;
+ public static String AllEntitiesProcessor_annotate_getters;
+ public static String AllEntitiesProcessor_auto_select_from_class_preference;
public static String CriteriaQuickAssistProcessor_copy_to_criteria_editor;
public static String CriteriaQuickAssistProcessor_errormessage;
public static String DebugJavaCompletionProposalComputer_displaystring;
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUiMessages.properties
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUiMessages.properties 2008-12-16
13:53:24 UTC (rev 12622)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUiMessages.properties 2008-12-16
13:55:21 UTC (rev 12623)
@@ -10,6 +10,10 @@
##############################################################################/
AllEntitiesProcessor_header=Hibernate: add JPA annotations
AllEntitiesProcessor_message=Add JPA annotations to the related set of entities. The
following classes will be changed:
+AllEntitiesProcessor_setup_annotation_generation_preference=Setup annotation generation
preference:
+AllEntitiesProcessor_annotate_fields=Annotate fields
+AllEntitiesProcessor_annotate_getters=Annotate getters
+AllEntitiesProcessor_auto_select_from_class_preference=Auto select from class preference
CriteriaQuickAssistProcessor_copy_to_criteria_editor=Copy to Criteria Editor
CriteriaQuickAssistProcessor_errormessage= Could not get document contents for
CriteriaQuickAssist
DebugJavaCompletionProposalComputer_displaystring= I wanna show a dialog!
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionDelegate.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionDelegate.java 2008-12-16
13:53:24 UTC (rev 12622)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionDelegate.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -24,8 +24,8 @@
import org.eclipse.ui.IWorkbenchPart;
/**
+ * Main menu action delegate for "Generate Hibernate/JPA annotations..."
*
- *
* @author Vitali
*/
public class JPAMapToolActionDelegate implements IObjectActionDelegate,
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionPulldownDelegate.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionPulldownDelegate.java 2008-12-16
13:53:24 UTC (rev 12622)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionPulldownDelegate.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -29,8 +29,8 @@
import org.hibernate.eclipse.jdt.ui.internal.JdtUiMessages;
/**
+ * Context menu action delegate for "Generate Hibernate/JPA annotations..."
*
- *
* @author Vitali
*/
public class JPAMapToolActionPulldownDelegate implements
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java 2008-12-16
13:53:24 UTC (rev 12622)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -53,16 +53,34 @@
import org.hibernate.eclipse.jdt.ui.internal.jpa.process.AllEntitiesProcessor;
/**
+ * Actor to execute annotation generation.
+ * It is singleton.
*
- *
* @author Vitali
*/
public class JPAMapToolActor {
- protected static JPAMapToolActor actor = null;
+ /**
+ * instance
+ */
+ protected static JPAMapToolActor actor = null;
+ /**
+ * selection - start point to generate annotations
+ * could be java file, list of files, package, project, some other?
+ */
protected ISelection selection = null;
+ /**
+ * selected compilation units for startup processing,
+ * result of processing selection
+ */
protected Set<ICompilationUnit> selectionCU = new
HashSet<ICompilationUnit>();
+ /**
+ * responsible to gather information
+ */
protected AllEntitiesInfoCollector collector = new AllEntitiesInfoCollector();
+ /**
+ * responsible to generate JPA annotations
+ */
protected AllEntitiesProcessor processor = new AllEntitiesProcessor();
protected JPAMapToolActor() {
@@ -94,6 +112,9 @@
}
}
+ /**
+ * updates selected compilation units collection
+ */
public void updateSelected() {
if (selection != null) {
updateSelectedItems(selection);
@@ -135,8 +156,10 @@
collector.collect(icu);
}
collector.resolveRelations();
+ processor.setAnnotationStylePreference(collector.getAnnotationStylePreference());
processor.modify(javaProject, collector.getMapCUs_Info(), true);
}
+ processor.saveAnnotationStylePreference();
}
public void updateOpen() {
@@ -325,6 +348,10 @@
}
}
+ /**
+ * setup source selection node
+ * @param selection
+ */
synchronized public void setSelection(ISelection selection) {
//System.out.println("Blah! " + selection); //$NON-NLS-1$
if (selection instanceof StructuredSelection && selection.isEmpty()) {
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/AllEntitiesInfoCollector.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/AllEntitiesInfoCollector.java 2008-12-16
13:53:24 UTC (rev 12622)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/AllEntitiesInfoCollector.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -24,34 +24,57 @@
import org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefFieldInfo;
import org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefType;
import org.hibernate.eclipse.jdt.ui.internal.jpa.common.Utils;
+import org.hibernate.eclipse.jdt.ui.internal.jpa.process.AnnotStyle;
/**
+ * Collect information about JPA entity and it's dependences.
*
- *
* @author Vitali
*/
public class AllEntitiesInfoCollector {
+ /**
+ * place to search compilation units
+ */
protected IJavaProject javaProject;
- // fullyQualifiedName -> EntityInfo
+ /**
+ * map:
+ * fullyQualifiedName entity name -> EntityInfo
+ * this collection of processed entities
+ */
protected Map<String, EntityInfo> mapCUs_Info = new TreeMap<String,
EntityInfo>();
+ /**
+ * annotation style preference
+ */
+ protected AnnotStyle annotationStylePreference = AnnotStyle.FIELDS;
public void initCollector(IJavaProject javaProject) {
+ // setup java project
this.javaProject = javaProject;
+ // clear collection
mapCUs_Info.clear();
}
+ /**
+ * pair of 2 particular fields from 2 particular entities
+ */
protected class ProcessItem {
- //
+ // field names
public String fieldId = null;
public String fieldId2 = null;
- //
+ // information about field from both entities
public RefEntityInfo refEntityInfo = null;
public RefEntityInfo refEntityInfo2 = null;
}
+ /**
+ * abstract interface for connection of entities
+ */
protected abstract class IConnector {
+ /**
+ * object for processing
+ */
protected ProcessItem pi;
public void setProcessItem(ProcessItem processItem) {
@@ -60,6 +83,10 @@
public abstract boolean updateRelation();
}
+ /**
+ * responsible for enumeration all entities pairs which
+ * succeed in recognize
+ */
protected class EntityProcessor {
protected IConnector connector;
@@ -68,6 +95,9 @@
this.connector = connector;
}
+ /**
+ * enumerate function
+ */
public void enumEntityPairs() {
Iterator<Map.Entry<String, EntityInfo>> it =
mapCUs_Info.entrySet().iterator();
ProcessItem pi = new ProcessItem();
@@ -119,15 +149,30 @@
}
}
+ /**
+ * process all entities pairs iteratively:
+ * firstly process pairs with more information about and
+ * pairs with small information about - process in last order
+ */
public void resolveRelations() {
Iterator<Map.Entry<String, EntityInfo>> it = null;
+ int fromVariableCounter = 0;
+ int fromMethodCounter = 0;
// generate RefFieldInfoMap (for simple process)
it = mapCUs_Info.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, EntityInfo> entry = it.next();
EntityInfo entryInfo = entry.getValue();
entryInfo.generateRefFieldInfoMap();
+ fromVariableCounter += entryInfo.getFromVariableCounter();
+ fromMethodCounter += entryInfo.getFromMethodCounter();
}
+ if (fromVariableCounter >= fromMethodCounter) {
+ annotationStylePreference = AnnotStyle.FIELDS;
+ }
+ else {
+ annotationStylePreference = AnnotStyle.GETTERS;
+ }
// update relations
EntityProcessor ep = new EntityProcessor();
// 0)
@@ -381,6 +426,12 @@
ei.adjustPrimaryId(parentEI);
}
+ /**
+ * start to collect information from particular entity class and
+ * its dependencies
+ * @param fullyQualifiedName of startup point entity fully qualified name
+ * example:
"org.hibernate.eclipse.jdt.ui.internal.jpa.collect.AllEntitiesInfoCollector"
+ */
public void collect(String fullyQualifiedName) {
if (fullyQualifiedName == null) {
@@ -393,6 +444,11 @@
collect(icu);
}
+ /**
+ * start to collect information from particular entity class and
+ * its dependencies
+ * @param icu - startup point entity compilation unit
+ */
public void collect(ICompilationUnit icu) {
if (icu == null) {
@@ -427,7 +483,14 @@
}
}
+ /**
+ * collection of processed entities getter
+ */
public Map<String, EntityInfo> getMapCUs_Info() {
return mapCUs_Info;
}
+
+ public AnnotStyle getAnnotationStylePreference() {
+ return annotationStylePreference;
+ }
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/CollectEntityInfo.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/CollectEntityInfo.java 2008-12-16
13:53:24 UTC (rev 12622)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/CollectEntityInfo.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.hibernate.eclipse.jdt.ui.internal.jpa.collect;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -30,6 +31,8 @@
import org.eclipse.jdt.core.dom.ParameterizedType;
import org.eclipse.jdt.core.dom.PrimitiveType;
import org.eclipse.jdt.core.dom.QualifiedType;
+import org.eclipse.jdt.core.dom.ReturnStatement;
+import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.SimpleType;
import org.eclipse.jdt.core.dom.Type;
import org.eclipse.jdt.core.dom.TypeDeclaration;
@@ -43,12 +46,15 @@
import org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefType;
/**
+ * Visitor to collect information about JPA entity.
*
- *
* @author Vitali
*/
public class CollectEntityInfo extends ASTVisitor {
+ /**
+ * storage of collected info
+ */
protected EntityInfo entityInfo = new EntityInfo();
public EntityInfo getEntityInfo() {
@@ -174,7 +180,7 @@
VariableDeclarationFragment var = (VariableDeclarationFragment)itVarNames.next();
String name = var.getName().getIdentifier();
entityInfo.updateReference(name, true, type, mappedBy,
- 0 != annNameShort.compareTo(fullyQualifiedName));
+ 0 != annNameShort.compareTo(fullyQualifiedName), true);
}
astNode = astNode.getParent();
if (astNode instanceof TypeDeclaration) {
@@ -184,6 +190,26 @@
}
}
}
+ else if (astNode instanceof MethodDeclaration) {
+ MethodDeclaration md = (MethodDeclaration)astNode;
+ if (md.getName().getIdentifier().startsWith("get")) { //$NON-NLS-1$
+ // the getter - process it
+ String name = getReturnIdentifier(md);
+ // process it like FieldDeclaration
+ entityInfo.updateReference(name, true, type, mappedBy,
+ 0 != annNameShort.compareTo(fullyQualifiedName), false);
+ astNode = astNode.getParent();
+ if (astNode instanceof TypeDeclaration) {
+ astNode = astNode.getParent();
+ if (astNode instanceof CompilationUnit) {
+ cu = (CompilationUnit)astNode;
+ }
+ }
+ }
+ else {
+ // ignore others
+ }
+ }
if (cu != null) {
if (tb == null) {
entityInfo.addRequiredImport(annNameFull);
@@ -250,31 +276,83 @@
return true;
}
+ public String getReturnIdentifier(MethodDeclaration node) {
+ String res = null;
+ List bodyStatemants = node.getBody().statements();
+ Iterator it = bodyStatemants.iterator();
+ for ( ; it.hasNext(); ) {
+ Object obj = it.next();
+ if (obj instanceof ReturnStatement) {
+ ReturnStatement ret_statement = (ReturnStatement)obj;
+ obj = ret_statement.getExpression();
+ if (obj instanceof SimpleName) {
+ SimpleName sn = (SimpleName)obj;
+ res = sn.getIdentifier();
+ }
+ break;
+ }
+ }
+ return res;
+ }
+
public boolean visit(MethodDeclaration node) {
if (node.getName().getFullyQualifiedName().compareTo(entityInfo.getName()) == 0) {
- // this is constructor declaration - process it
+ // this is constructor declaration - process it separately
entityInfo.setImplicitConstructorFlag(false);
if (node.parameters().size() == 0) {
entityInfo.setDefaultConstructorFlag(true);
}
+ return true;
}
- return true;
+ // -) is it setter?
+ if (node.getName().getIdentifier().startsWith("set")) { //$NON-NLS-1$
+ // setter - do not process it
+ return true;
+ }
+ // +) is it getter?
+ if (!node.getName().getIdentifier().startsWith("get")) { //$NON-NLS-1$
+ // not the getter - do not process it
+ return true;
+ }
+ // ?) has it an annotation? - updateAnnotationRelInfo
+ // 4) try to define its return type
+ Type type = node.getReturnType2();
+ // 5) try to define name
+ String returnIdentifier = getReturnIdentifier(node);
+ List<String> list = new ArrayList<String>();
+ list.add(returnIdentifier);
+ // process it as a field declaration
+ boolean res = processFieldOrGetter(type, list);
+ return res;
}
public boolean visit(FieldDeclaration node) {
- if (node.getType().isPrimitiveType()) {
- PrimitiveType pt = (PrimitiveType)node.getType();
+ Type type = node.getType();
+ List<String> list = new ArrayList<String>();
+ Iterator itVarNames = node.fragments().iterator();
+ while (itVarNames.hasNext()) {
+ VariableDeclarationFragment var = (VariableDeclarationFragment)itVarNames.next();
+ String name = var.getName().getIdentifier();
+ list.add(name);
+ }
+ boolean res = processFieldOrGetter(type, list);
+ return res;
+ }
+
+ public boolean processFieldOrGetter(Type type, List<String> list) {
+ if (type.isPrimitiveType()) {
+ PrimitiveType pt = (PrimitiveType)type;
if (!pt.getPrimitiveTypeCode().equals(PrimitiveType.BOOLEAN)) {
// this is candidate for primary id
- Iterator itVarNames = node.fragments().iterator();
+ Iterator itVarNames = list.iterator();
while (itVarNames.hasNext()) {
VariableDeclarationFragment var = (VariableDeclarationFragment)itVarNames.next();
String name = var.getName().getIdentifier();
entityInfo.addPrimaryIdCandidate(name);
}
}
- } else if (node.getType().isSimpleType()) {
- SimpleType st = (SimpleType)node.getType();
+ } else if (type.isSimpleType()) {
+ SimpleType st = (SimpleType)type;
ITypeBinding tb = st.resolveBinding();
if (tb != null) {
String entityFullyQualifiedName = ""; //$NON-NLS-1$
@@ -286,10 +364,9 @@
HibernateConsolePlugin.getDefault().logErrorMessage("JavaModelException:
", e); //$NON-NLS-1$
}
entityInfo.addDependency(entityFullyQualifiedName);
- Iterator itVarNames = node.fragments().iterator();
+ Iterator itVarNames = list.iterator();
while (itVarNames.hasNext()) {
- VariableDeclarationFragment var = (VariableDeclarationFragment)itVarNames.next();
- String name = var.getName().getIdentifier();
+ String name = (String)itVarNames.next();
entityInfo.addReference(name, entityFullyQualifiedName, RefType.MANY2ONE);
}
}
@@ -297,22 +374,21 @@
ITypeBinding tbParent = tb.getTypeDeclaration().getSuperclass();
if (tbParent != null &&
"java.lang.Number".equals(tbParent.getBinaryName())) { //$NON-NLS-1$
// this is candidate for primary id
- Iterator itVarNames = node.fragments().iterator();
+ Iterator itVarNames = list.iterator();
while (itVarNames.hasNext()) {
- VariableDeclarationFragment var = (VariableDeclarationFragment)itVarNames.next();
- String name = var.getName().getIdentifier();
+ String name = (String)itVarNames.next();
entityInfo.addPrimaryIdCandidate(name);
}
}
}
}
- } else if (node.getType().isArrayType()) {
- ArrayType at = (ArrayType)node.getType();
+ } else if (type.isArrayType()) {
+ ArrayType at = (ArrayType)type;
ITypeBinding tb = at.resolveBinding();
- } else if (node.getType().isParameterizedType()) {
- ParameterizedType pt = (ParameterizedType)node.getType();
- Type type = (Type)pt.getType();
- ITypeBinding tb = type.resolveBinding();
+ } else if (type.isParameterizedType()) {
+ ParameterizedType pt = (ParameterizedType)type;
+ Type typeP = (Type)pt.getType();
+ ITypeBinding tb = typeP.resolveBinding();
if (tb != null) {
ITypeBinding[] interfaces = tb.getTypeDeclaration().getInterfaces();
String fullyQualifiedNameTypeName = ""; //$NON-NLS-1$
@@ -329,8 +405,8 @@
if (fullyQualifiedNameTypeName.length() > 0) {
Iterator typeArgsIt = pt.typeArguments().iterator();
while (typeArgsIt.hasNext()) {
- type = (Type)typeArgsIt.next();
- tb = type.resolveBinding();
+ typeP = (Type)typeArgsIt.next();
+ tb = typeP.resolveBinding();
String entityFullyQualifiedName = ""; //$NON-NLS-1$
if (tb.getJavaElement() instanceof SourceType) {
SourceType sourceT = (SourceType)tb.getJavaElement();
@@ -340,21 +416,20 @@
HibernateConsolePlugin.getDefault().logErrorMessage("JavaModelException:
", e); //$NON-NLS-1$
}
entityInfo.addDependency(entityFullyQualifiedName);
- Iterator itVarNames = node.fragments().iterator();
+ Iterator itVarNames = list.iterator();
while (itVarNames.hasNext()) {
- VariableDeclarationFragment var =
(VariableDeclarationFragment)itVarNames.next();
- String name = var.getName().getIdentifier();
+ String name = (String)itVarNames.next();
entityInfo.addReference(name, entityFullyQualifiedName, RefType.ONE2MANY);
}
}
}
}
}
- } else if (node.getType().isQualifiedType()) {
- QualifiedType qt = (QualifiedType)node.getType();
+ } else if (type.isQualifiedType()) {
+ QualifiedType qt = (QualifiedType)type;
ITypeBinding tb = qt.resolveBinding();
- } else if (node.getType().isWildcardType()) {
- WildcardType wt = (WildcardType)node.getType();
+ } else if (type.isWildcardType()) {
+ WildcardType wt = (WildcardType)type;
ITypeBinding tb = wt.resolveBinding();
}
return true;
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/EntityInfo.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/EntityInfo.java 2008-12-16
13:53:24 UTC (rev 12622)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/EntityInfo.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -19,8 +19,10 @@
import java.util.TreeSet;
/**
+ * Service place to collect information about entity class.
+ * Then this info has been transformed according annotations
+ * creation assumption.
*
- *
* @author Vitali
*/
public class EntityInfo {
@@ -98,7 +100,13 @@
protected Map<String, Set<RefFieldInfo>> mapRefFieldInfo = null;
/*
*/
- protected List<String> primaryIdCandidates = new ArrayList<String>();
+ protected Set<String> primaryIdCandidates = new TreeSet<String>();
+ /*
+ */
+ protected int fromVariableCounter = 0;
+ /*
+ */
+ protected int fromMethodCounter = 0;
public void generateRefFieldInfoMap() {
mapRefFieldInfo = new TreeMap<String, Set<RefFieldInfo>>();
@@ -143,28 +151,28 @@
}
public RefType getFieldIdRelValue(String fieldId) {
- if (references == null || !references.containsKey(fieldId)) {
+ if (references == null || fieldId == null || !references.containsKey(fieldId)) {
return RefType.UNDEF;
}
return references.get(fieldId).refType;
}
public boolean getFieldIdAnnotatedValue(String fieldId) {
- if (references == null || !references.containsKey(fieldId)) {
+ if (references == null || fieldId == null || !references.containsKey(fieldId)) {
return false;
}
return references.get(fieldId).annotated;
}
public String getFieldIdFQNameValue(String fieldId) {
- if (references == null || !references.containsKey(fieldId)) {
+ if (references == null || fieldId == null || !references.containsKey(fieldId)) {
return ""; //$NON-NLS-1$
}
return references.get(fieldId).fullyQualifiedName;
}
public RefEntityInfo getFieldIdRefEntityInfo(String fieldId) {
- if (references == null || !references.containsKey(fieldId)) {
+ if (references == null || fieldId == null || !references.containsKey(fieldId)) {
return null;
}
return references.get(fieldId);
@@ -307,18 +315,49 @@
}
public void addReference(String fieldId, String fullyQualifiedName, RefType refType) {
+ if (references == null || fieldId == null) {
+ return;
+ }
+ if (references.containsKey(fieldId)) {
+ RefEntityInfo rei = references.get(fieldId);
+ if (rei != null) {
+ if (rei.fullyQualifiedName != null) {
+ assert(rei.fullyQualifiedName.equals(fullyQualifiedName));
+ }
+ if (rei.refType != null) {
+ assert(rei.refType.equals(refType));
+ }
+ }
+ return;
+ }
references.put(fieldId, new RefEntityInfo(fullyQualifiedName, refType));
}
public void updateReference(String fieldId, boolean annotated, RefType refType, String
mappedBy,
- boolean resolvedAnnotationName) {
+ boolean resolvedAnnotationName, boolean fromVariable) {
+ if (references == null || fieldId == null || !references.containsKey(fieldId)) {
+ return;
+ }
RefEntityInfo rei = references.get(fieldId);
if (rei != null) {
- rei.annotated = annotated;
- rei.refType = refType;
- rei.mappedBy = mappedBy;
- rei.resolvedAnnotationName = resolvedAnnotationName;
+ if (rei.updateCounter == 0) {
+ rei.annotated = annotated;
+ rei.refType = refType;
+ rei.mappedBy = mappedBy;
+ rei.resolvedAnnotationName = resolvedAnnotationName;
+ }
+ else {
+ // TODO: possible conflicting info - think about it
+ assert(false);
+ }
+ rei.updateCounter++;
}
+ if (fromVariable) {
+ fromVariableCounter++;
+ }
+ else {
+ fromMethodCounter++;
+ }
}
public Set<RefFieldInfo> getRefFieldInfoSet(String fullyQualifiedName) {
@@ -377,4 +416,12 @@
public boolean needImport(String checkImport) {
return (!setExistingImports.contains(checkImport) &&
setRequiredImports.contains(checkImport));
}
+
+ public int getFromVariableCounter() {
+ return fromVariableCounter;
+ }
+
+ public int getFromMethodCounter() {
+ return fromMethodCounter;
+ }
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/JPAConst.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/JPAConst.java 2008-12-16
13:53:24 UTC (rev 12622)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/JPAConst.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -2,6 +2,12 @@
import java.util.Vector;
+/**
+ * Utility class to hold/operate strings constants
+ * of generated JPA annotations.
+ *
+ * @author Vitali
+ */
public class JPAConst {
static public String IMPORT_SERIALIZABLE = "java.io.Serializable";
//$NON-NLS-1$
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/RefEntityInfo.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/RefEntityInfo.java 2008-12-16
13:53:24 UTC (rev 12622)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/RefEntityInfo.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -11,8 +11,8 @@
package org.hibernate.eclipse.jdt.ui.internal.jpa.common;
/**
+ * Describes relation between 2 entities
*
- *
* @author Vitali
*/
public class RefEntityInfo implements Comparable<RefEntityInfo> {
@@ -40,6 +40,8 @@
public boolean hasGetter = false;
//
public boolean hasSetter = false;
+ // should count number of update operations - cause it is possible to get conflicting
information
+ public int updateCounter = 0;
//
public RefEntityInfo(String fullyQualifiedName, RefType refType) {
this.fullyQualifiedName = fullyQualifiedName;
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/RefFieldInfo.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/RefFieldInfo.java 2008-12-16
13:53:24 UTC (rev 12622)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/RefFieldInfo.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -11,8 +11,8 @@
package org.hibernate.eclipse.jdt.ui.internal.jpa.common;
/**
+ * Holds information about field reference annotation
*
- *
* @author Vitali
*/
public class RefFieldInfo implements Comparable<RefFieldInfo> {
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/RefType.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/RefType.java 2008-12-16
13:53:24 UTC (rev 12622)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/RefType.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -11,8 +11,8 @@
package org.hibernate.eclipse.jdt.ui.internal.jpa.common;
/**
+ * possible reference types
*
- *
* @author Vitali
*/
public enum RefType {
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/Utils.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/Utils.java 2008-12-16
13:53:24 UTC (rev 12622)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/Utils.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -27,8 +27,8 @@
import org.hibernate.eclipse.console.HibernateConsolePlugin;
/**
+ * Compilation unit common functions
*
- *
* @author Vitali
*/
public class Utils {
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/AllEntitiesProcessor.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/AllEntitiesProcessor.java 2008-12-16
13:53:24 UTC (rev 12622)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/AllEntitiesProcessor.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -31,17 +31,13 @@
import org.eclipse.jdt.internal.ui.refactoring.RefactoringSaveHelper;
import org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter;
import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider;
-import org.eclipse.jdt.ui.JavaElementLabelProvider;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.ListViewer;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StyledString;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ltk.core.refactoring.Change;
@@ -52,32 +48,49 @@
import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
import org.eclipse.text.edits.MalformedTreeException;
import org.eclipse.text.edits.TextEdit;
import org.eclipse.text.edits.UndoEdit;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.hibernate.eclipse.jdt.ui.Activator;
import org.hibernate.eclipse.jdt.ui.internal.JdtUiMessages;
import org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo;
import org.hibernate.eclipse.jdt.ui.internal.jpa.common.Utils;
/**
+ * Modify entity classes
*
- *
* @author Vitali
*/
public class AllEntitiesProcessor {
+ /**
+ * place to search compilation units
+ */
protected IJavaProject javaProject;
+ /**
+ * annotation style
+ */
+ protected AnnotStyle annotationStyle = AnnotStyle.FIELDS;
+ /**
+ * annotation style preference of majority
+ */
+ protected AnnotStyle annotationStylePreference = AnnotStyle.FIELDS;
+ /**
+ * group all information about changes of document in one structure
+ */
protected class ChangeStructure {
public String fullyQualifiedName;
public IPath path;
@@ -86,8 +99,41 @@
public ITextFileBuffer textFileBuffer;
public Change change;
};
+ /**
+ * change info storage
+ */
protected ArrayList<ChangeStructure> changes = new
ArrayList<ChangeStructure>();
+
+ public AllEntitiesProcessor() {
+ IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();
+ int value = preferenceStore.getInt(AllEntitiesProcessor.class.toString());
+ if (value >= AnnotStyle.values().length) {
+ value = 0;
+ }
+ annotationStyle = AnnotStyle.values()[value];
+ }
+
+ public void saveAnnotationStylePreference() {
+ IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();
+ int value = 0;
+ while (value < AnnotStyle.values().length) {
+ if (AnnotStyle.values()[value] == annotationStyle) {
+ break;
+ }
+ value++;
+ }
+ if (value >= AnnotStyle.values().length) {
+ value = 0;
+ }
+ preferenceStore.setValue(AllEntitiesProcessor.class.toString(), value);
+ }
+ /**
+ * execute modification for collection of entities
+ * @param project - common java project for collection of entities
+ * @param entities - collection
+ * @param askConfirmation - ask user confirmation (show dialog)
+ */
public void modify(IJavaProject project, Map<String, EntityInfo> entities,
boolean askConfirmation) {
changes.clear();
@@ -141,30 +187,21 @@
// show warning about compiler problems
// ...
// modify accepted items
- it = entities.entrySet().iterator();
- try {
- while (it.hasNext()) {
- Map.Entry<String, EntityInfo> entry = it.next();
- if (entry.getValue().isAbstractFlag()) {
- continue;
- }
- // this is not only errors, but warnings too
- //if (entry.getValue().isCompilerProblemsFlag()) {
- // continue;
- //}
- // modify only non-abstract classes
- collectModification(bufferManager, entry.getKey(), entry.getValue());
- }
- } catch (CoreException e) {
- HibernateConsolePlugin.getDefault().logErrorMessage("CoreException: ", e);
//$NON-NLS-1$
+ if (getAnnotationStyle().equals(AnnotStyle.AUTO)) {
+ setAnnotationStyle(getAnnotationStylePreference());
+ reCollectModification(bufferManager, entities);
+ setAnnotationStyle(AnnotStyle.AUTO);
}
+ else {
+ reCollectModification(bufferManager, entities);
+ }
}
else {
performChange = false;
}
//
if (askConfirmation) {
- if (!showRefactoringDialog(entities)) {
+ if (!showRefactoringDialog(entities, bufferManager)) {
performChange = false;
}
}
@@ -207,6 +244,24 @@
}
}
+ public void reCollectModification(ITextFileBufferManager bufferManager,
+ Map<String, EntityInfo> entities) {
+
+ changes.clear();
+ Iterator<Map.Entry<String, EntityInfo>> it =
entities.entrySet().iterator();
+ try {
+ while (it.hasNext()) {
+ Map.Entry<String, EntityInfo> entry = it.next();
+ if (entry.getValue().isAbstractFlag()) {
+ continue;
+ }
+ collectModification(bufferManager, entry.getKey(), entry.getValue());
+ }
+ } catch (CoreException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage("CoreException: ", e);
//$NON-NLS-1$
+ }
+ }
+
public void collectModification(ITextFileBufferManager bufferManager, String
fullyQualifiedName,
EntityInfo entityInfo) throws CoreException {
@@ -224,6 +279,7 @@
ASTRewrite rewriter = ASTRewrite.create(ast);
// ... rewrite
ProcessEntityInfo processor = new ProcessEntityInfo();
+ processor.setAnnotationStyle(annotationStyle);
processor.setEntityInfo(entityInfo);
processor.setASTRewrite(rewriter);
cu.accept(processor);
@@ -238,7 +294,8 @@
}
}
- public boolean showRefactoringDialog(final Map<String, EntityInfo> entities) {
+ public boolean showRefactoringDialog(final Map<String, EntityInfo> entities,
+ final ITextFileBufferManager bufferManager) {
final String wizard_title = JdtUiMessages.AllEntitiesProcessor_header;
@@ -257,7 +314,7 @@
@Override
public Change createChange(IProgressMonitor pm){
- final CompositeChange cc = new CompositeChange("");
+ final CompositeChange cc = new CompositeChange(""); //$NON-NLS-1$
for (int i = 0; i < changes.size(); i++) {
ChangeStructure cs = changes.get(i);
String change_name = cs.fullyQualifiedName;
@@ -276,6 +333,27 @@
}
};
+ final ModifyListener ml = new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ int idx = ((Combo)e.getSource()).getSelectionIndex();
+ if (idx == 0 && !getAnnotationStyle().equals(AnnotStyle.FIELDS)) {
+ setAnnotationStyle(AnnotStyle.FIELDS);
+ reCollectModification(bufferManager, entities);
+ }
+ else if (idx == 1 && !getAnnotationStyle().equals(AnnotStyle.GETTERS)) {
+ setAnnotationStyle(AnnotStyle.GETTERS);
+ reCollectModification(bufferManager, entities);
+ }
+ else if (idx == 2 && !getAnnotationStyle().equals(AnnotStyle.AUTO)) {
+ setAnnotationStyle(getAnnotationStylePreference());
+ reCollectModification(bufferManager, entities);
+ setAnnotationStyle(AnnotStyle.AUTO);
+ }
+ }
+
+ };
+
RefactoringWizard wizard = new RefactoringWizard(ref,
RefactoringWizard.DIALOG_BASED_USER_INTERFACE) {
@Override
@@ -344,6 +422,30 @@
.grab(true, true)
.hint(convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH),
convertHorizontalDLUsToPixels(2 *
IDialogConstants.BUTTON_BAR_HEIGHT)).applyTo(listViewer.getControl());
+ //Button generateChoice = new Button(container, SWT.CHECK);
+ //generateChoice.setText("fdwsdfv");
+ Composite combolabel = new Composite(container, SWT.NULL);
+ layout = new GridLayout();
+ combolabel.setLayout(layout);
+ layout.numColumns = 2;
+ Label labelChoice = new Label(combolabel, SWT.NULL);
+ labelChoice.setText(JdtUiMessages.AllEntitiesProcessor_setup_annotation_generation_preference);
+ Combo generateChoice = new Combo(combolabel, SWT.READ_ONLY);
+ generateChoice.add(JdtUiMessages.AllEntitiesProcessor_annotate_fields);
+ generateChoice.add(JdtUiMessages.AllEntitiesProcessor_annotate_getters);
+ generateChoice.add(JdtUiMessages.AllEntitiesProcessor_auto_select_from_class_preference);
+ int idx = 0;
+ if (getAnnotationStyle().equals(AnnotStyle.FIELDS)) {
+ idx = 0;
+ }
+ else if (getAnnotationStyle().equals(AnnotStyle.GETTERS)) {
+ idx = 1;
+ }
+ else if (getAnnotationStyle().equals(AnnotStyle.AUTO)) {
+ idx = 2;
+ }
+ generateChoice.select(idx);
+ generateChoice.addModifyListener(ml);
setControl(container);
}
};
@@ -362,11 +464,23 @@
return res;
}
- public IJavaProject getJavaProject() {
- return javaProject;
- }
-
protected void setJavaProject(IJavaProject project) {
javaProject = project;
}
+
+ public AnnotStyle getAnnotationStyle() {
+ return annotationStyle;
+ }
+
+ public void setAnnotationStyle(AnnotStyle annotationStyle) {
+ this.annotationStyle = annotationStyle;
+ }
+
+ public AnnotStyle getAnnotationStylePreference() {
+ return annotationStylePreference;
+ }
+
+ public void setAnnotationStylePreference(AnnotStyle annotationStylePreference) {
+ this.annotationStylePreference = annotationStylePreference;
+ }
}
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/AnnotStyle.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/AnnotStyle.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/AnnotStyle.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -0,0 +1,7 @@
+package org.hibernate.eclipse.jdt.ui.internal.jpa.process;
+
+public enum AnnotStyle {
+ FIELDS,
+ GETTERS,
+ AUTO,
+}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/ProcessEntityInfo.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/ProcessEntityInfo.java 2008-12-16
13:53:24 UTC (rev 12622)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/ProcessEntityInfo.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -14,6 +14,7 @@
import java.util.List;
import java.util.Set;
+import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.ASTVisitor;
import org.eclipse.jdt.core.dom.Block;
import org.eclipse.jdt.core.dom.CompilationUnit;
@@ -25,9 +26,11 @@
import org.eclipse.jdt.core.dom.Modifier;
import org.eclipse.jdt.core.dom.NormalAnnotation;
import org.eclipse.jdt.core.dom.QualifiedName;
+import org.eclipse.jdt.core.dom.ReturnStatement;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.SimpleType;
import org.eclipse.jdt.core.dom.StringLiteral;
+import org.eclipse.jdt.core.dom.Type;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
@@ -39,15 +42,26 @@
import org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefType;
/**
+ * Visitor to insert JPA annotations into proper
+ * places of entity class.
*
- *
* @author Vitali
*/
public class ProcessEntityInfo extends ASTVisitor {
+ /**
+ * information about entity's annotations
+ */
protected EntityInfo entityInfo;
+ /**
+ * rewriter to generate new AST blocks
+ */
protected ASTRewrite rewriter;
-
+ /**
+ * annotation style
+ */
+ protected AnnotStyle annotationStyle = AnnotStyle.FIELDS;
+
public void setEntityInfo(EntityInfo entityInfo) {
this.entityInfo = entityInfo;
}
@@ -57,6 +71,8 @@
}
public boolean visit(CompilationUnit node) {
+ // TODO: sort all imports in alphabetic order
+ //ListRewrite lrw = rewriter.getListRewrite(node, CompilationUnit.IMPORTS_PROPERTY);
for (int i = 0; i < JPAConst.ALL_IMPORTS.size(); i++) {
String tmp = JPAConst.ALL_IMPORTS.get(i);
if (entityInfo.needImport(tmp)) {
@@ -81,9 +97,28 @@
}
importDecl.setName(qualifiedName0);
ListRewrite lrw = rewriter.getListRewrite(node, CompilationUnit.IMPORTS_PROPERTY);
- // TODO: insert import declaration in the proper place
+ // insert import declaration in the proper place
// prefer alphabetic order and package separation
- lrw.insertLast(importDecl, null);
+ Iterator it = lrw.getRewrittenList().iterator();
+ ASTNode insertBeforeNode = null;
+ for ( ; it.hasNext(); ) {
+ Object obj = it.next();
+ if (!(obj instanceof ImportDeclaration)) {
+ continue;
+ }
+ ImportDeclaration id = (ImportDeclaration)obj;
+ String idName = id.getName().getFullyQualifiedName();
+ if (idName.compareTo(importDeclaration) > 0) {
+ insertBeforeNode = id;
+ break;
+ }
+ }
+ if (insertBeforeNode == null) {
+ lrw.insertLast(importDecl, null);
+ }
+ else {
+ lrw.insertBefore(importDecl, insertBeforeNode, null);
+ }
return true;
}
@@ -145,7 +180,14 @@
}
public boolean visit(FieldDeclaration node) {
- if (node.getType().isSimpleType() || node.getType().isPrimitiveType()) {
+ if (annotationStyle != AnnotStyle.FIELDS) {
+ return true;
+ }
+ Type type = node.getType();
+ if (type == null) {
+ return true;
+ }
+ if (type.isSimpleType() || type.isPrimitiveType()) {
if (entityInfo.isAddGeneratedValueFlag()) {
String primaryIdName = entityInfo.getPrimaryIdName();
Iterator itVarNames = node.fragments().iterator();
@@ -185,7 +227,7 @@
}
}
}
- if (node.getType().isSimpleType() || node.getType().isParameterizedType()) {
+ if (type.isSimpleType() || type.isParameterizedType()) {
Iterator itVarNames = node.fragments().iterator();
String fieldId = ""; //$NON-NLS-1$
RefType refType = RefType.UNDEF;
@@ -233,6 +275,105 @@
return true;
}
+ public boolean visit(MethodDeclaration node) {
+ if (annotationStyle != AnnotStyle.GETTERS) {
+ return true;
+ }
+ Type type = node.getReturnType2();
+ if (type == null) {
+ return true;
+ }
+ String returnIdentifier = getReturnIdentifier(node);
+ if (type.isSimpleType() || type.isPrimitiveType()) {
+ if (entityInfo.isAddGeneratedValueFlag()) {
+ String primaryIdName = entityInfo.getPrimaryIdName();
+ boolean addGeneratedValueMarker = false;
+ if (primaryIdName.equals(returnIdentifier)) {
+ addGeneratedValueMarker = true;
+ }
+ if (addGeneratedValueMarker) {
+ MarkerAnnotation matd = rewriter.getAST().newMarkerAnnotation();
+ matd.setTypeName(rewriter.getAST().newSimpleName(JPAConst.ANNOTATION_GENERATED_VALUE));
+ ListRewrite lrw = rewriter.getListRewrite(node,
MethodDeclaration.MODIFIERS2_PROPERTY);
+ lrw.insertFirst(matd, null);
+ }
+ }
+ if (entityInfo.isAddPrimaryIdFlag()) {
+ String primaryIdName = entityInfo.getPrimaryIdName();
+ boolean addIdMarker = false;
+ if (primaryIdName.equals(returnIdentifier)) {
+ addIdMarker = true;
+ }
+ if (addIdMarker) {
+ MarkerAnnotation matd = rewriter.getAST().newMarkerAnnotation();
+ matd.setTypeName(rewriter.getAST().newSimpleName(JPAConst.ANNOTATION_ID));
+ ListRewrite lrw = rewriter.getListRewrite(node,
MethodDeclaration.MODIFIERS2_PROPERTY);
+ lrw.insertFirst(matd, null);
+ }
+ }
+ }
+ if (type.isSimpleType() || type.isParameterizedType()) {
+ String fieldId = ""; //$NON-NLS-1$
+ RefType refType = RefType.UNDEF;
+ boolean annotated = false;
+ String fullyQualifiedName2 = ""; //$NON-NLS-1$
+ fieldId = returnIdentifier;
+ refType = entityInfo.getFieldIdRelValue(fieldId);
+ annotated = entityInfo.getFieldIdAnnotatedValue(fieldId);
+ fullyQualifiedName2 = entityInfo.getFieldIdFQNameValue(fieldId);
+ if (refType != RefType.UNDEF) {
+ }
+ Set<RefFieldInfo> setRFI = entityInfo.getRefFieldInfoSet(fullyQualifiedName2);
+ if (!annotated && setRFI != null) {
+ RefEntityInfo rei = entityInfo.getFieldIdRefEntityInfo(fieldId);
+ // try to process bidirectional relationships:
+ // nRefType == JPAConst.ONE2ONE - OneToOne - the owning side corresponds
+ // to the side that contains the corresponding foreign key
+ // nRefType == JPAConst.MANY2ONE - ManyToOne - owning side is always the
"many" side
+ // nRefType == JPAConst.MANY2MANY - ManyToMany bidirectional relationships
+ // either side may be the owning side
+ if (setRFI.size() > 1 && refType != RefType.MANY2ONE) {
+ if (rei.mappedBy == null || rei.mappedBy == "") { //$NON-NLS-1$
+ addSimpleMarkerAnnotation(node, JPAConst.getRefType(refType));
+ }
+ else {
+ // give to the user information about selected mapping
+ addComplexNormalAnnotation(node, JPAConst.getRefType(refType), rei);
+ }
+ }
+ else if (refType == RefType.MANY2ONE || rei.mappedBy == null || rei.mappedBy ==
"") { //$NON-NLS-1$
+ addSimpleMarkerAnnotation(node, JPAConst.getRefType(refType));
+ }
+ else {
+ // in case of bidirectional OneToOne - mark both sides with mappedBy -
+ // user should select the right decision
+ addComplexNormalAnnotation(node, JPAConst.getRefType(refType), rei);
+ }
+ }
+ }
+ return true;
+ }
+
+ // duplicate method from CollectEntityInfo
+ public String getReturnIdentifier(MethodDeclaration node) {
+ String res = null;
+ List bodyStatemants = node.getBody().statements();
+ Iterator it = bodyStatemants.iterator();
+ for ( ; it.hasNext(); ) {
+ Object obj = it.next();
+ if (obj instanceof ReturnStatement) {
+ ReturnStatement ret_statement = (ReturnStatement)obj;
+ obj = ret_statement.getExpression();
+ if (obj instanceof SimpleName) {
+ SimpleName sn = (SimpleName)obj;
+ res = sn.getIdentifier();
+ }
+ break;
+ }
+ }
+ return res;
+ }
+
public boolean addSimpleMarkerAnnotation(FieldDeclaration node, String name) {
if (name == null || name.length() == 0) {
return false;
@@ -265,5 +406,45 @@
lrw.insertFirst(natd, null);
return true;
}
+
+ public boolean addSimpleMarkerAnnotation(MethodDeclaration node, String name) {
+ if (name == null || name.length() == 0) {
+ return false;
+ }
+ MarkerAnnotation matd = rewriter.getAST().newMarkerAnnotation();
+ matd.setTypeName(rewriter.getAST().newSimpleName(name));
+ ListRewrite lrw = rewriter.getListRewrite(node,
MethodDeclaration.MODIFIERS2_PROPERTY);
+ lrw.insertFirst(matd, null);
+ return true;
+ }
+
+ public boolean addComplexNormalAnnotation(MethodDeclaration node, String name,
RefEntityInfo rei) {
+ if (name == null || name.length() == 0) {
+ return false;
+ }
+ NormalAnnotation natd = rewriter.getAST().newNormalAnnotation();
+ MemberValuePair mvp = null;
+ if (rei.mappedBy != null) {
+ mvp = rewriter.getAST().newMemberValuePair();
+ mvp.setName(rewriter.getAST().newSimpleName("mappedBy")); //$NON-NLS-1$
+ StringLiteral sl = rewriter.getAST().newStringLiteral();
+ sl.setLiteralValue(rei.mappedBy);
+ mvp.setValue(sl);
+ }
+ natd.setTypeName(rewriter.getAST().newSimpleName(name));
+ if (mvp != null) {
+ natd.values().add(mvp);
+ }
+ ListRewrite lrw = rewriter.getListRewrite(node,
MethodDeclaration.MODIFIERS2_PROPERTY);
+ lrw.insertFirst(natd, null);
+ return true;
+ }
+ public AnnotStyle getAnnotationStyle() {
+ return annotationStyle;
+ }
+
+ public void setAnnotationStyle(AnnotStyle annotationStyle) {
+ this.annotationStyle = annotationStyle;
+ }
}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/TestUtilsCommon.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/TestUtilsCommon.java 2008-12-16
13:53:24 UTC (rev 12622)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/TestUtilsCommon.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -17,6 +17,7 @@
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.core.internal.resources.ResourceException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
@@ -26,6 +27,7 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
@@ -100,10 +102,14 @@
File[] files = src.listFiles(fileFilter);
for (int i = 0; i < files.length; i++) {
File file = files[i];
- if (!file.exists())
+ if (!file.exists()) {
continue;
+ }
IFile iFile = dst.getFile(file.getName());
try {
+ if (iFile.exists()) {
+ iFile.delete(true, null);
+ }
iFile.create(new FileInputStream(file), true, null);
} catch (FileNotFoundException e) {
e.printStackTrace();
@@ -117,11 +123,14 @@
File[] dirs = src.listFiles(dirFilter);
for (int i = 0; i < dirs.length; i++) {
File dir = dirs[i];
- if (!dir.exists())
+ if (!dir.exists()) {
continue;
+ }
IFolder iFolder = dst.getFolder(dir.getName());
try {
- iFolder.create(true, true, null);
+ if (!iFolder.exists()) {
+ iFolder.create(true, true, null);
+ }
recursiveCopyFiles(dir, iFolder);
} catch (CoreException e) {
e.printStackTrace();
@@ -152,7 +161,15 @@
public void createAndOpenProject(IProjectDescription description,
IProject projectHandle) throws CoreException {
- projectHandle.create(description, null);
+ try {
+ projectHandle.create(description, null);
+ } catch (ResourceException re) {
+ // if the project exist - ignore exception
+ if (re.getStatus().getCode() != 374 || re.getStatus().getSeverity() != IStatus.ERROR
||
+ !"org.eclipse.core.resources".equals(re.getStatus().getPlugin())) {
//$NON-NLS-1$
+ throw re;
+ }
+ }
projectHandle.open(IResource.BACKGROUND_REFRESH, null);
}
@@ -226,9 +243,13 @@
File[] files = libFolder.listFiles(jarFilter);
for (int i = 0; i < files.length; i++) {
File file = files[i];
- if (!file.exists())
+ if (!file.exists()) {
continue;
+ }
IFile iFile = dst.getFile(file.getName());
+ if (iFile.exists()) {
+ iFile.delete(true, null);
+ }
try {
iFile.create(new FileInputStream(file), true, null);
libs.add(iFile.getFullPath());
Deleted:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/Document.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/Document.java 2008-12-16
13:53:24 UTC (rev 12622)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/Document.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package test.annotated;
-
-import java.util.Set;
-
-(a)javax.persistence.Entity
-public class Document {
-
- @javax.persistence.Id
- protected Long documentId;
-
- protected Person documentOwner;
-
- @javax.persistence.OneToMany
- protected Set<Person> persons;
-
- protected Byte docType = 0;
-
- public Long getDocumentId() {
- return documentId;
- }
-
- public void setDocumentId(Long documentId) {
- this.documentId = documentId;
- }
-
- public Person getDocumentOwner() {
- return documentOwner;
- }
-
- public void setDocumentOwner(Person documentOwner) {
- this.documentOwner = documentOwner;
- }
-
- public Set<Person> getPersons() {
- return persons;
- }
-
- public void setPersons(Set<Person> persons) {
- this.persons = persons;
- }
-
- public Byte getDocType() {
- return docType;
- }
-
- protected void setDocType(Byte docType) {
- this.docType = docType;
- }
-
-}
Deleted:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/Foto.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/Foto.java 2008-12-16
13:53:24 UTC (rev 12622)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/Foto.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package test.annotated;
-
-public class Foto {
-
- protected Long fid;
-
- protected Short id;
-
- protected Person person;
-
- protected Short width_IDtest;
-
- protected Short height_testID;
-
- public Foto() {
- }
-
- public Long getFid() {
- return fid;
- }
-
- public void setFid(Long fid) {
- this.fid = fid;
- }
-
- public Short getId() {
- return id;
- }
-
- public void setId(Short id) {
- this.id = id;
- }
-
- public Person getPerson() {
- return person;
- }
-
- public void setPerson(Person person) {
- this.person = person;
- }
-
- public Short getWidth_IDtest() {
- return width_IDtest;
- }
-
- public void setWidth_IDtest(Short width_IDtest) {
- this.width_IDtest = width_IDtest;
- }
-
- public Short getHeight_testID() {
- return height_testID;
- }
-
- public void setHeight_testID(Short height_testID) {
- this.height_testID = height_testID;
- }
-
-}
Deleted:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/Passport.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/Passport.java 2008-12-16
13:53:24 UTC (rev 12622)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/Passport.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package test.annotated;
-
-public class Passport extends Document {
-
- protected Long fakeId;
-
- public Passport() {
- setDocType((byte)1);
- }
-
-}
Deleted:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/Person.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/Person.java 2008-12-16
13:53:24 UTC (rev 12622)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/Person.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package test.annotated;
-
-import java.util.Set;
-
-public class Person {
-
- protected Long personId;
-
- @OneToMany(mappedBy="documentOwner")
- protected Set<Document> documents;
-
- protected Foto foto;
-
- protected Set someTestSet;
-
- public Long getPersonId() {
- return personId;
- }
-
- public void setPersonId(Long personId) {
- this.personId = personId;
- }
-
- public Set<Document> getDocuments() {
- return documents;
- }
-
- public void setDocuments(Set<Document> documents) {
- this.documents = documents;
- }
-
- public Foto getFoto() {
- return foto;
- }
-
- public void setFoto(Foto foto) {
- this.foto = foto;
- }
-
-}
Deleted:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/Staff.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/Staff.java 2008-12-16
13:53:24 UTC (rev 12622)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/Staff.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package test.annotated;
-
-public class Staff extends Document {
-
- protected Long code;
-
- public Staff(long code) {
- this.code = code;
- setDocType((byte)2);
- }
-}
Copied:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/fields/Document.java
(from rev 10877,
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/Document.java)
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/fields/Document.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/fields/Document.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package test.annotated.fields;
+
+import java.util.Set;
+
+(a)javax.persistence.Entity
+public class Document {
+
+ @javax.persistence.Id
+ protected Long documentId;
+
+ protected Person documentOwner;
+
+ @javax.persistence.OneToMany
+ protected Set<Person> persons;
+
+ protected Byte docType = 0;
+
+ public Long getDocumentId() {
+ return documentId;
+ }
+
+ public void setDocumentId(Long documentId) {
+ this.documentId = documentId;
+ }
+
+ public Person getDocumentOwner() {
+ return documentOwner;
+ }
+
+ public void setDocumentOwner(Person documentOwner) {
+ this.documentOwner = documentOwner;
+ }
+
+ public Set<Person> getPersons() {
+ return persons;
+ }
+
+ public void setPersons(Set<Person> persons) {
+ this.persons = persons;
+ }
+
+ public Byte getDocType() {
+ return docType;
+ }
+
+ protected void setDocType(Byte docType) {
+ this.docType = docType;
+ }
+
+}
Property changes on:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/fields/Document.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/fields/Foto.java
(from rev 10877,
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/Foto.java)
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/fields/Foto.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/fields/Foto.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package test.annotated.fields;
+
+public class Foto {
+
+ protected Long fid;
+
+ protected Short id;
+
+ protected Person person;
+
+ protected Short width_IDtest;
+
+ protected Short height_testID;
+
+ public Foto() {
+ }
+
+ public Long getFid() {
+ return fid;
+ }
+
+ public void setFid(Long fid) {
+ this.fid = fid;
+ }
+
+ public Short getId() {
+ return id;
+ }
+
+ public void setId(Short id) {
+ this.id = id;
+ }
+
+ public Person getPerson() {
+ return person;
+ }
+
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+
+ public Short getWidth_IDtest() {
+ return width_IDtest;
+ }
+
+ public void setWidth_IDtest(Short width_IDtest) {
+ this.width_IDtest = width_IDtest;
+ }
+
+ public Short getHeight_testID() {
+ return height_testID;
+ }
+
+ public void setHeight_testID(Short height_testID) {
+ this.height_testID = height_testID;
+ }
+
+}
Property changes on:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/fields/Foto.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/fields/Passport.java
(from rev 10877,
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/Passport.java)
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/fields/Passport.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/fields/Passport.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package test.annotated.fields;
+
+public class Passport extends Document {
+
+ protected Long fakeId;
+
+ public Passport() {
+ setDocType((byte)1);
+ }
+
+}
Property changes on:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/fields/Passport.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/fields/Person.java
(from rev 10877,
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/Person.java)
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/fields/Person.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/fields/Person.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package test.annotated.fields;
+
+import java.util.Set;
+
+public class Person {
+
+ protected Long personId;
+
+ @OneToMany(mappedBy="documentOwner")
+ protected Set<Document> documents;
+
+ protected Foto foto;
+
+ protected Set someTestSet;
+
+ public Long getPersonId() {
+ return personId;
+ }
+
+ public void setPersonId(Long personId) {
+ this.personId = personId;
+ }
+
+ public Set<Document> getDocuments() {
+ return documents;
+ }
+
+ public void setDocuments(Set<Document> documents) {
+ this.documents = documents;
+ }
+
+ public Foto getFoto() {
+ return foto;
+ }
+
+ public void setFoto(Foto foto) {
+ this.foto = foto;
+ }
+
+}
Property changes on:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/fields/Person.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/fields/Staff.java
(from rev 10877,
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/Staff.java)
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/fields/Staff.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/fields/Staff.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package test.annotated.fields;
+
+public class Staff extends Document {
+
+ protected Long code;
+
+ public Staff(long code) {
+ this.code = code;
+ setDocType((byte)2);
+ }
+}
Property changes on:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/fields/Staff.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/getters/Document.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/getters/Document.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/getters/Document.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package test.annotated.getters;
+
+import java.util.Set;
+
+(a)javax.persistence.Entity
+public class Document {
+
+ private Long documentId;
+
+ private Person documentOwner;
+
+ private Set<Person> persons;
+
+ private Byte docType = 0;
+
+ @javax.persistence.Id
+ public Long getDocumentId() {
+ return documentId;
+ }
+
+ public void setDocumentId(Long documentId) {
+ this.documentId = documentId;
+ }
+
+ public Person getDocumentOwner() {
+ return documentOwner;
+ }
+
+ public void setDocumentOwner(Person documentOwner) {
+ this.documentOwner = documentOwner;
+ }
+
+ @javax.persistence.OneToMany
+ public Set<Person> getPersons() {
+ return persons;
+ }
+
+ public void setPersons(Set<Person> persons) {
+ this.persons = persons;
+ }
+
+ public Byte getDocType() {
+ return docType;
+ }
+
+ protected void setDocType(Byte docType) {
+ this.docType = docType;
+ }
+
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/getters/Foto.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/getters/Foto.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/getters/Foto.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package test.annotated.getters;
+
+public class Foto {
+
+ private Long fid;
+
+ private Short id;
+
+ private Person person;
+
+ private Short width_IDtest;
+
+ private Short height_testID;
+
+ public Foto() {
+ }
+
+ public Long getFid() {
+ return fid;
+ }
+
+ public void setFid(Long fid) {
+ this.fid = fid;
+ }
+
+ public Short getId() {
+ return id;
+ }
+
+ public void setId(Short id) {
+ this.id = id;
+ }
+
+ public Person getPerson() {
+ return person;
+ }
+
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+
+ public Short getWidth_IDtest() {
+ return width_IDtest;
+ }
+
+ public void setWidth_IDtest(Short width_IDtest) {
+ this.width_IDtest = width_IDtest;
+ }
+
+ public Short getHeight_testID() {
+ return height_testID;
+ }
+
+ public void setHeight_testID(Short height_testID) {
+ this.height_testID = height_testID;
+ }
+
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/getters/Passport.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/getters/Passport.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/getters/Passport.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package test.annotated.getters;
+
+public class Passport extends Document {
+
+ private Long fakeId;
+
+ public Passport() {
+ setDocType((byte)1);
+ }
+
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/getters/Person.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/getters/Person.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/getters/Person.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package test.annotated.getters;
+
+import java.util.Set;
+
+import javax.persistence.OneToOne;
+
+public class Person {
+
+ private Long personId;
+
+ private Set<Document> documents;
+
+ private Foto foto;
+
+ private Set someTestSet;
+
+ public Long getPersonId() {
+ return personId;
+ }
+
+ public void setPersonId(Long personId) {
+ this.personId = personId;
+ }
+
+ @OneToMany(mappedBy="documentOwner")
+ public Set<Document> getDocuments() {
+ return documents;
+ }
+
+ public void setDocuments(Set<Document> documents) {
+ this.documents = documents;
+ }
+
+ @OneToOne(mappedBy="person")
+ public Foto getFoto() {
+ return foto;
+ }
+
+ public void setFoto(Foto foto) {
+ this.foto = foto;
+ }
+
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/getters/Staff.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/getters/Staff.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/project/test/annotated/getters/Staff.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package test.annotated.getters;
+
+public class Staff extends Document {
+
+ private Long code;
+
+ public Staff(long code) {
+ this.code = code;
+ setDocType((byte)2);
+ }
+}
Deleted:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/Document.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/Document.java 2008-12-16
13:53:24 UTC (rev 12622)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/Document.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package test.annotated;
-
-import java.util.Set;
-
-import javax.persistence.GeneratedValue;
-import javax.persistence.ManyToOne;
-
-(a)javax.persistence.Entity
-public class Document {
-
- @GeneratedValue @javax.persistence.Id
- protected Long documentId;
-
- @ManyToOne
- protected Person documentOwner;
-
- @javax.persistence.OneToMany
- protected Set<Person> persons;
-
- protected Byte docType = 0;
-
- public Long getDocumentId() {
- return documentId;
- }
-
- public void setDocumentId(Long documentId) {
- this.documentId = documentId;
- }
-
- public Person getDocumentOwner() {
- return documentOwner;
- }
-
- public void setDocumentOwner(Person documentOwner) {
- this.documentOwner = documentOwner;
- }
-
- public Set<Person> getPersons() {
- return persons;
- }
-
- public void setPersons(Set<Person> persons) {
- this.persons = persons;
- }
-
- public Byte getDocType() {
- return docType;
- }
-
- protected void setDocType(Byte docType) {
- this.docType = docType;
- }
-
-}
Deleted:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/Foto.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/Foto.java 2008-12-16
13:53:24 UTC (rev 12622)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/Foto.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package test.annotated;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.OneToOne;
-
-@Entity
-public class Foto {
-
- protected Long fid;
-
- @Id @GeneratedValue
- protected Short id;
-
- @OneToOne(mappedBy="foto")
- protected Person person;
-
- protected Short width_IDtest;
-
- protected Short height_testID;
-
- public Foto() {
- }
-
- public Long getFid() {
- return fid;
- }
-
- public void setFid(Long fid) {
- this.fid = fid;
- }
-
- public Short getId() {
- return id;
- }
-
- public void setId(Short id) {
- this.id = id;
- }
-
- public Person getPerson() {
- return person;
- }
-
- public void setPerson(Person person) {
- this.person = person;
- }
-
- public Short getWidth_IDtest() {
- return width_IDtest;
- }
-
- public void setWidth_IDtest(Short width_IDtest) {
- this.width_IDtest = width_IDtest;
- }
-
- public Short getHeight_testID() {
- return height_testID;
- }
-
- public void setHeight_testID(Short height_testID) {
- this.height_testID = height_testID;
- }
-
-}
Deleted:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/Passport.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/Passport.java 2008-12-16
13:53:24 UTC (rev 12622)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/Passport.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package test.annotated;
-
-import javax.persistence.Entity;
-
-@Entity
-public class Passport extends Document {
-
- protected Long fakeId;
-
- public Passport() {
- setDocType((byte)1);
- }
-
-}
Deleted:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/Person.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/Person.java 2008-12-16
13:53:24 UTC (rev 12622)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/Person.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package test.annotated;
-
-import java.util.Set;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.OneToOne;
-import javax.persistence.OneToMany;
-
-@Entity
-public class Person {
-
- @Id @GeneratedValue
- protected Long personId;
-
- @OneToMany(mappedBy="documentOwner")
- protected Set<Document> documents;
-
- @OneToOne(mappedBy="person")
- protected Foto foto;
-
- protected Set someTestSet;
-
- public Long getPersonId() {
- return personId;
- }
-
- public void setPersonId(Long personId) {
- this.personId = personId;
- }
-
- public Set<Document> getDocuments() {
- return documents;
- }
-
- public void setDocuments(Set<Document> documents) {
- this.documents = documents;
- }
-
- public Foto getFoto() {
- return foto;
- }
-
- public void setFoto(Foto foto) {
- this.foto = foto;
- }
-
-}
Deleted:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/Staff.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/Staff.java 2008-12-16
13:53:24 UTC (rev 12622)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/Staff.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package test.annotated;
-
-import javax.persistence.Entity;
-
-@Entity
-public class Staff extends Document {
-
- protected Long code;
-
- protected Staff() {
- }
-
- public Staff(long code) {
- this.code = code;
- setDocType((byte)2);
- }
-}
Copied:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Document.java
(from rev 10877,
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/Document.java)
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Document.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Document.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package test.annotated.fields;
+
+import java.util.Set;
+
+import javax.persistence.GeneratedValue;
+import javax.persistence.ManyToOne;
+
+(a)javax.persistence.Entity
+public class Document {
+
+ @GeneratedValue @javax.persistence.Id
+ protected Long documentId;
+
+ @ManyToOne
+ protected Person documentOwner;
+
+ @javax.persistence.OneToMany
+ protected Set<Person> persons;
+
+ protected Byte docType = 0;
+
+ public Long getDocumentId() {
+ return documentId;
+ }
+
+ public void setDocumentId(Long documentId) {
+ this.documentId = documentId;
+ }
+
+ public Person getDocumentOwner() {
+ return documentOwner;
+ }
+
+ public void setDocumentOwner(Person documentOwner) {
+ this.documentOwner = documentOwner;
+ }
+
+ public Set<Person> getPersons() {
+ return persons;
+ }
+
+ public void setPersons(Set<Person> persons) {
+ this.persons = persons;
+ }
+
+ public Byte getDocType() {
+ return docType;
+ }
+
+ protected void setDocType(Byte docType) {
+ this.docType = docType;
+ }
+
+}
Property changes on:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Document.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Foto.java
(from rev 11954,
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/Foto.java)
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Foto.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Foto.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package test.annotated.fields;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToOne;
+
+@Entity
+public class Foto {
+
+ protected Long fid;
+
+ @Id @GeneratedValue
+ protected Short id;
+
+ @OneToOne(mappedBy="foto")
+ protected Person person;
+
+ protected Short width_IDtest;
+
+ protected Short height_testID;
+
+ public Foto() {
+ }
+
+ public Long getFid() {
+ return fid;
+ }
+
+ public void setFid(Long fid) {
+ this.fid = fid;
+ }
+
+ public Short getId() {
+ return id;
+ }
+
+ public void setId(Short id) {
+ this.id = id;
+ }
+
+ public Person getPerson() {
+ return person;
+ }
+
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+
+ public Short getWidth_IDtest() {
+ return width_IDtest;
+ }
+
+ public void setWidth_IDtest(Short width_IDtest) {
+ this.width_IDtest = width_IDtest;
+ }
+
+ public Short getHeight_testID() {
+ return height_testID;
+ }
+
+ public void setHeight_testID(Short height_testID) {
+ this.height_testID = height_testID;
+ }
+
+}
Property changes on:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Foto.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Passport.java
(from rev 10877,
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/Passport.java)
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Passport.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Passport.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package test.annotated.fields;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Passport extends Document {
+
+ protected Long fakeId;
+
+ public Passport() {
+ setDocType((byte)1);
+ }
+
+}
Property changes on:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Passport.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Person.java
(from rev 11954,
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/Person.java)
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Person.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Person.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package test.annotated.fields;
+
+import java.util.Set;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
+
+@Entity
+public class Person {
+
+ @Id @GeneratedValue
+ protected Long personId;
+
+ @OneToMany(mappedBy="documentOwner")
+ protected Set<Document> documents;
+
+ @OneToOne(mappedBy="person")
+ protected Foto foto;
+
+ protected Set someTestSet;
+
+ public Long getPersonId() {
+ return personId;
+ }
+
+ public void setPersonId(Long personId) {
+ this.personId = personId;
+ }
+
+ public Set<Document> getDocuments() {
+ return documents;
+ }
+
+ public void setDocuments(Set<Document> documents) {
+ this.documents = documents;
+ }
+
+ public Foto getFoto() {
+ return foto;
+ }
+
+ public void setFoto(Foto foto) {
+ this.foto = foto;
+ }
+
+}
Property changes on:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Person.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Staff.java
(from rev 10877,
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/Staff.java)
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Staff.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Staff.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package test.annotated.fields;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Staff extends Document {
+
+ protected Long code;
+
+ protected Staff() {
+ }
+
+ public Staff(long code) {
+ this.code = code;
+ setDocType((byte)2);
+ }
+}
Property changes on:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/fields/Staff.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Document.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Document.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Document.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package test.annotated.getters;
+
+import java.util.Set;
+
+import javax.persistence.GeneratedValue;
+import javax.persistence.ManyToOne;
+
+(a)javax.persistence.Entity
+public class Document {
+
+ private Long documentId;
+
+ private Person documentOwner;
+
+ private Set<Person> persons;
+
+ private Byte docType = 0;
+
+ @GeneratedValue @javax.persistence.Id
+ public Long getDocumentId() {
+ return documentId;
+ }
+
+ public void setDocumentId(Long documentId) {
+ this.documentId = documentId;
+ }
+
+ @ManyToOne
+ public Person getDocumentOwner() {
+ return documentOwner;
+ }
+
+ public void setDocumentOwner(Person documentOwner) {
+ this.documentOwner = documentOwner;
+ }
+
+ @javax.persistence.OneToMany
+ public Set<Person> getPersons() {
+ return persons;
+ }
+
+ public void setPersons(Set<Person> persons) {
+ this.persons = persons;
+ }
+
+ public Byte getDocType() {
+ return docType;
+ }
+
+ protected void setDocType(Byte docType) {
+ this.docType = docType;
+ }
+
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Foto.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Foto.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Foto.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package test.annotated.getters;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToOne;
+
+@Entity
+public class Foto {
+
+ private Long fid;
+
+ private Short id;
+
+ private Person person;
+
+ private Short width_IDtest;
+
+ private Short height_testID;
+
+ public Foto() {
+ }
+
+ public Long getFid() {
+ return fid;
+ }
+
+ public void setFid(Long fid) {
+ this.fid = fid;
+ }
+
+ @Id @GeneratedValue
+ public Short getId() {
+ return id;
+ }
+
+ public void setId(Short id) {
+ this.id = id;
+ }
+
+ @OneToOne(mappedBy="foto")
+ public Person getPerson() {
+ return person;
+ }
+
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+
+ public Short getWidth_IDtest() {
+ return width_IDtest;
+ }
+
+ public void setWidth_IDtest(Short width_IDtest) {
+ this.width_IDtest = width_IDtest;
+ }
+
+ public Short getHeight_testID() {
+ return height_testID;
+ }
+
+ public void setHeight_testID(Short height_testID) {
+ this.height_testID = height_testID;
+ }
+
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Passport.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Passport.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Passport.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package test.annotated.getters;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Passport extends Document {
+
+ private Long fakeId;
+
+ public Passport() {
+ setDocType((byte)1);
+ }
+
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Person.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Person.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Person.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package test.annotated.getters;
+
+import java.util.Set;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
+
+@Entity
+public class Person {
+
+ private Long personId;
+
+ private Set<Document> documents;
+
+ private Foto foto;
+
+ private Set someTestSet;
+
+ @Id @GeneratedValue
+ public Long getPersonId() {
+ return personId;
+ }
+
+ public void setPersonId(Long personId) {
+ this.personId = personId;
+ }
+
+ @OneToMany(mappedBy="documentOwner")
+ public Set<Document> getDocuments() {
+ return documents;
+ }
+
+ public void setDocuments(Set<Document> documents) {
+ this.documents = documents;
+ }
+
+ @OneToOne(mappedBy="person")
+ public Foto getFoto() {
+ return foto;
+ }
+
+ public void setFoto(Foto foto) {
+ this.foto = foto;
+ }
+
+}
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Staff.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Staff.java
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/specimen/test/annotated/getters/Staff.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package test.annotated.getters;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Staff extends Document {
+
+ private Long code;
+
+ protected Staff() {
+ }
+
+ public Staff(long code) {
+ this.code = code;
+ setDocType((byte)2);
+ }
+}
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/JPAMapTest.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/JPAMapTest.java 2008-12-16
13:53:24 UTC (rev 12622)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/JPAMapTest.java 2008-12-16
13:55:21 UTC (rev 12623)
@@ -38,6 +38,7 @@
import org.hibernate.eclipse.jdt.ui.internal.jpa.collect.AllEntitiesInfoCollector;
import org.hibernate.eclipse.jdt.ui.internal.jpa.common.Utils;
import org.hibernate.eclipse.jdt.ui.internal.jpa.process.AllEntitiesProcessor;
+import org.hibernate.eclipse.jdt.ui.internal.jpa.process.AnnotStyle;
import junit.framework.TestCase;
@@ -52,6 +53,8 @@
public static String RESOURCE_PATH = "res/project/"; //$NON-NLS-1$
public static String SPECIMEN_PATH = "res/specimen/"; //$NON-NLS-1$
public static String TESTRESOURCE_PATH = "testresources"; //$NON-NLS-1$
+ public static String TEST_FIELDS = "fields"; //$NON-NLS-1$
+ public static String TEST_GETTERS = "getters"; //$NON-NLS-1$
static {
RESOURCE_PATH.replaceAll("//", File.separator); //$NON-NLS-1$
SPECIMEN_PATH.replaceAll("//", File.separator); //$NON-NLS-1$
@@ -62,19 +65,9 @@
protected IProject project;
protected IJavaProject javaProject;
+ protected String testSelection;
protected void setUp() throws Exception {
- try {
- createTestProject();
- } catch (JavaModelException e1) {
- fail(e1.getMessage());
- } catch (CoreException e1) {
- fail(e1.getMessage());
- } catch (IOException e1) {
- fail(e1.getMessage());
- }
- assertNotNull(project);
- assertNotNull(javaProject);
}
protected void tearDown() throws Exception {
@@ -89,7 +82,31 @@
assertNull(javaProject);
}
- public void testTransformer() {
+ public void testTransformerFields() {
+ testSelection = TEST_FIELDS;
+ processor.setAnnotationStyle(AnnotStyle.FIELDS);
+ startTestTransformer();
+ }
+
+ public void testTransformerGetters() {
+ testSelection = TEST_GETTERS;
+ processor.setAnnotationStyle(AnnotStyle.GETTERS);
+ startTestTransformer();
+ }
+
+ public void startTestTransformer() {
+ try {
+ createTestProject();
+ } catch (JavaModelException e1) {
+ fail(e1.getMessage());
+ } catch (CoreException e1) {
+ fail(e1.getMessage());
+ } catch (IOException e1) {
+ fail(e1.getMessage());
+ }
+ assertNotNull(project);
+ assertNotNull(javaProject);
+ //
javaProject = ProjectUtils.findJavaProject(PROJECT_NAME);
assertNotNull(javaProject);
try {
@@ -97,14 +114,16 @@
} catch (CoreException e) {
fail(e.getMessage());
}
+ //ICompilationUnit icu = Utils.findCompilationUnit(javaProject,
+ // "test.annotated." + testSelection + ".Document"); //$NON-NLS-1$
//$NON-NLS-2$
ICompilationUnit icu = Utils.findCompilationUnit(javaProject,
- "test.annotated.Passport"); //$NON-NLS-1$
+ "test.annotated." + testSelection + ".Passport"); //$NON-NLS-1$
//$NON-NLS-2$
ICompilationUnit icu2 = Utils.findCompilationUnit(javaProject,
- "test.annotated.Staff"); //$NON-NLS-1$
+ "test.annotated." + testSelection + ".Staff"); //$NON-NLS-1$
//$NON-NLS-2$
//ICompilationUnit icu = Utils.findCompilationUnit(javaProject,
- // "test.annotated.Foto"); //$NON-NLS-1$
+ // "test.annotated." + testSelection + ".Foto"); //$NON-NLS-1$
//$NON-NLS-2$
//ICompilationUnit icu2 = Utils.findCompilationUnit(javaProject,
- // "test.annotated.Person"); //$NON-NLS-1$
+ // "test.annotated." + testSelection + ".Person"); //$NON-NLS-1$
//$NON-NLS-2$
assertNotNull(icu);
assertNotNull(icu2);
collector.initCollector(javaProject);
@@ -136,7 +155,8 @@
protected ASTNode getGenerated(String strName) {
ICompilationUnit icu = Utils.findCompilationUnit(javaProject,
- "test.annotated." + strName); //$NON-NLS-1$
+ "test.annotated." + testSelection + //$NON-NLS-1$
+ "." + strName); //$NON-NLS-1$
ASTParser parser = ASTParser.newParser(AST.JLS3);
parser.setSource(icu);
ASTNode astNode = parser.createAST(null);
@@ -145,7 +165,10 @@
protected ASTNode getSpecimen(String strName) throws IOException {
File resourceFile = getResourceItem(SPECIMEN_PATH
- + "test" + File.separator + "annotated" + File.separator +
strName + ".java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + "test" + File.separator //$NON-NLS-1$
+ + "annotated" + File.separator //$NON-NLS-1$
+ + testSelection + File.separator + strName
+ + ".java"); //$NON-NLS-1$
if (!resourceFile.exists()) {
return null;
}