Exemple #1
0
 def loadSuboperations(self):
   print('Importing suboperations...')
   cnt = 0
   starttime = time()
   self.cursor.execute('''
     SELECT operation_id, suboperation_id, priority, effective_start, effective_end,
       (select type
        from operation
        where suboperation.operation_id = operation.name) as type
     FROM suboperation
     WHERE priority >= 0 %s
     ORDER BY operation_id, priority
     ''' % self.filter_and)
   curopername = None
   for i in self.cursor.fetchall():
     cnt += 1
     try:
       if i[0] != curopername:
         curopername = i[0]
         curoper = frepple.operation(name=curopername)
       sub = frepple.suboperation(
         owner=curoper,
         operation=frepple.operation(name=i[1]),
         priority=i[2]
         )
       if i[3]:
         sub.effective_start = i[3]
       if i[4]:
         sub.effective_end = i[4]
     except Exception as e:
       print("Error:", e)
   print('Loaded %d suboperations in %.2f seconds' % (cnt, time() - starttime))
Exemple #2
0
 def loadSuboperations(self):
   print('Importing suboperations...')
   cnt = 0
   starttime = time()
   self.cursor.execute('''
     SELECT operation_id, suboperation_id, priority, effective_start, effective_end,
       (select type
        from operation
        where suboperation.operation_id = operation.name) as type
     FROM suboperation
     WHERE priority >= 0 %s
     ORDER BY operation_id, priority
     ''' % self.filter_and)
   curopername = None
   for i in self.cursor.fetchall():
     cnt += 1
     try:
       if i[0] != curopername:
         curopername = i[0]
         curoper = frepple.operation(name=curopername)
       sub = frepple.suboperation(
         owner=curoper,
         operation=frepple.operation(name=i[1]),
         priority=i[2]
         )
       if i[3]:
         sub.effective_start = i[3]
       if i[4]:
         sub.effective_end = i[4]
     except Exception as e:
       print("Error:", e)
   print('Loaded %d suboperations in %.2f seconds' % (cnt, time() - starttime))
Exemple #3
0
  def run(cls, database=DEFAULT_DB_ALIAS, **kwargs):
    import frepple

    if cls.filter:
      filter_and = "and %s " % cls.filter
      filter_where = "where %s " % cls.filter
    else:
      filter_and = ""
      filter_where = ""

    with connections[database].chunked_cursor() as cursor:
      cnt = 0
      starttime = time()
      cursor.execute('''
        SELECT operation_id, suboperation_id, priority, effective_start, effective_end,
          (SELECT type
           from operation
           where suboperation.operation_id = operation.name) as type
        FROM suboperation
        WHERE priority >= 0 %s
        ORDER BY operation_id, priority
        ''' % filter_and)
      curopername = None
      for i in cursor:
        cnt += 1
        try:
          if i[0] != curopername:
            curopername = i[0]
            curoper = frepple.operation(name=curopername)
          sub = frepple.suboperation(
            owner=curoper,
            operation=frepple.operation(name=i[1]),
            priority=i[2]
            )
          if i[3]:
            sub.effective_start = i[3]
          if i[4]:
            sub.effective_end = i[4]
        except Exception as e:
          logger.error("**** %s ****" % e)
      logger.info('Loaded %d suboperations in %.2f seconds' % (cnt, time() - starttime))
Exemple #4
0

###
print("\nUpdating global settings")
frepple.settings.name = "demo model"
frepple.settings.description = "unicode А Б В Г Д Е Ё Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Ъ Ы Ь"
frepple.settings.current = datetime.datetime(2009,1,1)

###
print("\nCreating operations")
shipoper = frepple.operation_fixed_time(name="delivery end item", duration=86400)
choice = frepple.operation_alternate(name="make or buy item")
makeoper = frepple.operation_routing(name="make item")
frepple.suboperation(
  owner = makeoper,
  operation = frepple.operation_fixed_time(name="make item - step 1", duration=4*86400),
  priority = 1
  )
frepple.suboperation(
  owner = makeoper,
  operation = frepple.operation_fixed_time(name="make item - step 2", duration=3*86400),
  priority = 2
  )
buyoper = frepple.operation_fixed_time(name="buy item", duration=86400)
frepple.suboperation(
  owner = choice,
  operation = makeoper,
  priority = 1
  )
frepple.suboperation(
  owner = choice,
Exemple #5
0

###
print("\nUpdating global settings")
frepple.settings.name = "demo model"
frepple.settings.description = "unicode А Б В Г Д Е Ё Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Ъ Ы Ь"
frepple.settings.current = datetime.datetime(2009, 1, 1)

###
print("\nCreating operations")
shipoper = frepple.operation_fixed_time(name="delivery end item",
                                        duration=86400)
choice = frepple.operation_alternate(name="make or buy item")
makeoper = frepple.operation_routing(name="make item")
frepple.suboperation(owner=makeoper,
                     operation=frepple.operation_fixed_time(
                         name="make item - step 1", duration=4 * 86400),
                     priority=1)
frepple.suboperation(owner=makeoper,
                     operation=frepple.operation_fixed_time(
                         name="make item - step 2", duration=3 * 86400),
                     priority=2)
buyoper = frepple.operation_fixed_time(name="buy item", duration=86400)
frepple.suboperation(owner=choice, operation=makeoper, priority=1)
frepple.suboperation(owner=choice, operation=buyoper, priority=2)

###
print("\nCreating calendars")
c = frepple.calendar(name="Cal1", default=4.56)
c.setValue(datetime.datetime(2009, 1, 1), datetime.datetime(2009, 3, 1), 1)
c.setValue(datetime.datetime(2009, 2, 1), datetime.datetime(2009, 5, 1), 2)
c.setValue(datetime.datetime(2009, 2, 1), datetime.datetime(2009, 3, 1), 3)