def collection_action_on_a_page(page, skip_till_key="0000"):
    collections = [row.doc for row in page]

    for coll_doc in collections:
        if coll_doc["_id"] > skip_till_key:        
         new_coll_object = collection.create_objects_from_collection_doc(coll_doc)
    print "just finished", coll_doc["_id"]
    return
Beispiel #2
0
def collection_action_on_a_page(page, skip_till_key="0000"):
    collections = [row.doc for row in page]

    for coll_doc in collections:
        if coll_doc["_id"] > skip_till_key:
            new_coll_object = collection.create_objects_from_collection_doc(
                coll_doc)
    print "just finished", coll_doc["_id"]
    return
    def create_test_collection(self):
        test_collection = {"_id": "testcollectionid", 
                            "title": "mycollection", 
                            "type":"collection", 
                            "created":  "2012-08-23T14:40:16.888800", 
                            "last_modified":  "2012-08-23T14:40:16.888800", 
                            "alias_tiids": {
                                       "pmid:16023720": "iaw9rzldigp4xc7p20bycnkg",
                                       "pmid:16413797": "itsq6fgx8ogi9ixysbipmtxx"}}
        test_object = collection.create_objects_from_collection_doc(test_collection) 
        db.session.add(test_object) 

        biblio1 = {
               "journal": "The Astrophysical Journal",
               "authors": "Kwok, Purton, Fitzgerald",
               "year": "1978",
               "title": "On the origin of planetary nebulae"
           }
        biblio2 = {
               "journal": "The Astrophysical Journal 2",
               "authors": "Kwok, Purton, Fitzgerald",
               "year": "1900",
               "title": "On the origin of planetary nebulae The Sequel"
           }
        metrics1 = {
           "mendeley:readers": {
               "provenance_url": "http://www.mendeley.com/research/origin-planetary-nebulae/",
               "values": {
                   "raw_history": {
                       "2013-06-22T20:41:03.178277": 4,
                       "2013-01-15T22:21:55.253826": 3,
                       "2013-07-24T17:59:26.817504": 4,
                       "2013-07-24T18:04:41.035841": 9,
                   },
                   "raw": 9
               }
           },
           "mendeley:discipline": {
               "provenance_url": "http://www.mendeley.com/research/origin-planetary-nebulae/",
               "values": {
                   "raw_history": {
                       "2013-06-22T23:03:15.852461": [
                           {
                               "name": "Astronomy / Astrophysics / Space Science",
                               "value": 100,
                               "id": 2
                           }
                       ]
                    }
                }
            }
        }
        metrics2 = {
           "topsy:tweets": {
               "provenance_url": "http://topsydrilldown",
               "values": {
                   "raw_history": {
                       "2013-11-22T20:41:03.178277": 22
                   },
                   "raw": 22
                }
            }
        }

        test_item_docs = [
            {"_id": "iaw9rzldigp4xc7p20bycnkg", "type":"item", "created": "2012-08-23T14:40:16.888800", "last_modified": "2012-08-23T14:40:16.888800", "biblio":biblio1, "metrics":metrics1, "aliases":{"pmid": ["16023720"]}},
            {"_id": "itsq6fgx8ogi9ixysbipmtxx", "type":"item", "created": "2012-08-23T14:40:16.888800", "last_modified": "2012-08-23T14:40:16.888800", "biblio":biblio2, "metrics":metrics2, "aliases":{"pmid": ["16413797"]}}
        ]

        for item_doc in test_item_docs:
            test_object = item_module.create_objects_from_item_doc(item_doc) 
            db.session.add(test_object) 

        db.session.commit() 
Beispiel #4
0
    def create_test_collection(self):
        test_collection = {
            "_id": "testcollectionid",
            "title": "mycollection",
            "type": "collection",
            "created": "2012-08-23T14:40:16.888800",
            "last_modified": "2012-08-23T14:40:16.888800",
            "alias_tiids": {
                "pmid:16023720": "iaw9rzldigp4xc7p20bycnkg",
                "pmid:16413797": "itsq6fgx8ogi9ixysbipmtxx"
            }
        }
        test_object = collection.create_objects_from_collection_doc(
            test_collection)
        db.session.add(test_object)

        biblio1 = {
            "journal": "The Astrophysical Journal",
            "authors": "Kwok, Purton, Fitzgerald",
            "year": "1978",
            "title": "On the origin of planetary nebulae"
        }
        biblio2 = {
            "journal": "The Astrophysical Journal 2",
            "authors": "Kwok, Purton, Fitzgerald",
            "year": "1900",
            "title": "On the origin of planetary nebulae The Sequel"
        }
        metrics1 = {
            "mendeley:readers": {
                "provenance_url":
                "http://www.mendeley.com/research/origin-planetary-nebulae/",
                "values": {
                    "raw_history": {
                        "2013-06-22T20:41:03.178277": 4,
                        "2013-01-15T22:21:55.253826": 3,
                        "2013-07-24T17:59:26.817504": 4,
                        "2013-07-24T18:04:41.035841": 9,
                    },
                    "raw": 9
                }
            },
            "mendeley:discipline": {
                "provenance_url":
                "http://www.mendeley.com/research/origin-planetary-nebulae/",
                "values": {
                    "raw_history": {
                        "2013-06-22T23:03:15.852461": [{
                            "name": "Astronomy / Astrophysics / Space Science",
                            "value": 100,
                            "id": 2
                        }]
                    }
                }
            }
        }
        metrics2 = {
            "topsy:tweets": {
                "provenance_url": "http://topsydrilldown",
                "values": {
                    "raw_history": {
                        "2013-11-22T20:41:03.178277": 22
                    },
                    "raw": 22
                }
            }
        }

        test_item_docs = [{
            "_id": "iaw9rzldigp4xc7p20bycnkg",
            "type": "item",
            "created": "2012-08-23T14:40:16.888800",
            "last_modified": "2012-08-23T14:40:16.888800",
            "biblio": biblio1,
            "metrics": metrics1,
            "aliases": {
                "pmid": ["16023720"]
            }
        }, {
            "_id": "itsq6fgx8ogi9ixysbipmtxx",
            "type": "item",
            "created": "2012-08-23T14:40:16.888800",
            "last_modified": "2012-08-23T14:40:16.888800",
            "biblio": biblio2,
            "metrics": metrics2,
            "aliases": {
                "pmid": ["16413797"]
            }
        }]

        for item_doc in test_item_docs:
            test_object = item_module.create_objects_from_item_doc(item_doc)
            db.session.add(test_object)

        db.session.commit()