Class: CapicuaGen::Gaspar::CSCatalogWindowsFormFeature

Inherits:
TemplateFeature
  • Object
show all
Includes:
CapicuaGen, CapicuaGen::Gaspar, Melchior
Defined in:
lib/CapicuaGenGaspar/GUI/CSCatalogWindowsForm/Source/cs_catalog_windows_form_feature.rb

Overview

Caracteristica generadora de catalogos para las entidades

Instance Method Summary collapse

Methods included from CapicuaGen::Gaspar

#get_about_class_full_name, #get_about_class_name, #get_app_config_file, #get_db_connection_name_method, #get_db_connection_provider_method, #get_db_connection_string_method, #get_entity_data_access_full_name, #get_entity_data_access_name, #get_entity_full_name, #get_entity_interface_full_name, #get_entity_interface_name, #get_entity_name, #get_main_form_class_full_name, #get_main_form_class_name, #get_namespaces, #get_namespaces_text, #get_splash_class_full_name, #get_splash_class_name

Constructor Details

#initialize(values = {}) ⇒ CSCatalogWindowsFormFeature

Inicializa la caracteristica



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/CapicuaGenGaspar/GUI/CSCatalogWindowsForm/Source/cs_catalog_windows_form_feature.rb', line 41

def initialize(values= {})
  super(values)

  # Configuro los tipos si estos no han sido configurados previamente
  self.types= [:catalog] if self.types.blank?

  # Configuro los templates
  set_template("catalogState", Template.new(:file => 'CatalogState.erb'))
  set_template('catalogForm', Template.new(:file => 'catalogForm.erb'))
  set_template('catalogForm.designer', Template.new(:file => 'catalogForm.Designer.erb'))
  set_template('catalogForm.resx', Template.new(:file => 'catalogForm.resx.erb'))

end

Instance Method Details

#configure_attributesObject

Configura los atributos personalizados de la caracteristica (antes de establecer el generador)



102
103
104
105
# File 'lib/CapicuaGenGaspar/GUI/CSCatalogWindowsForm/Source/cs_catalog_windows_form_feature.rb', line 102

def configure_attributes()
  self.generation_attributes[:out_dir]  = "#{self.generation_attributes[:out_dir]}/#{self.generation_attributes[:namespace]}/Windows.Forms/EntityCatalogs" unless self.generation_attributes.has_in_self?(:out_dir)
  self.generation_attributes[:namespace]= "#{self.generation_attributes[:namespace]}.Windows.Forms.EntityCatalogs" unless self.generation_attributes.has_in_self?(:namespace)
end

#configure_template_targetsObject

Configura los objetivos de las platillas (despues de establecer el generador)



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/CapicuaGenGaspar/GUI/CSCatalogWindowsForm/Source/cs_catalog_windows_form_feature.rb', line 56

def configure_template_targets

  # Configuro los templates
  set_template_target('catalogState', TemplateTarget.new(:out_file => "CatalogState.cs", :types => :proyect_file))

  # Busco  las caracteristicas que contiene entidades de SQL para una table
  get_tables do |e|

    set_template_target("catalogForm/#{get_entity_catalog_name(e.name)}",
                        TemplateTarget.new(
                            :out_file      => "#{get_entity_catalog_name(e.name)}.cs",
                            :types         => :proyect_file,
                            :class_name    => get_entity_catalog_name(e.name),
                            :entity_schema => e
                        )
    )

    set_template_target("catalogForm.designer/#{get_entity_catalog_name(e.name)}",
                        TemplateTarget.new(
                            :out_file      => "#{get_entity_catalog_name(e.name)}.designer.cs",
                            :types         => :proyect_file,
                            :class_name    => get_entity_catalog_name(e.name),
                            :entity_schema => e
                        )
    )

    set_template_target("catalogForm.resx/#{get_entity_catalog_name(e.name)}",
                        TemplateTarget.new(
                            :out_file      => "#{get_entity_catalog_name(e.name)}.resx",
                            :types         => :proyect_file,
                            :class_name    => get_entity_catalog_name(e.name),
                            :entity_schema => e
                        )
    )

  end

end

#get_entity_by_catalog_name(catalog_name) ⇒ Object

Devuelve una entidad en base al nombre de su catalogo



134
135
136
137
138
139
140
141
142
# File 'lib/CapicuaGenGaspar/GUI/CSCatalogWindowsForm/Source/cs_catalog_windows_form_feature.rb', line 134

def get_entity_by_catalog_name(catalog_name)
  # Busco  las caracteristicas que contiene entidades de SQL para una table
  get_tables do |e|
    if catalog_name==get_entity_catalog_name(e.name)
      return e
    end
  end
  return nil
end

#get_entity_catalog_full_name(entity_name) ⇒ Object

Obtiene el nombre completo de un catalogo en base al nombre de una entidad



113
114
115
# File 'lib/CapicuaGenGaspar/GUI/CSCatalogWindowsForm/Source/cs_catalog_windows_form_feature.rb', line 113

def get_entity_catalog_full_name (entity_name)
  return "#{self.generation_attributes[:namespace]}.#{get_entity_catalog_name(entity_name)}"
end

#get_entity_catalog_name(entity_name) ⇒ Object

Obtiene el nombre de un catalogo en base al nombre de una entidad



108
109
110
# File 'lib/CapicuaGenGaspar/GUI/CSCatalogWindowsForm/Source/cs_catalog_windows_form_feature.rb', line 108

def get_entity_catalog_name(entity_name)
  return "#{entity_name}Catalog"
end

#get_entity_catalogs_full_nameObject

Obtiene el nombre completo de todos los catalogos



118
119
120
121
122
123
# File 'lib/CapicuaGenGaspar/GUI/CSCatalogWindowsForm/Source/cs_catalog_windows_form_feature.rb', line 118

def get_entity_catalogs_full_name
  # Busco  las caracteristicas que contiene entidades de SQL para una table
  get_tables do |e|
    yield get_entity_catalog_full_name e.name
  end
end

#get_entity_catalogs_nameObject

Obtiene el nombre de todos los catalogos



126
127
128
129
130
131
# File 'lib/CapicuaGenGaspar/GUI/CSCatalogWindowsForm/Source/cs_catalog_windows_form_feature.rb', line 126

def get_entity_catalogs_name
  # Busco  las caracteristicas que contiene entidades de SQL para una table
  get_tables do |e|
    yield get_entity_catalog_name e.name
  end
end

#reset_attributesObject

Resetea los atributos personalizados de la caracteristica (antes de establecer el generador)



96
97
98
99
# File 'lib/CapicuaGenGaspar/GUI/CSCatalogWindowsForm/Source/cs_catalog_windows_form_feature.rb', line 96

def reset_attributes
  self.generation_attributes[:out_dir]  = nil
  self.generation_attributes[:namespace]= nil
end