Can't import content model with types associations - associations

I use Alfresco Community - 7.2.0 (rf6d005c1-blocal). When I try to import content model with types associations I get the error: "special model does not support element 'associations'".
I have created very simple model to test. If tag 'associations' is commented then all is ok. I wonder what's wrong?
<?xml version="1.0" encoding="UTF-8"?>
<!-- xsi:schemaLocation="http://www.alfresco.org/model/dictionary/1.0 modelSchema.xsd" -->
<model name="cm_test:contentmodel_test"
xmlns="http://www.alfresco.org/model/dictionary/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<description>Alfresco Content Domain Model TEST</description>
<author>Test</author>
<published>2022-06-29</published>
<version>1.10</version>
<imports>
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
<import uri="http://www.alfresco.org/model/system/1.0" prefix="sys"/>
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
</imports>
<namespaces>
<namespace uri="http://www.alfresco_test.org/model/content_test/1.10" prefix="cm_test"/>
</namespaces>
<types>
<type name="cm_test:authority_test">
<title>Alfresco Authority Abstract Type</title>
<parent>sys:base</parent>
</type>
<type name="cm_test:zone_test">
<title>Alfresco Authentication Zone Type</title>
<parent>cm:cmobject</parent>
<properties>
</properties>
<associations>
<child-association name="cm_test:inZone_test">
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>cm_test:authority_test</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
<duplicate>false</duplicate>
</child-association>
</associations>
</type>
</types>
</model>

Related

How to fetch folder contents along with other custom types?

I am new to alfresco. This is the custom model. I need to fetch folder contents (cm:folder) along with other custom types (sparepart, metal). The following method is used to fetch the types but the folder contents are not being returned. What changes need to be made in the custom-model xml file (and in the java class) for it to work properly?
For example Factory is the parent container.under Factory ,emp:metal,emp:asset and emp:sparepart are sub containers.so when i add these subcontainers under Factory containers then all these associations will come.like wise i need to another association called folder association.i can also create folders and contents inside Factory Container.existing model is working fine.but how to add emp:folder type as association inside Factory Container.when i click view node browser its not showing type as "emp:folder" and also target associations.
List<AssociationRef> associationRefs = nodeService.getTargetAssocs(nodeRef,
EMPContentModel.EMP_NAMESPACE_URI_QNAME_PATTERN);
if i add another association under emp:fac then also its not working..
<association name="emp:containsFactoryFolder">
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>cm:folder</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
custommodel.xml
<namespaces>
<namespace uri="http://www.emp.com/model/emp-cms-core/2.0" prefix="emp"/>
</namespaces>
<types>
<type name="emp:container">
<title>Container</title>
<parent>cm:folder</parent>
</type>
<type name="emp:fac">
<title>Factory</title>
<parent>emp:container</parent>
<associations>
<association name="emp:containsFactoryAsset">
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>emp:asset</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
<association name="emp:containsFactorySparePart">
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>emp:sparepart</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
<association name="emp:containsFactoryMetal">
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>emp:metal</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
</associations>
</type>
<type name="emp:sparepart">
<title>Spare Part</title>
<parent>emp:container</parent>
<properties>
<property name="emp:sparePartNumber">
<title>Spare Part Number</title>
<type>d:text</type>
</property>
</properties>
<associations>
<association name="emp:containsSparePartAsset">
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>emp:asset</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
<association name="emp:containsSparePartMetal">
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>emp:metal</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
<association name="emp:derivesFromSparePart">
<source>
<mandatory>false</mandatory>
<many>false</many>
</source>
<target>
<class>emp:sparepart</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
</associations>
</type>
<type name="emp:metal">
<title>Metal</title>
<parent>emp:container</parent>
<associations>
<association name="emp:containsMetalAsset">
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>emp:asset</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
<association name="emp:derivesFromMetal">
<source>
<mandatory>false</mandatory>
<many>false</many>
</source>
<target>
<class>emp:metal</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
<association name="emp:containsMetalMetal">
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>emp:metal</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
</associations>
</type>
<type name="emp:content">
<title>Content</title>
<parent>cm:content</parent>
</type>
<type name="emp:asset">
<title>Asset</title>
<parent>emp:content</parent>
</type>
</types>
</model>
Thanks in advance.
You need add configuration to your share-config-custom.xml add Documentlibrary configuration which will enable you to see your custom content type on user interface.
<types>
<type name="cm:content">
</type>
<type name="cm:folder">
<subtype name="emp:fac" />
<subtype name="emp:sparepart" />
</type>
<type name="trx:transferTarget">
<subtype name="trx:fileTransferTarget" />
</type>
</types>
Once you have those visible you can create normal folder and change it's type to your custom content type i.e(emp:fac etc...).
In order to add associate those folders with others you need to again add configuration related to folder properties in share-config-custom.xml
<config evaluator="model-type" condition="emp:fac">
<forms>
<form>
<field-visibility>
<show id="cm:name" />
<show id="emp:containsFactoryAsset" />
<show id="emp:containsFactorySparePart" />
<show id="cm:title" force="true" />
<show id="cm:description" force="true" />
</field-visibility>
</form>
</forms>
</config>
Something like this.

Alfresco custom subtypes for cm:folder not working

I tried to to create a new folder type, that inherits everything from cm:folder, so I created an xml file for myModel.xml under tomcat/shared/classes/alfresco/extension/models, and added the following content to it:
<?xml version="1.0" encoding="UTF-8"?>
<!-- xsi:schemaLocation="http://www.alfresco.org/model/dictionary/1.0 modelSchema.xsd" -->
<model name="my:custmodel"
xmlns="http://www.alfresco.org/model/dictionary/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<description>custom folder test</description>
<author>Max Mustermann</author>
<published>2015-11-24</published>
<version>1.0</version>
<imports>
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
<import uri="http://www.alfresco.org/model/system/1.0" prefix="sys"/>
</imports>
<namespaces>
<namespace uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
<namespace uri="http://www.alfresco.org/model/rendition/1.0" prefix="rn"/>
<namespace uri="http://www.alfresco.org/model/exif/1.0" prefix="exif"/>
<namespace uri="http://www.alfresco.org/model/audio/1.0" prefix="audio"/>
<namespace uri="http://www.alfresco.org/model/webdav/1.0" prefix="webdav"/>
<namespace uri="http://www.example.com/model/content/1.0" prefix="my" />
</namespaces>
<types>
<type name="my:folder1">
<title>folder1</title>
<parent>cm:folder</parent>
<archive>true</archive>
</type>
<type name="my:folder2">
<title>folder2</title>
<parent>cm:folder</parent>
<archive>true</archive>
</type>
</types>
then I added the following line to tomcat/shared/classes/alfresco/extension/custom-model-context.xml
<value>alfresco/extension/models/myModel.xml</value>
and finally in tomcat/shared/classes/alfresco/web-extension/share-config-custom.xml:
<type name="cm:folder">
<subtype name="my:folder1" />
<subtype name="my:folder2" />
</type>
Now the under details->change Typ, my subtypes appear, but when I try to apply them I get "cannot change type of document ..."
Your model file name in context file is mentioned as
<value>alfresco/extension/models/custModel.xml</value>
in your description you are saying name as "myModel.xml" is that a typo? Otherwise your file entries looks okey. Hope you are placing those entries properly.
This entry
<namespace uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
should be part of <imports> tag not <namespaces>
Something like this
<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>

One-to-many relation between type and aspect?

I have the next content model.:
<?xml version="1.0" encoding="UTF-8"?>
<model name="sm:modelContent" xmlns="http://www.alfresco.org/model/dictionary/1.0">
<description>Content Model</description>
<author>Arak</author>
<version>1.0</version>
<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.some.com/model/content/1.0" prefix="sm" />
</namespaces>
<!-- Types -->
<types>
<type name="sm:contentParent">
<parent>cm:content</parent>
</type>
<type name="sm:contentChildren1">
<parent>sm:contentParent</parent>
</type>
<type name="sm:contentChildren2">
<parent>sm:contentParent</parent>
</type>
<type name="sm:contentChildren3">
<parent>sm:contentParent</parent>
</type>
</types>
<!-- Aspects -->
<aspects>
<!-- An Aspect -->
<aspect name="sm:otherOtherAspect">
<properties>
....
</properties>
</aspect>
<!-- Other Aspect -->
<aspect name="sm:otherAspect">
<properties>
....
</properties>
</aspect>
<!-- An Other Aspect -->
<aspect name="sm:anOtherAspect1">
<properties>
....
</properties>
</aspect>
<aspect name="sm:anOtherAspect2">
<properties>
....
</properties>
</aspect>
<aspect name="sm:anOtherAspect3">
<properties>
....
</properties>
</aspect>
... can exist N ...
<!-- Other Other Aspect -->
<aspect name="sm:anAspect1">
<properties>
....
</properties>
</aspect>
<aspect name="sm:anAspect2">
<properties>
....
</properties>
</aspect>
<aspect name="sm:anAspect3">
<properties>
....
</properties>
</aspect>
... can exist N ...
</aspects>
Depending of the type of content:
sm:contentChildren1 can have a 1 "anOtherAspect" and 0 "anAspect".
sm:contentChildren2 can have a N "anOtherAspect" and 0 "anAspect".
sm:contentChildren3 can have a N "anOtherAspect" and N "anAspect".
These relationships exist between types and aspects? (one-to-one or one-to-many) How can use it?, if not exist, I can simulate this relationship in any way?
I would like to work aspects based on a relationship and not creating them one by one (exaggerating the value of N, and creating a lot of aspects).
Greetings,
Pablo.
Alfresco aspects are on-to-one in that an Alfresco node can only have one instance of a particular aspect and a particular instance of an aspect is only associated with one node.
You have two options for getting multiple values on your node.
Designate your properties as <multiple>true</multiple> which means that it can hold multiple values. More details on this here:
http://docs.alfresco.com/5.0/concepts/metadata-model-props.html
Use peer associations. These allow you to have any kind of multiplicity relationship between nodes. Also bear in mind that the content of Alfresco nodes can be empty and you can use one only to hold metadata in a sense using it as an aspect. These are detailed in the data dictionary guide:
http://wiki.alfresco.com/wiki/Data_Dictionary_Guide#Peer_.28Non-Child.29_Associations

Alfresco disable full text indexing on specific content model

Using Alfresco 4.2 or 5.0, how do you disable full text indexing on a content-model basis?
Here is an example content model, what do you change specifically (i.e. do not reference the index control aspect without how to actually use it with a content model).
<model name="my:textdoc" xmlns="http://www.alfresco.org/model/dictionary/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<imports>
<import prefix="d" uri="http://www.alfresco.org/model/dictionary/1.0" />
<import prefix="cm" uri="http://www.alfresco.org/model/content/1.0" />
</imports>
<namespaces>
<namespace prefix="my"
uri="http://www.notarealurl.xyz/model/my/1.0" />
</namespaces>
<types>
<type name="my:securetextdoc">
<title>text docs with keyword searching, but not content searching</title>
<parent>cm:content</parent>
<properties>
<property name="my:securekeywords">
<title>custom key word text field</title>
<type>d:text</type>
<mandatory>true</mandatory>
</property>
</properties>
<mandatory-aspects>
<!-- <aspect>cm:dublincore</aspect> -->
<aspect>cm:versionable</aspect>
</mandatory-aspects>
</type>
</types>
FINAL ANSWER
<model name="my:textdoc" xmlns="http://www.alfresco.org/model/dictionary/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<imports>
<import prefix="d" uri="http://www.alfresco.org/model/dictionary/1.0" />
<import prefix="cm" uri="http://www.alfresco.org/model/content/1.0" />
</imports>
<namespaces>
<namespace prefix="my"
uri="http://www.notarealurl.xyz/model/my/1.0" />
</namespaces>
<types>
<type name="my:securetextdoc">
<title>text docs with keyword searching, but not content searching</title>
<parent>cm:content</parent>
<properties>
<property name="my:securekeywords">
<title>custom key word text field</title>
<type>d:text</type>
<mandatory>true</mandatory>
</property>
</properties>
<mandatory-aspects>
<!-- <aspect>cm:dublincore</aspect> -->
<aspect>my:doNotIndexContentControl</aspect>
<aspect>cm:versionable</aspect>
</mandatory-aspects>
</type>
</types>
<aspects>
<aspect name="my:doNotIndexContentControl">
<title>Do Not Index Control</title>
<parent>cm:indexControl</parent>
<overrides>
<property name="cm:isIndexed">
<default>true</default>
</property>
<property name="cm:isContentIndexed">
<default>false</default>
</property>
</overrides>
</aspect>
</aspects>
</model>
Important Note: If you get "Source node class has no callback" errors, this is related to changing the content model and then trying to update (likely versionable) existing content. No known workaround, but this is unrelated to index control options.
You can achieve this by defining a new aspect that extends cm:indexControl like so:
<aspect name="my:doNotIndexContentControl">
<title>Do Not Index Control</title>
<parent>cm:indexControl</parent>
<overrides>
<property name="cm:isIndexed">
<default>true</default>
</property>
<property name="cm:isContentIndexed">
<default>false</default>
</property>
</overrides>
</aspect>
Note the overrides. The overridden property, cm:isContentIndexed, with default value set to false is key.
You then add this aspect as mandatory for the types which you do not wish to full text index the content. The full configuration options for cm:indexControl can be found in the documentation http://docs.alfresco.com/4.2/concepts/admin-indexes.html
Also, if you have existing content items that have already been indexed and you want those documents to no longer be indexed, you will need to do a full re-index.
This is covered in the Data Dictionary guide on the Alfresco wiki
All you need to do is all this to your model:
<index enabled="false" />
If you look at something like the Alfresco system model, you'll see several examples of that

Error when saving document of custom type in Alfresco Share

I got this exception when trying to save a new document of custom type:
org.alfresco.service.cmr.repository.MalformedNodeRefException: 06010026 Invalid node ref - does not contain forward slash: {node.nodeRef}
Here is how the definition of the custom type looks like:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Definition of new Model -->
<model name="ht:channelmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
<!-- 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.someco.com/model/content/1.0" prefix="ht" />
</namespaces>
<types>
<!-- Here comes my type -->
<type name="ht:doc">
<title>Custom Document</title>
<parent>cm:content</parent>
<mandatory-aspects>
<aspect>cm:generalclassifiable</aspect>
</mandatory-aspects>
</type>
</types>
<aspects>
<aspect name="ht:channel">
<title>Content Channel</title>
<properties>
<property name="ht:isWeb">
<type>d:boolean</type>
</property>
</properties>
</aspect>
</aspects>
</model>
and here is how I set the forms for displaying the creation of a new document of my custom type (inside share-config-custom.xml)
<alfresco-config>
<config evaluator="string-compare" condition="DocumentLibrary">
<create-content>
<content id="plain-text" mimetype="text/plain" label="Prompt" itemid="ht:doc" />
</create-content>
<aspects>
<visible>
<aspect name="ht:channel" />
</visible>
<addable>
</addable>
<removeable>
</removeable>
</aspects>
<types>
<type name="cm:content">
<subtype name="ht:doc" />
</type>
</types>
</config>
<config evaluator="model-type" condition="ht:doc">
<forms>
<form>
<field-visibility>
<show id="cm:title" force="true" />
<show id="ht:isWeb" force="true" />
</field-visibility>
<appearance>
<field id="cm:title">
<control template="/org/alfresco/components/form/controls/textfield.ftl" />
</field>
</appearance>
</form>
</forms>
</config>
</alfresco-config>
Is it something wrong with the formatting or am I missing some fields in the type definition?
Thanks
Found the solution on the dedicated Alfresco forum.
Here it is:
<content id="myContent" label="Prompt" type="pagelink" index="1" >
<param name="page">create-content?destination={nodeRef}&itemId=ht:doc&mimeType=text/html</param>
</content>

Resources