ORCentral

src/eu/coform/database/command/InsertMimetypeCommand.java

Go to the documentation of this file.
00001 package eu.coform.database.command;
00002    
00003 import eu.coform.Mimetype;
00004 import eu.coform.database.DBException;
00005 import eu.coform.database.Database;
00006 import eu.coform.database.Query;
00007 
00011 public class InsertMimetypeCommand implements ResultDatabaseCommand {
00012 
00013    private Mimetype m_mimetype;
00014    private Integer m_result;
00015    
00016    public InsertMimetypeCommand(Mimetype mimetype) {
00017       setMimetype(mimetype);
00018    }
00024    @Override
00025    public void exec() throws DBException {
00026       NextIdCommand c = new NextIdCommand("ID", "mimetype");
00027       c.exec();
00028       m_mimetype.setMimetypeID(c.getResult().intValue());
00029       
00030       Query query = Database.getInstance().getNewQuery();     
00031       query.setQuery("INSERT INTO mimetype ('ID', 'Name', 'Extension', 'URI', 'Description') " +
00032             "VALUES ('" + m_mimetype.getMimetypeID() + "', '" + m_mimetype.getName() + "', '"
00033                         + m_mimetype.getExtension()  + "', '" + m_mimetype.getUri() + "', '"
00034                         + m_mimetype.getDescription() + "');");
00035       Database.getInstance().insert(query);
00036    }
00037 
00038    public void setMimetype(Mimetype m_mimetype) {
00039       this.m_mimetype = m_mimetype;
00040    }
00041 
00042    public Mimetype getMimetype() {
00043       return m_mimetype;
00044    }
00045 
00046    @Override
00047    public Integer getResult() {
00048       return m_result;
00049    }
00050 
00051 }
 All Classes Namespaces Files Functions Variables Enumerations