Ejemplo n.º 1
0
        void processSyncCommand(String strCmd, JSONEntry oCmdEntry, boolean bCheckUIRequest)
        {
            JSONStructIterator objIter = new JSONStructIterator(oCmdEntry);

            for ( ; !objIter.isEnd() && getSync().isContinueSync(); objIter.next())
            {
                String             strObject = objIter.getCurKey();
                JSONStructIterator attrIter  = new JSONStructIterator(objIter.getCurValue());

                try
                {
                    if (m_bSchemaSource)
                    {
                        processServerCmd_Ver3_Schema(strCmd, strObject, attrIter);
                    }
                    else
                    {
                        for ( ; !attrIter.isEnd() && getSync().isContinueSync(); attrIter.next())
                        {
                            String strAttrib = attrIter.getCurKey();
                            String strValue  = attrIter.getCurString();

                            processServerCmd_Ver3(strCmd, strObject, strAttrib, strValue);
                        }
                    }
                }catch (DBException exc)
                {
                    LOG.ERROR("Sync of server changes failed for " + getName() + ";object: " + strObject, exc);
                }

                if (getSyncType().compareTo("none") == 0)
                {
                    continue;
                }

                if (bCheckUIRequest)
                {
                    int nSyncObjectCount = getNotify().incLastSyncObjectCount(getID());
                    if (getProgressStep() > 0 && (nSyncObjectCount % getProgressStep() == 0))
                    {
                        getNotify().fireSyncNotification(this, false, RhoAppAdapter.ERR_NONE, "");
                    }

                    if (getDB().isUIWaitDB())
                    {
                        LOG.INFO("Commit transaction because of UI request.");
                        getDB().endTransaction();
                        SyncThread.sleep(1000);
                        getDB().startTransaction();
                    }
                }
            }
        }