Example #1
0
	def createWithoutCommit(self, objectVectorModel):
		cm = ConnectionManager.ConnectionManager('KappaBase')
		vDao = VectorDAO()
		vDao.createWithoutCommit(VectorModel(objectVectorModel.id, objectVectorModel.value, objectVectorModel.tagName))
		if(objectVectorModel.parent!=None) :
			res = cm.executeSQL("INSERT INTO Object_vector (id_vector, id_parent) VALUES (" + str(objectVectorModel.id) + ", " + str(objectVectorModel.parent.id) + ")")
		else :
			res = cm.executeSQL("INSERT INTO Object_vector (id_vector) VALUES (" + str(objectVectorModel.id) + ")")
Example #2
0
	def updateWithoutCommit(self, objectVectorModel):
		cm = ConnectionManager.ConnectionManager('KappaBase')
		vDao = VectorDAO()
		vDao.updateWithoutCommit(VectorModel(objectVectorModel.id, objectVectorModel.value, objectVectorModel.tagName))
		if(objectVectorModel.parent!=None) :
			cm.executeSQL("UPDATE Object_vector SET id_parent=" + str(objectVectorModel.parent.id)+ " WHERE id_vector=" + str(objectVectorModel.id))
		else :
			cm.executeSQL("UPDATE Object_vector SET id_parent=NULL WHERE id_vector=" + str(objectVectorModel.id))
Example #3
0
 def getAll(self):
     cm = ConnectionManager.ConnectionManager('KappaBase.db')
     res = cm.executeSQL("SELECT * FROM Vector NATURAL JOIN Face_vector")
     vectorList = []
     for elem in res:
         i = 0
         vectorList.append(
             FaceVectorModel(elem[0], elem[1], elem[2], elem[3]))
     return vectorList
Example #4
0
	def getByName(self, name):
		cm = ConnectionManager.ConnectionManager('KappaBase')
		res = cm.executeSQL("SELECT * FROM Vector NATURAL JOIN Object_vector WHERE tag_name=\"" + name + "\"")
		if (len(res)!=1) :
			return
		if(res[0][3]!=None) :
			res2 = ObjectVectorModel(res[0][0], res[0][1], res[0][2], self.getById(res[0][3]))
		else :
			res2 = ObjectVectorModel(res[0][0], res[0][1], res[0][2], None)
		return res2
Example #5
0
	def getById(self, id):
		cm = ConnectionManager.ConnectionManager('KappaBase')
		res = cm.executeSQL("SELECT * FROM Vector NATURAL JOIN Object_vector WHERE id_vector=" + str(id))
		if (len(res)!=1) :
			return
		if(res[0][3]!=None) :
			res2 = ObjectVectorModel(res[0][0], res[0][1], res[0][2], self.getById(res[0][3]))
		else :
			res2 = ObjectVectorModel(res[0][0], res[0][1], res[0][2], None)
		return res2
Example #6
0
	def getAll(self):
		cm = ConnectionManager.ConnectionManager('KappaBase')
		res = cm.executeSQL("SELECT * FROM Vector NATURAL JOIN Object_vector)")
		vectorList = []
		for elem in res:
			if(elem[3]!=None) :
				vectorList.append(ObjectVectorModel(elem[0], elem[1], elem[2], self.getById(elem[3])))
			else :
				vectorList.append(ObjectVectorModel(elem[0], elem[1], elem[2], None))
		return vectorList
Example #7
0
	def getByImageId(self, id):
		cm = ConnectionManager.ConnectionManager('KappaBase.db')
		res = cm.executeSQL("select * from Vector NATURAL JOIN OBJECT_VECTOR NATURAL JOIN INCLUDE where id_image = "+str(id)+";")
		vectorList = []
		for elem in res:
			if(elem[3]!=None) :
				vectorList.append(ObjectVectorModel(elem[0], elem[1], elem[2], self.getById(elem[3])))
			else :
				vectorList.append(ObjectVectorModel(elem[0], elem[1], elem[2], None))
		return vectorList
Example #8
0
 def create(self, imgModel):
     cm = ConnectionManager.ConnectionManager('KappaBase.db')
     res = cm.executeAndCommitSQL(
         "INSERT INTO Image (id_image, comment,creation_date,length,width,size,path)"
         + "VALUES (" + str(imgModel.id) + ", \"" + imgModel.comment +
         "\", \"" + imgModel.creation_date + "\", " + str(imgModel.length) +
         "," + str(imgModel.width) + "," + str(imgModel.size) + ",\"" +
         imgModel.path + "\")")
     if (imgModel.objectVectors == None):
         return
     for ov in imgModel.objectVectors:
         self.linkToVector(imgModel, ov)
Example #9
0
 def getByImageQuery(self, imageQuery):
     cm = ConnectionManager.ConnectionManager('KappaBase.db')
     res = cm.executeSQL(self.convertImageQueryToSQL(imageQuery))
     oVectDao = ObjectVectorDAO()
     fVectDao = FaceVectorDAO()
     imageList = []
     for elem in res:
         imageList.append(
             ImageModel(elem[0], elem[1], elem[2], elem[3], elem[4],
                        elem[5], elem[6], fVectDao.getByImageId(elem[0]),
                        oVectDao.getByImageId(elem[0])))
     return imageList
Example #10
0
 def getAll(self):
     cm = ConnectionManager.ConnectionManager('KappaBase.db')
     res = cm.executeSQL("SELECT * FROM Image")
     oVectDao = ObjectVectorDAO()
     fVectDao = FaceVectorDAO()
     imageList = []
     for elem in res:
         imageList.append(
             ImageModel(elem[0], elem[1], elem[2], elem[3], elem[4],
                        elem[5], elem[6], fVectDao.getByImageId(elem[0]),
                        oVectDao.getByImageId(elem[0])))
     return imageList
Example #11
0
	def importObjectVectors(self, tagItems):
		cm = ConnectionManager.ConnectionManager('KappaBase')

		for vector, tags_and_parent in tagItems:
			#exemple :
			#vector          => 'n07877187'
			#tags_and_parent => ('spaghetti and meatballs', 'n07557434')

			vChild = self.getByValue(vector)

			if (vChild!=None) :
				vChild.value = vector
				vChild.tagName = tags_and_parent[0]
				if(tags_and_parent[1]==None) :
					vChild.parent = None
				else :
					vParent = self.getByValue(tags_and_parent[1])
					if(vParent!=None) :
						vChild.parent = vParent
					else :
						nextId=self.getNextId()
						vParent = ObjectVectorModel(nextId, tags_and_parent[1], "", None)
						vChild.parent = vParent
						self.createWithoutCommit(vParent)
				self.updateWithoutCommit(vChild)
			else :
				nextId=self.getNextId()
				vChild = ObjectVectorModel(nextId, vector, tags_and_parent[0], None)
				if(tags_and_parent[1]==None) :
					vChild.parent = None
				else :
					vParent = self.getByValue(tags_and_parent[1])
					if(vParent!=None) :
						vChild.parent = vParent
					else :
						vParent = ObjectVectorModel(nextId+1, tags_and_parent[1], "", None)
						vChild.parent = vParent
						self.createWithoutCommit(vParent)
				self.createWithoutCommit(vChild)

		cm.executeAndCommitSQL("SELECT MAX(id_vector) FROM Vector")
Example #12
0
 def linkToVector(self, imgModel, vector):
     cm = ConnectionManager.ConnectionManager('KappaBase.db')
     res = cm.executeAndCommitSQL(
         "INSERT INTO Include (id_image, id_vector) VALUES (" +
         str(imgModel.id) + "," + str(vector.id) + ")")
Example #13
0
 def getById(self, id):
     cm = ConnectionManager.ConnectionManager('KappaBase.db')
     res = cm.executeSQL("SELECT * FROM Image where id_image =" + id + ";")
     return res