|
From: Frank V. C. <fr...@us...> - 2001-04-11 01:39:28
|
Update of /cvsroot/corelinux/clfw/src/libs/Persist
In directory usw-pr-cvs1:/tmp/cvs-serv11136/src/libs/Persist
Modified Files:
SchemaCatalog.cpp
Log Message:
Getting ready for gdbm in the schema catalog implementation
Index: SchemaCatalog.cpp
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/Persist/SchemaCatalog.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** SchemaCatalog.cpp 2001/04/10 21:17:50 1.3
--- SchemaCatalog.cpp 2001/04/11 01:39:25 1.4
***************
*** 25,28 ****
--- 25,32 ----
#endif
+ #if !defined(__ONTOLOGY_HPP)
+ #include <clfw/Ontology.hpp>
+ #endif
+
#if !defined(__SCHEMACATALOG_HPP)
#include INCL_SchemaCatalog
***************
*** 33,36 ****
--- 37,44 ----
#endif
+ #if !defined(__ATTRIBUTE_HPP)
+ #include <clfw/Attribute.hpp>
+ #endif
+
#if !defined(__SETCOLLECTION_HPP)
#include <clfw/SetCollection.hpp>
***************
*** 55,70 ****
// Property constants
! const FrameworkString nameKey("Name");
! const FrameworkString locationKey("Location");
! const FrameworkString collectionType("Collection");
! const FrameworkString guidKey("GUID");
// Environmental constants
! const FrameworkString homeEnviron("HOME");
! const FrameworkString catEnviron("CLFW++HOME");
! const FrameworkString catLocation("/.clfw++");
! const FrameworkString schemaLocation("/schemas");
! const FrameworkString catName("schemcat");
//
--- 63,79 ----
// Property constants
! static FrameworkString nameKey("Name");
! static FrameworkString locationKey("Location");
! static FrameworkString collectionType("Collection");
! static FrameworkString guidKey("GUID");
// Environmental constants
! const FrameworkString homeEnviron("HOME");
! const FrameworkString catEnviron("CLFW++HOME");
! const FrameworkString catLocation("/.clfw++");
! const FrameworkString schemaLocation("/schemas");
! const FrameworkString catName("schemcat");
! const FrameworkString defCollection("SetCollection");
//
***************
*** 137,143 ****
//
! void SchemaCatalog::createEntry( CollectionPtr )
{
}
--- 146,205 ----
//
! void SchemaCatalog::createEntry( CollectionPtr aCollection )
{
+ CollectionPtr aSchemaCol( NULLPTR );
+ FrameworkString aUid;
+
+ //
+ // Deal with the name first
+ //
+
+ FrameworkStringPtr aName
+ (
+ this->resolveValueAssignment(aCollection,&nameKey)
+ );
+
+ if( aName == NULLPTR )
+ {
+ throw NullPointerException( LOCATION );
+ }
+ else
+ {
+ ; // do nothing
+ }
+
+ //
+ // Get the collection instance
+ //
+
+ aSchemaCol = this->resolveCollectionAssignment(aCollection);
+
+ //
+ // Get unique identifier for schema
+ //
+
+ aUid = this->resolveUuidAssignment(aCollection);
+ //
+ // Create and assign name and collection
+ //
+
+ SchemaPtr aSchema = this->createSchema( aUid, *aName, aSchemaCol );
+
+ //
+ // Serialize the first part to the location
+ //
+
+ this->saveSchema( aSchema );
+
+ //
+ // Make the catalog entry and persist
+ //
+
+ //
+ // Get rid of the Schema
+ //
+
+ Schema::destroy( aSchema );
}
***************
*** 182,199 ****
SchemaPtr SchemaCatalog::createSchema
(
! FrameworkStringCref aKey,
! FrameworkStringCref aName,
! FrameworkStringCref aLocation
) throw ()
{
! SchemaPtr aSchm( NULLPTR );
return aSchm;
}
//
// Setup environmental information for this caller
//
! void SchemaCatalog::resolveLocations( void )
{
//
--- 244,375 ----
SchemaPtr SchemaCatalog::createSchema
(
! FrameworkStringCref aKey,
! FrameworkStringCref aName,
! CollectionPtr aCollection
) throw ()
{
! SchemaPtr aSchm( Schema::create() );
! AttributePtr anAttribute( Attribute::create() );
! UniversalIdentifier aSchmId( aKey.getValue() );
!
! anAttribute->setKey( new FrameworkString(nameKey) );
! anAttribute->setValue( new FrameworkString(aName) );
!
!
! aSchm->setOid( aSchmId );
! aSchm->setProperties( aCollection );
! aSchm->addAttribute( anAttribute );
!
return aSchm;
}
//
+ // Pull and resolve uuid assignment
+ //
+
+ FrameworkString SchemaCatalog::resolveUuidAssignment
+ (
+ CollectionPtr aCollection
+ )
+ {
+ FrameworkString aUid;
+ FrameworkStringPtr aResult
+ (
+ this->resolveValueAssignment(aCollection,&guidKey)
+ );
+
+ if( aResult != NULLPTR )
+ {
+ aUid = *aResult;
+ }
+ else
+ {
+ UniversalIdentifier aUUID;
+ UniversalIdentifier::setNewUid( aUUID );
+ Char buffer[40];
+ aUUID.getAsString( buffer );
+ aUid = buffer;
+ }
+ return aUid;
+ }
+
+ CollectionPtr SchemaCatalog::resolveCollectionAssignment
+ (
+ CollectionPtr aCollection
+ )
+ {
+ MetaClassPtr aClass( NULLPTR );
+ FrameworkEntityPtr aPtr( NULLPTR );
+
+ FrameworkStringPtr aResult
+ (
+ this->resolveValueAssignment(aCollection,&collectionType)
+ );
+
+ //
+ // Use the supplied or our default set collection
+ //
+
+ if( aResult != NULLPTR )
+ {
+ aClass = Ontology::getClassFor( aResult->getValue() );
+ }
+ else
+ {
+ aClass = Ontology::getClassFor( defCollection.getValue() );
+ }
+
+ //
+ // Instantiate it
+ //
+
+ aClass->dispatch( "Construct" , (void **)NULLPTR,(void *)&aPtr );
+ if( aPtr == NULLPTR )
+ {
+ throw NullPointerException( LOCATION );
+ }
+ else
+ {
+ ; // do nothing
+ }
+
+ return Collection::castDown( aPtr );
+ }
+
+ //
+ // Little workhorse
+ //
+
+ FrameworkStringPtr SchemaCatalog::resolveValueAssignment
+ (
+ CollectionPtr aCollection,
+ FrameworkStringPtr aValue
+ )
+ {
+ FrameworkStringPtr aResult(NULLPTR);
+ Attribute aQueryAttr;
+ ElementIndex anIndex(-1);
+
+ aQueryAttr.setKey( aValue );
+ AttributePtr aAttr( NULLPTR );
+
+ if( ( anIndex = aCollection->indexOf( &aQueryAttr ) ) >= 0 )
+ {
+ aAttr = Attribute::castDown(aCollection->getElementAt( anIndex ));
+ aResult = FrameworkString::castDown( aAttr->getValue() );
+ }
+ else
+ {
+ ; // do nothing
+ }
+
+ return aResult;
+ }
+
+ //
// Setup environmental information for this caller
//
! void SchemaCatalog::resolveLocations( void )
{
//
|