<?xml version="1.0" encoding="UTF-8"?>
<!-- Definition of new Model -->
<model name="ecm:ecmmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
    <!-- Optional meta-data about the model -->
    <description>Engineering Change Management Model</description>
    <author>QUERE</author>
    <version>1.0</version>
    <!-- Imports are required to allow references to definitions in other models -->
    <imports>
        <!-- Import Alfresco Dictionary Definitions -->
        <import uri="http://www.alfresco.org/model/dictionary/1.0"
            prefix="d" />
        <!-- Import Alfresco Content Domain Model Definitions -->
        <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
        <import uri="http://www.bcpg.fr/model/becpg/1.0" prefix="bcpg" />
        <import uri="http://www.bcpg.fr/model/report/1.0" prefix="rep" />
    </imports>
    
    <!-- Introduction of new namespaces defined by this model -->
    <namespaces>
        <namespace uri="http://www.bcpg.fr/model/ecm/1.0" prefix="ecm" />
    </namespaces>
    
    <constraints>
        <constraint name="ecm:revisionTypes" type="LIST">
            <parameter name="allowedValues">
                <list>
                    <value>NoRevision</value>
                    <value>Minor</value>
                    <value>Major</value>                    
                </list>
            </parameter>
        </constraint>
        <constraint name="ecm:ecoStates" type="LIST">
            <parameter name="allowedValues">
                <list>
                    <value>Automatic</value>
                    <value>InProgress</value>
                    <value>ToCalculateWUsed</value>
                    <value>WUsedCalculated</value>  
                    <value>Simulated</value>
                    <value>Applied</value>  
                    <value>InError</value>              
                    <value>Cancelled</value>                
                </list>
            </parameter>
        </constraint>
        <constraint name="ecm:ecoTypes" type="LIST">
            <parameter name="allowedValues">
                <list>
                    <value>Replacement</value>
                    <value>Merge</value>
                    <value>ImpactWUsed</value>
                </list>
            </parameter>
        </constraint>
    </constraints>

    <types>
        
        <!-- type change order -->
        <type name="ecm:changeOrder">
            <parent>bcpg:entityV2</parent>
            <properties>                                        
                <property name="ecm:ecoState">
                    <type>d:text</type>
                    <multiple>false</multiple>
                    <default>ToCalculateWUsed</default>
                    <index enabled="true">
                        <tokenised>false</tokenised>
                        <facetable>true</facetable>
                     </index>
                    <constraints>
                        <constraint ref="ecm:ecoStates" />
                    </constraints>
                </property>
                <property name="ecm:effectiveDate">
                    <type>d:date</type>
                    <index enabled="true">
                        <tokenised>false</tokenised>
                        <facetable>true</facetable>
                     </index>           
                </property>
                <property name="ecm:ecoType">
                    <type>d:text</type>
                    <multiple>false</multiple>
                    <default>Replacement</default>
                    <index enabled="true">
                        <tokenised>false</tokenised>
                        <facetable>true</facetable>
                     </index>
                    <constraints>
                        <constraint ref="ecm:ecoTypes" />
                    </constraints>
                </property>
                <property name="ecm:propertiesToCopy">
                    <type>d:text</type>
                    <multiple>true</multiple>
                    <index enabled="false"/>
                </property>
                <property name="ecm:applyToAll">
                    <type>d:boolean</type>
                    <index enabled="false"/>
                </property>
            </properties>
            <associations>              
                <association name="ecm:calculatedCharacts">
                    <source>
                        <mandatory>true</mandatory>
                        <many>true</many>
                    </source>
                    <target>
                        <class>bcpg:entityListItem</class>
                        <mandatory>false</mandatory>
                        <many>true</many>
                    </target>
                </association>              
            </associations>
            <mandatory-aspects>
                <aspect>bcpg:codeAspect</aspect>
                <aspect>bcpg:entityListsAspect</aspect>
                <aspect>rep:reportEntityAspect</aspect>
            </mandatory-aspects>
        </type>
                
		 <type name="ecm:changeOrderListItem">
            <parent>bcpg:entityListItem</parent>
        </type>		
				
        <!-- replacementList -->
        <type name="ecm:replacementList">
			<parent>ecm:changeOrderListItem</parent>
            <properties>
                <property name="ecm:rlRevisionType">
                    <type>d:text</type>
                    <multiple>false</multiple>
                    <index enabled="false"/>
                    <constraints>
                        <constraint ref="ecm:revisionTypes" />
                    </constraints>
                </property>
                <property name="ecm:rlQtyPerc">
                    <type>d:int</type>
                    <mandatory>true</mandatory>
                    <default>100</default>
                    <index enabled="false"/>
                </property>
                <property name="ecm:rlLoss">
                    <type>d:double</type>
                    <index enabled="false"/>
                </property>
            </properties>
            <associations>
                <association name="ecm:rlSourceItems">
                    <source>
                        <mandatory>true</mandatory>
                        <many>true</many>
                    </source>
                    <target>
                        <class>bcpg:entityV2</class>
                        <mandatory>false</mandatory>
                        <many>true</many>
                    </target>
                </association>
                <association name="ecm:rlTargetItem">
                    <source>
                        <mandatory>true</mandatory>
                        <many>true</many>
                    </source>
                    <target>
                        <class>bcpg:entityV2</class>
                        <mandatory>false</mandatory>
                        <many>false</many>
                    </target>
                </association>          
            </associations>
        </type>
    
        <!-- wUsedList -->
        <type name="ecm:wUsedList">
			<parent>ecm:changeOrderListItem</parent>			
            <properties>
                <property name="ecm:impactedDataList">
                    <type>d:qname</type>                
                    <index enabled="false"/>    
                </property>
                <property name="ecm:isWUsedImpacted">
                    <type>d:boolean</type>
                    <default>false</default>
                    <index enabled="true">
                        <tokenised>false</tokenised>
                        <facetable>true</facetable>
                     </index>
                </property> 
                <property name="ecm:wulEffectiveDate">
                    <type>d:date</type>
                    <index enabled="true">
                        <tokenised>false</tokenised>
                        <facetable>true</facetable>
                     </index>
                </property> 
                <property name="ecm:wulQty">
                    <type>d:double</type>
                    <index enabled="true">
                        <tokenised>false</tokenised>
                        <facetable>true</facetable>
                     </index>
                </property> 
                <property name="ecm:wulLoss">
                    <type>d:double</type>
                    <index enabled="true">
                        <tokenised>false</tokenised>
                        <facetable>true</facetable>
                     </index>
                </property> 
            </properties>
            <associations>
                <association name="ecm:wulLink">
                    <source>
                        <mandatory>true</mandatory>
                        <many>true</many>
                    </source>
                    <target>
                        <class>bcpg:entityListItem</class>
                        <mandatory>false</mandatory>
                        <many>false</many>
                    </target>
                </association>
                <association name="ecm:wulSourceItems">
                    <source>
                        <mandatory>true</mandatory>
                        <many>true</many>
                    </source>
                    <target>
                        <class>bcpg:entityV2</class>
                        <mandatory>false</mandatory>
                        <many>true</many>
                    </target>
                </association>  
                <association name="ecm:wulTargetItem">
                    <source>
                        <mandatory>true</mandatory>
                        <many>true</many>
                    </source>
                    <target>
                        <class>bcpg:entityV2</class>
                        <mandatory>false</mandatory>
                        <many>false</many>
                    </target>
                </association>
            </associations>
            <mandatory-aspects>
                <aspect>bcpg:depthLevelAspect</aspect>
                <aspect>bcpg:sortableListAspect</aspect>
            </mandatory-aspects>
        </type>
        
        <!-- changeUnitList -->
        <type name="ecm:changeUnitList">
			<parent>ecm:changeOrderListItem</parent>
            <properties>                                                        
                <property name="ecm:culRevision">
                    <type>d:text</type>
                    <multiple>false</multiple>
                    <index enabled="true">
                        <tokenised>false</tokenised>
                        <facetable>true</facetable>
                     </index>
                    <constraints>
                        <constraint ref="ecm:revisionTypes" />
                    </constraints>
                </property>         
                <property name="ecm:culReqType">
                    <type>d:text</type>
                    <mandatory>false</mandatory>
                    <index enabled="true">
                        <tokenised>false</tokenised>
                        <facetable>true</facetable>
                     </index>       
                    <constraints>
                        <constraint ref="bcpg:reqTypes" />
                    </constraints>          
                </property>             
                <property name="ecm:culReqDetails">
                    <type>d:mltext</type>             
                    <index enabled="false"/>    
                </property> 
                <property name="ecm:culReqError">
                    <type>d:mltext</type>             
                    <index enabled="false"/>    
                </property>
                <property name="ecm:culTreated">
                    <type>d:boolean</type>
                    <default>false</default>        
                    <index enabled="true">
                        <tokenised>false</tokenised>
                        <facetable>true</facetable>
                     </index>
                </property> 
            </properties>       
            <associations>
                <association name="ecm:culSourceItem">
                    <source>
                        <mandatory>true</mandatory>
                        <many>true</many>
                    </source>
                    <target>
                        <class>bcpg:entityV2</class>
                        <mandatory>false</mandatory>
                        <many>false</many>
                    </target>
                </association>
                <association name="ecm:culTargetItem">
                    <source>
                        <mandatory>true</mandatory>
                        <many>true</many>
                    </source>
                    <target>
                        <class>bcpg:entityV2</class>
                        <mandatory>false</mandatory>
                        <many>false</many>
                    </target>
                </association>
            
                
            </associations> 
        </type>
        
        
        <type name="ecm:calculatedCharactList">
			<parent>ecm:changeOrderListItem</parent>			
            <properties>
                <property name="ecm:cclSourceValue">
                    <type>d:any</type>                  
                    <index enabled="false"/>
                </property>
                <property name="ecm:cclTargetValue">
                    <type>d:any</type>          
                    <index enabled="false"/>
                </property>         
            </properties>
            <associations>
                <association name="ecm:cclSourceItem">
                    <source>
                        <mandatory>true</mandatory>
                        <many>true</many>
                    </source>
                    <target>
                        <class>bcpg:entityV2</class>
                        <mandatory>false</mandatory>
                        <many>false</many>
                    </target>
                </association>  
                <association name="ecm:cclCharact">
                    <source>
                        <mandatory>true</mandatory>
                        <many>true</many>
                    </source>
                    <target>
                        <class>bcpg:entityListItem</class>
                        <mandatory>false</mandatory>
                        <many>false</many>
                    </target>
                </association>              
            </associations>
        </type>
        
    </types>
    
    <aspects>
        <aspect name="ecm:changeOrderAspect">
            <associations>
                <association name="ecm:changeOrderRef">
                    <source>
                        <mandatory>false</mandatory>
                        <many>true</many>
                    </source>
                    <target>
                        <class>ecm:changeOrder</class>
                        <mandatory>false</mandatory>
                        <many>false</many>
                    </target>
                </association>
            </associations>
        </aspect>
    </aspects>
</model>
