String value = (yesno) ? "1":"0";
String sql = "update content set is_produced='" + value + "' where id='" + getId()+"'";
try {
- con = theStorageObject.getPooledCon();
- /** @todo should be preparedStatement: faster!! */
- stmt = con.createStatement();
- theStorageObject.executeUpdate(stmt,sql);
+ con = theStorageObject.getPooledCon();
+ /** @todo should be preparedStatement: faster!! */
+ stmt = con.createStatement();
+ theStorageObject.executeUpdate(stmt,sql);
} catch (StorageObjectException e) {
theLog.printDebugInfo(e.toString() + "\n -- set produced failed");
} catch (SQLException e) {
* dettach from media
*/
- public void dettach()
+ public void dettach(String cid,String mid)
{
- String sql = "update content set to_media=null, is_produced='0' where id='" + getId()+"'";
- try {
- theStorageObject.executeUpdate(sql);
- } catch (StorageObjectException e) {
- theLog.printError(e.toString() + "dettach failed");
- } catch (SQLException e) {
- theLog.printError(e.toString() + "dettach failed");
+ if (mid!=null){
+ try{
+ DatabaseContentToMedia.getInstance().delete(cid,mid);
+ } catch (Exception e){
+ theLog.printError("failed to get instance");
+ }
+ //set Content to unproduced
+ setProduced(false);
}
}
public void attach(String mid)
{
if (mid!=null) {
- String sql = "update content set to_media='" + mid + "', is_produced='0' where id='" + getId()+"'";
- try {
- theStorageObject.executeUpdate(sql);
- } catch (StorageObjectException e) {
- theLog.printError(e.toString() + "attach failed");
- } catch (SQLException e) {
- theLog.printError(e.toString() + "attach failed");
+ //write media-id mid and content-id in table content_x_media
+ try{
+ DatabaseContentToMedia.getInstance().addMedia(getId(),mid);
+ } catch(StorageObjectException e){
+ theLog.printError("attach: could not get the instance");
}
- }
- else
+ //set Content to unproduced
+ setProduced(false);
+ } else {
theLog.printError("EntityContent: attach without mid");
+ }
}
/**