@ -47,39 +47,44 @@ public class NameMaps {
// ---- Column name mappings -------
// ---- Column name mappings -------
// --------------------------------
// --------------------------------
private static final Map < Property < ? > , String > TASK_PROPERTIES_LOCAL_TO_SERVER ;
private static final Map < Property < ? > , String > TASK_PROPERTIES_LOCAL_TO_SERVER ;
private static final Map < String , Property < ? > > TASK_COLUMN_NAMES_TO_PROPERTIES ;
private static final Map < String , String > TASK_COLUMNS_LOCAL_TO_SERVER ;
private static final Map < String , String > TASK_COLUMNS_LOCAL_TO_SERVER ;
private static final Map < String , Property < ? > > TASK_PROPERTIES_SERVER_TO_LOCAL ;
private static final Map < String , Property < ? > > TASK_PROPERTIES_SERVER_TO_LOCAL ;
private static void putPropertyToServerName ( Property < ? > property , String serverName ,
private static void putPropertyToServerName ( Property < ? > property , String serverName ,
Map < Property < ? > , String > propertyMap , Map < String , String> n ameMap) {
Map < Property < ? > , String > propertyMap , Map < String , Property< ? > > localNameMap , Map < String , String > serverN ameMap) {
propertyMap . put ( property , serverName ) ;
propertyMap . put ( property , serverName ) ;
nameMap . put ( property . name , serverName ) ;
localNameMap . put ( property . name , property ) ;
serverNameMap . put ( property . name , serverName ) ;
}
}
static {
static {
// Hardcoded local columns mapped to corresponding server names
// Hardcoded local columns mapped to corresponding server names
TASK_PROPERTIES_LOCAL_TO_SERVER = new HashMap < Property < ? > , String > ( ) ;
TASK_PROPERTIES_LOCAL_TO_SERVER = new HashMap < Property < ? > , String > ( ) ;
TASK_COLUMNS_LOCAL_TO_SERVER = new HashMap < String , String > ( ) ;
TASK_COLUMNS_LOCAL_TO_SERVER = new HashMap < String , String > ( ) ;
putPropertyToServerName ( Task . TITLE , "title" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
TASK_COLUMN_NAMES_TO_PROPERTIES = new HashMap < String , Property < ? > > ( ) ;
putPropertyToServerName ( Task . IMPORTANCE , "importance" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( Task . DUE_DATE , "due" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( Task . TITLE , "title" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMN_NAMES_TO_PROPERTIES , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( Task . HIDE_UNTIL , "hide_until" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( Task . IMPORTANCE , "importance" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMN_NAMES_TO_PROPERTIES , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( Task . COMPLETION_DATE , "completed_at" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( Task . DUE_DATE , "due" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMN_NAMES_TO_PROPERTIES , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( Task . DELETION_DATE , "deleted_at" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( Task . HIDE_UNTIL , "hide_until" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMN_NAMES_TO_PROPERTIES , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( Task . NOTES , "notes" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( Task . COMPLETION_DATE , "completed_at" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMN_NAMES_TO_PROPERTIES , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( Task . RECURRENCE , "repeat" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( Task . DELETION_DATE , "deleted_at" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMN_NAMES_TO_PROPERTIES , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( Task . USER_ID , "user_id" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( Task . NOTES , "notes" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMN_NAMES_TO_PROPERTIES , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( Task . USER , "user" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( Task . RECURRENCE , "repeat" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMN_NAMES_TO_PROPERTIES , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( Task . CREATOR_ID , "creator_id" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( Task . USER_ID , "user_id" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMN_NAMES_TO_PROPERTIES , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( Task . UUID , "uuid" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( Task . USER , "user" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMN_NAMES_TO_PROPERTIES , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( Task . PROOF_TEXT , "proof_text" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( Task . CREATOR_ID , "creator_id" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMN_NAMES_TO_PROPERTIES , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( Task . PUSHED_AT , "pushed_at" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( Task . UUID , "uuid" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMN_NAMES_TO_PROPERTIES , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( Task . PROOF_TEXT , "proof_text" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMN_NAMES_TO_PROPERTIES , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( Task . PUSHED_AT , "pushed_at" , TASK_PROPERTIES_LOCAL_TO_SERVER , TASK_COLUMN_NAMES_TO_PROPERTIES , TASK_COLUMNS_LOCAL_TO_SERVER ) ;
TASK_PROPERTIES_SERVER_TO_LOCAL = AndroidUtilities . reverseMap ( TASK_PROPERTIES_LOCAL_TO_SERVER ) ;
TASK_PROPERTIES_SERVER_TO_LOCAL = AndroidUtilities . reverseMap ( TASK_PROPERTIES_LOCAL_TO_SERVER ) ;
}
}
private static final Map < Property < ? > , String > TAG_DATA_PROPERTIES_LOCAL_TO_SERVER ;
private static final Map < Property < ? > , String > TAG_DATA_PROPERTIES_LOCAL_TO_SERVER ;
private static final Map < String , Property < ? > > TAG_DATA_COLUMN_NAMES_TO_PROPERTIES ;
private static final Map < String , String > TAG_DATA_COLUMNS_LOCAL_TO_SERVER ;
private static final Map < String , String > TAG_DATA_COLUMNS_LOCAL_TO_SERVER ;
private static final Map < String , Property < ? > > TAG_DATA_PROPERTIES_SERVER_TO_LOCAL ;
private static final Map < String , Property < ? > > TAG_DATA_PROPERTIES_SERVER_TO_LOCAL ;
@ -87,47 +92,48 @@ public class NameMaps {
// Hardcoded local columns mapped to corresponding server names
// Hardcoded local columns mapped to corresponding server names
TAG_DATA_PROPERTIES_LOCAL_TO_SERVER = new HashMap < Property < ? > , String > ( ) ;
TAG_DATA_PROPERTIES_LOCAL_TO_SERVER = new HashMap < Property < ? > , String > ( ) ;
TAG_DATA_COLUMNS_LOCAL_TO_SERVER = new HashMap < String , String > ( ) ;
TAG_DATA_COLUMNS_LOCAL_TO_SERVER = new HashMap < String , String > ( ) ;
TAG_DATA_COLUMN_NAMES_TO_PROPERTIES = new HashMap < String , Property < ? > > ( ) ;
putPropertyToServerName ( TagData . USER_ID , "user_id" , TAG_DATA_PROPERTIES_LOCAL_TO_SERVER , TAG_DATA_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( TagData . USER , "user" , TAG_DATA_PROPERTIES_LOCAL_TO_SERVER , TAG_DATA_COLUMNS_LOCAL_TO_SERVER ) ; //TODO: NOT CORRECT
putPropertyToServerName ( TagData . USER_ID , "user_id" , TAG_DATA_PROPERTIES_LOCAL_TO_SERVER , TAG_DATA_COLUMN_NAMES_TO_PROPERTIES , TAG_DATA_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( TagData . NAME , "name" , TAG_DATA_PROPERTIES_LOCAL_TO_SERVER , TAG_DATA_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( TagData . USER , "user" , TAG_DATA_PROPERTIES_LOCAL_TO_SERVER , TAG_DATA_COLUMN_NAMES_TO_PROPERTIES , TAG_DATA_COLUMNS_LOCAL_TO_SERVER ) ; //TODO: NOT CORRECT
putPropertyToServerName ( TagData . PICTURE , "picture_id" , TAG_DATA_PROPERTIES_LOCAL_TO_SERVER , TAG_DATA_COLUMNS_LOCAL_TO_SERVER ) ; //TODO: NOT CORRECT
putPropertyToServerName ( TagData . NAME , "name" , TAG_DATA_PROPERTIES_LOCAL_TO_SERVER , TAG_DATA_COLUMN_NAMES_TO_PROPERTIES , TAG_DATA_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( TagData . MEMBERS , "members" , TAG_DATA_PROPERTIES_LOCAL_TO_SERVER , TAG_DATA_COLUMNS_LOCAL_TO_SERVER ) ; //TODO: NOT CORRECT
putPropertyToServerName ( TagData . PICTURE , "picture_id" , TAG_DATA_PROPERTIES_LOCAL_TO_SERVER , TAG_DATA_COLUMN_NAMES_TO_PROPERTIES , TAG_DATA_COLUMNS_LOCAL_TO_SERVER ) ; //TODO: NOT CORRECT
putPropertyToServerName ( TagData . CREATION_DATE , "created_at" , TAG_DATA_PROPERTIES_LOCAL_TO_SERVER , TAG_DATA_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( TagData . MEMBERS , "members" , TAG_DATA_PROPERTIES_LOCAL_TO_SERVER , TAG_DATA_COLUMN_NAMES_TO_PROPERTIES , TAG_DATA_COLUMNS_LOCAL_TO_SERVER ) ; //TODO: NOT CORRECT
putPropertyToServerName ( TagData . DELETION_DATE , "deleted_at" , TAG_DATA_PROPERTIES_LOCAL_TO_SERVER , TAG_DATA_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( TagData . CREATION_DATE , "created_at" , TAG_DATA_PROPERTIES_LOCAL_TO_SERVER , TAG_DATA_COLUMN_NAMES_TO_PROPERTIES , TAG_DATA_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( TagData . UUID , "uuid" , TAG_DATA_PROPERTIES_LOCAL_TO_SERVER , TAG_DATA_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( TagData . DELETION_DATE , "deleted_at" , TAG_DATA_PROPERTIES_LOCAL_TO_SERVER , TAG_DATA_COLUMN_NAMES_TO_PROPERTIES , TAG_DATA_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( TagData . PROOF_TEXT , "proof_text" , TAG_DATA_PROPERTIES_LOCAL_TO_SERVER , TAG_DATA_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( TagData . UUID , "uuid" , TAG_DATA_PROPERTIES_LOCAL_TO_SERVER , TAG_DATA_COLUMN_NAMES_TO_PROPERTIES , TAG_DATA_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( TagData . TAG_ORDERING , "tag_ordering" , TAG_DATA_PROPERTIES_LOCAL_TO_SERVER , TAG_DATA_COLUMNS_LOCAL_TO_SERVER ) ; //TODO: NOT CORRECT
putPropertyToServerName ( TagData . PROOF_TEXT , "proof_text" , TAG_DATA_PROPERTIES_LOCAL_TO_SERVER , TAG_DATA_COLUMN_NAMES_TO_PROPERTIES , TAG_DATA_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( TagData . PUSHED_AT , "pushed_at" , TAG_DATA_PROPERTIES_LOCAL_TO_SERVER , TAG_DATA_COLUMNS_LOCAL_TO_SERVER ) ;
putPropertyToServerName ( TagData . TAG_ORDERING , "tag_ordering" , TAG_DATA_PROPERTIES_LOCAL_TO_SERVER , TAG_DATA_COLUMN_NAMES_TO_PROPERTIES , TAG_DATA_COLUMNS_LOCAL_TO_SERVER ) ; //TODO: NOT CORRECT
putPropertyToServerName ( TagData . PUSHED_AT , "pushed_at" , TAG_DATA_PROPERTIES_LOCAL_TO_SERVER , TAG_DATA_COLUMN_NAMES_TO_PROPERTIES , TAG_DATA_COLUMNS_LOCAL_TO_SERVER ) ;
// Reverse the mapping to construct the server to local map
// Reverse the mapping to construct the server to local map
TAG_DATA_PROPERTIES_SERVER_TO_LOCAL = AndroidUtilities . reverseMap ( TAG_DATA_PROPERTIES_LOCAL_TO_SERVER ) ;
TAG_DATA_PROPERTIES_SERVER_TO_LOCAL = AndroidUtilities . reverseMap ( TAG_DATA_PROPERTIES_LOCAL_TO_SERVER ) ;
}
}
p ublic static String localColumnNameToServerColumnName ( String table , String localColumn ) {
p rivate static < A , B > B mapColumnName ( String table , String col , Map < A , B > taskMap , Map < A , B > tagMap ) {
Map < String, String > map = null ;
Map < A, B > map = null ;
if ( SERVER_TABLE_TASKS . equals ( table ) )
if ( SERVER_TABLE_TASKS . equals ( table ) )
map = TASK_COLUMNS_LOCAL_TO_SERVER ;
map = taskMap ;
else if ( SERVER_TABLE_TAGS . equals ( table ) )
else if ( SERVER_TABLE_TAGS . equals ( table ) )
map = TAG_DATA_COLUMNS_LOCAL_TO_SERVER ;
map = tagMap ;
if ( map = = null )
if ( map = = null )
return null ;
return null ;
return map . get ( lo calC olumn ) ;
return map . get ( col) ;
}
}
public static Property < ? > serverColumnNameToLocalProperty ( String table , String serverColumn ) {
public static String localColumnNameToServerColumnName ( String table , String localColumn ) {
Map < String , Property < ? > > map = null ;
return mapColumnName ( table , localColumn , TASK_COLUMNS_LOCAL_TO_SERVER , TAG_DATA_COLUMNS_LOCAL_TO_SERVER ) ;
if ( SERVER_TABLE_TASKS . equals ( table ) )
}
map = TASK_PROPERTIES_SERVER_TO_LOCAL ;
else if ( SERVER_TABLE_TAGS . equals ( table ) )
map = TAG_DATA_PROPERTIES_SERVER_TO_LOCAL ;
if ( map = = null )
public static Property < ? > localColumnNameToProperty ( String table , String localColumn ) {
return null ;
return mapColumnName ( table , localColumn , TASK_COLUMN_NAMES_TO_PROPERTIES , TAG_DATA_COLUMN_NAMES_TO_PROPERTIES ) ;
}
return map . get ( serverColumn ) ;
public static Property < ? > serverColumnNameToLocalProperty ( String table , String serverColumn ) {
return mapColumnName ( table , serverColumn , TASK_PROPERTIES_SERVER_TO_LOCAL , TAG_DATA_PROPERTIES_SERVER_TO_LOCAL ) ;
}
}
}
}