lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_entity.rb in adiwg-mdtranslator-1.4.0 vs lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_entity.rb in adiwg-mdtranslator-2.0.0rc2
- old
+ new
@@ -1,37 +1,40 @@
+# mdJson 2.0 writer - entity
+
+# History:
+# Stan Smith 2017-03-19 original script
+
require 'jbuilder'
-require_relative 'mdJson_base'
-require_relative 'mdJson_attribute'
+require_relative 'mdJson_entityAttribute'
+require_relative 'mdJson_entityIndex'
+require_relative 'mdJson_entityForeignKey'
module ADIWG
- module Mdtranslator
- module Writers
- module MdJson
- module Entity
- extend MdJson::Base
+ module Mdtranslator
+ module Writers
+ module MdJson
- def self.build(intObj)
- Jbuilder.new do |json|
- json.entityId intObj[:entityId]
- json.commonName intObj[:entityName]
- json.codeName intObj[:entityCode]
- json.alias intObj[:entityAlias]
- json.definition intObj[:entityDefinition]
- json.primaryKeyAttributeCodeName (intObj[:primaryKey])
- json.index(intObj[:indexes]) do |idx|
- json.codeName idx[:indexCode]
- json.allowDuplicates idx[:duplicate]
- json.attributeCodeName (idx[:attributeNames])
- end unless intObj[:indexes].empty?
- json.attribute json_map(intObj[:attributes], Attribute)
- json.foreignKey(intObj[:foreignKeys]) do |fk|
- json.localAttributeCodeName(fk[:fkLocalAttributes])
- json.referencedEntityCodeName fk[:fkReferencedEntity]
- json.referencedAttributeCodeName(fk[:fkReferencedAttributes])
- end unless intObj[:foreignKeys].empty?
- end
- end
- end
+ module Entity
+
+ @Namespace = ADIWG::Mdtranslator::Writers::MdJson
+
+ def self.build(hEntity)
+
+ Jbuilder.new do |json|
+ json.entityId hEntity[:entityId]
+ json.commonName hEntity[:entityName]
+ json.codeName hEntity[:entityCode]
+ json.alias hEntity[:entityAlias] unless hEntity[:entityAlias].empty?
+ json.definition hEntity[:entityDefinition]
+ json.primaryKeyAttributeCodeName hEntity[:primaryKey] unless hEntity[:primaryKey].empty?
+ json.index @Namespace.json_map(hEntity[:indexes], EntityIndex)
+ json.attribute @Namespace.json_map(hEntity[:attributes], EntityAttribute)
+ json.foreignKey @Namespace.json_map(hEntity[:foreignKeys], EntityForeignKey)
+ end
+
+ end # build
+ end # Entity
+
+ end
end
- end
- end
+ end
end