Ejemplo n.º 1
0
        // Looks at all tables involved in all the mappings in the definition and returns a list of output keys that will be created.  It will also deal with mapped
        // outputs.  The outputs from each mapping will only be included if it passes the inclusion/exclusion criteria based on the context.  If the schema has StagingOutputs
        // defined, then the calulated output list is exactly the same as the schema output list.
        // @param schema a StagingSchema
        // @param context a context of values used to to check mapping inclusion/exclusion
        // @return a Set of unique output keys
        public HashSet <String> getOutputs(StagingSchema schema, Dictionary <String, String> context)
        {
            HashSet <String> outputs = new HashSet <String>();

            // if outputs are defined in the schema, then there is no reason to look any further into the mappings; the output defines exactly what keys will
            // be returned and it doesn't matter what context is passed in that case
            if (schema.getOutputMap() != null)
            {
                foreach (KeyValuePair <String, IOutput> entry in schema.getOutputMap())
                {
                    outputs.Add(entry.Key);
                }

                return(outputs);
            }

            // if outputs were not defined, then the tables involved in the mappings will be used to determine the possible outputs
            if (schema.getMappings() != null)
            {
                foreach (StagingMapping mapping in schema.getMappings())
                {
                    outputs.UnionWith(getOutputs(mapping, context));
                }
            }

            // if valid outputs are defined on the schema level, only return outputs that defined; this removed "temporary" outputs that may be defined during the
            // staging process
            if (schema.getOutputMap() != null)
            {
                outputs.RemoveWhere(entry => !schema.getOutputMap().ContainsKey(entry));
            }

            return(outputs);
        }