blob: 7ee6e24fcacc921c4a6d93370573cb72ba6be78b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
/*******************************************************************************
* Copyright (c) 2009, 2015 Oracle. 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 http://www.eclipse.org/legal/epl-v10.html.
*
* Contributors:
* Oracle - initial API and implementation
******************************************************************************/
package org.eclipse.jpt.jpa.core.internal.jpa2.context.java;
import java.util.Collection;
import java.util.Map;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.common.core.utility.BodySourceWriter;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaPersistentType;
import org.eclipse.jpt.jpa.core.jpa2.context.MetamodelSourceType2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.PersistentType2_0;
/**
* JPA 2.0 Java persistent type.
* Support for specified access and metamodel generation.
*/
public class GenericJavaPersistentType2_0
extends AbstractJavaPersistentType
implements PersistentType2_0
{
protected String declaringTypeName;
protected final MetamodelSourceType2_0.Synchronizer metamodelSynchronizer;
public GenericJavaPersistentType2_0(JavaPersistentType.Parent parent, JavaResourceType jrt) {
super(parent, jrt);
this.declaringTypeName = this.buildDeclaringTypeName();
this.metamodelSynchronizer = this.buildMetamodelSynchronizer();
}
// ********** synchronize/update **********
@Override
public void synchronizeWithResourceModel(IProgressMonitor monitor) {
super.synchronizeWithResourceModel(monitor);
this.setDeclaringTypeName(this.buildDeclaringTypeName());
}
// ********** declaring type name **********
public String getDeclaringTypeName() {
return this.declaringTypeName;
}
protected void setDeclaringTypeName(String declaringTypeName) {
String old = this.declaringTypeName;
this.declaringTypeName = declaringTypeName;
this.firePropertyChanged(DECLARING_TYPE_NAME_PROPERTY, old, declaringTypeName);
}
protected String buildDeclaringTypeName() {
return this.resourceType.getDeclaringTypeName();
}
// ********** metamodel **********
public IFile getMetamodelFile() {
return this.metamodelSynchronizer.getFile();
}
public void initializeMetamodel() {
// do nothing - probably shouldn't be called...
}
public boolean isManaged() {
return true;
}
public void synchronizeMetamodel(Map<String, Collection<MetamodelSourceType2_0>> memberTypeTree) {
this.metamodelSynchronizer.synchronize(memberTypeTree);
}
public void printBodySourceOn(BodySourceWriter pw, Map<String, Collection<MetamodelSourceType2_0>> memberTypeTree) {
this.metamodelSynchronizer.printBodySourceOn(pw, memberTypeTree);
}
public void disposeMetamodel() {
// do nothing - probably shouldn't be called...
}
protected MetamodelSourceType2_0.Synchronizer buildMetamodelSynchronizer() {
return this.getJpaFactory2_0().buildMetamodelSynchronizer(this);
}
public PersistentType2_0 getMetamodelType() {
return this;
}
}
|