Changeset 8455 for mauRepo


Ignore:
Timestamp:
10/07/12 13:48:17 (7 years ago)
Author:
mnagni
Message:

Corrected method "synchronize" for the python classes (pythonClass.vm). Now do not lost values
Removed some unnecessary imports

Location:
mauRepo/xmi2sqlalchemy/trunk/src/main
Files:
8 edited

Legend:

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

    r8393 r8455  
    3434 
    3535import org.apache.commons.collections.CollectionUtils; 
    36 import org.apache.commons.collections.SetUtils; 
    3736import org.apache.commons.io.IOUtils; 
    3837import org.apache.commons.lang.StringUtils; 
  • mauRepo/xmi2sqlalchemy/trunk/src/main/java/ndg/services/newmoon/NmParserHelper.java

    r8393 r8455  
    3636import java.util.Arrays; 
    3737import java.util.HashSet; 
    38 import java.util.List; 
    3938import java.util.Set; 
     39import ndg.services.newmoon.xmiModel.UMLModel; 
    4040 
    41 import ndg.services.newmoon.xmiModel.UMLAssociation; 
    42 import ndg.services.newmoon.xmiModel.UMLGeneralization; 
    43 import ndg.services.newmoon.xmiModel.UMLModel; 
    44 import ndg.services.newmoon.xmiModel.UML_Element; 
    45 import ndg.services.newmoon.xmiModel.UML_ID; 
    4641 
    4742import org.apache.commons.io.IOUtils; 
  • mauRepo/xmi2sqlalchemy/trunk/src/main/java/ndg/services/newmoon/UmlToRDBM.java

    r8393 r8455  
    3535 
    3636import java.io.File; 
    37 import java.io.FileNotFoundException; 
    3837import java.io.IOException; 
    3938import java.io.InputStream; 
    40 import java.util.Collection; 
    4139import java.util.HashMap; 
    4240import java.util.HashSet; 
     
    4745import java.util.concurrent.Future; 
    4846 
    49 import ndg.services.newmoon.NewmoonManager.NM_PARAM; 
    5047import ndg.services.newmoon.collect.AttributeModel; 
    5148import ndg.services.newmoon.collect.ClassModel; 
     
    5653import ndg.services.newmoon.velocity.python.GenerateFromClassModel; 
    5754import ndg.services.newmoon.velocity.python.GenerateTables; 
    58 import ndg.services.newmoon.xmiModel.UMLClass; 
    5955import ndg.services.newmoon.xmiModel.UMLModel; 
    6056 
    61 import org.apache.commons.collections.CollectionUtils; 
    6257import org.apache.commons.collections.ListUtils; 
    63 import org.apache.commons.io.FileUtils; 
    6458import org.apache.commons.io.IOUtils; 
    6559import org.apache.commons.lang.StringUtils; 
     
    171165        } 
    172166         
     167        @SuppressWarnings("unchecked") 
    173168        private void substitutesSuperAttributes(List<ClassModel> cms) { 
    174169                //creates a map between parents and childrens (classes and their subclasses) 
  • mauRepo/xmi2sqlalchemy/trunk/src/main/java/ndg/services/newmoon/velocity/python/GenerateTables.java

    r8243 r8455  
    4141import java.util.Set; 
    4242 
    43 import ndg.services.newmoon.MaxDepthException; 
    44 import ndg.services.newmoon.NewmoonException; 
    4543import ndg.services.newmoon.UMLElementsArchive; 
    4644import ndg.services.newmoon.collect.AttributeModel; 
     
    5553 
    5654import org.apache.commons.collections.CollectionUtils; 
    57 import org.apache.commons.collections.SetUtils; 
    5855import org.apache.commons.lang.text.StrBuilder; 
    5956import org.apache.velocity.context.Context; 
  • mauRepo/xmi2sqlalchemy/trunk/src/main/java/ndg/services/newmoon/velocity/python/NmVelocity.java

    r8393 r8455  
    3434 
    3535import org.apache.velocity.Template; 
    36 import org.apache.velocity.VelocityContext; 
    3736import org.apache.velocity.app.VelocityEngine; 
    3837import org.apache.velocity.context.Context; 
  • mauRepo/xmi2sqlalchemy/trunk/src/main/java/ndg/services/newmoon/velocity/python/NmVelocityHelper.java

    r8393 r8455  
    4747 
    4848import org.apache.commons.collections.CollectionUtils; 
    49 import org.apache.commons.collections.ListUtils; 
    50 import org.apache.commons.collections.SetUtils; 
    5149import org.apache.commons.lang.StringUtils; 
    5250 
     
    165163                return ret; 
    166164        } 
    167          
    168 //      /** 
    169 //       * Returns an array containg on the first element the name of the module from 
    170 //       * where import and on the second the name of which class import. This methods 
    171 //       * takes care to substitute when necesary the   
    172 //       * @param className a class name 
    173 //       * @return a two elements array, <code>null</code> if {@link #isExternallyMapped(String)} returns <code>false</code>  
    174 //       * */ 
    175 //      @Deprecated 
    176 //      public static String[] getMappedImportImport(String className) { 
    177 //              String[] ret = null; 
    178 //              if (isExternallyMapped(className)) { 
    179 //                      ret = new String[2]; 
    180 //                      String clazz = getXMIToSQL().getProperty(className); 
    181 //                      ret[0] = StringUtils.substringBeforeLast(clazz, "."); 
    182 //                      ret[1] = StringUtils.substringAfterLast(clazz, "."); 
    183 //              }  
    184 //              return ret; 
    185 //      } 
    186 // 
    187 //      @Deprecated 
    188 //      private static String getMappedPythonImport(String className, String type) { 
    189 //              String[] ret = getMappedImportImport(className); 
    190 //              if (ret != null) { 
    191 //                      if (type.equals("Module")) { 
    192 //                              return ret[0];   
    193 //                      } else if (type.equals("Class")) { 
    194 //                              return ret[1]; 
    195 //                      }                        
    196 //              }  
    197 //              return className;  
    198 //      }  
    199 //       
    200 //      /** 
    201 //       * Returns the module from where import a given class. Is a shortway to get  
    202 //       * the first element of {@link #getMappedImportImport(String)} 
    203 //       * @param className a class name 
    204 //       * @return the module name, else return the given className  
    205 //       **/ 
    206 //      @Deprecated 
    207 //      public static String getMappedModule(String className) { 
    208 //              return getMappedPythonImport(className, "Module"); 
    209 //      }        
    210 // 
    211 //      /** 
    212 //       * Returns the Class from where import a given class. Is a shortway to get  
    213 //       * the first element of {@link #getMappedImportImport(String)} 
    214 //       * @param className a class name 
    215 //       * @return the module name, else return the given className  
    216 //       **/ 
    217 //      @Deprecated 
    218 //      public static String getMappedClass(String className) { 
    219 //              return getMappedPythonImport(className, "Class"); 
    220 //      }        
    221165         
    222166        private static String formatPythonImportString(UMLClassDataType umlClass, String type) { 
  • mauRepo/xmi2sqlalchemy/trunk/src/main/java/ndg/services/newmoon/velocity/python/PythonClassModel.java

    r8085 r8455  
    110110                return closure.getImportMap(); 
    111111        }                
    112  
    113         /* 
    114         private void importInheritedTypes(ClassModel classModel, List toImport) { 
    115                 if (!CollectionUtils.isEmpty(classModel.getParents())) { 
    116                         for (ClassModel cm : classModel.getParents()) { 
    117                                 importInheritedTypes(cm, toImport); 
    118                         } 
    119                 }                
    120                 CollectionUtils.addAll(toImport, classModel.getAttributeModel().iterator()); 
    121         } 
    122         */ 
    123112         
    124113        public UMLClass getStereotypeImplementation() { 
  • mauRepo/xmi2sqlalchemy/trunk/src/main/resources/velocity/python/pythonClass.vm

    r8436 r8455  
    137137##end 
    138138#foreach($attr in $attributes) 
    139 #if(!$attr.getParentName() && $attr.hasMultiplicity()) 
     139#if(!$attr.getParentName() && $attr.hasMultiplicity() && $attr.subTypes) 
     140${tab}${tab}int_${attr.name} = self.${attr.name}         
    140141#foreach($type in $attr.subTypes) 
    141142#set ( $assoClassL = "$type.associatedClass.name.toLowerCase()") 
     
    146147#foreach($attr in $attributes) 
    147148#if(!$attr.getParentName() && $attr.hasMultiplicity() && $attr.subTypes) 
    148 ${tab}${tab}for item in self.${attr.name}:       
     149${tab}${tab}for item in int_${attr.name}:        
     150${tab}${tab}${tab}valueClass = "%s.%s" % (type(item).__module__,type(item).__name__) 
    149151#foreach($type in $attr.subTypes) 
    150152#set ( $assoClassL = "$type.associatedClass.name.toLowerCase()") 
    151 ${tab}${tab}${tab}valueClass = "%s.%s" % (type(item).__module__,type(item).__name__) 
    152153${tab}${tab}${tab}if valueClass == "${vh.getMappedModule($type.associatedClass)}.${type.associatedClass.name}": 
    153154${tab}${tab}${tab}${tab}self._${attr.name}_${assoClassL}.append(item) 
     
    208209 
    209210#importing($imports) 
    210 from ascore.utils import has_value, collectionProofHash 
     211from ascore.utils import collectionProofHash 
    211212 
    212213''' 
Note: See TracChangeset for help on using the changeset viewer.