def __init__(self):
Script.__init__(self)
self.calls = []
- self.loaded = False
self.data_mgr = None
- self.bibs = []
- self.copies = []
- self.call_numbers = []
- self.org_unis = []
-
-
- '''
- def _fetch_dynamic_data(self):
- pcrud = 'open-ils.pcrud'
- method = 'open-ils.pcrud.search.%s.atomic'
-
- auth = eg_utils.authtoken()
- thread_count = props.get_property('constrictor.numThreads')
-
- self.bibs = BatchMethodTask(pcrud, method % 'bre').start(
- params = [auth, {'deleted' : 'f', 'id' : {'>' : 0}}, {'limit' : thread_count}])
-
- self.copies = BatchMethodTask(pcrud, method % 'acp').start(
- params = [auth, {'deleted' : 'f', 'id' : {'>' : 0}}, {'limit' : thread_count}])
-
- self.call_numbers = BatchMethodTask(pcrud, method % 'acn').start(
- params = [auth, {'deleted' : 'f', 'id' : {'>' : 0}}, {'limit' : thread_count}])
-
- self.org_units = BatchMethodTask(pcrud, method % 'aou').start(
- params = [auth, {'id' : {'>' : 0}}, {'limit' : thread_count}])
-
- self.data_mgr.insert_prop_data(eg_data.PROP_TITLE_ID, [obj.id() for obj in self.bibs])
- self.data_mgr.insert_prop_data(eg_data.PROP_COPY_ID, [obj.id() for obj in self.copies])
- self.data_mgr.insert_prop_data(eg_data.PROP_COPY_BARCODE, [obj.barcode() for obj in self.copies])
- self.data_mgr.insert_prop_data(eg_data.PROP_CALLNUMBER_ID, [obj.id() for obj in self.call_numbers])
- self.data_mgr.insert_prop_data(eg_data.PROP_ORG_ID, [obj.id() for obj in self.org_units])
- self.data_mgr.insert_prop_data(eg_data.PROP_ORG_SHORTNAME, [obj.shortname() for obj in self.org_units])
- '''
def load_file(self):
def run(self):
- if not self.loaded:
- self.load_file()
-
for idx in range(0, len(self.calls)):
call = self.calls[int(random.random() * len(self.calls))]
try:
-ScriptManager.go(BatchScript())
+script = BatchScript()
+script.load_file() # load the batch API file
+ScriptManager.go(script)
auth = eg_utils.authtoken()
thread_count = self.props.get_property('constrictor.numThreads')
- bibs = DataMethodTask(pcrud, method % 'bre').start(
- params = [auth, {'deleted' : 'f', 'id' : {'>' : 0}}, {'limit' : thread_count}])
+ if not self.data.get(PROP_TITLE_ID):
- copies = DataMethodTask(pcrud, method % 'acp').start(
- params = [auth, {'deleted' : 'f', 'id' : {'>' : 0}}, {'limit' : thread_count}])
+ bibs = DataMethodTask(pcrud, method % 'bre').start(
+ params = [auth, {'deleted' : 'f', 'id' : {'>' : 0}}, {'limit' : thread_count}])
- call_numbers = DataMethodTask(pcrud, method % 'acn').start(
- params = [auth, {'deleted' : 'f', 'id' : {'>' : 0}}, {'limit' : thread_count}])
+ self.insert_prop_data(PROP_TITLE_ID, [obj.id() for obj in bibs])
- org_units = DataMethodTask(pcrud, method % 'aou').start(
- params = [auth, {'id' : {'>' : 0}}, {'limit' : thread_count}])
+ if not self.data.get(PROP_COPY_ID) or not self.data.get(PROP_COPY_BARCODE):
- self.insert_prop_data(PROP_TITLE_ID, [obj.id() for obj in bibs])
- self.insert_prop_data(PROP_COPY_ID, [obj.id() for obj in copies])
- self.insert_prop_data(PROP_COPY_BARCODE, [obj.barcode() for obj in copies])
- self.insert_prop_data(PROP_CALLNUMBER_ID, [obj.id() for obj in call_numbers])
- self.insert_prop_data(PROP_ORG_ID, [obj.id() for obj in org_units])
- self.insert_prop_data(PROP_ORG_SHORTNAME, [obj.shortname() for obj in org_units])
+ copies = DataMethodTask(pcrud, method % 'acp').start(
+ params = [auth, {'deleted' : 'f', 'id' : {'>' : 0}}, {'limit' : thread_count}])
+
+ if not self.data.get(PROP_COPY_ID):
+ self.insert_prop_data(PROP_COPY_ID, [obj.id() for obj in copies])
+
+ if not self.data.get(PROP_COPY_BARCODE):
+ self.insert_prop_data(PROP_COPY_BARCODE, [obj.barcode() for obj in copies])
+
+ if not self.data.get(PROP_CALLNUMBER_ID):
+
+ call_numbers = DataMethodTask(pcrud, method % 'acn').start(
+ params = [auth, {'deleted' : 'f', 'id' : {'>' : 0}}, {'limit' : thread_count}])
+
+ self.insert_prop_data(PROP_CALLNUMBER_ID, [obj.id() for obj in call_numbers])
+
+ if not self.data.get(PROP_ORG_ID) or not self.data.get(PROP_ORG_SHORTNAME):
+
+ org_units = DataMethodTask(pcrud, method % 'aou').start(
+ params = [auth, {'id' : {'>' : 0}}, {'limit' : thread_count}])
+
+ if not self.data.get(PROP_ORG_ID):
+ self.insert_prop_data(PROP_ORG_ID, [obj.id() for obj in org_units])
+
+ if not self.data.get(PROP_ORG_SHORTNAME):
+
+ self.insert_prop_data(PROP_ORG_SHORTNAME, [obj.shortname() for obj in org_units])
def __str__(self):