MgFeatureSchemaCollection* MgFeatureServiceCacheEntry::GetSchemas(CREFSTRING schemaName, MgStringCollection* classNames, bool serialized)
{
    STRING schemaKey, classKey;
    INT32 classCount = FormatKeys(m_classNameHintUsed, schemaName, classNames, schemaKey, classKey);

    Ptr<MgFeatureSchemaCollection> data;
    Ptr<MgFeatureSchemaCacheItem> item = GetFeatureSchemaCacheItem(schemaKey);

    // Get the data from the current item.
    if (NULL != item.p)
    {
        data = item->GetSchemas(classKey, serialized);
    }

    // If the data is not found, then try to find it in the superset data from the current item or superset one.
    if (NULL == data.p)
    {
        if (0 == classCount)
        {
            ACE_ASSERT(classKey.empty());
            // If there is no class, then try to find the data in the superset data from the superset item.
            data = FindSchema(schemaKey, classKey, serialized, classCount);
        }
        else if (1 == classCount)
        {
            Ptr<MgFeatureSchemaCollection> supersetData;

            // Get the superset data from the current item.
            if (NULL != item.p && !classKey.empty())
            {
                supersetData = item->GetSchemas(L"", serialized);
            }

            // If the data is not found, then try to find it in the superset data from the superset item.
            if (NULL == supersetData.p)
            {
                data = FindSchema(schemaKey, classKey, serialized, classCount);
            }
            // Otherwise, determine if the superset data from the current item is reusable.
            else if (FindClass(supersetData.p, classKey))
            {
                data = supersetData;
            }
        }

        // Update the cache with the found data.
        if (NULL != data.p)
        {
            SetSchemas(schemaKey, classNames, serialized, data.p);
        }
    }

    return data.Detach();
}
Exemple #2
0
void CSchemaCombo::Load(LPCTSTR pszSelectURI, int nType, int nAvailability, BOOL bReset)
{
	if ( ( GetStyle() & CBS_OWNERDRAWVARIABLE ) == 0 )
	{
		ModifyStyle( 0, CBS_OWNERDRAWVARIABLE|CBS_HASSTRINGS );
	}

	SetExtendedUI();

	m_nType			= nType;
	m_nAvailability	= nAvailability;

	if ( bReset ) ResetContent();

	if ( bReset && m_sNoSchemaText.GetLength() )
	{
		SetItemData( AddString( _T(" ") ), 0 );
		SetCurSel( 0 );
	}

	for ( POSITION pos = SchemaCache.GetIterator() ; pos ; )
	{
		CSchemaPtr pSchema = SchemaCache.GetNext( pos );

		BOOL bSelected = pSchema->CheckURI( pszSelectURI );

		if ( ! bReset )
		{
			int nIndex = FindSchema( pSchema );

			if ( nIndex >= 0 )
			{
				if ( bSelected ) SetCurSel( nIndex );
				continue;
			}
		}

		if ( ( bSelected || pSchema->m_nType == nType || nType == -1 ) &&
			 ( bSelected || pSchema->m_nAvailability <= nAvailability ) )
		{
			int nIndex = AddString( pSchema->m_sTitle );
			SetItemData( nIndex, (LPARAM)pSchema );

			if ( bSelected ) SetCurSel( nIndex );
		}
	}

	if ( bReset && nAvailability < CSchema::saMax )
	{
		SetItemData( AddString( _T("ZZZ") ), 0 );
	}
}
///////////////////////////////////////////////////////////////////////////////
/// \brief
/// Find a schema in a superset data.
///
MgFeatureSchemaCollection* MgFeatureServiceCacheEntry::FindSchema(CREFSTRING schemaKey, CREFSTRING classKey, bool serialized, INT32 classCount)
{
    Ptr<MgFeatureSchemaCollection> data;

    // If the schema key is specified, then try to find the data in the superset data from the superset item.
    if (!schemaKey.empty())
    {
        // Get the superset item.
        Ptr<MgFeatureSchemaCacheItem> supersetItem = GetFeatureSchemaCacheItem(L"");

        if (NULL != supersetItem.p)
        {
            // Get the superset data from the the superset item.
            Ptr<MgFeatureSchemaCollection> supersetData = supersetItem->GetSchemas(classKey, serialized);
            // Find the data in the superset data.
            data = FindSchema(supersetData.p, schemaKey);

            // If the data is not found and the class count is 1,
            // then try using the unqualified class name instead of.
            if (NULL == data.p && 1 == classCount)
            {
                STRING parsedSchemaName, parsedClassName;

                MgUtil::ParseQualifiedClassName(classKey, parsedSchemaName, parsedClassName);

                // Determine if the superset data from the superset item is reusable.
                if (!parsedSchemaName.empty())
                {
                    supersetData = supersetItem->GetSchemas(parsedClassName, serialized);

                    if (FindClass(supersetData.p, parsedClassName))
                    {
                        data = supersetData;
                    }
                }
            }
        }
    }

    return data.Detach();
}