Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

SyncActionDBManager.java

00001 /*
00002  * OpenMobileIS - a free Java(TM) Framework for mobile applications Java(TM)
00003  * Copyright (C) 2004-2005 Philippe Delrieu
00004  * All rights reserved.
00005  * Contact: openmobileis@e-care.fr
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00020  * USA
00021  *
00022  *  Author : Philippe Delrieu
00023  * 
00024  */
00025 
00026 package org.openmobileis.synchro.openmsp.client.db;
00027 
00028 import org.openmobileis.common.util.log.*;
00029 import org.openmobileis.common.util.collection.Array;
00030 
00039 public class SyncActionDBManager{
00040 
00041   private static SyncActionDBManager manager;
00042   private static SyncActionDBQueryManager actiondbQueryManager;
00043 
00044   public static SyncActionDBManager getManager () {
00045     if (manager == null)  {
00046       synchronized (SyncActionDBManager.class) {
00047         if (manager == null)  {
00048           manager = new SyncActionDBManager();
00049         }
00050       }
00051     }
00052     return manager;
00053   }
00054 
00055   private SyncActionDBManager(){
00056 
00057     try {
00058       actiondbQueryManager.initDB();
00059     } catch (Exception e) {
00060       LogManager.traceError(LogServices.WEBSERVICE, e);
00061     }
00062   }
00063   
00064   public static void registerSyncActionDBQueryManager(SyncActionDBQueryManager actionManager)   {
00065                 actiondbQueryManager = actionManager;
00066   }
00067   
00068   public ActionDB[] getActionsForService(String serviceName) {
00069     try {
00070       Array result = actiondbQueryManager.getActionsForService(serviceName);
00071       ActionDB[] actionRes = new ActionDB[result.size()];
00072       result.toArray(actionRes);
00073       return actionRes;
00074     } catch (Exception e) {
00075       LogManager.traceError(LogServices.WEBSERVICE, e);
00076     }
00077     return new ActionDB[0];
00078   }
00079 
00080 
00081   public ActionDB getActionDB(String serviceName, String uid) {
00082     try {
00083       return actiondbQueryManager.getActionDB(serviceName, uid);
00084     } catch (Exception e) {
00085       LogManager.traceError(LogServices.WEBSERVICE, e);
00086     }
00087     return null;
00088   }
00089   
00090   public void addActionDB(ActionDB action)      {
00091     try { 
00092       actiondbQueryManager.create(action);
00093     } catch (Exception e) {
00094         LogManager.traceError(LogServices.WEBSERVICE, e);
00095     }
00096   }
00097 
00098 
00099   /*
00100   * insert or update an add actionDB.
00101   */
00102   public void setAddActionDB (String serviceName, String uid) {
00103 
00104     try { 
00105       ActionDB action = new ActionDB(serviceName, uid, ActionDB.ADD_ACTION);
00106       actiondbQueryManager.create(action);
00107    } catch (Exception e) {
00108         LogManager.traceError(LogServices.WEBSERVICE, e);
00109     }
00110   }
00111 
00112   /*
00113   * insert or update an update actionDB.
00114   */
00115   public void setUpdateActionDB (String serviceName, String uid) {
00116 
00117     try { 
00118       ActionDB action = new ActionDB(serviceName, uid, ActionDB.UPDATE_ACTION);
00119       actiondbQueryManager.create(action);
00120     } catch (Exception e) {
00121         LogManager.traceError(LogServices.WEBSERVICE, e);
00122     }
00123   }
00124 
00125   /*
00126   * insert or update an delete actionDB.
00127   */
00128   public void setDeleteActionDB (String serviceName, String uid) {
00129     try { 
00130       ActionDB action = new ActionDB(serviceName, uid, ActionDB.DELETE_ACTION);
00131       actiondbQueryManager.create(action);
00132     } catch (Exception e) {
00133         LogManager.traceError(LogServices.WEBSERVICE, e);
00134     }
00135   }
00136 
00137   /*
00138   * delete the action associated with the service and uid.
00139   */
00140   public void deleteActionDB (String serviceName, String uid) {
00141 
00142     try { 
00143       actiondbQueryManager.delete(serviceName, uid);
00144     } catch (Exception e) {
00145         LogManager.traceError(LogServices.WEBSERVICE, e);
00146     }
00147   }
00148 
00149   /*
00150   * delete the action associated with the service and uid.
00151   */
00152   public void deleteAllActionDBForService (String serviceName) {
00153 
00154     try { 
00155       actiondbQueryManager.deleteAllActionForService(serviceName);
00156     } catch (Exception e) {
00157         LogManager.traceError(LogServices.WEBSERVICE, e);
00158     }
00159   }
00160 
00161 
00162 
00163 }

Generated on Wed Dec 14 21:05:35 2005 for OpenMobileIS by  doxygen 1.4.4