|
@@ -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.*; |
9 |
5 |
|
import org.litesoft.aokeyhole.objects.AttributeMetaData; |
10 |
6 |
|
import org.litesoft.aokeyhole.objects.attributes.*; |
|
@@ -13,15 +9,16 @@ |
13 |
9 |
|
import org.litesoft.bo.*; |
14 |
10 |
|
import org.litesoft.bo.attributes.*; |
15 |
11 |
|
import org.litesoft.codegen.*; |
|
12 |
+ |
import org.litesoft.commonfoundation.typeutils.*; |
|
13 |
+ |
import org.litesoft.commonfoundation.typeutils.Objects; |
16 |
14 |
|
import org.litesoft.core.simpletypes.currency.*; |
17 |
15 |
|
import org.litesoft.core.simpletypes.temporal.*; |
18 |
|
- |
import org.litesoft.commonfoundation.typeutils.Objects; |
19 |
16 |
|
|
20 |
|
- |
public abstract class AbstractTypeFileGenerator extends SourceCodeGenerator |
21 |
|
- |
{ |
|
17 |
+ |
import java.util.*; |
|
18 |
+ |
|
|
19 |
+ |
public abstract class AbstractTypeFileGenerator extends SourceCodeGenerator { |
22 |
20 |
|
protected interface AttributeProxy extends MinimalAttributeMetaData, |
23 |
|
- |
HasValidOptions |
24 |
|
- |
{ |
|
21 |
+ |
HasValidOptions { |
25 |
22 |
|
boolean isInjected(); |
26 |
23 |
|
|
27 |
24 |
|
String getDerivedFromAttribute(); |
|
@@ -64,8 +61,8 @@ |
64 |
61 |
|
protected final String mPackage, mObjectName, mClassName; |
65 |
62 |
|
protected final boolean mIsParent; |
66 |
63 |
|
|
67 |
|
- |
public AbstractTypeFileGenerator( String pReportingType, ErrorSinc pErrorSinc, ObjectMetaData pObjectMetaData, ObjectRef pObjectRef, String pTypeExtension, ObjectRef pParentObjectRef, boolean pIsParent ) |
68 |
|
- |
{ |
|
64 |
+ |
public AbstractTypeFileGenerator( String pReportingType, ErrorSinc pErrorSinc, ObjectMetaData pObjectMetaData, ObjectRef pObjectRef, String pTypeExtension, |
|
65 |
+ |
ObjectRef pParentObjectRef, boolean pIsParent ) { |
69 |
66 |
|
super( pReportingType, pObjectRef.getFullFolderPath() + "/" + pObjectMetaData.getName() + pTypeExtension + ".java" ); |
70 |
67 |
|
mErrorSinc = pErrorSinc; |
71 |
68 |
|
mObjectRef = pObjectRef; |
|
@@ -76,8 +73,7 @@ |
76 |
73 |
|
setOverwrite( mClassName.endsWith( "GO" ) ); |
77 |
74 |
|
} |
78 |
75 |
|
|
79 |
|
- |
public final SourceCodeGenerator generate() |
80 |
|
- |
{ |
|
76 |
+ |
public final SourceCodeGenerator generate() { |
81 |
77 |
|
addPackage( mPackage ); |
82 |
78 |
|
|
83 |
79 |
|
LLaddImports(); |
|
@@ -91,80 +87,62 @@ |
91 |
87 |
|
return this; |
92 |
88 |
|
} |
93 |
89 |
|
|
94 |
|
- |
protected String getExtends( String pNoParentClassPrefix ) |
95 |
|
- |
{ |
96 |
|
- |
if ( mParentObjectRef == null ) |
97 |
|
- |
{ |
|
90 |
+ |
protected String getExtends( String pNoParentClassPrefix ) { |
|
91 |
+ |
if ( mParentObjectRef == null ) { |
98 |
92 |
|
return pNoParentClassPrefix; |
99 |
93 |
|
} |
100 |
94 |
|
return removePackageIfPossible( mParentObjectRef.getFullyQualifiedName() ); |
101 |
95 |
|
} |
102 |
96 |
|
|
103 |
|
- |
protected String removePackageIfPossible( String pFullyQualifiedName ) |
104 |
|
- |
{ |
|
97 |
+ |
protected String removePackageIfPossible( String pFullyQualifiedName ) { |
105 |
98 |
|
int zDotAt = pFullyQualifiedName.lastIndexOf( '.' ); |
106 |
|
- |
if ( (zDotAt != -1) && mPackage.equals( pFullyQualifiedName.substring( 0, zDotAt ) ) ) |
107 |
|
- |
{ |
|
99 |
+ |
if ( (zDotAt != -1) && mPackage.equals( pFullyQualifiedName.substring( 0, zDotAt ) ) ) { |
108 |
100 |
|
pFullyQualifiedName = pFullyQualifiedName.substring( zDotAt + 1 ); |
109 |
101 |
|
} |
110 |
102 |
|
return pFullyQualifiedName; |
111 |
103 |
|
} |
112 |
104 |
|
|
113 |
|
- |
protected void LLaddImports() |
114 |
|
- |
{ |
|
105 |
+ |
protected void LLaddImports() { |
115 |
106 |
|
} |
116 |
107 |
|
|
117 |
108 |
|
abstract protected void LLaddClassDefinition(); |
118 |
109 |
|
|
119 |
|
- |
protected void LLaddClassBody() |
120 |
|
- |
{ |
|
110 |
+ |
protected void LLaddClassBody() { |
121 |
111 |
|
} |
122 |
112 |
|
|
123 |
113 |
|
abstract protected AttributeProxy[] getAttributes(); |
124 |
114 |
|
|
125 |
|
- |
protected static Mutability convertToMutability( AttributeMetaData pAttribute ) |
126 |
|
- |
{ |
|
115 |
+ |
protected static Mutability convertToMutability( AttributeMetaData pAttribute ) { |
127 |
116 |
|
AttributeType zType = pAttribute.getAttributeSet().getType(); |
128 |
|
- |
if ( A_ID.TYPE.equals( zType ) ) |
129 |
|
- |
{ |
|
117 |
+ |
if ( A_ID.TYPE.equals( zType ) ) { |
130 |
118 |
|
return Mutability.AddOnly; |
131 |
119 |
|
} |
132 |
120 |
|
String zChangeable = pAttribute.getPropertyManager().get_String( PMD_Changeable.NAME, "" ).trim(); |
133 |
|
- |
if ( PMD_Changeable.ADD_ONLY.equals( zChangeable ) ) |
134 |
|
- |
{ |
|
121 |
+ |
if ( PMD_Changeable.ADD_ONLY.equals( zChangeable ) ) { |
135 |
122 |
|
return Mutability.AddOnly; |
136 |
123 |
|
} |
137 |
|
- |
if ( PMD_Changeable.READ_ONLY.equals( zChangeable ) ) |
138 |
|
- |
{ |
|
124 |
+ |
if ( PMD_Changeable.READ_ONLY.equals( zChangeable ) ) { |
139 |
125 |
|
return Mutability.RO; |
140 |
126 |
|
} |
141 |
127 |
|
return Mutability.RW; |
142 |
128 |
|
} |
143 |
129 |
|
|
144 |
|
- |
protected BoAttribute.AttributeType getType( MinimalAttributeMetaData pAttribute ) |
145 |
|
- |
{ |
|
130 |
+ |
protected BoAttribute.AttributeType getType( MinimalAttributeMetaData pAttribute ) { |
146 |
131 |
|
AttributeType zAttributeType = pAttribute.getAttributeSetType(); |
147 |
|
- |
if ( zAttributeType.getFAT().isSimple() ) |
148 |
|
- |
{ |
|
132 |
+ |
if ( zAttributeType.getFAT().isSimple() ) { |
149 |
133 |
|
Class zTypeClass = zAttributeType.getSimpleDataType(); |
150 |
|
- |
if ( zTypeClass == null ) |
151 |
|
- |
{ |
|
134 |
+ |
if ( zTypeClass == null ) { |
152 |
135 |
|
mErrorSinc.addError( "CurrentlyUnsupportedAttributeType", pAttribute.toString(), mObjectMetaData.toStringForError() ); |
153 |
|
- |
} |
154 |
|
- |
else |
155 |
|
- |
{ |
|
136 |
+ |
} else { |
156 |
137 |
|
String zType = zTypeClass.getName(); |
157 |
138 |
|
int zAt = zType.lastIndexOf( '.' ); |
158 |
|
- |
if ( zAt != -1 ) |
159 |
|
- |
{ |
|
139 |
+ |
if ( zAt != -1 ) { |
160 |
140 |
|
zType = zType.substring( zAt + 1 ); |
161 |
141 |
|
} |
162 |
|
- |
try |
163 |
|
- |
{ |
|
142 |
+ |
try { |
164 |
143 |
|
return BoAttribute.AttributeType.valueOf( zType ); |
165 |
144 |
|
} |
166 |
|
- |
catch ( IllegalArgumentException e ) |
167 |
|
- |
{ |
|
145 |
+ |
catch ( IllegalArgumentException e ) { |
168 |
146 |
|
mErrorSinc.addError( "CurrentlyUnsupportedAttributeType", "of: " + zType, pAttribute.toString(), mObjectMetaData.toStringForError() ); |
169 |
147 |
|
} |
170 |
148 |
|
} |
|
@@ -172,28 +150,22 @@ |
172 |
150 |
|
return null; |
173 |
151 |
|
} |
174 |
152 |
|
|
175 |
|
- |
protected void addNotes( String pNotes ) |
176 |
|
- |
{ |
177 |
|
- |
if ( Strings.isNotNullOrEmpty( pNotes ) ) |
178 |
|
- |
{ |
|
153 |
+ |
protected void addNotes( String pNotes ) { |
|
154 |
+ |
if ( Strings.isNotNullOrEmpty( pNotes ) ) { |
179 |
155 |
|
addLine( "/**" ); |
180 |
156 |
|
String[] zLines = Strings.parseChar( Strings.normalizeNewLines( pNotes ), '\n' ); |
181 |
|
- |
for ( String zLine : zLines ) |
182 |
|
- |
{ |
|
157 |
+ |
for ( String zLine : zLines ) { |
183 |
158 |
|
addLine( " " + ("* " + zLine).trim() ); |
184 |
159 |
|
} |
185 |
160 |
|
addLine( " */" ); |
186 |
161 |
|
} |
187 |
162 |
|
} |
188 |
163 |
|
|
189 |
|
- |
protected String adjustOptionForName( String pOption ) |
190 |
|
- |
{ |
|
164 |
+ |
protected String adjustOptionForName( String pOption ) { |
191 |
165 |
|
StringBuilder rv = new StringBuilder( pOption ); |
192 |
|
- |
for ( int i = 0; i < rv.length(); i++ ) |
193 |
|
- |
{ |
|
166 |
+ |
for ( int i = 0; i < rv.length(); i++ ) { |
194 |
167 |
|
char c = rv.charAt( i ); |
195 |
|
- |
if ( (c != '_') && !Characters.isAlphaNumeric( c ) ) |
196 |
|
- |
{ |
|
168 |
+ |
if ( (c != '_') && !Characters.isAlphaNumeric( c ) ) { |
197 |
169 |
|
rv.setCharAt( i, '_' ); |
198 |
170 |
|
} |
199 |
171 |
|
} |
|
@@ -202,60 +174,47 @@ |
202 |
174 |
|
|
203 |
175 |
|
private static Map<ObjectMetaData, List<AttributeProxy>> sInjectedAttributes = new HashMap<ObjectMetaData, List<AttributeProxy>>(); |
204 |
176 |
|
|
205 |
|
- |
protected synchronized List<AttributeProxy> getInjectedAttributes( ObjectMetaData pObjectMetaData ) |
206 |
|
- |
{ |
|
177 |
+ |
protected synchronized List<AttributeProxy> getInjectedAttributes( ObjectMetaData pObjectMetaData ) { |
207 |
178 |
|
List<AttributeProxy> zInjectedAttributes = sInjectedAttributes.get( pObjectMetaData ); |
208 |
|
- |
if ( zInjectedAttributes == null ) |
209 |
|
- |
{ |
|
179 |
+ |
if ( zInjectedAttributes == null ) { |
210 |
180 |
|
sInjectedAttributes.put( pObjectMetaData, zInjectedAttributes = createInjectedAttributes( pObjectMetaData ) ); |
211 |
181 |
|
} |
212 |
182 |
|
return zInjectedAttributes; |
213 |
183 |
|
} |
214 |
184 |
|
|
215 |
|
- |
protected List<AttributeProxy> createInjectedAttributes( ObjectMetaData pObjectMetaData ) |
216 |
|
- |
{ |
|
185 |
+ |
protected List<AttributeProxy> createInjectedAttributes( ObjectMetaData pObjectMetaData ) { |
217 |
186 |
|
String zTimeTracked = pObjectMetaData.getPropertyManager().get_String( PMD_TimeTracked.NAME, PMD_TimeTracked.NONE ); |
218 |
|
- |
if ( PMD_TimeTracked.NONE.equals( zTimeTracked ) ) |
219 |
|
- |
{ |
|
187 |
+ |
if ( PMD_TimeTracked.NONE.equals( zTimeTracked ) ) { |
220 |
188 |
|
return Collections.emptyList(); |
221 |
189 |
|
} |
222 |
190 |
|
ArrayList<AttributeProxy> zInjected = new ArrayList<AttributeProxy>(); |
223 |
|
- |
if ( PMD_TimeTracked.CREATED.equals( zTimeTracked ) || PMD_TimeTracked.BOTH.equals( zTimeTracked ) ) |
224 |
|
- |
{ |
|
191 |
+ |
if ( PMD_TimeTracked.CREATED.equals( zTimeTracked ) || PMD_TimeTracked.BOTH.equals( zTimeTracked ) ) { |
225 |
192 |
|
zInjected.add( IAP_CREATED ); |
226 |
193 |
|
} |
227 |
|
- |
if ( PMD_TimeTracked.LAST_MOD.equals( zTimeTracked ) || PMD_TimeTracked.BOTH.equals( zTimeTracked ) ) |
228 |
|
- |
{ |
|
194 |
+ |
if ( PMD_TimeTracked.LAST_MOD.equals( zTimeTracked ) || PMD_TimeTracked.BOTH.equals( zTimeTracked ) ) { |
229 |
195 |
|
zInjected.add( IAP_LAST_MOD ); |
230 |
196 |
|
} |
231 |
197 |
|
return zInjected; |
232 |
198 |
|
} |
233 |
199 |
|
|
234 |
|
- |
protected MinimalAttributeMetaData getRegularOrInjectedAttribute( ObjectMetaData pObjectMetaData, String pAttrName ) |
235 |
|
- |
{ |
|
200 |
+ |
protected MinimalAttributeMetaData getRegularOrInjectedAttribute( ObjectMetaData pObjectMetaData, String pAttrName ) { |
236 |
201 |
|
AttributeMetaData zAMD = pObjectMetaData.getAttribute( pAttrName ); |
237 |
|
- |
if ( zAMD != null ) |
238 |
|
- |
{ |
|
202 |
+ |
if ( zAMD != null ) { |
239 |
203 |
|
return zAMD; |
240 |
204 |
|
} |
241 |
205 |
|
List<AttributeProxy> zInjectedAttributes = getInjectedAttributes( pObjectMetaData ); |
242 |
|
- |
for ( AttributeProxy zAttribute : zInjectedAttributes ) |
243 |
|
- |
{ |
244 |
|
- |
if ( zAttribute.getName().equals( pAttrName ) ) |
245 |
|
- |
{ |
|
206 |
+ |
for ( AttributeProxy zAttribute : zInjectedAttributes ) { |
|
207 |
+ |
if ( zAttribute.getName().equals( pAttrName ) ) { |
246 |
208 |
|
return zAttribute; |
247 |
209 |
|
} |
248 |
210 |
|
} |
249 |
211 |
|
return null; |
250 |
212 |
|
} |
251 |
213 |
|
|
252 |
|
- |
protected MinimalAttributeMetaData getAttribute( ObjectMetaData pObjectMetaData, String pAttrName ) |
253 |
|
- |
{ |
254 |
|
- |
while ( pObjectMetaData != null ) |
255 |
|
- |
{ |
|
214 |
+ |
protected MinimalAttributeMetaData getAttribute( ObjectMetaData pObjectMetaData, String pAttrName ) { |
|
215 |
+ |
while ( pObjectMetaData != null ) { |
256 |
216 |
|
MinimalAttributeMetaData zAMD = getRegularOrInjectedAttribute( pObjectMetaData, pAttrName ); |
257 |
|
- |
if ( zAMD != null ) |
258 |
|
- |
{ |
|
217 |
+ |
if ( zAMD != null ) { |
259 |
218 |
|
return zAMD; |
260 |
219 |
|
} |
261 |
220 |
|
String zParentName = Strings.noEmpty( pObjectMetaData.getParentName() ); |
|
@@ -265,21 +224,16 @@ |
265 |
224 |
|
return null; |
266 |
225 |
|
} |
267 |
226 |
|
|
268 |
|
- |
protected SystemMetaData getSystemMetaData( MetaDataOwner pOwner ) |
269 |
|
- |
{ |
270 |
|
- |
while ( pOwner instanceof AbstractNamedMetaData ) |
271 |
|
- |
{ |
|
227 |
+ |
protected SystemMetaData getSystemMetaData( MetaDataOwner pOwner ) { |
|
228 |
+ |
while ( pOwner instanceof AbstractNamedMetaData ) { |
272 |
229 |
|
pOwner = ((AbstractNamedMetaData) pOwner).getOwner(); |
273 |
230 |
|
} |
274 |
231 |
|
return (pOwner instanceof SystemMetaData) ? (SystemMetaData) pOwner : null; |
275 |
232 |
|
} |
276 |
233 |
|
|
277 |
|
- |
protected void LLaddAttributes( boolean pAddBlank ) |
278 |
|
- |
{ |
279 |
|
- |
for ( AttributeProxy zAttribute : getAttributes() ) |
280 |
|
- |
{ |
281 |
|
- |
if ( pAddBlank ) |
282 |
|
- |
{ |
|
234 |
+ |
protected void LLaddAttributes( boolean pAddBlank ) { |
|
235 |
+ |
for ( AttributeProxy zAttribute : getAttributes() ) { |
|
236 |
+ |
if ( pAddBlank ) { |
283 |
237 |
|
addBlankLine(); |
284 |
238 |
|
} |
285 |
239 |
|
pAddBlank = true; |
|
@@ -287,28 +241,22 @@ |
287 |
241 |
|
} |
288 |
242 |
|
} |
289 |
243 |
|
|
290 |
|
- |
protected void addPSFSattributeValidOptions( AttributeProxy pAttribute, String pPOorVO ) |
291 |
|
- |
{ |
|
244 |
+ |
protected void addPSFSattributeValidOptions( AttributeProxy pAttribute, String pPOorVO ) { |
292 |
245 |
|
String[] zOptions = pAttribute.getValidOptions(); |
293 |
|
- |
if ( Objects.isNotNullOrEmpty(zOptions) && (zOptions.length < 10) ) |
294 |
|
- |
{ |
|
246 |
+ |
if ( Objects.isNotNullOrEmpty( zOptions ) && (zOptions.length < 10) ) { |
295 |
247 |
|
addBlankLine(); |
296 |
|
- |
for ( String zOption : zOptions ) |
297 |
|
- |
{ |
298 |
|
- |
if ( Strings.isNotNullOrEmpty( zOption ) ) |
299 |
|
- |
{ |
|
248 |
+ |
for ( String zOption : zOptions ) { |
|
249 |
+ |
if ( Strings.isNotNullOrEmpty( zOption ) ) { |
300 |
250 |
|
addPSFS( pPOorVO + pAttribute.getName() + "_" + adjustOptionForName( zOption ), zOption ); |
301 |
251 |
|
} |
302 |
252 |
|
} |
303 |
253 |
|
} |
304 |
254 |
|
} |
305 |
255 |
|
|
306 |
|
- |
protected void LLaddAttribute( AttributeProxy zAttribute ) |
307 |
|
- |
{ |
|
256 |
+ |
protected void LLaddAttribute( AttributeProxy zAttribute ) { |
308 |
257 |
|
} |
309 |
258 |
|
|
310 |
|
- |
protected String createAttributeTypedCall( AttributeProxy pAttribute, String pPOorVO, String pBaseLine, String pLineTerminator ) |
311 |
|
- |
{ |
|
259 |
+ |
protected String createAttributeTypedCall( AttributeProxy pAttribute, String pPOorVO, String pBaseLine, String pLineTerminator ) { |
312 |
260 |
|
String zName = pAttribute.getName(); |
313 |
261 |
|
|
314 |
262 |
|
Mutability zMutability = pAttribute.getMutability(); |
|
@@ -316,9 +264,9 @@ |
316 |
264 |
|
String zRequired = pAttribute.isRequired() ? ", true" : ", false"; |
317 |
265 |
|
|
318 |
266 |
|
BoAttribute.AttributeType zType = pAttribute.getBoAttributeType(); |
319 |
|
- |
if ( zType == null ) |
320 |
|
- |
{ |
321 |
|
- |
mErrorSinc.addError( pPOorVO + " CurrentlyUnsupportedAttributeType", "of: " + pAttribute.getAttributeSetType(), pAttribute.toString(), mObjectMetaData.toStringForError() ); |
|
267 |
+ |
if ( zType == null ) { |
|
268 |
+ |
mErrorSinc.addError( pPOorVO + " CurrentlyUnsupportedAttributeType", "of: " + pAttribute.getAttributeSetType(), pAttribute.toString(), |
|
269 |
+ |
mObjectMetaData.toStringForError() ); |
322 |
270 |
|
zType = BoAttribute.AttributeType.String; |
323 |
271 |
|
} |
324 |
272 |
|
|
|
@@ -329,32 +277,23 @@ |
329 |
277 |
|
List<String> zProperties = new ArrayList<String>(); |
330 |
278 |
|
|
331 |
279 |
|
String[] zOptions = pAttribute.getValidOptions(); |
332 |
|
- |
if ( zOptions != null ) |
333 |
|
- |
{ |
|
280 |
+ |
if ( zOptions != null ) { |
334 |
281 |
|
zProperties.add( "Options.of( sValidOptions" + zName + " )" ); |
335 |
282 |
|
zEnumType = (zAttributeType instanceof HasOpenOption) ? "OpenValidOptions" : "ValidOptions"; |
336 |
|
- |
} |
337 |
|
- |
else if ( zAttributeType instanceof AbstractArrayOptionsAttributeTypeSimple ) |
338 |
|
- |
{ |
|
283 |
+ |
} else if ( zAttributeType instanceof AbstractArrayOptionsAttributeTypeSimple ) { |
339 |
284 |
|
String zArrayRef = Strings.noEmpty( zPM.get_String( PMD_FullyQualifiedStringArrayPath.NAME, "" ) ); |
340 |
|
- |
if ( zArrayRef == null ) |
341 |
|
- |
{ |
|
285 |
+ |
if ( zArrayRef == null ) { |
342 |
286 |
|
mErrorSinc.addError( "AttributeStringArrayPath", "Missing", pAttribute.toString(), mObjectMetaData.toStringForError() ); |
343 |
287 |
|
} |
344 |
288 |
|
zProperties.add( "Options.of( " + zArrayRef + " )" ); |
345 |
289 |
|
zEnumType = (zAttributeType instanceof HasOpenOption) ? "OpenValidOptions" : "ValidOptions"; |
346 |
|
- |
} |
347 |
|
- |
else if ( A_Password.TYPE.equals( zAttributeType ) ) |
348 |
|
- |
{ |
|
290 |
+ |
} else if ( A_Password.TYPE.equals( zAttributeType ) ) { |
349 |
291 |
|
zEnumType = "Password"; |
350 |
|
- |
} |
351 |
|
- |
else if ( A_Text.TYPE.equals( zAttributeType ) ) |
352 |
|
- |
{ |
|
292 |
+ |
} else if ( A_Text.TYPE.equals( zAttributeType ) ) { |
353 |
293 |
|
zEnumType = "Text"; |
354 |
294 |
|
} |
355 |
295 |
|
String zProperty = noEmpty( zPM.getProperty( PMD_Case.NAME ) ); |
356 |
|
- |
if ( zProperty != null ) |
357 |
|
- |
{ |
|
296 |
+ |
if ( zProperty != null ) { |
358 |
297 |
|
zProperties.add( PMD_Case.NAME + "." + zProperty ); |
359 |
298 |
|
} |
360 |
299 |
|
// Will be rendered in REVERSE order |
|
@@ -364,102 +303,73 @@ |
364 |
303 |
|
add( zProperties, zPM, PMD_DisplayWidthInitial.NAME, "DisplayWidthInitial" ); |
365 |
304 |
|
|
366 |
305 |
|
pBaseLine += zRequired + ", _" + zEnumType; |
367 |
|
- |
if ( !Mutability.RW.equals( zMutability ) ) |
368 |
|
- |
{ |
|
306 |
+ |
if ( !Mutability.RW.equals( zMutability ) ) { |
369 |
307 |
|
pBaseLine += "." + zMutability + "()"; |
370 |
308 |
|
} |
371 |
|
- |
if ( zProperties.isEmpty() ) |
372 |
|
- |
{ |
|
309 |
+ |
if ( zProperties.isEmpty() ) { |
373 |
310 |
|
addLine( pBaseLine + " )" + pLineTerminator ); |
374 |
|
- |
} |
375 |
|
- |
else |
376 |
|
- |
{ |
|
311 |
+ |
} else { |
377 |
312 |
|
pBaseLine += ".with( "; |
378 |
313 |
|
int i = zProperties.size(); |
379 |
|
- |
if ( i == 1 ) |
380 |
|
- |
{ |
|
314 |
+ |
if ( i == 1 ) { |
381 |
315 |
|
addLine( pBaseLine + zProperties.get( --i ) + " ) )" + pLineTerminator ); |
382 |
|
- |
} |
383 |
|
- |
else |
384 |
|
- |
{ |
|
316 |
+ |
} else { |
385 |
317 |
|
String zPadding = Strings.spaces( pBaseLine.length() ); |
386 |
318 |
|
addLine( pBaseLine + zProperties.get( --i ) + ", //" ); |
387 |
|
- |
while ( i > 1 ) |
388 |
|
- |
{ |
|
319 |
+ |
while ( i > 1 ) { |
389 |
320 |
|
addLine( zPadding + zProperties.get( --i ) + ", //" ); |
390 |
321 |
|
} |
391 |
322 |
|
addLine( zPadding + zProperties.get( --i ) + " ) )" + pLineTerminator ); |
392 |
323 |
|
} |
393 |
324 |
|
} |
394 |
325 |
|
String zTypeExtra = ""; |
395 |
|
- |
if ( Money.class.equals( zType.getType() ) ) |
396 |
|
- |
{ |
|
326 |
+ |
if ( Money.class.equals( zType.getType() ) ) { |
397 |
327 |
|
zTypeExtra = "org.litesoft.core.simpletypes.currency.Currency.US, "; |
398 |
|
- |
} |
399 |
|
- |
else if ( CalendarYMD.class.equals( zType.getType() ) ) |
400 |
|
- |
{ |
|
328 |
+ |
} else if ( CalendarYMD.class.equals( zType.getType() ) ) { |
401 |
329 |
|
zTypeExtra = "org.litesoft.core.simpletypes.temporal.DateFormatControl.DEFAULT_YMD_FORMAT, "; |
402 |
|
- |
} |
403 |
|
- |
else if ( SimpleTime.class.equals( zType.getType() ) ) |
404 |
|
- |
{ |
|
330 |
+ |
} else if ( SimpleTime.class.equals( zType.getType() ) ) { |
405 |
331 |
|
zTypeExtra = "org.litesoft.core.simpletypes.temporal.TimeRes.ToMIN, "; |
406 |
|
- |
} |
407 |
|
- |
else if ( SimpleTimestamp.class.equals( zType.getType() ) ) |
408 |
|
- |
{ |
|
332 |
+ |
} else if ( SimpleTimestamp.class.equals( zType.getType() ) ) { |
409 |
333 |
|
zTypeExtra = "org.litesoft.core.simpletypes.temporal.TimeRes.ToMSEC, "; |
410 |
334 |
|
} |
411 |
335 |
|
return zTypeExtra; |
412 |
336 |
|
} |
413 |
337 |
|
|
414 |
|
- |
protected void add( List<String> pCollector, PropertyManager pPropertyManager, String pProperty, String pWhat ) |
415 |
|
- |
{ |
|
338 |
+ |
protected void add( List<String> pCollector, PropertyManager pPropertyManager, String pProperty, String pWhat ) { |
416 |
339 |
|
String zProperty = noEmpty( pPropertyManager.getProperty( pProperty ) ); |
417 |
|
- |
if ( zProperty != null ) |
418 |
|
- |
{ |
|
340 |
+ |
if ( zProperty != null ) { |
419 |
341 |
|
pCollector.add( pWhat + ".of( " + zProperty + " )" ); |
420 |
342 |
|
} |
421 |
343 |
|
} |
422 |
344 |
|
|
423 |
|
- |
private String noEmpty( Property pProperty ) |
424 |
|
- |
{ |
|
345 |
+ |
private String noEmpty( Property pProperty ) { |
425 |
346 |
|
return (pProperty != null) ? Strings.noEmpty( pProperty.getValueAsString() ) : null; |
426 |
347 |
|
} |
427 |
348 |
|
|
428 |
|
- |
protected void addTopValidOptions( String pPOorVO ) |
429 |
|
- |
{ |
430 |
|
- |
for ( AttributeProxy zAttribute : getAttributes() ) |
431 |
|
- |
{ |
|
349 |
+ |
protected void addTopValidOptions( String pPOorVO ) { |
|
350 |
+ |
for ( AttributeProxy zAttribute : getAttributes() ) { |
432 |
351 |
|
addTopPSFSattributeValidOptions( zAttribute, pPOorVO ); |
433 |
352 |
|
} |
434 |
353 |
|
} |
435 |
354 |
|
|
436 |
|
- |
private void addTopPSFSattributeValidOptions( AttributeProxy pAttribute, String pPOorVO ) |
437 |
|
- |
{ |
|
355 |
+ |
private void addTopPSFSattributeValidOptions( AttributeProxy pAttribute, String pPOorVO ) { |
438 |
356 |
|
String[] zOptions = pAttribute.getValidOptions(); |
439 |
|
- |
if ( zOptions != null ) |
440 |
|
- |
{ |
|
357 |
+ |
if ( zOptions != null ) { |
441 |
358 |
|
addLine( "public static final String[] sValidOptions" + pAttribute.getName() + " = //" ); |
442 |
359 |
|
indentStart(); |
443 |
360 |
|
indentStart(); |
444 |
361 |
|
addLine( "{ //" ); |
445 |
362 |
|
indentPlus( 2 ); |
446 |
363 |
|
|
447 |
|
- |
if ( (zOptions.length < 10) ) |
448 |
|
- |
{ |
449 |
|
- |
for ( String zOption : zOptions ) |
450 |
|
- |
{ |
451 |
|
- |
if ( Strings.isNotNullOrEmpty( zOption ) ) |
452 |
|
- |
{ |
|
364 |
+ |
if ( (zOptions.length < 10) ) { |
|
365 |
+ |
for ( String zOption : zOptions ) { |
|
366 |
+ |
if ( Strings.isNotNullOrEmpty( zOption ) ) { |
453 |
367 |
|
addLine( pPOorVO + pAttribute.getName() + "_" + adjustOptionForName( zOption ) + ", //" ); |
454 |
368 |
|
} |
455 |
369 |
|
} |
456 |
|
- |
} |
457 |
|
- |
else |
458 |
|
- |
{ |
459 |
|
- |
for ( String zOption : zOptions ) |
460 |
|
- |
{ |
461 |
|
- |
if ( Strings.isNotNullOrEmpty( zOption ) ) |
462 |
|
- |
{ |
|
370 |
+ |
} else { |
|
371 |
+ |
for ( String zOption : zOptions ) { |
|
372 |
+ |
if ( Strings.isNotNullOrEmpty( zOption ) ) { |
463 |
373 |
|
addLine( quote( zOption ) + ", //" ); |
464 |
374 |
|
} |
465 |
375 |
|
} |
|
@@ -476,171 +386,143 @@ |
476 |
386 |
|
private static final InjectedAttributeProxy IAP_CREATED = createSysTimeStampAMD( "Created" ); |
477 |
387 |
|
private static final InjectedAttributeProxy IAP_LAST_MOD = createSysTimeStampAMD( "LastModified" ); |
478 |
388 |
|
|
479 |
|
- |
private static InjectedAttributeProxy createSysTimeStampAMD( String pName ) |
480 |
|
- |
{ |
|
389 |
+ |
private static InjectedAttributeProxy createSysTimeStampAMD( String pName ) { |
481 |
390 |
|
return new InjectedAttributeProxy( pName, true, A_Timestamp.TYPE, BoAttribute.AttributeType.SimpleTimestamp ); |
482 |
391 |
|
} |
483 |
392 |
|
|
484 |
|
- |
private static class InjectedAttributeProxy implements AttributeProxy |
485 |
|
- |
{ |
|
393 |
+ |
private static class InjectedAttributeProxy implements AttributeProxy { |
486 |
394 |
|
private String mName; |
487 |
395 |
|
private boolean mSysSetOnly; |
488 |
396 |
|
private AttributeType mAttributeSetType; |
489 |
397 |
|
private BoAttribute.AttributeType mBoAttributeType; |
490 |
398 |
|
|
491 |
|
- |
private InjectedAttributeProxy( String pName, boolean pSysSetOnly, AttributeType pAttributeSetType, BoAttribute.AttributeType pBoAttributeType ) |
492 |
|
- |
{ |
|
399 |
+ |
private InjectedAttributeProxy( String pName, boolean pSysSetOnly, AttributeType pAttributeSetType, BoAttribute.AttributeType pBoAttributeType ) { |
493 |
400 |
|
mName = pName; |
494 |
401 |
|
mSysSetOnly = pSysSetOnly; |
495 |
402 |
|
mAttributeSetType = pAttributeSetType; |
496 |
403 |
|
mBoAttributeType = pBoAttributeType; |
497 |
|
- |
if ( pAttributeSetType.getSimpleDataType() != pBoAttributeType.getType() ) |
498 |
|
- |
{ |
|
404 |
+ |
if ( pAttributeSetType.getSimpleDataType() != pBoAttributeType.getType() ) { |
499 |
405 |
|
throw new IllegalArgumentException( "Incompatible AttributeTypes Set=" + pAttributeSetType + " & " + pBoAttributeType + "=BO" ); |
500 |
406 |
|
} |
501 |
407 |
|
} |
502 |
408 |
|
|
503 |
409 |
|
@Override |
504 |
|
- |
public boolean isInjected() |
505 |
|
- |
{ |
|
410 |
+ |
public boolean isInjected() { |
506 |
411 |
|
return true; |
507 |
412 |
|
} |
508 |
413 |
|
|
509 |
414 |
|
@Override |
510 |
|
- |
public String getDerivedFromAttribute() |
511 |
|
- |
{ |
|
415 |
+ |
public String getDerivedFromAttribute() { |
512 |
416 |
|
return null; |
513 |
417 |
|
} |
514 |
418 |
|
|
515 |
419 |
|
@Override |
516 |
|
- |
public String getName() |
517 |
|
- |
{ |
|
420 |
+ |
public String getName() { |
518 |
421 |
|
return mName; |
519 |
422 |
|
} |
520 |
423 |
|
|
521 |
424 |
|
@Override |
522 |
|
- |
public String getColumnName() |
523 |
|
- |
{ |
|
425 |
+ |
public String getColumnName() { |
524 |
426 |
|
return mName; |
525 |
427 |
|
} |
526 |
428 |
|
|
527 |
429 |
|
@Override |
528 |
|
- |
public Mutability getMutability() |
529 |
|
- |
{ |
|
430 |
+ |
public Mutability getMutability() { |
530 |
431 |
|
return Mutability.RO; |
531 |
432 |
|
} |
532 |
433 |
|
|
533 |
434 |
|
@Override |
534 |
|
- |
public boolean isSysSetOnly() |
535 |
|
- |
{ |
|
435 |
+ |
public boolean isSysSetOnly() { |
536 |
436 |
|
return mSysSetOnly; |
537 |
437 |
|
} |
538 |
438 |
|
|
539 |
439 |
|
@Override |
540 |
|
- |
public String getNotes() |
541 |
|
- |
{ |
|
440 |
+ |
public String getNotes() { |
542 |
441 |
|
return null; |
543 |
442 |
|
} |
544 |
443 |
|
|
545 |
444 |
|
@Override |
546 |
|
- |
public boolean isVirtual() |
547 |
|
- |
{ |
|
445 |
+ |
public boolean isVirtual() { |
548 |
446 |
|
return false; |
549 |
447 |
|
} |
550 |
448 |
|
|
551 |
449 |
|
@Override |
552 |
|
- |
public Class getSimpleDataType() |
553 |
|
- |
{ |
|
450 |
+ |
public Class getSimpleDataType() { |
554 |
451 |
|
return mAttributeSetType.getSimpleDataType(); |
555 |
452 |
|
} |
556 |
453 |
|
|
557 |
454 |
|
@Override |
558 |
|
- |
public String[] getValidOptions() |
559 |
|
- |
{ |
|
455 |
+ |
public String[] getValidOptions() { |
560 |
456 |
|
return null; |
561 |
457 |
|
} |
562 |
458 |
|
|
563 |
459 |
|
@Override |
564 |
|
- |
public BoAttribute.AttributeType getBoAttributeType() |
565 |
|
- |
{ |
|
460 |
+ |
public BoAttribute.AttributeType getBoAttributeType() { |
566 |
461 |
|
return mBoAttributeType; |
567 |
462 |
|
} |
568 |
463 |
|
|
569 |
464 |
|
@Override |
570 |
|
- |
public AttributeType getAttributeSetType() |
571 |
|
- |
{ |
|
465 |
+ |
public AttributeType getAttributeSetType() { |
572 |
466 |
|
return mAttributeSetType; |
573 |
467 |
|
} |
574 |
468 |
|
|
575 |
469 |
|
@Override |
576 |
|
- |
public boolean isRequired() |
577 |
|
- |
{ |
|
470 |
+ |
public boolean isRequired() { |
578 |
471 |
|
return true; |
579 |
472 |
|
} |
580 |
473 |
|
|
581 |
474 |
|
@Override |
582 |
|
- |
public boolean isQueryView() |
583 |
|
- |
{ |
|
475 |
+ |
public boolean isQueryView() { |
584 |
476 |
|
return false; |
585 |
477 |
|
} |
586 |
478 |
|
|
587 |
479 |
|
@Override |
588 |
|
- |
public PropertyManager getPropertyManager() |
589 |
|
- |
{ |
|
480 |
+ |
public PropertyManager getPropertyManager() { |
590 |
481 |
|
return PropertyManager.NONE; |
591 |
482 |
|
} |
592 |
483 |
|
|
593 |
484 |
|
@Override |
594 |
|
- |
public String getToManyFullyQualifiedName() |
595 |
|
- |
{ |
|
485 |
+ |
public String getToManyFullyQualifiedName() { |
596 |
486 |
|
return null; |
597 |
487 |
|
} |
598 |
488 |
|
|
599 |
489 |
|
@Override |
600 |
|
- |
public boolean isToManyInstantiable() |
601 |
|
- |
{ |
|
490 |
+ |
public boolean isToManyInstantiable() { |
602 |
491 |
|
return false; |
603 |
492 |
|
} |
604 |
493 |
|
|
605 |
494 |
|
@Override |
606 |
|
- |
public String getToManyBackReference() |
607 |
|
- |
{ |
|
495 |
+ |
public String getToManyBackReference() { |
608 |
496 |
|
return null; |
609 |
497 |
|
} |
610 |
498 |
|
|
611 |
499 |
|
@Override |
612 |
|
- |
public AttributeProxy getToManyBackReferenceAttributeProxy() |
613 |
|
- |
{ |
|
500 |
+ |
public AttributeProxy getToManyBackReferenceAttributeProxy() { |
614 |
501 |
|
return null; |
615 |
502 |
|
} |
616 |
503 |
|
|
617 |
504 |
|
@Override |
618 |
|
- |
public String getToOneFullyQualifiedName() |
619 |
|
- |
{ |
|
505 |
+ |
public String getToOneFullyQualifiedName() { |
620 |
506 |
|
return null; |
621 |
507 |
|
} |
622 |
508 |
|
|
623 |
509 |
|
@Override |
624 |
|
- |
public boolean isToOneInstantiable() |
625 |
|
- |
{ |
|
510 |
+ |
public boolean isToOneInstantiable() { |
626 |
511 |
|
return false; |
627 |
512 |
|
} |
628 |
513 |
|
|
629 |
514 |
|
@Override |
630 |
|
- |
public String getToOneBackReference() |
631 |
|
- |
{ |
|
515 |
+ |
public String getToOneBackReference() { |
632 |
516 |
|
return null; |
633 |
517 |
|
} |
634 |
518 |
|
|
635 |
519 |
|
@Override |
636 |
|
- |
public AttributeProxy getToOneBackReferenceAttributeProxy() |
637 |
|
- |
{ |
|
520 |
+ |
public AttributeProxy getToOneBackReferenceAttributeProxy() { |
638 |
521 |
|
return null; |
639 |
522 |
|
} |
640 |
523 |
|
|
641 |
524 |
|
@Override |
642 |
|
- |
public String toString() |
643 |
|
- |
{ |
|
525 |
+ |
public String toString() { |
644 |
526 |
|
return getClass().getSimpleName() + "(" + getSimpleDataType().getSimpleName() + "): " + getName(); |
645 |
527 |
|
} |
646 |
528 |
|
} |