/** * Return the dump-ready data * * @return The dump strings */ @Override public ArrayList<String> getDumpInfo() { int tmpErrorCount; int i; RecordError tmpError; ArrayList<String> tmpDumpList; tmpDumpList = new ArrayList<>(); // Get the error count tmpErrorCount = this.getErrors().size(); tmpDumpList.add("============ DETAIL RECORD ============"); tmpDumpList.add(" Record Number = <" + this.RecordNumber + ">"); tmpDumpList.add(" custId = <" + getCustId() + ">"); tmpDumpList.add(" serviceId = <" + getServiceId() + ">"); tmpDumpList.add(" phone number = <" + getNumber() + ">"); tmpDumpList.add(" price plan = <" + getPricePlan() + ">"); tmpDumpList.add(" valid from = <" + getValidFrom() + ">"); tmpDumpList.add(" valid to = <" + getValidTo() + ">"); tmpDumpList.add(" valid from UTC = <" + getValidFromUTC() + ">"); tmpDumpList.add(" valid to UTC = <" + getValidToUTC() + ">"); tmpDumpList.add(" segment from = <" + getSegmentValidFrom() + ">"); tmpDumpList.add(" segment to = <" + getSegmentValidTo() + ">"); tmpDumpList.add(" segment from UTC= <" + getSegmentValidFromUTC() + ">"); tmpDumpList.add(" segment to UTC = <" + getSegmentValidToUTC() + ">"); tmpDumpList.add(" Errors = <" + this.getErrors().size() + ">"); if (tmpErrorCount > 0) { tmpDumpList.add("-------------- ERRORS ----------------"); for (i = 0; i < this.getErrors().size(); i++) { tmpError = (RecordError) this.getErrors().get(i); tmpDumpList.add( " Error = <" + tmpError.getMessage() + "> (" + tmpError.getModuleName() + ")"); } } return tmpDumpList; }
public boolean performFieldValidation(String moduleName) { if (fields.length != INPUT_FIELD_COUNT) { RecordError tmpError = new RecordError("ERR_INVALID_FIELD_NUMBER", ErrorType.DATA_VALIDATION); tmpError.setModuleName("Balance mapping"); tmpError.setErrorDescription("Invalid Number of Fields"); addError(tmpError); return false; } if (fields[IDX_USER] == null || fields[IDX_USER].length() == 0) { RecordError tmpError = new RecordError("ERR_MISSING_USER", ErrorType.DATA_VALIDATION); tmpError.setModuleName("Balance mapping"); tmpError.setErrorDescription("Missing user"); addError(tmpError); return false; } if (fields[IDX_DATE] == null || fields[IDX_DATE].length() == 0) { RecordError tmpError = new RecordError("ERR_MISSING_DATE", ErrorType.DATA_VALIDATION); tmpError.setModuleName("Balance mapping"); tmpError.setErrorDescription("Missing date"); addError(tmpError); return false; } if (fields[IDX_AGG_ID] == null || fields[IDX_AGG_ID].length() == 0) { RecordError tmpError = new RecordError("ERR_MISSING_AGG_ID", ErrorType.DATA_VALIDATION); tmpError.setModuleName("Balance mapping"); tmpError.setErrorDescription("Missing aggregatition ID"); addError(tmpError); return false; } if (fields[IDX_FIN_CD] == null || fields[IDX_FIN_CD].length() == 0) { RecordError tmpError = new RecordError("ERR_FIN_CD_MISSING", ErrorType.DATA_VALIDATION); tmpError.setModuleName("Balance mapping"); tmpError.setErrorDescription("Missing financial code"); addError(tmpError); return false; } if (fields[IDX_ALIAS_STAT] == null || fields[IDX_ALIAS_STAT].length() == 0) { RecordError tmpError = new RecordError("ERR_ALIAS_STAT_MISSING", ErrorType.DATA_VALIDATION); tmpError.setModuleName("Balance mapping"); tmpError.setErrorDescription("Missing ALIAS STATUS"); addError(tmpError); return false; } if (fields[IDX_NETWORK] == null || fields[IDX_NETWORK].length() == 0) { RecordError tmpError = new RecordError("ERR_NETWORK_MISSING", ErrorType.DATA_VALIDATION); tmpError.setModuleName("Balance mapping"); tmpError.setErrorDescription("Missing NETWORK"); addError(tmpError); return false; } if (fields[IDX_DURATION] == null || fields[IDX_DURATION].length() == 0) { RecordError tmpError = new RecordError("ERR_DURATION_MISSING", ErrorType.DATA_VALIDATION); tmpError.setModuleName("Balance mapping"); tmpError.setErrorDescription("Duration Information Missing"); addError(tmpError); return false; } if (fields[IDX_COUNT] == null || fields[IDX_COUNT].length() == 0) { RecordError tmpError = new RecordError("ERR_COUNT_MISSING", ErrorType.DATA_VALIDATION); tmpError.setModuleName("Balance mapping"); tmpError.setErrorDescription("Count Information Missing"); addError(tmpError); return false; } Double retail = Double.parseDouble(fields[IDX_RETAIL]); Double wholesale = Double.parseDouble(fields[IDX_WHOLESALE]); Double rp = Double.parseDouble(fields[IDX_REMOTEPOLO]); Double rr = Double.parseDouble(fields[IDX_REMOTEROLO]); Double lp = Double.parseDouble(fields[IDX_LOCALPOLO]); Double lr = Double.parseDouble(fields[IDX_LOCALROLO]); Double lt = Double.parseDouble(fields[IDX_LOCALTRANSIT]); Double rt = Double.parseDouble(fields[IDX_REMOTETRANSIT]); try { this.User = fields[IDX_USER]; this.Date = fields[IDX_DATE]; this.AggID = fields[IDX_AGG_ID]; this.Financial_Code = fields[IDX_FIN_CD]; this.AliasStat = fields[IDX_ALIAS_STAT]; this.Network = fields[IDX_NETWORK]; this.Duration = Double.parseDouble(fields[IDX_DURATION]); this.Count = Integer.valueOf(fields[IDX_COUNT]); this.RetailCost = retail.doubleValue(); this.WholeSaleCost = wholesale.doubleValue(); this.RemotePolo = rp.doubleValue(); this.RemoteRolo = rr.doubleValue(); this.LocalPolo = lp.doubleValue(); this.LocalRolo = lr.doubleValue(); this.LocalTransit = lt.doubleValue(); this.RemoteTransit = rt.doubleValue(); } catch (NumberFormatException e) { RecordError tmpError = new RecordError("ERR_INVALID_CAST", ErrorType.DATA_VALIDATION); tmpError.setModuleName("Balance mapping"); tmpError.setErrorDescription("Balance invalid"); addError(tmpError); return false; } return true; }