Create an aspect in Alfresco Content Model

后端 未结 2 996
春和景丽
春和景丽 2021-01-06 09:38

I am starting currently using Alfresco CMS. I need to create an \"aspect\" in my content model which must contains a number of properties as:

Aspect: 
    pr         


        
2条回答
  •  说谎
    说谎 (楼主)
    2021-01-06 10:04

    Let me try to add some extra info to @Alch3mi5t's answer based on your comment. I'm using an imaginary business case here.

    Basically, Alfresco model consists of 3 sections: constraints, types and aspects. Plus, I'll add associations in the mix.

    • Type

    Each node in alfresco (you might incorrectly think of it as of a "record") has a type. So this type has properties ("columns"). So you have your base type, let's say it's called Vendor. It has two props, Name and tax ID (string and int). Your type definition would look like:

    
      Vendor</type>
      <parent>cm:folder</parent>
      <properties>
        <property name="myCompany:vendorName">
          <title>Vendor name
          d:text
        
        
          Vendor Tax ID
          d:int
        
      
    
    

    There goes your type, not unlike a db table with columns vendorName and vendorTaxID of the string and int type.

    • Constraint

    Let's say you now have to add some constraint on the tax id - simple regex example. So you have a constraint defined like this:

    
      
        ^ID[1-9](\-[1-9])*
      
      
        true
      
    
    

    Now we only need to modify our taxId property:

    
      Vendor Tax ID
      d:int
      
        
      
    
    

    So, you now placed a constraint on that property.

    • Aspect Now you want an aspect - in Alfresco, this would be as if you want to add few extra columns to that table.

    No - better analogy, you want a relation from your original table. So if it's null, it's null. But alternatively, it creates a 1-1 (usually) relation to your records to that other table.

    The baseline here is that you would never add anything into the aspect table alone - it only comes as an addition to the base type. An example aspect:

    
      Address aspect
      
        
          City
          d:text
        
      
    
    

    You can make this a mandatory aspect if you add this to your type definition (just after the properties section):

    
      myCompany:myAspect
    
    

    Now, you can add a "record" to your base "table", and if you added this as a mandatory aspect, then each record will have 3 props: name, tax id and city. If not mandatory, then each record will have two base columns, but you will be able to add the third to select few. Programatically or manually, doesn't matter.

    • Associations Now we can also add associatons in the mix: this is a link only between two nodes (or "records"). So, after the properties section in your type, you can add associations section. Let's say you want to connect (some) Vendors to their creators (Key accounts).

    You add this to your type:

    
      
        
          false
          true
        
        
          cm:person
          false
          true
        
      
    
    

    There you have it! You can now connect some or all of the Vendors in your Vendor table to their respective KAMs (so you can email KAMs when something is going on with the Vendor, let's say). Basically, a 1-n connection between your Vendors table and your Users table. 1-n meaning you can connect one Vendor to many Persons. You can also connect different Vendors to one person. (the many parameters).

    You can also add association to an aspect, in the same manner:

    
     
     ...
     
     
      
        
          true
          true
        
        
          cm:folder
          false
          true
        
      
     
    
    

    Now you can create regular alfresco folders (cm:folder type) and name them after the state, and have each of the cities be connected to one of them folders. (Not the best way, but shows my point.) so this association is mandatory, meaning if you add this other aspect (not the original one), which is not mandatory, you HAVE to create an association.

    So play with the combinations to do what you need.

    • Model

    So now you have your example model:

        
        
          Custom Content Model
          Zlatko Đurić
          2013-03-22
          1.0
          
            
            
          
    
          
            
          
    
          
            
              
                ^ID[1-9](\-[1-9])*
              
              
                true
              
            
          
    
          
            
              Vendor</type>
              <parent>cm:folder</parent>
              <properties>
                <property name="myCompany:vendorName">
                  <title>Vendor name
                  d:text
                
                
                  Vendor Tax ID
                  d:int
                  
                    
                  
                  
              
              
                myCompany:myAspect
              
              
                
                  
                    false
                    true
                  
                  
                    cm:person
                    false
                    true
                  
                
              
            
          
    
          
            
              Address aspect
              
                
                  City
                  d:text
                
              
    
              
                
                  
                    true
                    true
                  
                  
                    cm:folder
                    false
                    true
                  
                
               
             
          
        
    
    There, I hope this helps you.
    

提交回复
热议问题