Package sos.hostware

Examples of sos.hostware.Record


          this.getLogger().debug1("not found file position for \"" + localFilename + "\" in database : position will be skipped");
        }
      }
      int i = 0;
      while (!hwFile.eof()) {
        Record lineRecord = hwFile.get();
        _recordFoundCount++;
        if (position >= _recordFoundCount) {
          _recordSkippedCount++;
          continue;
        }
        recordParameters = new LinkedHashMap();
        recordExtraParameters = new LinkedHashMap();
        for (int j = 0; j < lineRecord.field_count(); j++) {
          String val = lineRecord.string(lineRecord.field_name(j)) == null ? "" : lineRecord.string(lineRecord.field_name(j));
          if (_mappings.containsValue(lineRecord.field_name(j))) {
            recordParameters.put(lineRecord.field_name(j), val);
          }
          else {
            recordExtraParameters.put(lineRecord.field_name(j).toUpperCase(), val);
          }
        }
        recordExtraParameters = checkRecordExtraParameters(recordExtraParameters);
        try {
          if (importLine(recordParameters, recordExtraParameters, false)) {
View Full Code Here


                }
            }
           
            while (!inFile.eof())
            {
                Record record = inFile.get();
                String line = "";
                recordCount++;
                fieldCount = 0;

                if (outputFieldNamesWrite) {
                    if (outputFields.isEmpty()) {
                        for(int i=0; i<record.field_count(); i++) {
                            if (i>0) line += this.getOutputFieldSeparator();
                            line += record.field_name(i);
                        }
                    } else {
                        Iterator it = outputFields.iterateKeys();
                        int itCount = 0;
                        while(it.hasNext()) {
                            if (itCount>0) line += this.getOutputFieldSeparator();
                            line += (String) it.next();
                            itCount++;
                        }
                    }
                    outFile.put_line(line);
                    line = "";
                    outputFieldNamesWrite = false;
                }

                // should no output fields have been found, then use them from the first ecord
                if (outputFields.isEmpty() && recordCount == 1) {
                    for(int i=0; i<record.field_count(); i++) {
                        outputFields.put(record.field_name(i).toLowerCase(), "string");  
                    }
                }
               
                try {
                    int outputFieldCount = 0;
                    Iterator it = outputFields.iterateKeys();
                    while(it.hasNext()) {
                        fieldName = (String) it.next();
                        fieldCount++;

                        if (record.string(fieldName) != null && record.string(fieldName).length() > 0) {
                            String fieldType = (String) outputFields.get(fieldName.toLowerCase());
                            if (fieldType != null && fieldType.toLowerCase().equals("string")) {
                                if (this.getOutputFieldDelimiterQuote().length() > 0) {
                                    if (outputFieldCount>0) line += this.getOutputFieldSeparator();
                                    line += this.getOutputFieldDelimiter() + record.string(fieldName).replaceAll("\\" + this.getOutputFieldDelimiter(), this.getOutputFieldDelimiterQuote() + this.getOutputFieldDelimiter()) + this.getOutputFieldDelimiter();
                                    outputFieldCount++;
                                } else {
                                    if (outputFieldCount>0) line += this.getOutputFieldSeparator();
                                    line += this.getOutputFieldDelimiter() + record.string(fieldName) + this.getOutputFieldDelimiter();
                                    outputFieldCount++;
                                }
                            } else if (fieldType != null && fieldType.toLowerCase().indexOf("date") > -1) {
                                try {
                                    if (outputFieldCount>0) line += this.getOutputFieldSeparator();
                                    // line += this.getOutputFieldDelimiter() + SOSDate.getDateAsString(SOSDate.getDate(record.string(fieldName), SOSDate.dateTimeFormat), this.getOutputDateFormat()) + this.getOutputFieldDelimiter();
                                    line += this.getOutputFieldDelimiter() + SOSDate.getDateAsString(SOSDate.getDate(record.string(fieldName), this.getInputDateFormat()), this.getOutputDateFormat()) + this.getOutputFieldDelimiter();
                                    outputFieldCount++;
                                } catch (Exception e) {
                                    throw new Exception("could not convert date using output date format [" + this.getOutputDateFormat() + "]: " + record.string(fieldName));
                                }
                            } else if (fieldType == null || fieldType.length() == 0) {
                                // skip record
                            } else {
                                throw new Exception("unsupported field type specified for field [" + fieldName + "]: " + fieldType);
View Full Code Here

                schedulerCommand.setTimeout(this.getEventSupervisorSchedulerTimeout());
                schedulerCommand.connect();
               
                while (!hwFile.eof())
                {
                    Record record = hwFile.get();
                    spooler_log.info("--->" + record);
                    if (record.field_count() < 10) throw new Exception("number of fields in event file [" + eventFile.getCanonicalPath() + "] is too small: " + record.field_count());
                    eventCount++;
                    spooler_log.info("... will be processed");
                    spooler_log.info(record.string(0) + " event");
                   
                    String command = "<add_order title=\"dequeued event\" job_chain=\"" + this.getEventSupervisorSchedulerJobChainName() + "\">";
                    command += "<params>";

                    command += "<param name=\"action\"          value=\"" + getValue(record.string(0)) + "\"/>";
                    command += "<param name=\"scheduler_host\"  value=\"" + getValue(record.string(1)) + "\"/>";
                    command += "<param name=\"scheduler_port\"  value=\"" + getValue(record.string(2)) + "\"/>";
                    command += "<param name=\"job_chain\"       value=\"" + getValue(record.string(3)) + "\"/>";
                    command += "<param name=\"order_id\"        value=\"" + getValue(record.string(4)) + "\"/>";
                    command += "<param name=\"job_name\"        value=\"" + getValue(record.string(5)) + "\"/>";
                    command += "<param name=\"event_class\"     value=\"" + getValue(record.string(6)) + "\"/>";
                    command += "<param name=\"event_id\"        value=\"" + getValue(record.string(7)) + "\"/>";
                    command += "<param name=\"exit_code\"       value=\"" + getValue(record.string(8)) + "\"/>";
                    command += "<param name=\"created\"         value=\"" + getValue(record.string(9)) + "\"/>";

                    int expiration_column = 1;
                    if (record.field_count() > eventMinFieldCount) {
                        spooler_log.info("--->" + record.string(10) + " " + record.string(10).indexOf(""));
                        if (record.string(10).indexOf("=") == -1) {// Kompatibilit�tsabfrage
                           if (record.string(10) != null && record.string(10).length() > 0)
                              command += "<param name=\"expires\"        value=\"" + record.string(10) + "\"/>";
                              expiration_column = 0;
                        }
                    }
                  
                    for(int i=eventMaxFieldCount-expiration_column; i<record.field_count(); i++) {
                        int posFound = record.string(i).indexOf("=");
                        if (posFound != -1) {
                            command += "<param name=\"" + record.string(i).substring(0, posFound) + "\"        value=\"" + record.string(i).substring(posFound+1) + "\"/>";
                        }
                    }

                    command += "</params></add_order>";
                    this.getLogger().info(".. sending command to remote Job Scheduler [" + this.getEventSupervisorSchedulerHost() + ":" + this.getEventSupervisorSchedulerPort() + "]: " + command );
View Full Code Here

TOP

Related Classes of sos.hostware.Record

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.