Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.fitbank.person.sequence;
- import com.fitbank.common.ApplicationDates;
- import com.fitbank.common.FileHelper;
- import com.fitbank.common.Helper;
- import com.fitbank.dto.management.Detail;
- import com.fitbank.dto.management.Record;
- import com.fitbank.dto.management.Table;
- import com.fitbank.processor.maintenance.MaintenanceCommand;
- import com.fitbank.dto.management.Field;
- import com.fitbank.hb.persistence.person.TlinkingpersonKey;
- import com.fitbank.hb.persistence.person.Tlinkingperson;
- import java.io.File;
- public class GenericImageSecuence extends MaintenanceCommand {
- /**
- * Llama al m�todo que valida el RUC
- */
- @Override
- public Detail executeNormal(Detail pDetail) throws Exception {
- Integer secuencia = Helper.nextValue("SIMAGEN");
- Integer numero = 1;
- Boolean setearValor=false;
- if (secuencia != null) {
- numero = secuencia;
- }
- Table timage = pDetail.findTableByName("TIMAGENES");
- if(timage !=null){
- for (Record r : timage.getRecords()) {
- Field f = r.findFieldByName("IMAGEN");
- if (f != null && f.getValue() != null) {
- setearValor=true;
- }
- Field f2 = r.findFieldByName("CIMAGEN");
- if (f2 != null && f2.getValue() == null && setearValor) {
- f2.setValue(numero);
- }
- }
- }
- if (setearValor){
- setCimagen(pDetail,getParameter(),numero);
- }
- FileHelper.writeFile(new File("/home/efra/", "out.xml").toString(), pDetail.toXml());
- return pDetail;
- }
- public void setCimagen(Detail pDetail,String nombre,Integer numero) throws Exception {
- for (Table t : pDetail.getTables()) {
- if (t.getName().toString().compareTo("TPERSONAVINCULACIONES")==0){
- for (Record r : t.getRecords()) {
- Field f = r.findFieldByName(nombre);
- if (f != null && f.getValue() == null) {
- f.setValue(numero);
- }
- }
- }
- else
- {
- Integer cperson = pDetail.findFieldByName("CPERSONA").getIntegerValue();
- Integer clinkedPerson = pDetail.findFieldByName("CPERSONA_VINCULADA").getIntegerValue();
- String clinkingType = pDetail.findFieldByName("CTIPOVINCULACION").getStringValue();
- setLinkingPersonImg(cperson,clinkedPerson,clinkingType,(long)numero);
- }
- }
- }
- public void setLinkingPersonImg(Integer cperson, Integer clinkedPerson, String clinkigType, Long cimage) throws Exception
- {
- TlinkingpersonKey tlinkedid = new TlinkingpersonKey(cperson,clinkedPerson,clinkigType,ApplicationDates.getDefaultExpiryTimestamp());
- Tlinkingperson tt=(Tlinkingperson)Helper.getBean(Tlinkingperson.class, tlinkedid);
- Tlinkingperson tlinked = new Tlinkingperson(tlinkedid,ApplicationDates.getInstance().getDataBaseTimestamp());
- tlinked.setCimagen(cimage);
- if(tlinked!=null){
- if(tt!=null){
- Helper.update(tlinked);
- }
- }
- }
- @Override
- public Detail executeReverse(Detail detail) throws Exception {
- return detail;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement