Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.fitbank.person.sequence;
- import com.fitbank.dto.management.Detail;
- import com.fitbank.dto.management.Field;
- import com.fitbank.dto.management.Record;
- import com.fitbank.dto.management.Table;
- import com.fitbank.processor.maintenance.MaintenanceCommand;
- public class SequenceLikendPerson extends MaintenanceCommand {
- private final static String PERSON = "CPERSONA";
- private final static String PERSON_LIKEND = "CPERSONA_VINCULADA";
- @Override
- public Detail executeNormal(Detail pDetail) throws Exception {
- Integer numero=this.findCperson(pDetail);
- this.setCpersonInTable(pDetail, numero);
- pDetail.addField(new Field("192006", numero));
- if (pDetail.findFieldByName(PERSON_LIKEND) == null || pDetail.findFieldByName(PERSON_LIKEND).getValue() == null) {
- pDetail.findFieldByNameCreate(PERSON_LIKEND).setValue(numero);
- }
- return pDetail;
- }
- /**
- * Fija el cpersona en las tablas del Detail
- *
- * @param pDetail
- * @param numero
- */
- public void setCpersonInTable(Detail pDetail,Integer numero) {
- for (Table t : pDetail.getTables()) {
- for (Record r : t.getRecords()) {
- Field f = r.findFieldByName(PERSON_LIKEND);
- if (f != null && f.getValue() == null) {
- f.setValue(numero);
- }
- }
- }
- }
- /**
- *Busca en el Detail el cpersona que ya fue generado para la tabla tpersona
- *
- * @param pDetail
- */
- public Integer findCperson(Detail pDetail) throws Exception {
- Integer num=0;
- for (Table t : pDetail.getTables()) {
- if (t.getName().toString().compareTo("TPERSONAVINCULACIONES")==0){
- continue;
- }
- for (Record r : t.getRecords()) {
- Field f = r.findFieldByName(PERSON);
- if (f != null && f.getValue() != null) {
- num=f.getIntegerValue();
- }
- }
- }
- return num;
- }
- @Override
- public Detail executeReverse(Detail pDetail) throws Exception {
- return pDetail;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement