// Initialize a schema. // @param schema schema entity // @return initialized schema entity public static StagingSchema initSchema(StagingSchema schema) { // parse the schema selection ranges if (schema.getSchemaSelectionTable() == null) { throw new System.InvalidOperationException("Schemas must have a schema selection table."); } // store the inputs in a Map that can searched more efficiently if (schema.getInputs() != null) { Dictionary <String, IInput> parsedInputMap = new Dictionary <String, IInput>(); foreach (StagingSchemaInput input in schema.getInputs()) { // verify that all inputs contain a key if (input.getKey() == null) { throw new System.InvalidOperationException("All input definitions must have a 'key' defined."); } parsedInputMap[input.getKey()] = input; } schema.setInputMap(parsedInputMap); } // store the outputs in a Map that can searched more efficiently if (schema.getOutputs() != null) { Dictionary <String, IOutput> parsedOutputMap = new Dictionary <String, IOutput>(); foreach (StagingSchemaOutput output in schema.getOutputs()) { // verify that all inputs contain a key if (output.getKey() == null) { throw new System.InvalidOperationException("All output definitions must have a 'key' defined."); } parsedOutputMap[output.getKey()] = output; } schema.setOutputMap(parsedOutputMap); } // make sure that the mapping initial context does not set a value for an input field if (schema.getMappings() != null) { foreach (StagingMapping mapping in schema.getMappings()) { if (mapping.getInitialContext() != null) { foreach (StagingKeyValue kv in mapping.getInitialContext()) { if (schema.getInputMap().ContainsKey(kv.getKey())) { throw new System.InvalidOperationException("The key '" + kv.getKey() + "' is defined in an initial context, but that is not allowed since it is also defined as an input."); } } } } } return(schema); }