|
@@ -1,10 +1,6 @@ |
1 |
1 |
|
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
2 |
|
package org.litesoft.generator; |
3 |
3 |
|
|
4 |
|
- |
import org.litesoft.commonfoundation.typeutils.*; |
5 |
|
- |
|
6 |
|
- |
import java.util.*; |
7 |
|
- |
|
8 |
4 |
|
import org.litesoft.aokeyhole.objects.AttributeMetaData; |
9 |
5 |
|
import org.litesoft.aokeyhole.objects.*; |
10 |
6 |
|
import org.litesoft.aokeyhole.objects.attributes.*; |
|
@@ -12,23 +8,23 @@ |
12 |
8 |
|
import org.litesoft.bo.attributes.*; |
13 |
9 |
|
import org.litesoft.codegen.*; |
14 |
10 |
|
import org.litesoft.commonfoundation.typeutils.Objects; |
|
11 |
+ |
import org.litesoft.commonfoundation.typeutils.*; |
15 |
12 |
|
import org.litesoft.orsup.lazyeval.*; |
16 |
13 |
|
|
17 |
|
- |
public class GeneratePOGO extends AbstractPOFileGenerator |
18 |
|
- |
{ |
|
14 |
+ |
import java.util.*; |
|
15 |
+ |
|
|
16 |
+ |
public class GeneratePOGO extends AbstractPOFileGenerator { |
19 |
17 |
|
public static final String[] IMPLIMENTS_HAS_ATTRIBUTES = {"HasAttributes"}; |
20 |
18 |
|
|
21 |
19 |
|
private static final AttributeType[] PAIRED_TYPES = new AttributeType[]{A_CommonPairedToOne.TYPE, A_PairedToOne.TYPE}; |
22 |
20 |
|
private static final AttributeType[] BRIDGE_TYPES = new AttributeType[]{A_VariableBridgeToOneLeft.TYPE, A_BridgeToOneLeft.TYPE, A_BridgeToOneRight.TYPE}; |
23 |
21 |
|
|
24 |
|
- |
public GeneratePOGO( ErrorSinc pErrorSinc, ObjectMetaData pObjectMetaData, ObjectRef pObjectRef, ObjectRef pParentObjectRef, boolean pIsParent ) |
25 |
|
- |
{ |
|
22 |
+ |
public GeneratePOGO( ErrorSinc pErrorSinc, ObjectMetaData pObjectMetaData, ObjectRef pObjectRef, ObjectRef pParentObjectRef, boolean pIsParent ) { |
26 |
23 |
|
super( pErrorSinc, pObjectMetaData, pObjectRef, "GO", pParentObjectRef, pIsParent ); |
27 |
24 |
|
} |
28 |
25 |
|
|
29 |
26 |
|
@Override |
30 |
|
- |
protected void LLaddImports() |
31 |
|
- |
{ |
|
27 |
+ |
protected void LLaddImports() { |
32 |
28 |
|
boolean zHasAttributes = (getAttributes().length != 0); |
33 |
29 |
|
addImports( // |
34 |
30 |
|
zHasAttributes ? "org.litesoft.bo.attributes.*" : null, // |
|
@@ -41,30 +37,23 @@ |
41 |
37 |
|
} |
42 |
38 |
|
|
43 |
39 |
|
@Override |
44 |
|
- |
protected void LLaddClassDefinition() |
45 |
|
- |
{ |
|
40 |
+ |
protected void LLaddClassDefinition() { |
46 |
41 |
|
String[] zImplements = (getAttributes().length != 0) ? IMPLIMENTS_HAS_ATTRIBUTES : null; |
47 |
42 |
|
makeClassAbstract(); |
48 |
|
- |
if ( mIsParent ) |
49 |
|
- |
{ |
50 |
|
- |
addClassDefinition( mClassName + "<T extends " + mObjectName + ">", getExtends( "org.litesoft.orsup.nonpublic.PersistentObjectImpl" ) + "<T>", zImplements ); |
51 |
|
- |
} |
52 |
|
- |
else |
53 |
|
- |
{ |
|
43 |
+ |
if ( mIsParent ) { |
|
44 |
+ |
addClassDefinition( mClassName + "<T extends " + mObjectName + ">", getExtends( "org.litesoft.orsup.nonpublic.PersistentObjectImpl" ) + "<T>", |
|
45 |
+ |
zImplements ); |
|
46 |
+ |
} else { |
54 |
47 |
|
addClassDefinition( mClassName, getExtends( "org.litesoft.orsup.nonpublic.PersistentObjectImpl" ) + "<" + mObjectName + ">", zImplements ); |
55 |
48 |
|
} |
56 |
49 |
|
} |
57 |
50 |
|
|
58 |
51 |
|
@Override |
59 |
|
- |
protected void LLaddClassBody() |
60 |
|
- |
{ |
|
52 |
+ |
protected void LLaddClassBody() { |
61 |
53 |
|
addTopValidOptions( mObjectName + "Names.po" ); |
62 |
|
- |
if ( mIsParent ) |
63 |
|
- |
{ |
|
54 |
+ |
if ( mIsParent ) { |
64 |
55 |
|
constructorsParent(); |
65 |
|
- |
} |
66 |
|
- |
else |
67 |
|
- |
{ |
|
56 |
+ |
} else { |
68 |
57 |
|
addLine( "private static final ConstructionControl CONSTRUCTION_CONTROL = new ConstructionControl();" ); |
69 |
58 |
|
addBlankLine(); |
70 |
59 |
|
addStaticMethodPublic( "SimpleFromIdentifier", "from" ); |
|
@@ -79,25 +68,21 @@ |
79 |
68 |
|
addMyMetaData(); |
80 |
69 |
|
} |
81 |
70 |
|
|
82 |
|
- |
private void constructorsParent() |
83 |
|
- |
{ |
|
71 |
+ |
private void constructorsParent() { |
84 |
72 |
|
addConstructorProtected( mClassName, "MetaDataForPO pMetaDataForPO", "Transaction pTransaction" ); |
85 |
73 |
|
addLine( "super( pMetaDataForPO, pTransaction );" ); |
86 |
74 |
|
addMethodEnd(); |
87 |
75 |
|
|
88 |
|
- |
addConstructorProtected( mClassName, "MetaDataForPO pMetaDataForPO", "ConstructionControl pConstructionControlExpected", "ConstructionControl pConstructionControlActual" ); |
|
76 |
+ |
addConstructorProtected( mClassName, "MetaDataForPO pMetaDataForPO", "ConstructionControl pConstructionControlExpected", |
|
77 |
+ |
"ConstructionControl pConstructionControlActual" ); |
89 |
78 |
|
addLine( "super( pMetaDataForPO, pConstructionControlExpected, pConstructionControlActual );" ); |
90 |
79 |
|
addBlockEnd(); |
91 |
80 |
|
} |
92 |
81 |
|
|
93 |
|
- |
private String getSequenceNumberSource() |
94 |
|
- |
{ |
95 |
|
- |
for ( AttributeProxy zAttribute : getAttributes() ) |
96 |
|
- |
{ |
97 |
|
- |
if ( !zAttribute.isVirtual() ) |
98 |
|
- |
{ |
99 |
|
- |
if ( A_PairedToOne.TYPE.equals( zAttribute.getAttributeSetType() ) ) |
100 |
|
- |
{ |
|
82 |
+ |
private String getSequenceNumberSource() { |
|
83 |
+ |
for ( AttributeProxy zAttribute : getAttributes() ) { |
|
84 |
+ |
if ( !zAttribute.isVirtual() ) { |
|
85 |
+ |
if ( A_PairedToOne.TYPE.equals( zAttribute.getAttributeSetType() ) ) { |
101 |
86 |
|
String zToOne = Objects.justClassNameIfPackage( zAttribute.getToOneFullyQualifiedName(), mPackage + "." ); |
102 |
87 |
|
return zToOne + ".class"; |
103 |
88 |
|
} |
|
@@ -106,8 +91,7 @@ |
106 |
91 |
|
return "getClass()"; |
107 |
92 |
|
} |
108 |
93 |
|
|
109 |
|
- |
private void constructorsRegular() |
110 |
|
- |
{ |
|
94 |
+ |
private void constructorsRegular() { |
111 |
95 |
|
addConstructorProtected( mClassName, "Transaction pTransaction" ); |
112 |
96 |
|
addLine( "super( " + mObjectName + "MetaData.INSTANCE, pTransaction );" ); |
113 |
97 |
|
addLine( "mID = getNextSequenceNumber( " + getSequenceNumberSource() + " );" ); |
|
@@ -120,8 +104,7 @@ |
120 |
104 |
|
addBlockEnd(); |
121 |
105 |
|
} |
122 |
106 |
|
|
123 |
|
- |
private void addRecordVersion() |
124 |
|
- |
{ |
|
107 |
+ |
private void addRecordVersion() { |
125 |
108 |
|
addBlankLine(); |
126 |
109 |
|
addLine( "public static final AttributeAccessorSCD CD_RecordVersion = new AttributeAccessor_RecordVersion();" ); |
127 |
110 |
|
addBlankLine(); |
|
@@ -143,34 +126,30 @@ |
143 |
126 |
|
addBlockEnd(); |
144 |
127 |
|
} |
145 |
128 |
|
|
146 |
|
- |
public String getTableName() |
147 |
|
- |
{ |
|
129 |
+ |
public String getTableName() { |
148 |
130 |
|
return mObjectMetaData.getPropertyManager().get_String( PMD_TableName.NAME, mObjectName ); |
149 |
131 |
|
} |
150 |
132 |
|
|
151 |
|
- |
public String getDisplayValueFormat() |
152 |
|
- |
{ |
|
133 |
+ |
public String getDisplayValueFormat() { |
153 |
134 |
|
return quote( Strings.noEmpty( mObjectMetaData.getPropertyManager().get_String( PMD_DisplayValueFormat.NAME, "" ) ) ); |
154 |
135 |
|
} |
155 |
136 |
|
|
156 |
|
- |
private void addMyMetaData() |
157 |
|
- |
{ |
|
137 |
+ |
private void addMyMetaData() { |
158 |
138 |
|
addBlankLine(); |
159 |
139 |
|
makeClassStatic(); |
160 |
140 |
|
makeClassPackageFriendly(); |
161 |
|
- |
if ( mIsParent ) |
162 |
|
- |
{ |
|
141 |
+ |
if ( mIsParent ) { |
163 |
142 |
|
makeClassAbstract(); |
164 |
143 |
|
addClassDefinition( "MyMetaData<T extends " + mObjectName + ">", getExtends( "org.litesoft.orsup.nonpublic.PersistentObjectImpl" ) + "MetaData<T>" ); |
165 |
|
- |
addConstructorPackageFriendly( "MyMetaData", "String pIdentifierName", "String pTableName", "AttributeAccessorKeySet pAttributeAccessorKeySet", "AttributeAccessorSCD... pAccessorSCDs" ); |
|
144 |
+ |
addConstructorPackageFriendly( "MyMetaData", "String pIdentifierName", "String pTableName", "AttributeAccessorKeySet pAttributeAccessorKeySet", |
|
145 |
+ |
"AttributeAccessorSCD... pAccessorSCDs" ); |
166 |
146 |
|
addLine( "this( null, pIdentifierName, pTableName, pAttributeAccessorKeySet, pAccessorSCDs );" ); |
167 |
147 |
|
addMethodEnd(); |
168 |
|
- |
addConstructorPackageFriendly( "MyMetaData", "AttributeAccessorSCD[] pAccessorSCDs", "String pIdentifierName", "String pTableName", "AttributeAccessorKeySet pAttributeAccessorKeySet", "AttributeAccessorSCD... pMoreAccessorSCDs" ); |
|
148 |
+ |
addConstructorPackageFriendly( "MyMetaData", "AttributeAccessorSCD[] pAccessorSCDs", "String pIdentifierName", "String pTableName", |
|
149 |
+ |
"AttributeAccessorKeySet pAttributeAccessorKeySet", "AttributeAccessorSCD... pMoreAccessorSCDs" ); |
169 |
150 |
|
addMDattributes( "super( join( pAccessorSCDs, pMoreAccessorSCDs ), pIdentifierName, pTableName, pAttributeAccessorKeySet", null ); |
170 |
151 |
|
addBlockEnd(); |
171 |
|
- |
} |
172 |
|
- |
else |
173 |
|
- |
{ |
|
152 |
+ |
} else { |
174 |
153 |
|
addClassDefinition( "MyMetaData", getExtends( "org.litesoft.orsup.nonpublic.PersistentObjectImpl" ) + "MetaData<" + mObjectName + ">" ); |
175 |
154 |
|
addPSFS( "OBJECT_NAME", mObjectName ); |
176 |
155 |
|
addPSFS( "TABLE_NAME", getTableName() ); |
|
@@ -207,8 +186,7 @@ |
207 |
186 |
|
addBlockEnd(); |
208 |
187 |
|
|
209 |
188 |
|
String zOrderBy = Strings.noEmpty( mObjectMetaData.getPropertyManager().get_String( PMD_OrderByAttribute.NAME, null ) ); |
210 |
|
- |
if ( zOrderBy != null ) |
211 |
|
- |
{ |
|
189 |
+ |
if ( zOrderBy != null ) { |
212 |
190 |
|
addBlankLine(); |
213 |
191 |
|
addLine( "@Override" ); |
214 |
192 |
|
addMethodPublic( "String", "getDefaultOrderByAttributeName" ); |
|
@@ -217,19 +195,16 @@ |
217 |
195 |
|
} |
218 |
196 |
|
} |
219 |
197 |
|
String zTimeTracked = mObjectMetaData.getPropertyManager().get_String( PMD_TimeTracked.NAME, PMD_TimeTracked.NONE ); |
220 |
|
- |
if ( PMD_TimeTracked.CREATED.equals( zTimeTracked ) || PMD_TimeTracked.BOTH.equals( zTimeTracked ) ) |
221 |
|
- |
{ |
|
198 |
+ |
if ( PMD_TimeTracked.CREATED.equals( zTimeTracked ) || PMD_TimeTracked.BOTH.equals( zTimeTracked ) ) { |
222 |
199 |
|
addSpecialTimestampMDmethods( "Created", "Creation" ); |
223 |
200 |
|
} |
224 |
|
- |
if ( PMD_TimeTracked.LAST_MOD.equals( zTimeTracked ) || PMD_TimeTracked.BOTH.equals( zTimeTracked ) ) |
225 |
|
- |
{ |
|
201 |
+ |
if ( PMD_TimeTracked.LAST_MOD.equals( zTimeTracked ) || PMD_TimeTracked.BOTH.equals( zTimeTracked ) ) { |
226 |
202 |
|
addSpecialTimestampMDmethods( "LastModified", "Transaction" ); |
227 |
203 |
|
} |
228 |
204 |
|
addClassEnd(); |
229 |
205 |
|
} |
230 |
206 |
|
|
231 |
|
- |
private void addSpecialTimestampMDmethods( String pAttributeName, String pMethodName ) |
232 |
|
- |
{ |
|
207 |
+ |
private void addSpecialTimestampMDmethods( String pAttributeName, String pMethodName ) { |
233 |
208 |
|
addBlankLine(); |
234 |
209 |
|
addLine( "@Override" ); |
235 |
210 |
|
addMethodPublic( "String", "get" + pMethodName + "TimestampAttributeName" ); |
|
@@ -242,14 +217,11 @@ |
242 |
217 |
|
addBlockEnd(); |
243 |
218 |
|
} |
244 |
219 |
|
|
245 |
|
- |
private void addIndexes() |
246 |
|
- |
{ |
|
220 |
+ |
private void addIndexes() { |
247 |
221 |
|
List<AttributeMetaData> zAttributes = new ArrayList<AttributeMetaData>( mObjectMetaData.getSortedAttributes() ); |
248 |
|
- |
for ( ObjectMetaData zOMD = mObjectMetaData; zOMD.getParentName() != null; ) |
249 |
|
- |
{ |
|
222 |
+ |
for ( ObjectMetaData zOMD = mObjectMetaData; zOMD.getParentName() != null; ) { |
250 |
223 |
|
ObjectMetaData zParentOMD = zOMD.getSystemMetaData().getObject( zOMD.getParentName() ); |
251 |
|
- |
if ( zParentOMD == null ) |
252 |
|
- |
{ |
|
224 |
+ |
if ( zParentOMD == null ) { |
253 |
225 |
|
throw new IllegalStateException( "Parent Name '" + zOMD.getParentName() + "' but no Parent on: " + zOMD ); |
254 |
226 |
|
} |
255 |
227 |
|
zAttributes.addAll( zParentOMD.getSortedAttributes() ); |
|
@@ -259,13 +231,10 @@ |
259 |
231 |
|
|
260 |
232 |
|
List<Index> zIndexes = new ArrayList<Index>(); |
261 |
233 |
|
|
262 |
|
- |
for ( Integer zGroup : getUniqueGroups( zAttributes ) ) |
263 |
|
- |
{ |
|
234 |
+ |
for ( Integer zGroup : getUniqueGroups( zAttributes ) ) { |
264 |
235 |
|
Index zIndex = new Index( getTableName(), "MUG", zGroup, true ); |
265 |
|
- |
for ( AttributeMetaData zAttribute : zAttributes ) |
266 |
|
- |
{ |
267 |
|
- |
if ( zGroup.equals( zAttribute.getPropertyManager().get_Integer( PMD_UniqueGroup.NAME, null ) ) ) |
268 |
|
- |
{ |
|
236 |
+ |
for ( AttributeMetaData zAttribute : zAttributes ) { |
|
237 |
+ |
if ( zGroup.equals( zAttribute.getPropertyManager().get_Integer( PMD_UniqueGroup.NAME, null ) ) ) { |
269 |
238 |
|
zIndex.addAttribute( zAttribute.getName() ); |
270 |
239 |
|
} |
271 |
240 |
|
} |
|
@@ -273,26 +242,19 @@ |
273 |
242 |
|
} |
274 |
243 |
|
|
275 |
244 |
|
int zAutoIndexes = 0; |
276 |
|
- |
for ( AttributeMetaData zAttribute : zAttributes ) |
277 |
|
- |
{ |
278 |
|
- |
if ( isToOnePersisted( zAttribute ) && !alreadyIndexed( zIndexes, zAttribute.getName() ) ) |
279 |
|
- |
{ |
|
245 |
+ |
for ( AttributeMetaData zAttribute : zAttributes ) { |
|
246 |
+ |
if ( isToOnePersisted( zAttribute ) && !alreadyIndexed( zIndexes, zAttribute.getName() ) ) { |
280 |
247 |
|
zIndexes.add( new Index( getTableName(), "21A", ++zAutoIndexes, false ).addAttribute( zAttribute.getName() ) ); |
281 |
248 |
|
} |
282 |
249 |
|
} |
283 |
250 |
|
|
284 |
|
- |
if ( !zIndexes.isEmpty() ) |
285 |
|
- |
{ |
|
251 |
+ |
if ( !zIndexes.isEmpty() ) { |
286 |
252 |
|
int i = zIndexes.size() - 1; |
287 |
|
- |
if ( i == 0 ) |
288 |
|
- |
{ |
|
253 |
+ |
if ( i == 0 ) { |
289 |
254 |
|
addLine( "setIndexes( " + zIndexes.get( 0 ) + " );" ); |
290 |
|
- |
} |
291 |
|
- |
else |
292 |
|
- |
{ |
|
255 |
+ |
} else { |
293 |
256 |
|
addLine( "setIndexes( " + zIndexes.get( i-- ) + ", //" ); |
294 |
|
- |
while ( i > 0 ) |
295 |
|
- |
{ |
|
257 |
+ |
while ( i > 0 ) { |
296 |
258 |
|
addLine( " " + zIndexes.get( i-- ) + ", //" ); |
297 |
259 |
|
} |
298 |
260 |
|
addLine( " " + zIndexes.get( i ) + " );" ); |
|
@@ -300,42 +262,32 @@ |
300 |
262 |
|
} |
301 |
263 |
|
} |
302 |
264 |
|
|
303 |
|
- |
private boolean isToOnePersisted( AttributeMetaData pAttribute ) |
304 |
|
- |
{ |
305 |
|
- |
if ( !pAttribute.isVirtual() ) |
306 |
|
- |
{ |
|
265 |
+ |
private boolean isToOnePersisted( AttributeMetaData pAttribute ) { |
|
266 |
+ |
if ( !pAttribute.isVirtual() ) { |
307 |
267 |
|
AttributeType zType = pAttribute.getAttributeSet().getType(); |
308 |
268 |
|
return zType.getFAT().isToOne() && !A_PairedToOne.TYPE.equals( zType ); |
309 |
269 |
|
} |
310 |
270 |
|
return false; |
311 |
271 |
|
} |
312 |
272 |
|
|
313 |
|
- |
private boolean alreadyIndexed( List<Index> pIndexes, String pAttributeName ) |
314 |
|
- |
{ |
315 |
|
- |
for ( Index zIndex : pIndexes ) |
316 |
|
- |
{ |
317 |
|
- |
if ( zIndex.isJustFor( pAttributeName ) ) |
318 |
|
- |
{ |
|
273 |
+ |
private boolean alreadyIndexed( List<Index> pIndexes, String pAttributeName ) { |
|
274 |
+ |
for ( Index zIndex : pIndexes ) { |
|
275 |
+ |
if ( zIndex.isJustFor( pAttributeName ) ) { |
319 |
276 |
|
return true; |
320 |
277 |
|
} |
321 |
278 |
|
} |
322 |
279 |
|
return false; |
323 |
280 |
|
} |
324 |
281 |
|
|
325 |
|
- |
private List<Integer> getUniqueGroups( List<AttributeMetaData> pAttributes ) |
326 |
|
- |
{ |
|
282 |
+ |
private List<Integer> getUniqueGroups( List<AttributeMetaData> pAttributes ) { |
327 |
283 |
|
List<Integer> zUniqueGroups = new ArrayList<Integer>(); |
328 |
|
- |
for ( AttributeMetaData zAttribute : pAttributes ) |
329 |
|
- |
{ |
|
284 |
+ |
for ( AttributeMetaData zAttribute : pAttributes ) { |
330 |
285 |
|
Integer zGroupID = zAttribute.getPropertyManager().get_Integer( PMD_UniqueGroup.NAME, null ); |
331 |
|
- |
if ( zGroupID != null ) |
332 |
|
- |
{ |
333 |
|
- |
if ( zGroupID < 1 ) |
334 |
|
- |
{ |
|
286 |
+ |
if ( zGroupID != null ) { |
|
287 |
+ |
if ( zGroupID < 1 ) { |
335 |
288 |
|
throw new IllegalArgumentException( "Unique Group may only be Positive!" ); |
336 |
289 |
|
} |
337 |
|
- |
if ( !zUniqueGroups.contains( zGroupID ) ) |
338 |
|
- |
{ |
|
290 |
+ |
if ( !zUniqueGroups.contains( zGroupID ) ) { |
339 |
291 |
|
zUniqueGroups.add( zGroupID ); |
340 |
292 |
|
} |
341 |
293 |
|
} |
|
@@ -344,16 +296,14 @@ |
344 |
296 |
|
return zUniqueGroups; |
345 |
297 |
|
} |
346 |
298 |
|
|
347 |
|
- |
private static class Index |
348 |
|
- |
{ |
|
299 |
+ |
private static class Index { |
349 |
300 |
|
private String mTableName; |
350 |
301 |
|
private String mType; |
351 |
302 |
|
private int mNumber; |
352 |
303 |
|
private boolean mUnique; |
353 |
304 |
|
private List<String> mAttributeNames = new ArrayList<String>(); |
354 |
305 |
|
|
355 |
|
- |
public Index( String pTableName, String pType, int pNumber, boolean pUnique ) |
356 |
|
- |
{ |
|
306 |
+ |
public Index( String pTableName, String pType, int pNumber, boolean pUnique ) { |
357 |
307 |
|
mTableName = pTableName; |
358 |
308 |
|
mType = pType; |
359 |
309 |
|
mNumber = pNumber; |
|
@@ -361,33 +311,29 @@ |
361 |
311 |
|
} |
362 |
312 |
|
|
363 |
313 |
|
@Override |
364 |
|
- |
public String toString() |
365 |
|
- |
{ |
366 |
|
- |
StringBuilder sb = new StringBuilder().append( "new Index( \"" ).append( mTableName ).append( mType ).append( "IDX" ).append( mNumber ).append( "\", null, " ).append( mUnique ); |
367 |
|
- |
for ( String zAttributeName : mAttributeNames ) |
368 |
|
- |
{ |
|
314 |
+ |
public String toString() { |
|
315 |
+ |
StringBuilder sb = |
|
316 |
+ |
new StringBuilder().append( "new Index( \"" ).append( mTableName ).append( mType ).append( "IDX" ).append( mNumber ).append( "\", null, " ) |
|
317 |
+ |
.append( mUnique ); |
|
318 |
+ |
for ( String zAttributeName : mAttributeNames ) { |
369 |
319 |
|
sb.append( ", CD_" ).append( zAttributeName ); |
370 |
320 |
|
} |
371 |
321 |
|
return sb.append( " )" ).toString(); |
372 |
322 |
|
} |
373 |
323 |
|
|
374 |
|
- |
public Index addAttribute( String pName ) |
375 |
|
- |
{ |
|
324 |
+ |
public Index addAttribute( String pName ) { |
376 |
325 |
|
mAttributeNames.add( pName ); |
377 |
326 |
|
return this; |
378 |
327 |
|
} |
379 |
328 |
|
|
380 |
|
- |
public boolean isJustFor( String pAttributeName ) |
381 |
|
- |
{ |
|
329 |
+ |
public boolean isJustFor( String pAttributeName ) { |
382 |
330 |
|
return (mAttributeNames.size() == 1) && pAttributeName.equals( mAttributeNames.get( 0 ) ); |
383 |
331 |
|
} |
384 |
332 |
|
} |
385 |
333 |
|
|
386 |
|
- |
private void addMDattributes( String pFirstLine, String pPlus ) |
387 |
|
- |
{ |
|
334 |
+ |
private void addMDattributes( String pFirstLine, String pPlus ) { |
388 |
335 |
|
AttributeProxy[] zAttributes = getAttributes(); |
389 |
|
- |
if ( (zAttributes.length == 0) && (pPlus == null) ) |
390 |
|
- |
{ |
|
336 |
+ |
if ( (zAttributes.length == 0) && (pPlus == null) ) { |
391 |
337 |
|
addLine( pFirstLine + " );" ); |
392 |
338 |
|
return; |
393 |
339 |
|
} |
|
@@ -398,20 +344,17 @@ |
398 |
344 |
|
|
399 |
345 |
|
int zMaxLength = Strings.deNull( pPlus ).length(); |
400 |
346 |
|
|
401 |
|
- |
for ( AttributeProxy zAttribute : zAttributes ) |
402 |
|
- |
{ |
|
347 |
+ |
for ( AttributeProxy zAttribute : zAttributes ) { |
403 |
348 |
|
zMaxLength = Math.max( zMaxLength, zAttribute.getName().length() ); |
404 |
349 |
|
} |
405 |
350 |
|
|
406 |
351 |
|
CDhelper zHelper = new CDhelper( zMaxLength ); |
407 |
352 |
|
|
408 |
|
- |
if ( pPlus != null ) |
409 |
|
- |
{ |
|
353 |
+ |
if ( pPlus != null ) { |
410 |
354 |
|
zHelper.addCD( "", pPlus, false ); |
411 |
355 |
|
} |
412 |
356 |
|
|
413 |
|
- |
if ( zAttributes.length != 0 ) |
414 |
|
- |
{ |
|
357 |
+ |
if ( zAttributes.length != 0 ) { |
415 |
358 |
|
addCDs( zHelper, zAttributes, "", SELECT_ID ); |
416 |
359 |
|
addCDs( zHelper, zAttributes, "Injected", SELECT_INJECTED ); |
417 |
360 |
|
addCDs( zHelper, zAttributes, "Regular", SELECT_SIMPLE_REGULAR ); |
|
@@ -428,140 +371,109 @@ |
428 |
371 |
|
indentMinus( 7 ); |
429 |
372 |
|
} |
430 |
373 |
|
|
431 |
|
- |
private void addCDs( CDhelper pHelper, AttributeProxy[] pAttributes, String pSectionTitle, AttributeSelector pSelector ) |
432 |
|
- |
{ |
|
374 |
+ |
private void addCDs( CDhelper pHelper, AttributeProxy[] pAttributes, String pSectionTitle, AttributeSelector pSelector ) { |
433 |
375 |
|
addCDs( pHelper, pAttributes, pSectionTitle, pSelector, null ); |
434 |
376 |
|
} |
435 |
377 |
|
|
436 |
|
- |
private void addCDs( CDhelper pHelper, AttributeProxy[] pAttributes, String pSectionTitle, AttributeSelector pSelector, Boolean pRequired ) |
437 |
|
- |
{ |
438 |
|
- |
for ( AttributeProxy zAttribute : pAttributes ) |
439 |
|
- |
{ |
|
378 |
+ |
private void addCDs( CDhelper pHelper, AttributeProxy[] pAttributes, String pSectionTitle, AttributeSelector pSelector, Boolean pRequired ) { |
|
379 |
+ |
for ( AttributeProxy zAttribute : pAttributes ) { |
440 |
380 |
|
String zAttributeName = zAttribute.getName(); |
441 |
|
- |
if ( pHelper.notProcessed( zAttributeName ) && pSelector.selects( zAttribute ) ) |
442 |
|
- |
{ |
|
381 |
+ |
if ( pHelper.notProcessed( zAttributeName ) && pSelector.selects( zAttribute ) ) { |
443 |
382 |
|
pSectionTitle = pHelper.addCD( pSectionTitle, zAttributeName, (pRequired == null) ? zAttribute.isRequired() : pRequired ); |
444 |
383 |
|
} |
445 |
384 |
|
} |
446 |
385 |
|
} |
447 |
386 |
|
|
448 |
|
- |
private interface AttributeSelector |
449 |
|
- |
{ |
|
387 |
+ |
private interface AttributeSelector { |
450 |
388 |
|
boolean selects( AttributeProxy zAttribute ); |
451 |
389 |
|
} |
452 |
390 |
|
|
453 |
|
- |
public static final AttributeSelector SELECT_ID = new AttributeSelector() |
454 |
|
- |
{ |
|
391 |
+ |
public static final AttributeSelector SELECT_ID = new AttributeSelector() { |
455 |
392 |
|
@Override |
456 |
|
- |
public boolean selects( AttributeProxy pAttribute ) |
457 |
|
- |
{ |
|
393 |
+ |
public boolean selects( AttributeProxy pAttribute ) { |
458 |
394 |
|
return A_ID.TYPE.equals( pAttribute.getAttributeSetType() ); |
459 |
395 |
|
} |
460 |
396 |
|
}; |
461 |
397 |
|
|
462 |
|
- |
public static final AttributeSelector SELECT_INJECTED = new AttributeSelector() |
463 |
|
- |
{ |
|
398 |
+ |
public static final AttributeSelector SELECT_INJECTED = new AttributeSelector() { |
464 |
399 |
|
@Override |
465 |
|
- |
public boolean selects( AttributeProxy pAttribute ) |
466 |
|
- |
{ |
|
400 |
+ |
public boolean selects( AttributeProxy pAttribute ) { |
467 |
401 |
|
return pAttribute.isInjected(); |
468 |
402 |
|
} |
469 |
403 |
|
}; |
470 |
404 |
|
|
471 |
|
- |
public static final AttributeSelector SELECT_SIMPLE_REGULAR = new AttributeSelector() |
472 |
|
- |
{ |
|
405 |
+ |
public static final AttributeSelector SELECT_SIMPLE_REGULAR = new AttributeSelector() { |
473 |
406 |
|
@Override |
474 |
|
- |
public boolean selects( AttributeProxy pAttribute ) |
475 |
|
- |
{ |
|
407 |
+ |
public boolean selects( AttributeProxy pAttribute ) { |
476 |
408 |
|
return !pAttribute.isVirtual() && pAttribute.getAttributeSetType().getFAT().isSimple(); |
477 |
409 |
|
} |
478 |
410 |
|
}; |
479 |
411 |
|
|
480 |
|
- |
public static final AttributeSelector SELECT_SIMPLE_VIRTUAL = new AttributeSelector() |
481 |
|
- |
{ |
|
412 |
+ |
public static final AttributeSelector SELECT_SIMPLE_VIRTUAL = new AttributeSelector() { |
482 |
413 |
|
@Override |
483 |
|
- |
public boolean selects( AttributeProxy pAttribute ) |
484 |
|
- |
{ |
|
414 |
+ |
public boolean selects( AttributeProxy pAttribute ) { |
485 |
415 |
|
return pAttribute.isVirtual() && pAttribute.getAttributeSetType().getFAT().isSimple(); |
486 |
416 |
|
} |
487 |
417 |
|
}; |
488 |
418 |
|
|
489 |
|
- |
public static final AttributeSelector SELECT_BRIDGE = new AttributeSelector() |
490 |
|
- |
{ |
|
419 |
+ |
public static final AttributeSelector SELECT_BRIDGE = new AttributeSelector() { |
491 |
420 |
|
@Override |
492 |
|
- |
public boolean selects( AttributeProxy pAttribute ) |
493 |
|
- |
{ |
|
421 |
+ |
public boolean selects( AttributeProxy pAttribute ) { |
494 |
422 |
|
return Objects.isOneOf( pAttribute.getAttributeSetType(), BRIDGE_TYPES ); |
495 |
423 |
|
} |
496 |
424 |
|
}; |
497 |
425 |
|
|
498 |
|
- |
public static final AttributeSelector SELECT_PAIRED = new AttributeSelector() |
499 |
|
- |
{ |
|
426 |
+ |
public static final AttributeSelector SELECT_PAIRED = new AttributeSelector() { |
500 |
427 |
|
@Override |
501 |
|
- |
public boolean selects( AttributeProxy pAttribute ) |
502 |
|
- |
{ |
|
428 |
+ |
public boolean selects( AttributeProxy pAttribute ) { |
503 |
429 |
|
return Objects.isOneOf( pAttribute.getAttributeSetType(), PAIRED_TYPES ); |
504 |
430 |
|
} |
505 |
431 |
|
}; |
506 |
432 |
|
|
507 |
|
- |
public static final AttributeSelector SELECT_TOONE_REGULAR = new AttributeSelector() |
508 |
|
- |
{ |
|
433 |
+ |
public static final AttributeSelector SELECT_TOONE_REGULAR = new AttributeSelector() { |
509 |
434 |
|
@Override |
510 |
|
- |
public boolean selects( AttributeProxy pAttribute ) |
511 |
|
- |
{ |
|
435 |
+ |
public boolean selects( AttributeProxy pAttribute ) { |
512 |
436 |
|
return !pAttribute.isVirtual() && pAttribute.getAttributeSetType().getFAT().isToOne(); |
513 |
437 |
|
} |
514 |
438 |
|
}; |
515 |
439 |
|
|
516 |
|
- |
public static final AttributeSelector SELECT_TOONE_VIRTUAL = new AttributeSelector() |
517 |
|
- |
{ |
|
440 |
+ |
public static final AttributeSelector SELECT_TOONE_VIRTUAL = new AttributeSelector() { |
518 |
441 |
|
@Override |
519 |
|
- |
public boolean selects( AttributeProxy pAttribute ) |
520 |
|
- |
{ |
|
442 |
+ |
public boolean selects( AttributeProxy pAttribute ) { |
521 |
443 |
|
return pAttribute.isVirtual() && pAttribute.getAttributeSetType().getFAT().isToOne(); |
522 |
444 |
|
} |
523 |
445 |
|
}; |
524 |
446 |
|
|
525 |
|
- |
public static final AttributeSelector SELECT_TOMANY = new AttributeSelector() |
526 |
|
- |
{ |
|
447 |
+ |
public static final AttributeSelector SELECT_TOMANY = new AttributeSelector() { |
527 |
448 |
|
@Override |
528 |
|
- |
public boolean selects( AttributeProxy pAttribute ) |
529 |
|
- |
{ |
|
449 |
+ |
public boolean selects( AttributeProxy pAttribute ) { |
530 |
450 |
|
return pAttribute.getAttributeSetType().getFAT().isToMany(); |
531 |
451 |
|
} |
532 |
452 |
|
}; |
533 |
453 |
|
|
534 |
|
- |
public static final AttributeSelector SELECT_REMAINING = new AttributeSelector() |
535 |
|
- |
{ |
|
454 |
+ |
public static final AttributeSelector SELECT_REMAINING = new AttributeSelector() { |
536 |
455 |
|
@Override |
537 |
|
- |
public boolean selects( AttributeProxy pAttribute ) |
538 |
|
- |
{ |
|
456 |
+ |
public boolean selects( AttributeProxy pAttribute ) { |
539 |
457 |
|
return true; |
540 |
458 |
|
} |
541 |
459 |
|
}; |
542 |
460 |
|
|
543 |
|
- |
private class CDhelper |
544 |
|
- |
{ |
|
461 |
+ |
private class CDhelper { |
545 |
462 |
|
private Set<String> mNamesProcessed = new HashSet<String>(); |
546 |
463 |
|
private int mMaxLength; |
547 |
464 |
|
private String mSectionTitle = null; |
548 |
465 |
|
private String mPrevName = null; |
549 |
466 |
|
private boolean mPrevRequired; |
550 |
467 |
|
|
551 |
|
- |
public CDhelper( int pMaxLength ) |
552 |
|
- |
{ |
|
468 |
+ |
public CDhelper( int pMaxLength ) { |
553 |
469 |
|
mMaxLength = pMaxLength + 2; |
554 |
470 |
|
} |
555 |
471 |
|
|
556 |
|
- |
private void processPrev( boolean pMore ) |
557 |
|
- |
{ |
558 |
|
- |
if ( mPrevName != null ) |
559 |
|
- |
{ |
560 |
|
- |
if ( mSectionTitle != null ) |
561 |
|
- |
{ |
|
472 |
+ |
private void processPrev( boolean pMore ) { |
|
473 |
+ |
if ( mPrevName != null ) { |
|
474 |
+ |
if ( mSectionTitle != null ) { |
562 |
475 |
|
addBlankLine(); |
563 |
|
- |
if ( mSectionTitle.length() != 0 ) |
564 |
|
- |
{ |
|
476 |
+ |
if ( mSectionTitle.length() != 0 ) { |
565 |
477 |
|
addLine( "// " + mSectionTitle ); |
566 |
478 |
|
} |
567 |
479 |
|
mSectionTitle = null; |
|
@@ -570,33 +482,26 @@ |
570 |
482 |
|
sb.append( "CD_" ).append( mPrevName ); |
571 |
483 |
|
int zDots = mMaxLength - mPrevName.length(); |
572 |
484 |
|
mPrevName = null; |
573 |
|
- |
if ( pMore ) |
574 |
|
- |
{ |
|
485 |
+ |
if ( pMore ) { |
575 |
486 |
|
sb.append( ", /* " ); |
576 |
|
- |
} |
577 |
|
- |
else |
578 |
|
- |
{ |
|
487 |
+ |
} else { |
579 |
488 |
|
sb.append( " /* ." ); |
580 |
489 |
|
} |
581 |
|
- |
while ( zDots-- > 0 ) |
582 |
|
- |
{ |
|
490 |
+ |
while ( zDots-- > 0 ) { |
583 |
491 |
|
sb.append( '.' ); |
584 |
492 |
|
} |
585 |
|
- |
if ( mPrevRequired ) |
586 |
|
- |
{ |
|
493 |
+ |
if ( mPrevRequired ) { |
587 |
494 |
|
sb.append( " Required" ); |
588 |
495 |
|
} |
589 |
496 |
|
sb.append( " */" ); |
590 |
|
- |
if ( !pMore ) |
591 |
|
- |
{ |
|
497 |
+ |
if ( !pMore ) { |
592 |
498 |
|
sb.append( " );" ); |
593 |
499 |
|
} |
594 |
500 |
|
addLine( sb.toString() ); |
595 |
501 |
|
} |
596 |
502 |
|
} |
597 |
503 |
|
|
598 |
|
- |
public String addCD( String pSectionTitle, String pAttributeName, boolean pRequired ) |
599 |
|
- |
{ |
|
504 |
+ |
public String addCD( String pSectionTitle, String pAttributeName, boolean pRequired ) { |
600 |
505 |
|
processPrev( true ); |
601 |
506 |
|
mSectionTitle = pSectionTitle; |
602 |
507 |
|
mPrevName = pAttributeName; |
|
@@ -605,23 +510,19 @@ |
605 |
510 |
|
return null; |
606 |
511 |
|
} |
607 |
512 |
|
|
608 |
|
- |
public void fini() |
609 |
|
- |
{ |
|
513 |
+ |
public void fini() { |
610 |
514 |
|
processPrev( false ); |
611 |
515 |
|
} |
612 |
516 |
|
|
613 |
|
- |
public boolean notProcessed( String pAttributeName ) |
614 |
|
- |
{ |
|
517 |
+ |
public boolean notProcessed( String pAttributeName ) { |
615 |
518 |
|
return !mNamesProcessed.contains( pAttributeName ); |
616 |
519 |
|
} |
617 |
520 |
|
} |
618 |
521 |
|
|
619 |
522 |
|
@Override |
620 |
|
- |
protected void LLaddAttribute( AttributeProxy pAttribute ) |
621 |
|
- |
{ |
|
523 |
+ |
protected void LLaddAttribute( AttributeProxy pAttribute ) { |
622 |
524 |
|
FundamentalAttributeType zFAT = pAttribute.getAttributeSetType().getFAT(); |
623 |
|
- |
switch ( zFAT ) |
624 |
|
- |
{ |
|
525 |
+ |
switch ( zFAT ) { |
625 |
526 |
|
default: |
626 |
527 |
|
mErrorSinc.addError( "CurrentlyUnsupportedAttributeType FAT", "of: " + zFAT, pAttribute.toString(), mObjectMetaData.toStringForError() ); |
627 |
528 |
|
break; |
|
@@ -637,11 +538,9 @@ |
637 |
538 |
|
} |
638 |
539 |
|
} |
639 |
540 |
|
|
640 |
|
- |
private void addAttributeSimple( AttributeProxy pAttribute ) |
641 |
|
- |
{ |
|
541 |
+ |
private void addAttributeSimple( AttributeProxy pAttribute ) { |
642 |
542 |
|
Class zSimpleDataTypeClass = pAttribute.getSimpleDataType(); |
643 |
|
- |
if ( zSimpleDataTypeClass == null ) |
644 |
|
- |
{ |
|
543 |
+ |
if ( zSimpleDataTypeClass == null ) { |
645 |
544 |
|
mErrorSinc.addError( "CurrentlyUnsupportedAttributeType", pAttribute.toString(), mObjectMetaData.toStringForError() ); |
646 |
545 |
|
return; |
647 |
546 |
|
} |
|
@@ -650,11 +549,9 @@ |
650 |
549 |
|
|
651 |
550 |
|
String zDBtype = null; |
652 |
551 |
|
LiteSoftToJDBCtypeSupport zJDBCtypeSupport = !pAttribute.isVirtual() ? LiteSoftToJDBCtypeSupport.get( zSimpleDataTypeClass ) : null; |
653 |
|
- |
if ( (zJDBCtypeSupport != null) ) |
654 |
|
- |
{ |
|
552 |
+ |
if ( (zJDBCtypeSupport != null) ) { |
655 |
553 |
|
Class<?> zClass = zJDBCtypeSupport.getJDBC(); |
656 |
|
- |
if ( NonPersistable.class.equals( zClass ) ) |
657 |
|
- |
{ |
|
554 |
+ |
if ( NonPersistable.class.equals( zClass ) ) { |
658 |
555 |
|
mErrorSinc.addError( "CurrentlyUnsupportedAttributeType", pAttribute.toString(), mObjectMetaData.toStringForError() ); |
659 |
556 |
|
return; |
660 |
557 |
|
} |
|
@@ -668,13 +565,10 @@ |
668 |
565 |
|
String zNonImportableFeature = null; |
669 |
566 |
|
Mutability zMutability = pAttribute.getMutability(); |
670 |
567 |
|
AttributeType zAttributeType = pAttribute.getAttributeSetType(); |
671 |
|
- |
if ( A_ID.TYPE.equals( zAttributeType ) || pAttribute.isSysSetOnly() ) |
672 |
|
- |
{ |
|
568 |
+ |
if ( A_ID.TYPE.equals( zAttributeType ) || pAttribute.isSysSetOnly() ) { |
673 |
569 |
|
zNonImportableFeature = "NonImportableFeature"; |
674 |
570 |
|
zMutability = Mutability.RO; |
675 |
|
- |
} |
676 |
|
- |
else if ( pAttribute.getPropertyManager().get_boolean( PMD_CachedCalculatedValue.NAME ) ) |
677 |
|
- |
{ |
|
571 |
+ |
} else if ( pAttribute.getPropertyManager().get_boolean( PMD_CachedCalculatedValue.NAME ) ) { |
678 |
572 |
|
zNonImportableFeature = "NonImportableFeature"; |
679 |
573 |
|
} |
680 |
574 |
|
|
|
@@ -685,8 +579,7 @@ |
685 |
579 |
|
|
686 |
580 |
|
String zCharacterCaseIgnored = PMD_Case.IGNORED.equals( zCaseControl ) ? "CharacterCaseIgnored" : null; |
687 |
581 |
|
|
688 |
|
- |
if ( pAttribute.isVirtual() ) |
689 |
|
- |
{ |
|
582 |
+ |
if ( pAttribute.isVirtual() ) { |
690 |
583 |
|
addNotes( zNotes ); |
691 |
584 |
|
zExtends = "Virtual"; |
692 |
585 |
|
addAbstractMethodPublic( zSimpleDataType, "get" + zName ); |
|
@@ -695,8 +588,7 @@ |
695 |
588 |
|
addAbstractMethodProtected( "void", "LLclear" + zName ); |
696 |
589 |
|
addBlankLine(); |
697 |
590 |
|
|
698 |
|
- |
if ( !Mutability.RO.equals( zMutability ) ) |
699 |
|
- |
{ |
|
591 |
+ |
if ( !Mutability.RO.equals( zMutability ) ) { |
700 |
592 |
|
addAbstractMethodProtected( "void", "LLset" + zName, zSimpleDataType + " p" + zName ); |
701 |
593 |
|
addBlankLine(); |
702 |
594 |
|
|
|
@@ -705,17 +597,12 @@ |
705 |
597 |
|
addLine( "LLset" + zName + "( p" + zName + ");" ); |
706 |
598 |
|
addMethodEnd(); |
707 |
599 |
|
} |
708 |
|
- |
} |
709 |
|
- |
else |
710 |
|
- |
{ |
|
600 |
+ |
} else { |
711 |
601 |
|
zExtends = "Persisted"; |
712 |
602 |
|
|
713 |
|
- |
if ( zJDBCtypeSupport == null ) |
714 |
|
- |
{ |
|
603 |
+ |
if ( zJDBCtypeSupport == null ) { |
715 |
604 |
|
addLine( "private " + zSimpleDataType + " m" + zName + ";" + (zEncrypted ? " // Encrypted" : "") ); |
716 |
|
- |
} |
717 |
|
- |
else |
718 |
|
- |
{ |
|
605 |
+ |
} else { |
719 |
606 |
|
String zLazyEvalName = zJDBCtypeSupport.getLazyEval().getName(); |
720 |
607 |
|
addLine( "final " + zLazyEvalName + " m" + zName + " = new " + zLazyEvalName + "();" ); |
721 |
608 |
|
} |
|
@@ -723,14 +610,10 @@ |
723 |
610 |
|
|
724 |
611 |
|
addNotes( zNotes ); |
725 |
612 |
|
addMethodPublic( zSimpleDataType, "get" + zName ); |
726 |
|
- |
if ( zJDBCtypeSupport != null ) |
727 |
|
- |
{ |
|
613 |
+ |
if ( zJDBCtypeSupport != null ) { |
728 |
614 |
|
addLine( "return m" + zName + ".get" + zSimpleDataTypeSimpleName + "();" ); |
729 |
|
- |
} |
730 |
|
- |
else |
731 |
|
- |
{ |
732 |
|
- |
if ( zEncrypted ) |
733 |
|
- |
{ |
|
615 |
+ |
} else { |
|
616 |
+ |
if ( zEncrypted ) { |
734 |
617 |
|
addLine( "return fromEncrypted( LLget" + zName + "() );" ); |
735 |
618 |
|
addMethodEnd(); |
736 |
619 |
|
|
|
@@ -740,40 +623,28 @@ |
740 |
623 |
|
} |
741 |
624 |
|
addMethodEnd(); |
742 |
625 |
|
|
743 |
|
- |
if ( Mutability.RO.equals( zMutability ) ) |
744 |
|
- |
{ |
|
626 |
+ |
if ( Mutability.RO.equals( zMutability ) ) { |
745 |
627 |
|
addMethodProtected( "void", "LLset" + zName, zSimpleDataType + " p" + zName ); |
746 |
|
- |
} |
747 |
|
- |
else |
748 |
|
- |
{ |
|
628 |
+ |
} else { |
749 |
629 |
|
addMethodPublic( "void", "set" + zName, zSimpleDataType + " p" + zName ); |
750 |
|
- |
if ( zEncrypted ) |
751 |
|
- |
{ |
|
630 |
+ |
if ( zEncrypted ) { |
752 |
631 |
|
addLine( "LLset" + zName + "( toEncrypted( p" + zName + " ) );" ); |
753 |
632 |
|
addMethodEnd(); |
754 |
633 |
|
|
755 |
634 |
|
addMethodProtected( "void", "LLset" + zName, zSimpleDataType + " p" + zName ); |
756 |
635 |
|
} |
757 |
636 |
|
} |
758 |
|
- |
if ( zJDBCtypeSupport == null ) |
759 |
|
- |
{ |
|
637 |
+ |
if ( zJDBCtypeSupport == null ) { |
760 |
638 |
|
addLine( "verifyMutability( CD_" + zName + ", m" + zName + ", p" + zName + " );" ); |
761 |
639 |
|
|
762 |
|
- |
if ( PMD_Case.UPPERED.equals( zCaseControl ) ) |
763 |
|
- |
{ |
|
640 |
+ |
if ( PMD_Case.UPPERED.equals( zCaseControl ) ) { |
764 |
641 |
|
addLine( "m" + zName + " = toUpperCase( p" + zName + " );" ); |
765 |
|
- |
} |
766 |
|
- |
else if ( PMD_Case.LOWERED.equals( zCaseControl ) ) |
767 |
|
- |
{ |
|
642 |
+ |
} else if ( PMD_Case.LOWERED.equals( zCaseControl ) ) { |
768 |
643 |
|
addLine( "m" + zName + " = toLowerCase( p" + zName + " );" ); |
769 |
|
- |
} |
770 |
|
- |
else |
771 |
|
- |
{ |
|
644 |
+ |
} else { |
772 |
645 |
|
addLine( "m" + zName + " = p" + zName + ";" ); |
773 |
646 |
|
} |
774 |
|
- |
} |
775 |
|
- |
else |
776 |
|
- |
{ |
|
647 |
+ |
} else { |
777 |
648 |
|
addLine( "verifyMutability( CD_" + zName + ", m" + zName + ".get" + zSimpleDataTypeSimpleName + "(), p" + zName + " );" ); |
778 |
649 |
|
addLine( "m" + zName + ".set" + zSimpleDataTypeSimpleName + "( p" + zName + " );" ); |
779 |
650 |
|
} |
|
@@ -781,28 +652,25 @@ |
781 |
652 |
|
} |
782 |
653 |
|
makeClassPrivate(); |
783 |
654 |
|
makeClassStatic(); |
784 |
|
- |
zExtends = "AttributeAccessorSCDsimple" + zExtends + (Mutability.RO.equals( zMutability ) ? (pAttribute.isSysSetOnly() ? "SysSetOnly" : "ReadOnly") : "Regular"); |
|
655 |
+ |
zExtends = "AttributeAccessorSCDsimple" + zExtends + |
|
656 |
+ |
(Mutability.RO.equals( zMutability ) ? (pAttribute.isSysSetOnly() ? "SysSetOnly" : "ReadOnly") : "Regular"); |
785 |
657 |
|
zExtends += "<" + mObjectName + ">"; |
786 |
658 |
|
addClassDefinition( "AttributeAccessor_" + zName, zExtends, zNonImportableFeature, zCharacterCaseIgnored ); |
787 |
659 |
|
|
788 |
660 |
|
addConstructorPublic( "AttributeAccessor_" + zName ); |
789 |
661 |
|
String zBaseLine = "super( \"" + zName + "\""; |
790 |
|
- |
if ( !pAttribute.isVirtual() ) |
791 |
|
- |
{ |
|
662 |
+ |
if ( !pAttribute.isVirtual() ) { |
792 |
663 |
|
zBaseLine += ", \"" + pAttribute.getColumnName() + "\""; |
793 |
664 |
|
} |
794 |
665 |
|
String zTypeExtra = createAttributeTypedCall( pAttribute, "PO", zBaseLine, ";" ); |
795 |
666 |
|
addMethodEnd(); |
796 |
667 |
|
|
797 |
|
- |
if ( !Mutability.RO.equals( zMutability ) ) |
798 |
|
- |
{ |
|
668 |
+ |
if ( !Mutability.RO.equals( zMutability ) ) { |
799 |
669 |
|
String zDefaultValue = pAttribute.getPropertyManager().get_String( PMD_DefaultValue.NAME, null ); |
800 |
|
- |
if ( zDefaultValue != null ) |
801 |
|
- |
{ |
|
670 |
+ |
if ( zDefaultValue != null ) { |
802 |
671 |
|
addLine( "@Override" ); |
803 |
672 |
|
addMethodPublic( "Object", "getDefault" ); |
804 |
|
- |
if ( pAttribute.getBoAttributeType().dataNeedsQuoting() ) |
805 |
|
- |
{ |
|
673 |
+ |
if ( pAttribute.getBoAttributeType().dataNeedsQuoting() ) { |
806 |
674 |
|
zDefaultValue = quote( zDefaultValue ); |
807 |
675 |
|
} |
808 |
676 |
|
addLine( "return " + zDefaultValue + ";" ); |
|
@@ -814,10 +682,8 @@ |
814 |
682 |
|
addMethodPublic( "Object", "getValueOnPO", mObjectName + " pPO" ); |
815 |
683 |
|
addLine( "return pPO.get" + zName + "();" ); |
816 |
684 |
|
|
817 |
|
- |
if ( pAttribute.isVirtual() ) |
818 |
|
- |
{ |
819 |
|
- |
if ( !Mutability.RO.equals( zMutability ) ) |
820 |
|
- |
{ |
|
685 |
+ |
if ( pAttribute.isVirtual() ) { |
|
686 |
+ |
if ( !Mutability.RO.equals( zMutability ) ) { |
821 |
687 |
|
addMethodEnd(); |
822 |
688 |
|
addLine( "@Override" ); |
823 |
689 |
|
addMethodPublic( "void", "setValueOnPO", mObjectName + " pPO", "Object pValue" ); |
|
@@ -828,25 +694,19 @@ |
828 |
694 |
|
addLine( "@Override" ); |
829 |
695 |
|
addMethodProtected( "void", "LL_clearVirtualValueOnPO", mObjectName + " pPO" ); |
830 |
696 |
|
addLine( "pPO.LLclear" + zName + "();" ); |
831 |
|
- |
} |
832 |
|
- |
else if ( zJDBCtypeSupport == null ) |
833 |
|
- |
{ |
834 |
|
- |
if ( Mutability.RO.equals( zMutability ) ) |
835 |
|
- |
{ |
|
697 |
+ |
} else if ( zJDBCtypeSupport == null ) { |
|
698 |
+ |
if ( Mutability.RO.equals( zMutability ) ) { |
836 |
699 |
|
addMethodEnd(); |
837 |
700 |
|
addLine( "@Override" ); |
838 |
701 |
|
addMethodPublic( "void", "db_setValueOnPO", mObjectName + " pPO", "Object pValue" ); |
839 |
702 |
|
addLine( "pPO.LLset" + zName + "( to_" + zSimpleDataTypeSimpleName + "( " + zTypeExtra + "pValue ) );" ); |
840 |
|
- |
} |
841 |
|
- |
else |
842 |
|
- |
{ |
|
703 |
+ |
} else { |
843 |
704 |
|
addMethodEnd(); |
844 |
705 |
|
addLine( "@Override" ); |
845 |
706 |
|
addMethodPublic( "void", "setValueOnPO", mObjectName + " pPO", "Object pValue" ); |
846 |
707 |
|
addLine( "pPO.set" + zName + "( to_" + zSimpleDataTypeSimpleName + "( " + zTypeExtra + "pValue ) );" ); |
847 |
708 |
|
|
848 |
|
- |
if ( zEncrypted ) |
849 |
|
- |
{ |
|
709 |
+ |
if ( zEncrypted ) { |
850 |
710 |
|
addMethodEnd(); |
851 |
711 |
|
addLine( "@Override" ); |
852 |
712 |
|
addMethodPublic( "Object", "db_getValueOnPO", mObjectName + " pPO" ); |
|
@@ -858,11 +718,8 @@ |
858 |
718 |
|
addLine( "pPO.LLset" + zName + "( to_" + zSimpleDataTypeSimpleName + "( pValue ) );" ); |
859 |
719 |
|
} |
860 |
720 |
|
} |
861 |
|
- |
} |
862 |
|
- |
else |
863 |
|
- |
{ |
864 |
|
- |
if ( !Mutability.RO.equals( zMutability ) ) |
865 |
|
- |
{ |
|
721 |
+ |
} else { |
|
722 |
+ |
if ( !Mutability.RO.equals( zMutability ) ) { |
866 |
723 |
|
addMethodEnd(); |
867 |
724 |
|
addLine( "@Override" ); |
868 |
725 |
|
addMethodPublic( "void", "setValueOnPO", mObjectName + " pPO", "Object pValue" ); |
|
@@ -882,54 +739,44 @@ |
882 |
739 |
|
addClassEnd(); |
883 |
740 |
|
} |
884 |
741 |
|
|
885 |
|
- |
private void addAttributeToOne( AttributeProxy pAttribute ) |
886 |
|
- |
{ |
887 |
|
- |
if ( pAttribute.isVirtual() ) |
888 |
|
- |
{ |
|
742 |
+ |
private void addAttributeToOne( AttributeProxy pAttribute ) { |
|
743 |
+ |
if ( pAttribute.isVirtual() ) { |
889 |
744 |
|
addAttributeToOneVirtual( pAttribute ); |
890 |
745 |
|
return; |
891 |
746 |
|
} |
892 |
747 |
|
AttributeType zType = pAttribute.getAttributeSetType(); |
893 |
|
- |
if ( A_Blob.TYPE.equals( zType ) ) |
894 |
|
- |
{ |
|
748 |
+ |
if ( A_Blob.TYPE.equals( zType ) ) { |
895 |
749 |
|
addAttributeToBlob( pAttribute ); |
896 |
750 |
|
return; |
897 |
751 |
|
} |
898 |
|
- |
if ( A_CommonPairedToOne.TYPE.equals( zType ) ) |
899 |
|
- |
{ |
|
752 |
+ |
if ( A_CommonPairedToOne.TYPE.equals( zType ) ) { |
900 |
753 |
|
addAttributeToOneCommonPaired( pAttribute ); |
901 |
754 |
|
return; |
902 |
755 |
|
} |
903 |
|
- |
if ( A_PairedToOne.TYPE.equals( zType ) ) |
904 |
|
- |
{ |
|
756 |
+ |
if ( A_PairedToOne.TYPE.equals( zType ) ) { |
905 |
757 |
|
addAttributeToOnePaired( pAttribute ); |
906 |
758 |
|
return; |
907 |
759 |
|
} |
908 |
|
- |
if ( A_ToOne.TYPE.equals( zType ) ) |
909 |
|
- |
{ |
|
760 |
+ |
if ( A_ToOne.TYPE.equals( zType ) ) { |
910 |
761 |
|
addAttributeToOneRegular( pAttribute ); |
911 |
762 |
|
return; |
912 |
763 |
|
} |
913 |
|
- |
if ( A_VariableBridgeToOneLeft.TYPE.equals( zType ) ) |
914 |
|
- |
{ |
|
764 |
+ |
if ( A_VariableBridgeToOneLeft.TYPE.equals( zType ) ) { |
915 |
765 |
|
addAttributeToOneVariableBridgeLeft( pAttribute ); |
916 |
766 |
|
return; |
917 |
767 |
|
} |
918 |
|
- |
if ( A_VariableToOne.TYPE.equals( zType ) ) |
919 |
|
- |
{ |
|
768 |
+ |
if ( A_VariableToOne.TYPE.equals( zType ) ) { |
920 |
769 |
|
addAttributeToOneVariable( pAttribute ); |
921 |
770 |
|
return; |
922 |
771 |
|
} |
923 |
|
- |
if ( A_BridgeToOneLeft.TYPE.equals( zType ) || A_BridgeToOneRight.TYPE.equals( zType ) ) |
924 |
|
- |
{ |
|
772 |
+ |
if ( A_BridgeToOneLeft.TYPE.equals( zType ) || A_BridgeToOneRight.TYPE.equals( zType ) ) { |
925 |
773 |
|
addAttributeToOneBridge( pAttribute ); |
926 |
774 |
|
return; |
927 |
775 |
|
} |
928 |
776 |
|
throw new Error( "Currently Unsupported To One Type: " + zType + " on " + pAttribute + " on " + mObjectName ); |
929 |
777 |
|
} |
930 |
778 |
|
|
931 |
|
- |
private void addToOneRegular( AttributeProxy pAttribute, boolean pRequired, boolean pCascadeDeleteThem ) |
932 |
|
- |
{ |
|
779 |
+ |
private void addToOneRegular( AttributeProxy pAttribute, boolean pRequired, boolean pCascadeDeleteThem ) { |
933 |
780 |
|
String zName = pAttribute.getName(); |
934 |
781 |
|
String zToOne = Objects.justClassNameIfPackage( pAttribute.getToOneFullyQualifiedName(), mPackage + "." ); |
935 |
782 |
|
String zGenericType = "<" + mObjectName + "," + zToOne + ">"; |
|
@@ -947,8 +794,7 @@ |
947 |
794 |
|
addMethodEnd(); |
948 |
795 |
|
|
949 |
796 |
|
Mutability zMutability = pAttribute.getMutability(); |
950 |
|
- |
if ( !Mutability.RO.equals( zMutability ) ) |
951 |
|
- |
{ |
|
797 |
+ |
if ( !Mutability.RO.equals( zMutability ) ) { |
952 |
798 |
|
addMethodPublic( "void", "set" + zName, zToOne + " p" + zName ); |
953 |
799 |
|
addLine( "processLazyLoadMutation( m" + zName + ", p" + zName + " );" ); |
954 |
800 |
|
addMethodEnd(); |
|
@@ -977,12 +823,9 @@ |
977 |
823 |
|
addLine( "@Override" ); |
978 |
824 |
|
addMethodPublic( "void", "setValueOnPO", mObjectName + " pPO", "Object pValue" ); |
979 |
825 |
|
|
980 |
|
- |
if ( Mutability.RO.equals( zMutability ) ) |
981 |
|
- |
{ |
|
826 |
+ |
if ( Mutability.RO.equals( zMutability ) ) { |
982 |
827 |
|
addLine( "throw new UnsupportedOperationException( \"'" + zName + "' is Read Only\" );" ); |
983 |
|
- |
} |
984 |
|
- |
else |
985 |
|
- |
{ |
|
828 |
+ |
} else { |
986 |
829 |
|
addLine( "pPO.set" + zName + "( to_PO( pPO, " + zToOne + ".class, pValue ) );" ); |
987 |
830 |
|
} |
988 |
831 |
|
addMethodEnd(); |
|
@@ -998,8 +841,7 @@ |
998 |
841 |
|
addClassEnd(); |
999 |
842 |
|
} |
1000 |
843 |
|
|
1001 |
|
- |
private void addToOneVariable( AttributeProxy pAttribute, boolean pRequired ) |
1002 |
|
- |
{ |
|
844 |
+ |
private void addToOneVariable( AttributeProxy pAttribute, boolean pRequired ) { |
1003 |
845 |
|
String zName = pAttribute.getName(); |
1004 |
846 |
|
String zGeneraicType = "<" + mObjectName + ">"; |
1005 |
847 |
|
String zAAtype = "AttributeAccessorSCDtoOneVariable" + zGeneraicType; |
|
@@ -1037,8 +879,7 @@ |
1037 |
879 |
|
addClassEnd(); |
1038 |
880 |
|
} |
1039 |
881 |
|
|
1040 |
|
- |
private void addAttributeToOneVirtual( AttributeProxy pAttribute ) |
1041 |
|
- |
{ |
|
882 |
+ |
private void addAttributeToOneVirtual( AttributeProxy pAttribute ) { |
1042 |
883 |
|
String zName = pAttribute.getName(); |
1043 |
884 |
|
String zToOne = Objects.justClassNameIfPackage( pAttribute.getToOneFullyQualifiedName(), mPackage + "." ); |
1044 |
885 |
|
String zGenericType = "<" + mObjectName + "," + zToOne + ">"; |
|
@@ -1053,8 +894,7 @@ |
1053 |
894 |
|
addBlankLine(); |
1054 |
895 |
|
|
1055 |
896 |
|
Mutability zMutability = pAttribute.getMutability(); |
1056 |
|
- |
if ( !Mutability.RO.equals( zMutability ) ) |
1057 |
|
- |
{ |
|
897 |
+ |
if ( !Mutability.RO.equals( zMutability ) ) { |
1058 |
898 |
|
addAbstractMethodProtected( "void", "LLset" + zName, zToOne + " p" + zName ); |
1059 |
899 |
|
addBlankLine(); |
1060 |
900 |
|
|
|
@@ -1080,12 +920,9 @@ |
1080 |
920 |
|
addLine( "@Override" ); |
1081 |
921 |
|
addMethodPublic( "void", "setValueOnPO", mObjectName + " pPO", "Object pValue" ); |
1082 |
922 |
|
|
1083 |
|
- |
if ( Mutability.RO.equals( zMutability ) ) |
1084 |
|
- |
{ |
|
923 |
+ |
if ( Mutability.RO.equals( zMutability ) ) { |
1085 |
924 |
|
addLine( "throw new UnsupportedOperationException( \"'" + zName + "' is Read Only\" );" ); |
1086 |
|
- |
} |
1087 |
|
- |
else |
1088 |
|
- |
{ |
|
925 |
+ |
} else { |
1089 |
926 |
|
addLine( "pPO.set" + zName + "( to_PO( pPO, " + zToOne + ".class, pValue ) );" ); |
1090 |
927 |
|
} |
1091 |
928 |
|
addMethodEnd(); |
|
@@ -1097,14 +934,12 @@ |
1097 |
934 |
|
addClassEnd(); |
1098 |
935 |
|
} |
1099 |
936 |
|
|
1100 |
|
- |
private void addAttributeToBlob( AttributeProxy pAttribute ) |
1101 |
|
- |
{ |
|
937 |
+ |
private void addAttributeToBlob( AttributeProxy pAttribute ) { |
1102 |
938 |
|
// A_Blob.TYPE, pPersisted |
1103 |
939 |
|
throw new Error( "Blob's can not currently be generated for " + pAttribute + " on " + mObjectName ); |
1104 |
940 |
|
} |
1105 |
941 |
|
|
1106 |
|
- |
private void addAttributeToOneCommonPaired( AttributeProxy pAttribute ) |
1107 |
|
- |
{ |
|
942 |
+ |
private void addAttributeToOneCommonPaired( AttributeProxy pAttribute ) { |
1108 |
943 |
|
// A_CommonPairedToOne.TYPE, pPersisted - String (To ObjectName) PMD_UniqueGroup, PMD_ColumnName, implicitly Required! & Changeable? |
1109 |
944 |
|
String zName = pAttribute.getName(); |
1110 |
945 |
|
String zGenericType = "<" + mObjectName + ">"; |
|
@@ -1125,7 +960,8 @@ |
1125 |
960 |
|
addLine( "processLazyLoadMutation( m" + zName + ", p" + zName + " );" ); |
1126 |
961 |
|
addMethodEnd(); |
1127 |
962 |
|
|
1128 |
|
- |
addMethodProtected( "void", "replacing" + zName, "org.litesoft.orsup.nonpublic.PersistentObjectImpl pOld" + zName, "org.litesoft.orsup.nonpublic.PersistentObjectImpl pNew" + zName ); |
|
963 |
+ |
addMethodProtected( "void", "replacing" + zName, "org.litesoft.orsup.nonpublic.PersistentObjectImpl pOld" + zName, |
|
964 |
+ |
"org.litesoft.orsup.nonpublic.PersistentObjectImpl pNew" + zName ); |
1129 |
965 |
|
addMethodEnd(); |
1130 |
966 |
|
|
1131 |
967 |
|
makeClassPrivate(); |
|
@@ -1152,14 +988,14 @@ |
1152 |
988 |
|
addMethodEnd(); |
1153 |
989 |
|
|
1154 |
990 |
|
addLine( "@Override" ); |
1155 |
|
- |
addMethodPublic( "void", "pairReplaced", mObjectName + " pPO", "org.litesoft.orsup.nonpublic.PersistentObjectImpl pOld" + zName, "org.litesoft.orsup.nonpublic.PersistentObjectImpl pNew" + zName ); |
|
991 |
+ |
addMethodPublic( "void", "pairReplaced", mObjectName + " pPO", "org.litesoft.orsup.nonpublic.PersistentObjectImpl pOld" + zName, |
|
992 |
+ |
"org.litesoft.orsup.nonpublic.PersistentObjectImpl pNew" + zName ); |
1156 |
993 |
|
addLine( "pPO.replacing" + zName + "( pOld" + zName + ", pNew" + zName + " );" ); |
1157 |
994 |
|
addBlockEnd(); |
1158 |
995 |
|
addClassEnd(); |
1159 |
996 |
|
} |
1160 |
997 |
|
|
1161 |
|
- |
private void addAttributeToOnePaired( AttributeProxy pAttribute ) |
1162 |
|
- |
{ |
|
998 |
+ |
private void addAttributeToOnePaired( AttributeProxy pAttribute ) { |
1163 |
999 |
|
// A_PairedToOne.TYPE, pPersisted - Not Really Persisted - MetaData Driven for Object Reference; |
1164 |
1000 |
|
String zName = pAttribute.getName(); |
1165 |
1001 |
|
String zToOne = Objects.justClassNameIfPackage( pAttribute.getToOneFullyQualifiedName(), mPackage + "." ); |
|
@@ -1197,62 +1033,51 @@ |
1197 |
1033 |
|
addClassEnd(); |
1198 |
1034 |
|
} |
1199 |
1035 |
|
|
1200 |
|
- |
private void addAttributeToOneRegular( AttributeProxy pAttribute ) |
1201 |
|
- |
{ |
|
1036 |
+ |
private void addAttributeToOneRegular( AttributeProxy pAttribute ) { |
1202 |
1037 |
|
addToOneRegular( pAttribute, pAttribute.isRequired(), pAttribute.getPropertyManager().get_boolean( PMD_CascadeDeleteThem.NAME ) ); |
1203 |
1038 |
|
} |
1204 |
1039 |
|
|
1205 |
|
- |
private void addAttributeToOneVariable( AttributeProxy pAttribute ) |
1206 |
|
- |
{ |
|
1040 |
+ |
private void addAttributeToOneVariable( AttributeProxy pAttribute ) { |
1207 |
1041 |
|
addToOneVariable( pAttribute, pAttribute.isRequired() ); // todo: , pAttribute.getPropertyManager().get_boolean( PMD_CascadeDeleteThem.NAME ) ); |
1208 |
1042 |
|
} |
1209 |
1043 |
|
|
1210 |
|
- |
private void addAttributeToOneBridge( AttributeProxy pAttribute ) |
1211 |
|
- |
{ |
|
1044 |
+ |
private void addAttributeToOneBridge( AttributeProxy pAttribute ) { |
1212 |
1045 |
|
// A_BridgeToOneRight.TYPE, pPersisted |
1213 |
1046 |
|
// A_BridgeToOneLeft.TYPE, pPersisted |
1214 |
1047 |
|
addToOneRegular( pAttribute, true, false ); |
1215 |
1048 |
|
} |
1216 |
1049 |
|
|
1217 |
|
- |
private void addAttributeToOneVariableBridgeLeft( AttributeProxy pAttribute ) |
1218 |
|
- |
{ |
|
1050 |
+ |
private void addAttributeToOneVariableBridgeLeft( AttributeProxy pAttribute ) { |
1219 |
1051 |
|
addToOneVariable( pAttribute, true ); |
1220 |
1052 |
|
} |
1221 |
1053 |
|
|
1222 |
|
- |
private void addAttributeToMany( AttributeProxy pAttribute ) |
1223 |
|
- |
{ |
1224 |
|
- |
if ( pAttribute.isVirtual() ) |
1225 |
|
- |
{ |
|
1054 |
+ |
private void addAttributeToMany( AttributeProxy pAttribute ) { |
|
1055 |
+ |
if ( pAttribute.isVirtual() ) { |
1226 |
1056 |
|
addAttributeToManyVirtual( pAttribute ); |
1227 |
1057 |
|
return; |
1228 |
1058 |
|
} |
1229 |
1059 |
|
AttributeProxy pBackReferenceAttributeProxy = pAttribute.getToManyBackReferenceAttributeProxy(); |
1230 |
1060 |
|
AttributeType zBackType = (pBackReferenceAttributeProxy != null) ? pBackReferenceAttributeProxy.getAttributeSetType() : null; |
1231 |
|
- |
if ( A_ToOne.TYPE.equals( zBackType ) ) |
1232 |
|
- |
{ |
|
1061 |
+ |
if ( A_ToOne.TYPE.equals( zBackType ) ) { |
1233 |
1062 |
|
addAttributeToManyRegular( pAttribute ); |
1234 |
1063 |
|
return; |
1235 |
1064 |
|
} |
1236 |
|
- |
if ( A_VariableBridgeToOneLeft.TYPE.equals( zBackType ) ) |
1237 |
|
- |
{ |
|
1065 |
+ |
if ( A_VariableBridgeToOneLeft.TYPE.equals( zBackType ) ) { |
1238 |
1066 |
|
addAttributeToManyVariableBridgeLeft( pAttribute ); |
1239 |
1067 |
|
return; |
1240 |
1068 |
|
} |
1241 |
|
- |
if ( A_VariableToOne.TYPE.equals( zBackType ) ) |
1242 |
|
- |
{ |
|
1069 |
+ |
if ( A_VariableToOne.TYPE.equals( zBackType ) ) { |
1243 |
1070 |
|
addAttributeToManyVariable( pAttribute ); |
1244 |
1071 |
|
return; |
1245 |
1072 |
|
} |
1246 |
|
- |
if ( A_BridgeToOneLeft.TYPE.equals( zBackType ) || A_BridgeToOneRight.TYPE.equals( zBackType ) ) |
1247 |
|
- |
{ |
|
1073 |
+ |
if ( A_BridgeToOneLeft.TYPE.equals( zBackType ) || A_BridgeToOneRight.TYPE.equals( zBackType ) ) { |
1248 |
1074 |
|
addAttributeToManyBridge( pAttribute ); |
1249 |
1075 |
|
return; |
1250 |
1076 |
|
} |
1251 |
1077 |
|
throw new Error( "Currently Unsupported To Many, Back Type: " + zBackType + " on " + pAttribute + " on " + mObjectName ); |
1252 |
1078 |
|
} |
1253 |
1079 |
|
|
1254 |
|
- |
private void addToMany( String pForm, AttributeProxy pAttribute, boolean pCascadeDeleteThem ) |
1255 |
|
- |
{ |
|
1080 |
+ |
private void addToMany( String pForm, AttributeProxy pAttribute, boolean pCascadeDeleteThem ) { |
1256 |
1081 |
|
String zName = pAttribute.getName(); |
1257 |
1082 |
|
String zToMany = Objects.justClassNameIfPackage( pAttribute.getToManyFullyQualifiedName(), mPackage + "." ); |
1258 |
1083 |
|
String zGenericType = "<" + mObjectName + "," + zToMany + ">"; |
|
@@ -1270,8 +1095,7 @@ |
1270 |
1095 |
|
addMethodEnd(); |
1271 |
1096 |
|
|
1272 |
1097 |
|
Mutability zMutability = pAttribute.getMutability(); |
1273 |
|
- |
if ( !Mutability.RO.equals( zMutability ) ) |
1274 |
|
- |
{ |
|
1098 |
+ |
if ( !Mutability.RO.equals( zMutability ) ) { |
1275 |
1099 |
|
addMethodPublic( "void", "set" + zName, "java.util.List<" + zToMany + "> p" + zName ); |
1276 |
1100 |
|
addLine( "processLazyLoadMutation( m" + zName + ", p" + zName + " );" ); |
1277 |
1101 |
|
addMethodEnd(); |
|
@@ -1292,19 +1116,15 @@ |
1292 |
1116 |
|
addConstructorPublic( "AttributeAccessor_" + zName ); |
1293 |
1117 |
|
|
1294 |
1118 |
|
String zOrderBy = Strings.noEmpty( pAttribute.getPropertyManager().get_String( PMD_OrderByAttribute.NAME, null ) ); |
1295 |
|
- |
if ( zOrderBy != null ) |
1296 |
|
- |
{ |
|
1119 |
+ |
if ( zOrderBy != null ) { |
1297 |
1120 |
|
zOrderBy = "\"" + zOrderBy + "\""; |
1298 |
1121 |
|
} |
1299 |
|
- |
if ( "Variable".equals( pForm ) ) |
1300 |
|
- |
{ |
|
1122 |
+ |
if ( "Variable".equals( pForm ) ) { |
1301 |
1123 |
|
addLine( "super( \"" + zName + "\", " + zToMany + ".class, \"" + pAttribute.getToManyBackReference() + "\", " + // |
1302 |
1124 |
|
zOrderBy + ", " + // |
1303 |
1125 |
|
pCascadeDeleteThem + ", " + pAttribute.isRequired() + ", " + // |
1304 |
1126 |
|
"Mutability." + zMutability + " );" ); |
1305 |
|
- |
} |
1306 |
|
- |
else |
1307 |
|
- |
{ |
|
1127 |
+ |
} else { |
1308 |
1128 |
|
addLine( "super( \"" + zName + "\", \"ID\", " + zToMany + ".class, \"" + pAttribute.getToManyBackReference() + "\", " + // |
1309 |
1129 |
|
zOrderBy + ", " + // |
1310 |
1130 |
|
"Mutability." + zMutability + ", " + pAttribute.isRequired() + ", " + // |
|
@@ -1325,12 +1145,9 @@ |
1325 |
1145 |
|
addLine( "@Override" ); |
1326 |
1146 |
|
addMethodPublic( "void", "setValueOnPO", mObjectName + " pPO", "Object pValue" ); |
1327 |
1147 |
|
|
1328 |
|
- |
if ( Mutability.RO.equals( zMutability ) ) |
1329 |
|
- |
{ |
|
1148 |
+ |
if ( Mutability.RO.equals( zMutability ) ) { |
1330 |
1149 |
|
addLine( "throw new UnsupportedOperationException( \"'" + zName + "' is Read Only\" );" ); |
1331 |
|
- |
} |
1332 |
|
- |
else |
1333 |
|
- |
{ |
|
1150 |
+ |
} else { |
1334 |
1151 |
|
addLine( "pPO.set" + zName + "( to_POs( pPO, " + zToMany + ".class, pValue ) );" ); |
1335 |
1152 |
|
} |
1336 |
1153 |
|
addMethodEnd(); |
|
@@ -1338,12 +1155,9 @@ |
1338 |
1155 |
|
addLine( "@Override" ); |
1339 |
1156 |
|
addMethodPublic( "void", "addValueOnPO", mObjectName + " pPO", "Object pValue" ); |
1340 |
1157 |
|
|
1341 |
|
- |
if ( Mutability.RO.equals( zMutability ) ) |
1342 |
|
- |
{ |
|
1158 |
+ |
if ( Mutability.RO.equals( zMutability ) ) { |
1343 |
1159 |
|
addLine( "throw new UnsupportedOperationException( \"'" + zName + "' is Read Only\" );" ); |
1344 |
|
- |
} |
1345 |
|
- |
else |
1346 |
|
- |
{ |
|
1160 |
+ |
} else { |
1347 |
1161 |
|
addLine( "pPO.add" + zName + "( to_PO( pPO, " + zToMany + ".class, pValue ) );" ); |
1348 |
1162 |
|
} |
1349 |
1163 |
|
addMethodEnd(); |
|
@@ -1351,30 +1165,24 @@ |
1351 |
1165 |
|
addLine( "@Override" ); |
1352 |
1166 |
|
addMethodPublic( "void", "removeValueOnPO", mObjectName + " pPO", "Object pValue" ); |
1353 |
1167 |
|
|
1354 |
|
- |
if ( Mutability.RO.equals( zMutability ) ) |
1355 |
|
- |
{ |
|
1168 |
+ |
if ( Mutability.RO.equals( zMutability ) ) { |
1356 |
1169 |
|
addLine( "throw new UnsupportedOperationException( \"'" + zName + "' is Read Only\" );" ); |
1357 |
|
- |
} |
1358 |
|
- |
else |
1359 |
|
- |
{ |
|
1170 |
+ |
} else { |
1360 |
1171 |
|
addLine( "pPO.remove" + zName + "( to_PO( pPO, " + zToMany + ".class, pValue ) );" ); |
1361 |
1172 |
|
} |
1362 |
1173 |
|
addBlockEnd(); |
1363 |
1174 |
|
addClassEnd(); |
1364 |
1175 |
|
} |
1365 |
1176 |
|
|
1366 |
|
- |
private void addToManyRegular( AttributeProxy pAttribute, boolean pCascadeDeleteThem ) |
1367 |
|
- |
{ |
|
1177 |
+ |
private void addToManyRegular( AttributeProxy pAttribute, boolean pCascadeDeleteThem ) { |
1368 |
1178 |
|
addToMany( "Regular", pAttribute, pCascadeDeleteThem ); |
1369 |
1179 |
|
} |
1370 |
1180 |
|
|
1371 |
|
- |
private void addToManyVariable( AttributeProxy pAttribute, boolean pCascadeDeleteThem ) |
1372 |
|
- |
{ |
|
1181 |
+ |
private void addToManyVariable( AttributeProxy pAttribute, boolean pCascadeDeleteThem ) { |
1373 |
1182 |
|
addToMany( "Variable", pAttribute, pCascadeDeleteThem ); |
1374 |
1183 |
|
} |
1375 |
1184 |
|
|
1376 |
|
- |
private void addAttributeToManyVirtual( AttributeProxy pAttribute ) |
1377 |
|
- |
{ |
|
1185 |
+ |
private void addAttributeToManyVirtual( AttributeProxy pAttribute ) { |
1378 |
1186 |
|
String zName = pAttribute.getName(); |
1379 |
1187 |
|
String zToMany = Objects.justClassNameIfPackage( pAttribute.getToManyFullyQualifiedName(), mPackage + "." ); |
1380 |
1188 |
|
String zGenericType = "<" + mObjectName + "," + zToMany + ">"; |
|
@@ -1389,8 +1197,7 @@ |
1389 |
1197 |
|
addBlankLine(); |
1390 |
1198 |
|
|
1391 |
1199 |
|
Mutability zMutability = pAttribute.getMutability(); |
1392 |
|
- |
if ( !Mutability.RO.equals( zMutability ) ) |
1393 |
|
- |
{ |
|
1200 |
+ |
if ( !Mutability.RO.equals( zMutability ) ) { |
1394 |
1201 |
|
addAbstractMethodProtected( "void", "LLset" + zName, "java.util.List<" + zToMany + ">" + " p" + zName ); |
1395 |
1202 |
|
addBlankLine(); |
1396 |
1203 |
|
|
|
@@ -1432,12 +1239,9 @@ |
1432 |
1239 |
|
addLine( "@Override" ); |
1433 |
1240 |
|
addMethodPublic( "void", "setValueOnPO", mObjectName + " pPO", "Object pValue" ); |
1434 |
1241 |
|
|
1435 |
|
- |
if ( Mutability.RO.equals( zMutability ) ) |
1436 |
|
- |
{ |
|
1242 |
+ |
if ( Mutability.RO.equals( zMutability ) ) { |
1437 |
1243 |
|
addLine( "throw new UnsupportedOperationException( \"'" + zName + "' is Read Only\" );" ); |
1438 |
|
- |
} |
1439 |
|
- |
else |
1440 |
|
- |
{ |
|
1244 |
+ |
} else { |
1441 |
1245 |
|
addLine( "pPO.set" + zName + "( to_POs( pPO, " + zToMany + ".class, pValue ) );" ); |
1442 |
1246 |
|
} |
1443 |
1247 |
|
addMethodEnd(); |
|
@@ -1445,12 +1249,9 @@ |
1445 |
1249 |
|
addLine( "@Override" ); |
1446 |
1250 |
|
addMethodPublic( "void", "addValueOnPO", mObjectName + " pPO", "Object pValue" ); |
1447 |
1251 |
|
|
1448 |
|
- |
if ( Mutability.RO.equals( zMutability ) ) |
1449 |
|
- |
{ |
|
1252 |
+ |
if ( Mutability.RO.equals( zMutability ) ) { |
1450 |
1253 |
|
addLine( "throw new UnsupportedOperationException( \"'" + zName + "' is Read Only\" );" ); |
1451 |
|
- |
} |
1452 |
|
- |
else |
1453 |
|
- |
{ |
|
1254 |
+ |
} else { |
1454 |
1255 |
|
addLine( "pPO.add" + zName + "( to_PO( pPO, " + zToMany + ".class, pValue ) );" ); |
1455 |
1256 |
|
} |
1456 |
1257 |
|
addMethodEnd(); |
|
@@ -1458,12 +1259,9 @@ |
1458 |
1259 |
|
addLine( "@Override" ); |
1459 |
1260 |
|
addMethodPublic( "void", "removeValueOnPO", mObjectName + " pPO", "Object pValue" ); |
1460 |
1261 |
|
|
1461 |
|
- |
if ( Mutability.RO.equals( zMutability ) ) |
1462 |
|
- |
{ |
|
1262 |
+ |
if ( Mutability.RO.equals( zMutability ) ) { |
1463 |
1263 |
|
addLine( "throw new UnsupportedOperationException( \"'" + zName + "' is Read Only\" );" ); |
1464 |
|
- |
} |
1465 |
|
- |
else |
1466 |
|
- |
{ |
|
1264 |
+ |
} else { |
1467 |
1265 |
|
addLine( "pPO.remove" + zName + "( to_PO( pPO, " + zToMany + ".class, pValue ) );" ); |
1468 |
1266 |
|
} |
1469 |
1267 |
|
addMethodEnd(); |
|
@@ -1475,24 +1273,20 @@ |
1475 |
1273 |
|
addClassEnd(); |
1476 |
1274 |
|
} |
1477 |
1275 |
|
|
1478 |
|
- |
private void addAttributeToManyRegular( AttributeProxy pAttribute ) |
1479 |
|
- |
{ |
|
1276 |
+ |
private void addAttributeToManyRegular( AttributeProxy pAttribute ) { |
1480 |
1277 |
|
addToManyRegular( pAttribute, pAttribute.getToManyBackReferenceAttributeProxy().isRequired() ); // CascadeDeleteThem if Other End Required |
1481 |
1278 |
|
} |
1482 |
1279 |
|
|
1483 |
|
- |
private void addAttributeToManyVariable( AttributeProxy pAttribute ) |
1484 |
|
- |
{ |
|
1280 |
+ |
private void addAttributeToManyVariable( AttributeProxy pAttribute ) { |
1485 |
1281 |
|
// A_VariableToOne.TYPE, pPersisted |
1486 |
1282 |
|
addToManyVariable( pAttribute, pAttribute.getToManyBackReferenceAttributeProxy().isRequired() ); // CascadeDeleteThem if Other End Required |
1487 |
1283 |
|
} |
1488 |
1284 |
|
|
1489 |
|
- |
private void addAttributeToManyBridge( AttributeProxy pAttribute ) |
1490 |
|
- |
{ |
|
1285 |
+ |
private void addAttributeToManyBridge( AttributeProxy pAttribute ) { |
1491 |
1286 |
|
addToManyRegular( pAttribute, true ); |
1492 |
1287 |
|
} |
1493 |
1288 |
|
|
1494 |
|
- |
private void addAttributeToManyVariableBridgeLeft( AttributeProxy pAttribute ) |
1495 |
|
- |
{ |
|
1289 |
+ |
private void addAttributeToManyVariableBridgeLeft( AttributeProxy pAttribute ) { |
1496 |
1290 |
|
// A_VariableBridgeToOneLeft.TYPE, pPersisted - String (Var2One) PMD_Changeable & PMD_UniqueGroup & PMD_ColumnName implicitly Required! |
1497 |
1291 |
|
addToManyVariable( pAttribute, true ); |
1498 |
1292 |
|
} |