lib/adiwg/mdtranslator/writers/html/sections/html_entity.rb in adiwg-mdtranslator-1.4.0 vs lib/adiwg/mdtranslator/writers/html/sections/html_entity.rb in adiwg-mdtranslator-2.0.0rc2

- old
+ new

@@ -1,138 +1,115 @@ # HTML writer -# data dictionary entity +# entity # History: +# Stan Smith 2017-04-05 refactored for mdTranslator 2.0 +# Stan Smith 2015-07-16 refactored to remove global namespace $HtmlNS # Stan Smith 2015-03-26 original script -# Stan Smith 2015-07-16 refactored to remove global namespace $HtmlNS require_relative 'html_entityIndex' require_relative 'html_entityAttribute' +require_relative 'html_entityForeignKey' module ADIWG - module Mdtranslator - module Writers - module Html + module Mdtranslator + module Writers + module Html - class MdHtmlDictionaryEntity - def initialize(html) - @html = html - end + class Html_Entity - def writeHtml(hEntity) + def initialize(html) + @html = html + end - # classes used - htmlEntIndex = MdHtmlEntityIndex.new(@html) - htmlEntAttrib = MdHtmlEntityAttribute.new(@html) + def writeHtml(hEntity) - # entity - user assigned entity id - s = hEntity[:entityId] - if !s.nil? - @html.em('Entity ID: ') - @html.text!(s) - @html.br - end + # classes used + indexClass = Html_EntityIndex.new(@html) + attributeClass = Html_EntityAttribute.new(@html) + foreignClass = Html_EntityForeignKey.new(@html) - # entity - common name - s = hEntity[:entityName] - if !s.nil? - @html.em('Common name: ') - @html.text!(s) - @html.br - end + # entity - entity id + unless hEntity[:entityId].nil? + @html.em('ID: ') + @html.text!(hEntity[:entityId]) + @html.br + end - # entity - code - s = hEntity[:entityCode] - if !s.nil? - @html.em('Code name: ') - @html.text!(s) - @html.br - end + # entity - name + unless hEntity[:entityName].nil? + @html.em('Name: ') + @html.text!(hEntity[:entityName]) + @html.br + end - # entity - alias names - aAlias = hEntity[:entityAlias] - if !aAlias.empty? - @html.em('Entity aliases: ') - @html.section(:class=>'block') do - @html.text!(aAlias.to_s) - end - end + # entity - code + unless hEntity[:entityCode].nil? + @html.em('Code: ') + @html.text!(hEntity[:entityCode]) + @html.br + end - # entity - definition - s = hEntity[:entityDefinition] - if !s.nil? - @html.em('Definition: ') - @html.section(:class=>'block') do - @html.text!(s.to_s) - end - end + # entity - alias names + hEntity[:entityAlias].each do |otherName| + @html.em('Alias: ') + @html.section(:class => 'block') do + @html.text!(otherName) + end + end - # entity - primary key - aPK = hEntity[:primaryKey] - if !aPK.empty? - @html.em('Primary key: ') - @html.text!(aPK.to_s) - @html.br + # entity - definition + unless hEntity[:entityDefinition].nil? + @html.em('Definition: ') + @html.section(:class => 'block') do + @html.text!(hEntity[:entityDefinition]) + end + end + + # entity - primary key + unless hEntity[:primaryKey].empty? + @html.em('Primary Key Attribute(s):') + @html.section(:class => 'block') do + hEntity[:primaryKey].each do |attribute| + @html.text!(attribute) + @html.br end + end + end - # entity - other indexes - aIndex = hEntity[:indexes] - if !aIndex.empty? - aIndex.each do |hIndex| - @html.em('Index: ') - @html.section(:class=>'block') do - htmlEntIndex.writeHtml(hIndex) - end - end + # entity - indexes [] {entityIndex} + hEntity[:indexes].each do |hIndex| + @html.details do + @html.summary('Index: '+hIndex[:indexCode], {'class' => 'h5'}) + @html.section(:class => 'block') do + indexClass.writeHtml(hIndex) end + end + end - # entity - attributes - aAttributes = hEntity[:attributes] - if !aAttributes.empty? - @html.em('Attribute List: ') - aAttributes.each do |hAttribute| - @html.section(:class=>'block') do - @html.details do - @html.summary(hAttribute[:attributeCode], {'class'=>'h5'}) - @html.section(:class=>'block') do - htmlEntAttrib.writeHtml(hAttribute) - end - end - end - end + # entity - attributes [] {entityAttribute} + hEntity[:attributes].each do |hAttribute| + @html.details do + @html.summary('Attribute: '+hAttribute[:attributeCode], {'class' => 'h5'}) + @html.section(:class => 'block') do + attributeClass.writeHtml(hAttribute) end + end + end - # entity - foreign keys - aFKs = hEntity[:foreignKeys] - if !aFKs.empty? - aFKs.each do |hFK| - @html.em('Foreign Key: ') - @html.section(:class=>'block') do - - # foreign key - local attribute list - @html.em('Local attribute: ') - @html.text!(hFK[:fkLocalAttributes].to_s) - @html.br - - # foreign key - referenced entity - @html.em('Referenced entity: ') - @html.text!(hFK[:fkReferencedEntity]) - @html.br - - # foreign key - referenced attribute list - @html.em('Referenced attribute: ') - @html.text!(hFK[:fkReferencedAttributes].to_s) - @html.br - - end - - end + # entity - foreign keys [] {entityForeignKey} + hEntity[:foreignKeys].each do |hForeign| + @html.details do + @html.summary('ForeignKey', {'class' => 'h5'}) + @html.section(:class => 'block') do + foreignClass.writeHtml(hForeign) end + end + end - end # writeHtml + end # writeHtml + end # Html_Entity - end # class - - end - end - end + end + end + end end