MyCrmLabelSynchroTarget.java

00001 
00021 package org.openmobileis.examples.mycrm.data.jdbc;
00022 
00023 
00024 import java.sql.ResultSet;
00025 
00026 
00027 
00028 import org.openmobileis.common.user.UserNotFoundException;
00029 import org.openmobileis.common.util.collection.Array;
00030 import org.openmobileis.common.util.exception.ServiceException;
00031 import org.openmobileis.database.fastobjectdb.FastObjectDB;
00032 import org.openmobileis.database.fastobjectdb.synchro.server.FODBSyncTarget;
00033 
00034 import org.openmobileis.modules.common.data.Label;
00035 import org.openmobileis.modules.common.database.fodb.FODBLabel;
00036 import org.openmobileis.synchro.algo.replication.AlwaysUpdateServerSynchroConflicResolver;
00037 import org.openmobileis.synchro.algo.replication.SynchroAtomicObject;
00038 import org.openmobileis.synchro.algo.replication.SynchroConflicResolver;
00039 import org.openmobileis.synchro.algo.replication.utils.DefaultSynchroAtomicObject;
00040 import org.openmobileis.synchro.openmsp.OpenMSPException;
00041 import org.openmobileis.synchro.security.auth.Credential;
00042 
00043 
00044 
00051 public class MyCrmLabelSynchroTarget implements FODBSyncTarget {
00052         
00053 //      public static final String LABEL_ATOMIC_OBJECT_UID="%labeluid1%";
00054 
00055   private MyCrmLabelQuery query = null;
00056         
00057   public MyCrmLabelSynchroTarget() {
00058     super();
00059     query = new MyCrmLabelQuery();
00060 
00061   }
00062 
00063   /* (non-Javadoc)
00064    * @see org.openmobileis.database.fastobjectdb.synchro.server.FODBSyncService#getCollectionName()
00065    */
00066   public String getCollectionName() {
00067     return "label";
00068   }
00069   
00077   public void setSendSynchroMetaData(Object metadata)throws OpenMSPException    {
00078     
00079   }
00080 
00081   /* (non-Javadoc)
00082    * @see org.openmobileis.database.fastobjectdb.synchro.server.FODBSyncService#getCollectionObjectWithId(java.lang.String)
00083    */
00084   public Object getCollectionObjectWithId(String id) throws OpenMSPException {
00085     
00086                 Label label = null;
00087                 try     {
00088                         String[] param = FODBLabel.getLabelIdAndCatIdFromId(id);
00089                         ResultSet result = query.getLabel(param);
00090                         while (result.next())   {
00091                                 label = query.convertLabelFromResult(result);
00092                         }
00093                 } catch (Throwable ex)  {
00094                         throw new OpenMSPException(ex);
00095                 } finally {
00096                         query.getDbManager().garbageOpenedConnection();
00097                 }
00098                 return label;
00099   }
00100 
00101   /* (non-Javadoc)
00102    * @see org.openmobileis.database.fastobjectdb.synchro.server.FODBSyncService#updateCollectionObject(java.lang.Object)
00103    */
00104   public void updateCollectionObject(Object obj) throws OpenMSPException {
00105   }
00106 
00107   /* (non-Javadoc)
00108    * @see org.openmobileis.database.fastobjectdb.synchro.server.FODBSyncService#deleteCollectionObject(java.lang.String)
00109    */
00110   public void deleteCollectionObject(String id) throws OpenMSPException {
00111   }
00112 
00113   /* (non-Javadoc)
00114    * @see org.openmobileis.database.fastobjectdb.synchro.server.FODBSyncService#getConflicResolver()
00115    */
00116   public SynchroConflicResolver getConflicResolver() {
00117     return new AlwaysUpdateServerSynchroConflicResolver();
00118   }
00119 
00120   /* (non-Javadoc)
00121    * @see org.openmobileis.database.fastobjectdb.synchro.server.FODBSyncService#getAllCollectionObject()
00122    */
00123   public Array getAllCollectionObject() throws OpenMSPException {
00124     
00125                 Array list = new Array();
00126                         try     {
00127                                 ResultSet result = query.getAllLabel();
00128                                 while (result.next())   {
00129                                         list.add(query.convertLabelFromResult(result));
00130                                 }
00131                         } catch (Throwable ex)  {
00132                                 throw new OpenMSPException(ex);
00133                         } finally {
00134                                 query.getDbManager().garbageOpenedConnection();
00135                         }
00136                 return list;
00137   }
00138 
00139   /* (non-Javadoc)
00140    * @see org.openmobileis.database.fastobjectdb.synchro.server.FODBSyncService#getCollectionObjectId(java.lang.Object)
00141    */
00142   public String getCollectionObjectId(Object obj) {
00143     return ((FODBLabel)obj).getLabelCategoryId();
00144   }
00145 
00146   /* (non-Javadoc)
00147    * @see org.openmobileis.database.fastobjectdb.synchro.server.FODBSyncService#getAllModifiedAtomicObjectForServiceSince(java.lang.String, long)
00148    */
00149   public SynchroAtomicObject[] getAllModifiedAtomicObjectSince(long date) throws OpenMSPException {
00150     if (date == 0)  { //synchronize only during complete synchro
00151       SynchroAtomicObject[] sync = new  SynchroAtomicObject[1];
00152       sync[0] = new DefaultSynchroAtomicObject("", "");
00153       return sync;
00154     }
00155     return new SynchroAtomicObject[0];
00156   }
00157 
00158   /* (non-Javadoc)
00159    * @see org.openmobileis.database.fastobjectdb.synchro.server.FODBSyncService#getUpdateMaxNbRow()
00160    */
00161   public int getUpdateMaxNbRow() {
00162     return 0;
00163   }
00164 
00165   /* (non-Javadoc)
00166    * @see org.openmobileis.database.fastobjectdb.synchro.server.FODBSyncService#updateSynchroDB(org.openmobileis.database.fastobjectdb.FastObjectDB)
00167    */
00168   public void updateSynchroDB(FastObjectDB db) throws OpenMSPException {
00169   }
00170   
00171   /* (non-Javadoc)
00172    * @see org.openmobileis.database.fastobjectdb.synchro.server.FODBSyncTarget#connect(org.openmobileis.synchro.security.auth.Credential)
00173    */
00174   public void connect(Credential cred) throws UserNotFoundException, ServiceException {
00175     // do nothing
00176   }
00177 
00178   /* (non-Javadoc)
00179    * @see org.openmobileis.database.fastobjectdb.synchro.server.FODBSyncTarget#disconnect()
00180    */
00181   public void disconnect() {
00182     // do nothing
00183   }
00184 }

Generated on Mon Dec 4 11:03:28 2006 for OpenMobileIS by  doxygen 1.5.1-p1