Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2011-08-01 15:10:18 +0000
committerkmoore2011-08-01 15:10:18 +0000
commitc7a08672e168714087c16ed7123975c92c21d7d9 (patch)
treec9cbd3a49133c49f67cd31001507066e9c0a595f /jpa_diagram_editor/plugins
parent188fe8a8a0f3f5e21db478434744dd8756739a4f (diff)
downloadwebtools.dali-c7a08672e168714087c16ed7123975c92c21d7d9.tar.gz
webtools.dali-c7a08672e168714087c16ed7123975c92c21d7d9.tar.xz
webtools.dali-c7a08672e168714087c16ed7123975c92c21d7d9.zip
consolidation of the java resource model for JAXB and JPA. Changing API to Iterables instead of Iterators
Diffstat (limited to 'jpa_diagram_editor/plugins')
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddAllEntitiesFeature.java9
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddJPAEntityFeature.java14
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateJPAEntityFeature.java8
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DirectEditJPAEntityFeature.java11
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalRemoveAttributeFeature.java10
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorAttributeTypeFeature.java14
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorEntityFeature.java31
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorDiagramTypeProvider.java18
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/EntityChangeListener.java6
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java38
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPASolver.java29
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java184
12 files changed, 172 insertions, 200 deletions
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddAllEntitiesFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddAllEntitiesFeature.java
index 1578345903..174d5df0d3 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddAllEntitiesFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddAllEntitiesFeature.java
@@ -1,7 +1,7 @@
/*******************************************************************************
* <copyright>
*
- * Copyright (c) 2005, 2010 SAP AG.
+ * Copyright (c) 2005, 2011 SAP AG.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -57,10 +57,12 @@ public class AddAllEntitiesFeature extends AbstractCustomFeature implements IAdd
super(fp);
}
+ @Override
public boolean isAvailable(IContext ctx) {
return true;
}
+ @Override
public boolean canExecute(ICustomContext context) {
return true;
}
@@ -68,7 +70,7 @@ public class AddAllEntitiesFeature extends AbstractCustomFeature implements IAdd
public void execute(ICustomContext context) {
Diagram d = getDiagram();
JpaProject project = getTargetJPAProject();
- PersistenceUnit unit = project.getRootContextNode().getPersistenceXml().getPersistence().persistenceUnits().next();
+ PersistenceUnit unit = project.getRootContextNode().getPersistenceXml().getPersistence().getPersistenceUnits().iterator().next();
Point lowestRightestPointOfExistingDiagram = getLowestRightestPoint(d);
@@ -87,8 +89,7 @@ public class AddAllEntitiesFeature extends AbstractCustomFeature implements IAdd
lowerEdges[0] = lowestRightestPointOfExistingDiagram.y + ((lowestRightestPointOfExistingDiagram.y == 0) ? DIST_FROM_EDGE_V : DIST_V);
- for (Iterator<ClassRef> classRefs = unit.classRefs(); classRefs.hasNext();) {
- ClassRef classRef = classRefs.next();
+ for (ClassRef classRef : unit.getClassRefs()) {
if (classRef.getJavaPersistentType() != null) { // null if
JavaPersistentType jpt = classRef.getJavaPersistentType();
if (jpt.getMappingKey() == MappingKeys.ENTITY_TYPE_MAPPING_KEY) {
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddJPAEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddJPAEntityFeature.java
index f296c865e8..55e69113e6 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddJPAEntityFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddJPAEntityFeature.java
@@ -1,7 +1,7 @@
/*******************************************************************************
* <copyright>
*
- * Copyright (c) 2005, 2010 SAP AG.
+ * Copyright (c) 2005, 2011 SAP AG.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -19,8 +19,6 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.ListIterator;
-
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.IAddContext;
import org.eclipse.graphiti.features.context.ICreateContext;
@@ -118,6 +116,7 @@ public class AddJPAEntityFeature extends AbstractAddShapeFeature {
return (pictograms == null) || (pictograms.length == 0);
}
+ @Override
public IJPAEditorFeatureProvider getFeatureProvider() {
return (IJPAEditorFeatureProvider) super.getFeatureProvider();
}
@@ -309,10 +308,7 @@ public class AddJPAEntityFeature extends AbstractAddShapeFeature {
String attributeAnnotations) {
List<JavaPersistentAttribute> attributes = new ArrayList<JavaPersistentAttribute>();
- ListIterator<JavaPersistentAttribute> attributesIterator = jpt
- .attributes();
- while (attributesIterator.hasNext()) {
- JavaPersistentAttribute attribute = attributesIterator.next();
+ for (JavaPersistentAttribute attribute : jpt.getAttributes()) {
HashSet<String> annotations = JpaArtifactFactory.instance().getAnnotationNames(attribute);
if (annotations.contains(attributeAnnotations)) {
attributes.add(attribute);
@@ -324,9 +320,7 @@ public class AddJPAEntityFeature extends AbstractAddShapeFeature {
private void addBasicAttributes(ContainerShape containerShape, JavaPersistentType jpt){
List<JavaPersistentAttribute> attributes = new ArrayList<JavaPersistentAttribute>();
- ListIterator<JavaPersistentAttribute> attributesIterator = jpt.attributes();
- while(attributesIterator.hasNext()){
- JavaPersistentAttribute attribute = attributesIterator.next();
+ for (JavaPersistentAttribute attribute : jpt.getAttributes()){
HashSet<String> annotations = JpaArtifactFactory.instance().getAnnotationNames(attribute);
if(!(annotations.contains(JPAEditorConstants.ANNOTATION_ID))&& !(annotations.contains(JPAEditorConstants.ANNOTATION_EMBEDDED_ID)) && !(annotations.contains(JPAEditorConstants.ANNOTATION_MANY_TO_MANY)) &&
!(annotations.contains(JPAEditorConstants.ANNOTATION_MANY_TO_ONE)) && !(annotations.contains(JPAEditorConstants.ANNOTATION_ONE_TO_MANY))&&
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateJPAEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateJPAEntityFeature.java
index 8150e71677..af13b1d949 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateJPAEntityFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateJPAEntityFeature.java
@@ -1,7 +1,7 @@
/*******************************************************************************
* <copyright>
*
- * Copyright (c) 2005, 2010 SAP AG.
+ * Copyright (c) 2005, 2011 SAP AG.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -145,7 +145,7 @@ public class CreateJPAEntityFeature extends AbstractCreateFeature {
JPADiagramEditorPlugin.logError("Cannot refresh the project", e1); //$NON-NLS-1$
}
- ListIterator<PersistenceUnit> lit = jpaProject.getRootContextNode().getPersistenceXml().getPersistence().persistenceUnits();
+ ListIterator<PersistenceUnit> lit = jpaProject.getRootContextNode().getPersistenceXml().getPersistence().getPersistenceUnits().iterator();
PersistenceUnit pu = lit.next();
JavaPersistentType jpt = (JavaPersistentType)pu.getPersistentType(entityName);
@@ -172,10 +172,12 @@ public class CreateJPAEntityFeature extends AbstractCreateFeature {
return new Object[] {};
}
- public String getCreateImageId() {
+ @Override
+ public String getCreateImageId() {
return JPAEditorImageProvider.ADD_JPA_ENTITY;
}
+ @Override
public IJPAEditorFeatureProvider getFeatureProvider() {
return (IJPAEditorFeatureProvider)super.getFeatureProvider();
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DirectEditJPAEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DirectEditJPAEntityFeature.java
index 932838d4dc..cd6e455357 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DirectEditJPAEntityFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DirectEditJPAEntityFeature.java
@@ -1,7 +1,7 @@
/*******************************************************************************
* <copyright>
*
- * Copyright (c) 2005, 2010 SAP AG.
+ * Copyright (c) 2005, 2011 SAP AG.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -78,8 +78,7 @@ public class DirectEditJPAEntityFeature extends AbstractDirectEditingFeature {
String packageName = Signature.getQualifier(jpt.getName());
PersistenceUnit unit = jpt.getPersistenceUnit();
- for(Iterator<ClassRef> classRefs = unit.classRefs(); classRefs.hasNext();){
- ClassRef classRef = classRefs.next();
+ for(ClassRef classRef : unit.getClassRefs()) {
if(classRef.getClassName().equals(packageName + Signature.C_DOT + value) && !(JPAEditorUtil.getText(jpt).equals(value))){
return MessageFormat.format(JPAEditorMessages.DirectEditJPAEntityFeature_duplicateEntityName, packageName+value);
@@ -101,6 +100,7 @@ public class DirectEditJPAEntityFeature extends AbstractDirectEditingFeature {
return null;
}
+ @Override
public void setValue(final String value, IDirectEditingContext context) {
PictogramElement pe = context.getPictogramElement();
ContainerShape csh = ((Shape)pe).getContainer();
@@ -127,6 +127,7 @@ public class DirectEditJPAEntityFeature extends AbstractDirectEditingFeature {
TransactionalEditingDomain ted = TransactionUtil.getEditingDomain(alg);
ted.getCommandStack().execute(new RecordingCommand(ted) {
+ @Override
protected void doExecute() {
((Text) alg).setValue(value);
}
@@ -150,13 +151,15 @@ public class DirectEditJPAEntityFeature extends AbstractDirectEditingFeature {
final String attName = newAtName;
TransactionalEditingDomain tedit = TransactionUtil.getEditingDomain(algo);
tedit.getCommandStack().execute(new RecordingCommand(tedit) {
- protected void doExecute() {
+ @Override
+ protected void doExecute() {
((Text) algo).setValue(attName);
}
});
}
}
+ @Override
public IJPAEditorFeatureProvider getFeatureProvider() {
return (IJPAEditorFeatureProvider)super.getFeatureProvider();
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalRemoveAttributeFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalRemoveAttributeFeature.java
index 96308fdfe2..c8d8cdffb8 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalRemoveAttributeFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalRemoveAttributeFeature.java
@@ -1,7 +1,7 @@
/*******************************************************************************
* <copyright>
*
- * Copyright (c) 2005, 2010 SAP AG.
+ * Copyright (c) 2005, 2011 SAP AG.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -19,8 +19,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
-import java.util.ListIterator;
-
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
@@ -56,6 +54,7 @@ class GraphicalRemoveAttributeFeature extends AbstractCustomFeature {
if (ted == null)
return;
ted.getCommandStack().execute(new RecordingCommand(ted) {
+ @Override
protected void doExecute() {
Shape sh = (Shape) pe;
Object bo = getFeatureProvider().getBusinessObjectForPictogramElement(sh);
@@ -106,9 +105,7 @@ class GraphicalRemoveAttributeFeature extends AbstractCustomFeature {
updateFeature.addSeparatorsToShape(relationShape);
updateFeature.addSeparatorsToShape(basicShape);
- ListIterator<JavaPersistentAttribute> attributeIter = javaPersistentType.attributes();
- while (attributeIter.hasNext()) {
- JavaPersistentAttribute attribute = attributeIter.next();
+ for (JavaPersistentAttribute attribute : javaPersistentType.getAttributes()) {
updateFeature.addAttributes(entityShape, attribute);
getFeatureProvider().renewAttributeJoiningStrategyPropertyListener(attribute);
@@ -135,6 +132,7 @@ class GraphicalRemoveAttributeFeature extends AbstractCustomFeature {
compartmentShape.getGraphicsAlgorithm().setHeight(0);
}
+ @Override
public IJPAEditorFeatureProvider getFeatureProvider() {
return (IJPAEditorFeatureProvider) super.getFeatureProvider();
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorAttributeTypeFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorAttributeTypeFeature.java
index b314f57cb8..c5c4387291 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorAttributeTypeFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorAttributeTypeFeature.java
@@ -1,7 +1,7 @@
/*******************************************************************************
* <copyright>
*
- * Copyright (c) 2005, 2010 SAP AG.
+ * Copyright (c) 2005, 2011 SAP AG.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -17,7 +17,6 @@ package org.eclipse.jpt.jpadiagrameditor.ui.internal.feature;
import java.text.MessageFormat;
import java.util.List;
-
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.ICustomContext;
import org.eclipse.graphiti.features.custom.AbstractCustomFeature;
@@ -25,10 +24,11 @@ import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement.Kind;
import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.dialog.SelectTypeDialog;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
@@ -46,6 +46,7 @@ public class RefactorAttributeTypeFeature extends AbstractCustomFeature {
super(fp);
}
+ @Override
public boolean canExecute(ICustomContext context) {
return true;
}
@@ -69,9 +70,9 @@ public class RefactorAttributeTypeFeature extends AbstractCustomFeature {
newTypeName = newTypeName.substring(0, newTypeName.indexOf('<')).trim();
getFeatureProvider().addAddIgnore((JavaPersistentType)jpa.getParent(), jpa.getName());
- JavaResourcePersistentAttribute jrpa = jpa.getResourcePersistentAttribute();
- getFeatureProvider().addRemoveIgnore((JavaPersistentType)jpa.getParent(), jrpa.getName());
- boolean isMethodAnnotated = jpa.isProperty();
+ JavaResourceAttribute jra = jpa.getResourceAttribute();
+ getFeatureProvider().addRemoveIgnore((JavaPersistentType)jpa.getParent(), jra.getName());
+ boolean isMethodAnnotated = jra.getKind() == Kind.METHOD;
List<String> annotations = JpaArtifactFactory.instance().getAnnotationStrings(jpa);
JpaArtifactFactory.instance().deleteAttribute((JavaPersistentType)jpa.getParent(), jpa.getName(),
@@ -87,6 +88,7 @@ public class RefactorAttributeTypeFeature extends AbstractCustomFeature {
((Shape)pe).getContainer(), (JavaPersistentType)newAt.getParent());
}
+ @Override
public IJPAEditorFeatureProvider getFeatureProvider() {
return (IJPAEditorFeatureProvider) super.getFeatureProvider();
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorEntityFeature.java
index ff85eb4381..ea7ca502ac 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorEntityFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorEntityFeature.java
@@ -1,7 +1,7 @@
/*******************************************************************************
* <copyright>
*
- * Copyright (c) 2005, 2010 SAP AG.
+ * Copyright (c) 2005, 2011 SAP AG.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -21,7 +21,6 @@ import java.util.Iterator;
import java.util.Set;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
-
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
@@ -41,6 +40,15 @@ import org.eclipse.graphiti.services.Graphiti;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.ui.actions.SelectionDispatchAction;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jpt.common.core.JptResourceModel;
+import org.eclipse.jpt.common.core.resource.java.Annotation;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceCompilationUnit;
+import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
+import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
+import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
+import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
+import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
import org.eclipse.jpt.jpa.core.JpaFile;
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
@@ -48,9 +56,6 @@ import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.resource.java.Annotation;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourceCompilationUnit;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
import org.eclipse.jpt.jpa.core.resource.java.OwnableRelationshipMappingAnnotation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.AddEntityContext;
@@ -59,12 +64,6 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPASolver;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
-import org.eclipse.jpt.common.core.JptResourceModel;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.widgets.Display;
@@ -79,6 +78,7 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature {
super(fp);
}
+ @Override
public boolean isAvailable(IContext context) {
if (!(context instanceof ICustomContext))
return false;
@@ -104,6 +104,7 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature {
return false;
}
+ @Override
public boolean canExecute(ICustomContext context) {
return true;
}
@@ -134,6 +135,7 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature {
TransactionalEditingDomain ted = TransactionUtil.getEditingDomain(pict);
ted.getCommandStack().execute(new RecordingCommand(ted) {
+ @Override
protected void doExecute() {
remapEntity(oldName, pict, pu, rename, lsnr, getFeatureProvider());
}
@@ -157,6 +159,7 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature {
JPASolver.ignoreEvents = false;
TransactionalEditingDomain ted = TransactionUtil.getEditingDomain(pict);
ted.getCommandStack().execute(new RecordingCommand(ted) {
+ @Override
protected void doExecute() {
remapEntity(oldName, pict, pu, true, lsnr, getFeatureProvider());
}
@@ -231,10 +234,12 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature {
+ @Override
protected Diagram getDiagram() {
return getFeatureProvider().getDiagramTypeProvider().getDiagram();
}
+ @Override
public IJPAEditorFeatureProvider getFeatureProvider() {
return (IJPAEditorFeatureProvider)super.getFeatureProvider();
}
@@ -278,8 +283,8 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature {
if (!JavaResourceCompilationUnit.class.isInstance(rm))
return;
JavaResourceCompilationUnit jrcu = (JavaResourceCompilationUnit)rm;
- JavaResourcePersistentType jrpt = jrcu.persistentTypes().next();
- newJptName = jrpt.getQualifiedName();
+ JavaResourceAbstractType jrt = jrcu.getPrimaryType();
+ newJptName = jrt.getQualifiedName();
s.release();
if ((ats == null) || hasNameAnnotation)
return;
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorDiagramTypeProvider.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorDiagramTypeProvider.java
index 440fddc4c8..9e2f47fe41 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorDiagramTypeProvider.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorDiagramTypeProvider.java
@@ -1,7 +1,7 @@
/*******************************************************************************
* <copyright>
*
- * Copyright (c) 2005, 2010 SAP AG.
+ * Copyright (c) 2005, 2011 SAP AG.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -101,16 +101,16 @@ public class JPAEditorDiagramTypeProvider extends AbstractDiagramTypeProvider {
return toolBehaviorProviders;
}
- public JPAEditorFeatureProvider getFeatureProvider() {
+ @Override
+ public JPAEditorFeatureProvider getFeatureProvider() {
return (JPAEditorFeatureProvider)super.getFeatureProvider();
}
public boolean hasToAdd() {
JpaProject project = getTargetJPAProject();
- PersistenceUnit unit = project.getRootContextNode().getPersistenceXml().getPersistence().persistenceUnits().next();
+ PersistenceUnit unit = project.getRootContextNode().getPersistenceXml().getPersistence().getPersistenceUnits().iterator().next();
- for (Iterator<ClassRef> classRefs = unit.classRefs(); classRefs.hasNext();) {
- ClassRef classRef = classRefs.next();
+ for (ClassRef classRef : unit.getClassRefs()) {
if (classRef.getJavaPersistentType() != null) {
JavaPersistentType jpt = classRef.getJavaPersistentType();
if (jpt.getMappingKey() == MappingKeys.ENTITY_TYPE_MAPPING_KEY) {
@@ -124,7 +124,8 @@ public class JPAEditorDiagramTypeProvider extends AbstractDiagramTypeProvider {
}
- public void postInit() {
+ @Override
+ public void postInit() {
final String jptName = getDiagramEditor().getPartProperty(JPAEditorConstants.OPEN_WHOLE_PERSISTENCE_UNIT_EDITOR_PROPERTY);
if (jptName != null) {
boolean hasToAdd = hasToAdd();
@@ -176,6 +177,7 @@ public class JPAEditorDiagramTypeProvider extends AbstractDiagramTypeProvider {
MessageDialog dialog = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
JPAEditorMessages.JPAEditorDiagramTypeProvider_JPADiagramReadOnlyTitle, null, message,
MessageDialog.INFORMATION, new String[] {JPAEditorMessages.BTN_OK, JPAEditorMessages.BTN_CANCEL}, 0) {
+ @Override
protected int getShellStyle() {
return SWT.TITLE | SWT.BORDER
| SWT.APPLICATION_MODAL
@@ -193,6 +195,7 @@ public class JPAEditorDiagramTypeProvider extends AbstractDiagramTypeProvider {
dialog = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
JPAEditorMessages.JPAEditorDiagramTypeProvider_cantMakeDiagramWritableTitle, null, message,
MessageDialog.CANCEL, new String[] {JPAEditorMessages.BTN_OK}, 0) {
+ @Override
protected int getShellStyle() {
return SWT.CLOSE | SWT.TITLE | SWT.BORDER
| SWT.APPLICATION_MODAL
@@ -231,6 +234,7 @@ public class JPAEditorDiagramTypeProvider extends AbstractDiagramTypeProvider {
TransactionalEditingDomain ted = TransactionUtil.getEditingDomain(diagram);
ted.getCommandStack().execute(new RecordingCommand(ted) {
+ @Override
protected void doExecute() {
while (iter.hasNext())
Graphiti.getPeService().deletePictogramElement(iter.next());
@@ -288,6 +292,7 @@ public class JPAEditorDiagramTypeProvider extends AbstractDiagramTypeProvider {
}
}
+ @Override
public JPADiagramEditor getDiagramEditor() {
return (JPADiagramEditor)super.getDiagramEditor();
}
@@ -300,6 +305,7 @@ public class JPAEditorDiagramTypeProvider extends AbstractDiagramTypeProvider {
return !isDisposed;
}
+ @Override
public void dispose() {
super.dispose();
setFeatureProvider(null);
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/EntityChangeListener.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/EntityChangeListener.java
index d52b0a1d97..71e401a6c4 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/EntityChangeListener.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/EntityChangeListener.java
@@ -1,7 +1,7 @@
/*******************************************************************************
* <copyright>
*
- * Copyright (c) 2005, 2010 SAP AG.
+ * Copyright (c) 2005, 2011 SAP AG.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -20,11 +20,11 @@ import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Set;
-
import org.eclipse.graphiti.features.context.impl.RemoveContext;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jpt.common.core.resource.java.Annotation;
import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
import org.eclipse.jpt.jpa.core.context.MappedByRelationship;
import org.eclipse.jpt.jpa.core.context.PersistentType;
@@ -34,7 +34,6 @@ import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.context.java.JavaRelationshipMapping;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaNullTypeMapping;
-import org.eclipse.jpt.jpa.core.resource.java.Annotation;
import org.eclipse.jpt.jpa.core.resource.java.OwnableRelationshipMappingAnnotation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.RemoveAndSaveEntityFeature;
@@ -61,6 +60,7 @@ public class EntityChangeListener extends Thread {
this.featureProvider = featureProvider;
}
+ @Override
public void run() {
UpdateFromModel taskClass = new UpdateFromModel();
while (goOn) {
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java
index ea6266b6dc..080fa8eb73 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java
@@ -1,7 +1,7 @@
/*******************************************************************************
* <copyright>
*
- * Copyright (c) 2005, 2010 SAP AG.
+ * Copyright (c) 2005, 2011 SAP AG.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -28,7 +28,6 @@ import java.util.ListIterator;
import java.util.Locale;
import java.util.Properties;
import java.util.Set;
-
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
@@ -65,13 +64,13 @@ import org.eclipse.jdt.ui.actions.FormatAllAction;
import org.eclipse.jdt.ui.actions.OrganizeImportsAction;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute;
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute;
import org.eclipse.jpt.jpa.core.resource.persistence.PersistenceFactory;
import org.eclipse.jpt.jpa.core.resource.persistence.XmlJavaClassRef;
import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistence;
@@ -182,15 +181,15 @@ public class JPAEditorUtil {
public static String getAttributeTypeName(JavaPersistentAttribute at) {
- return getAttributeTypeName(at.getResourcePersistentAttribute());
+ return getAttributeTypeName(at.getResourceAttribute());
}
- public static String getAttributeTypeName(JavaResourcePersistentAttribute at) {
+ public static String getAttributeTypeName(JavaResourceAttribute at) {
return at.getTypeName();
}
- public static List<String> getAttributeTypeTypeNames(JavaResourcePersistentAttribute at) {
- ListIterator<String> tt = at.typeTypeArgumentNames();
+ public static List<String> getAttributeTypeTypeNames(JavaResourceAttribute at) {
+ ListIterator<String> tt = at.getTypeTypeArgumentNames().iterator();
if ((tt == null) || !tt.hasNext())
return null;
LinkedList<String> res = new LinkedList<String>();
@@ -200,13 +199,13 @@ public class JPAEditorUtil {
}
public static String getAttributeTypeNameWithGenerics(JavaPersistentAttribute at) {
- return getAttributeTypeNameWithGenerics(at.getResourcePersistentAttribute());
+ return getAttributeTypeNameWithGenerics(at.getResourceAttribute());
}
- public static String getAttributeTypeNameWithGenerics(JavaResourcePersistentAttribute at) {
+ public static String getAttributeTypeNameWithGenerics(JavaResourceAttribute at) {
StringBuilder res = new StringBuilder(getAttributeTypeName(at));
- ListIterator<String> it = at.typeTypeArgumentNames();
+ ListIterator<String> it = at.getTypeTypeArgumentNames().iterator();
if ((it != null) && it.hasNext()) {
res.append('<');
res.append(createCommaSeparatedListOfFullTypeNames(it));
@@ -821,6 +820,7 @@ public class JPAEditorUtil {
final boolean selfOnly) {
TransactionalEditingDomain ted = TransactionUtil.getEditingDomain(cs);
ted.getCommandStack().execute(new RecordingCommand(ted) {
+ @Override
protected void doExecute() {
List<Anchor> anchorsFrom = getAnchors(cs);
for (Anchor anchorFrom : anchorsFrom) {
@@ -963,8 +963,8 @@ public class JPAEditorUtil {
int TXT_HEIGHT = 8;
double location = dcr.getLocation();
RelEndDir relEndDir = (location < 0.5) ?
- JPAEditorUtil.getConnectionStartDir((FreeFormConnection)c) :
- JPAEditorUtil.getConnectionEndDir((FreeFormConnection)c);
+ JPAEditorUtil.getConnectionStartDir(c) :
+ JPAEditorUtil.getConnectionEndDir(c);
Text txt = (Text)dcr.getGraphicsAlgorithm();
int TXT_WIDTH = txt.getValue().length() * 6;
boolean isCardinality = JPAEditorConstants.CARDINALITY_LABELS.contains(txt.getValue());
@@ -1339,11 +1339,9 @@ public class JPAEditorUtil {
static private HashSet<String> getEntityNames(JpaProject jpaProject) {
HashSet<String> names = new HashSet<String>();
ListIterator<PersistenceUnit> lit = jpaProject.getRootContextNode().getPersistenceXml().
- getPersistence().persistenceUnits();
+ getPersistence().getPersistenceUnits().iterator();
PersistenceUnit pu = lit.next();
- Iterator<ClassRef> li = pu.classRefs();
- while(li.hasNext()) {
- ClassRef cf = li.next();
+ for (ClassRef cf : pu.getClassRefs()) {
names.add(cf.getClassName());
}
return names;
@@ -1352,11 +1350,9 @@ public class JPAEditorUtil {
static private HashSet<String> getEntitySimpleNames(JpaProject jpaProject) {
HashSet<String> names = new HashSet<String>();
ListIterator<PersistenceUnit> lit = jpaProject.getRootContextNode().getPersistenceXml().
- getPersistence().persistenceUnits();
- PersistenceUnit pu = lit.next();
- Iterator<ClassRef> li = pu.classRefs();
- while(li.hasNext()) {
- ClassRef cf = li.next();
+ getPersistence().getPersistenceUnits().iterator();
+ PersistenceUnit pu = lit.next();
+ for (ClassRef cf : pu.getClassRefs()) {
names.add(JPAEditorUtil.returnSimpleName(cf.getClassName()).toLowerCase(Locale.ENGLISH));
}
return names;
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPASolver.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPASolver.java
index ff823ea38b..bb5afb2e22 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPASolver.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPASolver.java
@@ -1,7 +1,7 @@
/*******************************************************************************
* <copyright>
*
- * Copyright (c) 2005, 2010 SAP AG.
+ * Copyright (c) 2005, 2011 SAP AG.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -23,10 +23,8 @@ import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
-import java.util.ListIterator;
import java.util.Set;
import java.util.WeakHashMap;
-
import org.eclipse.core.internal.resources.File;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarkerDelta;
@@ -65,6 +63,8 @@ import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.core.PackageFragmentRoot;
import org.eclipse.jpt.common.core.JptResourceModel;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceCompilationUnit;
import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
import org.eclipse.jpt.common.utility.model.Model;
import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
@@ -103,8 +103,6 @@ import org.eclipse.jpt.jpa.core.context.java.JavaOneToOneMapping;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourceCompilationUnit;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditor;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.facade.EclipseFacade;
@@ -342,9 +340,7 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
Object o = keyToBO.remove(key);
if (o instanceof JavaPersistentType) {
JavaPersistentType jpt = (JavaPersistentType) o;
- ListIterator<JavaPersistentAttribute> atts = jpt.attributes();
- while (atts.hasNext()) {
- JavaPersistentAttribute at = atts.next();
+ for (JavaPersistentAttribute at : jpt.getAttributes()) {
String k = getKeyForBusinessObject(at);
remove(k);
}
@@ -388,10 +384,8 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
}
public Set<IRelation> getRelationsRelatedToEntity(JavaPersistentType jpt) {
- ListIterator<JavaPersistentAttribute> it = jpt.attributes();
HashSet<IRelation> res = new HashSet<IRelation>();
- while (it.hasNext()) {
- JavaPersistentAttribute at = it.next();
+ for (JavaPersistentAttribute at : jpt.getAttributes()) {
IRelation rel = getRelationRelatedToAttribute(at);
if (rel != null)
res.add(rel);
@@ -1034,8 +1028,8 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
if (!JavaResourceCompilationUnit.class.isInstance(jrm))
continue;
JavaResourceCompilationUnit jrcu = (JavaResourceCompilationUnit)jrm;
- JavaResourcePersistentType jrpt = jrcu.persistentTypes().next();
- String name = jrpt.getQualifiedName();
+ JavaResourceAbstractType jrat = jrcu.getPrimaryType();
+ String name = jrat.getQualifiedName();
JpaProject jpaProject = jpaFile.getJpaProject();
PersistenceUnit pu = JpaArtifactFactory.instance().getPersistenceUnit(jpaProject);
@@ -1051,6 +1045,7 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
public void run() {
TransactionalEditingDomain ted = TransactionUtil.getEditingDomain(cs);
ted.getCommandStack().execute(new RecordingCommand(ted) {
+ @Override
protected void doExecute() {
ft.remove(ctx);
}
@@ -1103,6 +1098,7 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
public void run() {
TransactionalEditingDomain ted = featureProvider.getTransactionalEditingDomain();
ted.getCommandStack().execute(new RecordingCommand(ted) {
+ @Override
protected void doExecute() {
JavaPersistentType jpt = je.getPersistentType();
updateJPTName(jpt);
@@ -1249,6 +1245,7 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
TransactionalEditingDomain ted = TransactionUtil.getEditingDomain(cd);
ted.getCommandStack().execute(new RecordingCommand(ted) {
+ @Override
protected void doExecute() {
Text txt = (Text)cd.getGraphicsAlgorithm();
txt.setValue(newLabelText);
@@ -1305,7 +1302,7 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
}
shapesToRemove.add(atShape);
- IRelation rel = ((IJPAEditorFeatureProvider) featureProvider).getRelationRelatedToAttribute(at);
+ IRelation rel = featureProvider.getRelationRelatedToAttribute(at);
if (rel == null)
continue;
Connection conn = (Connection) featureProvider.getPictogramElementForBusinessObject(rel);
@@ -1324,7 +1321,7 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
ft.remove(ctx);
}
Collection<IRelation> rels = JpaArtifactFactory.instance().produceAllRelations(
- (JavaPersistentType) event.getSource(), (IJPAEditorFeatureProvider) featureProvider);
+ (JavaPersistentType) event.getSource(), featureProvider);
Iterator<IRelation> iter = rels.iterator();
while (iter.hasNext()) {
IRelation rel = iter.next();
@@ -1405,7 +1402,7 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
public void run() {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- if ((ModelIntegrationUtil.getProjectByDiagram(diagram.getName()).getProject()).equals((IProject)resource)) {
+ if ((ModelIntegrationUtil.getProjectByDiagram(diagram.getName()).getProject()).equals(resource)) {
page.closeEditor(diagramBySelectedProject, false);
}
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java
index 230628b08b..3a9e40eabd 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java
@@ -1,7 +1,7 @@
/*******************************************************************************
* <copyright>
*
- * Copyright (c) 2005, 2010 SAP AG.
+ * Copyright (c) 2005, 2011 SAP AG.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -27,7 +27,6 @@ import java.util.ListIterator;
import java.util.Locale;
import java.util.Properties;
import java.util.Set;
-
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -49,7 +48,15 @@ import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.ui.refactoring.RenameSupport;
import org.eclipse.jpt.common.core.JptResourceModel;
+import org.eclipse.jpt.common.core.resource.java.Annotation;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceCompilationUnit;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.common.core.resource.java.NestableAnnotation;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement.Kind;
import org.eclipse.jpt.common.utility.internal.iterables.ArrayListIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.SubListIterableWrapper;
import org.eclipse.jpt.jpa.core.JpaFile;
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
@@ -69,22 +76,14 @@ import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.context.java.JavaTypeMapping;
import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.resource.java.Annotation;
import org.eclipse.jpt.jpa.core.resource.java.AttributeOverrideAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.AttributeOverridesAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.ColumnAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.EmbeddedIdAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.IdAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.IdClassAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourceCompilationUnit;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
import org.eclipse.jpt.jpa.core.resource.java.JoinColumnAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.JoinColumnsAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.ManyToManyAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.MapKeyAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.NestableAttributeOverrideAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.NestableJoinColumnAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.OneToManyAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.OneToOneAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.OwnableRelationshipMappingAnnotation;
@@ -156,7 +155,7 @@ public class JpaArtifactFactory {
JavaPersistentAttribute attr = (JavaPersistentAttribute) ownerJPT
.resolveAttribute(ownerAttibute.getName());
- attr.getResourcePersistentAttribute().setPrimaryAnnotation("javax.persistence.OneToOne", new ArrayListIterable<String>()); //$NON-NLS-1$
+ attr.getResourceAttribute().setPrimaryAnnotation("javax.persistence.OneToOne", new ArrayListIterable<String>()); //$NON-NLS-1$
if (direction == JPAEditorConstants.RELATION_TYPE_BIDIRECTIONAL) {
JpaArtifactFactory.instance().refreshEntityModel(null, referencedJPT);
JavaPersistentAttribute attr2 = (JavaPersistentAttribute) referencedJPT.resolveAttribute(referencedAttribute.getName());
@@ -234,7 +233,7 @@ public class JpaArtifactFactory {
}
if (isMap)
- singleSideAttibute.getResourcePersistentAttribute().addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ singleSideAttibute.getResourceAttribute().addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
if (direction == JPAEditorConstants.RELATION_TYPE_BIDIRECTIONAL) {
if(manySideJPT.getAttributeNamed(manySideAttribute.getName()) == null){
refreshEntityModel(fp, manySideJPT);
@@ -262,23 +261,20 @@ public class JpaArtifactFactory {
if (ids.length == 1) {
if (isSimpleId(ids[0])) {
JoinColumnAnnotation an = (JoinColumnAnnotation) jpa
- .getResourcePersistentAttribute().addAnnotation(
+ .getResourceAttribute().addAnnotation(0,
JoinColumnAnnotation.ANNOTATION_NAME);
String idColName = getColumnName(ids[0]);
an.setName(tableName + "_" + idColName); //$NON-NLS-1$
an.setReferencedColumnName(idColName);
} else {
Hashtable<String, String> atNameToColName = getOverriddenColNames(ids[0]);
- JoinColumnsAnnotation an = (JoinColumnsAnnotation) jpa
- .getResourcePersistentAttribute().addAnnotation(
- JoinColumnsAnnotation.ANNOTATION_NAME);
PersistenceUnit pu = getPersistenceUnit(jpt);
String embeddableTypeName = ids[0].getTypeName();
Embeddable emb = pu.getEmbeddable(embeddableTypeName);
Iterator<AttributeMapping> amIt = emb.allAttributeMappings();
while (amIt.hasNext()) {
AttributeMapping am = amIt.next();
- NestableJoinColumnAnnotation jc = an.addNestedAnnotation();
+ JoinColumnAnnotation jc = (JoinColumnAnnotation) jpa.getResourceAttribute().addAnnotation(jpa.getResourceAttribute().getAnnotationsSize(JoinColumnAnnotation.ANNOTATION_NAME), JoinColumnAnnotation.ANNOTATION_NAME);
JavaPersistentAttribute at = (JavaPersistentAttribute) am
.getPersistentAttribute();
String idColName = atNameToColName.get(at.getName());
@@ -289,11 +285,8 @@ public class JpaArtifactFactory {
}
}
} else {
- JoinColumnsAnnotation an = (JoinColumnsAnnotation) jpa
- .getResourcePersistentAttribute().addAnnotation(
- JoinColumnsAnnotation.ANNOTATION_NAME);
for (JavaPersistentAttribute idAt : ids) {
- NestableJoinColumnAnnotation jc = an.addNestedAnnotation();
+ JoinColumnAnnotation jc = (JoinColumnAnnotation) jpa.getResourceAttribute().addAnnotation( jpa.getResourceAttribute().getAnnotationsSize(JoinColumnAnnotation.ANNOTATION_NAME), JoinColumnAnnotation.ANNOTATION_NAME);
String idColName = getColumnName(idAt);
jc.setName(tableName + "_" + idColName); //$NON-NLS-1$
jc.setReferencedColumnName(idColName);
@@ -305,7 +298,7 @@ public class JpaArtifactFactory {
JavaPersistentAttribute embIdAt) {
Hashtable<String, String> res = new Hashtable<String, String>();
AttributeOverrideAnnotation aon = (AttributeOverrideAnnotation) embIdAt
- .getResourcePersistentAttribute().getAnnotation(
+ .getResourceAttribute().getAnnotation(0,
AttributeOverrideAnnotation.ANNOTATION_NAME);
if (aon != null) {
ColumnAnnotation colAn = aon.getColumn();
@@ -317,18 +310,9 @@ public class JpaArtifactFactory {
res.put(aon.getName(), colName);
return res;
}
- AttributeOverridesAnnotation aosn = (AttributeOverridesAnnotation) embIdAt
- .getResourcePersistentAttribute().getAnnotation(
- AttributeOverridesAnnotation.ANNOTATION_NAME);
- if (aosn == null)
- return res;
- Iterable<NestableAttributeOverrideAnnotation> it = aosn
- .getNestedAnnotations();
- if (it == null)
- return res;
- Iterator<NestableAttributeOverrideAnnotation> iter = it.iterator();
- while (iter.hasNext()) {
- NestableAttributeOverrideAnnotation an = iter.next();
+ Iterable<AttributeOverrideAnnotation> it = new SubListIterableWrapper<NestableAnnotation, AttributeOverrideAnnotation>(
+ embIdAt.getResourceAttribute().getAnnotations(AttributeOverrideAnnotation.ANNOTATION_NAME));
+ for (AttributeOverrideAnnotation an : it) {
ColumnAnnotation colAn = an.getColumn();
if (colAn == null)
continue;
@@ -371,7 +355,7 @@ public class JpaArtifactFactory {
return;
a.setMappedBy(manySideAttribute.getName());
if (isMap)
- singleSideAttibute.getResourcePersistentAttribute().addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ singleSideAttibute.getResourceAttribute().addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
}
public void addManyToManyBidirectionalRelation(IFeatureProvider fp, JavaPersistentType jpt1,
@@ -403,7 +387,7 @@ public class JpaArtifactFactory {
resolvedOwnerSideAttribute
.setMappingKey(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
if (isMap)
- resolvedOwnerSideAttribute.getResourcePersistentAttribute().addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ resolvedOwnerSideAttribute.getResourceAttribute().addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
if (direction == JPAEditorConstants.RELATION_TYPE_BIDIRECTIONAL) {
JpaArtifactFactory.instance().refreshEntityModel(null, inverseSideJPT);
@@ -433,7 +417,7 @@ public class JpaArtifactFactory {
return;
a.setMappedBy(ownerSideAttribute.getName());
if (isMap)
- resolvedInverseSideAttribute.getResourcePersistentAttribute().addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ resolvedInverseSideAttribute.getResourceAttribute().addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
}
}
@@ -499,9 +483,7 @@ public class JpaArtifactFactory {
String fullyQualifiedTypeName) {
PersistenceUnit unit = getPersistenceUnit(jpaProject);
- Iterator<ClassRef> it = unit.classRefs();
- while (it.hasNext()) {
- ClassRef ref = it.next();
+ for (ClassRef ref : unit.getClassRefs()) {
JavaPersistentType jpt = ref.getJavaPersistentType();
if ((jpt != null) && jpt.getName().equals(fullyQualifiedTypeName)) {
return ref.getJavaPersistentType();
@@ -518,7 +500,7 @@ public class JpaArtifactFactory {
public String getEntityName(JavaPersistentType jpt) {
if (jpt == null)
return ""; //$NON-NLS-1$
- JavaResourcePersistentType jrpt = convertJPTToJRPT(jpt);
+ JavaResourceType jrpt = convertJPTToJRT(jpt);
if (jrpt == null)
return ""; //$NON-NLS-1$
@@ -534,7 +516,7 @@ public class JpaArtifactFactory {
public boolean hasNameAnnotation(JavaPersistentType jpt) {
if (jpt == null)
return false;
- JavaResourcePersistentType jrpt = convertJPTToJRPT(jpt);
+ JavaResourceType jrpt = convertJPTToJRT(jpt);
if (jrpt == null)
return false;
JavaEntity mapping = (JavaEntity) jpt.getMapping();
@@ -704,7 +686,7 @@ public class JpaArtifactFactory {
}
public void refreshEntityModel(IFeatureProvider fp, JavaPersistentType jpt) {
- if(convertJPTToJRPT(jpt) == null)
+ if(convertJPTToJRT(jpt) == null)
return;
if (fp == null) {
jpt.update();
@@ -949,7 +931,7 @@ public class JpaArtifactFactory {
new String[0]);
if (!getAttributeMethod.exists()) {
JavaPersistentAttribute jpa = jpt.getAttributeNamed(attributeName);
- String typeName = jpa.getResourcePersistentAttribute().getTypeName();
+ String typeName = jpa.getResourceAttribute().getTypeName();
if ("boolean".equals(typeName)) { //$NON-NLS-1$
getterPrefix = "is"; //$NON-NLS-1$
methodName = getterPrefix + attrNameWithCapitalLetter;
@@ -1041,10 +1023,9 @@ public class JpaArtifactFactory {
ICompilationUnit ijl = fp.getCompilationUnit(jpt);
IType type = null;
type = ijl.findPrimaryType();
- Iterator<String> it = jpt.attributeNames();
Set<String> attrNames = new HashSet<String>();
- while (it.hasNext()) {
- attrNames.add(it.next());
+ for (String name : jpt.getAttributeNames()) {
+ attrNames.add(name);
}
String name = null;
for (int i = 1; i < 10000000; i++) {
@@ -1078,13 +1059,12 @@ public class JpaArtifactFactory {
}
public Annotation[] getAnnotations(JavaPersistentAttribute persistentAttribite) {
- JavaResourcePersistentAttribute jrpt = persistentAttribite.getResourcePersistentAttribute();
- Annotation[] res = new Annotation[jrpt.annotationsSize()];
+ JavaResourceAttribute jrpt = persistentAttribite.getResourceAttribute();
+ Annotation[] res = new Annotation[jrpt.getAnnotationsSize()];
//mappingAnnotationsSize() + jrpt.supportingAnnotationsSize()];
- Iterator<Annotation> it = jrpt.annotations();
int c = 0;
- while (it.hasNext()) {
- res[c] = it.next();
+ for (Annotation annotation : jrpt.getAnnotations()) {
+ res[c] = annotation;
c++;
}
/*
@@ -1100,11 +1080,11 @@ public class JpaArtifactFactory {
public HashSet<String> getAnnotationNames(
JavaPersistentAttribute persistentAttribite) {
- JavaResourcePersistentAttribute jrpt = persistentAttribite.getResourcePersistentAttribute();
+ JavaResourceAttribute jrpt = persistentAttribite.getResourceAttribute();
HashSet<String> res = new HashSet<String>();
- Iterator<Annotation> it = jrpt.annotations();
- while (it.hasNext())
- res.add(JPAEditorUtil.returnSimpleName(it.next().getAnnotationName()));
+ for (Annotation annotation : jrpt.getAnnotations()) {
+ res.add(JPAEditorUtil.returnSimpleName(annotation.getAnnotationName()));
+ }
/*
it = jrpt.supportingAnnotations();
while (it.hasNext())
@@ -1117,12 +1097,10 @@ public class JpaArtifactFactory {
JavaPersistentAttribute persistentAttribite) {
JavaPersistentType jpt = (JavaPersistentType)persistentAttribite.getParent();
- CompilationUnit jdtCU = jpt.getResourcePersistentType().getJavaResourceCompilationUnit().buildASTRoot();
- JavaResourcePersistentAttribute jrpt = persistentAttribite.getResourcePersistentAttribute();
+ CompilationUnit jdtCU = jpt.getJavaResourceType().getJavaResourceCompilationUnit().buildASTRoot();
+ JavaResourceAttribute jrpt = persistentAttribite.getResourceAttribute();
List<String> res = new LinkedList<String>();
- Iterator<Annotation> it = jrpt.annotations();
- while (it.hasNext()) {
- Annotation an = it.next();
+ for (Annotation an : jrpt.getAnnotations()) {
org.eclipse.jdt.core.dom.Annotation jdtAn = an.getAstAnnotation(jdtCU);
res.add(jdtAn.toString());
}
@@ -1180,10 +1158,8 @@ public class JpaArtifactFactory {
private Collection<IRelation> produceRelations(
JavaPersistentType newJPT, IJPAEditorFeatureProvider fp) {
- ListIterator<JavaPersistentAttribute> it = newJPT.attributes();
HashSet<IRelation> res = new HashSet<IRelation>();
- while (it.hasNext()) {
- JavaPersistentAttribute at = it.next();
+ for (JavaPersistentAttribute at : newJPT.getAttributes()) {
IRelation rel = produceRelation(at, fp);
if (rel != null)
res.add(rel);
@@ -1207,8 +1183,8 @@ public class JpaArtifactFactory {
JavaPersistentAttribute persistentAttribite,
IJPAEditorFeatureProvider fp) {
- JavaResourcePersistentAttribute jrpa = persistentAttribite
- .getResourcePersistentAttribute();
+ JavaResourceAttribute jrpa = persistentAttribite
+ .getResourceAttribute();
IRelation res = null;
Annotation[] ans = getAnnotations(persistentAttribite);
@@ -1230,15 +1206,13 @@ public class JpaArtifactFactory {
JavaPersistentType jpt2, IJPAEditorFeatureProvider fp) {
Collection<IRelation> resSet = new HashSet<IRelation>();
- ListIterator<JavaPersistentAttribute> it = jpt1.attributes();
IRelation res = null;
- while (it.hasNext()) {
- JavaPersistentAttribute at = it.next();
+ for (JavaPersistentAttribute at : jpt1.getAttributes()) {
IResource r = at.getParent().getResource();
if (!r.exists())
throw new RuntimeException();
try {
- JavaResourcePersistentAttribute jrpa = at.getResourcePersistentAttribute();
+ JavaResourceAttribute jrpa = at.getResourceAttribute();
Annotation[] ans = this.getAnnotations(at);
for (Annotation an : ans) {
String annotationName = JPAEditorUtil.returnSimpleName(an.getAnnotationName());
@@ -1424,10 +1398,10 @@ public class JpaArtifactFactory {
continue;
JavaResourceCompilationUnit jrcu = (JavaResourceCompilationUnit)rm;
//CSN #130859 2010
- if(!jrcu.persistentTypes().hasNext())
+ JavaResourceAbstractType jrt = jrcu.getPrimaryType();
+ if (jrt == null)
continue;
- JavaResourcePersistentType jrpt = jrcu.persistentTypes().next();
- String name = jrpt.getQualifiedName();
+ String name = jrt.getQualifiedName();
JavaPersistentType jpt1 = (JavaPersistentType) pu
.getPersistentType(name);
if (jpt1 == null)
@@ -1448,9 +1422,7 @@ public class JpaArtifactFactory {
JavaPersistentType relJPT) {
Set<JavaPersistentAttribute> res = new HashSet<JavaPersistentAttribute>();
- ListIterator<JavaPersistentAttribute> attIt = relJPT.attributes();
- while (attIt.hasNext()) {
- JavaPersistentAttribute at = attIt.next();
+ for (JavaPersistentAttribute at : relJPT.getAttributes()) {
IResource r = at.getParent().getResource();
if (!r.exists())
throw new RuntimeException();
@@ -1459,7 +1431,7 @@ public class JpaArtifactFactory {
for (Annotation an : ans) {
annotationName = JPAEditorUtil.returnSimpleName(an.getAnnotationName());
if (JPAEditorConstants.RELATION_ANNOTATIONS.contains(annotationName)) {
- String relTypeName = getRelTypeName((RelationshipMappingAnnotation)an, at.getResourcePersistentAttribute());
+ String relTypeName = getRelTypeName((RelationshipMappingAnnotation)an, at.getResourceAttribute());
if (!relTypeName.equals(jpt.getName()))
continue;
res.add(at);
@@ -1506,9 +1478,9 @@ public class JpaArtifactFactory {
PersistenceUnit pu = null;
JavaPersistentAttribute oldAt = jpt.getAttributeNamed(oldName);
fp.addAddIgnore((JavaPersistentType)oldAt.getParent(), newName);
- JavaResourcePersistentAttribute jrpa = oldAt
- .getResourcePersistentAttribute();
- fp.addRemoveIgnore((JavaPersistentType)oldAt.getParent(), jrpa.getName());
+ JavaResourceAttribute jra = oldAt
+ .getResourceAttribute();
+ fp.addRemoveIgnore((JavaPersistentType)oldAt.getParent(), jra.getName());
IRelation rel = fp.getRelationRelatedToAttribute(oldAt);
String inverseJPAName = null;
JavaPersistentType inverseJPT = null;
@@ -1756,18 +1728,16 @@ public class JpaArtifactFactory {
JavaPersistentType jpt = (JavaPersistentType)jpa.getParent();
JpaArtifactFactory.instance().refreshEntityModel(null, jpt);
- ListIterator<JavaPersistentAttribute> attIt = relJPT.attributes();
- while (attIt.hasNext()) {
- JavaPersistentAttribute relEntAt = attIt.next();
+ for (JavaPersistentAttribute relEntAt : relJPT.getAttributes()) {
IResource r = relEntAt.getParent().getResource();
if (!r.exists())
throw new RuntimeException();
- JavaResourcePersistentAttribute relJRPA = relEntAt.getResourcePersistentAttribute();
+ JavaResourceAttribute relJRA = relEntAt.getResourceAttribute();
Annotation[] ans = this.getAnnotations(relEntAt);
for (Annotation an : ans) {
String annotationName = JPAEditorUtil.returnSimpleName(an.getAnnotationName());
if (JPAEditorConstants.RELATION_ANNOTATIONS.contains(annotationName)) {
- String relTypeName = getRelTypeName((RelationshipMappingAnnotation)an, relJRPA);
+ String relTypeName = getRelTypeName((RelationshipMappingAnnotation)an, relJRA);
if (!relTypeName.equals(jpt.getName()))
continue;
JavaAttributeMapping mp = relEntAt.getMapping();
@@ -2074,7 +2044,7 @@ public class JpaArtifactFactory {
this.refreshEntityModel(null, jpt);
PersistentAttribute at = jpt.getAttributeNamed(attributeName);
if (at == null) {
- jpt.getResourcePersistentType().synchronizeWith(jpt.getResourcePersistentType().getJavaResourceCompilationUnit().buildASTRoot());
+ jpt.getJavaResourceType().synchronizeWith(jpt.getJavaResourceType().getJavaResourceCompilationUnit().buildASTRoot());
jpt.update();
}
int c = 0;
@@ -2100,10 +2070,10 @@ public class JpaArtifactFactory {
return exists;
}
- public JavaResourcePersistentType convertJPTToJRPT(JavaPersistentType jpt) {
+ public JavaResourceType convertJPTToJRT(JavaPersistentType jpt) {
if (jpt == null)
return null;
- return jpt.getJpaProject().getJavaResourcePersistentType(jpt.getName());
+ return (JavaResourceType) jpt.getJpaProject().getJavaResourceType(jpt.getName(), Kind.TYPE);
}
public PersistenceUnit getPersistenceUnit(JpaFile jpaFile) {
@@ -2117,7 +2087,7 @@ public class JpaArtifactFactory {
if(project.getRootContextNode().getPersistenceXml() == null)
return null;
return project.getRootContextNode().getPersistenceXml().getPersistence()
- .persistenceUnits().next();
+ .getPersistenceUnits().iterator().next();
}
public PersistenceUnit getPersistenceUnit(JavaPersistentType jpt) {
@@ -2125,11 +2095,11 @@ public class JpaArtifactFactory {
}
public boolean isMethodAnnotated(JavaPersistentAttribute attr) {
- return !attr.getResourcePersistentAttribute().isField();
+ return attr.getResourceAttribute().getKind() == Kind.METHOD;
}
public boolean isMethodAnnotated(JavaPersistentType jpt) {
- ListIterator<JavaPersistentAttribute> li = jpt.attributes();
+ ListIterator<JavaPersistentAttribute> li = jpt.getAttributes().iterator();
if (!li.hasNext())
return false;
return (isMethodAnnotated(li.next()));
@@ -2148,10 +2118,10 @@ public class JpaArtifactFactory {
public String getTableName(JavaPersistentType jpt) {
if (jpt == null)
return null;
- JavaResourcePersistentType jrpt = convertJPTToJRPT(jpt);
- if (jrpt == null)
+ JavaResourceType jrt = convertJPTToJRT(jpt);
+ if (jrt == null)
return null;
- TableAnnotation tan = (TableAnnotation)jrpt.getAnnotation("javax.persistence.Table"); //$NON-NLS-1$
+ TableAnnotation tan = (TableAnnotation)jrt.getAnnotation("javax.persistence.Table"); //$NON-NLS-1$
String tableName = null;
if (tan == null){
tableName = JPAEditorUtil.returnSimpleName(jpt.getName());
@@ -2167,11 +2137,11 @@ public class JpaArtifactFactory {
public void setTableName(JavaPersistentType jpt, String tableName) {
if (jpt == null)
return;
- JavaResourcePersistentType jrpt = convertJPTToJRPT(jpt);
- if (jrpt == null) {
+ JavaResourceType jrt = convertJPTToJRT(jpt);
+ if (jrt == null) {
return;
}
- TableAnnotation ta = (TableAnnotation)jrpt.getAnnotation("javax.persistence.Table"); //$NON-NLS-1$
+ TableAnnotation ta = (TableAnnotation)jrt.getAnnotation("javax.persistence.Table"); //$NON-NLS-1$
if (ta != null)
ta.setName(tableName);
}
@@ -2249,16 +2219,16 @@ public class JpaArtifactFactory {
}
private String getRelTypeName(RelationshipMappingAnnotation an,
- JavaResourcePersistentAttribute jrpa) {
+ JavaResourceAttribute jra) {
String relTypeName = null;
try {
- boolean isMap = jrpa.getTypeName().equals("java.util.Map"); //$NON-NLS-1$
- relTypeName = jrpa.getTypeTypeArgumentName(isMap ? 1 : 0);
+ boolean isMap = jra.getTypeName().equals("java.util.Map"); //$NON-NLS-1$
+ relTypeName = jra.getTypeTypeArgumentName(isMap ? 1 : 0);
} catch (Exception e) {}
if (relTypeName == null)
relTypeName = an.getFullyQualifiedTargetEntityClassName();
if (relTypeName == null)
- relTypeName = JPAEditorUtil.getAttributeTypeName(jrpa);
+ relTypeName = JPAEditorUtil.getAttributeTypeName(jra);
return relTypeName;
}
@@ -2267,7 +2237,7 @@ public class JpaArtifactFactory {
}
public String getIdType(JavaPersistentType jpt) {
- IdClassAnnotation an = (IdClassAnnotation)jpt.getResourcePersistentType().getAnnotation(IdClassAnnotation.ANNOTATION_NAME);
+ IdClassAnnotation an = (IdClassAnnotation)jpt.getJavaResourceType().getAnnotation(IdClassAnnotation.ANNOTATION_NAME);
if (an != null)
return an.getFullyQualifiedClassName();
JavaPersistentAttribute[] ids = getIds(jpt);
@@ -2279,10 +2249,8 @@ public class JpaArtifactFactory {
}
public JavaPersistentAttribute[] getIds(JavaPersistentType jpt) {
- ListIterator<JavaPersistentAttribute> attribsIter = jpt.attributes();
ArrayList<JavaPersistentAttribute> res = new ArrayList<JavaPersistentAttribute>();
- while (attribsIter.hasNext()) {
- JavaPersistentAttribute at = attribsIter.next();
+ for (JavaPersistentAttribute at : jpt.getAttributes()) {
if (isId(at))
res.add(at);
}
@@ -2295,19 +2263,19 @@ public class JpaArtifactFactory {
}
public boolean isSimpleId(JavaPersistentAttribute jpa) {
- IdAnnotation an = (IdAnnotation)jpa.getResourcePersistentAttribute().getAnnotation(IdAnnotation.ANNOTATION_NAME);
+ IdAnnotation an = (IdAnnotation)jpa.getResourceAttribute().getAnnotation(IdAnnotation.ANNOTATION_NAME);
return (an != null);
}
public boolean isEmbeddedId(JavaPersistentAttribute jpa) {
- EmbeddedIdAnnotation an = (EmbeddedIdAnnotation)jpa.getResourcePersistentAttribute().getAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME);
+ EmbeddedIdAnnotation an = (EmbeddedIdAnnotation)jpa.getResourceAttribute().getAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME);
return (an != null);
}
public String getColumnName(JavaPersistentAttribute jpa) {
String columnName= null;
ColumnAnnotation an = (ColumnAnnotation)jpa.
- getResourcePersistentAttribute().
+ getResourceAttribute().
getAnnotation(ColumnAnnotation.ANNOTATION_NAME);
if (an != null)
columnName = an.getName();

Back to the top