AnsweredAssumed Answered

How to get associations from the data list?

Question asked by Aleksey Bykov on Aug 17, 2017
Latest reply on Aug 18, 2017 by Aleksey Bykov

I have the custom data list that I'm using to store predefined list of assignees for all the departments. By the name of the department, I can identify the performers and assign them automatically.

 

There is a problem - I can't get associations from the data list in the web script. For example, data list model definition described as follows:

 

<?xml version="1.0" encoding="UTF-8"?>
<model name="mspdl:MSpredefinedAssigneesDataListModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

    <description>...</description>
    <author>...</author>
    <version>...</version>

    <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"/>
        <import uri="http://www.alfresco.org/model/datalist/1.0" prefix="dl" />
    </imports>

    <namespaces>
         <namespace uri="http://www.....com/model/datalist/3.0" prefix="mspdl"/>
    </namespaces>

    <types>
        <type name="mspdl:assigneesListItem">
            <title>...</title>
            <parent>dl:dataListItem</parent>
            <properties>
                <property name="mspdl:serviceName">
                    <type>d:text</type>
                    <mandatory>true</mandatory>
                </property>
            </properties>
            <associations>
           
                <association name="mspdl:projectMember1">
                    <source>
                        <mandatory>true</mandatory>
                        <many>false</many>
                    </source>
                    <target>
                        <class>cm:person</class>
                        <mandatory>true</mandatory>
                        <many>false</many>
                    </target>
                </association>
               
                <association name="mspdl:projectMember2">
                    <source>
                        <mandatory>true</mandatory>
                        <many>false</many>
                    </source>
                    <target>
                        <class>cm:person</class>
                        <mandatory>true</mandatory>
                        <many>false</many>
                    </target>
                </association>
                ...
                <association name="mspdl:projectMemberN">
                    <source>
                        <mandatory>true</mandatory>
                        <many>false</many>
                    </source>
                    <target>
                        <class>cm:person</class>
                        <mandatory>true</mandatory>
                        <many>false</many>
                    </target>
                </association>
               
            </associations>
        </type>
    </types>
</model>

 

The web script where I'm trying to retrieve associations:

 

public class DataListAssignmentsRetriever extends DeclarativeWebScript {

     private final String DATA_LIST_SITE_CONTAINER = "dataLists";
     private final String NAMESPACE_URI = "http://www.......com/model/datalist/3.0";

     @Override
     protected Map<String, Object> executeImpl(WebScriptRequest req, Status status) {          
          QName ASSOC_NAME_PROJECT_MEMBER_1 = QName.createQName(NAMESPACE_URI, "projectMember1");
          List<AssociationRef> temp00List = serviceRegistry.getNodeService().getSourceAssocs(dataListNodeRef, ASSOC_NAME_PROJECT_MEMBER_1);
          // temp00List.size() == 0 ???
          
          List<AssociationRef> temp01List = serviceRegistry.getNodeService().getTargetAssocs(dataListNodeRef, ASSOC_NAME_PROJECT_MEMBER_1);
          // temp01List.size() == 0 ???
          
          List<ChildAssociationRef> temp02List = serviceRegistry.getNodeService().getChildAssocs(dataListNodeRef);
          // temp02List == 1 < -- Allows to find just only the property 'serviceName'.
          
          List<ChildAssociationRef> temp03List =
               serviceRegistry.getNodeService().getChildAssocs(dataListNodeRef, RegexQNamePattern.MATCH_ALL, ASSOC_NAME_PROJECT_MEMBER_1);
          // temp03List.size() == 0 ???
          
          List<AssociationRef> temp04List.size() =
               serviceRegistry.getNodeService().getSourceAssocs(dataListNodeRef, RegexQNamePattern.MATCH_ALL);
          // temp04List.size() == 0 ???
                    
          List<AssociationRef> temp05List = serviceRegistry.getNodeService().getTargetAssocs(nodeRef, RegexQNamePattern.MATCH_ALL);
          // temp05List.size() == 0 ???
          
          ...
     }
}

 

Service serviceRegistry is injected correctly.

 

What I'm doing wrong? How to get associations from the data list?

 

I would be very grateful for the information. Thanks to all.

Outcomes