cancel
Showing results for 
Search instead for 
Did you mean: 

Add aspect to type

sihnu
Champ in-the-making
Champ in-the-making
Hi,

I've defined a custom aspect in my own custom model and now I would like to add that aspect to a type in another custom model I've made. I've tried importing it. This is the namespace in the model where the aspect is defined:

<namespace uri="http://www.alfresco.com/model/test-model/1.0" prefix="test"/>

And this is the import in the model where the type is defined:

<import uri="http://www.alfresco.com/model/test-model/1.0" prefix="test"/>

For some reason this breaks my Alfresco. Both of those models works fine alone. This is the way I would add the aspect to my type. Though not got that far as the import breaks it. Anyway, I'm not sure if this is the right way so I paste it here now:

<mandatory-aspects>
   <aspect>test:testaspect</aspect>
</mandatory-aspects>

I'm doing it wrong so could someone help me how to do it properly? Until then I will just define the aspect in the model where the type is defined also. But this breaks the idea of aspects, doesn't it?

Thanks in advance.
3 REPLIES 3

amitabhandari1
Champ in-the-making
Champ in-the-making
Hi Sihnu,

This code seems to  be fine  . If you can attach the  models where you have defined aspect and the content type then it would be helpful to find out the issue.

Thanks,

sihnu
Champ in-the-making
Champ in-the-making
Thanks for the answer.

I can't post the models right now but I will asap. Anyway, I stumbled on the same error later… The import really seems to be causing the error. I copied a bpmModel to extension/model folder and changed the name to custombpmModel. Then I changed import from original bpmModel to the model I copied to my extension folder. It worked with the original bpmModel but is not working with the new one even though I've only changed the name of the model and nothing else. I don't understand why this is happening.

I will paste the whole model here tomorrow. Hope something will pop out.

Sihnu

sihnu
Champ in-the-making
Champ in-the-making
Here are the models:

This is the model where the apsect should be imported:

<?xml version="1.0" encoding="UTF-8"?>

<!– Definition of Knowledge Base Model –>

<model name="test:testmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <!– Optional meta-data about the model –>
   <description>test Model</description>
   <author>Henri Lämsä</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"/>
   </imports>

   <!– Introduction of new namespaces defined by this model –>
   <namespaces>
      <namespace uri="http://www.alfresco.com/model/test/1.0" prefix="test"/>
   </namespaces>

    <aspects>
      <!– Definition of new Content Aspect: Knowledge Base Document –>
      <aspect name="test:asiakirja">
         <title>Asiakirja</title>
         <properties>
            <property name="test:dateAccepted">
               <type>d:date</type>
            </property>
       <property name="test:dateGathered">
               <type>d:date</type>
            </property>
       <property name="test:dateValid">
               <type>d:date</type>
            </property>
       <property name="test:authenticityChecker">
               <type>d:text</type>
            </property>
       <property name="test:authenticityDate">
               <type>d:date</type>
            </property>
       <property name="test:authenticityDescription">
               <type>d:mltext</type>
            </property>
       <property name="test:signatureDescription">
               <type>d:text</type>
            </property>
       <property name="test:coverage">
               <type>d:text</type>
            </property>
       <property name="test:coverageJurisdiction">
               <type>d:text</type>
            </property>
       <property name="test:coverageSpatial">
               <type>d:text</type>
            </property>
       <property name="test:coverageTemporal">
               <type>d:text</type>
            </property>
       <property name="test:audience">
               <type>d:text</type>
            </property>
       <property name="test:source">
               <type>d:text</type>
            </property>
       <property name="test:rights">
               <type>d:text</type>
            </property>
        <property name="test:relationRequires">
               <type>d:text</type>
            </property>
       <property name="test:relationIsPartOf">
               <type>d:text</type>
            </property>
       <property name="test:relationIsFormatOf">
               <type>d:text</type>
            </property>
       <property name="test:relationIsVersionOf">
               <type>d:text</type>
            </property>
       <property name="test:relationIsRedactionOf">
               <type>d:text</type>
            </property>
       <property name="test:protectionClass">
               <type>d:text</type>
            </property>
       <property name="test:alternativeTitle">
               <type>d:text</type>
            </property>
       <property name="test:version">
               <type>d:text</type>
            </property>
         </properties>
      </aspect>
   </aspects>

</model>

And this is the model where to the asepct is imported:

<?xml version="1.0" encoding="UTF-8"?>

<model name="wf:workflow" xmlns="http://www.alfresco.org/model/dictionary/1.0">

  <imports>
     <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
     <import uri="http://www.alfresco.org/model/bpm/1.0" prefix="bpm"/>
  </imports>

  <namespaces>
     <namespace uri="http://www.alfresco.org/model/workflow/1.0" prefix="wf"/>
  </namespaces>
     
  <types>


     <type name="wf:submitAdhocTask">
        <parent>bpm:startTask</parent>
        
        <properties>
           <property name="wf:notifyMe">
              <type>d:boolean</type>
              <default>false</default>
           </property>
        </properties>

        <mandatory-aspects>
           <aspect>bpm:assignee</aspect>
           <aspect>wf:task</aspect>
        </mandatory-aspects>
     </type>

     <type name="wf:adhocTask">
        <parent>bpm:workflowTask</parent>
     </type>

     <type name="wf:completedAdhocTask">
        <parent>bpm:workflowTask</parent>
     </type>
     
  </types>

  <aspects>
  <aspect name="wf:task">
        <title>Toimenpide</title>
        <properties>
           <property name="wf:dateFinished">
              <title>Päättymispvm</title>
              <type>d:date</type>
           </property>
           <property name="wf:electronicNotificationAcceptionDate">
              <title>Suostumusajankohta</title>
              <type>d:date</type>
           </property>
           <property name="wf:electronicNotificationAcceptionDescription">
              <title>Suostumuskuvaus</title>
              <type>d:mltext</type>
           </property>
           <property name="wf:electronicNotificationNotificationPeriodStart">
              <title>Tiedoksiantoperiodiin alkamispvm</title>
              <type>d:date</type>
           </property>
           <property name="wf:electronicNotificationNotificationPeriodEnd">
              <title>Tiedoksiantoperiodiin loppumispvm</title>
              <type>d:date</type>
           </property>
           <property name="wf:electronicNotificationDelivered">
              <title>Tiedoksiannon hakeminen</title>
              <type>d:date</type>
           </property>
        </properties>
     </aspect>
     </aspects>
</model>

I would like to have the aspect task in the formed model but importing the model breaks it like I told earlier. Both of these models work fine alone.