Changeset 283


Ignore:
Timestamp:
Dec 17, 2009, 3:34:41 PM (10 years ago)
Author:
jjbot
Message:

Added saveItems method. Cleanups.

Location:
web
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • web/IbidasAtomicServices2.py

    r282 r283  
    11import logging
    22
     3
     4from container import table, scalar
     5from parsers import utils
    36from IbidasSimpleMessage import IbidasSimpleMessage
    47
     
    242245        return msg.finalize()
    243246
    244     def getSetContentBySourceName(self, name):
     247    def getSetContentBySourceName(self, args):
    245248        """Returns all the items and links associated with the
    246249        provided set_name."""
    247         setid = self.cd.set[_.name==name]()
    248         return self.getSetContentBySourceID(setid)
     250        setName = args['set_name']
     251        print setName
     252        #setName = setName[0]
     253        setid = self.cd.set[_.name==setName]()
     254        args[self.SETS] = [setid[0],]
     255        return self.getSetContentBySourceID(args)
    249256
    250257    def getSetContentBySourceID(self, args):
     
    298305        return msg.finalize()
    299306
     307    def saveItems(self, args):
     308        assert args.has_key('set_name'), "No set name provided."
     309        assert args.has_key('set_version'), "No set version provided."
     310        assert args.has_key('set_description'), "No set description provided."
     311        assert args.has_key('item_ids'), "No item ids provided."
     312
     313        ds_id = utils.resolveSet(self.cd, args['set_name'],
     314                args['set_version'], args['set_description'])
     315       
     316        item_ids = args['item_ids']
     317        t = table(item_ids, ('item_id',))
     318        # FIXME: should set and source id be different, does it even make sense
     319        # to have them both?
     320        t = t.select(_, scalar(ds_id) / 'source_id')
     321        t = t.select(_, scalar(ds_id) / 'set_id')
     322        # FIXME: what should the type_id be?
     323        t = t.select(_, scalar(0) / 'type_id')
     324        self.cd.item_prop_set.extend(t)
     325        self.cd.item_prop_set.flush()
     326        self.cd.commit()
     327
     328        out = {'message': 'it worked'}
     329        return out
     330
    300331    def testConnection(self):
    301332        return "It works!"
  • web/IbidasSimpleMessage.py

    r276 r283  
    2121    ITEMAC_STR      = 'itemaccessions'
    2222    ITEMAC_FN_STR   = 'itemaccession_fn'
    23     ITEMAC_FT_STR     = 'itemaccession_ft'
     23    ITEMAC_FT_STR   = 'itemaccession_ft'
    2424    ITEMLINK_STR    = 'itemlinks'
    2525    ITEMLINK_FN_STR = 'itemlink_fn'
     
    7171            self.items = cont
    7272
    73     def addItemaccessions(self, cont):
     73    def addItemAccessions(self, cont):
    7474        print "addItemaccessions called"
    7575        if not self.itemaccessions is None:
Note: See TracChangeset for help on using the changeset viewer.