Esempio n. 1
0
 def base_create_dep_objs(cls):
     """
     Create all objects that Files depend on.
     """
     trans = Transactions()
     TestTransactions.base_create_dep_objs()
     trans.from_hash(SAMPLE_TRANSACTION_HASH)
     trans.save(force_insert=True)
Esempio n. 2
0
 def from_hash(self, obj):
     """
     Converts the hash to an object
     """
     super(Files, self).from_hash(obj)
     if '_id' in obj:
         # pylint: disable=invalid-name
         self.id = int(obj['_id'])
         # pylint: enable=invalid-name
     if 'name' in obj:
         self.name = unicode(obj['name'])
     if 'subdir' in obj:
         self.subdir = unicode(obj['subdir'])
     if 'mimetype' in obj:
         self.mimetype = str(obj['mimetype'])
     if 'ctime' in obj:
         self.ctime = datetime.fromtimestamp(int(obj['ctime']))
     if 'mtime' in obj:
         self.mtime = datetime.fromtimestamp(int(obj['mtime']))
     if 'size' in obj:
         self.size = int(obj['size'])
     if 'transaction_id' in obj:
         self.transaction = Transactions.get(
             Transactions.id == obj['transaction_id']
         )
     if 'encoding' in obj:
         self.encoding = str(obj['encoding'])
 def base_create_dep_objs(cls):
     """
     Create all objects that TransactionKeyValue need.
     """
     trans = Transactions()
     keys = Keys()
     values = Values()
     TestTransactions.base_create_dep_objs()
     trans.from_hash(SAMPLE_TRANSACTION_HASH)
     trans.save(force_insert=True)
     TestKeys.base_create_dep_objs()
     keys.from_hash(SAMPLE_KEY_HASH)
     keys.save(force_insert=True)
     TestValues.base_create_dep_objs()
     values.from_hash(SAMPLE_VALUE_HASH)
     values.save(force_insert=True)
 def from_hash(self, obj):
     """Convert the hash into the object."""
     super(AToolTransaction, self).from_hash(obj)
     if 'analytical_tool_id' in obj:
         self.analytical_tool = AnalyticalTools.get(
             AnalyticalTools.id == obj['analytical_tool_id'])
     if 'transaction_id' in obj:
         self.transaction = Transactions.get(
             Transactions.id == obj['transaction_id'])
 def from_hash(self, obj):
     """Convert the hash into the object."""
     super(TransactionKeyValue, self).from_hash(obj)
     if 'transaction_id' in obj:
         self.transaction = Transactions.get(Transactions.id == obj['transaction_id'])
     if 'value_id' in obj:
         self.value = Values.get(Values.id == obj['value_id'])
     if 'key_id' in obj:
         self.key = Keys.get(Keys.id == obj['key_id'])
 def from_hash(self, obj):
     """
     Converts the hash into the object
     """
     super(TransactionKeyValue, self).from_hash(obj)
     if 'transaction_id' in obj:
         self.transaction = Transactions.get(Transactions.id == obj['transaction_id'])
     if 'value_id' in obj:
         self.value = Values.get(Values.id == obj['value_id'])
     if 'key_id' in obj:
         self.key = Keys.get(Keys.id == obj['key_id'])
Esempio n. 7
0
 def where_clause(self, kwargs):
     """PeeWee specific where expression."""
     where_clause = super(Files, self).where_clause(kwargs)
     if 'transaction_id' in kwargs:
         trans = Transactions.get(
             Transactions.id == kwargs['transaction_id'])
         where_clause &= Expression(Files.transaction, OP.EQ, trans)
     if '_id' in kwargs:
         where_clause &= Expression(Files.id, OP.EQ, kwargs['_id'])
     where_clause = self._where_date_clause(where_clause, kwargs)
     where_clause = self._where_attr_clause(where_clause, kwargs)
     return where_clause
 def where_clause(self, kwargs):
     """Where clause for the various elements."""
     where_clause = super(TransactionKeyValue, self).where_clause(kwargs)
     if 'transaction_id' in kwargs:
         trans = Transactions.get(Transactions.id == kwargs['transaction_id'])
         where_clause &= Expression(TransactionKeyValue.transaction, OP.EQ, trans)
     if 'key_id' in kwargs:
         key = Keys.get(Keys.id == kwargs['key_id'])
         where_clause &= Expression(TransactionKeyValue.key, OP.EQ, key)
     if 'value_id' in kwargs:
         value = Values.get(Values.id == kwargs['value_id'])
         where_clause &= Expression(TransactionKeyValue.value, OP.EQ, value)
     return where_clause
 def where_clause(self, kwargs):
     """Where clause for the various elements."""
     where_clause = super(AToolTransaction, self).where_clause(kwargs)
     if 'analytical_tool_id' in kwargs:
         atool = AnalyticalTools.get(
             AnalyticalTools.id == kwargs['analytical_tool_id'])
         where_clause &= Expression(AToolTransaction.analytical_tool, OP.EQ,
                                    atool)
     if 'transaction_id' in kwargs:
         trans = Transactions.get(
             Transactions.id == kwargs['transaction_id'])
         where_clause &= Expression(AToolTransaction.transaction, OP.EQ,
                                    trans)
     return where_clause
 def where_clause(self, kwargs):
     """
     Where clause for the various elements.
     """
     where_clause = super(TransactionKeyValue, self).where_clause(kwargs)
     if 'transaction_id' in kwargs:
         trans = Transactions.get(Transactions.id == kwargs['transaction_id'])
         where_clause &= Expression(TransactionKeyValue.transaction, OP.EQ, trans)
     if 'key_id' in kwargs:
         key = Keys.get(Keys.id == kwargs['key_id'])
         where_clause &= Expression(TransactionKeyValue.key, OP.EQ, key)
     if 'value_id' in kwargs:
         value = Values.get(Values.id == kwargs['value_id'])
         where_clause &= Expression(TransactionKeyValue.value, OP.EQ, value)
     return where_clause
 def base_create_dep_objs(cls):
     """Create all objects that TransactionKeyValue need."""
     trans = Transactions()
     tool = AnalyticalTools()
     TestTransactions.base_create_dep_objs()
     trans.from_hash(SAMPLE_TRANSACTION_HASH)
     trans.save(force_insert=True)
     TestAnalyticalTools.base_create_dep_objs()
     tool.from_hash(SAMPLE_TOOL_HASH)
     tool.save(force_insert=True)
Esempio n. 12
0
 def where_clause(self, kwargs):
     """
     PeeWee specific extension meant to be passed to a PeeWee get
     or select.
     """
     where_clause = super(Files, self).where_clause(kwargs)
     for date in ['mtime', 'ctime']:
         if date in kwargs:
             kwargs[date] = datetime.fromtimestamp(kwargs[date])
     if 'transaction_id' in kwargs:
         kwargs['transaction_id'] = Transactions.get(
             Transactions.id == kwargs['transaction_id']
         )
     if '_id' in kwargs:
         where_clause &= Expression(Files.id, OP.EQ, kwargs['_id'])
     for key in ['name', 'subdir', 'mimetype', 'size', 'mtime', 'ctime', 'encoding']:
         if key in kwargs:
             where_clause &= Expression(getattr(Files, key), OP.EQ, kwargs[key])
     return where_clause
Esempio n. 13
0
 def base_create_dep_objs(cls):
     """Create all objects that TransactionKeyValue need."""
     trans = Transactions()
     keys = Keys()
     values = Values()
     TestTransactions.base_create_dep_objs()
     trans.from_hash(SAMPLE_TRANSACTION_HASH)
     trans.save(force_insert=True)
     TestKeys.base_create_dep_objs()
     keys.from_hash(SAMPLE_KEY_HASH)
     keys.save(force_insert=True)
     TestValues.base_create_dep_objs()
     values.from_hash(SAMPLE_VALUE_HASH)
     values.save(force_insert=True)
Esempio n. 14
0
 def base_create_dep_objs(cls):
     """Create all objects that Files depend on."""
     trans = Transactions()
     TestTransactions.base_create_dep_objs()
     trans.from_hash(SAMPLE_TRANSACTION_HASH)
     trans.save(force_insert=True)
Esempio n. 15
0
 def trans_func():
     """Return the transaction for the obj id."""
     return Transactions.get(Transactions.id == obj['transaction_id'])