ORCentral
|
00001 package eu.coform.database.command; 00002 00003 import eu.coform.Filestruct; 00004 import eu.coform.UniqueID; 00005 import eu.coform.database.DBException; 00006 import eu.coform.database.Database; 00007 import eu.coform.database.Query; 00008 00012 public class InsertFileDBCommand implements DatabaseCommand { 00013 00014 private Filestruct file = null; 00015 private int userId; 00016 00017 public InsertFileDBCommand(Filestruct file, int userId){ 00018 this.file = file; 00019 this.userId = userId; 00020 } 00026 @Override 00027 public void exec() throws DBException { 00028 UniqueID uid = file.getFilestructID(); 00029 00030 IntIDDBCommand intcom = new IntIDDBCommand(uid); 00031 intcom.exec(); 00032 int intid = intcom.getResult(); 00033 00034 Query query = Database.getInstance().getNewQuery(); 00035 query.setQuery("INSERT INTO file(ID,FileName,Size,checksum," + 00036 "Mimetype,Status,CreationDate,CreationUserID)VALUES(" + 00037 "'" + intid +"',"+ 00038 "'" + file.getFilename() +"',"+ 00039 "'" + file.getSize() +"',"+ 00040 "UNHEX('" + file.getM_Md5sum().toBin16() +"'),"+ 00041 "'" + file.getMimetype() +"',"+ 00042 "'" + file.getStatus() +"',"+ 00043 "FROM_UNIXTIME('" + file.getCreationDate().getDatetime() +"')," + 00044 "'" + userId +"')"); 00045 //System.out.println(query.toString()); 00046 Database.getInstance().insert(query); 00047 00048 } 00049 00050 }