Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.21 KB | None | 0 0
  1. package com.fitbank.person.sequence;
  2.  
  3. import com.fitbank.dto.management.Detail;
  4. import com.fitbank.dto.management.Field;
  5. import com.fitbank.dto.management.Record;
  6. import com.fitbank.dto.management.Table;
  7. import com.fitbank.processor.maintenance.MaintenanceCommand;
  8.  
  9. public class SequenceLikendPerson extends MaintenanceCommand  {
  10.  
  11.     private final static String PERSON = "CPERSONA";
  12.     private final static String PERSON_LIKEND = "CPERSONA_VINCULADA";
  13.    
  14.     @Override
  15.     public Detail executeNormal(Detail pDetail) throws Exception {
  16.         Integer numero=this.findCperson(pDetail);
  17.         this.setCpersonInTable(pDetail, numero);
  18.        
  19.         pDetail.addField(new Field("192006", numero));      
  20.         if (pDetail.findFieldByName(PERSON_LIKEND) == null || pDetail.findFieldByName(PERSON_LIKEND).getValue() == null) {
  21.             pDetail.findFieldByNameCreate(PERSON_LIKEND).setValue(numero);
  22.         }
  23.  
  24.         return pDetail;
  25.     }
  26.  
  27.     /**
  28.      * Fija el cpersona en las tablas del Detail
  29.      *
  30.      * @param pDetail
  31.      * @param numero
  32.      */
  33.     public void setCpersonInTable(Detail pDetail,Integer numero) {
  34.         for (Table t : pDetail.getTables()) {
  35.             for (Record r : t.getRecords()) {
  36.                 Field f = r.findFieldByName(PERSON_LIKEND);
  37.                 if (f != null && f.getValue() == null) {
  38.                     f.setValue(numero);
  39.                 }
  40.             }
  41.         }
  42.     }
  43.  
  44.     /**
  45.      *Busca en el Detail el cpersona que ya fue generado para la tabla tpersona
  46.      *
  47.      * @param pDetail
  48.      */
  49.     public Integer findCperson(Detail pDetail) throws Exception {
  50.         Integer num=0;
  51.         for (Table t : pDetail.getTables()) {
  52.             if (t.getName().toString().compareTo("TPERSONAVINCULACIONES")==0){
  53.                  continue;
  54.             }
  55.             for (Record r : t.getRecords()) {
  56.                 Field f = r.findFieldByName(PERSON);
  57.                 if (f != null && f.getValue() != null) {
  58.                     num=f.getIntegerValue();
  59.                 }
  60.             }
  61.         }
  62.         return num;
  63.     }
  64.  
  65.     @Override
  66.     public Detail executeReverse(Detail pDetail) throws Exception {
  67.         return pDetail;
  68.     }
  69.  
  70.  
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement