Skip to content
  • Marek Szuba's avatar
    RNAProduct: implement synchronise_attributes() · b1c97544
    Marek Szuba authored
    Properties of specific types of mature RNA products such as microRNAs
    are stored in the database as attributes (so that we needn't add
    type-specific columns to the rnaproduct table) but have shorthand
    accessors such as MicroRNA::arm() backed by cache member variables
    in the API (for convenience and speed). In order for this to work
    properly we have to push possible changes to the cache variables back
    to attributes before they are stored in the database - which is what
    this method does.
    
    The synchronisation code itself is generic and has been implemented
    in the superclass. Specialisation is handled by class-specific mappings
    between member names and respective Attribute codes, provided
    by RNAProductTypeMapper.
    
    Limitations:
     - at present there can only be either zero or one target attribute;
       having many attributes with the same code results in an exception
       because we do not know which one(s) to update. In the future we might
       have to extend the mapping syntax to support multiple attributes, for
       now however (i.e. for microRNA arms) we do not need it;
     - chances are things will break badly if we fetch a MicroRNA object
       from the database, change the arm and push it back. Right now this is
       not a problem because RNAProducts do not support database updates at
       all, then again should we want to support them we will have to check
       how AttributeAdaptor handles updates of existing objects (as well as
       the same for DBEntryAdaptor, as a matter of fact).
    b1c97544