-
Notifications
You must be signed in to change notification settings - Fork 0
/
API_XIB_Application.incl
340 lines (238 loc) · 12 KB
/
API_XIB_Application.incl
1
/* * ——————————————————————————— * This is the Objects Metadata dictionary * part of Object's Metadata Structure * */local fn InitAttributeMetadataDict( objectDictionaryRef as CFMutableDictionaryRef )CFMutableDictionaryRef metadataDictionaryRefmetadataDictionaryRef = fn CFDictionaryCreateMutable( _kCFAllocatorDefault, 0, @kCFCopyStringDictionaryKeyCallBacks, @kCFTypeDictionaryValueCallBacks )' fn CFArrayAppendValue( objectDictionaryRef, metadataDictionaryRef )fn CFDictionaryAddValue( objectDictionaryRef, @"metadata", metadataDictionaryRef )fn CFRelease( metadataDictionaryRef )end fn/* * ——————————————————————————— * This is the Objects dictionary for * a new Project's Data Structure * */local fn InitAttributeArray( objectDictionaryRef as CFMutableDictionaryRef )CFMutableArrayRef attributeArrayRefattributeArrayRef = fn CFArrayCreateMutable( _kCFAllocatorDefault, 0, @kCFTypeArrayCallBacks )fn CFDictionaryAddValue( objectDictionaryRef, @"attributes", attributeArrayRef )fn CFRelease( attributeArrayRef )end fn/* * ——————————————————————————— * This is the Objects Metadata dictionary * part of Object's Metadata Structure * */local fn InitObjectMetadataDict( objectDictionaryRef as CFMutableDictionaryRef )CFMutableDictionaryRef metadataDictionaryRefmetadataDictionaryRef = fn CFDictionaryCreateMutable( _kCFAllocatorDefault, 0, @kCFCopyStringDictionaryKeyCallBacks, @kCFTypeDictionaryValueCallBacks )fn CFDictionaryAddValue( objectDictionaryRef, @"metadata", metadataDictionaryRef )fn CFRelease( metadataDictionaryRef )end fn/* * ——————————————————————————— * This is the Objects dictionary for * a new Project's Data Structure * */local fn InitObjectDictionary( projectDictionaryRef as CFMutableDictionaryRef )CFMutableDictionaryRef objectDictionaryRefobjectDictionaryRef = fn CFDictionaryCreateMutable( _kCFAllocatorDefault, 0, @kCFCopyStringDictionaryKeyCallBacks, @kCFTypeDictionaryValueCallBacks )' add Metaaata list for each Object (CFDictionary) to this Project' fn InitObjectMetadataDict( objectDictionaryRef )' fn InitAttributeArray( objectDictionaryRef )fn CFDictionaryAddValue( projectDictionaryRef, @"objects", objectDictionaryRef )fn CFRelease( objectDictionaryRef )end fn/* * ——————————————————————————— * This is the entry point for * a new Project Data Structure * ——————————————————————————— * * projectDictRef <-- the return type * | * |___ objectDictRef <-- a list of Objects: key = @"Name" * | * |___ objectMetadataDictRef <-- a Dictionary of Metadata Data Types e.g, @"Name", @"Alias" * | * |___ objectAttributeArrayRef <-- a Array of Attributes * | * |___ attributetMetadataDictRef <-- a Dictionary of Metadata Data Types * * e.g., @"Alias", @"Type", @"Size", @"Precision" * * * */local fn InitProjectDictionary as CFMutableDictionaryRefCFMutableDictionaryRef projectDictionaryRef/* Setup the Dictionary with an empty results array */projectDictionaryRef = fn CFDictionaryCreateMutable( _kCFAllocatorDefault, NULL, @kCFCopyStringDictionaryKeyCallBacks, @kCFTypeDictionaryValueCallBacks )' adds the Object list (CFDictionary) to this Projectfn InitObjectDictionary( projectDictionaryRef )end fn = projectDictionaryRef/* * this is my SQL test app * * queryResults <-- the return type * | * |___ resultsColumnNamesArrayRef <-- an array of Column Names * | * |___ resultsMetadata <-- a Dictionary of Col Data Types e.g. the Type of Data for each Column in a Row in the results * | * |___ resultsDataArrayRef <-- an array of Row Data e.g. each element in the array every row in the result set * | * |___ resultsColumnData <-- a Dictionary of Col Data Types e.g. the Data for each Column in a Row in the results */local fn GetObjectByObjectNameRecord( anObjectName as CFStringRef ) as CFMutableDictionaryRef'~'1CFMutableDictionaryRef resultsDictionaryRefresultsDictionaryRef = fn CFDictionaryCreateMutable( _kCFAllocatorDefault, 0, @kCFCopyStringDictionaryKeyCallBacks, @kCFTypeDictionaryValueCallBacks )/*dim as CFMutableDictionaryRef queryDictionaryRef, resultsDictionaryRefdim as CFMutableStringRef mySQLStringdim as sqlite3_stmtPtr statementfn NSLog( @"GetContactsByPersonIDRecord %@", anID )queryDictionaryRef = fn SelectPersonContactsQuery( anID )mySQLString = fn GenerateSelectSQL( queryDictionaryRef )fn NSLog( @"Contact Select SQL %@", mySQLString )if ( gDBIsConnected )statement = fn BuildPreparedStatement_Select( gDatabasePtr, mySQLString, fn GetSelectFilterArray( queryDictionaryRef ))resultsDictionaryRef = fn ExecutePreparedStatement( statement, queryDictionaryRef )fn NSLog( @"Contact %@", resultsDictionaryRef )elsefn NSLog( @"Database is not connected!" )end if*/end fn = resultsDictionaryRefvoid local fn PopulateObjectView( objectDictionaryRef as CFDictionaryRef )if( objectDictionaryRef != NULL )/*EnumeratorRef enumerator = fn ArrayObjectEnumerator( fn DictionaryValueForKey( resultsDictionaryRef, @"data" ))CFTypeRef obj = fn EnumeratorNextObject( enumerator )while ( obj )fn PopUpButtonSetTitle( _personTypePopup, fn DictionaryValueForKey( obj, @"Type" ))fn ControlSetStringValue( _personGivenName, fn DictionaryValueForKey( obj, @"Given Name" ))fn ControlSetStringValue( _personMiddleName, fn DictionaryValueForKey( obj, @"Middle Name" ))fn ControlSetStringValue( _personSurName, fn DictionaryValueForKey( obj, @"Sur Name" ))fn ControlSetStringValue( _personBalance, fn DictionaryValueForKey( obj, @"Balance" ))obj = fn EnumeratorNextObject( enumerator )wend*/end ifend fnvoid local fn PopulateObjectListView( resultsDictionaryRef as CFDictionaryRef )/*if( resultsDictionaryRef != NULL ) EnumeratorRef enumerator = fn ArrayObjectEnumerator( fn DictionaryValueForKey( resultsDictionaryRef, @"data" ))CFTypeRef obj = fn EnumeratorNextObject( enumerator )while ( obj )fn PopUpButtonSetTitle( _personTypePopup, fn DictionaryValueForKey( obj, @"Type" ))fn ControlSetStringValue( _personGivenName, fn DictionaryValueForKey( obj, @"Given Name" ))fn ControlSetStringValue( _personMiddleName, fn DictionaryValueForKey( obj, @"Middle Name" ))fn ControlSetStringValue( _personSurName, fn DictionaryValueForKey( obj, @"Sur Name" ))fn ControlSetStringValue( _personBalance, fn DictionaryValueForKey( obj, @"Balance" ))obj = fn EnumeratorNextObject( enumerator )wendend if*/end fn/* * —————————————————————————————————- * This is the entry point for a * new Project Data Structure called * when the project is created * —————————————————————————————————— * * projectDictRef <-- the return type. e.g, @"Name", @"host" * | * |___ objectDictRef <-- a list of Objects: key = @"Name" * | * |___ objectMetadataDictRef <-- a Dictionary of Metadata Data Types e.g, @"Name", @"Alias" * | * |___ objectAttributeArrayRef <-- a Array of Attributes * | * |___ attributetMetadataDictRef <-- a Dictionary of Metadata Data Types * * e.g., @"Alias", @"Type", @"Size", @"Precision" * * * * S T E P S T O I N I T I A T E A P R O J E C T * * 1. validate the Project Name is unique * 2. set global base URL for AoiLogicProject * 3. validate isSecurityOn global variable * 4. call metadata API with attributes * 5. Load Object Data into Object List View * */void local fn InitProjectCFDictionaryRef resultsObjectData, attributeObjectData, objectAttributeDictionaryRefCFStringRef anObjectKeyStringRefCFMutableArrayRef tableArrayEnumeratorRef objectEnumerator, attributeEnumeratorCFArrayRef apiResourceKeysArrayRefglobalProjectDictionary = fn InitProjectDictionaryif ( globalProjectDictionary != NULL )fn ProjectMetadataAPI(@"/metadata?include=attributes")tableArray = fn TableViewData( _objectListView )' fn MutableArrayAddObject( tableArray, @"Hello" )if ( tableArray != NULL )objectEnumerator = fn DictionaryKeyEnumerator( globalProjectDictionary )resultsObjectData = (CFMutableDictionaryRef) fn EnumeratorNextObject( objectEnumerator )while ( resultsObjectData )fn NSLog( @"Row Data: %@" , resultsObjectData )fn MutableArrayAddObject( tableArray, resultsObjectData )' fn MutableDictionarySetObjectForKey( resultsObjectData, fn StringWithFormat( @"%@ %@", fn CFDictionaryGetValue( resultsColumnData, @"Given Name" ), fn CFDictionaryGetValue( resultsColumnData, @"Sur Name" ) ), @"Full Name" )' fn MutableArrayAddObject( tableArray, resultsColumnData )objectAttributeDictionaryRef = ( CFMutableDictionaryRef ) fn DictionaryObjectForKey( globalProjectDictionary, @"objects" )attributeEnumerator = fn DictionaryKeyEnumerator( objectAttributeDictionaryRef )attributeObjectData = (CFMutableDictionaryRef) fn EnumeratorNextObject( attributeEnumerator )fn NSLog( @" Attribute Data: %@" , fn DictionaryCount( objectAttributeDictionaryRef ) )while ( attributeObjectData )' fn MutableDictionarySetObjectForKey( resultsObjectData, fn StringWithFormat( @"%@ %@", fn CFDictionaryGetValue( resultsColumnData, @"Given Name" ), fn CFDictionaryGetValue( resultsColumnData, @"Sur Name" ) ), @"Full Name" )' fn MutableArrayAddObject( tableArray, resultsColumnData )fn NSLog( @" an Attribute Data: %@" , attributeObjectData )attributeObjectData = (CFMutableDictionaryRef)fn EnumeratorNextObject( attributeEnumerator )wendresultsObjectData = (CFMutableDictionaryRef)fn EnumeratorNextObject( objectEnumerator )wendTableViewReloadData( _objectListView )/*tableArray = fn TableViewData( _objectListView )if ( tableArray != NULL )projectObjectsDictionaryRef = ( CFMutableDictionaryRef ) fn DictionaryObjectForKey( globalProjectDictionary, @"resources" )apiResourceKeysArrayRef = ( CFArrayRef ) fn DictionaryAllKeys( projectObjectsDictionaryRef )if ( apiResourceKeysArrayRef != NULL )objectEnumerator = fn DictionaryKeyEnumerator( apiResourceKeysArrayRef )if ( objectEnumerator != NULL )' get the first objectanObjectKeyStringRef = (CFStringRef) fn EnumeratorNextObject( objectEnumerator )while ( anObjectKeyStringRef )' fn MutableDictionarySetObjectForKey( resultsObjectData, fn StringWithFormat( @"%@ %@", fn CFDictionaryGetValue( resultsObjectData, @"Given Name" ), fn CFDictionaryGetValue( resultsObjectData, @"Sur Name" ) ), @"Full Name" )' fn MutableDictionarySetObjectForKey( resultsObjectData, fn StringWithFormat( @"%@ %@", fn CFDictionaryGetValue( resultsObjectData, @"Given Name" ), fn CFDictionaryGetValue( resultsObjectData, @"Sur Name" ) ), @"Full Name" )fn MutableArrayAddObject( tableArray, anObjectKeyStringRef )fn NSLog( @"Added Object Data : %@" , anObjectKeyStringRef )anObjectKeyStringRef = (CFStringRef) fn EnumeratorNextObject( objectEnumerator )wendelsefn NSLog( @"table list is NULL" )end ifend ifTableViewReloadData( _objectListView )' fn CFRelease( resultsDictionaryRef ) 'release the query dict referenceelsefn NSLog( @"object list is NULL" )end if*/elsefn NSLog( @"global Project Dictionary is NULL" )end ifend ifend fn