UPDATE xval_cross_validator SET oid=NULL WHERE oid=((SELECT preference_value from cmn_application_preference where preference_name = 'root_oid')||(SELECT preference_value FROM cmn_application_preference WHERE preference_name LIKE 'x_validator_definition_oid_suffix'))|| id;

DELETE FROM cmn_application_preference WHERE preference_name = 'x_validator_definition_oid_suffix';

UPDATE xval_cross_validator SET oid=(SELECT preference_value from cmn_application_preference WHERE preference_name='x_validator_root_oid')|| id WHERE oid IS NULL;

INSERT INTO public.evsc_calling_tool (id, label, oid, tool_type, url)
  VALUES (nextval('evsc_calling_tool_id_seq'), 'Message Content Analyzer', 'MCA', 2, 'http://localhost:8080/EVSClient/messageContentAnalyzerDetailedResult.seam?oid=');
INSERT INTO cmn_application_preference (id, class_name, description, preference_name, preference_value)
  VALUES (nextval('cmn_application_preference_id_seq'), 'java.lang.String', 'OID of the calling tool that the MCA will use to access cross validation', 'mca_tool_oid', 'MCA');

INSERT INTO mca_zip_config (id, doc_type, validation_type, archive_name, x_validator_oid) VALUES (nextval('mca_zip_config_id_seq'), 'XDM ZIP', NULL, 'IHE_XDM.zip', '2.16.840.1.113883.2.8.3.9.3.38');


INSERT INTO mca_folder_config (id, folder_name) VALUES (nextval('mca_folder_config_id_seq'), 'IHE_XDM');


INSERT INTO mca_zip_folder_children (zip_structure_id, folder_id) VALUES (currval('mca_zip_config_id_seq'), currval('mca_folder_config_id_seq'));


INSERT INTO mca_file_config (id, file_name, regex, x_val_input_type) VALUES (nextval('mca_file_config_id_seq'), 'INDEX.HTM', false, null);
INSERT INTO mca_folder_file_children (folder_id, file_child_id) VALUES (currval('mca_folder_config_id_seq'), currval('mca_file_config_id_seq'));
INSERT INTO mca_file_config (id, file_name, regex, x_val_input_type) VALUES (nextval('mca_file_config_id_seq'), 'README.TXT', false, null);
INSERT INTO mca_folder_file_children (folder_id, file_child_id) VALUES (currval('mca_folder_config_id_seq'), currval('mca_file_config_id_seq'));


INSERT INTO mca_folder_config (id, folder_name) VALUES (nextval('mca_folder_config_id_seq'), 'IHE_XDM');
INSERT INTO mca_folder_folder_children (folder_id, folder_child_id) VALUES (1, 2);

INSERT INTO mca_folder_config (id, folder_name) VALUES (nextval('mca_folder_config_id_seq'), 'SUBSET01');
INSERT INTO mca_folder_folder_children (folder_id, folder_child_id) VALUES (2, 3);

INSERT INTO mca_file_config (id, file_name, regex, x_val_input_type) VALUES (nextval('mca_file_config_id_seq'), 'METADATA.XML', false, 'MANIFEST');
INSERT INTO mca_folder_file_children (folder_id, file_child_id) VALUES (currval('mca_folder_config_id_seq'), currval('mca_file_config_id_seq'));
INSERT INTO mca_file_config (id, file_name, regex, x_val_input_type) VALUES (nextval('mca_file_config_id_seq'), '([A-Z]|[0-9]){1,8}\.XML', true, 'ATTACHMENT');
INSERT INTO mca_folder_file_children (folder_id, file_child_id) VALUES (currval('mca_folder_config_id_seq'), currval('mca_file_config_id_seq'));