[Cubicweb] Error while defining a relation

Dominique GEFFROY dominique.geffroy at cea.fr
Thu Jul 7 16:29:38 CEST 2011


Thank you for the explanations.
I finally succeeded in doing what I wanted, creating a new Entity type 
FileName that I used as the object of the relation.

Dominique

Sylvain Thénault a écrit :
> On 07 juillet 15:32, Dominique GEFFROY wrote:
>   
>> In fact, what I really wanted to do is to add this relation has_file
>> to all the entity type of my schema that all derive from the same
>> entity type.
>> Let's say I have a parent entity type class A and several entity
>> type class B, C, etc that all derive directly or not from class A.
>> I first tried to to give A as the subject of the relation but then I
>> got an error when I tried to add this relation to an entity of type
>> B for example. The error was about incompatible types and I supposed
>> that the relation was not inherited in the subclasses of A. That's
>> why I used "*" to add the relation to all the entity types, I don't
>> know if there is a better way to do so ?
>>     
>
> if you define this relation in class A (using SubjectRelation),
> then all subclasses will have it.
> Else, you can also explicitly list all entity types that should
> have it as 'subject'
>  
>   
>> Anyway, I thought I had to define at least the cardinality of the
>> relation because it is "*" ( each entity can have several has_file
>> relations) and it seems that the default cardinality is "1". I
>> actually tried to define the relation with only subject and object
>> attributes but then I got entities with only one has_file
>> relation... And when I add the cardinality attribute in the
>> relation, I have the reported error about the composite attribute...
>>
>> Does it mean that I should create an entity for the object of the
>> relation ? If a relation with String as object is automatically an
>> attribute relation, maybe it is not possible to have a cardinality
>> different from 1 in such relation ?
>>     
>
> yep, attribute relations can only have ? or 1 cardinality. We should
> have an error when trying to do otherwise. When you want multiple
> values, you currently have to define an entity type.
>   
>   

-- 

Dominique Geffroy - IFR49

CEA/SAC/DSV/I2BM/NeuroSpin
Bât 145, Point Courrier 156
91191 GIF/YVETTE, FRANCE
Tel +33 (0) 1 69 08 94 80
Fax +33 (0) 1 69 08 78 55
 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubicweb.org/pipermail/cubicweb/attachments/20110707/5cc420bb/attachment-0127.html>


More information about the Cubicweb mailing list