de.armax.ax.devtools.generator
Class AXojbHelper

java.lang.Object
  extended byde.armax.ax.devtools.uml.AXmodelChecker
      extended byde.armax.ax.devtools.generator.AXojbHelper

public class AXojbHelper
extends AXmodelChecker

Helper class for generation of OJB or Hibernate related code with AXgen.

This class is configured via the "ojbhelper.properties" file which must be located on the classpath

This class serves also as a model checker (see AXmodelChecker and AXgenCheck) to check a model prior to code generation. It delegates model checker calls to an instance of AXdefaultModelChecker.

See the example properties file for configuration details

Author:
Peter Wieland, ARMAX mindware GmbH

Field Summary
 
Fields inherited from class de.armax.ax.devtools.uml.AXmodelChecker
RESULT_ERRORS, RESULT_OK, RESULT_WARNINGS
 
Method Summary
 void addModelCheckerListener(AXmodelCheckerListener listener)
           
 int check(AXmodel model)
          AXmodelChecker method delegated to AXdefaultModelChecker.
 AXattribute getAccessibleAttributeByName(AXclass clasz, java.lang.String name, boolean excludeImplemented)
           
 java.lang.String getAll1ToNAssocsListString(AXclass clasz)
           
 java.lang.String getAllAttributesListString(AXclass clasz)
           
 java.lang.String getAllMToNAssocsListString(AXclass clasz)
           
 java.lang.String getAllXTo1AssocsListString(AXclass clasz)
           
 java.lang.String getAllXToNAssocsListString(AXclass clasz)
           
 java.lang.String getCascadeType(AXassociation assoc)
          Get the hibernate cascade type (none, delete, autoupdate or all).
 java.lang.String getColumnPrefix(AXclass cls)
          Get the column prefix for a given class.
 java.lang.String getConversionAttribute(AXassociation assoc)
          This convenience method returns the XML attribute for OJB type conversion (conversion="foo.bar.FooToBarFieldConversion") preceded by a single blank.
 java.lang.String getConversionAttribute(AXattribute attribute)
          This convenience method returns the XML attribute for OJB type conversion (conversion="foo.bar.FooToBarFieldConversion") preceded by a single blank.
 java.lang.String getConversionClassName(AXassociation assoc)
          Looks up the conversion class in the properties file.
 java.lang.String getConversionClassName(AXattribute attribute)
          Looks up the conversion class in the properties file.
 java.lang.String getDbColumn(AXattribute attrib)
          Get the db column for a given attribute.
 java.lang.String getDbColumn(AXclass owner, java.lang.String attributeName)
          Get the db column for an attribute specified by its name and the owning class.
 java.lang.String getDbType(AXassociation assoc)
          Get the db-type for the given assoc The type defaults to java.lang.String, the length defaults to 50
 java.lang.String getDbType(AXattribute attrib)
          Get the db-type for the given attribute Length defaults to 50
 java.lang.String getDbType(java.lang.String type, int length)
          Get the db type for the given type This method tries first to find a db type for the specified type directly.
 int getErrorCount()
          AXmodelChecker method delegated to AXdefaultModelChecker.
 java.lang.String getHibernateType(AXattribute attribute)
          Get the hibernate type for a given attribute.
 java.lang.String getHibernateType(java.lang.String type)
          Get the hibernate type for a given java type.
static AXojbHelper getInstance()
           
 java.lang.String getJdbcType(AXassociation assoc)
           
 java.lang.String getJdbcType(AXattribute attribute)
           
 java.lang.String getJdbcType(java.lang.String type)
          This method first looks for a JDBC type mapping in the properties.
 java.lang.String getMaxValue(AXattribute attribute)
           
 java.lang.String getMinValue(AXattribute attribute)
           
 java.lang.String getNamespaceName(ru.novosoft.uml.foundation.core.MNamespace namespace)
           
 java.lang.String getSqlAdditionalCommand()
          Returns the value of the property "additioanl.sql.command" followed by a new line character if such a property exists.
 java.lang.String getSqlCommandlineEnd()
           
 java.lang.String getSqlCreateMiddlefix()
          Returns the SQL create middlefix looked up in the properties file if it exists (followed by a single blank).
 java.lang.String getSufficientlyQualifiedCasted(AXclassifier type, AXclass reference, java.lang.String value)
           
 java.lang.String getTimestamp()
           
 java.lang.String getUser()
           
 int getWarningCount()
          AXmodelChecker method delegated to AXdefaultModelChecker.
 java.lang.String getWrappedVariable(AXclassifier type, java.lang.String value)
           
 boolean hasMinMaxValues(AXattribute attribute)
           
 boolean isWithoutLock()
          Returns true if an attribute without.lock exists and its value is "true"
 void removeModelCheckerListener(AXmodelCheckerListener listener)
           
 
Methods inherited from class de.armax.ax.devtools.uml.AXmodelChecker
fireErrorEvent, fireFinishedEvent, fireWarningEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static AXojbHelper getInstance()

getTimestamp

public java.lang.String getTimestamp()

getUser

public java.lang.String getUser()

getAccessibleAttributeByName

public AXattribute getAccessibleAttributeByName(AXclass clasz,
                                                java.lang.String name,
                                                boolean excludeImplemented)

getWrappedVariable

public java.lang.String getWrappedVariable(AXclassifier type,
                                           java.lang.String value)

getSufficientlyQualifiedCasted

public java.lang.String getSufficientlyQualifiedCasted(AXclassifier type,
                                                       AXclass reference,
                                                       java.lang.String value)

getJdbcType

public java.lang.String getJdbcType(AXassociation assoc)

getJdbcType

public java.lang.String getJdbcType(AXattribute attribute)

getJdbcType

public java.lang.String getJdbcType(java.lang.String type)

This method first looks for a JDBC type mapping in the properties. If no corresponding mapping is found, the default JDBC types for the native types, their Wrapper classes and the java.sql.Date, java.sql.Time and java.sql.Timestamp classes are used.

Parameters:
type -
Throws:
java.lang.IllegalArgumentException - if no mapping can be found

hasMinMaxValues

public boolean hasMinMaxValues(AXattribute attribute)

getMinValue

public java.lang.String getMinValue(AXattribute attribute)

getMaxValue

public java.lang.String getMaxValue(AXattribute attribute)

getSqlAdditionalCommand

public java.lang.String getSqlAdditionalCommand()

Returns the value of the property "additioanl.sql.command" followed by a new line character if such a property exists. Otherwise an empty String is returned


getSqlCommandlineEnd

public java.lang.String getSqlCommandlineEnd()

getSqlCreateMiddlefix

public java.lang.String getSqlCreateMiddlefix()

Returns the SQL create middlefix looked up in the properties file if it exists (followed by a single blank).

If the property does not exist, an empty String is returned.


getDbType

public java.lang.String getDbType(AXassociation assoc)

Get the db-type for the given assoc

The type defaults to java.lang.String, the length defaults to 50

Parameters:
assoc -

getDbType

public java.lang.String getDbType(AXattribute attrib)

Get the db-type for the given attribute

Length defaults to 50

Parameters:
attrib -

getDbType

public java.lang.String getDbType(java.lang.String type,
                                  int length)

Get the db type for the given type

This method tries first to find a db type for the specified type directly. If this fails, it tries to get a db type for the corresponding JDBC type. If this fails too, the corresponding JDBC type is returned

Parameters:
type -
length -
Throws:
java.lang.IllegalArgumentException - if no db type is found and type can not be converted to a JDBC type.

getConversionAttribute

public java.lang.String getConversionAttribute(AXattribute attribute)

This convenience method returns the XML attribute for OJB type conversion (conversion="foo.bar.FooToBarFieldConversion") preceded by a single blank. if the conversion class name returned by getConversionClassName(AXattribute) is not null. Otherwise it returns an empty String

Parameters:
attribute -

getConversionAttribute

public java.lang.String getConversionAttribute(AXassociation assoc)

This convenience method returns the XML attribute for OJB type conversion (conversion="foo.bar.FooToBarFieldConversion") preceded by a single blank. if the conversion class name returned by getConversionClassName(AXassociation) is not null. Otherwise it returns an empty String

Parameters:
assoc -

getConversionClassName

public java.lang.String getConversionClassName(AXattribute attribute)

Looks up the conversion class in the properties file.


getConversionClassName

public java.lang.String getConversionClassName(AXassociation assoc)

Looks up the conversion class in the properties file.

Parameters:
assoc -

isWithoutLock

public boolean isWithoutLock()

Returns true if an attribute without.lock exists and its value is "true"


getNamespaceName

public java.lang.String getNamespaceName(ru.novosoft.uml.foundation.core.MNamespace namespace)

getHibernateType

public java.lang.String getHibernateType(AXattribute attribute)

Get the hibernate type for a given attribute.

Parameters:
attribute -

getHibernateType

public java.lang.String getHibernateType(java.lang.String type)

Get the hibernate type for a given java type.

Parameters:
type -

getCascadeType

public java.lang.String getCascadeType(AXassociation assoc)

Get the hibernate cascade type (none, delete, autoupdate or all).

Parameters:
assoc -

getColumnPrefix

public java.lang.String getColumnPrefix(AXclass cls)

Get the column prefix for a given class.

Parameters:
cls -

getDbColumn

public java.lang.String getDbColumn(AXattribute attrib)

Get the db column for a given attribute.

Parameters:
attrib -

getDbColumn

public java.lang.String getDbColumn(AXclass owner,
                                    java.lang.String attributeName)

Get the db column for an attribute specified by its name and the owning class.

Parameters:
owner -
attributeName -

check

public int check(AXmodel model)

AXmodelChecker method delegated to AXdefaultModelChecker.

Specified by:
check in class AXmodelChecker

getErrorCount

public int getErrorCount()

AXmodelChecker method delegated to AXdefaultModelChecker.

Specified by:
getErrorCount in class AXmodelChecker

getWarningCount

public int getWarningCount()

AXmodelChecker method delegated to AXdefaultModelChecker.

Specified by:
getWarningCount in class AXmodelChecker

addModelCheckerListener

public void addModelCheckerListener(AXmodelCheckerListener listener)
Overrides:
addModelCheckerListener in class AXmodelChecker

removeModelCheckerListener

public void removeModelCheckerListener(AXmodelCheckerListener listener)
Overrides:
removeModelCheckerListener in class AXmodelChecker

getAllAttributesListString

public java.lang.String getAllAttributesListString(AXclass clasz)

getAllMToNAssocsListString

public java.lang.String getAllMToNAssocsListString(AXclass clasz)

getAll1ToNAssocsListString

public java.lang.String getAll1ToNAssocsListString(AXclass clasz)

getAllXToNAssocsListString

public java.lang.String getAllXToNAssocsListString(AXclass clasz)

getAllXTo1AssocsListString

public java.lang.String getAllXTo1AssocsListString(AXclass clasz)


Copyright © 2003 ARMAX mindware GmbH. All Rights Reserved.