Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 7ca34ec5c0e94bf944e2719bd2fdb66fdeaf93ac (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
/*******************************************************************************
 * Copyright (c) 2013, 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_1.context.orm;

import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jpa.core.context.java.JavaManagedType;
import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmManagedType;
import org.eclipse.jpt.jpa.core.jpa2_1.context.ConverterType2_1;
import org.eclipse.jpt.jpa.core.jpa2_1.context.orm.EntityMappings2_1;
import org.eclipse.jpt.jpa.core.jpa2_1.context.orm.OrmConverterType2_1;
import org.eclipse.jpt.jpa.core.resource.orm.XmlConverter;
import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings;

public class GenericOrmConverterType2_1
	extends AbstractOrmManagedType<EntityMappings2_1>
	implements OrmConverterType2_1
{
	protected boolean autoApply;

	protected Boolean specifiedAutoApply;

	public GenericOrmConverterType2_1(EntityMappings2_1 parent, XmlConverter xmlConverter) {
		super(parent, xmlConverter);
		this.specifiedAutoApply = this.buildSpecifiedAutoApply();
		this.autoApply = this.buildAutoApply();
	}

	@Override
	public void synchronizeWithResourceModel() {
		super.synchronizeWithResourceModel();
		this.setSpecifiedAutoApply_(this.buildSpecifiedAutoApply());
		this.setAutoApply(this.buildAutoApply());
	}

	@Override
	public void update() {
		super.update();
	}

	@Override
	public XmlConverter getXmlManagedType() {
		return (XmlConverter) super.getXmlManagedType();
	}

	public XmlConverter getXmlConverter() {
		return this.getXmlManagedType();
	}


	// ********** auto apply **********

	public boolean isAutoApply() {
		return this.autoApply;
	}

	protected void setAutoApply(boolean autoApply) {
		boolean old = this.autoApply;
		this.autoApply = autoApply;
		firePropertyChanged(AUTO_APPLY_PROPERTY, old, autoApply);
	}

	protected boolean buildAutoApply() {
		return this.specifiedAutoApply == null ? this.isDefaultAutoApply() : this.specifiedAutoApply.booleanValue();
	}

	public boolean isDefaultAutoApply() {
		return DEFAULT_AUTO_APPLY;
	}

	public Boolean getSpecifiedAutoApply() {
		return this.specifiedAutoApply;
	}

	public void setSpecifiedAutoApply(Boolean autoApply) {
		this.setSpecifiedAutoApply_(autoApply);
		this.getXmlConverter().setAutoApply(autoApply);
	}

	protected void setSpecifiedAutoApply_(Boolean autoApply) {
		Boolean old = this.specifiedAutoApply;
		this.specifiedAutoApply = autoApply;
		this.firePropertyChanged(SPECIFIED_AUTO_APPLY_PROPERTY, old, autoApply);
	}

	protected Boolean buildSpecifiedAutoApply() {
		return this.getXmlConverter().getAutoApply();
	}


	// ********** JpaStructureNode implementation **********

	public Class<ConverterType2_1> getManagedTypeType() {
		return ConverterType2_1.class;
	}


	// ********** OrmManagedType implementation **********

	public int getXmlSequence() {
		return 4;
	}

	public void addXmlManagedTypeTo(XmlEntityMappings entityMappings) {
		entityMappings.getConverters().add(this.getXmlConverter());
	}

	public void removeXmlManagedTypeFrom(XmlEntityMappings entityMappings) {
		entityMappings.getConverters().remove(this.getXmlConverter());
	}

	@Override
	protected JavaManagedType buildJavaManagedType(JavaResourceType jrt) {
		return jrt != null ? this.getJpaFactory2_1().buildJavaConverterType(this, jrt) : null;
	}
}

Back to the top