cancel
Showing results for 
Search instead for 
Did you mean: 

AMP/AMP model dependency

stephenl
Champ on-the-rise
Champ on-the-rise
Hi,

I'm just wondering if there's a way to have two AMPs and have a custom model in one dependent on a custom model in another? Using Eclipse I have previously built my root amp and have it sat in a dependency folder when I build and deploy my child AMP:


<build>
        <plugins>
            <plugin>
          <groupId>org.alfresco.maven.plugin</groupId>
          <artifactId>alfresco-maven-plugin</artifactId>
         
          <extensions>true</extensions>
          <executions>
             <execution>
               <id>install-amps</id>
               <goals>
                   <goal>install</goal>
               </goals>
               <phase>package</phase>
             </execution>
          </executions>
          <configuration>
            <ampLocation>libs</ampLocation>
          </configuration>
        </plugin>


This all seems to work fine for the availability of the webscripts in the root AMP (at run-time) but not for referring to the root model even though it is declared as imported in the child model:


<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" />
 
<import uri="http://someurl/othercomponent/content/1.0" prefix="rootmodel" />
</imports>


But I always get errors stating that rootmodel cannot be found.

Edit:Basically, what I'm aiming for is the ability to derive a child custom content type from one defined in the root AMP's custom content model.


Thanks a lot.
2 REPLIES 2

steven_okennedy
Star Contributor
Star Contributor
Hi,

Sounds like you're just having problems controlling the order that your amps are being loaded by the system at startup.  The module.properies file has an available option called module.depends.* which allows you to specify that your module depends on (a particular version/minimum version/version range of) another amp.

E.g. module.depends.RootAmp.1.0.0

Have a look at http://docs.alfresco.com/5.1/concepts/dev-extensions-modules-module-properties.html for some examples of what you can do.

Regards

Steven

Hi Steven,

Thank you for a detailed answer, I was unaware of the module.properties file contents and I have added in the dependency as you suggest. Although I don't think this immediately solved the problem it will still be required as the child amp will require the root project to be in place. Ultimately I had to modify {project.id}-model-context.xml in the extension folder of my child project to be dependent on the root project:


<!– Registration of new models –>
   <bean id="child.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="root.dictionaryBootstrap">
      <property name="models">
         <list>
            <value>alfresco/extension/model/childModel.xml</value>
         </list>
      </property>
   </bean>


The depends-on="root.dictionaryBootstrap" seems to have solved it but module.properties still needs modifying to ensure the root's existence.

Thanks,
Stephen