You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@chemistry.apache.org by Philip Barr <Ph...@synapps-solutions.com> on 2014/08/20 12:44:23 UTC

Creating Relationships

Hi all,

I'm using DotCMIS 0.6 to connect to Alfresco Community 4.2f, but am having problems creating a relationship from any folder to any other folder, and any folder to any other document. I can't create a relationship of type "cmis:relationship" because it is handily "uncreateable" and all other relationships are clearly wrappers around Alfresco association types, so would be unusable when I try to connect another repository.
Even if I decide to use an Alfresco type and just change it for different repositories, I can't work  out which one to use because RelationshipType.GetAllowableSourceTypes and Relationship.GetAllowableTargetTypes is always just an empty list.

How do I create a relationship from any folder/doc to any other folder/doc.

My code:

            Dictionary<string, string> parameters = new Dictionary<string, string>();

            parameters[SessionParameter.BindingType] = BindingType.AtomPub;

            string url = "http://localhost:8080/alfresco/cmisatom";

            parameters[SessionParameter.AtomPubUrl] = url;

            parameters[SessionParameter.User] = "admin";

            parameters[SessionParameter.Password] = "admin";

            SessionFactory factory = SessionFactory.NewInstance();

            IList<IRepository> repositories = factory.GetRepositories(parameters);

            ISession session = repositories[0].CreateSession();

            IItemEnumerable<IObjectType> children = session.GetTypeChildren("cmis:relationship", true);

            foreach (IObjectType child in children)

            {

                RelationshipType rel = child as RelationshipType;

                Console.WriteLine(rel.Id + ": \n");

                Console.WriteLine("\tSource Types:" );

                foreach (IObjectType type in rel.GetAllowedSourceTypes)

                {

                    Console.WriteLine("\t\t" + type.Id);

                }

                Console.WriteLine("\tTarget Types:");

                foreach (IObjectType type in rel.GetAllowedTargetTypes)

                {

                    Console.WriteLine("\t\t" + type.Id);

                }

            }


Kind Regards,
Phil.

IMPORTANT NOTICE

This e-mail contains information which is confidential and may be privileged and is for the exclusive use of the recipient. If you are not the named recipient please contact the sender immediately and delete the communication from your system. You are hereby notified that any disclosure, distribution or copying of this communication, in whole or in part, is strictly prohibited. It is the responsibility of the recipient to ensure that this message and its attachments are virus free. Any views or opinions presented are solely those of the author and do not necessarily represent those of the Company, its directors or officers unless otherwise specifically stated. The Company is not responsible for any reliance placed on the information contained herein and excludes all liability.

SynApps Solutions Limited is a company registered in England & Wales. Company Registration No.: 04770224. VAT No.: 823778892

Re: Creating Relationships

Posted by Florian Müller <fm...@apache.org>.
Hi Philip,

If the allowable source types or the allowable target types lists are empty,
then any object can be the source respectively the target of this relationship.
(CMIS 1.1 spec, section 2.1.6.1.1)
It's the responsibility of the repository to provide the correct data here. If
you think that Alfresco provides wrong information, please discuss this in an
Alfresco forum.

- Florian


> Hi all,
> 
> I'm using DotCMIS 0.6 to connect to Alfresco Community 4.2f, but am having
> problems creating a relationship from any folder to any other folder, and any
> folder to any other document. I can't create a relationship of type
> "cmis:relationship" because it is handily "uncreateable" and all other
> relationships are clearly wrappers around Alfresco association types, so would
> be unusable when I try to connect another repository.
> Even if I decide to use an Alfresco type and just change it for different
> repositories, I can't work  out which one to use because
> RelationshipType.GetAllowableSourceTypes and
> Relationship.GetAllowableTargetTypes is always just an empty list.
> 
> How do I create a relationship from any folder/doc to any other folder/doc.
> 
> My code:
> 
>             Dictionary<string, string> parameters = new Dictionary<string,
> string>();
> 
>             parameters[SessionParameter.BindingType] = BindingType.AtomPub;
> 
>             string url = "http://localhost:8080/alfresco/cmisatom";
> 
>             parameters[SessionParameter.AtomPubUrl] = url;
> 
>             parameters[SessionParameter.User] = "admin";
> 
>             parameters[SessionParameter.Password] = "admin";
> 
>             SessionFactory factory = SessionFactory.NewInstance();
> 
>             IList<IRepository> repositories =
> factory.GetRepositories(parameters);
> 
>             ISession session = repositories[0].CreateSession();
> 
>             IItemEnumerable<IObjectType> children =
> session.GetTypeChildren("cmis:relationship", true);
> 
>             foreach (IObjectType child in children)
> 
>             {
> 
>                 RelationshipType rel = child as RelationshipType;
> 
>                 Console.WriteLine(rel.Id + ": \n");
> 
>                 Console.WriteLine("\tSource Types:" );
> 
>                 foreach (IObjectType type in rel.GetAllowedSourceTypes)
> 
>                 {
> 
>                     Console.WriteLine("\t\t" + type.Id);
> 
>                 }
> 
>                 Console.WriteLine("\tTarget Types:");
> 
>                 foreach (IObjectType type in rel.GetAllowedTargetTypes)
> 
>                 {
> 
>                     Console.WriteLine("\t\t" + type.Id);
> 
>                 }
> 
>             }
> 
> 
> Kind Regards,
> Phil.
> 
> IMPORTANT NOTICE
> 
> This e-mail contains information which is confidential and may be privileged
> and is for the exclusive use of the recipient. If you are not the named
> recipient please contact the sender immediately and delete the communication
> from your system. You are hereby notified that any disclosure, distribution or
> copying of this communication, in whole or in part, is strictly prohibited. It
> is the responsibility of the recipient to ensure that this message and its
> attachments are virus free. Any views or opinions presented are solely those
> of the author and do not necessarily represent those of the Company, its
> directors or officers unless otherwise specifically stated. The Company is not
> responsible for any reliance placed on the information contained herein and
> excludes all liability.
> 
> SynApps Solutions Limited is a company registered in England & Wales. Company
> Registration No.: 04770224. VAT No.: 823778892