Changeset 8006


Ignore:
Timestamp:
06/12/11 16:32:27 (8 years ago)
Author:
mnagni
Message:
 
Location:
mauRepo/xmi2sqlalchemy/trunk/src/main
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/xmi2sqlalchemy/trunk/src/main/java/ndg/services/newmoon/collect/CollectClassesClosure.java

    r8005 r8006  
    4040 
    4141import ndg.services.newmoon.NewmoonException; 
    42 import ndg.services.newmoon.NmParser; 
    4342import ndg.services.newmoon.UMLElementsArchive; 
    4443import ndg.services.newmoon.velocity.python.GenerateClasses.EmbeddedType; 
     
    5251import ndg.services.newmoon.xmiModel.UMLClassDataType; 
    5352import ndg.services.newmoon.xmiModel.UMLDataType; 
    54 import ndg.services.newmoon.xmiModel.UMLModel; 
    5553import ndg.services.newmoon.xmiModel.UMLStereotype; 
    5654import ndg.services.newmoon.xmiModel.UMLValueTagged; 
     
    6260import org.apache.commons.lang.StringUtils; 
    6361import org.apache.commons.lang.math.NumberUtils; 
    64 import org.w3c.dom.Node; 
    6562 
    6663/** 
     
    175172                UMLClass item = null; 
    176173                while (items.hasNext()) { 
    177                         item = items.next(); 
     174                        item = items.next();                     
    178175                        CollectionUtils.addIgnoreNull(cm.getParents(), processUMLclass(item)); 
    179176                } 
    180177        } 
    181178 
     179 
     180         
    182181        private void processStereotype(ClassModel cm) { 
    183182                // Set<UMLStereotype> stereotypes = 
  • mauRepo/xmi2sqlalchemy/trunk/src/main/java/ndg/services/newmoon/velocity/python/GenerateClassesClosure.java

    r8004 r8006  
    124124                        CollectionUtils.addAll(toImport, cm.getAttributeModel().iterator()); 
    125125                        //not the best solution but ok for now 
    126                         toImport.add(new ASText());                      
     126                        //toImport.add(new ASText());                    
    127127                } 
    128128                 
  • mauRepo/xmi2sqlalchemy/trunk/src/main/java/ndg/services/newmoon/velocity/python/GenerateTables_.java

    r8004 r8006  
    170170                sqlTablesWriter.append("from sqlalchemy.orm.util import class_mapper\n");                
    171171                sqlTablesWriter.append("from sqlalchemy.schema import ForeignKeyConstraint\n\n"); 
     172                sqlTablesWriter.append("from ascore.astext import ASText\n\n"); 
    172173 
    173174                sqlTablesWriter.flush(); 
  • mauRepo/xmi2sqlalchemy/trunk/src/main/java/ndg/services/newmoon/velocity/python/InnerGenerateTablesClosure.java

    r8005 r8006  
    220220                return (classModel.isCodeList()  
    221221                                || classModel.isEnumeration()  
    222                                 || checkIfIsPrimitiveAttribute(classModel) 
    223                                 || classModel.getStereotype().equals(STEREOTYPE.Metaclass)); 
     222                                || checkIfIsPrimitiveAttribute(classModel)); 
    224223        } 
    225224 
  • mauRepo/xmi2sqlalchemy/trunk/src/main/resources/global_library.vm

    r8004 r8006  
    1 #macro( substituteType $typeName) 
     1#macro( substituteClassType $typeName) 
    22#if($typeName.equals('CharacterString')) 
    3 ASText#elseif($typeName.equals('Character')) 
    4 ASText#elseif($typeName.equals('Integer')) 
     3str#elseif($typeName.equals('Character')) 
     4str#else 
     5${typeName} 
     6#end 
     7#end 
     8 
     9#macro( substituteDBType $typeName) 
     10#if($typeName.equals('CharacterString')) 
     11TEXT#elseif($typeName.equals('Character')) 
     12TEXT#elseif($typeName.equals('Integer')) 
    513Integer#elseif($typeName.equals('Boolean')) 
    614BOOLEAN#elseif($typeName.equals('Real')) 
  • mauRepo/xmi2sqlalchemy/trunk/src/main/resources/velocity/python/notSortableMapping_1.vm

    r7996 r8006  
    11## notSortableMapping_1.vm 
    22 
    3 mapper($tableModel.associatedClass.name, #tableName($tableModel)#inheritedClasses($tableModel)) 
     3mapper($tableModel.associatedClass.name, #tableName($tableModel)) 
    44 
  • mauRepo/xmi2sqlalchemy/trunk/src/main/resources/velocity/python/pythonClass.vm

    r8004 r8006  
    1111#macro( superclass $superclasses, $stereotype) 
    1212#if($superclasses.size() == 0 && !$stereotype) 
    13 $object#end 
    14 #if($stereotype) 
    15 ${stereotype.name}#end 
    16 #if($stereotype && $superclasses.size() > 0),#end 
    17 #if($superclasses.size() > 0) 
     13$object#elseif($stereotype && $superclasses.size() == 0) 
     14${stereotype.name}#elseif($superclasses.size() > 0) 
    1815#foreach( $classModel in $superclasses) 
    1916${classModel.associatedClass.name}#if($foreach.hasNext),#end 
     
    4037#macro (unionDictionary $attributeModel) 
    4138#foreach($item in $attributeModel) 
    42 '${item.name}':#substituteType(${item.associatedType.associatedClass.name})#if($foreach.hasNext),#end   
     39'${item.name}':#substituteClassType(${item.associatedType.associatedClass.name})#if($foreach.hasNext),#end   
    4340#end 
    4441#end 
     
    9693#end 
    9794 
     95#macro( addAggregate $classModel) 
     96#foreach($parent in $classModel.parents) 
     97#if (!($parent.isEnumeration() || $parent.isCodeList() || $parent.isUnion())) 
     98${tab}self._${parent.associatedClass.name} 
     99#end 
     100#end 
     101#end 
     102 
    98103 
    99104#macro( importing $toImport) 
     
    133138${tab}''' 
    134139${tab}def __init__(self): 
    135 ${tab}${tab}super(${classModel.associatedClass.name}, self).__init__() 
     140${tab}#addAggregate($classModel) 
     141${tab}super(${classModel.associatedClass.name}, self).__init__() 
    136142#end 
    137143#if (!($classModel.isEnumeration() || $classModel.isCodeList() || $classModel.isUnion())) 
  • mauRepo/xmi2sqlalchemy/trunk/src/main/resources/velocity/python/sqlAlchemyTables.vm

    r8004 r8006  
    66 
    77#macro( attributeType $attribute) 
    8 #if(($attribute.associatedType.isCodeList() || $attribute.associatedType.isEnumeration())) 
     8#if($attribute.associatedType.associatedClass.name.equalsIgnoreCase('boolean') 
     9&& ($attribute.associatedType.isCodeList() || $attribute.associatedType.isEnumeration())) 
    910${attribute.associatedType.associatedClass.name}.db_type()#elseif($attribute.hasMultiplicity()) 
    10 ARRAY(#substituteType(${attribute.associatedType.associatedClass.name}))#else 
    11 #substituteType(${attribute.associatedType.associatedClass.name})(#if($attribute.lenght > 0)${attribute.lenght}#end)#end 
     11ARRAY(#substituteDBType(${attribute.associatedType.associatedClass.name}))#else 
     12#substituteDBType(${attribute.associatedType.associatedClass.name})#end 
    1213#end 
    1314 
Note: See TracChangeset for help on using the changeset viewer.