// Look up a schema based on site, histology and an optional discriminator.
        // @param lookup schema lookup input
        // @return a list of StagingSchemaInfo objects
        public List <StagingSchema> lookupSchema(SchemaLookup lookup)
        {
            List <StagingSchema> lstRetval = null;

            // If doing a more broad lookup without giving both site and histology, do not use the cache.  I don't want to cache
            // since the results could include all the data
            if (lookup.getSite() == null || lookup.getHistology() == null)
            {
                return(getSchemas(lookup));
            }


            // Dictionary for cache.
            String sIDString = lookup.GetHashString();


            if (!mLookupMemoryDict.TryGetValue(sIDString, out lstRetval))
            {
                if (miLookupMemoryDictCount > NUM_ITEMS_IN_CACHE_CAUSES_TRIM)
                {
                    mLookupMemoryDict.Clear();
                    Interlocked.Exchange(ref miLookupMemoryDictCount, 0);
                }

                lstRetval = getSchemas(lookup);

                if (mLookupMemoryDict.TryAdd(sIDString, lstRetval))
                {
                    Interlocked.Increment(ref miLookupMemoryDictCount);
                }
            }

            return(lstRetval);
        }
        // Look up a schema based on site, histology and an optional discriminator.
        // @param lookup schema lookup input
        // @return a list of StagingSchemaInfo objects
        private List <StagingSchema> getSchemas(SchemaLookup lookup)
        {
            List <StagingSchema> matchedSchemas = new List <StagingSchema>(5);

            String site             = lookup.getInput(StagingData.PRIMARY_SITE_KEY);
            String histology        = lookup.getInput(StagingData.HISTOLOGY_KEY);
            bool   hasDiscriminator = lookup.hasDiscriminator();

            // site or histology must be supplied and they must be valid; I am assuming that all algorithms must have tables that validate
            // both site and histology
            if ((site != null && !isValidSite(site)) || (histology != null && !isValidHistology(histology)))
            {
                return(matchedSchemas);
            }

            // searching on a discriminator is only supported if also searching on site and histology; if ssf25 supplied without either
            // of those fields, return no results
            if (hasDiscriminator && (site == null || (site.Length == 0) || histology == null || (histology.Length == 0)))
            {
                return(matchedSchemas);
            }

            // site or histology must be supplied
            if (site != null || histology != null)
            {
                HashSet <String> lstSchemaIds = getSchemaIds();

                // loop over selection table and match using only the supplied keys
                foreach (String schemaId in lstSchemaIds)
                {
                    StagingSchema schema = (StagingSchema)(getDefinition(schemaId));

                    if (schema.getSchemaSelectionTable() != null)
                    {
                        StagingTable table = (StagingTable)(getTable(schema.getSchemaSelectionTable()));
                        if (table != null && DecisionEngineFuncs.matchTable(table, lookup.getInputs(), lookup.getKeys()) != null)
                        {
                            matchedSchemas.Add(schema);
                        }
                    }
                }
            }

            return(matchedSchemas);
        }
예제 #3
0
 // Look up a schema based on site, histology and an optional discriminator.
 // @param lookup schema lookup input
 // @return a list of StagingSchema objects
 public List <StagingSchema> lookupSchema(SchemaLookup lookup)
 {
     return(_provider.lookupSchema(lookup));
 }