AnsweredAssumed Answered

Child-Association with delete propagation

Question asked by d_franz on Sep 17, 2012
I have created a Content model with a tutorial for the Alfresco-Explorer ( http://sujitpal.blogspot.de/2010/05/alfresco-developing-content-model.html ). To use this in Share I have putted the new types to share-config-custome.xml.
Now I can apply child nodes by the share UI to a parent. My problem is that if I am deleting a parent the childs remain in the DB. What I want is that the childs are deleted if I delete there parent.

My Content-Model:
<model name="my:mynewmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
   <description>Example custom Model</description>
   <author></author>
   <version>1.0</version>

  <!– import base models –>
  <imports>
    <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
    <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
  </imports>
  
   <namespaces>
      <!– Define a Namespace for my new definitions –>
      <namespace uri="my.new.model" prefix="my"/>
   </namespaces>
  
  <constraints>
    <constraint name="my:pubStates" type="LIST">
      <parameter name="allowedValues">
        <list>
          <value>Draft</value>
          <value>Review</value>
          <value>Published</value>
        </list>
      </parameter>
    </constraint>
  </constraints>

  <types>
    <!– ==================================================== –>
    <!– Represents the base document for this application    –>
    <!– ==================================================== –>
    <type name="my:baseDoc">
      <title>Base Document</title>
      <description>Abstract Base Document for this application</description>
      <parent>cm:content</parent>
      <mandatory-aspects>
        <aspect>cm:ownable</aspect>
      </mandatory-aspects>
    </type>
    <!– ==================================================== –>
    <!– Represents a blog written by a user (represented by  –>
    <!– a my:profile content). This has a 1:1 mapping to a   –>
    <!– profile, ie, a blog must have an associated profile  –>
    <!– It has a 0:n mapping to posts, ie, a blog can have 0 –>
    <!– to n posts associated with it. Fields for it are     –>
    <!– title, description and creation date.                –>
    <!– ==================================================== –>
    <type name="my:blog">
      <title>Blog Information</title>
      <description>Blog Level Information</description>
      <parent>my:baseDoc</parent>
      <properties>
        <property name="my:blogname">
          <type>d:text</type>
        </property>
        <!–property name="my:byline">
          <type>d:text</type>
        </property–>
        <!–property name="my:user">
          <type>d:noderef</type>
        </property–>
      </properties>
      <associations>
        <child-association name="my:post">
          <title>Posts</title>
          <target>
            <class>my:post</class>
            <mandatory>true</mandatory>
            <many>true</many>
          </target>
        <duplicate>false</duplicate>
        </child-association>
      </associations>
    </type>
    <!– ==================================================== –>
    <!– Represents a single blog post.                       –>
    <!– ==================================================== –>
    <type name="my:post">
      <title>Blog Post</title>
      <description>Single Blog Post</description>
      <parent>my:baseDoc</parent>
      <properties>
        <property name="my:blogRef">
          <type>d:noderef</type>
        </property>
      </properties>
      <!–mandatory-aspects>
        <aspect>cm:titled</aspect>
        <aspect>my:tagClassifiable</aspect>
        <aspect>my:publishable</aspect>
      </mandatory-aspects–>
    </type>

  </types>

  <aspects>

    <aspect name="my:publishable">
      <title>Publishable</title>
      <properties>
        <property name="my:pubState">
          <type>d:text</type>
          <multiple>true</multiple>
          <constraints>
            <constraint ref="my:pubStates"/>
          </constraints>
        </property>
        <property name="my:pubDttm">
          <type>d:datetime</type>
          <index enabled="true">
            <atomic>true</atomic>
            <stored>true</stored>
            <tokenised>both</tokenised>
          </index>
        </property>
        <property name="my:unpubDttm">
          <type>d:datetime</type>
          <index enabled="true">
            <atomic>true</atomic>
            <stored>true</stored>
            <tokenised>both</tokenised>
          </index>
        </property>
        <property name="my:furl">
          <type>d:text</type>
        </property>
      </properties>
    </aspect>

    <aspect name="my:tagClassifiable">
      <title>Category Tag</title>
      <parent>cm:classifiable</parent>
      <properties>
        <property name="my:tags">
          <title>Tags</title>
          <type>d:category</type>
          <mandatory>false</mandatory>
          <multiple>true</multiple>
          <index enabled="true">
            <atomic>true</atomic>
            <stored>true</stored>
            <tokenised>false</tokenised>
          </index>
        </property>
      </properties>
    </aspect>
  </aspects>

</model>

My share-config-custom.xml:
<alfresco-config>

    <!– Repository Library config section –>
   <config evaluator="string-compare" condition="RepositoryLibrary" replace="true">
      <!–
         Whether the link to the Repository Library appears in the header component or not.
      –>
      <visible>true</visible>
   </config>
  
   <!– Document Library config section –>
   <config evaluator="string-compare" condition="DocumentLibrary" replace="true">

      <tree>
         <!–
            Whether the folder Tree component should enumerate child folders or not.
            This is a relatively expensive operation, so should be set to "false" for Repositories with broad folder structures.
         –>
         <evaluate-child-folders>true</evaluate-child-folders>
        
         <!–
            Optionally limit the number of folders shown in treeview throughout Share.
         –>
         <maximum-folder-count>-1</maximum-folder-count>
      </tree>

      <!–
         Used by the "Manage Aspects" action and Rules pages

         For custom aspects, remember to also add the relevant i18n string(s)
            aspect.cm_myaspect=My Aspect
      –>
      <aspects>

         <!–
            Aspects that a user can see in UI.
            Used by Rules, aspects are the listed aspects for rule's "has-aspect" action condition.
         –>
         <visible>
            <aspect name="cm:versionable" />
            <aspect name="cm:taggable" />
         <aspect name="my:tagClassifiable" />   
         <aspect name="my:publishable" />
         </visible>

         <!–
            Aspects that a user can add in UI.
            Used by Rules, aspects are the listed aspects for rule's "add-features" action.
            Same as "visible" if left empty.
         –>
         <addable>
         </addable>

         <!–
            Aspects that a user can remove in UI.
            Used by Rules, aspects are the listed aspects for rule's "remove-features" action.
            Same as "visible" if left empty
         –>
         <removeable>
         </removeable>
      </aspects>

      <!–
         Used by the "Change Type" action.
         Used by Rules:
          - parent types are the listed types for rule's "is-subtype" action condition
          - sub types are the listed types for rule's "specialise-type" action

         Define valid subtypes using the following example:
            <type name="cm:content">
               <subtype name="cm:mysubtype" />
            </type>

         Remember to also add the relevant i18n string(s):
            type.cm_mysubtype=My SubType
      –>
      <types>
         <type name="cm:content">
         <subtype name="my:baseDoc"/>      
         <subtype name="my:blog"/>
         <subtype name="my:post" />
      </type>

         <type name="cm:folder">
         </type>
      </types>

      <!–
         If set, will present a WebDAV link for the current item on the Document and Folder details pages.
         Also used to generate the "View in Alfresco Explorer" action for folders.
      –>
      <!–
      <repository-url>http://localhost:8080/alfresco</repository-url>
      –>
    
      <!–
         File upload configuration
      –>
      <file-upload>
         <!–
            Adobe Flash
            In certain environments, an HTTP request originating from Flash cannot be authenticated using an existing session.
            See: http://bugs.adobe.com/jira/browse/FP-4830
            For these cases, it is useful to disable the Flash-based uploader for Share Document Libraries.
         –>
         <adobe-flash-enabled>true</adobe-flash-enabled>
      </file-upload>
   </config>
 
  
</alfresco-config>

Outcomes