Permalink
Browse files

Final part of renaming the model.

  • Loading branch information...
1 parent 0aa4f5e commit 8389d6cb1bf2c2b92235a348b3adc0649ce233ef @cpoirier committed Mar 16, 2012
Showing with 161 additions and 155 deletions.
  1. +3 −5 lib/schemaform.rb
  2. +2 −2 lib/schemaform/adapters/generic_sql/adapter.rb
  3. +2 −2 lib/schemaform/adapters/generic_sql/mapping/entity_map.rb
  4. +1 −1 lib/schemaform/adapters/generic_sql/schema/builders.rb
  5. +7 −7 lib/schemaform/adapters/generic_sql/type_manager.rb
  6. +7 −7 lib/schemaform/language/entity_definition.rb
  7. +9 −9 lib/schemaform/language/formula_capture.rb
  8. +1 −1 lib/schemaform/language/formula_definition.rb
  9. +7 −5 lib/schemaform/language/formula_inversion.rb
  10. +3 −3 lib/schemaform/language/placeholders/entity_tuple.rb
  11. +2 −2 lib/schemaform/language/placeholders/literal_list.rb
  12. +2 −2 lib/schemaform/language/placeholders/literal_set.rb
  13. +1 −1 lib/schemaform/language/schema_definition.rb
  14. +15 −15 lib/schemaform/language/tuple_definition.rb
  15. +2 −0 lib/schemaform/migration/driver.rb
  16. +2 −2 lib/schemaform/model/accessor.rb
  17. +2 −2 lib/schemaform/model/accessor_types/defined_accessor.rb
  18. +2 −2 lib/schemaform/model/accessor_types/generated_accessor.rb
  19. +2 −2 lib/schemaform/model/accessor_types/key_accessor.rb
  20. +2 −2 lib/schemaform/model/attribute.rb
  21. +2 −2 lib/schemaform/model/attribute_types/derived_attribute.rb
  22. +2 −2 lib/schemaform/model/attribute_types/id_attribute.rb
  23. +2 −2 lib/schemaform/model/attribute_types/optional_attribute.rb
  24. +2 −2 lib/schemaform/model/attribute_types/required_attribute.rb
  25. +2 −2 lib/schemaform/model/attribute_types/type_attribute.rb
  26. +2 −2 lib/schemaform/model/collection.rb
  27. +2 −2 lib/schemaform/model/component.rb
  28. +2 −2 lib/schemaform/model/element.rb
  29. +2 −2 lib/schemaform/model/entity.rb
  30. +2 −2 lib/schemaform/model/entity_types/defined_entity.rb
  31. +2 −2 lib/schemaform/model/entity_types/derived_entity.rb
  32. +2 −2 lib/schemaform/model/key.rb
  33. +2 −2 lib/schemaform/model/list.rb
  34. +2 −2 lib/schemaform/model/projection.rb
  35. +2 −0 lib/schemaform/model/schema.rb
  36. +2 −2 lib/schemaform/model/set.rb
  37. +2 −2 lib/schemaform/model/tuple.rb
  38. +2 −2 lib/schemaform/model/type.rb
  39. +2 −2 lib/schemaform/model/type_manager.rb
  40. +2 −2 lib/schemaform/model/types/boolean_type.rb
  41. +2 −2 lib/schemaform/model/types/coded_type.rb
  42. +2 −2 lib/schemaform/model/types/collection_type.rb
  43. +2 −2 lib/schemaform/model/types/date_time_type.rb
  44. +2 −2 lib/schemaform/model/types/entity_reference_type.rb
  45. +2 −2 lib/schemaform/model/types/enumerated_type.rb
  46. +2 −2 lib/schemaform/model/types/identifier_type.rb
  47. +2 −2 lib/schemaform/model/types/indirect_type.rb
  48. +2 −2 lib/schemaform/model/types/integer_type.rb
  49. +2 −2 lib/schemaform/model/types/list_type.rb
  50. +2 −2 lib/schemaform/model/types/numeric_type.rb
  51. +2 −2 lib/schemaform/model/types/reference_type.rb
  52. +2 −2 lib/schemaform/model/types/scalar_type.rb
  53. +2 −2 lib/schemaform/model/types/set_type.rb
  54. +2 −2 lib/schemaform/model/types/string_type.rb
  55. +2 −2 lib/schemaform/model/types/structured_type.rb
  56. +2 −2 lib/schemaform/model/types/tuple_type.rb
  57. +1 −1 lib/schemaform/model/types/unknown_type.rb
  58. +2 −2 lib/schemaform/model/types/user_defined_type.rb
  59. +2 −2 lib/schemaform/model/types/void_type.rb
  60. +7 −5 lib/schemaform/plan/builders.rb
  61. +1 −1 lib/schemaform/plan/tuple.rb
  62. +2 −2 lib/schemaform/runtime/workspace.rb
View
@@ -60,13 +60,13 @@ def self.defined?( name, version = nil )
#
- # Creates a Schema and calls your block to fill it in (see Schema::DefinitionLanguage).
+ # Creates a Schema and calls your block to fill it in (see Language::SchemaDefinition).
def self.define( name, version, &block )
@@schemas.register(VersionSet.new(name)) unless @@schemas.member?(name)
assert(!@@schemas[name].member?(version), "Schema #{name} version #{version} is already defined")
- Schema.new(name, version).use do |schema|
+ Model::Schema.new(name, version).use do |schema|
@@schemas[name][version] = schema
Language::SchemaDefinition.process(schema, &block)
end
@@ -205,9 +205,7 @@ def self.log_to( stream )
private
- require locate("schemaform/schema.rb")
-
- ["utilities", "language", "productions", "plan", "adapters", "runtime", "migration"].each do |directory|
+ ["utilities", "model", "language", "productions", "plan", "adapters", "runtime", "migration"].each do |directory|
Dir[Schemaform.locate("schemaform/#{directory}/*.rb")].each do |path|
require path
end
@@ -136,8 +136,8 @@ def print_to( printer )
def initialize( address, overrides = {} )
@address = address
@tables = Registry.new() # name => Table
- @schema_maps = {} # Schemaform::Schema => SchemaMap
- @entity_maps = {} # Schemaform::Schema::Entity => EntityMap
+ @schema_maps = {} # Schemaform::Model::Schema => SchemaMap
+ @entity_maps = {} # Schemaform::Model::Entity => EntityMap
@query_plans = {} # Language::Placeholder => QueryPlan
@monitor = Monitor.new()
@overrides = overrides
@@ -20,7 +20,7 @@
#
-# Captures informtion about how a Schema::Entity is mapped into Tables and Fields.
+# Captures informtion about how a Model::Entity is mapped into Tables and Fields.
module Schemaform
module Adapters
@@ -39,7 +39,7 @@ def initialize( schema_map, entity, anchor_table, base_map = nil )
@base_map = base_map || (entity.base_entity.exists? ? @schema_map[entity.base_entity] : nil)
@parent_links = {} # child Table => Link
@all_links = Hash.new(){|h, k| h[k] = {}} # descendent Table => { ancestor Table => Link }
- @mappings = Hash.new(){|h, k| h[k] = {}} # Schema::Attribute => { aspect => Field }
+ @mappings = Hash.new(){|h, k| h[k] = {}} # Model::Attribute => { aspect => Field }
@sources = {} # Field => source Field
@copies = Hash.new(){|h, k| h[k] = []} # source Field => [all copies]
@schema_map.register_table(anchor_table)
@@ -271,7 +271,7 @@ def current_optionality()
def with_attribute( attribute )
@attribute_stack.push_and_pop(AttributeFrame.new(attribute, Language::Productions::ValueAccessor)) do
- @table_stack.top.current_optionality = attribute.is_a?(Schema::OptionalAttribute)
+ @table_stack.top.current_optionality = attribute.is_a?(Model::OptionalAttribute)
name_stack.push_and_pop((name_stack.top || @adapter.empty_name()) + attribute.name) do
yield
end
@@ -75,22 +75,22 @@ def scalar_type( type )
case type
when TypeInfo
type
- when Schemaform::Schema::StringType
+ when Schemaform::Model::StringType
if type.typeof?(type.schema.text_type) then
text_type(type.length)
else
binary_type(type.length)
end
- when Schemaform::Schema::BooleanType, :boolean
+ when Schemaform::Model::BooleanType, :boolean
boolean_type()
- when Schemaform::Schema::IntegerType, :integer
+ when Schemaform::Model::IntegerType, :integer
integer_type(type.range)
- when Schemaform::Schema::NumericType, :real
+ when Schemaform::Model::NumericType, :real
real_type(type.range)
- when Schemaform::Schema::DateTimeType
+ when Schemaform::Model::DateTimeType
date_time_type()
- when Schemaform::Schema::EnumeratedType
- if type.evaluated_type.is_a?(Schemaform::Schema::StringType) then
+ when Schemaform::Model::EnumeratedType
+ if type.evaluated_type.is_a?(Schemaform::Model::StringType) then
text_type(type.evaluated_type.length)
else
integer_type(type.evaluated_type.range)
@@ -49,7 +49,7 @@ def initialize( schema, name, parent )
def each( tuple_name, &block )
assert(@entity.nil?, "you can define the entity using one \"each\" or \"as\" clause only")
- @entity = Schema::DefinedEntity.new(@name, @parent)
+ @entity = Model::DefinedEntity.new(@name, @parent)
@schema.entities.register(@entity)
@entity.heading.use do |tuple|
@@ -69,7 +69,7 @@ def as( &block )
assert(@entity.nil?, "you can define the entity using one \"each\" or \"as\" clause only")
assert(@parent.nil?, "derived entities cannot have a base entity" )
- @entity = Schema::DerivedEntity.new(@name, block)
+ @entity = Model::DerivedEntity.new(@name, block)
@schema.entities.register(@entity)
end
@@ -113,9 +113,9 @@ def key( *args, &block )
where = hash.fetch(:where) || block
fail_todo
else
- key = Schema::Key.new(@entity, name, lambda{|entity| entity.project_attributes(attributes)})
+ key = Model::Key.new(@entity, name, lambda{|entity| entity.project_attributes(attributes)})
@entity.keys.register key
- @entity.accessors.register Schema::KeyAccessor.new(key)
+ @entity.accessors.register Model::KeyAccessor.new(key)
end
end
@@ -134,7 +134,7 @@ def key( *args, &block )
def projection( name, details, &block )
assert(@entity.exists?, "you must define the entity using one \"each\" or \"as\" clause before defining any projections")
attributes = details.fetch(:project) || block
- @entity.projections.register Schema::Projection.new(@entity, name, lambda{|entity| entity.project_attributes(attributes)})
+ @entity.projections.register Model::Projection.new(@entity, name, lambda{|entity| entity.project_attributes(attributes)})
end
@@ -157,9 +157,9 @@ def accessor( *args, &block )
name, hash = *args
if hash.member?(:on) then
attributes = hash[:on]
- @entity.accessors.register Schema::GeneratedAccessor.new(@entity, name, lambda{|entity| entity.project_attributes(attributes)} )
+ @entity.accessors.register Model::GeneratedAccessor.new(@entity, name, lambda{|entity| entity.project_attributes(attributes)} )
elsif hash.member?(:where) then
- @entity.accessors.register Schema::DefinedAccessor.new(@entity, name, hash.fetch(:where) || block)
+ @entity.accessors.register Model::DefinedAccessor.new(@entity, name, hash.fetch(:where) || block)
else
fail
end
@@ -18,7 +18,7 @@
# limitations under the License.
# =============================================================================================
-require Schemaform.locate("schemaform/schema.rb")
+require Schemaform.locate("schemaform/model/schema.rb")
module Schemaform
module Language
@@ -36,8 +36,8 @@ def self.unknown_type()
end
def self.resolve_type( name )
- return name if name.is_a?(Schema::Type)
- Schema.current do |schema|
+ return name if name.is_a?(Model::Type)
+ Model::Schema.current do |schema|
schema.types.member?(name) ? schema.types[name] : schema.send((name.to_s + "_type").intern)
end
end
@@ -51,7 +51,7 @@ def self.capture( value, production = nil )
case value
when Placeholder, NilClass
return value
- when Schema::Type
+ when Model::Type
return value.placeholder(production)
when Array
return LiteralList.new(*value.collect{|e| capture(e)})
@@ -141,7 +141,7 @@ def self.capture_formula( formula_context, block, result_type = nil, join_compat
# =============================================================================================
module Schemaform
-class Schema
+module Model
class Component
def placeholder( production = nil )
@@ -298,7 +298,7 @@ def capture_method( receiver, method_name, args = [], block = nil )
end
end
- Schema::ListType.build(member_type, :order => order_attributes).placeholder(Language::Productions::OrderBy.new(receiver, *order_attributes))
+ Model::ListType.build(member_type, :order => order_attributes).placeholder(Language::Productions::OrderBy.new(receiver, *order_attributes))
else
super
end
@@ -488,7 +488,7 @@ def placeholder( production = nil )
end
-end # Schema
+end # Model
end # Schemaform
@@ -499,7 +499,7 @@ def placeholder( production = nil )
# =============================================================================================
module Schemaform
-class Schema
+module Model
class Entity
@@ -560,7 +560,7 @@ def search( path = nil, &block )
end
end
-end # Schema
+end # Model
end # Schemaform
@@ -36,7 +36,7 @@ def self.if_then_else( condition, true_branch, false_branch = nil )
end
def self.all( entity_name )
- Schema.current do |schema|
+ Model::Schema.current do |schema|
assert(schema.entities.member?(entity_name), "unable to find entity [#{entity_name}] in resolution scope")
schema.entities[entity_name].placeholder
end
@@ -40,11 +40,13 @@ module FormulaInversion
# =============================================================================================
module Schemaform
-class Schema
+module Model
- def build_maintainers()
- @entities.each do |entity|
- entity.build_maintainers()
+ class Schema
+ def build_maintainers()
+ @entities.each do |entity|
+ entity.build_maintainers()
+ end
end
end
@@ -80,6 +82,6 @@ def build_maintainers( target_element = nil )
end
end
-end # Schema
+end # Model
end # Schemaform
@@ -51,7 +51,7 @@ def get_related( entity_name, link_attribute = nil, &link_expression )
else
link_path = related_entity.search do |attribute, path|
type = attribute.evaluated_type
- next unless type.is_a?(Schema::EntityReferenceType)
+ next unless type.is_a?(Model::EntityReferenceType)
next unless @names.member?(type.entity_name)
attribute.placeholder(path)
end
@@ -64,15 +64,15 @@ def get_related( entity_name, link_attribute = nil, &link_expression )
end
reference_type = link_path.instance_variable_get(:@definition).singular_type.evaluated_type
- if !reference_type.is_a?(Schema::EntityReferenceType) then
+ if !reference_type.is_a?(Model::EntityReferenceType) then
fail "expected reference result from the link expression, found #{reference_type.class.name}"
elsif !@names.member?(reference_type.entity_name) then
fail "expected reference to #{@entity.full_name} as the result of the link expression"
end
warn_todo("if the link attribute for a related lookup is part of a key, the result should be a single (optional) record")
- return Schema::SetType.build(related_entity.reference_type).placeholder(Productions::RelatedTuples.new(@entity, link_path))
+ return Model::SetType.build(related_entity.reference_type).placeholder(Productions::RelatedTuples.new(@entity, link_path))
end
def method_missing( symbol, *args, &block )
@@ -27,12 +27,12 @@ class LiteralList < Placeholder
def initialize( *members )
@members = members
- member_type = Schema.current.unknown_type
+ member_type = Model::Schema.current.unknown_type
members.each do |member|
member_type = member_type.best_common_type(member.get_type)
end
- super(Schema.current.build_list_type(member_type))
+ super(Model::Schema.current.build_list_type(member_type))
end
def method_missing( symbol, *args, &block )
@@ -26,12 +26,12 @@ class LiteralSet < Placeholder
def initialize( *members )
@members = members
- member_type = Schema.current.unknown_type
+ member_type = Model::Schema.current.unknown_type
members.each do |member|
member_type = member_type.best_common_type(member.get_type)
end
- super(Schema.current.build_set_type(member_type))
+ super(Model::Schema.current.build_set_type(member_type))
end
def method_missing( symbol, *args, &block )
@@ -44,7 +44,7 @@ def initialize(schema, &block)
# Defines an entity within the Schema.
def define_entity( name, parent = nil, &block )
- if parent && !parent.is_an?(Schema::Entity) then
+ if parent && !parent.is_an?(Model::Entity) then
parent = @schema.entities.find(parent, checks_enabled?)
end
Oops, something went wrong.

0 comments on commit 8389d6c

Please sign in to comment.