Module: Muml_Namespace

Defined in:
lib/ontomde-java/java/xsd.rb,
lib/ontomde-java/java/java.rb

Constant Summary collapse

JAVA_IGNORE_NAMESPACE =

List of namespaces to be ignored by generator.

NOTE:

  • user may add its own item int the list.

  • list may contain package or class qualified names.

EXAMPLE:

  • “org.xyz” will ignore every item under org.xyz

  • “org.xyz.ClassZ” will ignore only ClassZ

["java.", "javax.", "xmda.bpm.api", "ontomde.bpm", "xmda.common","org.acegi"]

Instance Method Summary collapse

Instance Method Details

#java_FilePathObject

Returns the path where to generate file for this object.

NOTE:

  • Root directory is taken from context (cf: mtk_context)

Examples (with context equals to “build/”:

  • build/package1/package2

  • build/package1/package2/UneClasse.java



394
395
396
# File 'lib/ontomde-java/java/java.rb', line 394

def java_FilePath
  return java_getContextJavaFilePath()+java_InternalFilePath
end

#java_getContextJavaFilePathObject



350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
# File 'lib/ontomde-java/java/java.rb', line 350

def java_getContextJavaFilePath()
  d=context[:javaDir,nil]
  return d unless d.nil?

  n=java_qualifiedName.to_s
  #root namespace name
  rns=nil
  rnso=umlx_rootNamespace_one0
  #puts "rnso=#{rnso}" unless rnso.nil?
  rns=rnso.uml_name.to_s+'/' unless rnso.nil?
  rns=context[:defaultRootDir]+"/" if rns.nil? 

  #Hack Override package name for some generated elements
  rns='webapp/' if n.include?('struts')

  mappingPathHash=context[:javaMappingPathForRootContainer, {} ]
  if ! mappingPathHash.nil?
   override_rns=mappingPathHash[rns]
   rns=override_rns unless override_rns.nil?
  end

  rel=context[:javaRelativeDir,""]
  
  # override javaRelative
  jfp=context[:javaFilePathRegexp,nil]
  jfp.each { |mapping|
    next unless n =~ mapping[0]
    rel= "/"+mapping[1]
    break
  }
  
  #puts "rns=#{rns}"
  #puts "rel=#{rel}"
  #puts "td rns+rel=#{context[:targetDir]}|#{rns}|#{rel}|"
  return context[:targetDir]+rns+rel
end

#java_ignoreMe?(ignoreExternal = true) ⇒ Boolean

return true if java generator should totaly ignore this element.

NOTE:

  • returns true if this class name is in JAVA_IGNORE_ROOT_PACKAGE_NAME

Returns:

  • (Boolean)


445
446
447
448
449
450
451
452
453
454
# File 'lib/ontomde-java/java/java.rb', line 445

def java_ignoreMe?(ignoreExternal=true)
  #puts "ignore=#{self.class} #{self.uml_name}"
  qn=java_qualifiedName
  return true if umlx_hasStereotype?("nocode")
  return true if umlx_external? && ignoreExternal 
  JAVA_IGNORE_NAMESPACE.each { |ns|
    return true if qn.index(ns)==0
  }
  return false;
end

#java_InternalFilePathObject

Returns the internal path where to generate file for this object.

NOTE:

Examples *package1/package2 *package1/package2/UneClasse.java



405
406
407
408
409
410
411
412
# File 'lib/ontomde-java/java/java.rb', line 405

def java_InternalFilePath
  r=""
  umlx_sub_hierarchy.each { |n|
    r+=n.java_Name
    r+="/"
  }
  return r
end

#java_qualifiedNameObject

Returns this element java qualified name

Example:

package1.package2.AClassClasse
AClassInRootDefaultPackage
package1.package2


420
421
422
423
424
425
426
427
428
# File 'lib/ontomde-java/java/java.rb', line 420

def java_qualifiedName
  r=sep=""
  umlx_hierarchy.each { |n|
    r+=sep
    r+=n.java_Name
    sep="."
  }
  return r
end

#xsd_getContextJavaFilePath(default = nil) ⇒ Object



473
474
475
476
477
478
479
480
481
482
483
# File 'lib/ontomde-java/java/xsd.rb', line 473

def xsd_getContextJavaFilePath(default=nil)
  n=xsd_qualifiedName.to_s
  jfp=context[:javaFilePathRegexp,nil]
  return default if jfp.nil?
  jfp.each { |mapping|
    if n =~ mapping[0]
      return context[:targetDir]+"/"+mapping[1]
    end
  }
  return default
end

#xsd_ignoreMe?(ignoreExternal = true) ⇒ Boolean

return true if java generator should totaly ignore this element.

NOTE:

  • returns true if this class name is in JAVA_IGNORE_ROOT_PACKAGE_NAME

Returns:

  • (Boolean)


544
545
546
547
548
# File 'lib/ontomde-java/java/xsd.rb', line 544

def xsd_ignoreMe?(ignoreExternal=true)
  #puts "ignore=#{self.class} #{self.uml_name}"
  return true if java_ignoreMe?(ignoreExternal)
  return struts_isStruts?
end

#xsd_InternalFilePathObject

Returns the internal path where to generate file for this object.

NOTE:

Examples *package1/package2 *package1/package2/UneClasse.xsd



504
505
506
507
508
509
510
511
# File 'lib/ontomde-java/java/xsd.rb', line 504

def xsd_InternalFilePath
  r=""
  umlx_sub_hierarchy.each { |n|
    r+=n.xsd_Name
    r+="/"
  }
  return r
end

#xsd_qualifiedNameObject

Returns this element java qualified name

Example:

package1.package2.AClassClasse
AClassInRootDefaultPackage
package1.package2


519
520
521
522
523
524
525
526
527
# File 'lib/ontomde-java/java/xsd.rb', line 519

def xsd_qualifiedName
  r=sep=""
  umlx_hierarchy.each { |n|
    r+=sep
    r+=n.xsd_Name
    sep="."
  }
  return r
end

#xsd_SchemaNameObject

Returns the full java file name for this element (Uses: Java_FilePath and xsd_Name.) Example:

  • build/package1/package2/NomDeLaClasse.xsd



468
469
470
# File 'lib/ontomde-java/java/xsd.rb', line 468

def xsd_SchemaName
  return "#{xsd_SchemaPath}#{xsd_Name}Rec.xsd"
end

#xsd_SchemaPathObject

Returns the path where to generate file for this object.

NOTE:

  • Root directory is taken from context (cf: mtk_context)

Examples (with context equals to “build/”:

  • build/package1/package2

  • build/package1/package2/UneClasse.xsd



492
493
494
495
# File 'lib/ontomde-java/java/xsd.rb', line 492

def xsd_SchemaPath

  return xsd_getContextJavaFilePath(context[:javaRelativeDir])+xsd_InternalFilePath
end