cancel
Showing results for 
Search instead for 
Did you mean: 

Defining Categories in an AMP

jsant
Champ in-the-making
Champ in-the-making
I'm developing several custom content types and as such have a lot of custom categories that I have created.

For the time being, I've created them via the Admin UI, however this method isn't reproducable and doesn't allow me to easily deploy my content to dev, test and prod environments. Instead I'd like the categories to be part of the AMP file I'm developing, but I don't understand what method I need to use to do this.

As mentioned in this thread http://forums.alfresco.com/en/viewtopic.php?t=7052, I could generate a categories.xml and use that to bootstrap a clean server installation, but that isn't possible in a production environment.  The "category import script" attached to the post is an alternative, but I wanted to know if there is a "standard" way of doing it via an AMP file that I'm not seeing?

Thanks
3 REPLIES 3

ivo_costa
Champ in-the-making
Champ in-the-making
Hi jsant

have you managed to find a solution for this???

I'm looking to do the same but I can't get it to work

heres my cat.xml:

<view:view xmlns:view="http://www.alfresco.org/view/repository/1.0"
           xmlns:sys="http://www.alfresco.org/model/system/1.0"
           xmlns:cm="http://www.alfresco.org/model/content/1.0">

    <cm:category_root view:childName="cm:categoryRoot">
        <cm:name>categories</cm:name>
        <cm:categories>
            <cm:category view:childName="cm:generalclassifiable">
                <cm:name>General</cm:name>
                <cm:subcategories>
                    <mp:category>
                        <cm:name>001.000.0.000</cm:name>
                        <cm:description>Teste</cm:description>
                        <mp:classDesc>Test de Classificacao</mp:classDesc>
                    </mp:category>

                </cm:subcategories>
            </cm:category>

        </cm:categories>
    </cm:category_root>

</view:view>


And my bootstrap context
<bean id="CLIP2009.bootstrapSpaces" class="org.alfresco.repo.module.ImporterModuleComponent" parent="module.baseComponent">
        <property name="sinceVersion" value="9.9.11" />
        <property name="appliesFromVersion" value="9.9.11" />

        <property name="importer" ref="spacesBootstrap" />
        <property name="bootstrapViews">
            <list>
                <props>
                    <prop key="path">/cm:categoryRoot/cm:generalclassifiable</prop>
                    <prop key="location">alfresco/module/CLIP2009/bootstrap/categories.xml</prop>
                </props>
            </list>
        </property>
    </bean>
</beans>


I'm always getting a can't load module error no matter what I try to do

I'm using a custom category, don't know if it might be from that

Thanks

phileas
Champ in-the-making
Champ in-the-making
Looking at http://wiki.alfresco.com/wiki/Bootstrap_Data it seems like you are missing the "moduleId" property in your bootstrap bean.
But anyway with that property I don't get any errors but my categories are still not deployed.

darryl_staflund
Champ in-the-making
Champ in-the-making
Hi there,

I ran into this problem too and found that I was able to bootstrap my categories if all of them were of type 'cm:generalclassifiable'.  But the moment I tried working with categories of type 'cm:categoryRoot', the bootstrap would fail. I don't know why.

Here is how I structured my amp to import categories (NB:  It took me a while to come upon this solution so I am posting it here to help anyone else who might be wanting to do this):


AMP Structure

    /com_example_categories-1.0.0
        /config
            /alfresco
                /module
                    /com_example_categories
                        /boostrap
                            sample_categories.xml
                        /context
                            boostrap-context.xml
                        module-context.xml
        file-mapping.properties
        module.properties

Here is what 'sample_categories.xml' looks like:


<?xml version="1.0" encoding="UTF-8"?>
<view:view  xmlns:view="http://www.alfresco.org/view/repository/1.0"
            xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
            xmlns:alf="http://www.alfresco.org"
            xmlns:d="http://www.alfresco.org/model/dictionary/1.0"
            xmlns:act="http://www.alfresco.org/model/action/1.0"
            xmlns:wf="http://www.alfresco.org/model/workflow/1.0"
            xmlns:app="http://www.alfresco.org/model/application/1.0"
            xmlns:usr="http://www.alfresco.org/model/user/1.0"
            xmlns:ver="http://www.alfresco.org/model/versionstore/1.0"
            xmlns:cm="http://www.alfresco.org/model/content/1.0"
            xmlns:sv="http://www.jcp.org/jcr/sv/1.0"
            xmlns:mix="http://www.jcp.org/jcr/mix/1.0"
            xmlns:jcr="http://www.jcp.org/jcr/1.0"
            xmlns:sys="http://www.alfresco.org/model/system/1.0"
            xmlns:rule="http://www.alfresco.org/model/rule/1.0"
            xmlns:fm="http://www.alfresco.org/model/forum/1.0"
            xmlns:bpm="http://www.alfresco.org/model/bpm/1.0"
            xmlns:rma="http://www.alfresco.org/model/recordsmanagement/1.0"
            xmlns:dod="http://www.alfresco.org/model/dod5015/1.0"
            xmlns:custom="custom.model"
            xmlns="" >
           
   <cm:category view:childName="cm:generalclassifiable">   
       <cm:name>Sample Classifications</cm:name>
       <cm:subcategories>
      
           <cm:category>
               <cm:name>0100 Category 1</cm:name>
               <cm:subcategories>
                   <cm:category><cm:name>0110 Subcategory 1</cm:name></cm:category>
                   <cm:category><cm:name>0115 Subcategory 2</cm:name></cm:category>
                   <cm:category><cm:name>0120 Subcategory 3</cm:name></cm:category>
               </cm:subcategories>
           </cm:category>
          
           <cm:category>
               <cm:name>0200 Category 2</cm:name>
               <cm:subcategories>
                   <cm:category><cm:name>0210 Subcategory 1</cm:name></cm:category>
                   <cm:category><cm:name>0215 Subcategory 2</cm:name></cm:category>
                   <cm:category><cm:name>0220 Subcategory 3</cm:name></cm:category>
               </cm:subcategories>
           </cm:category>

           <cm:category>
               <cm:name>0300 Category 3</cm:name>
               <cm:subcategories>
                   <cm:category><cm:name>0310 Subcategory 1</cm:name></cm:category>
                   <cm:category><cm:name>0315 Subcategory 2</cm:name></cm:category>
                   <cm:category><cm:name>0320 Subcategory 3</cm:name></cm:category>
               </cm:subcategories>
           </cm:category>

           <cm:category><cm:name>Draft</cm:name></cm:category>
           <cm:category><cm:name>Unknown</cm:name></cm:category>
       </cm:subcategories>
   </cm:category>

</view:view>

Here is what 'bootstrap-context.xml' looks like:


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

<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:lang="http://www.springframework.org/schema/lang"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
        http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.0.xsd">

    <bean id="com_example_categories_bootstrapSpaces" class="org.alfresco.repo.module.ImporterModuleComponent" parent="module.baseComponent">
        <property name="moduleId" value="com_example_categories" />
        <property name="name" value="com_example_categories.bootstrapSpaces" />
        <property name="description" value="Bootstrap Sample Categories." />
        <property name="sinceVersion" value="1.0.0" />
        <property name="appliesFromVersion" value="1.0.0" />
        <property name="importer" ref="spacesBootstrap"/>
        <property name="bootstrapView">
            <props>
                 <prop key="path">/cm:categoryRoot/cm:generalclassifiable</prop>
                 <prop key="location">alfresco/module/com_example_categories/bootstrap/sample_categories.xml</prop>
             </props>
        </property>
    </bean>
</beans>

Here is what 'module-context.xml' looks like:


<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
    <import resource="classpath:alfresco/module/com_example_categories/context/*-context.xml" />
</beans>

Here is what 'file-mapping.properties' looks like:


/config=/WEB-INF/classes

Here is what 'module-properties.xml' looks like:


module.id=com_example_categories
module.title=Sample Categories Module
module.description=Bootstraps sample categories.
module.version=1.0.0
module.repo.version.min=3.3

I hope someone finds this helpful.

Darryl