Commits

tbrugz committed 8354a6d Draft

transf: candidatos: adicionado 'valido', melhoria geração de FKs

Comments (0)

Files changed (3)

kettle/repositorio-de-dados-eleitorais/origem_LISTACAND.ktr

         <rename>DESC_SIT_TOT_TURNO</rename>
         <update>Y</update>
       </value>
+      <value>
+        <name>SIGLA_UE</name>
+        <rename>SIGLA_UE</rename>
+        <update>Y</update>
+      </value>
+      <value>
+        <name>ID_UE</name>
+        <rename>ID_UE</rename>
+        <update>Y</update>
+      </value>
+      <value>
+        <name>VALIDO</name>
+        <rename>VALIDO</rename>
+        <update>Y</update>
+      </value>
     </lookup>
      <cluster_schema/>
  <remotesteps>   <input>   </input>   <output>   </output> </remotesteps>    <GUI>
         <rename/>
         <length>-2</length>
         <precision>-2</precision>
+      </field>      <field>        <name>ID_UE</name>
+        <rename/>
+        <length>-2</length>
+        <precision>-2</precision>
+      </field>      <field>        <name>VALIDO</name>
+        <rename/>
+        <length>-2</length>
+        <precision>-2</precision>
       </field>        <select_unspecified>N</select_unspecified>
     </fields>     <cluster_schema/>
  <remotesteps>   <input>   </input>   <output>   </output> </remotesteps>    <GUI>
 	+lpad(CD_CARGO,&apos;0&apos;,2)
 	+lpad(NR_CANDIDATO,&apos;0&apos;,5)
 	;
-</jsScript_script>
+
+var ID_UE = &apos;&apos;
+	+ANO_ELEICAO
+	+SIGLA_UE
+
+var VALIDO = &apos;S&apos;;</jsScript_script>
       </jsScript>    </jsScripts>    <fields>      <field>        <name>ID_PARTIDO</name>
         <rename>ID_PARTIDO</rename>
         <type>String</type>
         <length>20</length>
         <precision>-1</precision>
         <replace>N</replace>
+      </field>      <field>        <name>ID_UE</name>
+        <rename>ID_UE</rename>
+        <type>String</type>
+        <length>10</length>
+        <precision>-1</precision>
+        <replace>N</replace>
+      </field>      <field>        <name>VALIDO</name>
+        <rename>VALIDO</rename>
+        <type>String</type>
+        <length>1</length>
+        <precision>-1</precision>
+        <replace>N</replace>
       </field>    </fields>     <cluster_schema/>
  <remotesteps>   <input>   </input>   <output>   </output> </remotesteps>    <GUI>
       <xloc>340</xloc>

kettle/repositorio-de-dados-eleitorais/origem_ue_candidatos_invalidos.ktr

   <order>
   <hop> <from>js</from><to>tse_candidatos inv</to><enabled>Y</enabled> </hop>  <hop> <from>tse_unidade_eleitoral</from><to>js</to><enabled>Y</enabled> </hop>  </order>
   <step>
+    <name>js</name>
+    <type>ScriptValueMod</type>
+    <description/>
+    <distribute>Y</distribute>
+    <copies>1</copies>
+         <partitioning>
+           <method>none</method>
+           <schema_name/>
+           </partitioning>
+    <compatible>N</compatible>
+    <jsScripts>      <jsScript>        <jsScript_type>0</jsScript_type>
+        <jsScript_name>Script 1</jsScript_name>
+        <jsScript_script>&#47;&#47;Script here
+
+var ID_PARTIDO = &apos;&apos;
+	+ANO_ELEICAO
+	+SIGLA_UE
+	+lpad(NR_PARTIDO,&apos;0&apos;,2)
+	;
+
+var ID_CANDIDATO = &apos;&apos;
+	+ANO_ELEICAO
+	+SIGLA_UE
+	+lpad(CD_CARGO,&apos;0&apos;,2)
+	+lpad(NR_PARTIDO,&apos;0&apos;,5)
+	;</jsScript_script>
+      </jsScript>    </jsScripts>    <fields>      <field>        <name>ID_PARTIDO</name>
+        <rename>ID_PARTIDO</rename>
+        <type>String</type>
+        <length>12</length>
+        <precision>-1</precision>
+        <replace>N</replace>
+      </field>      <field>        <name>ID_CANDIDATO</name>
+        <rename>ID_CANDIDATO</rename>
+        <type>String</type>
+        <length>20</length>
+        <precision>-1</precision>
+        <replace>N</replace>
+      </field>    </fields>     <cluster_schema/>
+ <remotesteps>   <input>   </input>   <output>   </output> </remotesteps>    <GUI>
+      <xloc>222</xloc>
+      <yloc>100</yloc>
+      <draw>Y</draw>
+      </GUI>
+    </step>
+
+  <step>
     <name>tse_candidatos inv</name>
     <type>InsertUpdate</type>
     <description/>
         <rename>ID_CANDIDATO</rename>
         <update>Y</update>
       </value>
+      <value>
+        <name>UF</name>
+        <rename>SIGLA_UF</rename>
+        <update>Y</update>
+      </value>
+      <value>
+        <name>VALIDO</name>
+        <rename>VALIDO</rename>
+        <update>Y</update>
+      </value>
     </lookup>
      <cluster_schema/>
  <remotesteps>   <input>   </input>   <output>   </output> </remotesteps>    <GUI>
     </step>
 
   <step>
-    <name>js</name>
-    <type>ScriptValueMod</type>
-    <description/>
-    <distribute>Y</distribute>
-    <copies>1</copies>
-         <partitioning>
-           <method>none</method>
-           <schema_name/>
-           </partitioning>
-    <compatible>N</compatible>
-    <jsScripts>      <jsScript>        <jsScript_type>0</jsScript_type>
-        <jsScript_name>Script 1</jsScript_name>
-        <jsScript_script>&#47;&#47;Script here
-
-var ID_PARTIDO = &apos;&apos;
-	+ANO_ELEICAO
-	+SIGLA_UE
-	+lpad(NR_PARTIDO,&apos;0&apos;,2)
-	;
-
-var ID_CANDIDATO = &apos;&apos;
-	+ANO_ELEICAO
-	+SIGLA_UE
-	+lpad(CD_CARGO,&apos;0&apos;,2)
-	+lpad(NR_PARTIDO,&apos;0&apos;,5)
-	;</jsScript_script>
-      </jsScript>    </jsScripts>    <fields>      <field>        <name>ID_PARTIDO</name>
-        <rename>ID_PARTIDO</rename>
-        <type>String</type>
-        <length>12</length>
-        <precision>-1</precision>
-        <replace>N</replace>
-      </field>      <field>        <name>ID_CANDIDATO</name>
-        <rename>ID_CANDIDATO</rename>
-        <type>String</type>
-        <length>20</length>
-        <precision>-1</precision>
-        <replace>N</replace>
-      </field>    </fields>     <cluster_schema/>
- <remotesteps>   <input>   </input>   <output>   </output> </remotesteps>    <GUI>
-      <xloc>222</xloc>
-      <yloc>100</yloc>
-      <draw>Y</draw>
-      </GUI>
-    </step>
-
-  <step>
     <name>tse_unidade_eleitoral</name>
     <type>TableInput</type>
     <description/>
            <schema_name/>
            </partitioning>
     <connection>dw_pgsql_tse</connection>
-    <sql>SELECT ANO_ELEICAO, DS_ELEICAO, SIGLA_UE, ID_UE, NR_PARTIDO, SIGLA_PARTIDO, NM_PARTIDO, NM_LEGENDA, DS_LEGENDA, CD_CARGO, ESFERA_CARGO, DS_CARGO
-FROM tse_unidade_eleitoral ue, TSE_PARTIDOS_CONS p, TSE_CARGOS c
-where p.id_tse is null
-and ano_eleicao = ${dadostse.carga.anoeleicao}
-and sigla_uf = &apos;${dadostse.carga.uf}&apos;
+    <sql>SELECT ANO_ELEICAO, DS_ELEICAO, SIGLA_UF, SIGLA_UE, ID_UE, 
+	NR_PARTIDO, SIGLA_PARTIDO, NM_PARTIDO, NM_LEGENDA, DS_LEGENDA, 
+	CD_CARGO, ESFERA_CARGO, DS_CARGO, &apos;N&apos; as VALIDO
+FROM tse_unidade_eleitoral ue, TSE_PARTIDOS_CONS p, TSE_CARGOS c
+where p.id_tse is null
+and ano_eleicao = ${dadostse.carga.anoeleicao}
+and sigla_uf = &apos;${dadostse.carga.uf}&apos;
 order by id_ue, nr_partido</sql>
     <limit>0</limit>
     <lookup/>

modelo/TABLEs.sql

 	desc_sit_tot_turno varchar(100),
 	sigla_ue varchar(5),
 	id_ue varchar(10),
+	valido varchar(1),
 	constraint tse_candidatos_pk primary key (id_candidato),
 	constraint tse_candidatos_uk1 UNIQUE (seq_candidato)
 );