-- to dump tf tables fror TM

-- pg_dump -f dumpp.sql --table=tf_* -U gazelle gazelle-prod

-- to update tf model on cda-generator

-- psql -U gazelle -f dumpp.sql cda-generator

--------------------

SELECT 'INSERT INTO cdagen_object_type(id, keyword, description) VALUES (' || tm_object_type.id || ',''' || tm_object_type.keyword
|| ''',''' ||  tm_object_type.description || ''');' FROM (
SELECT DISTINCT 
tm_object_type.id,
tm_object_type.keyword,
tm_object_type.instructions,
tm_object_type.description,
tm_object_type.default_desc
FROM 
tm_object_type
WHERE 
tm_object_type.id IN
	(
	SELECT DISTINCT tm_object_file.object_id 
	FROM tm_object_file
	WHERE
	tm_object_file.type_id=12
	)
) as tm_object_type;

-- psql -U gazelle -f /Users/aboufahj/Documents/workspace/CDAGenerator/CDAGenerator-ear/src/main/sql/tf-updater.sql gazelle-prod >> /Users/aboufahj/Documents/workspace/CDAGenerator/CDAGenerator-ear/src/main/sql/cda-obj-updater.sql


SELECT DISTINCT 'INSERT INTO cdagen_object_type_tf_actor_integration_profile_option(cdagen_object_type_id, actorintegrationprofileoptions_id) VALUES (' || 
				 tm_object_creator.object_id || ',' || tm_object_creator.aipo_id || ');'  
FROM tm_object_creator
WHERE
tm_object_creator.object_id IN (
	SELECT DISTINCT tm_object_file.object_id 
	FROM tm_object_file
	WHERE
	tm_object_file.type_id=12
);
