import everything from 'http://ns.nuke24.net/Schema/'
import everything from 'http://ns.nuke24.net/Schema/DataTypeTranslation/'
import everything from 'http://ns.nuke24.net/Schema/Application/'

import 'http://www.w3.org/2000/01/rdf-schema#isSubclassOf' as 'extends'
import 'http://ns.nuke24.net/Schema/RDB/Schema'
import 'http://ns.nuke24.net/Schema/RDB/Sequence'
import 'http://ns.nuke24.net/Schema/RDB/defaultValueSequence'
import 'http://ns.nuke24.net/Schema/RDB/initialValue'
import 'http://ns.nuke24.net/Schema/RDB/isInNamespace'

class 'integer' :
	SQL type @ "INT" :
	PHP type @ "int" :
	JSON type @ "number" :
	regex @ "[+-]?\\d+"
class 'boolean' :
	SQL type @ "BOOLEAN" :
	PHP type @ "bool" :
	JSON type @ "boolean"
class 'string' :
	SQL type @ "VARCHAR(127)" :
	PHP type @ "string" :
	JSON type @ "string"
class 'text' : extends(string) :
	SQL type @ "TEXT"
class 'entity ID' : extends(integer) :
	SQL type @ "BIGINT" :
	PHP type @ "string" :
	JSON type @ "string"
class 'percentage' : extends(integer) :
	SQL type @ "SMALLINT"

class property 'collection name' : value type @ string :
	long name @ "http://ns.earthit.com/CMIPREST/collectionName" :
	comment @ "Name of the set of members of this class; usually this would be the plural form of the class name"

schema 'CMIPREST test'

sequence 'new entity ID' : initial value @ 1001 : is in namespace @ CMIPREST test

# Standard Rest Resource
class modifier 'SRR' = has a database table : has a REST service : members are public : is in namespace @ CMIPREST test

field modifier 'EIPK' = entity ID : key(primary) : default value sequence @ new entity ID

class 'mood code' : extends(string)

class 'mood' : SRR {
	mood code : mood code : key(primary)
	description : string
}

class 'resource' : SRR {
	ID : EIPK
	URN : string
}

class 'person' : SRR : collection name @ "people" {
	ID : EIPK
	first name : string
	last name : string
}

class 'rating' : SRR {
	author : reference(person) : key(primary) {
		ID = author ID
	}
	subject : reference(resource) : key(primary) {
		ID = subject ID
	}
	
	comment          : text       : nullable
	quality rating   : percentage : nullable
	resource is fake : boolean    : nullable
	mood : reference(mood) : nullable = mood code
}

# These are for testing request parsing.  They don't have actual tables.

class 'field' : comment @ "A place where deer live" : has a REST service {
	ID : EIPK
}

class 'deer' : collection name @ "deer" : has a REST service {
	ID : EIPK
	name : string
	# inverse collection name @ "resident deer" would be appropriate,
	# except that the whole point is to test resolving ambiguity between
	# singular and plural 'deer'
	home field : reference(field) = ID = home field ID
}
