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

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  *  Modifications :
00025  *  2004 Creation P.Delrieu
00026  *  2004 Modified by Romain Beaugrand
00027  * 
00028  */
00029 
00030 package org.openmobileis.database.fastobjectdb.synchro.client;
00031 
00032 import org.openmobileis.common.util.log.*;
00033 import org.openmobileis.common.util.collection.Array;
00034 
00043 public class SyncActionDBManager{
00044 
00045   private static SyncActionDBManager manager;
00046   private static SyncActionDBQueryManager actiondbQueryManager;
00047   private static int uidMaxKeyLength = 0;
00048 
00049   public static SyncActionDBManager getManager () {
00050     if (manager == null)  {
00051       synchronized (SyncActionDBManager.class) {
00052         if (manager == null)  {
00053           manager = new SyncActionDBManager();
00054         }
00055       }
00056     }
00057     return manager;
00058   }
00059 
00060   private SyncActionDBManager(){
00061 
00062     try {
00063       actiondbQueryManager.initDB();
00064     } catch (Exception e) {
00065       LogManager.traceError(LogServices.WEBSERVICE, e);
00066     }
00067   }
00068   
00069   public static void registerSyncActionDBQueryManager(SyncActionDBQueryManager actionManager)   {
00070                 actiondbQueryManager = actionManager;
00071   }
00072   
00073   
00079   public static void setActionUIDMaxKeyLength(int length) {
00080      uidMaxKeyLength = length;
00081   }
00082 
00083   public ActionDB[] getActionsForService(String serviceName) {
00084     try {
00085       Array result = actiondbQueryManager.getActionsForService(serviceName);
00086       ActionDB[] actionRes = new ActionDB[result.size()];
00087       result.toArray(actionRes);
00088       return actionRes;
00089     } catch (Exception e) {
00090       LogManager.traceError(LogServices.WEBSERVICE, e);
00091     }
00092     return new ActionDB[0];
00093   }
00094 
00095 
00096   public ActionDB getActionDB(String serviceName, String uid) {
00097     try {
00098       return actiondbQueryManager.getActionDB(serviceName, uid);
00099     } catch (Exception e) {
00100       LogManager.traceError(LogServices.WEBSERVICE, e);
00101     }
00102     return null;
00103   }
00104   
00105   public void addActionDB(ActionDB action)      {
00106     try { 
00107       actiondbQueryManager.create(action);
00108     } catch (Exception e) {
00109         LogManager.traceError(LogServices.WEBSERVICE, e);
00110     }
00111   }
00112 
00113 
00114   /*
00115   * insert or update an add actionDB.
00116   */
00117   public void setAddActionDB (String serviceName, String uid) {
00118 
00119     try { 
00120       ActionDB action = new ActionDB(serviceName, uid, ActionDB.ADD_ACTION);
00121       actiondbQueryManager.create(action);
00122    } catch (Exception e) {
00123         LogManager.traceError(LogServices.WEBSERVICE, e);
00124     }
00125   }
00126 
00127   /*
00128   * insert or update an update actionDB.
00129   */
00130   public void setUpdateActionDB (String serviceName, String uid) {
00131 
00132     try { 
00133       ActionDB action = new ActionDB(serviceName, uid, ActionDB.UPDATE_ACTION);
00134       actiondbQueryManager.create(action);
00135     } catch (Exception e) {
00136         LogManager.traceError(LogServices.WEBSERVICE, e);
00137     }
00138   }
00139 
00140   /*
00141   * insert or update an delete actionDB.
00142   */
00143   public void setDeleteActionDB (String serviceName, String uid) {
00144     try { 
00145       ActionDB action = new ActionDB(serviceName, uid, ActionDB.DELETE_ACTION);
00146       actiondbQueryManager.create(action);
00147     } catch (Exception e) {
00148         LogManager.traceError(LogServices.WEBSERVICE, e);
00149     }
00150   }
00151 
00152   /*
00153   * delete the action associated with the service and uid.
00154   */
00155   public void deleteActionDB (String serviceName, String uid) {
00156 
00157     try { 
00158       actiondbQueryManager.delete(serviceName, uid);
00159     } catch (Exception e) {
00160         LogManager.traceError(LogServices.WEBSERVICE, e);
00161     }
00162   }
00163 
00164   /*
00165   * delete the action associated with the service and uid.
00166   */
00167   public void deleteAllActionDBForService (String serviceName) {
00168 
00169     try { 
00170       actiondbQueryManager.deleteAllActionForService(serviceName);
00171     } catch (Exception e) {
00172         LogManager.traceError(LogServices.WEBSERVICE, e);
00173     }
00174   }
00175 
00176 
00177 
00178 }

Generated on Thu Oct 6 10:06:34 2005 for OpenMobileIS by  doxygen 1.4.3