Skip to main content
summaryrefslogtreecommitdiffstats
blob: 4c092108d6e2927ee1d0aa5afca58a3d2531088a (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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*******************************************************************************
 * Copyright (c) 2008, 2009 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.core.context.orm;

import java.util.ListIterator;

import org.eclipse.jpt.core.context.PersistentType;
import org.eclipse.jpt.core.context.XmlContextNode;
import org.eclipse.jpt.core.context.java.JavaPersistentType;

/**
 * Context <code>orm.xml</code> persistent type.
 * <p>
 * Provisional API: This interface is part of an interim API that is still
 * under development and expected to change significantly before reaching
 * stability. It is available at this early stage to solicit feedback from
 * pioneering adopters on the understanding that any code that uses this API
 * will almost certainly be broken (repeatedly) as the API evolves.
 */
public interface OrmPersistentType
	extends PersistentType, PersistentType.Owner, XmlContextNode
{
	// ********** covariant overrides **********

	EntityMappings getParent();

	@SuppressWarnings("unchecked")
	ListIterator<OrmPersistentAttribute> attributes();
	
	OrmPersistentAttribute getAttributeNamed(String attributeName);

	OrmTypeMapping getMapping();
	
	
	//***************** specified attributes ***********************************
	
	/**
	 * Return a read only iterator of the specified {@link OrmPersistentAttribute}s.
	 */
	ListIterator<OrmPersistentAttribute> specifiedAttributes();
	
	/**
	 * Return the number of specified {@link OrmPersistentAttribute}s.
	 */
	int specifiedAttributesSize();
	
	//TODO these are currently only used by tests, possibly remove them.  OrmPersistenAttributes.setVirtual(boolean) is used by the UI
	OrmPersistentAttribute addSpecifiedPersistentAttribute(String mappingKey, String attributeName);

	void removeSpecifiedPersistentAttribute(OrmPersistentAttribute ormPersistentAttribute);
	
	
	//***************** virtual attributes *************************************
	
	String VIRTUAL_ATTRIBUTES_LIST = "virtualAttributes"; //$NON-NLS-1$

	/**
	 * Return a read only iterator of the virtual orm persistent attributes.  These
	 * are attributes that exist in the underyling java class, but are not specified
	 * in the orm.xml
	 */
	ListIterator<OrmPersistentAttribute> virtualAttributes();
	
	/**
	 * Return the number of virtual orm persistent attributes.  These are attributes that 
	 * exist in the underyling java class, but are not specified in the orm.xml
	 */
	int virtualAttributesSize();
	
	/**
	 * Return whether this persistent type contains the given virtual persistent attribute.
	 */
	boolean containsVirtualPersistentAttribute(OrmPersistentAttribute ormPersistentAttribute);
	
	/**
	 * Remove the given specified orm persistent attribute from the orm.xml. The attribute 
	 * will be removed from the orm.xml and moved from the list of specified attributes 
	 * to the list of virtual attributes.
	 */
	void makePersistentAttributeVirtual(OrmPersistentAttribute ormPersistentAttribute);
		
	/**
	 * Add the given virtual orm persistent attribute to the orm.xml. The attribute will
	 * be added to the orm.xml and moved from the list of virtual attributes to the list
	 * of specified attributes
	 */
	void makePersistentAttributeSpecified(OrmPersistentAttribute ormPersistentAttribute);

	/**
	 * Add the given virtual orm persistent attribute to the orm.xml with a mapping of 
	 * type mappingKey. The attribute will be added to the orm.xml and moved from 
	 * the list of virtual attributes to the list of specified attributes
	 */
	void makePersistentAttributeSpecified(OrmPersistentAttribute ormPersistentAttribute, String mappingKey);


	//******************* mapping morphing *******************

	void changeMapping(OrmPersistentAttribute ormPersistentAttribute, OrmAttributeMapping oldMapping, OrmAttributeMapping newMapping);
	
	
	//******************* updating *******************

	/**
	 * Update the OrmPersistentType context model object to match the 
	 * resource model object. see {@link org.eclipse.jpt.core.JpaProject#update()}
	 */
	void update();
	

	boolean contains(int textOffset);
	
	/**
	 * Return whether the persistent type applies to the
	 * specified type.
	 */
	boolean isFor(String typeName);
	
	void classChanged(String oldClass, String newClass);
	
	/**
	 * Return the Java persistent type that is referred to by this orm.xml persistent type.
	 * If there is no underlying java persistent type, then null is returned.
	 */
	JavaPersistentType getJavaPersistentType();
		String JAVA_PERSISTENT_TYPE_PROPERTY = "javaPersistentType"; //$NON-NLS-1$

	/**
	 * Return the persistent type's default package.
	 */
	String getDefaultPackage();

	/**
	 * Return whether the persistent type is default metadata complete.
	 */
	boolean isDefaultMetadataComplete();

}

Back to the top