text:
/******************************************************************
Change Script 3.0.10.97
1. create new function to pmt_is_data_groups support consistantcy checks
2. add new fields to the taxonomy table to support ownership
3. update pmt_taxonomies function for current model
4. create new pmt_edit_taxonomy function
5. create new pmt_edit_classification function
6. create pmt_taxonomy_search to filter all active taxonomies
  by search criteria, and exclude returns by taxonomy_id
7. create pmt_taxonomy_count to return count of filtered taxonomies
8. create pmt_classification_search to filter all active classifications
  by search criteria
9. create pmt_classification_count to count filtered active classifications
  by search criteria
******************************************************************/
INSERT INTO version(_version, _iteration, _changeset) VALUES (3.0, 10, 97);
-- select * from version order by _iteration desc, _changeset desc;

/*************************************************************************
  1. create new function to pmt_is_data_groups support consistantcy checks
  select id from classification where taxonomy_id = 1
  select * from pmt_is_data_groups(ARRAY[2237]);
*************************************************************************/
-- pmt_is_data_groups
CREATE OR REPLACE FUNCTION pmt_is_data_groups(classification_ids integer[]) RETURNS boolean AS $$
DECLARE
	rec_count integer;
BEGIN
     IF $1 IS NULL OR array_length($1, 1) = 0 THEN
       -- allowing nulls to be truthy
       RETURN true;
     END IF;

     SELECT INTO rec_count count(DISTINCT id)::int FROM classification WHERE classification.id = ANY($1) AND taxonomy_id = 1;
     -- SELECT count(DISTINCT id)::int,array_length(ARRAY[1068,769,768], 1)  FROM classification WHERE classification.id = ANY(ARRAY[1068,769,768]) AND taxonomy_id = 1;

     IF rec_count = array_length($1, 1) THEN
       RETURN TRUE;
     ELSE
       RETURN FALSE;
     END IF;

EXCEPTION WHEN OTHERS THEN
    RETURN FALSE;
END;
$$ LANGUAGE 'plpgsql';

/******************************************************************
 2. add new taxonomy table to support ownership
******************************************************************/
-- add new fields
ALTER TABLE taxonomy
	ADD COLUMN _core boolean default false,
	ADD COLUMN data_group_ids integer[];
-- add new constraint
ALTER TABLE taxonomy DROP CONSTRAINT IF EXISTS chk_taxonomy_dg_chk;
ALTER TABLE taxonomy
	ADD CONSTRAINT chk_taxonomy_dg_chk CHECK (pmt_is_data_groups(data_group_ids)) NOT VALID;

/******************************************************************
 3. update pmt_taxonomies function for current model
   select * from pmt_taxonomies(1,false);
******************************************************************/
-- drop old 8.0 function
DROP FUNCTION IF EXISTS pmt_taxonomies(character varying);
-- new function to replace old
CREATE OR REPLACE FUNCTION pmt_taxonomies(instance_id integer, return_core boolean) RETURNS SETOF pmt_json_result_type AS $$
DECLARE
	valid_instance record;
	execute_statement text;
	rec record;
	error_msg text;
BEGIN

   -- validate instance id
   IF $1 IS NOT NULL THEN
     SELECT INTO valid_instance * FROM instance WHERE id = $1;
     IF valid_instance IS NULL THEN
       FOR rec IN SELECT row_to_json(j) FROM( SELECT 'Error: provided instance_id is invalid.' AS error ) as j LOOP RETURN NEXT rec; END LOOP;
     END IF;
   END IF;

   -- return instance specific taxonomies
   IF valid_instance IS NOT NULL THEN
     -- return core
     IF return_core THEN
       execute_statement:= 'SELECT * FROM taxonomy WHERE data_group_ids <@ valid_instance.data_group_ids AND _active = true';
     -- do not return core
     ELSE
       execute_statement:= 'SELECT * FROM taxonomy WHERE data_group_ids <@ valid_instance.data_group_ids AND _active = true AND _core = false';
     END IF;
   -- return all instance taxonomies
   ELSE
     -- return core
     IF return_core THEN
       execute_statement:= 'SELECT * FROM taxonomy WHERE _active = true';
     -- do not return core
     ELSE
       execute_statement:= 'SELECT * FROM taxonomy WHERE _active = true AND _core = false';
     END IF;
   END IF;

  RAISE NOTICE 'Execute statement: %', execute_statement;

  FOR rec IN EXECUTE 'SELECT row_to_json(j) FROM (' || execute_statement || ')j' LOOP
	RETURN NEXT rec;
  END LOOP;

EXCEPTION WHEN others THEN
  GET STACKED DIAGNOSTICS error_msg = MESSAGE_TEXT;
    RAISE NOTICE 'Internal Error - Contact your DBA with the following error message: %', error_msg;
END;
$$ LANGUAGE 'plpgsql';

/******************************************************************
 4. create new pmt_edit_taxonomy function
   select * from pmt_edit_taxonomy(1,34,null,'{"_name": "Test Taxonomy","_description": "testing"}',false); -- create
   select * from pmt_edit_taxonomy(1,34,85,'{"_description": "testing update"}',false); -- update
   select * from pmt_edit_taxonomy(1,34,85,null,true); -- delete
   select * from taxonomy where _name = 'Test Taxonomy'
   delete from taxonomy where _name = 'Test Taxonomy'
******************************************************************/
CREATE OR REPLACE FUNCTION pmt_edit_taxonomy(instance_id integer, user_id integer, taxonomy_id integer, key_value_data json, delete_record boolean DEFAULT false)
  RETURNS SETOF pmt_json_result_type AS $$
DECLARE
	valid_taxonomy_id integer;
	new_taxonomy_id integer;
	username text;
	valid_user_instance record;
	t_id integer;
	json record;
	column_record record;
	execute_statement text;
	invalid_editing_columns text[];
	users_role record;
	rec record;
	error_msg1 text;
	error_msg2 text;
	error_msg3 text;
BEGIN

  -- set columns that are not editable via the parameters
  invalid_editing_columns := ARRAY['id', '_active', '_retired_by', '_created_by', '_created_date', '_updated_by', '_updated_date', 'data_group_ids', '_core' ];

  -- instance_id is required for all operations
  IF ($1 IS NULL) THEN
	FOR rec IN (SELECT row_to_json(j) FROM(select null as id, 'Error: instance_id is a required parameter for all operations.' as message) j) LOOP  RETURN NEXT rec; END LOOP; RETURN;
  END IF;
  -- user_id is required for all operations
  IF ($2 IS NULL) THEN
	FOR rec IN (SELECT row_to_json(j) FROM(select null as id, 'Error: user_id is a required parameter for all operations.' as message) j) LOOP  RETURN NEXT rec; END LOOP; RETURN;
  END IF;

  -- update/create operation
  IF NOT ($5) THEN
    -- json is required
    IF ($4 IS NULL) THEN
      FOR rec IN (SELECT row_to_json(j) FROM(select null as id, 'Error: The json parameter is required for a create/update operation.' as message) j) LOOP  RETURN NEXT rec; END LOOP; RETURN;
    END IF;
  -- delete operation
  ELSE
    -- taxonomy id is requried
    IF ($3 IS NULL) THEN
      FOR rec IN (SELECT row_to_json(j) FROM(select null as id, 'Error: taxonomy_id is required for a delete operation.' as message) j) LOOP  RETURN NEXT rec; END LOOP; RETURN;
    ELSE
      SELECT INTO valid_taxonomy_id id FROM taxonomy WHERE id = $3;
      IF valid_taxonomy_id IS NULL THEN
        FOR rec IN (SELECT row_to_json(j) FROM(select null as id, 'Error: The provided taxonomy_id is invalid.' as message) j) LOOP  RETURN NEXT rec; END LOOP; RETURN;
      END IF;
    END IF;
  END IF;

  -- get users name
  SELECT INTO username _username FROM users WHERE users.id = $2;
  -- get user role
  SELECT INTO valid_user_instance * FROM _user_instances WHERE _user_instances.user_id = $2 AND _user_instances.instance_id = $1;
  -- valiate user access on instance
  IF valid_user_instance.user_id IS NOT NULL THEN
    SELECT INTO users_role * FROM role WHERE id = valid_user_instance.role_id;
    RAISE NOTICE 'Role: %', valid_user_instance.role;
  ELSE
    FOR rec IN (SELECT row_to_json(j) FROM(select null as id, 'Error: User does not have authorization on the provided instance.' as message) j) LOOP  RETURN NEXT rec; END LOOP; RETURN;
  END IF;

  -- validate user's authorization to edit at the entity level (required role with: _security = true)
  IF (SELECT _security FROM role WHERE id = valid_user_instance.role_id) THEN
    -- create operation
    IF ($3 IS NULL) THEN
      EXECUTE 'INSERT INTO taxonomy(data_group_ids, _created_by, _updated_by) VALUES (ARRAY[' || array_to_string(valid_user_instance.data_group_ids, ',') || '], ' || quote_literal(valid_user_instance.username) ||
      ',' || quote_literal(valid_user_instance.username) || ') RETURNING id;' INTO new_taxonomy_id;
      -- RAISE NOTICE 'Created new taxonomy with id: %', new_taxonomy_id;
    -- update/delete operations
    ELSE
      -- validate users authorization to edit requested taxonomy
      IF (SELECT valid_user_instance.data_group_ids @> data_group_ids FROM taxonomy WHERE id = $3) THEN
        -- delete operation
        IF ($5) THEN
          UPDATE taxonomy SET _active = false, _updated_by = quote_literal(valid_user_instance.username) WHERE id = $3;
          UPDATE classification SET _active = false, _updated_by = quote_literal(valid_user_instance.username) WHERE classification.taxonomy_id = $3;
        END IF;
      ELSE
        FOR rec IN (SELECT row_to_json(j) FROM(select null as id, 'Error: User does not have authorization to edit this taxonomy.' as message) j) LOOP  RETURN NEXT rec; END LOOP; RETURN;
      END IF;
    END IF;
  ELSE
    FOR rec IN (SELECT row_to_json(j) FROM(select null as id, 'Error: The user does not have authorization to edit taxonomies for the provided instance.' as message) j) LOOP  RETURN NEXT rec; END LOOP; RETURN;
  END IF;

  -- assign the activity_id to use in statements
  IF new_taxonomy_id IS NOT NULL THEN
    t_id := new_taxonomy_id;
  ELSE
    t_id := $3;
  END IF;

 -- loop through the columns of the activity table
  FOR json IN (SELECT * FROM json_each_text($4)) LOOP
    RAISE NOTICE 'JSON key/value: %', lower(json.key) || ':' || json.value;
    -- get the column information for column that user is requesting to edit
    FOR column_record IN (SELECT * FROM information_schema.columns WHERE table_schema='public' AND table_name='taxonomy' AND column_name != ALL(invalid_editing_columns) AND lower(column_name) = lower(json.key)) LOOP
      RAISE NOTICE 'Editing column: %', column_record.column_name;
      RAISE NOTICE 'Assigning new value: %', json.value;
      execute_statement := null;
      CASE column_record.data_type
        WHEN 'integer', 'numeric' THEN
          IF (SELECT pmt_isnumeric(json.value)) THEN
            execute_statement := 'UPDATE taxonomy SET ' || column_record.column_name || ' = ' || json.value || ' WHERE id = ' || t_id;
          END IF;
          IF (lower(json.value) = 'null') THEN
            execute_statement := 'UPDATE taxonomy SET ' || column_record.column_name || ' = null WHERE id = ' || t_id;
          END IF;
        ELSE
          -- if the value has the text null then assign the column value null
          IF (lower(json.value) = 'null') THEN
            execute_statement := 'UPDATE taxonomy SET ' || column_record.column_name || ' = null WHERE id = ' || t_id;
          ELSE
            execute_statement := 'UPDATE taxonomy SET ' || column_record.column_name || ' = ' || quote_literal(json.value) || ' WHERE id = ' || t_id;
          END IF;
      END CASE;
      IF execute_statement IS NOT NULL THEN
        RAISE NOTICE 'Statement: %', execute_statement;
        EXECUTE execute_statement;

        EXECUTE 'UPDATE taxonomy SET _updated_by = ' || quote_literal(username) || ', _updated_date = ' || quote_literal(current_date) || ' WHERE  id = ' || t_id;
      END IF;
    END LOOP;
  END LOOP;

  -- editing completed successfullly
  FOR rec IN (SELECT row_to_json(j) FROM(select t_id as id, 'Success' as message) j) LOOP  RETURN NEXT rec; END LOOP; RETURN;

EXCEPTION WHEN others THEN
    GET STACKED DIAGNOSTICS error_msg1 = MESSAGE_TEXT,
                          error_msg2 = PG_EXCEPTION_DETAIL,
                          error_msg3 = PG_EXCEPTION_HINT;
    FOR rec IN (SELECT row_to_json(j) FROM(select t_id as id, 'Internal Error - Taxonomy table edit. Please contact your DBA with the following error message: ' || error_msg1 as message) j) LOOP  RETURN NEXT rec; END LOOP; RETURN;
END;
$$ LANGUAGE 'plpgsql';

/******************************************************************
 5. create new pmt_edit_classification function
   select * from pmt_edit_classification(1,34,null,80,'{"_name": "Test Classification","_description": "testing"}',false); -- create
   select * from pmt_edit_classification(1,34,2571,null,'{"_description": "testing update"}',false); -- update
   select * from pmt_edit_classification(1,34,2571,null,null,true); -- delete
   select * from classification where _name = 'Test Classification'
   delete from classification where _name = 'Test Classification'
******************************************************************/
CREATE OR REPLACE FUNCTION pmt_edit_classification(instance_id integer, user_id integer, classification_id integer, taxonomy_id integer, key_value_data json, delete_record boolean DEFAULT false)
  RETURNS SETOF pmt_json_result_type AS $$
DECLARE
	valid_classification record;
	valid_taxonomy_id integer;
	new_classification_id integer;
	username text;
	valid_user_instance record;
	c_id integer;
	json record;
	column_record record;
	execute_statement text;
	invalid_editing_columns text[];
	users_role record;
	rec record;
	error_msg1 text;
	error_msg2 text;
	error_msg3 text;
BEGIN

  -- set columns that are not editable via the parameters
  invalid_editing_columns := ARRAY['id', '_active', '_retired_by', '_created_by', '_created_date', '_updated_by', '_updated_date' ];

  -- instance_id is required for all operations
  IF ($1 IS NULL) THEN
	FOR rec IN (SELECT row_to_json(j) FROM(select null as id, 'Error: instance_id is a required parameter for all operations.' as message) j) LOOP  RETURN NEXT rec; END LOOP; RETURN;
  END IF;
  -- user_id is required for all operations
  IF ($2 IS NULL) THEN
	FOR rec IN (SELECT row_to_json(j) FROM(select null as id, 'Error: user_id is a required parameter for all operations.' as message) j) LOOP  RETURN NEXT rec; END LOOP; RETURN;
  END IF;

  -- update/create operation
  IF NOT ($6) THEN
    -- json is required
    IF ($5 IS NULL) THEN
      FOR rec IN (SELECT row_to_json(j) FROM(select null as id, 'Error: The json parameter is required for a create/update operation.' as message) j) LOOP  RETURN NEXT rec; END LOOP; RETURN;
    END IF;
    -- taxonomy id required on create operations
    IF ($3 IS NULL) AND ($4 IS NULL) THEN
      FOR rec IN (SELECT row_to_json(j) FROM(select null as id, 'Error: The taxonomy_id parameter is required for a create operation.' as message) j) LOOP  RETURN NEXT rec; END LOOP; RETURN;
    END IF;
  -- delete operation
  ELSE
    -- classification id is requried
    IF ($3 IS NULL) THEN
      FOR rec IN (SELECT row_to_json(j) FROM(select null as id, 'Error: classification_id is required for a delete operation.' as message) j) LOOP  RETURN NEXT rec; END LOOP; RETURN;
    END IF;
  END IF;
  -- validate classification id if provided
  IF ($3 IS NOT NULL) THEN
    SELECT INTO valid_classification * FROM classification WHERE id = $3;
    IF valid_classification IS NULL THEN
         FOR rec IN (SELECT row_to_json(j) FROM(select null as id, 'Error: The provided classification_id is invalid.' as message) j) LOOP  RETURN NEXT rec; END LOOP; RETURN;
    END IF;
  END IF;

  -- get users name
  SELECT INTO username _username FROM users WHERE users.id = $2;
  -- get user role
  SELECT INTO valid_user_instance * FROM _user_instances WHERE _user_instances.user_id = $2 AND _user_instances.instance_id = $1;
  -- valiate user access on instance
  IF valid_user_instance.user_id IS NOT NULL THEN
    SELECT INTO users_role * FROM role WHERE id = valid_user_instance.role_id;
    RAISE NOTICE 'Role: %', valid_user_instance.role;
  ELSE
    FOR rec IN (SELECT row_to_json(j) FROM(select null as id, 'Error: User does not have authorization on the provided instance.' as message) j) LOOP  RETURN NEXT rec; END LOOP; RETURN;
  END IF;

  -- validate user's authorization to edit at the entity level (required role with: _security = true)
  IF (SELECT _security FROM role WHERE id = valid_user_instance.role_id) THEN
    -- create operation
    IF ($3 IS NULL) THEN
      SELECT INTO valid_taxonomy_id id FROM taxonomy WHERE id = $4;
      IF valid_taxonomy_id IS NULL THEN
        FOR rec IN (SELECT row_to_json(j) FROM(select null as id, 'Error: A valid taxonomy_id parameter is required for a create operation.' as message) j) LOOP  RETURN NEXT rec; END LOOP; RETURN;
      END IF;
      EXECUTE 'INSERT INTO classification(taxonomy_id, _created_by, _updated_by) VALUES (' || valid_taxonomy_id || ',' || quote_literal(valid_user_instance.username) ||
      ',' || quote_literal(valid_user_instance.username) || ') RETURNING id;' INTO new_classification_id;
      -- RAISE NOTICE 'Created new classification with id: %', new_classification_id;
    -- update/delete operations
    ELSE
      -- validate users authorization to edit requested taxonomy
      IF (SELECT valid_user_instance.data_group_ids @> data_group_ids FROM taxonomy WHERE id = valid_classification.taxonomy_id) THEN
        -- delete operation
        IF ($6) THEN
          UPDATE classification SET _active = false, _updated_by = quote_literal(valid_user_instance.username) WHERE id = $3;
        END IF;
      ELSE
        FOR rec IN (SELECT row_to_json(j) FROM(select null as id, 'Error: User does not have authorization to edit this taxonomy.' as message) j) LOOP  RETURN NEXT rec; END LOOP; RETURN;
      END IF;
    END IF;
  ELSE
    FOR rec IN (SELECT row_to_json(j) FROM(select null as id, 'Error: The user does not have authorization to edit taxonomies for the provided instance.' as message) j) LOOP  RETURN NEXT rec; END LOOP; RETURN;
  END IF;

  -- assign the id to use in statements
  IF new_classification_id IS NOT NULL THEN
    c_id := new_classification_id;
  ELSE
    c_id := $3;
  END IF;

 -- loop through the columns of the activity table
  FOR json IN (SELECT * FROM json_each_text($5)) LOOP
    RAISE NOTICE 'JSON key/value: %', lower(json.key) || ':' || json.value;
    -- get the column information for column that user is requesting to edit
    FOR column_record IN (SELECT * FROM information_schema.columns WHERE table_schema='public' AND table_name='classification' AND column_name != ALL(invalid_editing_columns) AND lower(column_name) = lower(json.key)) LOOP
      RAISE NOTICE 'Editing column: %', column_record.column_name;
      RAISE NOTICE 'Assigning new value: %', json.value;
      execute_statement := null;
      CASE column_record.data_type
        WHEN 'integer', 'numeric' THEN
          IF (SELECT pmt_isnumeric(json.value)) THEN
            execute_statement := 'UPDATE classification SET ' || column_record.column_name || ' = ' || json.value || ' WHERE id = ' || c_id;
          END IF;
          IF (lower(json.value) = 'null') THEN
            execute_statement := 'UPDATE classification SET ' || column_record.column_name || ' = null WHERE id = ' || c_id;
          END IF;
        ELSE
          -- if the value has the text null then assign the column value null
          IF (lower(json.value) = 'null') THEN
            execute_statement := 'UPDATE classification SET ' || column_record.column_name || ' = null WHERE id = ' || c_id;
          ELSE
            execute_statement := 'UPDATE classification SET ' || column_record.column_name || ' = ' || quote_literal(json.value) || ' WHERE id = ' || c_id;
          END IF;
      END CASE;
      IF execute_statement IS NOT NULL THEN
        RAISE NOTICE 'Statement: %', execute_statement;
        EXECUTE execute_statement;

        EXECUTE 'UPDATE classification SET _updated_by = ' || quote_literal(username) || ', _updated_date = ' || quote_literal(current_date) || ' WHERE  id = ' || c_id;
      END IF;
    END LOOP;
  END LOOP;

  -- editing completed successfullly
  FOR rec IN (SELECT row_to_json(j) FROM(select c_id as id, 'Success' as message) j) LOOP  RETURN NEXT rec; END LOOP; RETURN;

EXCEPTION WHEN others THEN
    GET STACKED DIAGNOSTICS error_msg1 = MESSAGE_TEXT,
                          error_msg2 = PG_EXCEPTION_DETAIL,
                          error_msg3 = PG_EXCEPTION_HINT;
    FOR rec IN (SELECT row_to_json(j) FROM(select c_id as id, 'Internal Error - classification table edit. Please contact your DBA with the following error message: ' || error_msg1 as message) j) LOOP  RETURN NEXT rec; END LOOP; RETURN;
END;
$$ LANGUAGE 'plpgsql';

 /******************************************************************
6. create pmt_taxonomy_search to filter all active taxonomies
  by search criteria, and exclude returns by taxonomy_id
  select * from pmt_taxonomy_search(1,'org',null,0,10,true);
  select * from pmt_taxonomy_search(1,'org','5,8',0,10,false);
  select * from pmt_taxonomy_search(1,null,null,0,30,false);
  select * from pmt_taxonomy_search(1,'org',null,0,10,false);
  select * from pmt_taxonomy_search(1,null,'5',5,5,true);
******************************************************************/
CREATE OR REPLACE FUNCTION pmt_taxonomy_search(instance_id integer, search_text text, exclude_ids character varying, offsetter integer, limiter integer, return_core boolean)
  RETURNS SETOF pmt_json_result_type AS $$
DECLARE
  t_ids integer[];
  valid_taxonomy_ids integer[];
  valid_instance record;
  rec record;
  execute_statement text;
BEGIN

  -- validate instance id
  IF $1 IS NOT NULL THEN
    SELECT INTO valid_instance * FROM instance WHERE id = $1;
    IF valid_instance IS NULL THEN
      FOR rec IN SELECT row_to_json(j) FROM( SELECT 'Error: provided instance_id is invalid.' AS error ) as j LOOP RETURN NEXT rec; END LOOP;
    END IF;
  END IF;

  -- validate excluded taxonomy ids
  IF $3 IS NOT NULL AND $3 <> '' THEN
    t_ids:= string_to_array($3, ',')::int[];
    SELECT INTO valid_taxonomy_ids array_agg(id)::int[] FROM taxonomy t WHERE _active=true AND id = ANY(t_ids);
  END IF;

  -- return instance specific taxonomies
  IF valid_instance IS NOT NULL THEN
    -- return core
     IF return_core THEN
      execute_statement:= 'SELECT * FROM taxonomy WHERE data_group_ids <@ valid_instance.data_group_ids AND _active = true ';
    -- do not return core
    ELSE
      execute_statement:= 'SELECT * FROM taxonomy WHERE data_group_ids <@ valid_instance.data_group_ids AND _active = true AND _core = false ';
    END IF;
  -- return all instance taxonomies
  ELSE
    -- return core
    IF return_core THEN
      execute_statement:= 'SELECT * FROM taxonomy WHERE _active = true ';
    -- do not return core
    ELSE
      execute_statement:= 'SELECT * FROM taxonomy WHERE _active = true AND _core = false ';
    END IF;
  END IF;

  -- filter by search critieria
  IF $2 IS NOT NULL AND $2 <> '' THEN
    execute_statement:= execute_statement || 'AND id IN (SELECT taxonomy_id FROM _taxonomy_classifications WHERE (lower(taxonomy) LIKE ''%' || lower($2) || '%'' ' ||
						' OR lower(classification) LIKE ''%' || lower($2) || '%'')) ';
  END IF;

  -- exculusons
  IF $3 IS NOT NULL AND $3 <> '' THEN
    execute_statement:= execute_statement || ' AND NOT (id = ANY(ARRAY[' || array_to_string(valid_taxonomy_ids, ',') || '])) ';
  END IF;

  execute_statement:= execute_statement || ' ORDER BY id, _name ';

  -- offset
  IF $4 IS NOT NULL THEN
    execute_statement:= execute_statement || ' OFFSET ' || $4;
  END IF;

  -- limit
  IF $5 IS NOT NULL THEN
    execute_statement:= execute_statement || ' LIMIT ' || $5;
  END IF;

  RAISE NOTICE 'execute_statement: %', execute_statement;

  FOR rec IN EXECUTE 'SELECT row_to_json(j) FROM (' || execute_statement || ')j' LOOP
	RETURN NEXT rec;
  END LOOP;

END;
$$ LANGUAGE 'plpgsql';

 /******************************************************************
7. create pmt_taxonomy_count to return count of filtered taxonomies
  select * from pmt_taxonomy_count(1,'org',null,false);
  select * from pmt_taxonomy_count(1,'org','5,8',false);
  select * from pmt_taxonomy_count(1,null,null,false);
  select * from pmt_taxonomy_count(1,'org',null,false);
  select * from pmt_taxonomy_count(1,null,'5',true);
******************************************************************/
CREATE OR REPLACE FUNCTION pmt_taxonomy_count(instance_id integer, search_text text, exclude_ids character varying, return_core boolean)
  RETURNS SETOF pmt_json_result_type AS $$
DECLARE
  t_ids integer[];
  valid_taxonomy_ids integer[];
  valid_instance record;
  rec record;
  execute_statement text;
BEGIN

  -- validate instance id
  IF $1 IS NOT NULL THEN
    SELECT INTO valid_instance * FROM instance WHERE id = $1;
    IF valid_instance IS NULL THEN
      FOR rec IN SELECT row_to_json(j) FROM( SELECT 'Error: provided instance_id is invalid.' AS error ) as j LOOP RETURN NEXT rec; END LOOP;
    END IF;
  END IF;

  -- validate excluded taxonomy ids
  IF $3 IS NOT NULL AND $3 <> '' THEN
    t_ids:= string_to_array($3, ',')::int[];
    SELECT INTO valid_taxonomy_ids array_agg(id)::int[] FROM taxonomy t WHERE _active=true AND id = ANY(t_ids);
  END IF;

  execute_statement := 'SELECT   Count(DISTINCT taxonomy_id) FROM _taxonomy_classifications ';

  -- return instance specific taxonomies
  IF valid_instance IS NOT NULL THEN
    -- return core
     IF return_core THEN
      execute_statement:= 'SELECT count(DISTINCT id) as count FROM taxonomy WHERE data_group_ids <@ valid_instance.data_group_ids AND _active = true ';
    -- do not return core
    ELSE
      execute_statement:= 'SELECT count(DISTINCT id) as count FROM taxonomy WHERE data_group_ids <@ valid_instance.data_group_ids AND _active = true AND _core = false ';
    END IF;
  -- return all instance taxonomies
  ELSE
    -- return core
    IF return_core THEN
      execute_statement:= 'SELECT count(DISTINCT id) as count FROM taxonomy WHERE _active = true ';
    -- do not return core
    ELSE
      execute_statement:= 'SELECT count(DISTINCT id) as count FROM taxonomy WHERE _active = true AND _core = false ';
    END IF;
  END IF;

  -- filter by search critieria
  IF $2 IS NOT NULL AND $2 <> '' THEN
    execute_statement:= execute_statement || 'AND id IN (SELECT taxonomy_id FROM _taxonomy_classifications WHERE (lower(taxonomy) LIKE ''%' || lower($2) || '%'' ' ||
						' OR lower(classification) LIKE ''%' || lower($2) || '%'')) ';
  END IF;

  -- exculusons
  IF $3 IS NOT NULL AND $3 <> '' THEN
    execute_statement:= execute_statement || ' AND NOT (id = ANY(ARRAY[' || array_to_string(valid_taxonomy_ids, ',') || '])) ';
  END IF;

  RAISE NOTICE 'execute_statement: %', execute_statement;

  FOR rec IN EXECUTE 'SELECT row_to_json(j) FROM (' || execute_statement || ')j' LOOP
	RETURN NEXT rec;
  END LOOP;

END;
$$ LANGUAGE 'plpgsql';

  /******************************************************************
8. create pmt_classification_search to filter all active classifications
  by search criteria
  select * from  pmt_classification_search(77,'agr',null,null);
******************************************************************/
CREATE OR REPLACE FUNCTION pmt_classification_search(taxonomy_id integer, search_text text, offsetter integer, limiter integer)
  RETURNS SETOF pmt_json_result_type AS $$
DECLARE
  filtered_parent_classification_ids integer[];
  filtered_child_classification_ids integer[];
  valid_taxonomy record;
  rec record;
  execute_statement text;
  error_msg text;
BEGIN
  -- validate taxonomy id
  IF $1 IS NULL THEN
    FOR rec IN (SELECT row_to_json(j) FROM(select null as id, 'Error: taxonomy_id is a required parameter.' as message) j) LOOP  RETURN NEXT rec; END LOOP; RETURN;
  ELSE
    SELECT INTO valid_taxonomy * FROM taxonomy WHERE _active = true AND id = $1;
    IF valid_taxonomy IS NULL THEN
      FOR rec IN SELECT row_to_json(j) FROM( SELECT 'Error: provided taxonomy_id is invalid.' AS error ) as j LOOP RETURN NEXT rec; END LOOP;
    END IF;
  END IF;

  -- filter by search critieria
  IF $2 IS NOT NULL AND $2 <> '' THEN
    -- get a filtered listing of ids for parent taxonomies matching criteria
    execute_statement := 'SELECT array_agg(DISTINCT cid) FROM ( ' ||
			'SELECT tc1.classification_id as cid, tc1.classification as cc, null as id, null as c ' ||
			'FROM (SELECT * FROM _taxonomy_classifications tc  WHERE taxonomy_id = ' || $1 || ' AND lower(classification) LIKE ''%' || lower($2) || '%'' ) tc1 ' ||
			'UNION ALL ' ||
			'SELECT tc3.classification_id as id, tc3.classification as c, tc2.classification_id as id, tc2.classification as c FROM ' ||
			'(SELECT * FROM _taxonomy_classifications tc  WHERE taxonomy_id = (SELECT id FROM taxonomy WHERE parent_id = ' || $1 || ') ' ||
			'AND lower(classification) LIKE ''%' || lower($2) || '%'' ) tc2 ' ||
			'LEFT JOIN _taxonomy_classifications tc3 ' ||
			'ON tc3.classification_id = tc2.classification_parent_id) as foo';
    EXECUTE execute_statement INTO filtered_parent_classification_ids;

    -- get a filtered listing of ids for child taxonomies matching criteria (if requested taxonomy is a parent)
    IF (valid_taxonomy._is_category) THEN
      execute_statement := 'SELECT array_agg(DISTINCT id) FROM ( ' ||
			'SELECT tc1.classification_id as cid, tc1.classification as cc, null as id, null as c ' ||
			'FROM (SELECT * FROM _taxonomy_classifications tc  WHERE taxonomy_id = ' || $1 || ' AND lower(classification) LIKE ''%' || lower($2) || '%'' ) tc1 ' ||
			'UNION ALL ' ||
			'SELECT tc3.classification_id as id, tc3.classification as c, tc2.classification_id as id, tc2.classification as c FROM ' ||
			'(SELECT * FROM _taxonomy_classifications tc  WHERE taxonomy_id = (SELECT id FROM taxonomy WHERE parent_id = ' || $1 || ') ' ||
			'AND lower(classification) LIKE ''%' || lower($2) || '%'' ) tc2 ' ||
			'LEFT JOIN _taxonomy_classifications tc3 ' ||
			'ON tc3.classification_id = tc2.classification_parent_id) as foo';
      EXECUTE execute_statement INTO filtered_child_classification_ids;
    END IF;
  END IF;

  -- begin building nested query for parent -> child taxonomies
  IF (valid_taxonomy._is_category) THEN
      execute_statement := 'SELECT classification_id as id, classification as c, (SELECT array_to_json(array_agg(row_to_json(a))) FROM ( ' ||
				'SELECT DISTINCT parent_id as id, _title FROM _activity_family_taxonomies WHERE classification_id = tc.classification_id ' ||
				') a ) as activities ' ||
			',(SELECT array_to_json(array_agg(row_to_json(t))) FROM ( ' ||
				'SELECT classification_id as id, classification as c, (SELECT array_to_json(array_agg(row_to_json(a))) FROM ( ' ||
					'SELECT DISTINCT parent_id as id, _title FROM _activity_family_taxonomies WHERE classification_id = cc.classification_id ' ||
					') a ) as activities ' ||
				'FROM _taxonomy_classifications cc ';
      -- add child filter if requested
      IF $2 IS NOT NULL AND $2 <> '' THEN
        -- child filter has results
        IF array_length(filtered_child_classification_ids, 1) > 0 THEN
          execute_statement := execute_statement || 'WHERE classification_parent_id = tc.classification_id AND classification_id = ANY(ARRAY[' || array_to_string(filtered_child_classification_ids, ',') || ']) )t ) as children ';
        -- child filter has no results
        ELSE
          execute_statement := execute_statement || 'WHERE classification_parent_id = tc.classification_id AND classification_id IS NULL )t ) as children ';
        END IF;

        -- parent filter has results
        IF array_length(filtered_parent_classification_ids, 1) > 0 THEN
          execute_statement := execute_statement || 'FROM _taxonomy_classifications tc  WHERE classification_id = ANY(ARRAY[' || array_to_string(filtered_parent_classification_ids, ',') || ']) ';
        -- parent filter has no results
        ELSE
          execute_statement := execute_statement || 'FROM _taxonomy_classifications tc  WHERE classification_id = null ';
        END IF;

      -- no filter was applied
      ELSE
        execute_statement := execute_statement || 'WHERE classification_parent_id = tc.classification_id ' ||
			')t ) as children ' ||
			'FROM _taxonomy_classifications tc  WHERE taxonomy_id = ' || $1;
      END IF;
    -- begin building flat query for single taxonomies
    ELSE
      execute_statement := 'SELECT classification_id as id, classification as c, (SELECT array_to_json(array_agg(row_to_json(a))) FROM ( ' ||
				'SELECT DISTINCT parent_id as id, _title FROM _activity_family_taxonomies WHERE classification_id = tc.classification_id ' ||
				') a ) as activities, null as children ' ||
			'FROM _taxonomy_classifications tc  WHERE taxonomy_id = ' || $1;
      -- add filter if requested
      IF $2 IS NOT NULL AND $2 <> '' THEN
        execute_statement := execute_statement || 'AND lower(classification) LIKE ''%' || lower($2) || '%''';
      END IF;
    END IF;

  -- offset
  IF $3 IS NOT NULL THEN
    execute_statement:= execute_statement || ' OFFSET ' || $3;
  END IF;

  -- limit
  IF $4 IS NOT NULL THEN
    execute_statement:= execute_statement || ' LIMIT ' || $4;
  END IF;

  RAISE NOTICE 'execute_statement: %', execute_statement;

  FOR rec IN EXECUTE 'SELECT row_to_json(j) FROM (' || execute_statement || ')j' LOOP
	RETURN NEXT rec;
  END LOOP;

EXCEPTION WHEN others THEN
    GET STACKED DIAGNOSTICS error_msg = MESSAGE_TEXT;
    FOR rec IN (SELECT row_to_json(j) FROM(select 'Internal Error: Please contact your DBA with the following error message: ' || error_msg as message) j) LOOP  RETURN NEXT rec; END LOOP; RETURN;

END;
$$ LANGUAGE 'plpgsql';

 /******************************************************************
9. create pmt_classification_count to count filtered active classifications
  by search criteria
  select * from pmt_classification_count(81,null);
******************************************************************/
CREATE OR REPLACE FUNCTION pmt_classification_count(taxonomy_id integer, search_text text)
  RETURNS SETOF pmt_json_result_type AS $$
DECLARE
  valid_taxonomy_id int;
  rec record;
  execute_statement text;
  error_msg text;
BEGIN
  -- validate taxonomy id
  IF $1 IS NULL THEN
    FOR rec IN (SELECT row_to_json(j) FROM(select null as id, 'Error: taxonomy_id is a required parameter.' as message) j) LOOP  RETURN NEXT rec; END LOOP; RETURN;
  ELSE
    SELECT INTO valid_taxonomy_id id FROM taxonomy WHERE _active = true AND id = $1;
    IF valid_taxonomy_id IS NULL THEN
      FOR rec IN SELECT row_to_json(j) FROM( SELECT 'Error: provided taxonomy_id is invalid.' AS error ) as j LOOP RETURN NEXT rec; END LOOP;
    END IF;
  END IF;

  execute_statement:= 'SELECT count(DISTINCT id) as count FROM classification WHERE taxonomy_id = ' || $1;

  -- filter by search critieria
  IF $2 IS NOT NULL AND $2 <> '' THEN
    execute_statement:= execute_statement || ' AND lower(_name) LIKE ''%' || lower($2) || '%'' ';
  END IF;

  RAISE NOTICE 'execute_statement: %', execute_statement;

  FOR rec IN EXECUTE 'SELECT row_to_json(j) FROM (' || execute_statement || ')j' LOOP
	RETURN NEXT rec;
  END LOOP;

EXCEPTION WHEN others THEN
    GET STACKED DIAGNOSTICS error_msg = MESSAGE_TEXT;
    FOR rec IN (SELECT row_to_json(j) FROM(select 'Internal Error: Please contact your DBA with the following error message: ' || error_msg as message) j) LOOP  RETURN NEXT rec; END LOOP; RETURN;

END;
$$ LANGUAGE 'plpgsql';

-- update permissions
GRANT USAGE ON SCHEMA public TO pmt_read;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO pmt_read;
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO pmt_read;
GRANT USAGE ON SCHEMA public TO pmt_write;
GRANT SELECT,INSERT ON ALL TABLES IN SCHEMA public TO pmt_write;
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO pmt_write;


text:
import React, { Component } from 'react';
import axios from 'axios';
import { propertySections } from '../../functions/propertiesFuncs';
import * as toastify from '../../functions/Toastify';

import styled from 'styled-components';
import { SpeedDial, SpeedDialItem } from 'react-mui-speeddial';
import ContentAdd from 'material-ui/svg-icons/content/add';
import NavigationClose from 'material-ui/svg-icons/navigation/close';
import DeleteIcon from 'material-ui/svg-icons/action/delete';
import ModeEdit from 'material-ui/svg-icons/editor/mode-edit';
import TextField from 'material-ui/TextField';
import Dialog from 'material-ui/Dialog';
import FlatButton from 'material-ui/FlatButton';
import RaisedButton from 'material-ui/RaisedButton';
import { Button } from 'react-bootstrap';
import FloatingActionButton from 'material-ui/FloatingActionButton';
import EditBtn from 'material-ui/svg-icons/content/create';
import EditFilesBtn from 'material-ui/svg-icons/image/photo-library';
import UploadPropertyFiles from '../UploadPropertyFiles';
import Toggle from 'react-toggle';
import Divider from 'material-ui/Divider';
import { isoToShortDate, fullDateToIsoDate } from '../../functions.js';
import DatePicker from 'material-ui/DatePicker';
import firebase from 'firebase';

const SectionContainer = styled.div`

margin-bottom: 20px;
  .col-md-10 {
    padding-left: 35px;
    margin-bottom: 50px;
  }
  p {
    color: #484848 !important;
    font-family: Circular,-apple-system,BlinkMacSystemFont,Roboto,Helvetica Neue,sans-serif !important;
    font-size: 17px !important;
    font-weight: 300 !important;
    letter-spacing: 0.2px !important;
    line-height: 22px !important;
  }
  .col-md-2 {
    padding: 0px;
  }

  .col-md-7, .col-md-5 {
    padding: 10px;
  }

  .name {
    font-weight: 700 !important;
    color: #484848 !important;
    font-family: Circular,-apple-system,BlinkMacSystemFont,Roboto,Helvetica Neue,sans-serif !important;
    margin: 0px !important;
    word-wrap: break-word !important;
    font-size: 36px !important;
    line-height: 44px !important;
    letter-spacing: -0.6px !important;
    padding-top: 6px !important;
    margin-bottom: 10px;
    padding-bottom: 10px;
    display: block;
  }

  .title {
    color: #484848 !important;
    font-family: Circular,-apple-system,BlinkMacSystemFont,Roboto,Helvetica Neue,sans-serif !important;
    font-size: 17px !important;
    font-weight: 300 !important;
    letter-spacing: 0.2px !important;
    line-height: 22px !important;
  }
  h4 {
    font-size: 22px !important;
    font-weight: 400 !important;
    letter-spacing: -0.2px !important;
    line-height: 28px !important;
    border-bottom: 1px #e5e5e5 solid;
    padding-bottom: 10px;
    color: #484848 !important;
    font-family: Circular,-apple-system,BlinkMacSystemFont,Roboto,Helvetica Neue,sans-serif !important;
    font-size: 17px !important;
    font-weight: 300 !important;
    letter-spacing: 0.2px !important;
    line-height: 22px !important;
  }

  h5 {
    color: #484848 !important;
    font-family: Circular,-apple-system,BlinkMacSystemFont,Roboto,Helvetica Neue,sans-serif !important;
    font-size: 17px !important;
    font-weight: 300 !important;
    letter-spacing: 0.2px !important;
    line-height: 22px !important;
  }

  .IconRowDivider {
    border-top: 1px solid #dce0e0;
    border-bottom: 1px solid #dce0e0;
    display: flex;
    justify-content: space-around;
    padding: 10px;

    img {
      margin: 6px auto;
      display: block;
    }
  }
`;

let borderBottom = {
  borderBottom: '1px solid rgb(234, 233, 233)',
  marginBottom: '22px',
  paddingBottom: '10px',
  paddingTop: '14px'
}

class NotifyUpdate extends Component {
  constructor(props) {
    super(props);
    this.state = {

      open: false,
      // updates: [],
      defaultUpdateText: 'You Have A New Update From ME Real-Estate About ' + this.getSectionName() + ': ',
      updateText: ''
    };
    this.sendUpdate = this.sendUpdate.bind(this);
  }

  getSectionName() {
    if (this.props.sectionName == propertySections.PurchasesAndSales)
      return "Purchase And Sales";

    return this.props.sectionName;
  }

  componentWillMount() {
    // this.initUpdateInvestorByFireBase();
  }

  // initUpdateInvestorByFireBase() {
  //   this.firebaseRef = firebase.database().ref("updates/" + this.props.propertyId);
  //   this.firebaseRef.orderByChild("section").equalTo(this.props.sectionName).on('value', function (dataSnapshot) {
  //     var items = [];
  //     dataSnapshot.forEach(function (val) {
  //       if (val.val().status == '0') {
  //         var item = val.val();
  //         item.key = val.key;
  //         items.push(item);
  //       }
  //     });
  //     this.setState({ updates: items })
  //   }.bind(this));
  // }

  sendUpdate = () => {
    axios({
      method: 'post',
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
      },
      url: 'http://ec2-54-190-49-213.us-west-2.compute.amazonaws.com/index.php/api/RequestUpdate/sendUpdateToClient',
      data: {
        propId: this.props.propertyId,
        id: (this.props.update.length > 0) ? this.props.update[0].id : 0,
        response: this.state.defaultUpdateText + this.state.updateText,
        sectionName: this.props.sectionName,
        investorId: (this.props.update.length > 0) ? this.props.update[0].InvestorId : 0
      }
    }).then((res) => {
      toastify.notifySuccess(toastify.messages.updateInvestorSuccess);

      if (this.props.fireUpdates.length > 0 && this.props.fireUpdates[0].key != undefined) {
        var test = firebase.database().ref("updates/" + this.props.propertyId + "/" + this.props.fireUpdates[0].key);
        var query = test.orderByChild("section").equalTo(this.props.sectionName).ref;
        query.ref.update({ status: 1 });
      }
      else {
        let newRef = firebase.database().ref("updates/" + this.props.propertyId)
        newRef.push({
          section: this.props.sectionName,
          timestamp: new Date().getTime(),
          investorId: this.props.investorId,
          propertyId: this.props.propertyId,
          status: 1
        });
      }
    }).catch(function (error) {
      toastify.notifyErorr(toastify.messages.updateInvestorError);
    });;

    this.props.save();
    this.props.handleClose()
  };

  // handleOpen = () => {
  //   this.setState({ open: true });
  // };

  // handleClose = () => {
  //   this.setState({ open: false });
  // };

  setUpdateText = (event) => {
    this.setState({ updateText: event.target.value });
  }

  renderSendUpdateDialog() {
    const actions = [
      <FlatButton
        label="Cancel"
        primary={false}
        onClick={this.props.handleClose}
      />,
      <FlatButton
        label="Save And Send"
        primary={true}
        keyboardFocused={true}
        onClick={this.sendUpdate}
      />,
    ];
    return (
      <Dialog
        title="Send Update"
        actions={actions}
        modal={false}
        onRequestClose={this.handleClose}
        open={this.props.open}
      >

          Enter Text:
          <textarea className="form-control" rows="5" id="comment" value={this.state.updateText} onChange={this.setUpdateText}></textarea>

          Content of the full message:
          <textarea className="form-control" rows="5" id="comment" value={this.state.defaultUpdateText + this.state.updateText} ></textarea>

      </Dialog>
    )
  }

  render() {
    return (
      <SectionContainer >
        {this.renderSendUpdateDialog()}
      </SectionContainer>
    );
  }

}

export default NotifyUpdate;

redpajama_set_name: RedPajamaGithub


text:
package controlador;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

import modelo.Usuario;
import persistencia.UsuarioDAO;
import spark.*;

public class LoginControlador implements TemplateViewRoute {
	public ModelAndView handle(Request req, Response res) {
		String matricula = req.queryParams("matricula2");
		String senha = req.queryParams("password2");
		File file = new File("banco/cadastros/" + matricula + ".csv");
		if (!file.exists()) {
			res.redirect("/erro/login");
			return new ModelAndView("", "");
		}
		Usuario user = new Usuario();
		UsuarioDAO dao = new UsuarioDAO();
		user = dao.load(matricula);
		if (user == null)
			res.redirect("/erro/login");
		if (user.getSenha().equals(senha)) {
			req.session().attribute("usuario_logado", user);
			if (user.getMatricula().equals("11030231")
					|| user.getMatricula().equals("11030234")
					|| user.getMatricula().equals("11030235")) {
				res.redirect("/admin");
			} else {
				res.redirect("/home");
			}
		} else {
			res.redirect("/erro/senha");
		}
		return new ModelAndView("", "");
	}
}


text:
package com.amazonaws.services.elastictranscoder.model;

import java.io.Serializable;
import javax.annotation.Generated;
import com.amazonaws.protocol.StructuredPojo;
import com.amazonaws.protocol.ProtocolMarshaller;

/**
 *

 * Information about the file that you're transcoding.
 *

 */
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class JobInput implements Serializable, Cloneable, StructuredPojo {

    /**
     *

     * The name of the file to transcode. Elsewhere in the body of the JSON block is the the ID of the pipeline to use
     * for processing the job. The InputBucket object in that pipeline tells Elastic Transcoder which
     * Amazon S3 bucket to get the file from.
     *

     *

     * If the file name includes a prefix, such as cooking/lasagna.mpg, include the prefix in the key. If
     * the file isn't in the specified bucket, Elastic Transcoder returns an error.
     *

     */
    private String key;
    /**
     *

     * The frame rate of the input file. If you want Elastic Transcoder to automatically detect the frame rate of the
     * input file, specify auto. If you want to specify the frame rate for the input file, enter one of the
     * following values:
     *

     *

     * 10, 15, 23.97, 24, 25, 29.97,
     * 30, 60
     *

     *

     * If you specify a value other than auto, Elastic Transcoder disables automatic detection of the frame
     * rate.
     *

     */
    private String frameRate;
    /**
     *

     * This value must be auto, which causes Elastic Transcoder to automatically detect the resolution of
     * the input file.
     *

     */
    private String resolution;
    /**
     *

     * The aspect ratio of the input file. If you want Elastic Transcoder to automatically detect the aspect ratio of
     * the input file, specify auto. If you want to specify the aspect ratio for the output file, enter one
     * of the following values:
     *

     *

     * 1:1, 4:3, 3:2, 16:9
     *

     *

     * If you specify a value other than auto, Elastic Transcoder disables automatic detection of the
     * aspect ratio.
     *

     */
    private String aspectRatio;
    /**
     *

     * Whether the input file is interlaced. If you want Elastic Transcoder to automatically detect whether the input
     * file is interlaced, specify auto. If you want to specify whether the input file is interlaced, enter
     * one of the following values:
     *

     *

     * true, false
     *

     *

     * If you specify a value other than auto, Elastic Transcoder disables automatic detection of
     * interlacing.
     *

     */
    private String interlaced;
    /**
     *

     * The container type for the input file. If you want Elastic Transcoder to automatically detect the container type
     * of the input file, specify auto. If you want to specify the container type for the input file, enter
     * one of the following values:
     *

     *

     * 3gp, aac, asf, avi, divx, flv,
     * m4a, mkv, mov, mp3, mp4, mpeg,
     * mpeg-ps, mpeg-ts, mxf, ogg, vob,
     * wav, webm
     *

     */
    private String container;
    /**
     *

     * The encryption settings, if any, that are used for decrypting your input files. If your input file is encrypted,
     * you must specify the mode that Elastic Transcoder uses to decrypt your file.
     *

     */
    private Encryption encryption;
    /**
     *

     * Settings for clipping an input. Each input can have different clip settings.
     *

     */
    private TimeSpan timeSpan;
    /**
     *

     * You can configure Elastic Transcoder to transcode captions, or subtitles, from one format to another. All
     * captions must be in UTF-8. Elastic Transcoder supports two types of captions:
     *

     *

     *

     *

     * Embedded: Embedded captions are included in the same file as the audio and video. Elastic Transcoder
     * supports only one embedded caption per language, to a maximum of 300 embedded captions per file.
     *

     *

     * Valid input values include: CEA-608 (EIA-608, first non-empty channel only),
     * CEA-708 (EIA-708, first non-empty channel only), and mov-text
     *

     *

     * Valid outputs include: mov-text
     *

     *

     * Elastic Transcoder supports a maximum of one embedded format per output.
     *

     *

     *

     *

     * Sidecar: Sidecar captions are kept in a separate metadata file from the audio and video data. Sidecar
     * captions require a player that is capable of understanding the relationship between the video file and the
     * sidecar file. Elastic Transcoder supports only one sidecar caption per language, to a maximum of 20 sidecar
     * captions per file.
     *

     *

     * Valid input values include: dfxp (first div element only), ebu-tt, scc,
     * smpt, srt, ttml (first div element only), and webvtt
     *

     *

     * Valid outputs include: dfxp (first div element only), scc, srt, and
     * webvtt.
     *

     *

     *

     *

     * If you want ttml or smpte-tt compatible captions, specify dfxp as your output format.
     *

     *

     * Elastic Transcoder does not support OCR (Optical Character Recognition), does not accept pictures as a valid
     * input for captions, and is not available for audio-only transcoding. Elastic Transcoder does not preserve text
     * formatting (for example, italics) during the transcoding process.
     *

     *

     * To remove captions or leave the captions empty, set Captions to null. To pass through existing
     * captions unchanged, set the MergePolicy to MergeRetain, and pass in a null
     * CaptionSources array.
     *

     *

     * For more information on embedded files, see the Subtitles Wikipedia page.
     *

     *

     * For more information on sidecar files, see the Extensible Metadata Platform and Sidecar file Wikipedia pages.
     *

     */
    private InputCaptions inputCaptions;
    /**
     *

     * The detected properties of the input file.
     *

     */
    private DetectedProperties detectedProperties;

    /**
     *

     * The name of the file to transcode. Elsewhere in the body of the JSON block is the the ID of the pipeline to use
     * for processing the job. The InputBucket object in that pipeline tells Elastic Transcoder which
     * Amazon S3 bucket to get the file from.
     *

     *

     * If the file name includes a prefix, such as cooking/lasagna.mpg, include the prefix in the key. If
     * the file isn't in the specified bucket, Elastic Transcoder returns an error.
     *

     *
     * @param key
     *        The name of the file to transcode. Elsewhere in the body of the JSON block is the the ID of the pipeline
     *        to use for processing the job. The InputBucket object in that pipeline tells Elastic
     *        Transcoder which Amazon S3 bucket to get the file from.

     *

     *        If the file name includes a prefix, such as cooking/lasagna.mpg, include the prefix in the
     *        key. If the file isn't in the specified bucket, Elastic Transcoder returns an error.
     */

    public void setKey(String key) {
        this.key = key;
    }

    /**
     *

     * The name of the file to transcode. Elsewhere in the body of the JSON block is the the ID of the pipeline to use
     * for processing the job. The InputBucket object in that pipeline tells Elastic Transcoder which
     * Amazon S3 bucket to get the file from.
     *

     *

     * If the file name includes a prefix, such as cooking/lasagna.mpg, include the prefix in the key. If
     * the file isn't in the specified bucket, Elastic Transcoder returns an error.
     *

     *
     * @return The name of the file to transcode. Elsewhere in the body of the JSON block is the the ID of the pipeline
     *         to use for processing the job. The InputBucket object in that pipeline tells Elastic
     *         Transcoder which Amazon S3 bucket to get the file from.

     *

     *         If the file name includes a prefix, such as cooking/lasagna.mpg, include the prefix in the
     *         key. If the file isn't in the specified bucket, Elastic Transcoder returns an error.
     */

    public String getKey() {
        return this.key;
    }

    /**
     *

     * The name of the file to transcode. Elsewhere in the body of the JSON block is the the ID of the pipeline to use
     * for processing the job. The InputBucket object in that pipeline tells Elastic Transcoder which
     * Amazon S3 bucket to get the file from.
     *

     *

     * If the file name includes a prefix, such as cooking/lasagna.mpg, include the prefix in the key. If
     * the file isn't in the specified bucket, Elastic Transcoder returns an error.
     *

     *
     * @param key
     *        The name of the file to transcode. Elsewhere in the body of the JSON block is the the ID of the pipeline
     *        to use for processing the job. The InputBucket object in that pipeline tells Elastic
     *        Transcoder which Amazon S3 bucket to get the file from.

     *

     *        If the file name includes a prefix, such as cooking/lasagna.mpg, include the prefix in the
     *        key. If the file isn't in the specified bucket, Elastic Transcoder returns an error.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public JobInput withKey(String key) {
        setKey(key);
        return this;
    }

    /**
     *

     * The frame rate of the input file. If you want Elastic Transcoder to automatically detect the frame rate of the
     * input file, specify auto. If you want to specify the frame rate for the input file, enter one of the
     * following values:
     *

     *

     * 10, 15, 23.97, 24, 25, 29.97,
     * 30, 60
     *

     *

     * If you specify a value other than auto, Elastic Transcoder disables automatic detection of the frame
     * rate.
     *

     *
     * @param frameRate
     *        The frame rate of the input file. If you want Elastic Transcoder to automatically detect the frame rate of
     *        the input file, specify auto. If you want to specify the frame rate for the input file, enter
     *        one of the following values:

     *

     *        10, 15, 23.97, 24, 25, 29.97, 30, 60
     *

     *

     *        If you specify a value other than auto, Elastic Transcoder disables automatic detection of
     *        the frame rate.
     */

    public void setFrameRate(String frameRate) {
        this.frameRate = frameRate;
    }

    /**
     *

     * The frame rate of the input file. If you want Elastic Transcoder to automatically detect the frame rate of the
     * input file, specify auto. If you want to specify the frame rate for the input file, enter one of the
     * following values:
     *

     *

     * 10, 15, 23.97, 24, 25, 29.97,
     * 30, 60
     *

     *

     * If you specify a value other than auto, Elastic Transcoder disables automatic detection of the frame
     * rate.
     *

     *
     * @return The frame rate of the input file. If you want Elastic Transcoder to automatically detect the frame rate
     *         of the input file, specify auto. If you want to specify the frame rate for the input file,
     *         enter one of the following values:

     *

     *         10, 15, 23.97, 24, 25,
     *         29.97, 30, 60
     *

     *

     *         If you specify a value other than auto, Elastic Transcoder disables automatic detection of
     *         the frame rate.
     */

    public String getFrameRate() {
        return this.frameRate;
    }

    /**
     *

     * The frame rate of the input file. If you want Elastic Transcoder to automatically detect the frame rate of the
     * input file, specify auto. If you want to specify the frame rate for the input file, enter one of the
     * following values:
     *

     *

     * 10, 15, 23.97, 24, 25, 29.97,
     * 30, 60
     *

     *

     * If you specify a value other than auto, Elastic Transcoder disables automatic detection of the frame
     * rate.
     *

     *
     * @param frameRate
     *        The frame rate of the input file. If you want Elastic Transcoder to automatically detect the frame rate of
     *        the input file, specify auto. If you want to specify the frame rate for the input file, enter
     *        one of the following values:

     *

     *        10, 15, 23.97, 24, 25, 29.97, 30, 60
     *

     *

     *        If you specify a value other than auto, Elastic Transcoder disables automatic detection of
     *        the frame rate.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public JobInput withFrameRate(String frameRate) {
        setFrameRate(frameRate);
        return this;
    }

    /**
     *

     * This value must be auto, which causes Elastic Transcoder to automatically detect the resolution of
     * the input file.
     *

     *
     * @param resolution
     *        This value must be auto, which causes Elastic Transcoder to automatically detect the
     *        resolution of the input file.
     */

    public void setResolution(String resolution) {
        this.resolution = resolution;
    }

    /**
     *

     * This value must be auto, which causes Elastic Transcoder to automatically detect the resolution of
     * the input file.
     *

     *
     * @return This value must be auto, which causes Elastic Transcoder to automatically detect the
     *         resolution of the input file.
     */

    public String getResolution() {
        return this.resolution;
    }

    /**
     *

     * This value must be auto, which causes Elastic Transcoder to automatically detect the resolution of
     * the input file.
     *

     *
     * @param resolution
     *        This value must be auto, which causes Elastic Transcoder to automatically detect the
     *        resolution of the input file.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public JobInput withResolution(String resolution) {
        setResolution(resolution);
        return this;
    }

    /**
     *

     * The aspect ratio of the input file. If you want Elastic Transcoder to automatically detect the aspect ratio of
     * the input file, specify auto. If you want to specify the aspect ratio for the output file, enter one
     * of the following values:
     *

     *

     * 1:1, 4:3, 3:2, 16:9
     *

     *

     * If you specify a value other than auto, Elastic Transcoder disables automatic detection of the
     * aspect ratio.
     *

     *
     * @param aspectRatio
     *        The aspect ratio of the input file. If you want Elastic Transcoder to automatically detect the aspect
     *        ratio of the input file, specify auto. If you want to specify the aspect ratio for the output
     *        file, enter one of the following values:

     *

     *        1:1, 4:3, 3:2, 16:9
     *

     *

     *        If you specify a value other than auto, Elastic Transcoder disables automatic detection of
     *        the aspect ratio.
     */

    public void setAspectRatio(String aspectRatio) {
        this.aspectRatio = aspectRatio;
    }

    /**
     *

     * The aspect ratio of the input file. If you want Elastic Transcoder to automatically detect the aspect ratio of
     * the input file, specify auto. If you want to specify the aspect ratio for the output file, enter one
     * of the following values:
     *

     *

     * 1:1, 4:3, 3:2, 16:9
     *

     *

     * If you specify a value other than auto, Elastic Transcoder disables automatic detection of the
     * aspect ratio.
     *

     *
     * @return The aspect ratio of the input file. If you want Elastic Transcoder to automatically detect the aspect
     *         ratio of the input file, specify auto. If you want to specify the aspect ratio for the
     *         output file, enter one of the following values:

     *

     *         1:1, 4:3, 3:2, 16:9
     *

     *

     *         If you specify a value other than auto, Elastic Transcoder disables automatic detection of
     *         the aspect ratio.
     */

    public String getAspectRatio() {
        return this.aspectRatio;
    }

    /**
     *

     * The aspect ratio of the input file. If you want Elastic Transcoder to automatically detect the aspect ratio of
     * the input file, specify auto. If you want to specify the aspect ratio for the output file, enter one
     * of the following values:
     *

     *

     * 1:1, 4:3, 3:2, 16:9
     *

     *

     * If you specify a value other than auto, Elastic Transcoder disables automatic detection of the
     * aspect ratio.
     *

     *
     * @param aspectRatio
     *        The aspect ratio of the input file. If you want Elastic Transcoder to automatically detect the aspect
     *        ratio of the input file, specify auto. If you want to specify the aspect ratio for the output
     *        file, enter one of the following values:

     *

     *        1:1, 4:3, 3:2, 16:9
     *

     *

     *        If you specify a value other than auto, Elastic Transcoder disables automatic detection of
     *        the aspect ratio.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public JobInput withAspectRatio(String aspectRatio) {
        setAspectRatio(aspectRatio);
        return this;
    }

    /**
     *

     * Whether the input file is interlaced. If you want Elastic Transcoder to automatically detect whether the input
     * file is interlaced, specify auto. If you want to specify whether the input file is interlaced, enter
     * one of the following values:
     *

     *

     * true, false
     *

     *

     * If you specify a value other than auto, Elastic Transcoder disables automatic detection of
     * interlacing.
     *

     *
     * @param interlaced
     *        Whether the input file is interlaced. If you want Elastic Transcoder to automatically detect whether the
     *        input file is interlaced, specify auto. If you want to specify whether the input file is
     *        interlaced, enter one of the following values:

     *

     *        true, false
     *

     *

     *        If you specify a value other than auto, Elastic Transcoder disables automatic detection of
     *        interlacing.
     */

    public void setInterlaced(String interlaced) {
        this.interlaced = interlaced;
    }

    /**
     *

     * Whether the input file is interlaced. If you want Elastic Transcoder to automatically detect whether the input
     * file is interlaced, specify auto. If you want to specify whether the input file is interlaced, enter
     * one of the following values:
     *

     *

     * true, false
     *

     *

     * If you specify a value other than auto, Elastic Transcoder disables automatic detection of
     * interlacing.
     *

     *
     * @return Whether the input file is interlaced. If you want Elastic Transcoder to automatically detect whether the
     *         input file is interlaced, specify auto. If you want to specify whether the input file is
     *         interlaced, enter one of the following values:

     *

     *         true, false
     *

     *

     *         If you specify a value other than auto, Elastic Transcoder disables automatic detection of
     *         interlacing.
     */

    public String getInterlaced() {
        return this.interlaced;
    }

    /**
     *

     * Whether the input file is interlaced. If you want Elastic Transcoder to automatically detect whether the input
     * file is interlaced, specify auto. If you want to specify whether the input file is interlaced, enter
     * one of the following values:
     *

     *

     * true, false
     *

     *

     * If you specify a value other than auto, Elastic Transcoder disables automatic detection of
     * interlacing.
     *

     *
     * @param interlaced
     *        Whether the input file is interlaced. If you want Elastic Transcoder to automatically detect whether the
     *        input file is interlaced, specify auto. If you want to specify whether the input file is
     *        interlaced, enter one of the following values:

     *

     *        true, false
     *

     *

     *        If you specify a value other than auto, Elastic Transcoder disables automatic detection of
     *        interlacing.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public JobInput withInterlaced(String interlaced) {
        setInterlaced(interlaced);
        return this;
    }

    /**
     *

     * The container type for the input file. If you want Elastic Transcoder to automatically detect the container type
     * of the input file, specify auto. If you want to specify the container type for the input file, enter
     * one of the following values:
     *

     *

     * 3gp, aac, asf, avi, divx, flv,
     * m4a, mkv, mov, mp3, mp4, mpeg,
     * mpeg-ps, mpeg-ts, mxf, ogg, vob,
     * wav, webm
     *

     *
     * @param container
     *        The container type for the input file. If you want Elastic Transcoder to automatically detect the
     *        container type of the input file, specify auto. If you want to specify the container type for
     *        the input file, enter one of the following values:

     *

     *        3gp, aac, asf, avi, divx,
     *        flv, m4a, mkv, mov, mp3, mp4, mpeg, mpeg-ps, mpeg-ts, mxf, ogg,
     *        vob, wav, webm
     */

    public void setContainer(String container) {
        this.container = container;
    }

    /**
     *

     * The container type for the input file. If you want Elastic Transcoder to automatically detect the container type
     * of the input file, specify auto. If you want to specify the container type for the input file, enter
     * one of the following values:
     *

     *

     * 3gp, aac, asf, avi, divx, flv,
     * m4a, mkv, mov, mp3, mp4, mpeg,
     * mpeg-ps, mpeg-ts, mxf, ogg, vob,
     * wav, webm
     *

     *
     * @return The container type for the input file. If you want Elastic Transcoder to automatically detect the
     *         container type of the input file, specify auto. If you want to specify the container type
     *         for the input file, enter one of the following values:

     *

     *         3gp, aac, asf, avi, divx,
     *         flv, m4a, mkv, mov, mp3,
     *         mp4, mpeg, mpeg-ps, mpeg-ts, mxf,
     *         ogg, vob, wav, webm
     */

    public String getContainer() {
        return this.container;
    }

    /**
     *

     * The container type for the input file. If you want Elastic Transcoder to automatically detect the container type
     * of the input file, specify auto. If you want to specify the container type for the input file, enter
     * one of the following values:
     *

     *

     * 3gp, aac, asf, avi, divx, flv,
     * m4a, mkv, mov, mp3, mp4, mpeg,
     * mpeg-ps, mpeg-ts, mxf, ogg, vob,
     * wav, webm
     *

     *
     * @param container
     *        The container type for the input file. If you want Elastic Transcoder to automatically detect the
     *        container type of the input file, specify auto. If you want to specify the container type for
     *        the input file, enter one of the following values:

     *

     *        3gp, aac, asf, avi, divx,
     *        flv, m4a, mkv, mov, mp3, mp4, mpeg, mpeg-ps, mpeg-ts, mxf, ogg,
     *        vob, wav, webm
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public JobInput withContainer(String container) {
        setContainer(container);
        return this;
    }

    /**
     *

     * The encryption settings, if any, that are used for decrypting your input files. If your input file is encrypted,
     * you must specify the mode that Elastic Transcoder uses to decrypt your file.
     *

     *
     * @param encryption
     *        The encryption settings, if any, that are used for decrypting your input files. If your input file is
     *        encrypted, you must specify the mode that Elastic Transcoder uses to decrypt your file.
     */

    public void setEncryption(Encryption encryption) {
        this.encryption = encryption;
    }

    /**
     *

     * The encryption settings, if any, that are used for decrypting your input files. If your input file is encrypted,
     * you must specify the mode that Elastic Transcoder uses to decrypt your file.
     *

     *
     * @return The encryption settings, if any, that are used for decrypting your input files. If your input file is
     *         encrypted, you must specify the mode that Elastic Transcoder uses to decrypt your file.
     */

    public Encryption getEncryption() {
        return this.encryption;
    }

    /**
     *

     * The encryption settings, if any, that are used for decrypting your input files. If your input file is encrypted,
     * you must specify the mode that Elastic Transcoder uses to decrypt your file.
     *

     *
     * @param encryption
     *        The encryption settings, if any, that are used for decrypting your input files. If your input file is
     *        encrypted, you must specify the mode that Elastic Transcoder uses to decrypt your file.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public JobInput withEncryption(Encryption encryption) {
        setEncryption(encryption);
        return this;
    }

    /**
     *

     * Settings for clipping an input. Each input can have different clip settings.
     *

     *
     * @param timeSpan
     *        Settings for clipping an input. Each input can have different clip settings.
     */

    public void setTimeSpan(TimeSpan timeSpan) {
        this.timeSpan = timeSpan;
    }

    /**
     *

     * Settings for clipping an input. Each input can have different clip settings.
     *

     *
     * @return Settings for clipping an input. Each input can have different clip settings.
     */

    public TimeSpan getTimeSpan() {
        return this.timeSpan;
    }

    /**
     *

     * Settings for clipping an input. Each input can have different clip settings.
     *

     *
     * @param timeSpan
     *        Settings for clipping an input. Each input can have different clip settings.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public JobInput withTimeSpan(TimeSpan timeSpan) {
        setTimeSpan(timeSpan);
        return this;
    }

    /**
     *

     * You can configure Elastic Transcoder to transcode captions, or subtitles, from one format to another. All
     * captions must be in UTF-8. Elastic Transcoder supports two types of captions:
     *

     *

     *

     *

     * Embedded: Embedded captions are included in the same file as the audio and video. Elastic Transcoder
     * supports only one embedded caption per language, to a maximum of 300 embedded captions per file.
     *

     *

     * Valid input values include: CEA-608 (EIA-608, first non-empty channel only),
     * CEA-708 (EIA-708, first non-empty channel only), and mov-text
     *

     *

     * Valid outputs include: mov-text
     *

     *

     * Elastic Transcoder supports a maximum of one embedded format per output.
     *

     *

     *

     *

     * Sidecar: Sidecar captions are kept in a separate metadata file from the audio and video data. Sidecar
     * captions require a player that is capable of understanding the relationship between the video file and the
     * sidecar file. Elastic Transcoder supports only one sidecar caption per language, to a maximum of 20 sidecar
     * captions per file.
     *

     *

     * Valid input values include: dfxp (first div element only), ebu-tt, scc,
     * smpt, srt, ttml (first div element only), and webvtt
     *

     *

     * Valid outputs include: dfxp (first div element only), scc, srt, and
     * webvtt.
     *

     *

     *

     *

     * If you want ttml or smpte-tt compatible captions, specify dfxp as your output format.
     *

     *

     * Elastic Transcoder does not support OCR (Optical Character Recognition), does not accept pictures as a valid
     * input for captions, and is not available for audio-only transcoding. Elastic Transcoder does not preserve text
     * formatting (for example, italics) during the transcoding process.
     *

     *

     * To remove captions or leave the captions empty, set Captions to null. To pass through existing
     * captions unchanged, set the MergePolicy to MergeRetain, and pass in a null
     * CaptionSources array.
     *

     *

     * For more information on embedded files, see the Subtitles Wikipedia page.
     *

     *

     * For more information on sidecar files, see the Extensible Metadata Platform and Sidecar file Wikipedia pages.
     *

     *
     * @param inputCaptions
     *        You can configure Elastic Transcoder to transcode captions, or subtitles, from one format to another. All
     *        captions must be in UTF-8. Elastic Transcoder supports two types of captions:

     *

     *

     *

     *        Embedded: Embedded captions are included in the same file as the audio and video. Elastic
     *        Transcoder supports only one embedded caption per language, to a maximum of 300 embedded captions per
     *        file.
     *

     *

     *        Valid input values include: CEA-608 (EIA-608, first non-empty channel only),
     *        CEA-708 (EIA-708, first non-empty channel only), and mov-text
     *

     *

     *        Valid outputs include: mov-text
     *

     *

     *        Elastic Transcoder supports a maximum of one embedded format per output.
     *

     *

     *

     *

     *        Sidecar: Sidecar captions are kept in a separate metadata file from the audio and video data.
     *        Sidecar captions require a player that is capable of understanding the relationship between the video file
     *        and the sidecar file. Elastic Transcoder supports only one sidecar caption per language, to a maximum of
     *        20 sidecar captions per file.
     *

     *

     *        Valid input values include: dfxp (first div element only), ebu-tt,
     *        scc, smpt, srt, ttml (first div element only), and
     *        webvtt
     *

     *

     *        Valid outputs include: dfxp (first div element only), scc, srt, and
     *        webvtt.
     *

     *

     *

     *

     *        If you want ttml or smpte-tt compatible captions, specify dfxp as your output format.
     *

     *

     *        Elastic Transcoder does not support OCR (Optical Character Recognition), does not accept pictures as a
     *        valid input for captions, and is not available for audio-only transcoding. Elastic Transcoder does not
     *        preserve text formatting (for example, italics) during the transcoding process.
     *

     *

     *        To remove captions or leave the captions empty, set Captions to null. To pass through
     *        existing captions unchanged, set the MergePolicy to MergeRetain, and pass in a
     *        null CaptionSources array.
     *

     *

     *        For more information on embedded files, see the Subtitles Wikipedia page.
     *

     *

     *        For more information on sidecar files, see the Extensible Metadata Platform and Sidecar file Wikipedia
     *        pages.
     */

    public void setInputCaptions(InputCaptions inputCaptions) {
        this.inputCaptions = inputCaptions;
    }

    /**
     *

     * You can configure Elastic Transcoder to transcode captions, or subtitles, from one format to another. All
     * captions must be in UTF-8. Elastic Transcoder supports two types of captions:
     *

     *

     *

     *

     * Embedded: Embedded captions are included in the same file as the audio and video. Elastic Transcoder
     * supports only one embedded caption per language, to a maximum of 300 embedded captions per file.
     *

     *

     * Valid input values include: CEA-608 (EIA-608, first non-empty channel only),
     * CEA-708 (EIA-708, first non-empty channel only), and mov-text
     *

     *

     * Valid outputs include: mov-text
     *

     *

     * Elastic Transcoder supports a maximum of one embedded format per output.
     *

     *

     *

     *

     * Sidecar: Sidecar captions are kept in a separate metadata file from the audio and video data. Sidecar
     * captions require a player that is capable of understanding the relationship between the video file and the
     * sidecar file. Elastic Transcoder supports only one sidecar caption per language, to a maximum of 20 sidecar
     * captions per file.
     *

     *

     * Valid input values include: dfxp (first div element only), ebu-tt, scc,
     * smpt, srt, ttml (first div element only), and webvtt
     *

     *

     * Valid outputs include: dfxp (first div element only), scc, srt, and
     * webvtt.
     *

     *

     *

     *

     * If you want ttml or smpte-tt compatible captions, specify dfxp as your output format.
     *

     *

     * Elastic Transcoder does not support OCR (Optical Character Recognition), does not accept pictures as a valid
     * input for captions, and is not available for audio-only transcoding. Elastic Transcoder does not preserve text
     * formatting (for example, italics) during the transcoding process.
     *

     *

     * To remove captions or leave the captions empty, set Captions to null. To pass through existing
     * captions unchanged, set the MergePolicy to MergeRetain, and pass in a null
     * CaptionSources array.
     *

     *

     * For more information on embedded files, see the Subtitles Wikipedia page.
     *

     *

     * For more information on sidecar files, see the Extensible Metadata Platform and Sidecar file Wikipedia pages.
     *

     *
     * @return You can configure Elastic Transcoder to transcode captions, or subtitles, from one format to another. All
     *         captions must be in UTF-8. Elastic Transcoder supports two types of captions:

     *

     *

     *

     *         Embedded: Embedded captions are included in the same file as the audio and video. Elastic
     *         Transcoder supports only one embedded caption per language, to a maximum of 300 embedded captions per
     *         file.
     *

     *

     *         Valid input values include: CEA-608 (EIA-608, first non-empty channel only),
     *         CEA-708 (EIA-708, first non-empty channel only), and mov-text
     *

     *

     *         Valid outputs include: mov-text
     *

     *

     *         Elastic Transcoder supports a maximum of one embedded format per output.
     *

     *

     *

     *

     *         Sidecar: Sidecar captions are kept in a separate metadata file from the audio and video data.
     *         Sidecar captions require a player that is capable of understanding the relationship between the video
     *         file and the sidecar file. Elastic Transcoder supports only one sidecar caption per language, to a
     *         maximum of 20 sidecar captions per file.
     *

     *

     *         Valid input values include: dfxp (first div element only), ebu-tt,
     *         scc, smpt, srt, ttml (first div element only), and
     *         webvtt
     *

     *

     *         Valid outputs include: dfxp (first div element only), scc, srt,
     *         and webvtt.
     *

     *

     *

     *

     *         If you want ttml or smpte-tt compatible captions, specify dfxp as your output format.
     *

     *

     *         Elastic Transcoder does not support OCR (Optical Character Recognition), does not accept pictures as a
     *         valid input for captions, and is not available for audio-only transcoding. Elastic Transcoder does not
     *         preserve text formatting (for example, italics) during the transcoding process.
     *

     *

     *         To remove captions or leave the captions empty, set Captions to null. To pass through
     *         existing captions unchanged, set the MergePolicy to MergeRetain, and pass in a
     *         null CaptionSources array.
     *

     *

     *         For more information on embedded files, see the Subtitles Wikipedia page.
     *

     *

     *         For more information on sidecar files, see the Extensible Metadata Platform and Sidecar file Wikipedia
     *         pages.
     */

    public InputCaptions getInputCaptions() {
        return this.inputCaptions;
    }

    /**
     *

     * You can configure Elastic Transcoder to transcode captions, or subtitles, from one format to another. All
     * captions must be in UTF-8. Elastic Transcoder supports two types of captions:
     *

     *

     *

     *

     * Embedded: Embedded captions are included in the same file as the audio and video. Elastic Transcoder
     * supports only one embedded caption per language, to a maximum of 300 embedded captions per file.
     *

     *

     * Valid input values include: CEA-608 (EIA-608, first non-empty channel only),
     * CEA-708 (EIA-708, first non-empty channel only), and mov-text
     *

     *

     * Valid outputs include: mov-text
     *

     *

     * Elastic Transcoder supports a maximum of one embedded format per output.
     *

     *

     *

     *

     * Sidecar: Sidecar captions are kept in a separate metadata file from the audio and video data. Sidecar
     * captions require a player that is capable of understanding the relationship between the video file and the
     * sidecar file. Elastic Transcoder supports only one sidecar caption per language, to a maximum of 20 sidecar
     * captions per file.
     *

     *

     * Valid input values include: dfxp (first div element only), ebu-tt, scc,
     * smpt, srt, ttml (first div element only), and webvtt
     *

     *

     * Valid outputs include: dfxp (first div element only), scc, srt, and
     * webvtt.
     *

     *

     *

     *

     * If you want ttml or smpte-tt compatible captions, specify dfxp as your output format.
     *

     *

     * Elastic Transcoder does not support OCR (Optical Character Recognition), does not accept pictures as a valid
     * input for captions, and is not available for audio-only transcoding. Elastic Transcoder does not preserve text
     * formatting (for example, italics) during the transcoding process.
     *

     *

     * To remove captions or leave the captions empty, set Captions to null. To pass through existing
     * captions unchanged, set the MergePolicy to MergeRetain, and pass in a null
     * CaptionSources array.
     *

     *

     * For more information on embedded files, see the Subtitles Wikipedia page.
     *

     *

     * For more information on sidecar files, see the Extensible Metadata Platform and Sidecar file Wikipedia pages.
     *

     *
     * @param inputCaptions
     *        You can configure Elastic Transcoder to transcode captions, or subtitles, from one format to another. All
     *        captions must be in UTF-8. Elastic Transcoder supports two types of captions:

     *

     *

     *

     *        Embedded: Embedded captions are included in the same file as the audio and video. Elastic
     *        Transcoder supports only one embedded caption per language, to a maximum of 300 embedded captions per
     *        file.
     *

     *

     *        Valid input values include: CEA-608 (EIA-608, first non-empty channel only),
     *        CEA-708 (EIA-708, first non-empty channel only), and mov-text
     *

     *

     *        Valid outputs include: mov-text
     *

     *

     *        Elastic Transcoder supports a maximum of one embedded format per output.
     *

     *

     *

     *

     *        Sidecar: Sidecar captions are kept in a separate metadata file from the audio and video data.
     *        Sidecar captions require a player that is capable of understanding the relationship between the video file
     *        and the sidecar file. Elastic Transcoder supports only one sidecar caption per language, to a maximum of
     *        20 sidecar captions per file.
     *

     *

     *        Valid input values include: dfxp (first div element only), ebu-tt,
     *        scc, smpt, srt, ttml (first div element only), and
     *        webvtt
     *

     *

     *        Valid outputs include: dfxp (first div element only), scc, srt, and
     *        webvtt.
     *

     *

     *

     *

     *        If you want ttml or smpte-tt compatible captions, specify dfxp as your output format.
     *

     *

     *        Elastic Transcoder does not support OCR (Optical Character Recognition), does not accept pictures as a
     *        valid input for captions, and is not available for audio-only transcoding. Elastic Transcoder does not
     *        preserve text formatting (for example, italics) during the transcoding process.
     *

     *

     *        To remove captions or leave the captions empty, set Captions to null. To pass through
     *        existing captions unchanged, set the MergePolicy to MergeRetain, and pass in a
     *        null CaptionSources array.
     *

     *

     *        For more information on embedded files, see the Subtitles Wikipedia page.
     *

     *

     *        For more information on sidecar files, see the Extensible Metadata Platform and Sidecar file Wikipedia
     *        pages.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public JobInput withInputCaptions(InputCaptions inputCaptions) {
        setInputCaptions(inputCaptions);
        return this;
    }

    /**
     *

     * The detected properties of the input file.
     *

     *
     * @param detectedProperties
     *        The detected properties of the input file.
     */

    public void setDetectedProperties(DetectedProperties detectedProperties) {
        this.detectedProperties = detectedProperties;
    }

    /**
     *

     * The detected properties of the input file.
     *

     *
     * @return The detected properties of the input file.
     */

    public DetectedProperties getDetectedProperties() {
        return this.detectedProperties;
    }

    /**
     *

     * The detected properties of the input file.
     *

     *
     * @param detectedProperties
     *        The detected properties of the input file.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public JobInput withDetectedProperties(DetectedProperties detectedProperties) {
        setDetectedProperties(detectedProperties);
        return this;
    }

    /**
     * Returns a string representation of this object; useful for testing and debugging.
     *
     * @return A string representation of this object.
     *
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        if (getKey() != null)
            sb.append("Key: ").append(getKey()).append(",");
        if (getFrameRate() != null)
            sb.append("FrameRate: ").append(getFrameRate()).append(",");
        if (getResolution() != null)
            sb.append("Resolution: ").append(getResolution()).append(",");
        if (getAspectRatio() != null)
            sb.append("AspectRatio: ").append(getAspectRatio()).append(",");
        if (getInterlaced() != null)
            sb.append("Interlaced: ").append(getInterlaced()).append(",");
        if (getContainer() != null)
            sb.append("Container: ").append(getContainer()).append(",");
        if (getEncryption() != null)
            sb.append("Encryption: ").append(getEncryption()).append(",");
        if (getTimeSpan() != null)
            sb.append("TimeSpan: ").append(getTimeSpan()).append(",");
        if (getInputCaptions() != null)
            sb.append("InputCaptions: ").append(getInputCaptions()).append(",");
        if (getDetectedProperties() != null)
            sb.append("DetectedProperties: ").append(getDetectedProperties());
        sb.append("}");
        return sb.toString();
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;

        if (obj instanceof JobInput == false)
            return false;
        JobInput other = (JobInput) obj;
        if (other.getKey() == null ^ this.getKey() == null)
            return false;
        if (other.getKey() != null && other.getKey().equals(this.getKey()) == false)
            return false;
        if (other.getFrameRate() == null ^ this.getFrameRate() == null)
            return false;
        if (other.getFrameRate() != null && other.getFrameRate().equals(this.getFrameRate()) == false)
            return false;
        if (other.getResolution() == null ^ this.getResolution() == null)
            return false;
        if (other.getResolution() != null && other.getResolution().equals(this.getResolution()) == false)
            return false;
        if (other.getAspectRatio() == null ^ this.getAspectRatio() == null)
            return false;
        if (other.getAspectRatio() != null && other.getAspectRatio().equals(this.getAspectRatio()) == false)
            return false;
        if (other.getInterlaced() == null ^ this.getInterlaced() == null)
            return false;
        if (other.getInterlaced() != null && other.getInterlaced().equals(this.getInterlaced()) == false)
            return false;
        if (other.getContainer() == null ^ this.getContainer() == null)
            return false;
        if (other.getContainer() != null && other.getContainer().equals(this.getContainer()) == false)
            return false;
        if (other.getEncryption() == null ^ this.getEncryption() == null)
            return false;
        if (other.getEncryption() != null && other.getEncryption().equals(this.getEncryption()) == false)
            return false;
        if (other.getTimeSpan() == null ^ this.getTimeSpan() == null)
            return false;
        if (other.getTimeSpan() != null && other.getTimeSpan().equals(this.getTimeSpan()) == false)
            return false;
        if (other.getInputCaptions() == null ^ this.getInputCaptions() == null)
            return false;
        if (other.getInputCaptions() != null && other.getInputCaptions().equals(this.getInputCaptions()) == false)
            return false;
        if (other.getDetectedProperties() == null ^ this.getDetectedProperties() == null)
            return false;
        if (other.getDetectedProperties() != null && other.getDetectedProperties().equals(this.getDetectedProperties()) == false)
            return false;
        return true;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int hashCode = 1;

        hashCode = prime * hashCode + ((getKey() == null) ? 0 : getKey().hashCode());
        hashCode = prime * hashCode + ((getFrameRate() == null) ? 0 : getFrameRate().hashCode());
        hashCode = prime * hashCode + ((getResolution() == null) ? 0 : getResolution().hashCode());
        hashCode = prime * hashCode + ((getAspectRatio() == null) ? 0 : getAspectRatio().hashCode());
        hashCode = prime * hashCode + ((getInterlaced() == null) ? 0 : getInterlaced().hashCode());
        hashCode = prime * hashCode + ((getContainer() == null) ? 0 : getContainer().hashCode());
        hashCode = prime * hashCode + ((getEncryption() == null) ? 0 : getEncryption().hashCode());
        hashCode = prime * hashCode + ((getTimeSpan() == null) ? 0 : getTimeSpan().hashCode());
        hashCode = prime * hashCode + ((getInputCaptions() == null) ? 0 : getInputCaptions().hashCode());
        hashCode = prime * hashCode + ((getDetectedProperties() == null) ? 0 : getDetectedProperties().hashCode());
        return hashCode;
    }

    @Override
    public JobInput clone() {
        try {
            return (JobInput) super.clone();
        } catch (CloneNotSupportedException e) {
            throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
        }
    }

    @com.amazonaws.annotation.SdkInternalApi
    @Override
    public void marshall(ProtocolMarshaller protocolMarshaller) {
        com.amazonaws.services.elastictranscoder.model.transform.JobInputMarshaller.getInstance().marshall(this, protocolMarshaller);
    }
}


text:
layout: post
date: 2016-01-27
title: "Atelier Aimée wedding dresses 2014 simona strapless ball gown gold accents Sleeveless Ballgown"
category: Atelier Aimée
tags: [Atelier Aimée,Ballgown,Scalloped-Edge,Sleeveless]
---
### Atelier Aimée wedding dresses 2014 simona strapless ball gown gold accents
Just **$459.99**
###   Sleeveless  Ballgown

BRANDS	Atelier Aimée

Silhouette	Ballgown

Neckline	Scalloped-Edge

Sleeve	Sleeveless

Buy it: [https://www.readybrides.com/en/atelier-aimee/40868-atelier-aimee-wedding-dresses-2014-simona-strapless-ball-gown-gold-accents.html](https://www.readybrides.com/en/atelier-aimee/40868-atelier-aimee-wedding-dresses-2014-simona-strapless-ball-gown-gold-accents.html)


text:
require 'optparse'
require 'google/ads/google_ads'
require 'date'

def handle_rate_exceeded_error(customer_id, ad_group_id)
  # GoogleAdsClient will read a config file from
  # ENV['HOME']/google_ads_config.rb when called without parameters
  client = Google::Ads::GoogleAds::GoogleAdsClient.new

  # Sequentially sends the requests.
  NUM_REQUESTS.times do |i|
    # Creates operations.
    operations = create_ad_group_criterion_operations(
      client, customer_id, ad_group_id, i)

    begin
      retry_count = 0
      retry_seconds = RETRY_SECONDS
      while retry_count < NUM_RETRIES
        begin
          # Sends request.
          request_mutate_and_display_result(client, customer_id, operations)
          break
        rescue Google::Ads::GoogleAds::Errors::GoogleAdsError => e
          has_rate_exceeded_error = false
          e.failure.errors.each do |error|
            # Checks if any of the errors are QuotaError.RESOURCE_EXHAUSTED or
            # QuotaError.RESOURCE_TEMPORARILY_EXHAUSTED.
            if error.error_code.quota_error == :RESOURCE_EXHAUSTED \
              || error.error_code.quota_error == :RESOURCE_TEMPORARILY_EXHAUSTED
              puts "Received rate exceeded error, retry after " \
                "#{retry_seconds} seconds."
              sleep retry_seconds
              has_rate_exceeded_error = true
              retry_count += 1
              # Uses an exponential back-off policy.
              retry_seconds *= 2
              break
            end
          end
          # Bubbles up when there is not RateExceededError.
          if !has_rate_exceeded_error
            raise
          end
        ensure
          # Bubbles up when the number of retries has already been reached.
          if retry_count == NUM_RETRIES
            raise "Could not recover after making #{retry_count} attempts."
          end
        end
      end
    rescue StandardError => e
      # Prints any unhandled exception and bubbles up.
      puts "Failed to validate keywords. #{e.message}"
      raise
    end
  end
end

def create_ad_group_criterion_operations(
  client,
  customer_id,
  ad_group_id,
  req_index
)
  operations = []
  NUM_KEYWORDS.times do |i|
    # Creates an ad group criterion operation.
    operations << client.operation.create_resource.ad_group_criterion do |agc|
      agc.ad_group = client.path.ad_group(customer_id, ad_group_id)
      agc.status = :ENABLED
      agc.keyword = client.resource.keyword_info do |ki|
        ki.text = "mars cruise req #{req_index} seed #{i}"
        ki.match_type = :EXACT
      end
    end
  end
  operations
end

def request_mutate_and_display_result(client, customer_id, operations)
  # Makes a validate_only mutate request.
  response = client.service.ad_group_criterion.mutate_ad_group_criteria(
    customer_id: customer_id,
    operations: operations,
    partial_failure: false,
    validate_only: true,
  )

  # Displays the results.
  puts "Added #{response.results.size} ad group criteria:"
  response.results.each do |result|
    puts "\t#{result.resource_name}"
  end
end

if __FILE__ == $PROGRAM_NAME
  # Number of requests to be run.
  NUM_REQUESTS = 5
  # Number of keywords to be validated in each API call.
  NUM_KEYWORDS = 100
  # Number of retries to be run in case of a RateExceededError.
  NUM_RETRIES = 3
  # Minimum number of seconds to wait before a retry.
  RETRY_SECONDS = 10

  options = {}
  # The following parameter(s) should be provided to run the example. You can
  # either specify these by changing the INSERT_XXX_ID_HERE values below, or on
  # the command line.
  #
  # Parameters passed on the command line will override any parameters set in
  # code.
  #
  # Running the example with -h will print the command line usage.
  options[:customer_id] = 'INSERT_CUSTOMER_ID_HERE'
  options[:ad_group_id] = 'INSERT_AD_GROUP_ID_HERE'

  OptionParser.new do |opts|
    opts.banner = sprintf('Usage: ruby %s [options]', File.basename(__FILE__))

    opts.separator ''
    opts.separator 'Options:'

    opts.on('-C', '--customer-id CUSTOMER-ID', String, 'Customer ID') do |v|
      options[:customer_id] = v
    end

    opts.on('-A', '--ad-group-id AD-GROUP-ID', String, 'Ad Group ID') do |v|
      options[:ad_group_id] = v
    end

    opts.separator ''
    opts.separator 'Help:'

    opts.on_tail('-h', '--help', 'Show this message') do
      puts opts
      exit
    end
  end.parse!

  begin
    handle_rate_exceeded_error(
      options.fetch(:customer_id).tr("-", ""),
      options.fetch(:ad_group_id),
    )
  rescue Google::Ads::GoogleAds::Errors::GoogleAdsError => e
    e.failure.errors.each do |error|
      STDERR.printf("Error with message: %s\n", error.message)
      if error.location
        error.location.field_path_elements.each do |field_path_element|
          STDERR.printf("\tOn field: %s\n", field_path_element.field_name)
        end
      end
      error.error_code.to_h.each do |k, v|
        next if v == :UNSPECIFIED
        STDERR.printf("\tType: %s\n\tCode: %s\n", k, v)
      end
    end
    raise
  end
end