-class Manifest.Model\r
- constructor: (item_name) ->\r
- @item_name = item_name\r
+class Manifest.Model extends ManifestBase.Base\r
+ _attributes = null\r
+ _associations = null\r
+ _list = null\r
+ \r
+ attributes: () ->\r
+ _attributes\r
+ \r
+ associations: () ->\r
+ _associations\r
+ \r
+ list: () ->\r
+ _list\r
+ \r
+ set_default: () ->\r
+ super\r
+ @json['attributes'] ||= {}\r
+ @json['associations'] ||= {}\r
+ @json['list'] ||= {}\r
+ @json['attributes']['id'] = {\r
+ 'type': 'number',\r
+ 'primary_key': 1,\r
+ 'rules': {\r
+ 'number': true\r
+ }\r
+ }\r
+ @json['attributes']['created_at'] = {\r
+ 'type': 'datetime',\r
+ }\r
+ @json['attributes']['updated_at'] = {\r
+ 'type': 'datetime',\r
+ }\r
+ \r
+ init: () ->\r
+ super\r
+ _attributes = ManifestBase.load_name_values this, @json, 'attributes', Manifest.ModelModule.Attribute\r
+ _associations = ManifestBase.load_value this, @json, 'associations', Manifest.ModelModule.Association\r
+ _list = ManifestBase.load_value this, @json, 'list', Manifest.ModelModule.List\r
\r
model_name: () ->\r
- header: () ->\r
- paginate: () ->\r
-\r
+ _name\r
+ \r
+ classify: () ->\r
+ Manifest.item_name_to_model _name\r
+ \r
+ table_name: () ->\r
+ @classify.table_name\r
+ \r
+ valid_encode_columns: () ->\r
+ r = []\r
+ _.each @attributes, (attribute, attribute_name) ->\r
+ next if not attribute.type == 'text'\r
+ r.push attribute_name\r
+ r\r
+ \r
+ owner_type: () ->\r
+ return 'author' if @attributes['author_id']\r
+ return 'artist' if @attributes['artist_id']\r
+ false\r
+ \r
+ content_model: () ->\r
+ return true if @owner_type\r
+ false\r
+ \r
+ child_model_manifests: () ->\r
+ r = []\r
+ _.each Manifest.items, (peta_manifest, peta_name) ->\r
+ next if not peta_manifest.is_element\r
+ next if not peta_manifest.parent_model_name == @name\r
+ r.push Manifest.models[peta_name]\r
+ r\r
+ \r
+ child_models: () ->\r
+ _.map @child_model_manifests, (child_model_manifest) ->\r
+ child_model_manifest.classify\r
+ \r
+ child_element_names: () ->\r
+ _.map @child_models, (child_model) ->\r
+ _associations.child_element_name(child_model)\r
+ \r
+ child_element_name: (item_name) ->\r
+ _associations.child_element_name(child_model_manifest)\r
+ \r
+class Manifest.ModelModule\r