|
From: Frank V. C. <fr...@us...> - 2001-04-25 03:27:25
|
Update of /cvsroot/corelinux/clfw/src/libs/Persist
In directory usw-pr-cvs1:/tmp/cvs-serv12882/src/libs/Persist
Modified Files:
SchemaAbstractStore.cpp SchemaCatStore.cpp SchemaCatalog.cpp
SchemaStore.cpp
Log Message:
Fully functional schema management, work continues on cleanup and example completion
Index: SchemaAbstractStore.cpp
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/Persist/SchemaAbstractStore.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** SchemaAbstractStore.cpp 2001/04/22 14:30:51 1.4
--- SchemaAbstractStore.cpp 2001/04/25 03:27:22 1.5
***************
*** 137,140 ****
--- 137,150 ----
//
+ // Remove a block
+ //
+
+ void SchemaAbstractStore::removeDesc( CharPtr aKey )
+ {
+ REQUIRE( theHandle != NULLPTR );
+ datum key ={aKey, strlen(aKey)+1};
+ gdbm_delete((GDBM_FILE)theHandle,key);
+ }
+ //
// Update the toc record
//
Index: SchemaCatStore.cpp
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/Persist/SchemaCatStore.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** SchemaCatStore.cpp 2001/04/22 14:30:51 1.6
--- SchemaCatStore.cpp 2001/04/25 03:27:22 1.7
***************
*** 339,344 ****
//
! void SchemaCatStore::remove( CollectionPtr )
{
}
--- 339,363 ----
//
! void SchemaCatStore::remove( CollectionPtr aCollection )
{
+ REQUIRE( aCollection != NULLPTR );
+ SchemaStore *aPtr( NULLPTR );
+ Counter maxCnt( aCollection->getSize() );
+ Char aBuffer[37];
+ SchemaDataDescriptor aSd;
+
+ for( Counter x = 0; x < maxCnt; ++x )
+ {
+ aPtr = SchemaStore::castDown( aCollection->getElementAt(x) );
+ aPtr->getSchemaUid().getAsString( aBuffer );
+ if( SchemaAbstractStore::hasKey( aBuffer ) == true )
+ {
+ SchemaAbstractStore::removeDesc( aBuffer );
+ }
+ else
+ {
+ ; // do nothing
+ }
+ }
}
Index: SchemaCatalog.cpp
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/Persist/SchemaCatalog.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** SchemaCatalog.cpp 2001/04/22 14:30:51 1.10
--- SchemaCatalog.cpp 2001/04/25 03:27:22 1.11
***************
*** 57,60 ****
--- 57,64 ----
#endif
+ #if !defined(__DESCRIPTORNOTFOUND_HPP)
+ #include <clfw/DescriptorNotFound.hpp>
+ #endif
+
extern "C"
{
***************
*** 339,343 ****
AttributePtr aAttr( Attribute::create() );
FrameworkStringPtr aKey( FrameworkString::create() );
! aKey->setValue( aName->getValue() );
aAttr->setKey( aKey );
aAttr->setValue( aStore );
--- 343,347 ----
AttributePtr aAttr( Attribute::create() );
FrameworkStringPtr aKey( FrameworkString::create() );
! *aKey = aName->getValue();
aAttr->setKey( aKey );
aAttr->setValue( aStore );
***************
*** 367,370 ****
--- 371,455 ----
REQUIRE( aCollection != NULLPTR );
+ //
+ // Check for instance based on name or uuid
+ //
+
+ FrameworkStringPtr aName
+ (
+ Store::resolveValueAssignment(aCollection,&Store::getNameKey())
+ );
+
+ if( aName != NULLPTR )
+ {
+ Attribute srchAttr;
+ ElementIndex index;
+
+ srchAttr.setKey(aName);
+
+ if( ( index = theSchemas.indexOf( &srchAttr ) ) >= 0 )
+ {
+ AttributePtr anEntry
+ (
+ Attribute::castDown( theSchemas.getElementAt( index ) )
+ );
+
+ SchemaStorePtr aSchStore
+ (
+ SchemaStore::castDown( anEntry->getValue() )
+ );
+
+ //
+ // Delete the store
+ //
+
+ aSchStore->close();
+
+ FrameworkString aBase( aSchStore->getLocation() );
+ aBase += "/";
+ aBase += aSchStore->getName();
+ Int results(0);
+
+ //
+ // If we can unlink the file, we remove the in memory
+ // reference as well as the entry from the CatalogStore
+ //
+
+ if( (results = Environment::removeCommonAccess( aBase.getValue() ) ) == 0 )
+ {
+ Array anArray;
+
+ anArray.put( aSchStore );
+
+ theSchemas.remove( anEntry );
+ theCatalog->remove( &anArray );
+
+ FrameworkString::destroy
+ (
+ FrameworkString::castDown( anEntry->getKey() )
+ );
+
+ SchemaStore::destroy( aSchStore );
+ Attribute::destroy( anEntry );
+ }
+ else
+ {
+ cerr << "Return from remove = " << results << endl;
+ }
+
+ //
+ // Remove catalog entry
+ //
+
+ }
+ else
+ {
+ ; // return null, not found
+ }
+ }
+ else
+ {
+
+ }
+
}
***************
*** 422,431 ****
//
! // Save the schema
//
! void SchemaCatalog::saveSchema( SchemaPtr )
{
}
--- 507,568 ----
//
! // Save the schemas identified in the collection
! // Assumes that the object in the collection is a schema
! // pointer
//
! void SchemaCatalog::saveEntries( CollectionPtr aCollection )
{
+ REQUIRE( aCollection != NULLPTR );
+
+ SchemaPtr aPtr( NULLPTR );
+ SchemaStorePtr aSchemaStore( NULLPTR );
+
+ for( Counter entries=0; entries < aCollection->getSize(); ++entries )
+ {
+ aPtr = Schema::castDown( aCollection->getElementAt(entries) );
+ //
+ // Resolve the store that handles
+ // this schema
+ //
+
+ Counter maxCnt( theSchemas.getSize() );
+
+ for( Counter x = 0; x < maxCnt; ++x )
+ {
+ AttributePtr anAttribute
+ (
+ Attribute::castDown
+ (
+ theSchemas.getElementAt(x)
+ )
+ );
+
+ aSchemaStore = SchemaStore::castDown( anAttribute->getValue() );
+ if( aSchemaStore->getSchemaUid() == aPtr->getOid() )
+ {
+ x = maxCnt;
+ }
+ else
+ {
+ aSchemaStore = NULLPTR;
+ }
+ }
+
+ //
+ // Close the schema but retain the store
+ //
+
+ if( aSchemaStore != NULLPTR )
+ {
+ aSchemaStore->write(NULLPTR);
+ }
+ else
+ {
+ throw DescriptorNotFound( LOCATION );
+
+ }
+ }
}
***************
*** 434,440 ****
//
! void SchemaCatalog::closeSchema( SchemaPtr )
{
}
--- 571,626 ----
//
! void SchemaCatalog::closeEntries( CollectionPtr aCollection )
{
+ REQUIRE( aCollection != NULLPTR );
+
+ SchemaPtr aPtr( NULLPTR );
+ SchemaStorePtr aSchemaStore( NULLPTR );
+ for( Counter entries=0; entries < aCollection->getSize(); ++entries )
+ {
+ aPtr = Schema::castDown( aCollection->getElementAt(entries) );
+ //
+ // Resolve the store that handles
+ // this schema
+ //
+
+ Counter maxCnt( theSchemas.getSize() );
+
+ for( Counter x = 0; x < maxCnt; ++x )
+ {
+ AttributePtr anAttribute
+ (
+ Attribute::castDown
+ (
+ theSchemas.getElementAt(x)
+ )
+ );
+
+ aSchemaStore = SchemaStore::castDown( anAttribute->getValue() );
+ if( aSchemaStore->getSchemaUid() == aPtr->getOid() )
+ {
+ x = maxCnt;
+ }
+ else
+ {
+ aSchemaStore = NULLPTR;
+ }
+ }
+
+ //
+ // Close the schema but retain the store
+ //
+
+ if( aSchemaStore != NULLPTR )
+ {
+ aSchemaStore->close();
+ }
+ else
+ {
+ throw DescriptorNotFound( LOCATION );
+
+ }
+ }
}
Index: SchemaStore.cpp
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/Persist/SchemaStore.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** SchemaStore.cpp 2001/04/22 14:30:51 1.5
--- SchemaStore.cpp 2001/04/25 03:27:22 1.6
***************
*** 19,22 ****
--- 19,67 ----
*/
+ /*
+ The management of information layout has the following model:
+
+ Schema(Uid)-> Collection(Uid),
+ CollectionClass(Uid),
+ Size(Dword)
+
+ Collection(Uid)-> Concept(Uid)[0],
+ ConceptClass(Uid)[0],
+ ConceptCollection(Uid)[0],
+ ConceptCollectionClass(Uid)[0],
+ ConceptCollectionSize(Dword)[0],
+ ...
+ Concept(Uid)[Size-1]
+ ConceptClass(Uid)[Size-1],
+ ConceptCollection(Uid)[Size-1],
+ ConceptCollectionClass(Uid)[Size-1],
+ ConceptCollectionSize(Dword)[Size-1]
+
+ ConceptCollection(Uid)-> Attribute(Uid)[0],
+ AttributeClass(Uid)[0],
+ Attribute(Uid)[ConceptCollectionSize-1]
+ AttributeClass(Uid)[ConceptCollectionSize-1]
+
+ AttributeClass(Uid)[0]-> Key(Uid),
+ KeyClass(Uid),
+ Value(Uid),
+ ValueClass(Uid)
+
+ Key(Uid)-> FrameworkEntity(Uid) | zeroOid,
+ CountOfValues(Dword),
+ SizeOf(Dword)[0],
+ Data(variable)[0],
+ ...
+ SizeOf(Dword)[CountOfValues-1],
+ Data(variable)[CountOfValues-1]
+
+ Value(Uid)->FrameworkEntity(Uid) | zeroOid,
+ CountOfValues(Dword),
+ SizeOf(Dword)[0],
+ Data(variable)[0],
+ ...
+ SizeOf(Dword)[CountOfValues-1],
+ Data(variable)[CountOfValues-1],
+ */
#define PERSIST_FRAMEWORK
***************
*** 66,70 ****
--- 111,131 ----
DECLARE_TYPE( struct __SchemaStoreDesc, SchemaDesc );
+ typedef struct __ConceptDesc
+ {
+ UniqueId conceptOid;
+ UniqueId conceptClass;
+ UniqueId conceptColOid;
+ UniqueId conceptColClass;
+ Dword conceptColSize;
+ } ConceptDesc, *ConceptDescPtr;
+
+ typedef struct __AttrDesc
+ {
+ UniqueId attrOid;
+ UniqueId attrClass;
+ } AttrDesc,*AttrDescPtr;
+
const FrameworkString schemaMode("Write");
+ const FrameworkString conceptNameKey("Name");
//
***************
*** 104,107 ****
--- 165,191 ----
SchemaStore::~SchemaStore( void )
{
+ if( theSchema != NULLPTR )
+ {
+ CollectionPtr aCol(theSchema->getProperties());
+ MetaClassPtr aClass
+ ( Ontology::getClassFor
+ (
+ aCol->getType()->getIdentifier()
+ )
+ );
+ aClass->dispatch(aCol, "Destruct" , NULLPTR, NULLPTR );
+ aClass = Ontology::getClassFor
+ (
+ theSchema->getType()->getIdentifier()
+ );
+ aClass->dispatch(theSchema, "Destruct" , NULLPTR, NULLPTR );
+ theSchema = NULLPTR;
+ theCreatedFlag = false;
+ }
+ else
+ {
+ ; // do nothing
+ }
+
SchemaAbstractStore::closeStore();
}
***************
*** 436,439 ****
--- 520,547 ----
{
SchemaAbstractStore::closeStore();
+ if( theSchema != NULLPTR )
+ {
+ CollectionPtr aCol(theSchema->getProperties());
+ MetaClassPtr aClass
+ ( Ontology::getClassFor
+ (
+ aCol->getType()->getIdentifier()
+ )
+ );
+ aClass->dispatch(aCol, "Destruct" , NULLPTR, NULLPTR );
+
+ aClass = Ontology::getClassFor
+ (
+ theSchema->getType()->getIdentifier()
+ );
+ aClass->dispatch(theSchema, "Destruct" , NULLPTR, NULLPTR );
+
+ theSchema = NULLPTR;
+ theCreatedFlag = false;
+ }
+ else
+ {
+ ; // do not worry
+ }
}
***************
*** 551,554 ****
--- 659,817 ----
this->updateDesc( key, ad );
+ //
+ // Now the work for writing out what the collection tells us
+ //
+
+ this->writeProperties();
+
+ }
+
+ //
+ // The work goes here. We know we have the base record which puts
+ // the collection out, now we must serialize out the information
+ //
+
+ void SchemaStore::writeProperties( void )
+ {
+ CollectionPtr aCol( theSchema->getProperties() );
+ Char key[37];
+
+ Counter aSize( aCol->getSize() );
+ SchemaDataDescriptor aCollDesc;
+ Int totalSize( sizeof(ConceptDesc) * aSize );
+ ConceptDesc *aCncPtr( NULLPTR );
+
+ aCncPtr = (ConceptDescPtr) ::new Char[ totalSize ] ;
+
+ aCollDesc.setDescriptor( totalSize,CharPtr(aCncPtr) );
+
+ for( Counter x = 0; x < aSize; ++x )
+ {
+ // First put out the attribute information
+
+ AttributePtr aAttr( Attribute::castDown( aCol->getElementAt(x) ));
+ if( aAttr->getValue()->getType()->isTypeOf( Concept::getTypeDescriptor() ) )
+ {
+ ConceptPtr aConcept( Concept::castDown( aAttr->getValue() ));
+ CollectionPtr aCollection( aConcept->getProperties() );
+
+ aCncPtr->conceptOid =
+ aConcept->getOid().getUniqueId();
+ aCncPtr->conceptClass =
+ aConcept->getType()->getIdentifier().getUniqueId();
+ aCncPtr->conceptColOid =
+ aCollection->getOid().getUniqueId();
+ aCncPtr->conceptColClass =
+ aCollection->getType()->getIdentifier().getUniqueId();
+ aCncPtr->conceptColSize = aCollection->getSize();
+
+ ++aCncPtr;
+ this->writeConceptProperties( aCollection );
+ }
+ else
+ {
+ throw DescriptorNotFound( LOCATION );
+ }
+ }
+ aCol->getOid().getAsString( key );
+ this->updateDesc( key, aCollDesc );
+ }
+
+ void SchemaStore::writeConceptProperties( CollectionPtr aPtr )
+ {
+ Char key[37];
+ Counter aSize( aPtr->getSize() );
+ SchemaDataDescriptor aCollDesc;
+ Int totalSize( sizeof(AttrDesc) * aSize );
+ AttrDesc *aAttrPtr( NULLPTR );
+
+ aAttrPtr = (AttrDescPtr) ::new Char[ totalSize ] ;
+
+ aCollDesc.setDescriptor( totalSize,CharPtr(aAttrPtr) );
+
+ //
+ // For every element in the property, we have two ids
+ // which are put out:
+ // Attribute uid
+ // Attribute classid
+ //
+
+ for( Counter x = 0; x < aSize; ++x )
+ {
+ FrameworkEntityPtr aEnt( aPtr->getElementAt(x) );
+ aAttrPtr->attrOid = aEnt->getOid().getUniqueId();
+ aAttrPtr->attrClass = aEnt->getType()->getIdentifier().getUniqueId();
+ ++aAttrPtr;
+ this->writeAttribute( aEnt );
+ }
+
+ aPtr->getOid().getAsString( key );
+ this->updateDesc( key, aCollDesc );
+ }
+
+ void SchemaStore::writeAttribute( FrameworkEntityPtr aPtr )
+ {
+ AttributePtr anAtt( Attribute::castDown( aPtr ) );
+ Char key[37];
+ SchemaDataDescriptor aAttDesc;
+ UniqueIdPtr aUidPtr( ::new UniqueId[4] );
+ FrameworkEntityPtr aEntityPtr( NULLPTR );
+
+ aAttDesc.setDescriptor( sizeof(UniqueId)*4,CharPtr(aUidPtr) );
+
+ // Get the key information
+
+ aEntityPtr = anAtt->getKey();
+ *aUidPtr = aEntityPtr->getOid().getUniqueId();
+ aUidPtr++;
+ *aUidPtr = aEntityPtr->getType()->getIdentifier().getUniqueId();
+ aUidPtr++;
+
+ this->writeEntity( aEntityPtr );
+
+ // Get the value information
+
+ aEntityPtr = anAtt->getValue();
+ *aUidPtr = aEntityPtr->getOid().getUniqueId();
+ aUidPtr++;
+ *aUidPtr = aEntityPtr->getType()->getIdentifier().getUniqueId();
+
+ this->writeEntity( aEntityPtr );
+
+ anAtt->getOid().getAsString( key );
+ this->updateDesc( key, aAttDesc );
+
+ }
+
+ //
+ // Right now we only support name value pairs, so this has
+ // to be FrameworkStrings
+ //
+
+ void SchemaStore::writeEntity( FrameworkEntityPtr aPtr )
+ {
+ FrameworkStringPtr aStr( FrameworkString::castDown( aPtr ) );
+ Char key[37];
+ SchemaDataDescriptor aEntDesc;
+ Int totalSize(sizeof(UniqueId));
+ Dword sLen( std::strlen( aStr->getValue() ) + 1 );
+
+ totalSize += sizeof(Dword)*2;
+ totalSize += sLen;
+ CharPtr aBuffer( ::new Char[totalSize] );
+
+ aEntDesc.setDescriptor( totalSize,aBuffer );
+
+ *(UniqueIdPtr(aBuffer)) = UniversalIdentifier::getZeroUid().getUniqueId();
+ aBuffer += sizeof( UniqueId );
+ *(DwordPtr(aBuffer)) = 1;
+ aBuffer += sizeof( Dword );
+ *(DwordPtr(aBuffer)) = sLen;
+ aBuffer += sizeof( Dword );
+ std::strcpy( aBuffer, aStr->getValue() );
+
+ aStr->getOid().getAsString( key );
+ this->updateDesc( key, aEntDesc );
+
}
***************
*** 567,570 ****
--- 830,834 ----
FrameworkEntityPtr aPtr( NULLPTR );
SchemaPtr aScm( NULLPTR );
+ Counter aSize(0);
MetaClassPtr aClass( Ontology::getClassFor( theSchemaClassId ) );
***************
*** 633,637 ****
UniversalIdentifier aColClass;
SchemaDataDescriptorPtr aD;
- Counter aSize(0);
aD = SchemaDataDescriptor::castDown( aResult->getElementAt(0) );
--- 897,900 ----
***************
*** 667,670 ****
--- 930,948 ----
aCollection->setOid( aCID );
aScm->setProperties( Collection::castDown( aCollection ) );
+
+ //
+ // The schema is now ready to read in the rest of the
+ // goods, if it has any
+ //
+
+ if( aSize != 0 )
+ {
+ this->readProperties( aScm, aSize );
+ }
+ else
+ {
+ ; // do nothing
+ }
+
}
***************
*** 672,675 ****
--- 950,1312 ----
}
+ void SchemaStore::readProperties( SchemaPtr aScm, CounterCref aSize )
+ {
+ Char key[37];
+ Array anArray;
+ FrameworkString aKey;
+
+ aScm->getProperties()->getOid().getAsString(key);
+
+ aKey = key;
+ anArray.put(&aKey);
+ CollectionPtr aResult( this->read(&anArray) );
+
+ if( aResult->getSize() == 1 )
+ {
+ SchemaDataDescriptorPtr aD =
+ SchemaDataDescriptor::castDown( aResult->getElementAt(0) );
+
+ //
+ // The size of the buffer represents the structures of
+ // concept descriptors saved with the model
+ //
+
+ if( ( aD->getBufferSize() / (Int)sizeof(ConceptDesc) ) == aSize )
+ {
+ ConceptDesc *aCncPtr( NULLPTR );
+
+ aCncPtr = ConceptDescPtr(aD->getBuffer());
+ for( Counter x = 0; x < aSize; ++x , ++aCncPtr )
+ {
+ FrameworkEntityPtr aConcept( NULLPTR );
+ FrameworkEntityPtr aCollection( NULLPTR );
+
+ //
+ // Construct the concept
+ //
+
+ MetaClassPtr aClass
+ (
+ Ontology::getClassFor( aCncPtr->conceptClass )
+ );
+
+ aClass->dispatch
+ (
+ "Construct" ,
+ (void **)NULLPTR,
+ (void *)&aConcept
+ );
+
+ //
+ // Construct the concept collection
+ //
+
+ aClass =
+ (
+ Ontology::getClassFor( aCncPtr->conceptColClass )
+ );
+
+ aClass->dispatch
+ (
+ "Construct" ,
+ (void **)NULLPTR,
+ (void *)&aCollection
+ );
+
+ if( aConcept != NULLPTR && aCollection != NULLPTR )
+ {
+ aConcept->setOid( aCncPtr->conceptOid );
+ aCollection->setOid( aCncPtr->conceptColOid );
+
+ //
+ // Build the concept and store in
+ // the schema
+ //
+
+ try
+ {
+ aScm->addAttribute
+ (
+ this->readConcept
+ (
+ Concept::castDown( aConcept ),
+ Collection::castDown( aCollection ),
+ Counter(aCncPtr->conceptColSize)
+ )
+ );
+ }
+ catch( NullPointerExceptionRef aNPEx )
+ {
+ this->returnReadCollection( aResult );
+ throw aNPEx;
+ }
+ }
+ else
+ {
+ this->returnReadCollection( aResult );
+ throw NullPointerException( LOCATION );
+ }
+ }
+ this->returnReadCollection( aResult );
+ }
+ else
+ {
+ this->returnReadCollection( aResult );
+ throw NullPointerException( LOCATION );
+ }
+ }
+ else
+ {
+ this->returnReadCollection( aResult );
+ throw NullPointerException( LOCATION );
+ }
+ }
+
+
+ AttributePtr SchemaStore::readConcept
+ (
+ ConceptPtr aConcept,
+ CollectionPtr aCollection,
+ CounterCref aSize
+ )
+ {
+ AttributePtr aCncAtt( NULLPTR );
+ Char key[37];
+ Array anArray;
+ FrameworkString aKey;
+
+ aConcept->setProperties( aCollection );
+ aCollection->getOid().getAsString(key);
+
+ aKey = key;
+ anArray.put(&aKey);
+ CollectionPtr aResult( this->read(&anArray) );
+
+ if( aResult->getSize() == 1 )
+ {
+ SchemaDataDescriptorPtr aD =
+ SchemaDataDescriptor::castDown( aResult->getElementAt(0) );
+
+ //
+ // The size of the buffer represents the structures of
+ // attribute descriptors saved with the model
+ //
+
+ if( ( aD->getBufferSize() / (Int)sizeof(AttrDesc) ) == aSize )
+ {
+ AttrDesc *aAttrPtr( NULLPTR );
+
+ aAttrPtr = AttrDescPtr(aD->getBuffer());
+
+ for( Counter x = 0; x < aSize; ++x , ++aAttrPtr )
+ {
+ FrameworkEntityPtr aAtt( NULLPTR );
+
+ //
+ // Construct the concept
+ //
+
+ MetaClassPtr aClass
+ (
+ Ontology::getClassFor( aAttrPtr->attrClass )
+ );
+
+ aClass->dispatch
+ (
+ "Construct" ,
+ (void **)NULLPTR,
+ (void *)&aAtt
+ );
+
+ if( aAtt != NULLPTR )
+ {
+ aAtt->setOid( aAttrPtr->attrOid );
+ this->readAttribute( Attribute::castDown( aAtt ) );
+ aCollection->put(aAtt);
+ }
+ else
+ {
+ this->returnReadCollection( aResult );
+ throw NullPointerException( LOCATION );
+ }
+ }
+ this->returnReadCollection( aResult );
+ }
+ else
+ {
+ this->returnReadCollection( aResult );
+ throw NullPointerException( LOCATION );
+ }
+ }
+ else
+ {
+ this->returnReadCollection( aResult );
+ throw NullPointerException( LOCATION );
+ }
+
+ /*
+ Counter maxCnt( aCollection->getSize() );
+ for( Counter x = 0; x < maxCnt; ++x )
+ {
+ AttributePtr aPtr( Attribute::castDown( aCollection->getElementAt(x) ));
+ FrameworkStringPtr aS( FrameworkString::castDown(aPtr->getKey()) );
+ cout << "Read [" << aS->getValue() << "] = ";
+ aS = FrameworkString::castDown(aPtr->getValue());
+ cout << aS->getValue() << endl;
+ }
+ */
+ FrameworkStringPtr cncKey
+ (
+ Store::resolveValueAssignment
+ (
+ aCollection,
+ FrameworkStringPtr(&Store::getNameKey())
+ )
+ );
+
+ if( cncKey != NULLPTR )
+ {
+ aCncAtt = Attribute::create();
+ aCncAtt->setKey( cncKey );
+ aCncAtt->setValue( aConcept );
+ }
+ else
+ {
+ throw NullPointerException( LOCATION );
+ }
+
+ return aCncAtt;
+ }
+
+ void SchemaStore::readAttribute( AttributePtr aAtt )
+ {
+ Char key[37];
+ Array anArray;
+ FrameworkString aKey;
+
+ aAtt->getOid().getAsString(key);
+
+ aKey = key;
+ anArray.put(&aKey);
+ CollectionPtr aResult( this->read(&anArray) );
+
+ if( aResult->getSize() == 1 )
+ {
+ SchemaDataDescriptorPtr aD =
+ SchemaDataDescriptor::castDown( aResult->getElementAt(0) );
+
+ //
+ // The size of the buffer represents the structures of
+ // attribute descriptors saved with the model
+ //
+
+ if( aD->getBufferSize() == (Int)((sizeof(AttrDesc))*2) )
+ {
+ AttrDescPtr aEdesc( AttrDescPtr(aD->getBuffer()) );
+
+ try
+ {
+ aAtt->setKey
+ (
+ this->readEntity
+ (
+ aEdesc->attrOid,
+ aEdesc->attrClass
+ )
+ );
+
+ ++aEdesc;
+
+ aAtt->setValue
+ (
+ this->readEntity
+ (
+ aEdesc->attrOid,
+ aEdesc->attrClass
+ )
+ );
+
+ this->returnReadCollection( aResult );
+ }
+ catch( NullPointerExceptionRef aNPExcp )
+ {
+ this->returnReadCollection( aResult );
+ throw NullPointerException( LOCATION );
+ }
+ }
+ else
+ {
+ this->returnReadCollection( aResult );
+ throw NullPointerException( LOCATION );
+ }
+ }
+ else
+ {
+ this->returnReadCollection( aResult );
+ throw NullPointerException( LOCATION );
+ }
+
+ }
+
+ FrameworkEntityPtr SchemaStore::readEntity
+ (
+ UniversalIdentifierCref aOid,
+ UniversalIdentifierCref aClassOid
+ )
+ {
+ FrameworkEntityPtr aEntity( NULLPTR );
+
+ // Process the object
+
+ MetaClassPtr aClass
+ (
+ Ontology::getClassFor( aClassOid )
+ );
+
+ aClass->dispatch
+ (
+ "Construct" ,
+ (void **)NULLPTR,
+ (void *)&aEntity
+ );
+
+ if( aEntity != NULLPTR )
+ {
+ aEntity->setOid( aOid );
+
+ Char key[37];
+ Array anArray;
+ FrameworkString aKey;
+
+ aOid.getAsString(key);
+
+ aKey = key;
+ anArray.put(&aKey);
+ CollectionPtr aResult( this->read(&anArray) );
+ if( aResult->getSize() == 1 )
+ {
+ SchemaDataDescriptorPtr aD =
+ SchemaDataDescriptor::castDown( aResult->getElementAt(0) );
+
+ CharPtr aBuf( aD->getBuffer() );
+ aBuf += sizeof( UniqueId );
+ aBuf += sizeof( Dword );
+ aBuf += sizeof( Dword );
+ *( FrameworkString::castDown( aEntity )) = aBuf;
+ this->returnReadCollection( aResult );
+ }
+ else
+ {
+ this->returnReadCollection( aResult );
+ throw NullPointerException( LOCATION );
+ }
+ }
+ else
+ {
+ throw NullPointerException( LOCATION );
+ }
+
+ return aEntity;
+ }
//
|