-- Name: i_arc_pipelinedata_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_pipelinedata_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:pipelineData_meta_data)(';
      FOR current_row IN SELECT * FROM arc_pipelineData_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_pipelinedata_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_pipelineparameterdata(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_pipelineparameterdata(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:pipelineParameterData)(';
      FOR current_row IN SELECT * FROM arc_pipelineParameterData WHERE  arc_pipelineparameterdata_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.schemalink IS NOT NULL) THEN 
              fullText := fullText || '(schemalink:string)=(' || REPLACE(REPLACE(current_row.schemalink,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.csvvalues IS NOT NULL) THEN 
              fullText := fullText || '(csvvalues:string)=(' || REPLACE(REPLACE(current_row.csvvalues,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.csvvalues_selected IS NOT NULL) THEN 
              fullText := fullText || '(csvvalues_selected:string)=(' || REPLACE(REPLACE(current_row.csvvalues_selected,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.description IS NOT NULL) THEN 
              fullText := fullText || '(description:string)=(' || REPLACE(REPLACE(current_row.description,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.name IS NOT NULL) THEN 
              fullText := fullText || '(name:string)=(' || REPLACE(REPLACE(current_row.name,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.multiplevalues IS NOT NULL) THEN 
              fullText := fullText || '(multiplevalues:integer)=(' || current_row.multiplevalues || ')';
          END IF;
          IF (current_row.editable IS NOT NULL) THEN 
              fullText := fullText || '(editable:integer)=(' || current_row.editable || ')';
          END IF;
          IF (current_row.batchparam IS NOT NULL) THEN 
              fullText := fullText || '(batchparam:integer)=(' || current_row.batchparam || ')';
          END IF;
        IF ((current_row.pipelineParameterData_info IS NOT NULL)) THEN
            fullText := fullText || '(pipelineparameterdata_info:integer)=(' || current_row.pipelineparameterdata_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_pipelineParameterData_meta_data(current_row.pipelineParameterData_info, child_count,$3,false,false);
              fullText := fullText || '(pipelineparameterdata_info_pipelineparameterdata_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.parameters_parameter_arc_pipeli_arc_pipelinedata_id IS NOT NULL)) THEN
            fullText := fullText || '(parameters_parameter_arc_pipeli_arc_pipelinedata_id:integer)=(' || current_row.parameters_parameter_arc_pipeli_arc_pipelinedata_id || ')';
        END IF;
          IF (current_row.arc_pipelineparameterdata_id IS NOT NULL) THEN 
              fullText := fullText || '(arc_pipelineparameterdata_id:integer)=(' || current_row.arc_pipelineparameterdata_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_pipelineparameterdata(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_pipelineparameterdata_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_pipelineparameterdata_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:pipelineParameterData_history)(';
      FOR current_row IN SELECT * FROM arc_pipelineParameterData_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.schemalink IS NOT NULL) THEN 
              fullText := fullText || '(schemalink:string)=(' || REPLACE(REPLACE(current_row.schemalink,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.csvvalues IS NOT NULL) THEN 
              fullText := fullText || '(csvvalues:string)=(' || REPLACE(REPLACE(current_row.csvvalues,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.csvvalues_selected IS NOT NULL) THEN 
              fullText := fullText || '(csvvalues_selected:string)=(' || REPLACE(REPLACE(current_row.csvvalues_selected,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.description IS NOT NULL) THEN 
              fullText := fullText || '(description:string)=(' || REPLACE(REPLACE(current_row.description,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.name IS NOT NULL) THEN 
              fullText := fullText || '(name:string)=(' || REPLACE(REPLACE(current_row.name,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.multiplevalues IS NOT NULL) THEN 
              fullText := fullText || '(multiplevalues:integer)=(' || current_row.multiplevalues || ')';
          END IF;
          IF (current_row.editable IS NOT NULL) THEN 
              fullText := fullText || '(editable:integer)=(' || current_row.editable || ')';
          END IF;
          IF (current_row.batchparam IS NOT NULL) THEN 
              fullText := fullText || '(batchparam:integer)=(' || current_row.batchparam || ')';
          END IF;
        IF ((current_row.pipelineParameterData_info IS NOT NULL)) THEN
            fullText := fullText || '(pipelineparameterdata_info:integer)=(' || current_row.pipelineparameterdata_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_pipelineParameterData_meta_data(current_row.pipelineParameterData_info, child_count,$3,false,false);
              fullText := fullText || '(pipelineparameterdata_info_pipelineparameterdata_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.parameters_parameter_arc_pipeli_arc_pipelinedata_id IS NOT NULL)) THEN
            fullText := fullText || '(parameters_parameter_arc_pipeli_arc_pipelinedata_id:integer)=(' || current_row.parameters_parameter_arc_pipeli_arc_pipelinedata_id || ')';
        END IF;
          IF (current_row.arc_pipelineparameterdata_id IS NOT NULL) THEN 
              fullText := fullText || '(arc_pipelineparameterdata_id:integer)=(' || current_row.arc_pipelineparameterdata_id || ')';
          END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_pipelineparameterdata_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_pipelineparameterdata_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_pipelineparameterdata_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:pipelineParameterData_meta_data)(';
      FOR current_row IN SELECT * FROM arc_pipelineParameterData_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_pipelineparameterdata_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_project(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_project(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:project)(';
      FOR current_row IN SELECT * FROM arc_project WHERE  arc_project_id=$1
      LOOP
           row_ct := row_ct+1;
          
        IF ((current_row.paths_arc_pathinfo_id IS NOT NULL)) THEN
            fullText := fullText || '(paths_arc_pathinfo_id:integer)=(' || current_row.paths_arc_pathinfo_id || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_pathInfo(current_row.paths_arc_pathinfo_id, child_count,$3,false,false);
              fullText := fullText || '(paths_pathinfo:XFTItem)=(' || tempText || ')';
        END IF;
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM arc_fieldSpecification WHERE fieldspecifications_fieldspecif_arc_project_id=current_row.arc_project_id ORDER BY arc_fieldspecification_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_fieldSpecification( parent_row.arc_fieldspecification_id, child_count,$3,false,false);
              fullText := fullText || '(fieldspecifications_fieldspecification_fieldspecification' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM arc_property WHERE properties_property_arc_project_arc_project_id=current_row.arc_project_id ORDER BY arc_property_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_property( parent_row.arc_property_id, child_count,$3,false,false);
              fullText := fullText || '(properties_property_property' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM arc_project_descendant WHERE pipelines_descendants_descendan_arc_project_id=current_row.arc_project_id ORDER BY arc_project_descendant_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_project_descendant( parent_row.arc_project_descendant_id, child_count,$3,false,false);
              fullText := fullText || '(pipelines_descendants_descendant_project_descendant' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM arc_project_pipeline WHERE pipelines_pipeline_arc_project_arc_project_id=current_row.arc_project_id ORDER BY arc_pipelinedata_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_project_pipeline( parent_row.arc_pipelinedata_id, child_count,$3,false,false);
              fullText := fullText || '(pipelines_pipeline_project_pipeline' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
          IF (current_row.id IS NOT NULL) THEN 
              fullText := fullText || '(id:string)=(' || REPLACE(REPLACE(current_row.id,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.current_arc IS NOT NULL) THEN 
              fullText := fullText || '(current_arc:string)=(' || REPLACE(REPLACE(current_row.current_arc,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.quarantine_code IS NOT NULL) THEN 
              fullText := fullText || '(quarantine_code:integer)=(' || current_row.quarantine_code || ')';
          END IF;
          IF (current_row.prearchive_code IS NOT NULL) THEN 
              fullText := fullText || '(prearchive_code:integer)=(' || current_row.prearchive_code || ')';
          END IF;
        IF ((current_row.project_info IS NOT NULL)) THEN
            fullText := fullText || '(project_info:integer)=(' || current_row.project_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_project_meta_data(current_row.project_info, child_count,$3,false,false);
              fullText := fullText || '(project_info_project_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.projects_project_arc_ArchiveSpe_arc_archivespecification_id IS NOT NULL)) THEN
            fullText := fullText || '(projects_project_arc_archivespe_arc_archivespecification_id:integer)=(' || current_row.projects_project_arc_archivespe_arc_archivespecification_id || ')';
        END IF;
          IF (current_row.arc_project_id IS NOT NULL) THEN 
              fullText := fullText || '(arc_project_id:integer)=(' || current_row.arc_project_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_project(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_project_descendant(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_project_descendant(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:project_descendant)(';
      FOR current_row IN SELECT * FROM arc_project_descendant WHERE  arc_project_descendant_id=$1
      LOOP
           row_ct := row_ct+1;
          
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM arc_project_descendant_pipeline WHERE arc_project_descendant_arc_project_descendant_id=current_row.arc_project_descendant_id ORDER BY arc_pipelinedata_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_project_descendant_pipeline( parent_row.arc_pipelinedata_id, child_count,$3,false,false);
              fullText := fullText || '(pipeline_project_descendant_pipeline' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
          IF (current_row.xsitype IS NOT NULL) THEN 
              fullText := fullText || '(xsitype:string)=(' || REPLACE(REPLACE(current_row.xsitype,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.project_descendant_info IS NOT NULL)) THEN
            fullText := fullText || '(project_descendant_info:integer)=(' || current_row.project_descendant_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_project_descendant_meta_data(current_row.project_descendant_info, child_count,$3,false,false);
              fullText := fullText || '(project_descendant_info_project_descendant_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.pipelines_descendants_descendan_arc_project_id IS NOT NULL)) THEN
            fullText := fullText || '(pipelines_descendants_descendan_arc_project_id:integer)=(' || current_row.pipelines_descendants_descendan_arc_project_id || ')';
        END IF;
          IF (current_row.arc_project_descendant_id IS NOT NULL) THEN 
              fullText := fullText || '(arc_project_descendant_id:integer)=(' || current_row.arc_project_descendant_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_project_descendant(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_project_descendant_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_project_descendant_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:project_descendant_history)(';
      FOR current_row IN SELECT * FROM arc_project_descendant_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM arc_project_descendant_pipeline_history WHERE arc_project_descendant_arc_project_descendant_id=current_row.arc_project_descendant_id AND xft_version=current_row.xft_version ORDER BY arc_pipelinedata_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_project_descendant_pipeline_history( parent_row.arc_pipelinedata_id, child_count,$3,false,false);
              fullText := fullText || '(pipeline_project_descendant_pipeline' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
          IF (current_row.xsitype IS NOT NULL) THEN 
              fullText := fullText || '(xsitype:string)=(' || REPLACE(REPLACE(current_row.xsitype,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.project_descendant_info IS NOT NULL)) THEN
            fullText := fullText || '(project_descendant_info:integer)=(' || current_row.project_descendant_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_project_descendant_meta_data(current_row.project_descendant_info, child_count,$3,false,false);
              fullText := fullText || '(project_descendant_info_project_descendant_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.pipelines_descendants_descendan_arc_project_id IS NOT NULL)) THEN
            fullText := fullText || '(pipelines_descendants_descendan_arc_project_id:integer)=(' || current_row.pipelines_descendants_descendan_arc_project_id || ')';
        END IF;
          IF (current_row.arc_project_descendant_id IS NOT NULL) THEN 
              fullText := fullText || '(arc_project_descendant_id:integer)=(' || current_row.arc_project_descendant_id || ')';
          END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_project_descendant_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_project_descendant_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_project_descendant_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:project_descendant_meta_data)(';
      FOR current_row IN SELECT * FROM arc_project_descendant_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_project_descendant_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_project_descendant_pipeline(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_project_descendant_pipeline(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:project_descendant_pipeline)(';
      FOR current_row IN SELECT * FROM arc_project_descendant_pipeline WHERE  arc_pipelinedata_id=$1
      LOOP
           row_ct := row_ct+1;
          
        IF ((current_row.arc_pipelinedata_id IS NOT NULL)) THEN
            fullText := fullText || '(arc_pipelinedata_id:integer)=(' || current_row.arc_pipelinedata_id || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := ie_arc_pipelineData(current_row.arc_pipelinedata_id, child_count,$3,false,false);
              fullText := fullText || '(pipelinedata_pipelinedata:XFTItem)=(' || tempText || ')';
        END IF;
          IF (current_row.stepid IS NOT NULL) THEN 
              fullText := fullText || '(stepid:string)=(' || REPLACE(REPLACE(current_row.stepid,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.dependent IS NOT NULL) THEN 
              fullText := fullText || '(dependent:integer)=(' || current_row.dependent || ')';
          END IF;
        IF ((current_row.project_descendant_pipeline_info IS NOT NULL)) THEN
            fullText := fullText || '(project_descendant_pipeline_info:integer)=(' || current_row.project_descendant_pipeline_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_project_descendant_pipeline_meta_data(current_row.project_descendant_pipeline_info, child_count,$3,false,false);
              fullText := fullText || '(project_descendant_pipeline_info_project_descendant_pipeline_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.arc_project_descendant_arc_project_descendant_id IS NOT NULL)) THEN
            fullText := fullText || '(arc_project_descendant_arc_project_descendant_id:integer)=(' || current_row.arc_project_descendant_arc_project_descendant_id || ')';
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
           child_count := child_count+1;
           tempText := NULL;
           tempText := ie_arc_pipelineData( $1, child_count,$3,$4,false);
              fullText := fullText || '(pipelinedata_pipelinedata:XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
          
      END IF;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_project_descendant_pipeline(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_project_descendant_pipeline_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_project_descendant_pipeline_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:project_descendant_pipeline_history)(';
      FOR current_row IN SELECT * FROM arc_project_descendant_pipeline_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
        IF ((current_row.arc_pipelinedata_id IS NOT NULL)) THEN
            fullText := fullText || '(arc_pipelinedata_id:integer)=(' || current_row.arc_pipelinedata_id || ')';
           child_count := child_count+1;
           tempText := NULL;
           DECLARE
           	ext_row RECORD;
           BEGIN 
           	FOR ext_row IN SELECT * FROM arc_pipelineData_history WHERE arc_pipelinedata_id=current_row.arc_pipelinedata_id AND xft_version=current_row.xft_version
           	LOOP
 -- 632
           	   tempText := ie_arc_pipelineData_history(ext_row.history_id, child_count,$3,false,false);
           	      fullText := fullText || '(pipelinedata_pipelinedata:XFTItem)=(' || tempText || ')';
           	END LOOP;
           END;
        END IF;
          IF (current_row.stepid IS NOT NULL) THEN 
              fullText := fullText || '(stepid:string)=(' || REPLACE(REPLACE(current_row.stepid,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.dependent IS NOT NULL) THEN 
              fullText := fullText || '(dependent:integer)=(' || current_row.dependent || ')';
          END IF;
        IF ((current_row.project_descendant_pipeline_info IS NOT NULL)) THEN
            fullText := fullText || '(project_descendant_pipeline_info:integer)=(' || current_row.project_descendant_pipeline_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_project_descendant_pipeline_meta_data(current_row.project_descendant_pipeline_info, child_count,$3,false,false);
              fullText := fullText || '(project_descendant_pipeline_info_project_descendant_pipeline_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.arc_project_descendant_arc_project_descendant_id IS NOT NULL)) THEN
            fullText := fullText || '(arc_project_descendant_arc_project_descendant_id:integer)=(' || current_row.arc_project_descendant_arc_project_descendant_id || ')';
        END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
      IF (row_ct=0) THEN 
           child_count := child_count+1;
           tempText := NULL;
           tempText := ie_arc_pipelineData_history( $1, child_count,$3,$4,false);
              fullText := fullText || '(pipelinedata_pipelinedata:XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
          
      END IF;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_project_descendant_pipeline_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_project_descendant_pipeline_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_project_descendant_pipeline_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:project_descendant_pipeline_meta_data)(';
      FOR current_row IN SELECT * FROM arc_project_descendant_pipeline_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_project_descendant_pipeline_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_project_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_project_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:project_history)(';
      FOR current_row IN SELECT * FROM arc_project_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
        IF ((current_row.paths_arc_pathinfo_id IS NOT NULL)) THEN
            fullText := fullText || '(paths_arc_pathinfo_id:integer)=(' || current_row.paths_arc_pathinfo_id || ')';
 -- 661
           DECLARE
           mapping_row RECORD; 
           loop_count int4:=0; 
           BEGIN 
           	FOR mapping_row IN SELECT * FROM arc_pathInfo_history WHERE  arc_pathinfo_id=current_row.paths_arc_pathinfo_id AND xft_version=current_row.xft_version LIMIT 1
           	LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_pathInfo_history(mapping_row.history_id, child_count,$3,false,false);
              fullText := fullText || '(paths_pathinfo:XFTItem)=(' || tempText || ')';
           	END LOOP;
           END; 
        END IF;
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM arc_fieldSpecification_history WHERE fieldspecifications_fieldspecif_arc_project_id=current_row.arc_project_id AND xft_version=current_row.xft_version ORDER BY arc_fieldspecification_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_fieldSpecification_history( parent_row.arc_fieldspecification_id, child_count,$3,false,false);
              fullText := fullText || '(fieldspecifications_fieldspecification_fieldspecification' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM arc_property_history WHERE properties_property_arc_project_arc_project_id=current_row.arc_project_id AND xft_version=current_row.xft_version ORDER BY arc_property_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_property_history( parent_row.arc_property_id, child_count,$3,false,false);
              fullText := fullText || '(properties_property_property' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM arc_project_descendant_history WHERE pipelines_descendants_descendan_arc_project_id=current_row.arc_project_id AND xft_version=current_row.xft_version ORDER BY arc_project_descendant_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_project_descendant_history( parent_row.arc_project_descendant_id, child_count,$3,false,false);
              fullText := fullText || '(pipelines_descendants_descendant_project_descendant' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM arc_project_pipeline_history WHERE pipelines_pipeline_arc_project_arc_project_id=current_row.arc_project_id AND xft_version=current_row.xft_version ORDER BY arc_pipelinedata_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_project_pipeline_history( parent_row.arc_pipelinedata_id, child_count,$3,false,false);
              fullText := fullText || '(pipelines_pipeline_project_pipeline' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
          IF (current_row.id IS NOT NULL) THEN 
              fullText := fullText || '(id:string)=(' || REPLACE(REPLACE(current_row.id,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.current_arc IS NOT NULL) THEN 
              fullText := fullText || '(current_arc:string)=(' || REPLACE(REPLACE(current_row.current_arc,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.quarantine_code IS NOT NULL) THEN 
              fullText := fullText || '(quarantine_code:integer)=(' || current_row.quarantine_code || ')';
          END IF;
          IF (current_row.prearchive_code IS NOT NULL) THEN 
              fullText := fullText || '(prearchive_code:integer)=(' || current_row.prearchive_code || ')';
          END IF;
        IF ((current_row.project_info IS NOT NULL)) THEN
            fullText := fullText || '(project_info:integer)=(' || current_row.project_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_project_meta_data(current_row.project_info, child_count,$3,false,false);
              fullText := fullText || '(project_info_project_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.projects_project_arc_ArchiveSpe_arc_archivespecification_id IS NOT NULL)) THEN
            fullText := fullText || '(projects_project_arc_archivespe_arc_archivespecification_id:integer)=(' || current_row.projects_project_arc_archivespe_arc_archivespecification_id || ')';
        END IF;
          IF (current_row.arc_project_id IS NOT NULL) THEN 
              fullText := fullText || '(arc_project_id:integer)=(' || current_row.arc_project_id || ')';
          END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_project_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_project_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_project_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:project_meta_data)(';
      FOR current_row IN SELECT * FROM arc_project_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_project_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_project_pipeline(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_project_pipeline(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:project_pipeline)(';
      FOR current_row IN SELECT * FROM arc_project_pipeline WHERE  arc_pipelinedata_id=$1
      LOOP
           row_ct := row_ct+1;
          
        IF ((current_row.arc_pipelinedata_id IS NOT NULL)) THEN
            fullText := fullText || '(arc_pipelinedata_id:integer)=(' || current_row.arc_pipelinedata_id || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := ie_arc_pipelineData(current_row.arc_pipelinedata_id, child_count,$3,false,false);
              fullText := fullText || '(pipelinedata_pipelinedata:XFTItem)=(' || tempText || ')';
        END IF;
          IF (current_row.stepid IS NOT NULL) THEN 
              fullText := fullText || '(stepid:string)=(' || REPLACE(REPLACE(current_row.stepid,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.dependent IS NOT NULL) THEN 
              fullText := fullText || '(dependent:integer)=(' || current_row.dependent || ')';
          END IF;
        IF ((current_row.project_pipeline_info IS NOT NULL)) THEN
            fullText := fullText || '(project_pipeline_info:integer)=(' || current_row.project_pipeline_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_project_pipeline_meta_data(current_row.project_pipeline_info, child_count,$3,false,false);
              fullText := fullText || '(project_pipeline_info_project_pipeline_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.pipelines_pipeline_arc_project_arc_project_id IS NOT NULL)) THEN
            fullText := fullText || '(pipelines_pipeline_arc_project_arc_project_id:integer)=(' || current_row.pipelines_pipeline_arc_project_arc_project_id || ')';
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
           child_count := child_count+1;
           tempText := NULL;
           tempText := ie_arc_pipelineData( $1, child_count,$3,$4,false);
              fullText := fullText || '(pipelinedata_pipelinedata:XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
          
      END IF;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_project_pipeline(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_project_pipeline_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_project_pipeline_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:project_pipeline_history)(';
      FOR current_row IN SELECT * FROM arc_project_pipeline_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
        IF ((current_row.arc_pipelinedata_id IS NOT NULL)) THEN
            fullText := fullText || '(arc_pipelinedata_id:integer)=(' || current_row.arc_pipelinedata_id || ')';
           child_count := child_count+1;
           tempText := NULL;
           DECLARE
           	ext_row RECORD;
           BEGIN 
           	FOR ext_row IN SELECT * FROM arc_pipelineData_history WHERE arc_pipelinedata_id=current_row.arc_pipelinedata_id AND xft_version=current_row.xft_version
           	LOOP
 -- 632
           	   tempText := ie_arc_pipelineData_history(ext_row.history_id, child_count,$3,false,false);
           	      fullText := fullText || '(pipelinedata_pipelinedata:XFTItem)=(' || tempText || ')';
           	END LOOP;
           END;
        END IF;
          IF (current_row.stepid IS NOT NULL) THEN 
              fullText := fullText || '(stepid:string)=(' || REPLACE(REPLACE(current_row.stepid,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.dependent IS NOT NULL) THEN 
              fullText := fullText || '(dependent:integer)=(' || current_row.dependent || ')';
          END IF;
        IF ((current_row.project_pipeline_info IS NOT NULL)) THEN
            fullText := fullText || '(project_pipeline_info:integer)=(' || current_row.project_pipeline_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_project_pipeline_meta_data(current_row.project_pipeline_info, child_count,$3,false,false);
              fullText := fullText || '(project_pipeline_info_project_pipeline_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.pipelines_pipeline_arc_project_arc_project_id IS NOT NULL)) THEN
            fullText := fullText || '(pipelines_pipeline_arc_project_arc_project_id:integer)=(' || current_row.pipelines_pipeline_arc_project_arc_project_id || ')';
        END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
      IF (row_ct=0) THEN 
           child_count := child_count+1;
           tempText := NULL;
           tempText := ie_arc_pipelineData_history( $1, child_count,$3,$4,false);
              fullText := fullText || '(pipelinedata_pipelinedata:XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
          
      END IF;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_project_pipeline_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_project_pipeline_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_project_pipeline_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:project_pipeline_meta_data)(';
      FOR current_row IN SELECT * FROM arc_project_pipeline_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_project_pipeline_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_property(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_property(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:property)(';
      FOR current_row IN SELECT * FROM arc_property WHERE  arc_property_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.property IS NOT NULL) THEN 
              fullText := fullText || '(property:string)=(' || REPLACE(REPLACE(current_row.property,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.name IS NOT NULL) THEN 
              fullText := fullText || '(name:string)=(' || REPLACE(REPLACE(current_row.name,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.property_info IS NOT NULL)) THEN
            fullText := fullText || '(property_info:integer)=(' || current_row.property_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_property_meta_data(current_row.property_info, child_count,$3,false,false);
              fullText := fullText || '(property_info_property_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.properties_property_arc_project_arc_project_id IS NOT NULL)) THEN
            fullText := fullText || '(properties_property_arc_project_arc_project_id:integer)=(' || current_row.properties_property_arc_project_arc_project_id || ')';
        END IF;
          IF (current_row.arc_property_id IS NOT NULL) THEN 
              fullText := fullText || '(arc_property_id:integer)=(' || current_row.arc_property_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_property(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_property_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_property_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:property_history)(';
      FOR current_row IN SELECT * FROM arc_property_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.property IS NOT NULL) THEN 
              fullText := fullText || '(property:string)=(' || REPLACE(REPLACE(current_row.property,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.name IS NOT NULL) THEN 
              fullText := fullText || '(name:string)=(' || REPLACE(REPLACE(current_row.name,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.property_info IS NOT NULL)) THEN
            fullText := fullText || '(property_info:integer)=(' || current_row.property_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_arc_property_meta_data(current_row.property_info, child_count,$3,false,false);
              fullText := fullText || '(property_info_property_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.properties_property_arc_project_arc_project_id IS NOT NULL)) THEN
            fullText := fullText || '(properties_property_arc_project_arc_project_id:integer)=(' || current_row.properties_property_arc_project_arc_project_id || ')';
        END IF;
          IF (current_row.arc_property_id IS NOT NULL) THEN 
              fullText := fullText || '(arc_property_id:integer)=(' || current_row.arc_property_id || ')';
          END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_property_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_arc_property_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_arc_property_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(arc:property_meta_data)(';
      FOR current_row IN SELECT * FROM arc_property_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_arc_property_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_cat_catalog(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_cat_catalog(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     fullText TEXT;
    begin
      FOR current_row IN SELECT * FROM (SELECT cat_catalog.cat_catalog_id AS cat_catalog6, table1.element_name AS xdat_meta_element105, table2.insert_date AS cat_catalog_meta_data112 FROM cat_catalog cat_catalog   LEFT JOIN xdat_meta_element table1 ON cat_catalog.extension=table1.xdat_meta_element_id   LEFT JOIN cat_catalog_meta_data table2 ON cat_catalog.catalog_info=table2.meta_data_id) SEARCH  WHERE 
 ( (cat_catalog6=$1))
      LOOP
         IF (current_row.xdat_meta_element105 IS NULL) THEN 
             fullText:= ie_cat_catalog( $1, $2,$3,$4,$5);
         ELSE
            --CALL EXTENDER 
            declare
               matches int4:=0;
            begin
            IF (current_row.xdat_meta_element105='cat:dcmCatalog') THEN
                fullText:= i_cat_dcmCatalog( $1, $2,$3,$4,$5);
                matches:=1;
            END IF;
                IF (matches=0) THEN
                    fullText:= ie_cat_catalog( $1, $2,$3,$4,$5);
                END IF;
            end;
         end IF;
      END LOOP;
	
	RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_cat_catalog(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_cat_catalog_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_cat_catalog_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     fullText TEXT;
    begin
      FOR current_row IN SELECT * FROM (SELECT cat_catalog_history.history_id AS cat_catalog_history5, table1.element_name AS xdat_meta_element12, cat_catalog_history.xft_version AS cat_catalog_history_xft_version, cat_catalog_history.cat_catalog_id AS cat_catalog_history6 FROM cat_catalog_history cat_catalog_history   LEFT JOIN xdat_meta_element table1 ON cat_catalog_history.extension=table1.xdat_meta_element_id) SEARCH  WHERE 
 ( (cat_catalog_history5=$1))
      LOOP
         IF (current_row.xdat_meta_element12 IS NULL) THEN 
             fullText:= ie_cat_catalog( $1, $2,$3,$4,$5);
         ELSE
            --CALL EXTENDER 
            declare
               matches int4:=0;
            begin
            IF (current_row.xdat_meta_element12='cat:dcmCatalog') THEN
            --907 
            DECLARE
            	ext_row RECORD;
            BEGIN 
            	FOR ext_row IN SELECT * FROM cat_dcmCatalog_history WHERE cat_catalog_id=current_row.cat_catalog_history6 AND xft_version=current_row.cat_catalog_history_xft_version
           	LOOP
                fullText:= i_cat_dcmCatalog_history(ext_row.history_id, $2,$3,$4,$5);
                matches:=1;
            	END LOOP;
            END;
            END IF;
                IF (matches=0) THEN
                    fullText:= ie_cat_catalog_history( $1, $2,$3,$4,$5);
                END IF;
            end;
         end IF;
      END LOOP;
	
	RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_cat_catalog_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_cat_catalog_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_cat_catalog_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(cat:catalog_meta_data)(';
      FOR current_row IN SELECT * FROM cat_catalog_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_cat_catalog_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_cat_catalog_metafield(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_cat_catalog_metafield(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(cat:catalog_metaField)(';
      FOR current_row IN SELECT * FROM cat_catalog_metaField WHERE  cat_catalog_metafield_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.metafield IS NOT NULL) THEN 
              fullText := fullText || '(metafield:string)=(' || REPLACE(REPLACE(current_row.metafield,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.name IS NOT NULL) THEN 
              fullText := fullText || '(name:string)=(' || REPLACE(REPLACE(current_row.name,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.catalog_metaField_info IS NOT NULL)) THEN
            fullText := fullText || '(catalog_metafield_info:integer)=(' || current_row.catalog_metafield_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_cat_catalog_metaField_meta_data(current_row.catalog_metaField_info, child_count,$3,false,false);
              fullText := fullText || '(catalog_metafield_info_catalog_metafield_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.metafields_metafield_cat_catalo_cat_catalog_id IS NOT NULL)) THEN
            fullText := fullText || '(metafields_metafield_cat_catalo_cat_catalog_id:integer)=(' || current_row.metafields_metafield_cat_catalo_cat_catalog_id || ')';
        END IF;
          IF (current_row.cat_catalog_metafield_id IS NOT NULL) THEN 
              fullText := fullText || '(cat_catalog_metafield_id:integer)=(' || current_row.cat_catalog_metafield_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_cat_catalog_metafield(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_cat_catalog_metafield_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_cat_catalog_metafield_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(cat:catalog_metaField_history)(';
      FOR current_row IN SELECT * FROM cat_catalog_metaField_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.metafield IS NOT NULL) THEN 
              fullText := fullText || '(metafield:string)=(' || REPLACE(REPLACE(current_row.metafield,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.name IS NOT NULL) THEN 
              fullText := fullText || '(name:string)=(' || REPLACE(REPLACE(current_row.name,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.catalog_metaField_info IS NOT NULL)) THEN
            fullText := fullText || '(catalog_metafield_info:integer)=(' || current_row.catalog_metafield_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_cat_catalog_metaField_meta_data(current_row.catalog_metaField_info, child_count,$3,false,false);
              fullText := fullText || '(catalog_metafield_info_catalog_metafield_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.metafields_metafield_cat_catalo_cat_catalog_id IS NOT NULL)) THEN
            fullText := fullText || '(metafields_metafield_cat_catalo_cat_catalog_id:integer)=(' || current_row.metafields_metafield_cat_catalo_cat_catalog_id || ')';
        END IF;
          IF (current_row.cat_catalog_metafield_id IS NOT NULL) THEN 
              fullText := fullText || '(cat_catalog_metafield_id:integer)=(' || current_row.cat_catalog_metafield_id || ')';
          END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_cat_catalog_metafield_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_cat_catalog_metafield_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_cat_catalog_metafield_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(cat:catalog_metaField_meta_data)(';
      FOR current_row IN SELECT * FROM cat_catalog_metaField_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_cat_catalog_metafield_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_cat_catalog_tag(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_cat_catalog_tag(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(cat:catalog_tag)(';
      FOR current_row IN SELECT * FROM cat_catalog_tag WHERE  cat_catalog_tag_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.tag IS NOT NULL) THEN 
              fullText := fullText || '(tag:string)=(' || REPLACE(REPLACE(current_row.tag,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.catalog_tag_info IS NOT NULL)) THEN
            fullText := fullText || '(catalog_tag_info:integer)=(' || current_row.catalog_tag_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_cat_catalog_tag_meta_data(current_row.catalog_tag_info, child_count,$3,false,false);
              fullText := fullText || '(catalog_tag_info_catalog_tag_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.tags_tag_cat_catalog_cat_catalog_id IS NOT NULL)) THEN
            fullText := fullText || '(tags_tag_cat_catalog_cat_catalog_id:integer)=(' || current_row.tags_tag_cat_catalog_cat_catalog_id || ')';
        END IF;
          IF (current_row.cat_catalog_tag_id IS NOT NULL) THEN 
              fullText := fullText || '(cat_catalog_tag_id:integer)=(' || current_row.cat_catalog_tag_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_cat_catalog_tag(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_cat_catalog_tag_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_cat_catalog_tag_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(cat:catalog_tag_history)(';
      FOR current_row IN SELECT * FROM cat_catalog_tag_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.tag IS NOT NULL) THEN 
              fullText := fullText || '(tag:string)=(' || REPLACE(REPLACE(current_row.tag,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.catalog_tag_info IS NOT NULL)) THEN
            fullText := fullText || '(catalog_tag_info:integer)=(' || current_row.catalog_tag_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_cat_catalog_tag_meta_data(current_row.catalog_tag_info, child_count,$3,false,false);
              fullText := fullText || '(catalog_tag_info_catalog_tag_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.tags_tag_cat_catalog_cat_catalog_id IS NOT NULL)) THEN
            fullText := fullText || '(tags_tag_cat_catalog_cat_catalog_id:integer)=(' || current_row.tags_tag_cat_catalog_cat_catalog_id || ')';
        END IF;
          IF (current_row.cat_catalog_tag_id IS NOT NULL) THEN 
              fullText := fullText || '(cat_catalog_tag_id:integer)=(' || current_row.cat_catalog_tag_id || ')';
          END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_cat_catalog_tag_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_cat_catalog_tag_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_cat_catalog_tag_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(cat:catalog_tag_meta_data)(';
      FOR current_row IN SELECT * FROM cat_catalog_tag_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_cat_catalog_tag_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_cat_dcmcatalog(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_cat_dcmcatalog(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(cat:dcmCatalog)(';
      FOR current_row IN SELECT * FROM cat_dcmCatalog WHERE  cat_catalog_id=$1
      LOOP
           row_ct := row_ct+1;
          
        IF ((current_row.cat_catalog_id IS NOT NULL)) THEN
            fullText := fullText || '(cat_catalog_id:integer)=(' || current_row.cat_catalog_id || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := ie_cat_catalog(current_row.cat_catalog_id, child_count,$3,false,false);
              fullText := fullText || '(catalog_catalog:XFTItem)=(' || tempText || ')';
        END IF;
          IF (current_row.dimensions_x IS NOT NULL) THEN 
              fullText := fullText || '(dimensions_x:integer)=(' || current_row.dimensions_x || ')';
          END IF;
          IF (current_row.dimensions_y IS NOT NULL) THEN 
              fullText := fullText || '(dimensions_y:integer)=(' || current_row.dimensions_y || ')';
          END IF;
          IF (current_row.dimensions_z IS NOT NULL) THEN 
              fullText := fullText || '(dimensions_z:integer)=(' || current_row.dimensions_z || ')';
          END IF;
          IF (current_row.dimensions_volumes IS NOT NULL) THEN 
              fullText := fullText || '(dimensions_volumes:integer)=(' || current_row.dimensions_volumes || ')';
          END IF;
          IF (current_row.voxelres_x IS NOT NULL) THEN 
              fullText := fullText || '(voxelres_x:float)=(' || current_row.voxelres_x || ')';
          END IF;
          IF (current_row.voxelres_y IS NOT NULL) THEN 
              fullText := fullText || '(voxelres_y:float)=(' || current_row.voxelres_y || ')';
          END IF;
          IF (current_row.voxelres_z IS NOT NULL) THEN 
              fullText := fullText || '(voxelres_z:float)=(' || current_row.voxelres_z || ')';
          END IF;
          IF (current_row.voxelres_units IS NOT NULL) THEN 
              fullText := fullText || '(voxelres_units:string)=(' || REPLACE(REPLACE(current_row.voxelres_units,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.orientation IS NOT NULL) THEN 
              fullText := fullText || '(orientation:string)=(' || REPLACE(REPLACE(current_row.orientation,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.uid IS NOT NULL) THEN 
              fullText := fullText || '(uid:string)=(' || REPLACE(REPLACE(current_row.uid,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.dcmCatalog_info IS NOT NULL)) THEN
            fullText := fullText || '(dcmcatalog_info:integer)=(' || current_row.dcmcatalog_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_cat_dcmCatalog_meta_data(current_row.dcmCatalog_info, child_count,$3,false,false);
              fullText := fullText || '(dcmcatalog_info_dcmcatalog_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
           child_count := child_count+1;
           tempText := NULL;
           tempText := ie_cat_catalog( $1, child_count,$3,$4,false);
              fullText := fullText || '(catalog_catalog:XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
          
      END IF;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_cat_dcmcatalog(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_cat_dcmcatalog_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_cat_dcmcatalog_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(cat:dcmCatalog_history)(';
      FOR current_row IN SELECT * FROM cat_dcmCatalog_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
        IF ((current_row.cat_catalog_id IS NOT NULL)) THEN
            fullText := fullText || '(cat_catalog_id:integer)=(' || current_row.cat_catalog_id || ')';
           child_count := child_count+1;
           tempText := NULL;
           DECLARE
           	ext_row RECORD;
           BEGIN 
           	FOR ext_row IN SELECT * FROM cat_catalog_history WHERE cat_catalog_id=current_row.cat_catalog_id AND xft_version=current_row.xft_version
           	LOOP
 -- 632
           	   tempText := ie_cat_catalog_history(ext_row.history_id, child_count,$3,false,false);
           	      fullText := fullText || '(catalog_catalog:XFTItem)=(' || tempText || ')';
           	END LOOP;
           END;
        END IF;
          IF (current_row.dimensions_x IS NOT NULL) THEN 
              fullText := fullText || '(dimensions_x:integer)=(' || current_row.dimensions_x || ')';
          END IF;
          IF (current_row.dimensions_y IS NOT NULL) THEN 
              fullText := fullText || '(dimensions_y:integer)=(' || current_row.dimensions_y || ')';
          END IF;
          IF (current_row.dimensions_z IS NOT NULL) THEN 
              fullText := fullText || '(dimensions_z:integer)=(' || current_row.dimensions_z || ')';
          END IF;
          IF (current_row.dimensions_volumes IS NOT NULL) THEN 
              fullText := fullText || '(dimensions_volumes:integer)=(' || current_row.dimensions_volumes || ')';
          END IF;
          IF (current_row.voxelres_x IS NOT NULL) THEN 
              fullText := fullText || '(voxelres_x:float)=(' || current_row.voxelres_x || ')';
          END IF;
          IF (current_row.voxelres_y IS NOT NULL) THEN 
              fullText := fullText || '(voxelres_y:float)=(' || current_row.voxelres_y || ')';
          END IF;
          IF (current_row.voxelres_z IS NOT NULL) THEN 
              fullText := fullText || '(voxelres_z:float)=(' || current_row.voxelres_z || ')';
          END IF;
          IF (current_row.voxelres_units IS NOT NULL) THEN 
              fullText := fullText || '(voxelres_units:string)=(' || REPLACE(REPLACE(current_row.voxelres_units,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.orientation IS NOT NULL) THEN 
              fullText := fullText || '(orientation:string)=(' || REPLACE(REPLACE(current_row.orientation,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.uid IS NOT NULL) THEN 
              fullText := fullText || '(uid:string)=(' || REPLACE(REPLACE(current_row.uid,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.dcmCatalog_info IS NOT NULL)) THEN
            fullText := fullText || '(dcmcatalog_info:integer)=(' || current_row.dcmcatalog_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_cat_dcmCatalog_meta_data(current_row.dcmCatalog_info, child_count,$3,false,false);
              fullText := fullText || '(dcmcatalog_info_dcmcatalog_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
      IF (row_ct=0) THEN 
           child_count := child_count+1;
           tempText := NULL;
           tempText := ie_cat_catalog_history( $1, child_count,$3,$4,false);
              fullText := fullText || '(catalog_catalog:XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
          
      END IF;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_cat_dcmcatalog_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_cat_dcmcatalog_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_cat_dcmcatalog_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(cat:dcmCatalog_meta_data)(';
      FOR current_row IN SELECT * FROM cat_dcmCatalog_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_cat_dcmcatalog_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_cat_dcmentry(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_cat_dcmentry(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(cat:dcmEntry)(';
      FOR current_row IN SELECT * FROM cat_dcmEntry WHERE  cat_entry_id=$1
      LOOP
           row_ct := row_ct+1;
          
        IF ((current_row.cat_entry_id IS NOT NULL)) THEN
            fullText := fullText || '(cat_entry_id:integer)=(' || current_row.cat_entry_id || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := ie_cat_entry(current_row.cat_entry_id, child_count,$3,false,false);
              fullText := fullText || '(entry_entry:XFTItem)=(' || tempText || ')';
        END IF;
          IF (current_row.uid IS NOT NULL) THEN 
              fullText := fullText || '(uid:string)=(' || REPLACE(REPLACE(current_row.uid,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.instancenumber IS NOT NULL) THEN 
              fullText := fullText || '(instancenumber:integer)=(' || current_row.instancenumber || ')';
          END IF;
        IF ((current_row.dcmEntry_info IS NOT NULL)) THEN
            fullText := fullText || '(dcmentry_info:integer)=(' || current_row.dcmentry_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_cat_dcmEntry_meta_data(current_row.dcmEntry_info, child_count,$3,false,false);
              fullText := fullText || '(dcmentry_info_dcmentry_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
           child_count := child_count+1;
           tempText := NULL;
           tempText := ie_cat_entry( $1, child_count,$3,$4,false);
              fullText := fullText || '(entry_entry:XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
          
      END IF;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_cat_dcmentry(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_cat_dcmentry_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_cat_dcmentry_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(cat:dcmEntry_history)(';
      FOR current_row IN SELECT * FROM cat_dcmEntry_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
        IF ((current_row.cat_entry_id IS NOT NULL)) THEN
            fullText := fullText || '(cat_entry_id:integer)=(' || current_row.cat_entry_id || ')';
           child_count := child_count+1;
           tempText := NULL;
           DECLARE
           	ext_row RECORD;
           BEGIN 
           	FOR ext_row IN SELECT * FROM cat_entry_history WHERE cat_entry_id=current_row.cat_entry_id AND xft_version=current_row.xft_version
           	LOOP
 -- 632
           	   tempText := ie_cat_entry_history(ext_row.history_id, child_count,$3,false,false);
           	      fullText := fullText || '(entry_entry:XFTItem)=(' || tempText || ')';
           	END LOOP;
           END;
        END IF;
          IF (current_row.uid IS NOT NULL) THEN 
              fullText := fullText || '(uid:string)=(' || REPLACE(REPLACE(current_row.uid,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.instancenumber IS NOT NULL) THEN 
              fullText := fullText || '(instancenumber:integer)=(' || current_row.instancenumber || ')';
          END IF;
        IF ((current_row.dcmEntry_info IS NOT NULL)) THEN
            fullText := fullText || '(dcmentry_info:integer)=(' || current_row.dcmentry_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_cat_dcmEntry_meta_data(current_row.dcmEntry_info, child_count,$3,false,false);
              fullText := fullText || '(dcmentry_info_dcmentry_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
      IF (row_ct=0) THEN 
           child_count := child_count+1;
           tempText := NULL;
           tempText := ie_cat_entry_history( $1, child_count,$3,$4,false);
              fullText := fullText || '(entry_entry:XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
          
      END IF;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_cat_dcmentry_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_cat_dcmentry_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_cat_dcmentry_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(cat:dcmEntry_meta_data)(';
      FOR current_row IN SELECT * FROM cat_dcmEntry_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_cat_dcmentry_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_cat_entry(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_cat_entry(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     fullText TEXT;
    begin
      FOR current_row IN SELECT * FROM (SELECT cat_entry.cat_entry_id AS cat_entry16, table1.element_name AS xdat_meta_element51, table2.insert_date AS cat_entry_meta_data58 FROM cat_entry cat_entry   LEFT JOIN xdat_meta_element table1 ON cat_entry.extension=table1.xdat_meta_element_id   LEFT JOIN cat_entry_meta_data table2 ON cat_entry.entry_info=table2.meta_data_id) SEARCH  WHERE 
 ( (cat_entry16=$1))
      LOOP
         IF (current_row.xdat_meta_element51 IS NULL) THEN 
             fullText:= ie_cat_entry( $1, $2,$3,$4,$5);
         ELSE
            --CALL EXTENDER 
            declare
               matches int4:=0;
            begin
            IF (current_row.xdat_meta_element51='cat:dcmEntry') THEN
                fullText:= i_cat_dcmEntry( $1, $2,$3,$4,$5);
                matches:=1;
            END IF;
                IF (matches=0) THEN
                    fullText:= ie_cat_entry( $1, $2,$3,$4,$5);
                END IF;
            end;
         end IF;
      END LOOP;
	
	RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_cat_entry(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_cat_entry_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_cat_entry_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     fullText TEXT;
    begin
      FOR current_row IN SELECT * FROM (SELECT cat_entry_history.history_id AS cat_entry_history14, table1.element_name AS xdat_meta_element24, cat_entry_history.xft_version AS cat_entry_history_xft_version, cat_entry_history.cat_entry_id AS cat_entry_history0 FROM cat_entry_history cat_entry_history   LEFT JOIN xdat_meta_element table1 ON cat_entry_history.extension=table1.xdat_meta_element_id) SEARCH  WHERE 
 ( (cat_entry_history14=$1))
      LOOP
         IF (current_row.xdat_meta_element24 IS NULL) THEN 
             fullText:= ie_cat_entry( $1, $2,$3,$4,$5);
         ELSE
            --CALL EXTENDER 
            declare
               matches int4:=0;
            begin
            IF (current_row.xdat_meta_element24='cat:dcmEntry') THEN
            --907 
            DECLARE
            	ext_row RECORD;
            BEGIN 
            	FOR ext_row IN SELECT * FROM cat_dcmEntry_history WHERE cat_entry_id=current_row.cat_entry_history0 AND xft_version=current_row.cat_entry_history_xft_version
           	LOOP
                fullText:= i_cat_dcmEntry_history(ext_row.history_id, $2,$3,$4,$5);
                matches:=1;
            	END LOOP;
            END;
            END IF;
                IF (matches=0) THEN
                    fullText:= ie_cat_entry_history( $1, $2,$3,$4,$5);
                END IF;
            end;
         end IF;
      END LOOP;
	
	RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_cat_entry_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_cat_entry_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_cat_entry_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(cat:entry_meta_data)(';
      FOR current_row IN SELECT * FROM cat_entry_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_cat_entry_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_cat_entry_metafield(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_cat_entry_metafield(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(cat:entry_metaField)(';
      FOR current_row IN SELECT * FROM cat_entry_metaField WHERE  cat_entry_metafield_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.metafield IS NOT NULL) THEN 
              fullText := fullText || '(metafield:string)=(' || REPLACE(REPLACE(current_row.metafield,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.name IS NOT NULL) THEN 
              fullText := fullText || '(name:string)=(' || REPLACE(REPLACE(current_row.name,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.entry_metaField_info IS NOT NULL)) THEN
            fullText := fullText || '(entry_metafield_info:integer)=(' || current_row.entry_metafield_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_cat_entry_metaField_meta_data(current_row.entry_metaField_info, child_count,$3,false,false);
              fullText := fullText || '(entry_metafield_info_entry_metafield_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.metafields_metafield_cat_entry_cat_entry_id IS NOT NULL)) THEN
            fullText := fullText || '(metafields_metafield_cat_entry_cat_entry_id:integer)=(' || current_row.metafields_metafield_cat_entry_cat_entry_id || ')';
        END IF;
          IF (current_row.cat_entry_metafield_id IS NOT NULL) THEN 
              fullText := fullText || '(cat_entry_metafield_id:integer)=(' || current_row.cat_entry_metafield_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_cat_entry_metafield(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_cat_entry_metafield_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_cat_entry_metafield_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(cat:entry_metaField_history)(';
      FOR current_row IN SELECT * FROM cat_entry_metaField_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.metafield IS NOT NULL) THEN 
              fullText := fullText || '(metafield:string)=(' || REPLACE(REPLACE(current_row.metafield,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.name IS NOT NULL) THEN 
              fullText := fullText || '(name:string)=(' || REPLACE(REPLACE(current_row.name,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.entry_metaField_info IS NOT NULL)) THEN
            fullText := fullText || '(entry_metafield_info:integer)=(' || current_row.entry_metafield_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_cat_entry_metaField_meta_data(current_row.entry_metaField_info, child_count,$3,false,false);
              fullText := fullText || '(entry_metafield_info_entry_metafield_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.metafields_metafield_cat_entry_cat_entry_id IS NOT NULL)) THEN
            fullText := fullText || '(metafields_metafield_cat_entry_cat_entry_id:integer)=(' || current_row.metafields_metafield_cat_entry_cat_entry_id || ')';
        END IF;
          IF (current_row.cat_entry_metafield_id IS NOT NULL) THEN 
              fullText := fullText || '(cat_entry_metafield_id:integer)=(' || current_row.cat_entry_metafield_id || ')';
          END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_cat_entry_metafield_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_cat_entry_metafield_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_cat_entry_metafield_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(cat:entry_metaField_meta_data)(';
      FOR current_row IN SELECT * FROM cat_entry_metaField_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_cat_entry_metafield_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_cat_entry_tag(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_cat_entry_tag(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(cat:entry_tag)(';
      FOR current_row IN SELECT * FROM cat_entry_tag WHERE  cat_entry_tag_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.tag IS NOT NULL) THEN 
              fullText := fullText || '(tag:string)=(' || REPLACE(REPLACE(current_row.tag,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.entry_tag_info IS NOT NULL)) THEN
            fullText := fullText || '(entry_tag_info:integer)=(' || current_row.entry_tag_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_cat_entry_tag_meta_data(current_row.entry_tag_info, child_count,$3,false,false);
              fullText := fullText || '(entry_tag_info_entry_tag_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.tags_tag_cat_entry_cat_entry_id IS NOT NULL)) THEN
            fullText := fullText || '(tags_tag_cat_entry_cat_entry_id:integer)=(' || current_row.tags_tag_cat_entry_cat_entry_id || ')';
        END IF;
          IF (current_row.cat_entry_tag_id IS NOT NULL) THEN 
              fullText := fullText || '(cat_entry_tag_id:integer)=(' || current_row.cat_entry_tag_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_cat_entry_tag(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_cat_entry_tag_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_cat_entry_tag_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(cat:entry_tag_history)(';
      FOR current_row IN SELECT * FROM cat_entry_tag_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.tag IS NOT NULL) THEN 
              fullText := fullText || '(tag:string)=(' || REPLACE(REPLACE(current_row.tag,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.entry_tag_info IS NOT NULL)) THEN
            fullText := fullText || '(entry_tag_info:integer)=(' || current_row.entry_tag_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_cat_entry_tag_meta_data(current_row.entry_tag_info, child_count,$3,false,false);
              fullText := fullText || '(entry_tag_info_entry_tag_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.tags_tag_cat_entry_cat_entry_id IS NOT NULL)) THEN
            fullText := fullText || '(tags_tag_cat_entry_cat_entry_id:integer)=(' || current_row.tags_tag_cat_entry_cat_entry_id || ')';
        END IF;
          IF (current_row.cat_entry_tag_id IS NOT NULL) THEN 
              fullText := fullText || '(cat_entry_tag_id:integer)=(' || current_row.cat_entry_tag_id || ')';
          END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_cat_entry_tag_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_cat_entry_tag_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_cat_entry_tag_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(cat:entry_tag_meta_data)(';
      FOR current_row IN SELECT * FROM cat_entry_tag_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_cat_entry_tag_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_pipe_pipelinedetails(character varying, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_pipe_pipelinedetails(character varying, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(pipe:pipelineDetails)(';
      FOR current_row IN SELECT * FROM pipe_pipelineDetails WHERE  path=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.path IS NOT NULL) THEN 
              fullText := fullText || '(path:string)=(' || REPLACE(REPLACE(current_row.path,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.description IS NOT NULL) THEN 
              fullText := fullText || '(description:string)=(' || REPLACE(REPLACE(current_row.description,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM pipe_pipelineDetails_element WHERE generateselements_element_pipe__path=current_row.path ORDER BY pipe_pipelinedetails_element_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_pipe_pipelineDetails_element( parent_row.pipe_pipelinedetails_element_id, child_count,$3,false,false);
              fullText := fullText || '(generateselements_element_pipelinedetails_element' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
          IF (current_row.customwebpage IS NOT NULL) THEN 
              fullText := fullText || '(customwebpage:string)=(' || REPLACE(REPLACE(current_row.customwebpage,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM pipe_pipelineDetails_parameter WHERE parameters_parameter_pipe_pipel_path=current_row.path ORDER BY pipe_pipelinedetails_parameter_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_pipe_pipelineDetails_parameter( parent_row.pipe_pipelinedetails_parameter_id, child_count,$3,false,false);
              fullText := fullText || '(parameters_parameter_pipelinedetails_parameter' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
          IF (current_row.appliesto IS NOT NULL) THEN 
              fullText := fullText || '(appliesto:string)=(' || REPLACE(REPLACE(current_row.appliesto,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.pipelineDetails_info IS NOT NULL)) THEN
            fullText := fullText || '(pipelinedetails_info:integer)=(' || current_row.pipelinedetails_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_pipe_pipelineDetails_meta_data(current_row.pipelineDetails_info, child_count,$3,false,false);
              fullText := fullText || '(pipelinedetails_info_pipelinedetails_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.pipe_PipelineRepository_pipe_pipelinerepository_id IS NOT NULL)) THEN
            fullText := fullText || '(pipe_pipelinerepository_pipe_pipelinerepository_id:integer)=(' || current_row.pipe_pipelinerepository_pipe_pipelinerepository_id || ')';
        END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_pipe_pipelinedetails(character varying, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_pipe_pipelinedetails_element(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_pipe_pipelinedetails_element(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(pipe:pipelineDetails_element)(';
      FOR current_row IN SELECT * FROM pipe_pipelineDetails_element WHERE  pipe_pipelinedetails_element_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.element IS NOT NULL) THEN 
              fullText := fullText || '(element:string)=(' || REPLACE(REPLACE(current_row.element,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.pipelineDetails_element_info IS NOT NULL)) THEN
            fullText := fullText || '(pipelinedetails_element_info:integer)=(' || current_row.pipelinedetails_element_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_pipe_pipelineDetails_element_meta_data(current_row.pipelineDetails_element_info, child_count,$3,false,false);
              fullText := fullText || '(pipelinedetails_element_info_pipelinedetails_element_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.generateselements_element_pipe__path IS NOT NULL)) THEN
            fullText := fullText || '(generateselements_element_pipe__path:string)=(' || current_row.generateselements_element_pipe__path || ')';
        END IF;
          IF (current_row.pipe_pipelinedetails_element_id IS NOT NULL) THEN 
              fullText := fullText || '(pipe_pipelinedetails_element_id:integer)=(' || current_row.pipe_pipelinedetails_element_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_pipe_pipelinedetails_element(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_pipe_pipelinedetails_element_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_pipe_pipelinedetails_element_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(pipe:pipelineDetails_element_history)(';
      FOR current_row IN SELECT * FROM pipe_pipelineDetails_element_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.element IS NOT NULL) THEN 
              fullText := fullText || '(element:string)=(' || REPLACE(REPLACE(current_row.element,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.pipelineDetails_element_info IS NOT NULL)) THEN
            fullText := fullText || '(pipelinedetails_element_info:integer)=(' || current_row.pipelinedetails_element_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_pipe_pipelineDetails_element_meta_data(current_row.pipelineDetails_element_info, child_count,$3,false,false);
              fullText := fullText || '(pipelinedetails_element_info_pipelinedetails_element_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.generateselements_element_pipe__path IS NOT NULL)) THEN
            fullText := fullText || '(generateselements_element_pipe__path:string)=(' || current_row.generateselements_element_pipe__path || ')';
        END IF;
          IF (current_row.pipe_pipelinedetails_element_id IS NOT NULL) THEN 
              fullText := fullText || '(pipe_pipelinedetails_element_id:integer)=(' || current_row.pipe_pipelinedetails_element_id || ')';
          END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_pipe_pipelinedetails_element_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_pipe_pipelinedetails_element_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_pipe_pipelinedetails_element_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(pipe:pipelineDetails_element_meta_data)(';
      FOR current_row IN SELECT * FROM pipe_pipelineDetails_element_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_pipe_pipelinedetails_element_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_pipe_pipelinedetails_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_pipe_pipelinedetails_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(pipe:pipelineDetails_history)(';
      FOR current_row IN SELECT * FROM pipe_pipelineDetails_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.path IS NOT NULL) THEN 
              fullText := fullText || '(path:string)=(' || REPLACE(REPLACE(current_row.path,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.description IS NOT NULL) THEN 
              fullText := fullText || '(description:string)=(' || REPLACE(REPLACE(current_row.description,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM pipe_pipelineDetails_element_history WHERE generateselements_element_pipe__path=current_row.path AND xft_version=current_row.xft_version ORDER BY pipe_pipelinedetails_element_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_pipe_pipelineDetails_element_history( parent_row.pipe_pipelinedetails_element_id, child_count,$3,false,false);
              fullText := fullText || '(generateselements_element_pipelinedetails_element' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
          IF (current_row.customwebpage IS NOT NULL) THEN 
              fullText := fullText || '(customwebpage:string)=(' || REPLACE(REPLACE(current_row.customwebpage,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM pipe_pipelineDetails_parameter_history WHERE parameters_parameter_pipe_pipel_path=current_row.path AND xft_version=current_row.xft_version ORDER BY pipe_pipelinedetails_parameter_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_pipe_pipelineDetails_parameter_history( parent_row.pipe_pipelinedetails_parameter_id, child_count,$3,false,false);
              fullText := fullText || '(parameters_parameter_pipelinedetails_parameter' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
          IF (current_row.appliesto IS NOT NULL) THEN 
              fullText := fullText || '(appliesto:string)=(' || REPLACE(REPLACE(current_row.appliesto,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.pipelineDetails_info IS NOT NULL)) THEN
            fullText := fullText || '(pipelinedetails_info:integer)=(' || current_row.pipelinedetails_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_pipe_pipelineDetails_meta_data(current_row.pipelineDetails_info, child_count,$3,false,false);
              fullText := fullText || '(pipelinedetails_info_pipelinedetails_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.pipe_PipelineRepository_pipe_pipelinerepository_id IS NOT NULL)) THEN
            fullText := fullText || '(pipe_pipelinerepository_pipe_pipelinerepository_id:integer)=(' || current_row.pipe_pipelinerepository_pipe_pipelinerepository_id || ')';
        END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_pipe_pipelinedetails_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_pipe_pipelinedetails_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_pipe_pipelinedetails_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(pipe:pipelineDetails_meta_data)(';
      FOR current_row IN SELECT * FROM pipe_pipelineDetails_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_pipe_pipelinedetails_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_pipe_pipelinedetails_parameter(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_pipe_pipelinedetails_parameter(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(pipe:pipelineDetails_parameter)(';
      FOR current_row IN SELECT * FROM pipe_pipelineDetails_parameter WHERE  pipe_pipelinedetails_parameter_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.name IS NOT NULL) THEN 
              fullText := fullText || '(name:string)=(' || REPLACE(REPLACE(current_row.name,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.values_schemalink IS NOT NULL) THEN 
              fullText := fullText || '(values_schemalink:string)=(' || REPLACE(REPLACE(current_row.values_schemalink,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.values_csvvalues IS NOT NULL) THEN 
              fullText := fullText || '(values_csvvalues:string)=(' || REPLACE(REPLACE(current_row.values_csvvalues,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.description IS NOT NULL) THEN 
              fullText := fullText || '(description:string)=(' || REPLACE(REPLACE(current_row.description,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.pipelineDetails_parameter_info IS NOT NULL)) THEN
            fullText := fullText || '(pipelinedetails_parameter_info:integer)=(' || current_row.pipelinedetails_parameter_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_pipe_pipelineDetails_parameter_meta_data(current_row.pipelineDetails_parameter_info, child_count,$3,false,false);
              fullText := fullText || '(pipelinedetails_parameter_info_pipelinedetails_parameter_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.parameters_parameter_pipe_pipel_path IS NOT NULL)) THEN
            fullText := fullText || '(parameters_parameter_pipe_pipel_path:string)=(' || current_row.parameters_parameter_pipe_pipel_path || ')';
        END IF;
          IF (current_row.pipe_pipelinedetails_parameter_id IS NOT NULL) THEN 
              fullText := fullText || '(pipe_pipelinedetails_parameter_id:integer)=(' || current_row.pipe_pipelinedetails_parameter_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_pipe_pipelinedetails_parameter(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_pipe_pipelinedetails_parameter_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_pipe_pipelinedetails_parameter_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(pipe:pipelineDetails_parameter_history)(';
      FOR current_row IN SELECT * FROM pipe_pipelineDetails_parameter_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.name IS NOT NULL) THEN 
              fullText := fullText || '(name:string)=(' || REPLACE(REPLACE(current_row.name,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.values_schemalink IS NOT NULL) THEN 
              fullText := fullText || '(values_schemalink:string)=(' || REPLACE(REPLACE(current_row.values_schemalink,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.values_csvvalues IS NOT NULL) THEN 
              fullText := fullText || '(values_csvvalues:string)=(' || REPLACE(REPLACE(current_row.values_csvvalues,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.description IS NOT NULL) THEN 
              fullText := fullText || '(description:string)=(' || REPLACE(REPLACE(current_row.description,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.pipelineDetails_parameter_info IS NOT NULL)) THEN
            fullText := fullText || '(pipelinedetails_parameter_info:integer)=(' || current_row.pipelinedetails_parameter_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_pipe_pipelineDetails_parameter_meta_data(current_row.pipelineDetails_parameter_info, child_count,$3,false,false);
              fullText := fullText || '(pipelinedetails_parameter_info_pipelinedetails_parameter_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.parameters_parameter_pipe_pipel_path IS NOT NULL)) THEN
            fullText := fullText || '(parameters_parameter_pipe_pipel_path:string)=(' || current_row.parameters_parameter_pipe_pipel_path || ')';
        END IF;
          IF (current_row.pipe_pipelinedetails_parameter_id IS NOT NULL) THEN 
              fullText := fullText || '(pipe_pipelinedetails_parameter_id:integer)=(' || current_row.pipe_pipelinedetails_parameter_id || ')';
          END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_pipe_pipelinedetails_parameter_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_pipe_pipelinedetails_parameter_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_pipe_pipelinedetails_parameter_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(pipe:pipelineDetails_parameter_meta_data)(';
      FOR current_row IN SELECT * FROM pipe_pipelineDetails_parameter_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_pipe_pipelinedetails_parameter_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_pipe_pipelinerepository(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_pipe_pipelinerepository(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(pipe:PipelineRepository)(';
      FOR current_row IN SELECT * FROM pipe_PipelineRepository WHERE  pipe_pipelinerepository_id=$1
      LOOP
           row_ct := row_ct+1;
          
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM pipe_pipelineDetails WHERE pipe_PipelineRepository_pipe_pipelinerepository_id=current_row.pipe_pipelinerepository_id ORDER BY path
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_pipe_pipelineDetails( parent_row.path, child_count,$3,false,false);
              fullText := fullText || '(pipeline_pipelinedetails' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
        IF ((current_row.PipelineRepository_info IS NOT NULL)) THEN
            fullText := fullText || '(pipelinerepository_info:integer)=(' || current_row.pipelinerepository_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_pipe_PipelineRepository_meta_data(current_row.PipelineRepository_info, child_count,$3,false,false);
              fullText := fullText || '(pipelinerepository_info_pipelinerepository_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
          IF (current_row.pipe_pipelinerepository_id IS NOT NULL) THEN 
              fullText := fullText || '(pipe_pipelinerepository_id:integer)=(' || current_row.pipe_pipelinerepository_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_pipe_pipelinerepository(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_pipe_pipelinerepository_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_pipe_pipelinerepository_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(pipe:PipelineRepository_history)(';
      FOR current_row IN SELECT * FROM pipe_PipelineRepository_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM pipe_pipelineDetails_history WHERE pipe_PipelineRepository_pipe_pipelinerepository_id=current_row.pipe_pipelinerepository_id AND xft_version=current_row.xft_version ORDER BY path
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_pipe_pipelineDetails_history( parent_row.path, child_count,$3,false,false);
              fullText := fullText || '(pipeline_pipelinedetails' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
        IF ((current_row.PipelineRepository_info IS NOT NULL)) THEN
            fullText := fullText || '(pipelinerepository_info:integer)=(' || current_row.pipelinerepository_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_pipe_PipelineRepository_meta_data(current_row.PipelineRepository_info, child_count,$3,false,false);
              fullText := fullText || '(pipelinerepository_info_pipelinerepository_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
          IF (current_row.pipe_pipelinerepository_id IS NOT NULL) THEN 
              fullText := fullText || '(pipe_pipelinerepository_id:integer)=(' || current_row.pipe_pipelinerepository_id || ')';
          END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_pipe_pipelinerepository_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_pipe_pipelinerepository_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_pipe_pipelinerepository_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(pipe:PipelineRepository_meta_data)(';
      FOR current_row IN SELECT * FROM pipe_PipelineRepository_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_pipe_pipelinerepository_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_prov_process(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_prov_process(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(prov:process)(';
      FOR current_row IN SELECT * FROM prov_process WHERE  prov_process_id=$1
      LOOP
           row_ct := row_ct+1;
          
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM prov_processStep WHERE prov_process_prov_process_id=current_row.prov_process_id ORDER BY prov_processstep_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_prov_processStep( parent_row.prov_processstep_id, child_count,$3,false,false);
              fullText := fullText || '(processstep_processstep' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
        IF ((current_row.process_info IS NOT NULL)) THEN
            fullText := fullText || '(process_info:integer)=(' || current_row.process_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_prov_process_meta_data(current_row.process_info, child_count,$3,false,false);
              fullText := fullText || '(process_info_process_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
          IF (current_row.prov_process_id IS NOT NULL) THEN 
              fullText := fullText || '(prov_process_id:integer)=(' || current_row.prov_process_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_prov_process(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_prov_process_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_prov_process_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(prov:process_history)(';
      FOR current_row IN SELECT * FROM prov_process_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM prov_processStep_history WHERE prov_process_prov_process_id=current_row.prov_process_id AND xft_version=current_row.xft_version ORDER BY prov_processstep_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_prov_processStep_history( parent_row.prov_processstep_id, child_count,$3,false,false);
              fullText := fullText || '(processstep_processstep' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
        IF ((current_row.process_info IS NOT NULL)) THEN
            fullText := fullText || '(process_info:integer)=(' || current_row.process_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_prov_process_meta_data(current_row.process_info, child_count,$3,false,false);
              fullText := fullText || '(process_info_process_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
          IF (current_row.prov_process_id IS NOT NULL) THEN 
              fullText := fullText || '(prov_process_id:integer)=(' || current_row.prov_process_id || ')';
          END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_prov_process_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_prov_process_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_prov_process_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(prov:process_meta_data)(';
      FOR current_row IN SELECT * FROM prov_process_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_prov_process_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_prov_processstep(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_prov_processstep(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(prov:processStep)(';
      FOR current_row IN SELECT * FROM prov_processStep WHERE  prov_processstep_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.program IS NOT NULL) THEN 
              fullText := fullText || '(program:string)=(' || REPLACE(REPLACE(current_row.program,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.program_version IS NOT NULL) THEN 
              fullText := fullText || '(program_version:string)=(' || REPLACE(REPLACE(current_row.program_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.program_arguments IS NOT NULL) THEN 
              fullText := fullText || '(program_arguments:string)=(' || REPLACE(REPLACE(current_row.program_arguments,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.timestamp IS NOT NULL) THEN 
              fullText := fullText || '(timestamp:dateTime)=(' || current_row.timestamp || ')';
          END IF;
          IF (current_row.cvs IS NOT NULL) THEN 
              fullText := fullText || '(cvs:string)=(' || REPLACE(REPLACE(current_row.cvs,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.user_name IS NOT NULL) THEN 
              fullText := fullText || '(user_name:string)=(' || REPLACE(REPLACE(current_row.user_name,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.machine IS NOT NULL) THEN 
              fullText := fullText || '(machine:string)=(' || REPLACE(REPLACE(current_row.machine,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.platform IS NOT NULL) THEN 
              fullText := fullText || '(platform:string)=(' || REPLACE(REPLACE(current_row.platform,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.platform_version IS NOT NULL) THEN 
              fullText := fullText || '(platform_version:string)=(' || REPLACE(REPLACE(current_row.platform_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.compiler IS NOT NULL) THEN 
              fullText := fullText || '(compiler:string)=(' || REPLACE(REPLACE(current_row.compiler,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.compiler_version IS NOT NULL) THEN 
              fullText := fullText || '(compiler_version:string)=(' || REPLACE(REPLACE(current_row.compiler_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM prov_processStep_library WHERE prov_processStep_prov_processstep_id=current_row.prov_processstep_id ORDER BY prov_processstep_library_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_prov_processStep_library( parent_row.prov_processstep_library_id, child_count,$3,false,false);
              fullText := fullText || '(library_processstep_library' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
        IF ((current_row.processStep_info IS NOT NULL)) THEN
            fullText := fullText || '(processstep_info:integer)=(' || current_row.processstep_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_prov_processStep_meta_data(current_row.processStep_info, child_count,$3,false,false);
              fullText := fullText || '(processstep_info_processstep_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.prov_process_prov_process_id IS NOT NULL)) THEN
            fullText := fullText || '(prov_process_prov_process_id:integer)=(' || current_row.prov_process_prov_process_id || ')';
        END IF;
          IF (current_row.prov_processstep_id IS NOT NULL) THEN 
              fullText := fullText || '(prov_processstep_id:integer)=(' || current_row.prov_processstep_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_prov_processstep(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_prov_processstep_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_prov_processstep_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(prov:processStep_history)(';
      FOR current_row IN SELECT * FROM prov_processStep_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.program IS NOT NULL) THEN 
              fullText := fullText || '(program:string)=(' || REPLACE(REPLACE(current_row.program,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.program_version IS NOT NULL) THEN 
              fullText := fullText || '(program_version:string)=(' || REPLACE(REPLACE(current_row.program_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.program_arguments IS NOT NULL) THEN 
              fullText := fullText || '(program_arguments:string)=(' || REPLACE(REPLACE(current_row.program_arguments,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.timestamp IS NOT NULL) THEN 
              fullText := fullText || '(timestamp:dateTime)=(' || current_row.timestamp || ')';
          END IF;
          IF (current_row.cvs IS NOT NULL) THEN 
              fullText := fullText || '(cvs:string)=(' || REPLACE(REPLACE(current_row.cvs,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.user_name IS NOT NULL) THEN 
              fullText := fullText || '(user_name:string)=(' || REPLACE(REPLACE(current_row.user_name,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.machine IS NOT NULL) THEN 
              fullText := fullText || '(machine:string)=(' || REPLACE(REPLACE(current_row.machine,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.platform IS NOT NULL) THEN 
              fullText := fullText || '(platform:string)=(' || REPLACE(REPLACE(current_row.platform,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.platform_version IS NOT NULL) THEN 
              fullText := fullText || '(platform_version:string)=(' || REPLACE(REPLACE(current_row.platform_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.compiler IS NOT NULL) THEN 
              fullText := fullText || '(compiler:string)=(' || REPLACE(REPLACE(current_row.compiler,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.compiler_version IS NOT NULL) THEN 
              fullText := fullText || '(compiler_version:string)=(' || REPLACE(REPLACE(current_row.compiler_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM prov_processStep_library_history WHERE prov_processStep_prov_processstep_id=current_row.prov_processstep_id AND xft_version=current_row.xft_version ORDER BY prov_processstep_library_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_prov_processStep_library_history( parent_row.prov_processstep_library_id, child_count,$3,false,false);
              fullText := fullText || '(library_processstep_library' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
        IF ((current_row.processStep_info IS NOT NULL)) THEN
            fullText := fullText || '(processstep_info:integer)=(' || current_row.processstep_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_prov_processStep_meta_data(current_row.processStep_info, child_count,$3,false,false);
              fullText := fullText || '(processstep_info_processstep_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.prov_process_prov_process_id IS NOT NULL)) THEN
            fullText := fullText || '(prov_process_prov_process_id:integer)=(' || current_row.prov_process_prov_process_id || ')';
        END IF;
          IF (current_row.prov_processstep_id IS NOT NULL) THEN 
              fullText := fullText || '(prov_processstep_id:integer)=(' || current_row.prov_processstep_id || ')';
          END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_prov_processstep_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_prov_processstep_library(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_prov_processstep_library(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(prov:processStep_library)(';
      FOR current_row IN SELECT * FROM prov_processStep_library WHERE  prov_processstep_library_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.library IS NOT NULL) THEN 
              fullText := fullText || '(library:string)=(' || REPLACE(REPLACE(current_row.library,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.version IS NOT NULL) THEN 
              fullText := fullText || '(version:string)=(' || REPLACE(REPLACE(current_row.version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.processStep_library_info IS NOT NULL)) THEN
            fullText := fullText || '(processstep_library_info:integer)=(' || current_row.processstep_library_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_prov_processStep_library_meta_data(current_row.processStep_library_info, child_count,$3,false,false);
              fullText := fullText || '(processstep_library_info_processstep_library_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.prov_processStep_prov_processstep_id IS NOT NULL)) THEN
            fullText := fullText || '(prov_processstep_prov_processstep_id:integer)=(' || current_row.prov_processstep_prov_processstep_id || ')';
        END IF;
          IF (current_row.prov_processstep_library_id IS NOT NULL) THEN 
              fullText := fullText || '(prov_processstep_library_id:integer)=(' || current_row.prov_processstep_library_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_prov_processstep_library(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_prov_processstep_library_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_prov_processstep_library_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(prov:processStep_library_history)(';
      FOR current_row IN SELECT * FROM prov_processStep_library_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.library IS NOT NULL) THEN 
              fullText := fullText || '(library:string)=(' || REPLACE(REPLACE(current_row.library,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.version IS NOT NULL) THEN 
              fullText := fullText || '(version:string)=(' || REPLACE(REPLACE(current_row.version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.processStep_library_info IS NOT NULL)) THEN
            fullText := fullText || '(processstep_library_info:integer)=(' || current_row.processstep_library_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_prov_processStep_library_meta_data(current_row.processStep_library_info, child_count,$3,false,false);
              fullText := fullText || '(processstep_library_info_processstep_library_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.prov_processStep_prov_processstep_id IS NOT NULL)) THEN
            fullText := fullText || '(prov_processstep_prov_processstep_id:integer)=(' || current_row.prov_processstep_prov_processstep_id || ')';
        END IF;
          IF (current_row.prov_processstep_library_id IS NOT NULL) THEN 
              fullText := fullText || '(prov_processstep_library_id:integer)=(' || current_row.prov_processstep_library_id || ')';
          END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_prov_processstep_library_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_prov_processstep_library_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_prov_processstep_library_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(prov:processStep_library_meta_data)(';
      FOR current_row IN SELECT * FROM prov_processStep_library_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_prov_processstep_library_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_prov_processstep_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_prov_processstep_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(prov:processStep_meta_data)(';
      FOR current_row IN SELECT * FROM prov_processStep_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_prov_processstep_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_scr_screeningassessment(character varying, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_scr_screeningassessment(character varying, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(scr:screeningAssessment)(';
      FOR current_row IN SELECT * FROM scr_screeningAssessment WHERE  id=$1
      LOOP
           row_ct := row_ct+1;
          
        IF ((current_row.id IS NOT NULL)) THEN
            fullText := fullText || '(id:string)=(' || current_row.id || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := ie_xnat_imageAssessorData(current_row.id, child_count,$3,false,false);
              fullText := fullText || '(imageassessordata_imageassessordata:XFTItem)=(' || tempText || ')';
        END IF;
          IF (current_row.rater IS NOT NULL) THEN 
              fullText := fullText || '(rater:string)=(' || REPLACE(REPLACE(current_row.rater,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.comments IS NOT NULL) THEN 
              fullText := fullText || '(comments:string)=(' || REPLACE(REPLACE(current_row.comments,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.pass IS NOT NULL) THEN 
              fullText := fullText || '(pass:string)=(' || REPLACE(REPLACE(current_row.pass,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM scr_screeningScanData WHERE scans_scan_scr_screeningAssessm_id=current_row.id ORDER BY scr_screeningscandata_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_scr_screeningScanData( parent_row.scr_screeningscandata_id, child_count,$3,false,false);
              fullText := fullText || '(scans_scan_screeningscandata' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
        IF ((current_row.screeningAssessment_info IS NOT NULL)) THEN
            fullText := fullText || '(screeningassessment_info:integer)=(' || current_row.screeningassessment_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_scr_screeningAssessment_meta_data(current_row.screeningAssessment_info, child_count,$3,false,false);
              fullText := fullText || '(screeningassessment_info_screeningassessment_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
           child_count := child_count+1;
           tempText := NULL;
           tempText := ie_xnat_imageAssessorData( $1, child_count,$3,$4,false);
              fullText := fullText || '(imageassessordata_imageassessordata:XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
          
      END IF;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_scr_screeningassessment(character varying, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_scr_screeningassessment_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_scr_screeningassessment_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(scr:screeningAssessment_history)(';
      FOR current_row IN SELECT * FROM scr_screeningAssessment_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
        IF ((current_row.id IS NOT NULL)) THEN
            fullText := fullText || '(id:string)=(' || current_row.id || ')';
           child_count := child_count+1;
           tempText := NULL;
           DECLARE
           	ext_row RECORD;
           BEGIN 
           	FOR ext_row IN SELECT * FROM xnat_imageAssessorData_history WHERE id=current_row.id AND xft_version=current_row.xft_version
           	LOOP
 -- 632
           	   tempText := ie_xnat_imageAssessorData_history(ext_row.history_id, child_count,$3,false,false);
           	      fullText := fullText || '(imageassessordata_imageassessordata:XFTItem)=(' || tempText || ')';
           	END LOOP;
           END;
        END IF;
          IF (current_row.rater IS NOT NULL) THEN 
              fullText := fullText || '(rater:string)=(' || REPLACE(REPLACE(current_row.rater,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.comments IS NOT NULL) THEN 
              fullText := fullText || '(comments:string)=(' || REPLACE(REPLACE(current_row.comments,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.pass IS NOT NULL) THEN 
              fullText := fullText || '(pass:string)=(' || REPLACE(REPLACE(current_row.pass,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM scr_screeningScanData_history WHERE scans_scan_scr_screeningAssessm_id=current_row.id AND xft_version=current_row.xft_version ORDER BY scr_screeningscandata_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_scr_screeningScanData_history( parent_row.scr_screeningscandata_id, child_count,$3,false,false);
              fullText := fullText || '(scans_scan_screeningscandata' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
        IF ((current_row.screeningAssessment_info IS NOT NULL)) THEN
            fullText := fullText || '(screeningassessment_info:integer)=(' || current_row.screeningassessment_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_scr_screeningAssessment_meta_data(current_row.screeningAssessment_info, child_count,$3,false,false);
              fullText := fullText || '(screeningassessment_info_screeningassessment_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
      IF (row_ct=0) THEN 
           child_count := child_count+1;
           tempText := NULL;
           tempText := ie_xnat_imageAssessorData_history( $1, child_count,$3,$4,false);
              fullText := fullText || '(imageassessordata_imageassessordata:XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
          
      END IF;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_scr_screeningassessment_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_scr_screeningassessment_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_scr_screeningassessment_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(scr:screeningAssessment_meta_data)(';
      FOR current_row IN SELECT * FROM scr_screeningAssessment_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_scr_screeningassessment_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_scr_screeningscandata(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_scr_screeningscandata(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(scr:screeningScanData)(';
      FOR current_row IN SELECT * FROM scr_screeningScanData WHERE  scr_screeningscandata_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.imagescan_id IS NOT NULL) THEN 
              fullText := fullText || '(imagescan_id:string)=(' || REPLACE(REPLACE(current_row.imagescan_id,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.comments IS NOT NULL) THEN 
              fullText := fullText || '(comments:string)=(' || REPLACE(REPLACE(current_row.comments,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.pass IS NOT NULL) THEN 
              fullText := fullText || '(pass:string)=(' || REPLACE(REPLACE(current_row.pass,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.screeningScanData_info IS NOT NULL)) THEN
            fullText := fullText || '(screeningscandata_info:integer)=(' || current_row.screeningscandata_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_scr_screeningScanData_meta_data(current_row.screeningScanData_info, child_count,$3,false,false);
              fullText := fullText || '(screeningscandata_info_screeningscandata_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.scans_scan_scr_screeningAssessm_id IS NOT NULL)) THEN
            fullText := fullText || '(scans_scan_scr_screeningassessm_id:string)=(' || current_row.scans_scan_scr_screeningassessm_id || ')';
        END IF;
          IF (current_row.scr_screeningscandata_id IS NOT NULL) THEN 
              fullText := fullText || '(scr_screeningscandata_id:integer)=(' || current_row.scr_screeningscandata_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_scr_screeningscandata(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_scr_screeningscandata_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_scr_screeningscandata_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(scr:screeningScanData_history)(';
      FOR current_row IN SELECT * FROM scr_screeningScanData_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.imagescan_id IS NOT NULL) THEN 
              fullText := fullText || '(imagescan_id:string)=(' || REPLACE(REPLACE(current_row.imagescan_id,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.comments IS NOT NULL) THEN 
              fullText := fullText || '(comments:string)=(' || REPLACE(REPLACE(current_row.comments,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.pass IS NOT NULL) THEN 
              fullText := fullText || '(pass:string)=(' || REPLACE(REPLACE(current_row.pass,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.screeningScanData_info IS NOT NULL)) THEN
            fullText := fullText || '(screeningscandata_info:integer)=(' || current_row.screeningscandata_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_scr_screeningScanData_meta_data(current_row.screeningScanData_info, child_count,$3,false,false);
              fullText := fullText || '(screeningscandata_info_screeningscandata_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.scans_scan_scr_screeningAssessm_id IS NOT NULL)) THEN
            fullText := fullText || '(scans_scan_scr_screeningassessm_id:string)=(' || current_row.scans_scan_scr_screeningassessm_id || ')';
        END IF;
          IF (current_row.scr_screeningscandata_id IS NOT NULL) THEN 
              fullText := fullText || '(scr_screeningscandata_id:integer)=(' || current_row.scr_screeningscandata_id || ')';
          END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_scr_screeningscandata_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_scr_screeningscandata_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_scr_screeningscandata_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(scr:screeningScanData_meta_data)(';
      FOR current_row IN SELECT * FROM scr_screeningScanData_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_scr_screeningscandata_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_val_additionalval(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_val_additionalval(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(val:additionalVal)(';
      FOR current_row IN SELECT * FROM val_additionalVal WHERE  val_additionalval_id=$1
      LOOP
           row_ct := row_ct+1;
          
        IF ((current_row.additionalVal_info IS NOT NULL)) THEN
            fullText := fullText || '(additionalval_info:integer)=(' || current_row.additionalval_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_val_additionalVal_meta_data(current_row.additionalVal_info, child_count,$3,false,false);
              fullText := fullText || '(additionalval_info_additionalval_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
          IF (current_row.val_additionalval_id IS NOT NULL) THEN 
              fullText := fullText || '(val_additionalval_id:integer)=(' || current_row.val_additionalval_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_val_additionalval(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_val_additionalval_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_val_additionalval_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(val:additionalVal_history)(';
      FOR current_row IN SELECT * FROM val_additionalVal_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
        IF ((current_row.additionalVal_info IS NOT NULL)) THEN
            fullText := fullText || '(additionalval_info:integer)=(' || current_row.additionalval_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_val_additionalVal_meta_data(current_row.additionalVal_info, child_count,$3,false,false);
              fullText := fullText || '(additionalval_info_additionalval_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
          IF (current_row.val_additionalval_id IS NOT NULL) THEN 
              fullText := fullText || '(val_additionalval_id:integer)=(' || current_row.val_additionalval_id || ')';
          END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_val_additionalval_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_val_additionalval_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_val_additionalval_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(val:additionalVal_meta_data)(';
      FOR current_row IN SELECT * FROM val_additionalVal_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_val_additionalval_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_val_protocoldata(character varying, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_val_protocoldata(character varying, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(val:protocolData)(';
      FOR current_row IN SELECT * FROM val_protocolData WHERE  id=$1
      LOOP
           row_ct := row_ct+1;
          
        IF ((current_row.id IS NOT NULL)) THEN
            fullText := fullText || '(id:string)=(' || current_row.id || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := ie_xnat_imageAssessorData(current_row.id, child_count,$3,false,false);
              fullText := fullText || '(imageassessordata_imageassessordata:XFTItem)=(' || tempText || ')';
        END IF;
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM val_protocolData_condition WHERE check_conditions_condition_val__id=current_row.id ORDER BY val_protocoldata_condition_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_val_protocolData_condition( parent_row.val_protocoldata_condition_id, child_count,$3,false,false);
              fullText := fullText || '(check_conditions_condition_protocoldata_condition' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM val_protocolData_comment WHERE check_comments_comment_val_prot_id=current_row.id ORDER BY val_protocoldata_comment_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_val_protocolData_comment( parent_row.val_protocoldata_comment_id, child_count,$3,false,false);
              fullText := fullText || '(check_comments_comment_protocoldata_comment' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
        IF ((current_row.check_additionalval_val_additionalval_id IS NOT NULL)) THEN
            fullText := fullText || '(check_additionalval_val_additionalval_id:integer)=(' || current_row.check_additionalval_val_additionalval_id || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_val_additionalVal(current_row.check_additionalval_val_additionalval_id, child_count,$3,false,false);
              fullText := fullText || '(check_additionalval_additionalval:XFTItem)=(' || tempText || ')';
        END IF;
          IF (current_row.check_status IS NOT NULL) THEN 
              fullText := fullText || '(check_status:string)=(' || REPLACE(REPLACE(current_row.check_status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF($3) THEN 
        DECLARE 
  --    198
        parent_row RECORD; 
        loop_count int4:=0; 
        BEGIN 
        FOR parent_row IN SELECT * FROM val_protocolData_scan_check WHERE scans_scan_check_val_protocolDa_id=current_row.id ORDER BY val_protocoldata_scan_check_id
        LOOP
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_val_protocolData_scan_check( parent_row.val_protocoldata_scan_check_id, child_count,$3,false,false);
              fullText := fullText || '(scans_scan_check_protocoldata_scan_check' || loop_count || ':XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
              loop_count := loop_count+1;
        END LOOP;
        END;
        END IF; 
        IF ((current_row.protocolData_info IS NOT NULL)) THEN
            fullText := fullText || '(protocoldata_info:integer)=(' || current_row.protocoldata_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_val_protocolData_meta_data(current_row.protocolData_info, child_count,$3,false,false);
              fullText := fullText || '(protocoldata_info_protocoldata_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
      END LOOP;
      IF (row_ct=0) THEN 
           child_count := child_count+1;
           tempText := NULL;
           tempText := ie_xnat_imageAssessorData( $1, child_count,$3,$4,false);
              fullText := fullText || '(imageassessordata_imageassessordata:XFTItem)=';
              fullText := fullText || '(' || tempText || ')';
          
      END IF;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_val_protocoldata(character varying, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_val_protocoldata_comment(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_val_protocoldata_comment(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(val:protocolData_comment)(';
      FOR current_row IN SELECT * FROM val_protocolData_comment WHERE  val_protocoldata_comment_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.comment IS NOT NULL) THEN 
              fullText := fullText || '(comment:string)=(' || REPLACE(REPLACE(current_row.comment,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.username IS NOT NULL) THEN 
              fullText := fullText || '(username:string)=(' || REPLACE(REPLACE(current_row.username,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.datetime IS NOT NULL) THEN 
              fullText := fullText || '(datetime:dateTime)=(' || current_row.datetime || ')';
          END IF;
        IF ((current_row.protocolData_comment_info IS NOT NULL)) THEN
            fullText := fullText || '(protocoldata_comment_info:integer)=(' || current_row.protocoldata_comment_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_val_protocolData_comment_meta_data(current_row.protocolData_comment_info, child_count,$3,false,false);
              fullText := fullText || '(protocoldata_comment_info_protocoldata_comment_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.check_comments_comment_val_prot_id IS NOT NULL)) THEN
            fullText := fullText || '(check_comments_comment_val_prot_id:string)=(' || current_row.check_comments_comment_val_prot_id || ')';
        END IF;
          IF (current_row.val_protocoldata_comment_id IS NOT NULL) THEN 
              fullText := fullText || '(val_protocoldata_comment_id:integer)=(' || current_row.val_protocoldata_comment_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_val_protocoldata_comment(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_val_protocoldata_comment_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_val_protocoldata_comment_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(val:protocolData_comment_history)(';
      FOR current_row IN SELECT * FROM val_protocolData_comment_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.comment IS NOT NULL) THEN 
              fullText := fullText || '(comment:string)=(' || REPLACE(REPLACE(current_row.comment,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.username IS NOT NULL) THEN 
              fullText := fullText || '(username:string)=(' || REPLACE(REPLACE(current_row.username,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.datetime IS NOT NULL) THEN 
              fullText := fullText || '(datetime:dateTime)=(' || current_row.datetime || ')';
          END IF;
        IF ((current_row.protocolData_comment_info IS NOT NULL)) THEN
            fullText := fullText || '(protocoldata_comment_info:integer)=(' || current_row.protocoldata_comment_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_val_protocolData_comment_meta_data(current_row.protocolData_comment_info, child_count,$3,false,false);
              fullText := fullText || '(protocoldata_comment_info_protocoldata_comment_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.check_comments_comment_val_prot_id IS NOT NULL)) THEN
            fullText := fullText || '(check_comments_comment_val_prot_id:string)=(' || current_row.check_comments_comment_val_prot_id || ')';
        END IF;
          IF (current_row.val_protocoldata_comment_id IS NOT NULL) THEN 
              fullText := fullText || '(val_protocoldata_comment_id:integer)=(' || current_row.val_protocoldata_comment_id || ')';
          END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_val_protocoldata_comment_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_val_protocoldata_comment_meta_data(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_val_protocoldata_comment_meta_data(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(val:protocolData_comment_meta_data)(';
      FOR current_row IN SELECT * FROM val_protocolData_comment_meta_data WHERE  meta_data_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:string)=(' || REPLACE(REPLACE(current_row.xft_version,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.last_modified IS NOT NULL) THEN 
              fullText := fullText || '(last_modified:dateTime)=(' || current_row.last_modified || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.activation_date IS NOT NULL) THEN 
              fullText := fullText || '(activation_date:dateTime)=(' || current_row.activation_date || ')';
          END IF;
          IF (current_row.row_last_modified IS NOT NULL) THEN 
              fullText := fullText || '(row_last_modified:dateTime)=(' || current_row.row_last_modified || ')';
          END IF;
          IF (current_row.insert_date IS NOT NULL) THEN 
              fullText := fullText || '(insert_date:dateTime)=(' || current_row.insert_date || ')';
          END IF;
        IF ((current_row.activation_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(activation_user_xdat_user_id:integer)=(' || current_row.activation_user_xdat_user_id || ')';
        END IF;
        IF ((current_row.insert_user_xdat_user_id IS NOT NULL)) THEN
            fullText := fullText || '(insert_user_xdat_user_id:integer)=(' || current_row.insert_user_xdat_user_id || ')';
        END IF;
          IF (current_row.origin IS NOT NULL) THEN 
              fullText := fullText || '(origin:string)=(' || REPLACE(REPLACE(current_row.origin,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.modified IS NOT NULL) THEN 
              fullText := fullText || '(modified:integer)=(' || current_row.modified || ')';
          END IF;
          IF (current_row.shareable IS NOT NULL) THEN 
              fullText := fullText || '(shareable:integer)=(' || current_row.shareable || ')';
          END IF;
          IF (current_row.meta_data_id IS NOT NULL) THEN 
              fullText := fullText || '(meta_data_id:integer)=(' || current_row.meta_data_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_val_protocoldata_comment_meta_data(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_val_protocoldata_condition(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_val_protocoldata_condition(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(val:protocolData_condition)(';
      FOR current_row IN SELECT * FROM val_protocolData_condition WHERE  val_protocoldata_condition_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.verified IS NOT NULL) THEN 
              fullText := fullText || '(verified:string)=(' || REPLACE(REPLACE(current_row.verified,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.diagnosis IS NOT NULL) THEN 
              fullText := fullText || '(diagnosis:string)=(' || REPLACE(REPLACE(current_row.diagnosis,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.id IS NOT NULL) THEN 
              fullText := fullText || '(id:string)=(' || REPLACE(REPLACE(current_row.id,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.xmlpath IS NOT NULL) THEN 
              fullText := fullText || '(xmlpath:string)=(' || REPLACE(REPLACE(current_row.xmlpath,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.protocolData_condition_info IS NOT NULL)) THEN
            fullText := fullText || '(protocoldata_condition_info:integer)=(' || current_row.protocoldata_condition_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_val_protocolData_condition_meta_data(current_row.protocolData_condition_info, child_count,$3,false,false);
              fullText := fullText || '(protocoldata_condition_info_protocoldata_condition_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.check_conditions_condition_val__id IS NOT NULL)) THEN
            fullText := fullText || '(check_conditions_condition_val__id:string)=(' || current_row.check_conditions_condition_val__id || ')';
        END IF;
          IF (current_row.val_protocoldata_condition_id IS NOT NULL) THEN 
              fullText := fullText || '(val_protocoldata_condition_id:integer)=(' || current_row.val_protocoldata_condition_id || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_val_protocoldata_condition(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
-- Name: i_val_protocoldata_condition_history(integer, integer, boolean, boolean, boolean); Type: FUNCTION; Schema: public; Owner: xnat
--

CREATE FUNCTION public.i_val_protocoldata_condition_history(integer, integer, boolean, boolean, boolean) RETURNS text
    LANGUAGE plpgsql
    AS $_$
    declare
     current_row RECORD;
     tempText TEXT;
     fullText TEXT;
     row_ct int4;
     local_count int4;
     child_count int4;
    begin
  --    72
      local_count := $2;
      child_count := $2;
      row_ct := 0;
      fullText := 'Item:(' || local_count || '(val:protocolData_condition_history)(';
      FOR current_row IN SELECT * FROM val_protocolData_condition_history WHERE  history_id=$1
      LOOP
           row_ct := row_ct+1;
          
          IF (current_row.verified IS NOT NULL) THEN 
              fullText := fullText || '(verified:string)=(' || REPLACE(REPLACE(current_row.verified,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.diagnosis IS NOT NULL) THEN 
              fullText := fullText || '(diagnosis:string)=(' || REPLACE(REPLACE(current_row.diagnosis,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.id IS NOT NULL) THEN 
              fullText := fullText || '(id:string)=(' || REPLACE(REPLACE(current_row.id,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.status IS NOT NULL) THEN 
              fullText := fullText || '(status:string)=(' || REPLACE(REPLACE(current_row.status,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
          IF (current_row.xmlpath IS NOT NULL) THEN 
              fullText := fullText || '(xmlpath:string)=(' || REPLACE(REPLACE(current_row.xmlpath,'(','*OPEN*'),')','*CLOSE*') || ')';
          END IF;
        IF ((current_row.protocolData_condition_info IS NOT NULL)) THEN
            fullText := fullText || '(protocoldata_condition_info:integer)=(' || current_row.protocoldata_condition_info || ')';
 -- 693
           child_count := child_count+1;
           tempText := NULL;
           tempText := i_val_protocolData_condition_meta_data(current_row.protocolData_condition_info, child_count,$3,false,false);
              fullText := fullText || '(protocoldata_condition_info_protocoldata_condition_meta_data:XFTItem)=(' || tempText || ')';
        END IF;
  -- 475
        IF ((current_row.check_conditions_condition_val__id IS NOT NULL)) THEN
            fullText := fullText || '(check_conditions_condition_val__id:string)=(' || current_row.check_conditions_condition_val__id || ')';
        END IF;
          IF (current_row.val_protocoldata_condition_id IS NOT NULL) THEN 
              fullText := fullText || '(val_protocoldata_condition_id:integer)=(' || current_row.val_protocoldata_condition_id || ')';
          END IF;
          IF (current_row.xft_version IS NOT NULL) THEN 
              fullText := fullText || '(xft_version:integer)=(' || current_row.xft_version || ')';
          END IF;
          IF (current_row.history_id IS NOT NULL) THEN 
              fullText := fullText || '(history_id:integer)=(' || current_row.history_id || ')';
          END IF;
          IF (current_row.change_user IS NOT NULL) THEN 
              fullText := fullText || '(change_user:integer)=(' || current_row.change_user || ')';
          END IF;
          IF (current_row.change_date IS NOT NULL) THEN 
              fullText := fullText || '(change_date:dateTime)=(' || current_row.change_date || ')';
          END IF;
          IF (current_row.previous_change_date IS NOT NULL) THEN 
              fullText := fullText || '(previous_change_date:dateTime)=(' || current_row.previous_change_date || ')';
          END IF;
      END LOOP;
	   fullText := fullText || ')*END_ITEM*' || local_count || ')';
	
	 RETURN fullText;
    end;
$_$;


ALTER FUNCTION public.i_val_protocoldata_condition_history(integer, integer, boolean, boolean, boolean) OWNER TO xnat;

--
