Changeset 8041
- Timestamp:
- 23/12/11 15:20:16 (9 years ago)
- Location:
- mauRepo/xmi2sqlalchemy/trunk/src/main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
mauRepo/xmi2sqlalchemy/trunk/src/main/java/ndg/services/newmoon/collect/CollectClassesClosure.java
r8028 r8041 225 225 try { 226 226 if (input instanceof UMLAttribute) { 227 generateSimpleKeyValues((UMLAttribute) input);228 227 ret.add(extractAttribute((UMLAttribute) input)); 229 } 230 231 232 if (input instanceof UMLAssociationEnd) 228 } else if (input instanceof UMLAssociationEnd) 233 229 ret.add(extractAttribute((UMLAssociationEnd) input)); 234 230 } catch (NewmoonException e) { … … 256 252 private AttributeModel extractAttribute(UMLAttribute umlAttribute) throws NewmoonException, 257 253 IOException { 254 generateSimpleKeyValues(umlAttribute); 258 255 return extractAttribute(umlAttribute.getClassifier(), umlAttribute, cm, 259 256 hasMolteplicity(umlAttribute), UMLElementsArchive.getInstance().isVoidable(umlAttribute)); … … 291 288 attrClassModel = processUMLclass(attrClass); 292 289 } 293 290 294 291 return new AttributeModel(attrClassModel, 295 292 valueTagged.getName(), … … 302 299 303 300 private Integer extractIntegerValue(UMLValueTagged valueTagged, String bound) { 304 String sBound = UMLElementsArchive.getInstance().getTaggedValue(valueTagged, bound); 305 if (sBound == null) 301 String sBound = null; 302 if (valueTagged instanceof UMLAssociationEnd) { 303 sBound = extractMulteplicity((UMLAssociationEnd)valueTagged, bound); 304 } else { 305 sBound = UMLElementsArchive.getInstance().getTaggedValue(valueTagged, bound); 306 } 307 return extractIntegerValue(sBound); 308 } 309 310 private String extractMulteplicity(UMLAssociationEnd umlAssociationEnd, String bound){ 311 if (umlAssociationEnd.getMultiplicity().contains("..")) { 312 String[] limits = umlAssociationEnd.getMultiplicity().split("\\.\\."); 313 if (bound.equals(Dictionary.LOWER_BOUND)) { 314 return limits[0]; 315 } else { 316 return limits[1]; 317 } 318 } 319 return null; 320 } 321 322 private Integer extractIntegerValue(String value) { 323 if (value == null) 306 324 return 0; 307 if (StringUtils.isNumeric( sBound))308 return Integer.parseInt( sBound);309 if ( sBound.equals("*"))325 if (StringUtils.isNumeric(value)) 326 return Integer.parseInt(value); 327 if (value.equals("*")) 310 328 return Integer.MAX_VALUE; 311 329 return 0; -
mauRepo/xmi2sqlalchemy/trunk/src/main/java/ndg/services/newmoon/velocity/python/GenerateTables.java
r8040 r8041 233 233 while (iterator.hasNext()) { 234 234 Relationship rl = iterator.next(); 235 if (rl.isOneToOne()) 236 return; 235 237 LoopFinder lf = new LoopFinder(rl, closure.getTableModels().size(), closure); 236 238 lf.search(); … … 271 273 Iterator<ForeignKey> fk = parent.getFk().iterator(); 272 274 while (fk.hasNext()) { 273 ForeignKey tmp_fk = fk.next(); 274 if (!tmp_fk.getTableModel().equals(child) )275 ForeignKey tmp_fk = fk.next(); 276 if (!tmp_fk.getTableModel().equals(child) || tmp_fk.getAssociatedRelationship().isOneToOne()) 275 277 continue; 276 278 … … 420 422 for (Relationship rl : child.getRelationship()) { 421 423 if (!rl.getToTable().equals(onParent)) 422 continue; 424 continue; 425 423 426 rl.setRelationType(RELATION_TYPE.MANY_TO_MANY); 424 427 return; -
mauRepo/xmi2sqlalchemy/trunk/src/main/resources/global_library.vm
r8040 r8041 33 33 #set ($ft = $relation.fromTable.associatedClass.name) 34 34 #set ($tmn = $tableModel.associatedClass.name) 35 #if ($relation.isManyToMany() )35 #if ($relation.isManyToMany() && !$relation.useList) 36 36 '${relation.name}': relationship(${tt}, 37 37 secondary=${tt.toLowerCase()}_${ft.toLowerCase()}_table … … 49 49 #end 50 50 #if($relation.isOneToMany()) 51 , primaryjoin=${tt.toLowerCase()}_table.c.${ft.toLowerCase()}_${relation.name }==${tmn.toLowerCase()}_table.c.id51 , primaryjoin=${tt.toLowerCase()}_table.c.${ft.toLowerCase()}_${relation.name.toLowerCase()}==${tmn.toLowerCase()}_table.c.id 52 52 #end 53 #if($relation.isOneToOne() )54 , primaryjoin=${tt.toLowerCase()}_table.c.${ft.toLowerCase()}_${relation.name }_id==${tmn.toLowerCase()}_table.c.id53 #if($relation.isOneToOne() || !$relation.useList) 54 , primaryjoin=${tt.toLowerCase()}_table.c.${ft.toLowerCase()}_${relation.name.toLowerCase()}_id==${tmn.toLowerCase()}_table.c.id 55 55 #end 56 56 )#end -
mauRepo/xmi2sqlalchemy/trunk/src/main/resources/velocity/python/sqlAlchemyTables.vm
r8040 r8041 17 17 #end 18 18 19 #macro(checkUseAlter $fk, $fkName )19 #macro(checkUseAlter $fk, $fkName, $relName) 20 20 #if($fk.useAlter) 21 , use_alter=True, name='fk_${fkName} '#end21 , use_alter=True, name='fk_${fkName}_${relName}'#end 22 22 #end 23 23 24 24 #macro( fk $foreignKey, $tableModel) 25 25 #set ($fkName = ${foreignKey.tableModel.associatedClass.name.toLowerCase()}) 26 #set ($relName = ${foreignKey.parentAttributeName })26 #set ($relName = ${foreignKey.parentAttributeName.toLowerCase()}) 27 27 #if($foreignKey.associatedRelationship.isOneToOne() || !$foreignKey.associatedRelationship.useList) 28 Column('${fkName}_${relName}_id', Integer, ForeignKey('${fkName}.id'#checkUseAlter($foreignKey, $fkName ))),28 Column('${fkName}_${relName}_id', Integer, ForeignKey('${fkName}.id'#checkUseAlter($foreignKey, $fkName, $relName))), 29 29 #else 30 Column('${fkName}_${relName}', Integer, ForeignKey('${fkName}.id'#checkUseAlter($foreignKey, $fkName ))),30 Column('${fkName}_${relName}', Integer, ForeignKey('${fkName}.id'#checkUseAlter($foreignKey, $fkName, $relName))), 31 31 #end 32 32 #end
Note: See TracChangeset
for help on using the changeset viewer.