001: /*
002: * SalomeTMF is a Test Management Framework
003: * Copyright (C) 2005 France Telecom R&D
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: *
019: * @author Marche Mikael
020: *
021: * Contact: mikael.marche@rd.francetelecom.com
022: */
023:
024: package org.objectweb.salome_tmf.data;
025:
026: import org.objectweb.salome_tmf.api.Api;
027: import org.objectweb.salome_tmf.api.Util;
028: import org.objectweb.salome_tmf.api.data.AttachementWrapper;
029: import org.objectweb.salome_tmf.api.sql.ISQLAttachment;
030:
031: public abstract class Attachment extends SimpleData {
032:
033: transient static ISQLAttachment pISQLAttachment = null;
034: protected String localisation = null;
035:
036: public String getLocalisation() {
037: return localisation;
038: }
039:
040: public void setLocalisation(String string) {
041: Util.log("[Attachment->setLocalisation] change " + localisation
042: + ", by " + string + ", for " + name);
043: localisation = string;
044: }
045:
046: /**
047: * Create instance of Attachment
048: * @param name
049: * @param description
050: */
051: public Attachment(String name, String description) {
052: super (name, description);
053: if (pISQLAttachment == null) {
054: pISQLAttachment = Api.getISQLObjectFactory()
055: .getISQLAttachment();
056: }
057: }
058:
059: /**
060: * Create instance of Attachment with an AttachementWrapper
061: * @param pAttach
062: */
063: public Attachment(AttachementWrapper pAttach) {
064: super (pAttach.getName(), pAttach.getDescription());
065: setIdBdd(pAttach.getIdBDD());
066: if (pISQLAttachment == null) {
067: pISQLAttachment = Api.getISQLObjectFactory()
068: .getISQLAttachment();
069: }
070: }
071:
072: /*
073: * Set id of this data in BDD
074: */
075: public void setIdBdd(int id) {
076: super .setIdBdd(id);
077: }
078:
079: /**
080: * Update the description of the attachment in the model
081: * @param desc : the new description
082: */
083: /*public void updateDescriptionInModel(String desc){
084: description = desc;
085: }*/
086:
087: /**
088: * Update the description of the attachment in the database
089: * @param desc : the new description
090: * @throws Exception
091: * no permission needed
092: */
093: public void updateDescriptionInDB(String desc) throws Exception {
094: if (!isInBase()) {
095: throw new Exception("Attachment " + name + " is not in BDD");
096: }
097: pISQLAttachment.updateDescription(idBdd, desc);
098: }
099:
100: /**
101: * Update the description of the attachment in the database and model
102: * @param desc : the new description
103: * @throws Exception
104: * no permission needed
105: */
106: public void updateDescriptionInDBdAndModel(String desc)
107: throws Exception {
108: //BDD
109: updateDescriptionInDB(desc);
110: //Model
111: updateDescriptionInModel(desc);
112: }
113:
114: public void updateInDBAndModel(String newName, String newDesc)
115: throws Exception {
116: updateDescriptionInDB(newDesc);
117: updateDescriptionInModel(newDesc);
118: }
119:
120: public boolean existeInBase() throws Exception {
121: return isInBase();
122: }
123: }
|