<Realm>
    "Archivo Fotográfico Manuel Toussaint"@es
    "Manuel Toussaint Photograph Archive"@en

    abbreviation afmt
    thisOntology "http://www.iie.unam.mx/archivo-fotografico-manuel-toussaint#"

    dependsRealm sys
    dependsRealm swv

    <RepositoryArea>
       "Archivo Fotográfico Manuel Toussaint"@es
       "Manuel Toussaint Photograph Archive"@en
        generalArchivalThings
    </RepositoryArea>
</Realm>

<DefinitionSet photo_collection>
    <RuleSet photographic_print>
        <Structure>
            <Descriptor has_unique_id>
                property swv:hasUniqueIdentifier
                minCardinality 1
                maxCardinality 1
                outRequirement fromPropRange
            </Descriptor>

            <Descriptor has_main_content_link>
                useDefinition swv.manifestation.has_main_content_link
            </Descriptor>
 
            <Descriptor has_tone_and_color>
                property swv:hasToneAndColor
                minCardinality 1
                maxCardinality 1
                outRequirement fromPropRange
            </Descriptor>

            <Descriptor has_format>
                property swv:hasFormat
                minCardinality 1
                maxCardinality 1
                outRequirement fromPropRange
            </Descriptor>

            <Descriptor has_component_link>
              useDefinition swv.physical_objects.has_component_link
            </Descriptor>    
            
            <Descriptor has_role_in_photographic_process>
              useDefinition swv.photograph.has_role_in_photographic_process
            </Descriptor>  
            
            <Descriptor exist_another_copies>
            </Descriptor>            
        </Structure>

        <KRRelationRules>
            <KRRelationRule has_main_content>
                swv.manifestation.has_main_content
                <StructRules>
                    outFromGroup sys.individuals.belongs_to_soc->photographic_prints_soc.has_main_content_group
                </StructRules>
            </KRRelationRule>
            <KRRelationRule has_primary_support>
                has_component_link->swv.component_links.has_linked_component
                <Condition>
                |{ (ROOT->has_component_link->has_component_role).nodes[0] ==  swv.roles_of_photograph_supports.primary }|
                </Condition>
            </KRRelationRule>
            
           <KRRelationRule was_reproduced_from>
              has_primary_support->has_manifestation_link->swv.manifestation_link.reproduced_from
               <Condition>
                |{OUT->has_linked_manifestation.inv->has_manifestation_link.inv->has_role_in_photographic_process == sw.roles_in_photographic_process.negative}|
               </Condition>  
           </KRRelationRule>
               
#           <KRRelationRule exist_another_copies>            
#              was_reproduced_from->swv.reproduced_from.inv->has_manifestation_link.inv
#              <Condition>
#                |{OUT->has_role_in_photographic_process.positive && OUT!= ROOT->has_primary_support}|
#              </Condition>  
#           </KRRelationRule>
                
  
        </KRRelationRules>

        <InferenceRules> 
        
            <InferenceRule has_role_in_photographic_proccess>
              | {role = ROOT->has_primary_support->swv.photograph.has_role_in_photographic_proccess
                 has_role_in_photographic_proccess.assign(ROOT, role)  
               }|
             </InferenceRule>
                                   
 
#             <InferenceRule exist_another_copies>
#              | {
#                 
#                 manifestations = Array.new
#                 copies = Array.new
#                 manifestations =  was_reproduced_from->swv.reproduced_from.inv->has_manifestation_link.inv
#                 
#                 for mani in manifestations
#              
#                  exist_another_copies.assign(mani)  if(ROOT->has_role_in_photographic_proccess.positive
#                                          && mani != ROOT->has_primary_support)                                               
#                 end  
#                 
#                 
#                 }|               
#              
#             </InferenceRule>
       
              
        <InferenceRule inferred_copy>
            |{
                objects = was_reproduced_from->swv.reproduced_from.inv->has_manifestation_link.inv
	              objects.each_node do |obj|
	
	            if (((obj->has_role_in_photographic_proccess).node == swv.roles_in_photographic_processes.positive) && (obj != ROOT))
                copy.assign(ROOT, obj)  
                end  
             }|
        </InferenceRule>
           
                        
        <BPVFunctions>
            <TextBPVFunction text_ref>
                defaultTextBPVFunction
                |{ (ROOT->has_unique_id).textBPV }|
            </TextBPVFunction>

            <ImageBPVFunciton image_ref>
                defaultImageBPVFunciton
#              (...)
            </ImageBPVFunciton>
        </BPVFunctions>

        <Descriptions>
            <VariableDesc>
#                (...)
            </VariableDesc>

            <ShortDesc>
#               (...)
            </ShortDesc>

            <FullDesc>
                <Area main>
                    <Title>
                        "Full record"@en
                        "Ficha completa"@es
                    </Title>
                    <Block>
#                    (...)
                        <% if ((ROOT->has_system_accessible_digital_copy).hasObj) %>
                            <df>
                                "Digital copy"@en
                                "Copia digital"@es
                                imageBPV (ROOT->has_system_accessible_digital_copy).imageBPV.thumb
                                linkTo image
                            </df>
                        <% end %>
                    </Block>
                </Area>
                <% if ((ROOT->has_system_accessible_digital_copy).hasObj) %>
                    <Area image>
                        <Title>
                            "Image"@en
                            "Imagen"@es
                        </Title>
                        imageBPV (ROOT->has_system_accessible_digital_copy).imageBPV.fitViewPort
#                        (...)
                    </Area>
                <% end %>
            </FullDesc>
        <Descriptions>
    </RuleSet>


    <RuleSet photographic_print_soc>
        <Structure>
            <Descriptor has_unique_id>
                property swv:hasUniqueIdentifier
                minCardinality 1
                maxCardinality 1
                outRequirement fromPropRange
            </Descriptor>
            <Descriptor has_title>
                property swv:hasTitle
                minCardinality 1
                maxCardinality 1
                outRequirement fromPropRange
                multilingual
            </Descriptor>
            <Descriptor has_archival_history>
                property swv:hasArchivalHistory
                minCardinality 1
                maxCardinality 1
                outRequirement fromPropRange
            </Descriptor>
#            (...)  
            <Descriptor has_main_content_group_link>
                useDefinition manifestation_group.has_main_content_group_link
            </Descriptor>
        </Structure>

        <KRRelationRules>
            <KRRelationRule has_main_content_group>
                manifestation_group.has_main_content_group
                <StructRules>
                    outValue images_as_content
                </StructRules>
            </KRRelationRule>

            <KRRelationRule has_photographer>
                has_main_content_group->image_as_content_soc.has_photographer
            <KRRelationRule>
        </KRRelationRules>

        <BPVFunctions>
            <TextBPVFunction text_ref>
                defaultTextBPVFunction
                |{ (ROOT->has_unique_id).textBPV }|
            </TextBPVFunction>
        </BPVFunctions>

        <Descriptions>
            <VariableDesc>
                df has_unique_id
                df has_title
                df has_archival_history
                df has_photographer
            </VariableDesc>

            <ShortDesc>
                df has_unique_id
                df has_title
            </ShortDesc>

            <FullDesc>
                <Block>
                    df has_unique_id
                    df has_title
                    df has_archival_history
                    df has_photographer
                </Block>
            </FullDesc>
        </Descriptions>
    </RuleSet>

    <RepositorySetup>
        <SOC photographic_prints>
            "Julio Michaud Collection"@en
            "Colección Julio Michaud"@es
            hasGroupDomain swv:PhotographicPrint
            bindToRuleSet photographic_print
            mainLevel
            bindSOCToRuleSet photographic_print_soc
        </SOC>
        
        <SOC component_links>
            "Component Links"@en
            "Vínculos a componentes@es
            hasGroupDomain swv:ComponentLink
            bindToRuleSet swv.component_links
            secondaryLevel
        </SOC>
        
        <SOC photograph_supports>
                "Photograph Supports"@en
                "Soportes fotográficos"@es
                hasGroupDomain swv:PhotographSupport
                bindToRuleSet swv.physical_objects   
                secondaryLevel
         </SOC>
         
         <SOC manifestation_links>
                "Manifestation Links"@en
                "Vínculos a manifestaciones"@es
                hasGroupDomain swv:ManifestationLink
                bindToRuleSet swv.manifestation_link   
                secondaryLevel
         </SOC>

         <SOC locations_on_object>
               "Locations on Object"@en
               "Ubicaciones sobre el objeto"@es
               hasGroupDomain swv:LocationOnObject
               bindToRuleSet swv.thing
               secondaryLevel
         </SOC>   

         <SOC inscriptions>
           "Inscriptions"@en
           "Inscripciones"@es
           #hasGroupDomain swv:Inscriptions
           hasGroupDomain swv:HandWrittenNote
           bindToRuleSet swv.manifestation
           secondaryLevel
         </SOC>                   
                
         <SOC content_links>
            "Content Links"@en
            "Vínculos de contenido"@es
            hasGroupDomain swv:ContentLink
            bindToRuleSet content_link
            secondaryLevel
        </SOC>     

        <SOC texts>
          "Texts"@en
          "Texto"@es
          hasGroupDomain swv:Text
          bindToRuleSet text
          secondaryLevel
        </SOC>                  
                
        <SOC main_content_links>
          "Main Content Link"@en
          "Vínculos a contenidos principales"@es
          hasGroupDomain swv:ContentLink
          bindToRuleSet content_link
          secondaryLevel
        </SOC>          
                
        <SOC inscribed_titles>
           "Inscribed Titles"@en
           "Títulos inscritos"@es
           hasGroupDomain swv:InscribedTitle  
           bindToRuleSet inscribed_title  
           secondaryLevel  
        </SOC>
                
                
    </RepositorySetup>

    <RuleSet image_as_content>
        <Structure>
            <Descriptor has_title>
                property swv:hasTitle
                minCardinality 1
                maxCardinality 1
                outRequirement swv:InscribedTitle
            </Descriptor>

            <Descriptot has_date>
                property swv:hasInitialPhotoDate
                minCardinality 0
                maxCardinality 1
                outRequirement fromPropRange
            </Descriptor>
    
            <Descriptor has_photographer>
              minCardinality 0
              maxCardinality 1  
              property swv:hasPhotographer
              outRequirement fromPropRange  
            <Descriptor>   

            <Descriptor has_editor>
              minCardinality 1
              maxCardinality 1  
              property swv:hasEditor
              outRequirement fromPropRange  
            <Descriptor>  
            
            <Descriptor has_formal_structure>
                property swv:hasFormalStructure
                minCardinality 1
                maxCardinality 1
                outRequirement fromPropRange
            </Descriptor>
            
            <Descriptor has_orientation>
                property swv:hasOrientation                    
                minCardinality 1
                maxCardinality 1
                outRequirement fromPropRange
            </Descriptor>
            
            <Descriptor has_plane>
                property swv:hasPlane
                minCardinality 1
                maxCardinality 1
                outRequirement formPropRange
            </Descriptor>

            <Descriptor taken_from>
                property swv:takenFrom
                minCardinality 0
                maxCardinality 1
            </Descriptor>    
            
            <Descriptor taken_facing>
                property swv:takenFacing
                minCardinality 0
                maxCardinality 1
            </Descriptor>
                  
              
            <Descriptor has_description>
                property swv:hasDescription
                minCardinality 1
                maxCardinality 1
                outRequirement fromPropRange
            </Descriptor>    
            
        </Structure>

        <KRRelationRules>
            <KRRelationRule has_accessible_digital_copy>
                swv.content.has_system_accessible_digital_copy
            </KRRelationRule>
        </KRRelationRules>

        <BPVFunctions>
            <TextBPVFunction text_ref>
                defaultTextBPVFunction
                |{ (ROOT->has_title).textBPV }|
            </TextBPVFunction>

            <ImageBPVFunciton image_ref>
                defaultImageBPVFunciton
                |{ (ROOT->has_system_accessible_digital_copy).imageBPV }|
            </ImageBPVFunciton>
        </BPVFunctions>

        <Descriptions>
            <NonDefaultDescFragments>
                <df has_system_accessible_digital_copy>
                    "Digital copy"@en
                    "Copia digital"@es
                </df>
            </NonDefaultDescFragments>

            VariableDesc default

            <ShortDesc>
                df has_title
                df has_description
            </ShortDesc>

            FullDesc default
        </Descriptions>
    </RuleSet>

    <RuleSet image_as_content_soc>
        <Structure>
#            <Descriptor has_photographer>
#                property swv:hasPhotographer
#                minCardinality 1
#                maxCardinality 1
#                outRequirement fromPropRange
#            </Descriptor>
            <Descriptor has_title>
                property swv:hasTitle
                minCardinality 1
                maxCardinality 1
                outRequirement fromPropRange
                multilingual
            </Descriptor>
        </Structure>

        <BPVFunctions>
            <TextBPVFunction text_ref>
                defaultTextBPVFunction
                |{ (ROOT->has_title).textBPV }|
            </TextBPVFunction>
        </BPVFunctions>

        <Descriptions>
            VariableDesc default
            ShortDesc default
            FullDesc default
        </Descriptions>
    </RuleSet>

    <RepositorySetup>
#        <SOC images_as_content>
#            "Images (as content) in the Juan Pérez Photo Archive"@en
#            "Imágenes (como contenido) del archivo de fotografías Juan Pérez"@es
#            hasGroupDomain swv:Image
#            bindToRuleSet image_as_content
#            secondaryLevel
#            bindSOCToRuleSet image_as_content_soc
#        </SOC>

    <SOC images_as_content>
        "Images (as content) in the Julio Michaud Collection"@en
        "Imágenes (como contenido) de la Colección Julio Michaud"@es
        hasGroupDomain swv:Image
        bindToRuleSet image_as_content
        secondaryLevel          
    </SOC>  

    <SOC authors>
        "Authors of the collection Julio Michaud"@en
        "Autores de la colección Julio Michaud"@es
        hasGroupDomain swv:Author
        bindToRuleSet swv.person  
        secondaryLevel
    </SOC>
    
 
    </RepositorySetup>

    <RuleSet digital_image_file>
        <Structure>
            <Descriptor has_system_accessible_uri>
                useDefinition sys.digital_file.has_system_accessible_uri
            </Descriptor>
            <Descriptor has_main_content_link>
                useDefinition swv.manifestation.has_main_content_link
            </Descriptor>
        </Structure>

        <BPVFunctions>
            <TextBPVFunction text_ref>
                defaultTextBPVFunction
                |{ (ROOT->has_system_accessible_uri).textBPV }|
            </TextBPVFunction>
        </BPVFunctions>

        <Descriptions>
            VariableDesc default

            <ShortDesc>
                df has_system_accessible_uri
            </ShortDesc>

            FullDesc default
        </Descriptions>
    </RuleSet>

    <RepositorySetup>
        <SOC digital_image_files>
            "Digital copies of the photographs in the Juan Pérez Photo Archive"@en
            "Copias digitales de las fotos del archivo Juan Pérez"@es
            hasGroupDomain sys:DigitalImageFile
            bindToRuleSet digital_image_file
            secondaryLevel
        </SOC>
    </RepositorySetup>
</DefinitionSet>
