blob: 4c406448fbf113c58780bc6710c8fdddd2b3c59d (
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
|
/*******************************************************************************
* 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.jpt.core.context.SequenceGenerator;
import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
import org.eclipse.jpt.core.context.java.JavaSequenceGenerator;
import org.eclipse.jpt.core.resource.java.SequenceGeneratorAnnotation;
public class GenericJavaSequenceGenerator extends AbstractJavaGenerator
implements JavaSequenceGenerator
{
protected String specifiedSequenceName;
public GenericJavaSequenceGenerator(JavaJpaContextNode parent) {
super(parent);
}
@Override
protected SequenceGeneratorAnnotation getGeneratorResource() {
return (SequenceGeneratorAnnotation) super.getGeneratorResource();
}
public void initializeFromResource(SequenceGeneratorAnnotation sequenceGenerator) {
super.initializeFromResource(sequenceGenerator);
this.specifiedSequenceName = this.specifiedSequenceName(sequenceGenerator);
}
public Integer getDefaultInitialValue() {
return SequenceGenerator.DEFAULT_INITIAL_VALUE;
}
public String getSequenceName() {
return (this.getSpecifiedSequenceName() == null) ? getDefaultSequenceName() : this.getSpecifiedSequenceName();
}
public String getSpecifiedSequenceName() {
return this.specifiedSequenceName;
}
public void setSpecifiedSequenceName(String newSpecifiedSequenceName) {
String oldSpecifiedSequenceName = this.specifiedSequenceName;
this.specifiedSequenceName = newSpecifiedSequenceName;
getGeneratorResource().setSequenceName(newSpecifiedSequenceName);
firePropertyChanged(SPECIFIED_SEQUENCE_NAME_PROPERTY, oldSpecifiedSequenceName, newSpecifiedSequenceName);
}
protected void setSpecifiedSequenceName_(String newSpecifiedSequenceName) {
String oldSpecifiedSequenceName = this.specifiedSequenceName;
this.specifiedSequenceName = newSpecifiedSequenceName;
firePropertyChanged(SPECIFIED_SEQUENCE_NAME_PROPERTY, oldSpecifiedSequenceName, newSpecifiedSequenceName);
}
public String getDefaultSequenceName() {
return null;
}
public void update(SequenceGeneratorAnnotation sequenceGenerator) {
super.update(sequenceGenerator);
this.setSpecifiedSequenceName_(this.specifiedSequenceName(sequenceGenerator));
}
protected String specifiedSequenceName(SequenceGeneratorAnnotation generatorResource) {
return generatorResource.getSequenceName();
}
}
|