<commit_before>{Base}                        = require './core'
Store                         = require './Store'
{AttributeFactory, Attribute} = require './attributes'
TypeRegister                  = require './TypeRegister'
_                             = require 'underscore'

class Model extends Base
	
	@addState 'NEW',
		transitions :
			initial : true
			exit    : 'LOCAL, READY'
		methods     : 
			
			buildAttributes: ->
				@attributes = {}

				unless @_schema['id']?
					@_schema['id'] = kind: 'property', name: 'id', type: 'String'

				for name, config of @_schema
					console.log "building attribute for #{name}"
					Object.defineProperty this, name,
						get: -> @get(name)
						set: (value) -> @set(name, value)

					attr = AttributeFactory.createAttribute config.kind, _.extend(config, owner: @)
					@attributes[name] = attr

					attr.on "change",      => @onAttributeChange
					attr.on "stateChange", => @onAttributeStateChange
			
			# now, determine from data passed in if we're an existing model or a new local model
			parse: (obj) ->
				
					<commit_msg>added prototype of the new statechart for model.<commit_after>{Base}                        = require './core'
Store                         = require './Store'
{AttributeFactory, Attribute} = require './attributes'
TypeRegister                  = require './TypeRegister'
_                             = require 'underscore'
Stateful                      = require 'stateful'

class Model extends Base
	
	# New statechart implementation
	# @StateChart
	# 	New:
	# 		transitions: [
	# 			destination: 'Existing'
	# 			action: 'save'
	# 		]
	# 		methods: 
	# 			save: -> Stateful.Success
	# 			
	# 	Existing:
	# 		transitions: [
	# 			destination: 'Existing/Loaded'
	# 			action: 'parse'
	# 		]
	# 		methods:
	# 			parse: -> Stateful.Success
	# 		paths:
	# 			Loaded:
	# 				transitions: [
	# 					destination: 'Existing/Loaded/Editing'
	# 					action: 'startEdit'
	# 				]
	# 				methods: 
	# 					startEdit: -> Stateful.Success
	# 				paths:
	# 					Editing:
	# 						transitions: [
	# 							{
	# 								destination: 'Existing/Loaded'
	# 								action: 'cancel'
	# 							}
	# 							{
	# 								destination: 'Existing/Loaded/Editing/Dirty'
	# 								action: 'save'
	# 							}
	# 						]
	# 						methods:
	# 							cancel: -> Stateful.Success
	# 							save: -> Stateful.Success
	# 						paths:
	# 							Dirty:
	# 								transitions: [
	# 									{destination: 'Existing/Loaded',action: 'commit'}
	# 									{destination: 'Existing/Loaded',action: 'rollback'}
	# 								]
	# 								methods: 
	# 									commit: -> Stateful.Success
	# 									rollback: -> Stateful.Success
	# 			
	# 
	
	@addState 'NEW',
		transitions :
			initial : true
			exit    : 'LOCAL, READY'
		methods     : 
			
			buildAttributes: ->
				@attributes = {}

				unless @_schema['id']?
					@_schema['id'] = kind: 'property', name: 'id', type: 'String'

				for name, config of @_schema
					console.log "building attribute for #{name}"
					Object.defineProperty this, name,
						get: -> @get(name)
						set: (value) -> @set(name, value)

					attr = AttributeFactory.createAttribute config.kind, _.extend(config, owner: @)
					@attributes[name] = attr

					attr.on "change",      => @onAttributeChange
					attr.on "stateChange", => @onAttributeStateChange
			
			# now, determine from data passed in if we're an existing model or a new local model
			parse: (obj) ->
				
					
{'fraction_non_alphanumeric': 0.12738301559792028, 'fraction_numerical': 0.0, 'mean_word_length': 1.9497444633730834, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '717293', 'n_tokens_mistral': 1447, 'n_tokens_neox': 1117, 'n_words': 250}