Creating associations via XML doesn't work

cancel
Showing results for 
Search instead for 
Did you mean: 
kwiesinger
Member II

Creating associations via XML doesn't work

Hi,

I tried to create an association in my model via XML. The model worked fine without the association but as soon as I added it and tried to import my XML I get an error (The existing model doesn't exist anymore) :

Association:

The VPIM:HVDisk is a type which exists and has properties in it. 

Is it possible that I forgot something? Do I need to activate anything?

My community edition is 5.2.

Looking forward to your answers.

Regards

13 Replies
rohit9637
Established Member

Re: Creating associations via XML doesn't work

Can you provide logs? It would be more helpful.

How are you importing the model? Is it by the bootstrap approach / the dynamic approach / from the model manager?

If you are using model manager then Creating a model from the model manager does not support associations.

Try this: https://docs.alfresco.com/6.1/references/dev-extension-points-content-model-define-and-deploy.html

kwiesinger
Member II

Re: Creating associations via XML doesn't work

I created the model with the model manager, then exported it, changed it and imported it (deleted the original model first).

This is my first project with Alfresco and I'm working with Angular and Typescript and therefore not with the Java Api.

So is it possible to create a raw XML-File with associations (e.g. via Notepad++) and import it with the dynamic approach?

Logs:

rohit9637
Established Member

Re: Creating associations via XML doesn't work

Yes, you can do it with Dynamic approach follow: https://docs.alfresco.com/6.1/tasks/deploy-dynamic.html

Make sure your existing model is deactivated if you have the same name.

abhinavmishra14
Advanced

Re: Creating associations via XML doesn't work

Would it be possible to post the content model here? Just want to check if there are any syntactical errors. I see that you have used a title element in association element. As per the model-schema (5.2.1), there is no title element allowed. Try removing title and see if it works. I have provided a working example of type and association below. 

<xs:complexType name="association">
<xs:sequence>
<xs:group ref="dd:TextualDescription"></xs:group>
<xs:element name="source" maxOccurs="1" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="role" type="xs:string" maxOccurs="1"
minOccurs="0" />

<xs:element name="mandatory" type="xs:boolean"
maxOccurs="1" minOccurs="0" />

<xs:element name="many" type="xs:boolean"
maxOccurs="1" minOccurs="0" />

</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="target">
<xs:complexType>
<xs:sequence>
<xs:element name="class" type="xs:string" maxOccurs="1" minOccurs="1" />
<xs:element name="role" type="xs:string" maxOccurs="1" minOccurs="0" />
<xs:element name="mandatory" type="dd:mandatoryDef"
maxOccurs="1" minOccurs="0" />

<xs:element name="many" type="xs:boolean"
maxOccurs="1" minOccurs="0" />

</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attributeGroup ref="dd:name" />
</xs:complexType>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Here is an example of creating "Peer Association" (as you are trying to create)

<type name="sc:whitepaper">
<title>Whitepaper</title>
<description>Whitepaper document</description>
<properties>
<property name="sc:author">
<title>Author</title>
<type>d:text</type>
<!-- Note that, protected element must be defined after type and
before mandatory element or any other element such as index, constraints etc. -->

<protected>false</protected>
<mandatory>false</mandatory>
<index enabled="true">
<!-- index in the background, i.e. async indexing -->
<atomic>true</atomic>
<stored>false</stored>
<tokenised>both</tokenised>
</index>
</property>
</properties>
<associations>
<association name="sc:relatedDocuments">
<source>
<!--mandatory = false , many= true means there can be 0 or more associations -->
<mandatory>false</mandatory>
<!-- sc:whitepaper can have many cm:content objects -->
<many>true</many>
</source>
<target>
<class>cm:content</class>
<!--mandatory = false , many= true means there can be 0 or more associations -->
<mandatory>false</mandatory>
<!-- cm:content object types can be tagged to many sc:whitepaper objects -->
<many>true</many>
</target>
</association>
</associations>
</type >‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
~Abhinav
(ACSCE, AWS SAA, Azure Admin)
kwiesinger
Member II

Re: Creating associations via XML doesn't work

Does the XML-File look the same with the dynamic approach? I'm just wondering if I could use my exported model and import it dynamically again.

I'm sorry for the layout, I marked the association bold at the end:

<?xml version="1.0" encoding="UTF-8"?>
<model xmlns="http://www.alfresco.org/model/dictionary/1.0" name="VPIM:VPIM">
<author>Katharina Wiesinger</author>
<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>
<namespace uri="VPIM" prefix="VPIM"/>
</namespaces>
<data-types/>
<constraints/>
<type name="VPIM:HVDisk">
<title>HVDisk</title>
<parent>VPIM:Base</parent>
<properties>
<property name="VPIM:HVDisk_Name">
<title>Name</title>
<type>d:text</type>
<mandatory>true</mandatory>
<index enabled="true">
<tokenised>TRUE</tokenised>
<facetable>false</facetable>
</index>
</property>
<property name="VPIM:HVDisk_GBAnzahl">
<title>GBAnzahl</title>
<type>d:double</type>
<mandatory>true</mandatory>
<index enabled="true">
<tokenised>TRUE</tokenised>
</index>
</property>
<property name="VPIM:HVDisk_DiskID">
<title>DiskID</title>
<type>d:int</type>
<mandatory>true</mandatory>
<index enabled="true">
<tokenised>TRUE</tokenised>
</index>
</property>
<property name="VPIM:HVDisk_DatentraegerID">
<title>DatenträgerID</title>
<type>d:int</type>
<mandatory>false</mandatory>
<index enabled="true">
<tokenised>TRUE</tokenised>
</index>
</property>
</properties>
<associations/>
<overrides/>
<mandatory-aspects/>
</type>
<type name="VPIM:Betriebsprojekt">
<title>Betriebsprojekt</title>
<parent>VPIM:Base</parent>
<properties>
<property name="VPIM:Betriebsprojekt_VerfuegbarkeitVon">
<title>VerfuegbarkeitVon</title>
<type>d:text</type>
<mandatory>false</mandatory>
<index enabled="true">
<tokenised>TRUE</tokenised>
<facetable>false</facetable>
</index>
</property>
<property name="VPIM:Betriebsprojekt_VerfuegbarkeitBis">
<title>VerfuegbarkeitBis</title>
<type>d:datetime</type>
<mandatory>false</mandatory>
<index enabled="true">
<tokenised>TRUE</tokenised>
</index>
</property>
<property name="VPIM:Betriebsprojekt_StartDatum">
<title>StartDatum</title>
<type>d:datetime</type>
<mandatory>true</mandatory>
<index enabled="true">
<tokenised>TRUE</tokenised>
</index>
</property>
<property name="VPIM:Betriebsprojekt_Anlage">
<title>Anlage</title>
<type>d:text</type>
<mandatory>false</mandatory>
<multiple>true</multiple>
<index enabled="true">
<tokenised>TRUE</tokenised>
<facetable>false</facetable>
</index>
</property>
<property name="VPIM:Betriebsprojekt_EndDatum">
<title>EndDatum</title>
<type>d:datetime</type>
<mandatory>false</mandatory>
<index enabled="true">
<tokenised>TRUE</tokenised>
</index>
</property>
<property name="VPIM:Betriebsprojekt_BetriebsprojektID">
<title>BetriebsprojektID</title>
<type>d:int</type>
<mandatory>true</mandatory>
<index enabled="true">
<tokenised>TRUE</tokenised>
</index>
</property>
<property name="VPIM:Betriebsprojekt_Beschreibung">
<title>Beschreibung</title>
<type>d:text</type>
<mandatory>false</mandatory>
<index enabled="true">
<tokenised>TRUE</tokenised>
<facetable>false</facetable>
</index>
<constraints>
<constraint name="VPIM:LENGTH_8365fe77-fbf9-40e6-815d-a4b6aa58ab2b" type="LENGTH">
<parameter name="maxLength">
<value>500</value>
</parameter>
<parameter name="minLength">
<value>0</value>
</parameter>
</constraint>
</constraints>
</property>
<property name="VPIM:Betriebsprojekt_Name">
<title>Name</title>
<type>d:text</type>
<mandatory>true</mandatory>
<index enabled="true">
<tokenised>TRUE</tokenised>
<facetable>false</facetable>
</index>
</property>
</properties>
<associations>
<association name="VPIM:test">
<title>test</title>
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>VPIM:HVDisk</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
</associations>
<overrides/>
<mandatory-aspects/>
</type>

</model>

rohit9637
Established Member

Re: Creating associations via XML doesn't work

yes, XML-File looks the same with the dynamic approach. Apart from it, you should remove the title tag which completely depends on the version you are using.

abhinavmishra14
Advanced

Re: Creating associations via XML doesn't work

Ideally dynamically generated xml should also be same. I also noticed in your model that you are missing <types> element where all types are defined.

Try adding <types> element and remove <title> element from <association> element as i mentioned above. Also update the Boolean values from 'TRUE' to 'true'

<?xml version="1.0" encoding="UTF-8"?>
<model xmlns="http://www.alfresco.org/model/dictionary/1.0" name="VPIM:VPIM">
<author>Katharina Wiesinger</author>
<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>
<namespace uri="VPIM" prefix="VPIM"/>
</namespaces>
<data-types/>
<constraints/>
<!-- Type Definitions -->
<types>
<type name="VPIM:HVDisk">
<title>HVDisk</title>
<parent>VPIM:Base</parent>
<properties>
<property name="VPIM:HVDisk_Name">
<title>Name</title>
<type>d:text</type>
<mandatory>true</mandatory>
<index enabled="true">
<tokenised>true</tokenised>
<facetable>false</facetable>
</index>
</property>
<property name="VPIM:HVDisk_GBAnzahl">
<title>GBAnzahl</title>
<type>d:double</type>
<mandatory>true</mandatory>
<index enabled="true">
<tokenised>true</tokenised>
</index>
</property>
<property name="VPIM:HVDisk_DiskID">
<title>DiskID</title>
<type>d:int</type>
<mandatory>true</mandatory>
<index enabled="true">
<tokenised>true</tokenised>
</index>
</property>
<property name="VPIM:HVDisk_DatentraegerID">
<title>DatenträgerID</title>
<type>d:int</type>
<mandatory>false</mandatory>
<index enabled="true">
<tokenised>true</tokenised>
</index>
</property>
</properties>
</type>
<type name="VPIM:Betriebsprojekt">
<title>Betriebsprojekt</title>
<parent>VPIM:Base</parent>
<properties>
<property name="VPIM:Betriebsprojekt_VerfuegbarkeitVon">
<title>VerfuegbarkeitVon</title>
<type>d:text</type>
<mandatory>false</mandatory>
<index enabled="true">
<tokenised>true</tokenised>
<facetable>false</facetable>
</index>
</property>
<property name="VPIM:Betriebsprojekt_VerfuegbarkeitBis">
<title>VerfuegbarkeitBis</title>
<type>d:datetime</type>
<mandatory>false</mandatory>
<index enabled="true">
<tokenised>true</tokenised>
</index>
</property>
<property name="VPIM:Betriebsprojekt_StartDatum">
<title>StartDatum</title>
<type>d:datetime</type>
<mandatory>true</mandatory>
<index enabled="true">
<tokenised>true</tokenised>
</index>
</property>
<property name="VPIM:Betriebsprojekt_Anlage">
<title>Anlage</title>
<type>d:text</type>
<mandatory>false</mandatory>
<multiple>true</multiple>
<index enabled="true">
<tokenised>true</tokenised>
<facetable>false</facetable>
</index>
</property>
<property name="VPIM:Betriebsprojekt_EndDatum">
<title>EndDatum</title>
<type>d:datetime</type>
<mandatory>false</mandatory>
<index enabled="true">
<tokenised>true</tokenised>
</index>
</property>
<property name="VPIM:Betriebsprojekt_BetriebsprojektID">
<title>BetriebsprojektID</title>
<type>d:int</type>
<mandatory>true</mandatory>
<index enabled="true">
<tokenised>true</tokenised>
</index>
</property>
<property name="VPIM:Betriebsprojekt_Beschreibung">
<title>Beschreibung</title>
<type>d:text</type>
<mandatory>false</mandatory>
<index enabled="true">
<tokenised>true</tokenised>
<facetable>false</facetable>
</index>
<constraints>
<constraint name="VPIM:LENGTH_8365fe77-fbf9-40e6-815d-a4b6aa58ab2b" type="LENGTH">
<parameter name="maxLength">
<value>500</value>
</parameter>
<parameter name="minLength">
<value>0</value>
</parameter>
</constraint>
</constraints>
</property>
<property name="VPIM:Betriebsprojekt_Name">
<title>Name</title>
<type>d:text</type>
<mandatory>true</mandatory>
<index enabled="true">
<tokenised>true</tokenised>
<facetable>false</facetable>
</index>
</property>
</properties>
<associations>
<association name="VPIM:test">
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>VPIM:HVDisk</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
</associations>
</type>
</types>
</model>

I have updated the model which you provided above for your reference. 

~Abhinav
(ACSCE, AWS SAA, Azure Admin)
kwiesinger
Member II

Re: Creating associations via XML doesn't work

Thank you very much, with your help it works!

It is normal that I don't see the model in the model manager? 

Regards

kwiesinger
Member II

Re: Creating associations via XML doesn't work

Edit: When I have my Project table and my HVDisk table and one Project can have many HVDisks, do I just have to add an association to my Project type?

In general it is difficult for me to understand on which type I have to place the "peer association".