<Realm>
  "Test"@en
  "Prueba"@es
  comment "Test definitions"@en
  comment "Definiciones de prueba"@es

  abbreviation prueba
  thisOntology "http://purl.org/NET/durito/ontologies/2005/09/prueba#"
  dependsRealm swv
  dependsRealm sys

  <RepositoryArea>
    "Test repository area"@en
    "Área de repositorio de prueba"@es
    sharedArchivalThings
  </RepositoryArea>
</Realm>

<DefinitionSet prueba>
  <Vocabulary>
    <Class prueba:Book>
      "Books"@en
      "Libros"@es
    </Class>

    <Class prueba:Person>
      "Person"@en
      "Persona"@es
    </Class>

    <Class prueba:Photo>
      "Photos"@en
      "Fotografías"@es
    </Class>

    <Property prueba:hasTitle>
      "Title"@en
      "Título"@es
      inverse "título de"@en
      inverse "title of"@es
      range swv:BasicTitle
    </Property>

    <Property prueba:hasGivenNames>
      "Given Names"@en
      "Nombres"@es
      inverse "Nombre de"@es
      inverse "Name of"@en
      range xsd:string
    </Property>
    
    <Property prueba:hasLastNames>
      "Last Names"@en
      "Apellidos"@es
      inverse "Apellidos de"@es
      inverse "Last Names of"@en
      range xsd:string
    </Property>

    <Property prueba:hasAuthor>
      "Author"@en
      "Autor"@es
      inverse "Autor de"@es
      inverse "Author of"@en
       range prueba:Person
    </Property>

    <Property prueba:publishedIn>
      "Published in"@en
      "Se publica en"@es
      inverse "Obra que publica"@es
      inverse "Work that publishes"@en
      range prueba:Book
    </Property>
  
    <Property prueba:hasDimensions>
      "Dimensions"@en
      "Medidas"@es
      inverse "Medidas de"@es
      inverse "Dimensions of"@en
       range prueba:DimensionsInfo
    </Property>
      
    <ComplexDataType prueba:DimensionsInfo>
      "Dimensions"@en
      "Medidas"@es
      comment "Los valores que se asignen a este tipo de datos son medidas"@es
      comment "The values assigned this data type are dimensions"@en
      bindToRuleSet dimensions
      comparisonVector Float volume
    </ComplexDataType>    
    
    <Property prueba:hasHeight>
      "Height"@en
      "Altura"@es
      comment "Indica la altura"@es
      domain  prueba:DimensionsInfo
      inverse "Altura de"@es
      inverse "Height of"@en
      range xsd:float
    </Property>
    
     <Property prueba:hasWidth>
       "Width"@en
       "Ancho"@es
       comment "Indica el ancho"@es
       domain  prueba:DimensionsInfo
       inverse "Ancho de"@es
       inverse "Width of"@en
       range xsd:float
     </Property>
    
     <Property prueba:hasLength>
       "Length"@en
       "Largo"@es
       comment "Indica  el largo"@es
       domain prueba:DimensionsInfo
       inverse "Largo de"@es
       inverse "Length of"@en
       range xsd:float
     </Property>      

     <Property prueba:hasMeasurementUnit>
       "Measurement Unit"@en
       "Unidad de medición"@es
       inverse "Unidad de medición de"@es
       inverse "Measurement Unit of"@en
       range  prueba:MeasurementUnit
     </Property>
            
     <Class prueba:MeasurementUnit>
       "Measurement Unit"@en
       "Unidad de medición"@es
       comment "Las instancias de esta clase son unidades de medición"@es
       comment "The instances of this class are measurement units"@en
     </Class>
       
     <Property prueba:hasName>
       "Name"@en
       "Nombre"@es
       comment "Indica el nombre de algo"@es
       inverse "Nombre de"@es
       inverse "Name of"@en
       range xsd:string
     </Property>
     
     <Property prueba:hasAbbreviation>
       "Abrreviation"@en
       "Abreviación"@es
       comment "Indica la abreviación de algo"@es
       inverse "Abreviación de"@es
       inverse "Abrreviation of"@en
       range xsd:string
     </Property>
     
     <FundamentalDataType prueba:float>
       "Floating Point"@en
       "Coma flotante"@es
       bindToRuleSet floating_point
     </FundamentalDataType>
  </Vocabulary>

  <RuleSet photo>
    <Structure>
      <Descriptor has_title>
        property prueba:hasTitle
        minCardinality 1
        maxCardinality 1
      </Descriptor>
      
      <Descriptor has_author>
        property prueba:hasAuthor
        minCardinality 1
        maxCardinality 1
      </Descriptor>
      
      <Descriptor published_in>
        property prueba:publishedIn
        minCardinality 1
        maxCardinality 1
      </Descriptor>
      
      <Descriptor has_dimensions>
        property prueba:hasDimensions
        minCardinality 1
        maxCardinality 1
      </Descriptor>
    </Structure>

#    <BPVFunctions>
#      <ImageBPVFunction image_ref>
#        defaultImageBPVFunction
#        |{ (@root->digital_copy).image_bpv }|
#      </ImageBPVFunction>
#    </BPVFunctions>

 #   <BPVFunctions>
 #     <TextBPVFunction title_and_author>
 #        |{ 
 #          title = (@root->has_title).text_bpv
 #          author = (@root->has_author).text_bpv
 #          "#{title} (#{author})"
 #        }|
 #     </TextBPVFunction>
 #   </BPVFunctions>

    <KRRelationRules>
      <KRRelationRule published_in_title>
         published_in->book.has_title
      </KRRelationRule>

      <KRRelationRule author_has_given_names>
        has_author->person.has_given_names
      </KRRelationRule>

      <KRRelationRule author_of_book_published_in>
        published_in->book.has_author
      </KRRelationRule>
      
      <KRRelationRule books_by_author_of_book_published_in>
        author_of_book_published_in->book.has_author[inv]
      </KRRelationRule>
      
    </KRRelationRules>
    
    <Descriptions>
    	defaultOrderBy has_author
    	
    	<VariableDesc>
        	df has_author
            df has_title
           	df published_in
       	</VariableDesc>
    
    	<ShortDesc>
        	df has_author
            df has_title
           	df published_in
           	df has_dimensions
    	</ShortDesc>

        <FullDesc>
        	<Area main>
            	<Title>
                	"Full record"@en
                	"Ficha completa"@es
            	</Title>
           		<Block>
           			<Title>
           				"Block with title"@en
                        "Bloque con título"@es
           			</Title>
           			<BlockSection>
           				<Label>
             				"Test code"@en
                        	"Codigo de prueba"@es
             			</Label>
                		df has_title
                		textBPV title_and_author
                	</BlockSection>
                	df has_author
                	df has_title
                	df published_in
                </Block>
                textBPV title_and_author
             </Area>
             <Area prueba>
             	<Block prueba>
             		df has_dimensions
             		df has_author
             		<UniqueDF>
             			<Label>
             				"Digital copy"@en
                            "Copia digital"@es
             			</Label>
             			<Value>
             				textBPV title_and_author
             			</Value>
                        <LinkTo image>
                        	"View in higher resolution..."@en
                            "Versión con mayor resolución..."@es
                        </LinkTo>
                    </UniqueDF>
             	</Block>
             </Area>
        </FullDesc>
    </Descriptions>
  </RuleSet>

  <RuleSet person>
    <Structure>
      <Descriptor has_given_names>
        property prueba:hasGivenNames
        minCardinality 1
        maxCardinality 1
      </Descriptor>
      
      <Descriptor has_last_names>
        property prueba:hasLastNames
        minCardinality 1
        maxCardinality 1
      </Descriptor>
    </Structure>
    
    <BPVFunctions>
      <TextBPVFunction full_name_lf>
         defaultTextBPVFunction
         |{ 
           given = (@root->has_given_names).text_bpv
           last = (@root->has_last_names).text_bpv
           "#{last}, #{given}"
         }|
      </TextBPVFunction>
    </BPVFunctions>    
  </RuleSet>

  <RuleSet book>
    <Structure>
      <Descriptor has_title>
        property prueba:hasTitle
        minCardinality 1
        maxCardinality 1
        multilingual
      </Descriptor>
      
      <Descriptor has_author>
        property prueba:hasAuthor
        minCardinality 1
      </Descriptor>
    </Structure>
    
    <Descriptions>
    	<ShortDesc>
        	df has_author
            df has_title
    	</ShortDesc>

        <FullDesc>
        	<Area main>
            	<Title>
                	"Full record"@en
                	"Ficha completa"@es
            	</Title>
           		<Block>
                	df has_author
                	df has_title
                </Block>
        	</Area>
        </FullDesc>
    </Descriptions>
  </RuleSet>
  
  <RuleSet dimensions>
    <Structure>
      <Descriptor has_height>
        property prueba:hasHeight
        minCardinality 1
        maxCardinality 1
      </Descriptor>
      
      <Descriptor has_width>
        property prueba:hasWidth
        minCardinality 1
        maxCardinality 1
      </Descriptor>
      
      <Descriptor has_length>
        property prueba:hasLength
        minCardinality 1
        maxCardinality 1
      </Descriptor>
      
      <Descriptor has_measurement_unit>
        property prueba:hasMeasurementUnit
        minCardinality 1
        maxCardinality 1
      </Descriptor>
    </Structure>
    
    <KRRelationRules>
      <KRRelationRule measurement_unit_abbrev>
         has_measurement_unit->measurement_unit.has_abbreviation
      </KRRelationRule>
      
      <KRRelationRule measurement_unit_name>
         has_measurement_unit->measurement_unit.has_name
      </KRRelationRule>
    </KRRelationRules>
    
    <CompVectorFunctions>
      <CompVectorFunction volume>
        |{ 
          x = (@root->has_width).val
          y = (@root->has_height).val
          z = (@root->has_length).val
          x * y * z
        }|
      </CompVectorFunction>
    </CompVectorFunctions>
    
    <BPVFunctions>
      <TextBPVFunction default_text>
         defaultTextBPVFunction
         |{ 
           x = (@root->has_width).text_bpv
           y = (@root->has_height).text_bpv
           z = (@root->has_length).text_bpv
           abbrev = (@root->measurement_unit_abbrev).text_bpv
           "#{x} x #{y} x #{z} #{abbrev}"
         }|
      </TextBPVFunction>
    </BPVFunctions>      
  </RuleSet>
  
  <RuleSet measurement_unit>
    <Structure>
      <Descriptor has_name>
        property prueba:hasName
        minCardinality 1
        maxCardinality 1
        multilingual
      </Descriptor>
      
      <Descriptor has_abbreviation>
        property prueba:hasAbbreviation
        minCardinality 1
        maxCardinality 1
        multilingual
      </Descriptor>
    </Structure>
  </RuleSet>
  
  <RuleSet floating_point>    
    typeInCode Float
  </RuleSet>
  
  <RepositorySetup>
    <SOC photos>
      "Photos"@en
      "Fotografías"@es
      hasGroupDomain prueba:Photo
      bindToRuleSet photo
      mainLevel
    </SOC>
    
    <SOC authors>
      "Authors"@en
      "Autores"@es
      hasGroupDomain prueba:Person
      bindToRuleSet person
      secondaryLevel
    </SOC>
    
    <SOC books>
      "Books"@en
      "Libros"@es
      hasGroupDomain prueba:Book
      bindToRuleSet book
      secondaryLevel
    </SOC>
    
    <SOC measurement_unit>    
      "Measurement Units"@en
      "Unidades de medición"@es
      hasGroupDomain prueba:MeasurementUnit
      bindToRuleSet measurement_unit
      secondaryLevel
    </SOC>  
  </RepositorySetup>
</DefinitionSet>