Skip to main content
summaryrefslogtreecommitdiffstats
blob: e7a21e46f80c86bda8d11009eafcb3bc65b0a1bc (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
/*******************************************************************************
 * Copyright (c) 2007, 2008 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.internal.context.java;

import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.context.Cascade;
import org.eclipse.jpt.core.context.java.JavaRelationshipMapping;
import org.eclipse.jpt.core.resource.java.RelationshipMappingAnnotation;
import org.eclipse.jpt.core.utility.TextRange;

public class JavaCascade extends AbstractJavaJpaContextNode implements Cascade
{
	protected boolean all;

	protected boolean persist;

	protected boolean merge;

	protected boolean remove;

	protected boolean refresh;

	protected RelationshipMappingAnnotation relationshipMapping;

	protected JavaCascade(JavaRelationshipMapping parent) {
		super(parent);
	}

	public boolean isAll() {
		return this.all;
	}

	public void setAll(boolean newAll) {
		boolean oldAll = this.all;
		this.all = newAll;
		this.relationshipMapping.setCascadeAll(newAll);
		firePropertyChanged(Cascade.ALL_PROPERTY, oldAll, newAll);
	}

	public boolean isPersist() {
		return this.persist;
	}

	public void setPersist(boolean newPersist) {
		boolean oldPersist = this.persist;
		this.persist = newPersist;
		this.relationshipMapping.setCascadePersist(newPersist);
		firePropertyChanged(Cascade.PERSIST_PROPERTY, oldPersist, newPersist);
	}

	public boolean isMerge() {
		return this.merge;
	}

	public void setMerge(boolean newMerge) {
		boolean oldMerge = this.merge;
		this.merge = newMerge;
		this.relationshipMapping.setCascadeMerge(newMerge);
		firePropertyChanged(Cascade.MERGE_PROPERTY, oldMerge, newMerge);
	}

	public boolean isRemove() {
		return this.remove;
	}

	public void setRemove(boolean newRemove) {
		boolean oldRemove = this.remove;
		this.remove = newRemove;
		this.relationshipMapping.setCascadeRemove(newRemove);
		firePropertyChanged(Cascade.REMOVE_PROPERTY, oldRemove, newRemove);
	}

	public boolean isRefresh() {
		return this.refresh;
	}

	public void setRefresh(boolean newRefresh) {
		boolean oldRefresh = this.refresh;
		this.refresh = newRefresh;
		this.relationshipMapping.setCascadeRefresh(newRefresh);
		firePropertyChanged(Cascade.REFRESH_PROPERTY, oldRefresh, newRefresh);
	}

	public TextRange getValidationTextRange(CompilationUnit astRoot) {
		return this.relationshipMapping.getCascadeTextRange(astRoot);
	}
	
	public void initialize(RelationshipMappingAnnotation relationshipMapping) {
		this.relationshipMapping = relationshipMapping;
		this.all = relationshipMapping.isCascadeAll();
		this.persist = relationshipMapping.isCascadePersist();
		this.merge = relationshipMapping.isCascadeMerge();
		this.remove = relationshipMapping.isCascadeRemove();
		this.refresh = relationshipMapping.isCascadeRefresh();
	}
	
	public void update(RelationshipMappingAnnotation relationshipMapping) {
		this.relationshipMapping = relationshipMapping;
		this.setAll(relationshipMapping.isCascadeAll());
		this.setPersist(relationshipMapping.isCascadePersist());
		this.setMerge(relationshipMapping.isCascadeMerge());
		this.setRemove(relationshipMapping.isCascadeRemove());
		this.setRefresh(relationshipMapping.isCascadeRefresh());
	}
}

Back to the top