Subversion Repository Public Repository

litesoft

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// This Source Code is in the Public Domain per: http://unlicense.org
package org.litesoft.generator;

import org.litesoft.aokeyhole.objects.*;
import org.litesoft.bo.attributes.*;
import org.litesoft.codegen.*;
import org.litesoft.commonfoundation.base.*;

public class GenerateVOGO extends AbstractVOFileGenerator {
    private String mVoAttributeGenericType = "XXX";

    public GenerateVOGO( ErrorSinc pErrorSinc, ObjectMetaData pObjectMetaData, DerivedObjectTuple pDerivedFromObject, ObjectRef pObjectRef,
                         ObjectRef pParentObjectRef ) {
        super( pErrorSinc, pObjectMetaData, pDerivedFromObject, pObjectRef, "GO", pParentObjectRef );
    }

    @Override
    protected void LLaddImports() {
        addImports( //
                    "org.litesoft.bo.views.*", //
                    null );
    }

    @Override
    protected void LLaddClassDefinition() {
        String zClassName = mClassName;
        String zExtendsName = getExtends( "ViewObject" );

        if ( mIsParent ) {
            zClassName += "<T extends " + mObjectName + "<T>>";
            mVoAttributeGenericType = "T";
        } else {
            mVoAttributeGenericType = mObjectName;
        }

        addNotes( mObjectMetaData.getNotes() );
        makeClassAbstract();
        addClassDefinition( zClassName, zExtendsName + "<" + mVoAttributeGenericType + ">", mObjectName + "Names" );
    }

    @Override
    protected void LLaddClassBody() {
        constructors();
        for ( AttributeProxy zAttribute : getAttributes() ) {
            attribute( zAttribute );
        }
    }

    private void constructors() {
        if ( mIsParent ) {
            addConstructorProtected( mClassName, mObjectName + "MetaData<T> pMetaData" );
            addLine( "super( pMetaData );" );
            addMethodEnd();
            addConstructorProtected( mClassName, mObjectName + "MetaData<T> pMetaData", "boolean pNew", "TransactionSet pTransactionSet" );
            addLine( "super( pMetaData, pNew, pTransactionSet );" );
            addBlockEnd();
        } else {
            addLine( "@Deprecated" );
            addConstructorProtected( mClassName );
            addLine( "super( " + mObjectName + "MetaData.getInstance() );" );
            addMethodEnd();
            addConstructorProtected( mClassName, "boolean pNew", "TransactionSet pTransactionSet" );
            addLine( "super( " + mObjectName + "MetaData.getInstance(), pNew, pTransactionSet );" );
            addBlockEnd();
        }
    }

    private void attribute( AttributeProxy pAttribute ) {
        Class zSimpleDataTypeClass = pAttribute.getSimpleDataType();
        if ( zSimpleDataTypeClass == null ) {
            mErrorSinc.addError( "CurrentlyUnsupportedAttributeType", pAttribute.toString(), mObjectMetaData.toStringForError() );
            return;
        }
        String zSimpleDataType = ClassName.simpleIfPackage( zSimpleDataTypeClass, JAVA_LANG_PACKAGE );

        addBlankLine();

        String zNotes = pAttribute.getNotes();

        String zName = pAttribute.getName();

        if ( pAttribute.isVirtual() ) {
            addNotes( zNotes );
            addAbstractMethodPublic( zSimpleDataType, "get" + zName );

            Mutability zMutability = pAttribute.getMutability();

            if ( !Mutability.RO.equals( zMutability ) ) {
                addBlankLine();
                addNotes( zNotes );
                addMethodPublic( "void", "set" + zName, zSimpleDataType + " p" + zName );
                addLine( "VoAttribute<" + mVoAttributeGenericType + "> zAttribute = getVoAttribute( a" + zName + " );" );
                addLine( "if ( verifyMutabilityOnChange( zAttribute, get" + zName + "(), p" + zName + " = zAttribute.normalize( p" + zName +
                         ",  zAttribute.isRequired() ) ) )" );
                addBlockStart();
                addLine( "LLset" + zName + "( p" + zName + " );" );
                addBlockEnd();
                addMethodEnd();

                addNotes( zNotes );
                addAbstractMethodProtected( "void", "LLset" + zName, zSimpleDataType + " p" + zName );
            }
        } else {
            addLine( "private " + zSimpleDataType + " m" + zName + ";" );

            addBlankLine();

            addNotes( zNotes );
            if ( "ID".equals( zName ) ) {
                addLine( "@Override" );
            }
            addMethodPublic( zSimpleDataType, "get" + zName );
            addLine( "return m" + zName + ";" );
            addMethodEnd();

            addNotes( zNotes );
            if ( "ID".equals( zName ) ) {
                addLine( "@Override" );
            }
            addMethodPublic( "void", "set" + zName, zSimpleDataType + " p" + zName );
            addLine( "VoAttribute<" + mVoAttributeGenericType + "> zAttribute = getVoAttribute( a" + zName + " );" );
            addLine( "if ( verifyMutabilityOnChange( zAttribute, get" + zName + "(), p" + zName + " = zAttribute.normalize( p" + zName +
                     ",  zAttribute.isRequired() ) ) )" );
            addBlockStart();
            addLine( "LLset" + zName + "( p" + zName + " );" );
            addBlockEnd();
            addMethodEnd();

            addNotes( zNotes );
            addMethodProtected( "void", "LLset" + zName, zSimpleDataType + " p" + zName );
            addLine( "m" + zName + " = p" + zName + ";" );
            addBlockEnd();
        }
    }
}

Commits for litesoft/trunk/Java/PoVoGenerator/Generator/src/org/litesoft/generator/GenerateVOGO.java

Diff revisions: vs.
Revision Author Commited Message
950 Diff Diff GeorgeS picture GeorgeS Thu 19 Jun, 2014 17:57:04 +0000

New Lines

949 Diff Diff GeorgeS picture GeorgeS Sun 08 Jun, 2014 17:19:33 +0000

Normalization

948 Diff Diff GeorgeS picture GeorgeS Sat 07 Jun, 2014 23:42:39 +0000

Jusefuls Formatter Updated to New Code Format

947 Diff Diff GeorgeS picture GeorgeS Fri 06 Jun, 2014 23:36:56 +0000

Correct Spelling of package!

939 Diff Diff GeorgeS picture GeorgeS Mon 02 Jun, 2014 21:30:31 +0000

Extracting commonfoundation

811 Diff Diff GeorgeS picture GeorgeS Sat 18 Aug, 2012 13:45:18 +0000
243 Diff Diff GeorgeS picture GeorgeS Sun 05 Jun, 2011 20:29:12 +0000
223 Diff Diff GeorgeS picture GeorgeS Fri 20 May, 2011 19:25:35 +0000
49 Diff Diff GeorgeS picture GeorgeS Mon 12 Apr, 2010 02:59:10 +0000

License Text

22 GeorgeS picture GeorgeS Tue 23 Feb, 2010 21:23:42 +0000