/*
 * ModeShape (http://www.modeshape.org)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 
 //------------------------------------------------------------------------------
// N A M E S P A C E S
//------------------------------------------------------------------------------
<jcr='http://www.jcp.org/jcr/1.0'>
<nt='http://www.jcp.org/jcr/nt/1.0'>
<mix='http://www.jcp.org/jcr/mix/1.0'>
<ddl='http://www.modeshape.org/ddl/1.0'>
<derbyddl='http://www.modeshape.org/ddl/derby/1.0'>

// =============================================================================
// OPERANDS
// =============================================================================
[derbyddl:functionOperand]  > ddl:operand mixin abstract
[derbyddl:indexOperand]     > ddl:operand mixin abstract
[derbyddl:procedureOperand] > ddl:operand mixin abstract
[derbyddl:roleOperand]      > ddl:operand mixin abstract
[derbyddl:synonymOperand]   > ddl:operand mixin abstract
[derbyddl:triggerOperand]   > ddl:operand mixin abstract

[derbyddl:roleName]         > derbyddl:roleOperand mixin

// =============================================================================
// COLUMN
// =============================================================================
[derbyddl:columnDefinition] > ddl:columnDefinition mixin
  - derbyddl:dropDefault (boolean)
  
[derbyddl:functionParameter] > ddl:columnDefinition mixin

[derbyddl:indexColumnReference] > ddl:columnReference mixin
  - derbyddl:order (STRING)
  
// =============================================================================
// CREATE STATEMENTS
// =============================================================================
[derbyddl:createFunctionStatement]     > ddl:creatable, ddl:statement, derbyddl:functionOperand mixin
  - ddl:datatypeName (STRING)
  - ddl:datatypeLength (LONG)
  - ddl:datatypePrecision (LONG)
  - ddl:datatypeScale (LONG)
  - ddl:isTableType (boolean)
  - derbyddl:parameterStyle (STRING)
  + * (ddl:createTableStatement) = ddl:createTableStatement sns
  + * (derbyddl:functionParameter) = derbyddl:functionParameter sns
  + * (ddl:statementOption) = ddl:statementOption sns
[derbyddl:createIndexStatement]        > ddl:statement, ddl:creatable, derbyddl:indexOperand mixin
  - derbyddl:tableName (string) mandatory
  - derbyddl:unique (boolean)
  + * (derbyddl:indexColumnReference) = derbyddl:indexColumnReference sns
[derbyddl:createProcedureStatement]    > ddl:creatable, ddl:statement, derbyddl:procedureOperand mixin
[derbyddl:createRoleStatement]         > ddl:creatable, ddl:statement, derbyddl:roleOperand mixin
[derbyddl:createSynonymStatement]      > ddl:creatable, ddl:statement, derbyddl:synonymOperand mixin
  - derbyddl:tableName (string) mandatory
[derbyddl:createTriggerStatement]      > ddl:creatable, ddl:statement, derbyddl:triggerOperand mixin
  - derbyddl:tableName (string) mandatory
  - ddl:sql (string) mandatory
  + * (ddl:columnReference) = ddl:columnReference sns
[derbyddl:declareGlobalTemporaryTableStatement] > ddl:createTableStatement mixin

// =============================================================================
// DROP STATEMENTS
// =============================================================================
[derbyddl:dropFunctionStatement]    > ddl:droppable, derbyddl:functionOperand mixin
[derbyddl:dropIndexStatement]       > ddl:droppable, derbyddl:indexOperand mixin
[derbyddl:dropProcedureStatement]   > ddl:droppable, derbyddl:procedureOperand mixin
[derbyddl:dropRoleStatement]        > ddl:droppable, derbyddl:roleOperand mixin
[derbyddl:dropSynonymStatement]     > ddl:droppable, derbyddl:synonymOperand mixin
[derbyddl:dropTriggerStatement]     > ddl:droppable, derbyddl:triggerOperand mixin

// =============================================================================
// MISC STATEMENTS
// =============================================================================
[derbyddl:lockTableStatement]       > ddl:statement, ddl:tableOperand mixin
[derbyddl:renameTableStatement]     > ddl:statement, ddl:renamable, ddl:tableOperand mixin
[derbyddl:renameIndexStatement]     > ddl:statement, ddl:renamable, derbyddl:indexOperand mixin

[derbyddl:grantOnFunctionStatement]     > ddl:grantStatement, derbyddl:functionOperand mixin
[derbyddl:grantOnProcedureStatement]    > ddl:grantStatement, derbyddl:procedureOperand mixin

[derbyddl:grantRolesStatement]          > ddl:grantStatement mixin
  + ddl:name (derbyddl:roleName) = derbyddl:roleName sns
