Search in sources :

Example 1 with Flag

use of com.vodafone360.people.datatypes.ActivityItem.Flag in project 360-Engine-for-Android by 360.

the class DatabaseHelper method deleteActivities.

/***
     * Removes all the status or timeline activities from the database. Note:
     * Only called from tests.
     * 
     * @param flag The type of activity to delete or null to delete all
     * @return SUCCESS or a suitable error code
     * @see #addActivities(List)
     * @see #fetchActivitiesIds(List, Long)
     */
public ServiceStatus deleteActivities(Integer flag) {
    if (Settings.ENABLED_DATABASE_TRACE)
        trace(false, "DatabaseHelper.deleteActivities() flag[" + flag + "]");
    ServiceStatus status = ActivitiesTable.deleteActivities(flag, getWritableDatabase());
    if (ServiceStatus.SUCCESS == status) {
        if (flag == null || flag.intValue() == ActivityItem.TIMELINE_ITEM) {
            StateTable.modifyLatestPhoneCallTime(System.currentTimeMillis(), getWritableDatabase());
        }
    }
    fireDatabaseChangedEvent(DatabaseChangeType.ACTIVITIES, true);
    return status;
}
Also used : ServiceStatus(com.vodafone360.people.service.ServiceStatus)

Example 2 with Flag

use of com.vodafone360.people.datatypes.ActivityItem.Flag in project 360-Engine-for-Android by 360.

the class ContactDetailsTable method syncSetServerIds.

/**
     * Set contact detail server ID for all those details which require a server
     * ID. In any case, the server sync contact ID flag is set to -1 to indicate
     * that the detail has been fully synced with the server.
     * 
     * @param serverIdList The list of contact details. This list should include
     *            all details even the ones which don't have server IDs.
     * @param writableDb A writable SQLite database object
     * @return SUCCESS or a suitable error code.
     */
public static ServiceStatus syncSetServerIds(List<ServerIdInfo> serverIdList, SQLiteDatabase writableDb) {
    final int STATEMENT1_COLUMN_SERVERID = 1;
    final int STATEMENT1_COLUMN_LOCALID = 2;
    final int STATEMENT2_COLUMN_LOCALID = 1;
    DatabaseHelper.trace(true, "ContactDetailsTable.syncSetServerIds()");
    if (serverIdList.size() == 0) {
        return ServiceStatus.SUCCESS;
    }
    SQLiteStatement statement1 = null;
    SQLiteStatement statement2 = null;
    try {
        writableDb.beginTransaction();
        for (int i = 0; i < serverIdList.size(); i++) {
            final ServerIdInfo info = serverIdList.get(i);
            if (info.serverId != null) {
                if (statement1 == null) {
                    statement1 = writableDb.compileStatement("UPDATE " + TABLE_NAME + " SET " + Field.DETAILSERVERID + "=?," + Field.SERVERSYNCCONTACTID + "=-1 WHERE " + Field.DETAILLOCALID + "=?");
                }
                statement1.bindLong(STATEMENT1_COLUMN_SERVERID, info.serverId);
                statement1.bindLong(STATEMENT1_COLUMN_LOCALID, info.localId);
                statement1.execute();
            } else {
                if (statement2 == null) {
                    statement2 = writableDb.compileStatement("UPDATE " + TABLE_NAME + " SET " + Field.SERVERSYNCCONTACTID + "=-1 WHERE " + Field.DETAILLOCALID + "=?");
                }
                statement2.bindLong(STATEMENT2_COLUMN_LOCALID, info.localId);
                statement2.execute();
            }
        }
        writableDb.setTransactionSuccessful();
        return ServiceStatus.SUCCESS;
    } catch (SQLException e) {
        LogUtils.logE("ContactDetailsTable.syncSetServerIds() SQLException - Unable to update contact detail server Ids", e);
        return ServiceStatus.ERROR_DATABASE_CORRUPT;
    } finally {
        writableDb.endTransaction();
        if (statement1 != null) {
            statement1.close();
            statement1 = null;
        }
        if (statement2 != null) {
            statement2.close();
            statement2 = null;
        }
    }
}
Also used : SQLiteStatement(android.database.sqlite.SQLiteStatement) SQLException(android.database.SQLException) ServerIdInfo(com.vodafone360.people.database.DatabaseHelper.ServerIdInfo)

Example 3 with Flag

use of com.vodafone360.people.datatypes.ActivityItem.Flag in project 360-Engine-for-Android by 360.

the class ResponseReaderThread method startConnection.

/**
     * Starts the connection by setting the connection flag and spawning a new
     * thread in which responses can be read without interfering with the rest
     * of the client.
     */
public void startConnection() {
    HttpConnectionThread.logI("RpgTcpResponseReader.startConnection()", "STARTING Response Reader!");
    mIsConnectionRunning = true;
    mThread = new Thread(this, "RpgTcpResponseReader");
    mThread.start();
}
Also used : HttpConnectionThread(com.vodafone360.people.service.transport.http.HttpConnectionThread) DecoderThread(com.vodafone360.people.service.transport.DecoderThread)

Example 4 with Flag

use of com.vodafone360.people.datatypes.ActivityItem.Flag in project 360-Engine-for-Android by 360.

the class TestModule method createFakeActivitiesList.

/**
	 * TODO: fill in the method properly
	 * @return
	 */
public List<ActivityItem> createFakeActivitiesList() {
    List<ActivityItem> activityList = new ArrayList<ActivityItem>();
    for (int i = 0; i < TABLE_SIZE; i++) {
        ActivityItem activityItem = new ActivityItem();
        /** Unique identifier for the activity. This can be empty when setting 
			 * a new activity (the id is generated on the server side) */
        activityItem.activityId = System.currentTimeMillis();
        /** Timestamp representing the time of the activity. 
			 * This may not be related to creation/updated time. */
        activityItem.time = System.currentTimeMillis();
        /** local id for db */
        //			activityItem.mLocalId; set by DB insertion
        //			activityItem.mMoreInfo; //new Hashtable<ActivityItem, String>
        /** The parent activity for 'grouped' or aggregated activities. This must be empty 
			 * for normal activities that can be retrieved normally. Normally, a GetActivities 
			 * without filter will not yield any 'grouped' or 'child' activities. 
			 * To get activities that have a mParentActivity set, the 'children' filter must 
			 * be used with a value of the parent Activity's id.*/
        //			activityItem.mParentActivity; // null
        /** Indicates wether this activity 'groups' several child activities. When set, 
			 * there must be child activities set that refer the main activity. Normally, 
			 * a GetActivities without filter will not yield any 'grouped' or 'child' activities. 
			 * To get activities that have a parentactivity set, the 'children' filter 
			 * must be used with a value of the parent Activity's id.*/
        //			activityItem.mHasChildren = false;
        /** Defines a binary preview for the activity. The preview can be a small thumbnail 
			 * of the activity. The type of the binary data is defined into the previewmime field.*/
        //			keep null
        //			activityItem.mPreview = ByteBuffer.allocate(bytes.length);
        //			activityItem.mPreviewMime;
        /** Defines an http url that the client can use to retrieve preview binary data. 
			 * Can be used to embed the url into an IMG HTML tag.*/
        //			activityItem.mPreviewUrl
        /** Name of the store type for this message. This field contains information about the 
			 * originator network (local or external community activity). 
			 * By default, should be set to local*/
        activityItem.store = "local";
        activityItem.title = generateRandomString();
        activityItem.description = activityItem.description + activityItem.store;
        /** Defines the type of the activity. */
        activityItem.type = Type.CONTACT_FRIEND_INVITATION_SENT;
        /** Defines an internal reference (if any) to the source of the activity. 
			 * The format for the uri is "module:identifier".Some examples of valid uri are:
			 * contact:2737b322c9f6476ca152aa6cf3e5ac12 The activity is linked to some 
			 * changes on a contact identified by id=2737b322c9f6476ca152aa6cf3e5ac12.
			 * file:virtual/flickr/2590004126 The activity is linked to some actions 
			 * on a file identified by id=virtual/flickr/2590004126.
			 * message:9efd255359074dd9bd04cc1c8c4743e5 The activity is linked to a message 
			 * identified by id=9efd255359074dd9bd04cc1c8c4743e5 */
        activityItem.uri = "virtual/flickr/2590004126";
        //can be 0		activityItem.mActivityFlags;
        /** Miscellaneous flags.*/
        activityItem.flagList = new ArrayList<Flag>();
        activityItem.flagList.add(Flag.ALREADY_READ);
        /** Defines the contact information of the counter-parties in the activity. 
			 * This field is not mandatory, because some activity types 
			 * are not related to contacts, but required if known.. */
        //keep it simple - empty		activityItem.mContactList = ;
        activityItem.visibility = new ArrayList<Visibility>();
        activityItem.visibility.add(Visibility.ORIGINATOR);
        //keep it 0		activityItem.mVisibilityFlags = 0;
        activityList.add(activityItem);
    }
    return activityList;
}
Also used : ArrayList(java.util.ArrayList) Visibility(com.vodafone360.people.datatypes.ActivityItem.Visibility) Flag(com.vodafone360.people.datatypes.ActivityItem.Flag) ActivityItem(com.vodafone360.people.datatypes.ActivityItem)

Example 5 with Flag

use of com.vodafone360.people.datatypes.ActivityItem.Flag in project 360-Engine-for-Android by 360.

the class NowPlusActivitiesTableTest method testDeleteActivities.

/**
     * this test checks that the deleted activities are not really present in the DB
     */
public void testDeleteActivities() {
    SQLiteDatabase db = mTestDatabase.getWritableDatabase();
    ActivitiesTable.create(db);
    /** Create dummy activities list. **/
    List<ActivityItem> activitiesList = mTestModule.createFakeActivitiesList();
    assertEquals("activitiesList is the wrong size", 25, activitiesList.size());
    /** Add activities list to database. **/
    assertEquals("ActivitiesTable.addActivities was unsuccessfull", ServiceStatus.SUCCESS, ActivitiesTable.addActivities(activitiesList, db, mContext));
    assertEquals("activitiesList is the wrong size", 25, activitiesList.size());
    /** Check if the records are in the database. **/
    List<Long> insertedDbIds = new ArrayList<Long>();
    ActivitiesTable.fetchActivitiesIds(insertedDbIds, YESTERDAY_TIME_MILLIS, db);
    for (ActivityItem item : activitiesList) {
        assertNotNull("item.mActivityId should not be NULL", item.activityId);
        assertNotNull("item.mLocalActivityId should not be NULL", item.localActivityId);
        assertNotNull("item.mTitle should not be NULL", item.title);
    }
    /** Delete all activities regardless of flag. **/
    assertEquals(ServiceStatus.SUCCESS, ActivitiesTable.deleteActivities(null, db));
    /** Check that the database is now empty. **/
    List<Long> actualDBIds = new ArrayList<Long>();
    ActivitiesTable.fetchActivitiesIds(actualDBIds, YESTERDAY_TIME_MILLIS, db);
    assertEquals("Activitiess table is not empty after deletion", 0, actualDBIds.size());
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ArrayList(java.util.ArrayList) ActivityItem(com.vodafone360.people.datatypes.ActivityItem)

Aggregations

ServiceStatus (com.vodafone360.people.service.ServiceStatus)9 ArrayList (java.util.ArrayList)6 PersistSettings (com.vodafone360.people.service.PersistSettings)5 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)4 ActivityItem (com.vodafone360.people.datatypes.ActivityItem)3 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)3 ContactChange (com.vodafone360.people.engine.contactsync.ContactChange)3 SQLiteStatement (android.database.sqlite.SQLiteStatement)2 ContactIdInfo (com.vodafone360.people.database.tables.ContactsTable.ContactIdInfo)2 Flag (com.vodafone360.people.datatypes.ActivityItem.Flag)2 Visibility (com.vodafone360.people.datatypes.ActivityItem.Visibility)2 PeopleContactsApi (com.vodafone360.people.engine.contactsync.PeopleContactsApi)2 SQLException (android.database.SQLException)1 ServerIdInfo (com.vodafone360.people.database.DatabaseHelper.ServerIdInfo)1 NativeContactsApi (com.vodafone360.people.engine.contactsync.NativeContactsApi)1 DecoderThread (com.vodafone360.people.service.transport.DecoderThread)1 HttpConnectionThread (com.vodafone360.people.service.transport.http.HttpConnectionThread)1