List of usage examples for org.apache.commons.beanutils.converters ArrayConverter setAllowedChars
public void setAllowedChars(char[] allowedChars)
From source file:com.feilong.core.bean.ConvertUtilTemp.java
/** * Convert./*from www .ja v a 2 s . c o m*/ * * @param <T> * the generic type * @param toBeConvertedValue * ?? * @param defaultArrayType * * @param individualArrayElementConverter * ? {@link Converter} * @return the t * @deprecated will Re-structure */ @Deprecated public static <T> T convert(Object toBeConvertedValue, Class<T> defaultArrayType, Converter individualArrayElementConverter) { char[] allowedChars = new char[] { ',', '-' }; char delimiter = ','; boolean onlyFirstToString = false; int defaultSize = 0; //********************************************************** ArrayConverter arrayConverter = new ArrayConverter(defaultArrayType, individualArrayElementConverter, defaultSize); arrayConverter.setAllowedChars(allowedChars); arrayConverter.setDelimiter(delimiter); arrayConverter.setOnlyFirstToString(onlyFirstToString); return arrayConverter.convert(defaultArrayType, toBeConvertedValue); }
From source file:com.commander4j.email.JeMailOutGoingMessage.java
public JeMailOutGoingMessage(JDBInterface inter, Long transactionRef, JFileIO fio) { interx = inter;/*from ww w . ja v a 2s. c om*/ txnRef = transactionRef; emailaddresses = inter.getEmailAddresses(); mail = new JeMail(inter.getHostID(), inter.getSessionID()); xfio = fio; StringConverter stringConverter = new StringConverter(); ArrayConverter arrayConverter = new ArrayConverter(String[].class, stringConverter); arrayConverter.setDelimiter(';'); arrayConverter.setAllowedChars(new char[] { '@' }); emailList = (String[]) arrayConverter.convert(String[].class, emailaddresses); }
From source file:com.commander4j.email.JeMailOutGoingMessageManual.java
public JeMailOutGoingMessageManual(String host, String session, String[] addresses, String subj, String msg, String shortname, String longname) { this.emailList = addresses; mail = new JeMail(host, session); this.subject = subj; this.message = msg; this.shortFilename = shortname; this.longFilename = longname; StringConverter stringConverter = new StringConverter(); ArrayConverter arrayConverter = new ArrayConverter(String[].class, stringConverter); arrayConverter.setDelimiter(';'); arrayConverter.setAllowedChars(new char[] { '@' }); emailList = (String[]) arrayConverter.convert(String[].class, emailaddresses); }
From source file:com.feilong.core.bean.ConvertUtilTemp.java
/** * Convert./*www .j av a 2 s . c o m*/ * * @param <T> * the generic type * @param defaultArrayType * * @param individualArrayElementConverter * ? {@link Converter} * @param toBeConvertedValue * ?? * @return the t * @since 1.2.2 */ private <T> T convert(Class<T> defaultArrayType, Converter individualArrayElementConverter, Object toBeConvertedValue) { char[] allowedChars = new char[] { ',', '-' }; char delimiter = ';'; boolean onlyFirstToString = true; int defaultSize = 0; //********************************************************** ArrayConverter arrayConverter = new ArrayConverter(defaultArrayType, individualArrayElementConverter, defaultSize); arrayConverter.setAllowedChars(allowedChars); arrayConverter.setDelimiter(delimiter); arrayConverter.setOnlyFirstToString(onlyFirstToString); T result = arrayConverter.convert(defaultArrayType, toBeConvertedValue); return result; }
From source file:com.feilong.core.util.ResourceBundleUtilTest.java
/** * Test read properties to alias bean1.//from www. j a v a 2 s.co m */ @Test public void testReadToAliasBean1() { ArrayConverter arrayConverter = new ArrayConverter(String[].class, new StringConverter(), 2); char[] allowedChars = { ':' }; arrayConverter.setAllowedChars(allowedChars); BeanUtil.register(arrayConverter, String[].class); DangaMemCachedConfig dangaMemCachedConfig = ResourceBundleUtil.readToAliasBean("messages.memcached", DangaMemCachedConfig.class); LOGGER.debug(JsonUtil.format(dangaMemCachedConfig)); }
From source file:com.commander4j.thread.OutboundMessageThread.java
public void run() { logger.debug("OutboundMessageThread running"); setSessionID(JUnique.getUniqueID()); JDBUser user = new JDBUser(getHostID(), getSessionID()); user.setUserId("interface"); user.setPassword("interface"); user.setLoginPassword("interface"); Common.userList.addUser(getSessionID(), user); Common.sd.setData(getSessionID(), "silentExceptions", "Yes", true); Boolean dbconnected = false;/* w w w. j a v a 2 s . com*/ if (Common.hostList.getHost(hostID).isConnected(sessionID) == false) { dbconnected = Common.hostList.getHost(hostID).connect(sessionID, hostID); } else { dbconnected = true; } if (dbconnected) { JeMail mail = new JeMail(getHostID(), getSessionID()); JDBInterfaceRequest ir = new JDBInterfaceRequest(getHostID(), getSessionID()); JDBInterface inter = new JDBInterface(getHostID(), getSessionID()); OutgoingProductionDeclarationConfirmation opdc = new OutgoingProductionDeclarationConfirmation( getHostID(), getSessionID()); OutgoingDespatchConfirmation odc = new OutgoingDespatchConfirmation(getHostID(), getSessionID()); OutgoingDespatchPreAdvice opa = new OutgoingDespatchPreAdvice(getHostID(), getSessionID()); OutgoingDespatchEmail ode = new OutgoingDespatchEmail(getHostID(), getSessionID()); OutgoingEquipmentTracking oet = new OutgoingEquipmentTracking(getHostID(), getSessionID()); OutgoingPalletStatusChange psc = new OutgoingPalletStatusChange(getHostID(), getSessionID()); OutgoingPalletSplit ops = new OutgoingPalletSplit(getHostID(), getSessionID()); OutgoingPalletDelete opd = new OutgoingPalletDelete(getHostID(), getSessionID()); LinkedList<Long> irqList = new LinkedList<Long>(); int noOfMessages = 0; while (true) { JWait.milliSec(500); if (allDone) { if (dbconnected) { Common.hostList.getHost(hostID).disconnect(getSessionID()); } return; } irqList.clear(); irqList = ir.getInterfaceRequestIDs(); noOfMessages = irqList.size(); if (noOfMessages > 0) { for (int x = 0; x < noOfMessages; x++) { JWait.milliSec(100); ir.setInterfaceRequestID(irqList.get(x)); ir.getInterfaceRequestProperties(); if (ir.getMode().equals("Inbound File Re-Submit")) { if (inter.getInterfaceProperties(ir.getInterfaceType(), "Input") == true) { String sourceFile = Common.base_dir + java.io.File.separator + "xml" + java.io.File.separator + "interface" + java.io.File.separator + "error" + java.io.File.separator + ir.getInterfaceType() + java.io.File.separator + ir.getFilename(); destinationFile = inter.getRealPath() + java.io.File.separator + ir.getFilename(); renamedDestinationFile = inter.getRealPath() + java.io.File.separator + ir.getFilename().replaceAll(".xml", ".lmx"); mover.move_File(sourceFile, renamedDestinationFile); mover.move_File(renamedDestinationFile, destinationFile); ir.delete(); } } if (ir.getMode().equals("Normal")) { errorMessage = "Unknown Outbound Interface Type :" + ir.getInterfaceType(); messageProcessedOK = false; if (ir.getInterfaceType().equals("Production Declaration")) { messageProcessedOK = opdc.processMessage(ir.getTransactionRef()); errorMessage = opdc.getErrorMessage(); GenericMessageHeader.updateStats("Output", "Production Declaration", messageProcessedOK.toString()); } if (ir.getInterfaceType().equals("Pallet Status Change")) { messageProcessedOK = psc.processMessage(ir.getTransactionRef()); errorMessage = psc.getErrorMessage(); GenericMessageHeader.updateStats("Output", "Pallet Status Change", messageProcessedOK.toString()); } if (ir.getInterfaceType().equals("Pallet Split")) { messageProcessedOK = ops.processMessage(ir.getTransactionRef()); errorMessage = ops.getErrorMessage(); GenericMessageHeader.updateStats("Output", "Pallet Split", messageProcessedOK.toString()); } if (ir.getInterfaceType().equals("Pallet Delete")) { messageProcessedOK = opd.processMessage(ir.getTransactionRef()); errorMessage = opd.getErrorMessage(); GenericMessageHeader.updateStats("Output", "Pallet Delete", messageProcessedOK.toString()); } if (ir.getInterfaceType().equals("Despatch Confirmation")) { messageProcessedOK = odc.processMessage(ir.getTransactionRef()); errorMessage = odc.getErrorMessage(); GenericMessageHeader.updateStats("Output", "Despatch Confirmation", messageProcessedOK.toString()); } if (ir.getInterfaceType().equals("Despatch Pre Advice")) { messageProcessedOK = opa.processMessage(ir.getTransactionRef()); errorMessage = opa.getErrorMessage(); GenericMessageHeader.updateStats("Output", "Despatch Pre Advice", messageProcessedOK.toString()); } if (ir.getInterfaceType().equals("Despatch Email")) { messageProcessedOK = ode.processMessage(ir.getTransactionRef()); errorMessage = ode.getErrorMessage(); GenericMessageHeader.updateStats("Output", "Despatch Email", messageProcessedOK.toString()); } if (ir.getInterfaceType().equals("Equipment Tracking")) { messageProcessedOK = oet.processMessage(ir.getTransactionRef()); errorMessage = oet.getErrorMessage(); GenericMessageHeader.updateStats("Output", "Equipment Tracking", messageProcessedOK.toString()); } if (messageProcessedOK == true) { ir.delete(); } else { ir.update(irqList.get(x), "Error"); if (inter.getInterfaceProperties(ir.getInterfaceType(), "Output") == true) { if (inter.getEmailError() == true) { String emailaddresses = inter.getEmailAddresses(); StringConverter stringConverter = new StringConverter(); ArrayConverter arrayConverter = new ArrayConverter(String[].class, stringConverter); arrayConverter.setDelimiter(';'); arrayConverter.setAllowedChars(new char[] { '@' }); String[] emailList = (String[]) arrayConverter.convert(String[].class, emailaddresses); if (emailList.length > 0) { try { String siteName = Common.hostList.getHost(getHostID()) .getSiteDescription(); mail.postMail(emailList, "Error Processing Outgoing " + ir.getInterfaceType() + " for [" + siteName + "] on " + JUtility.getClientName(), errorMessage, "", ""); } catch (MessagingException e) { } } } } } } } } } } }
From source file:com.commander4j.thread.InterfaceThread.java
public void startupInterface() { setSessionID(JUnique.getUniqueID()); Common.sessionID = getSessionID();/*w w w .j a v a 2s . c o m*/ Common.sd.setData(getSessionID(), "silentExceptions", "Yes", true); Common.applicationMode = "SwingClient"; JUtility.initLogging(""); JPrint.init(); if (JUtility.isValidJavaVersion(Common.requiredJavaVersion) == true) { Common.hostList.loadHosts(); Common.selectedHostID = getHostID(); houseKeeping = false; while (shutdown == false) { logger.debug("Connecting to database."); while ((Common.hostList.getHost(getHostID()).isConnected(getSessionID()) == false) && (shutdown == false)) { Common.hostList.getHost(getHostID()).connect(getSessionID(), getHostID()); } if ((Common.hostList.getHost(getHostID()).isConnected(getSessionID()) == true) && (shutdown == false)) { JDBSchema schema = new JDBSchema(getSessionID(), Common.hostList.getHost(getHostID())); schema.validate(false); JUtility.initEANBarcode(); JLaunchReport.init(); Common.init(); JDBUser user = new JDBUser(getHostID(), getSessionID()); JDBControl ctrl = new JDBControl(getHostID(), getSessionID()); JeMail mail = new JeMail(getHostID(), getSessionID()); user.setUserId("interface"); user.setPassword("interface"); user.setLoginPassword("interface"); Common.userList.addUser(getSessionID(), user); enableEnterfaceStatusEmails = Boolean .parseBoolean(ctrl.getKeyValueWithDefault("INTERFACE EMAIL NOTIFY", "false", "Email startup and shutdown events :- true or false")); interfaceEmailAddresses = ctrl.getKeyValueWithDefault("INTERFACE ADMIN EMAIL", "someone@somewhere.com", "Email address for startup and shutdown events."); StringConverter stringConverter = new StringConverter(); ArrayConverter arrayConverter = new ArrayConverter(String[].class, stringConverter); arrayConverter.setDelimiter(';'); arrayConverter.setAllowedChars(new char[] { '@', '_' }); String[] emailList = (String[]) arrayConverter.convert(String[].class, interfaceEmailAddresses); siteName = Common.hostList.getHost(getHostID()).getSiteDescription(); if (user.login()) { if (enableEnterfaceStatusEmails == true) { try { String subject = ""; if (houseKeeping == true) { } else { subject = "Commander4j " + JVersion.getProgramVersion() + " Interface startup for [" + siteName + "] on " + JUtility.getClientName(); mail.postMail(emailList, subject, "Interface service has started.", "", ""); } } catch (Exception ex) { logger.error("InterfaceThread Unable to send emails"); } } houseKeeping = false; logger.debug("Interface Logged on successfully"); logger.debug("Starting Threads...."); startupThreads(); while ((shutdown == false) & (houseKeeping == false)) { com.commander4j.util.JWait.milliSec(1000); currentDateTime = JUtility.getDateTimeString("yyyy-MM-dd HH:mm:ss"); currentDate = currentDateTime.substring(0, 10); currentTime = currentDateTime.substring(11, 19); if (currentTime.substring(0, 5).equals(Common.statusReportTime.substring(0, 5))) { if (currentDate.equals(lastRunDate) == false) { lastRunDate = currentDate; houseKeeping = true; } } } logger.debug("Stopping Threads...."); shutdownThreads(); user.logout(); logger.debug("Interface Logged out successfully"); if (enableEnterfaceStatusEmails == true) { try { String subject = ""; if (houseKeeping == true) { } else { subject = "Commander4j " + JVersion.getProgramVersion() + " Interface shutdown for [" + siteName + "] on " + JUtility.getClientName(); mail.postMail(emailList, subject, "Interface service has stopped.", "", ""); } } catch (Exception ex) { logger.error("InterfaceThread Unable to send emails"); } } } else { logger.debug("Interface routine failed to logon to application using account INTERFACE"); } try { backupMessageRetention = Integer.valueOf(ctrl.getKeyValueWithDefault( "INTERFACE BACKUP RETENTION", "30", "NUMBER OF DAYS TO KEEP BACKUP MESSAGES")); } catch (Exception ex) { backupMessageRetention = 30; } String archiveReportString = ""; if (shutdown == false) { logger.debug("Initiating data archiving...."); JDBArchive c = new JDBArchive(getHostID(), getSessionID()); c.runSQLJobList(); archiveReportString = c.reportData(); c = null; logger.debug("Data archiving complete...."); logger.debug("Disconnecting from database."); Common.hostList.getHost(getHostID()).disconnectAll(); } if (houseKeeping == true) { logger.debug("HOUSEKEEPING START"); // Archive old backup files goes here String archivedFiles = "Backup message files removed by auto archive = "; if (backupMessageRetention > 0) { archivedFiles = archivedFiles + String.valueOf(JArchive.archiveBackupFiles( System.getProperty("user.dir") + File.separator + Common.interface_backup_path, backupMessageRetention)); } else { archivedFiles = "Auto archive of messages disabled"; } String freeSpace = JUtility.diskFree(); String memoryBefore = "Memory used before garbage collection = " + String.valueOf( (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024) + "k"; System.gc(); String memoryAfter = "Memory used after garbage collection = " + String.valueOf( (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024) + "k"; String stats = GenericMessageHeader.getStats(); GenericMessageHeader.clearStats(); if (enableEnterfaceStatusEmails == true) { try { mail.postMail(emailList, "Commander4j " + JVersion.getProgramVersion() + " Interface maintenance for [" + siteName + "] on " + JUtility.getClientName(), memoryBefore + "\n\n" + memoryAfter + "\n\n" + archivedFiles + "\n\n" + freeSpace + "\n\n" + "Maintenance is scheduled to occur at " + Common.statusReportTime + " each day.\n\n\n\n" + stats + "\n\n\n" + archiveReportString, "", ""); } catch (Exception ex) { logger.error("InterfaceThread Unable to send emails"); } } logger.debug("Interface Garbage Collection."); logger.debug("HOUSEKEEPING END"); } } } } }
From source file:com.commander4j.thread.InboundMessageThread.java
public void run() { logger.debug("InboundMessageThread running"); Boolean dbconnected = false;/*from ww w . j a va 2s . c om*/ if (Common.hostList.getHost(hostID).isConnected(sessionID) == false) { dbconnected = Common.hostList.getHost(hostID).connect(sessionID, hostID); } else { dbconnected = true; } if (dbconnected) { JDBInterfaceLog il = new JDBInterfaceLog(getHostID(), getSessionID()); JeMail mail = new JeMail(getHostID(), getSessionID()); JDBInterface inter = new JDBInterface(getHostID(), getSessionID()); IncommingMaterialDefinition imd = new IncommingMaterialDefinition(getHostID(), getSessionID()); IncommingProcessOrderStatusChange iposc = new IncommingProcessOrderStatusChange(getHostID(), getSessionID()); IncommingProductionDeclarationConfirmation ipd = new IncommingProductionDeclarationConfirmation( getHostID(), getSessionID()); IncommingProcessOrder ipo = new IncommingProcessOrder(getHostID(), getSessionID()); IncommingLocation ilocn = new IncommingLocation(getHostID(), getSessionID()); IncommingPalletStatusChange ipsc = new IncommingPalletStatusChange(getHostID(), getSessionID()); IncommingPalletMove ipmv = new IncommingPalletMove(getHostID(), getSessionID()); IncommingBatchStatusChange bsc = new IncommingBatchStatusChange(getHostID(), getSessionID()); IncommingJourney ij = new IncommingJourney(getHostID(), getSessionID()); IncommingInspectionResult iirslt = new IncommingInspectionResult(getHostID(), getSessionID()); IncommingDespatchConfirmation idc = new IncommingDespatchConfirmation(getHostID(), getSessionID()); IncommingQMInspectionRequest iireq = new IncommingQMInspectionRequest(getHostID(), getSessionID()); IncommingMaterialAutoMove imam = new IncommingMaterialAutoMove(getHostID(), getSessionID()); GenericMessageHeader gmh = new GenericMessageHeader(); LinkedList<String> filenames = new LinkedList<String>(); BasicFileAttributes attrs; while (true) { com.commander4j.util.JWait.milliSec(100); if (allDone) { if (dbconnected) { Common.hostList.getHost(hostID).disconnect(getSessionID()); } return; } if (InboundMessageCollectionThread.recoveringFiles == false) { dir = new File(inputPath); chld = dir.listFiles((FileFilter) FileFileFilter.FILE); if (chld == null) { allDone = true; } else { Arrays.sort(chld, LastModifiedFileComparator.LASTMODIFIED_COMPARATOR); filenames.clear(); for (int i = 0; (i < chld.length) & (i < maxfiles); i++) { fileName = chld[i].getName(); try { attrs = Files.readAttributes(chld[i].getAbsoluteFile().toPath(), BasicFileAttributes.class); if (attrs.size() > 0) { if (fileName.endsWith(".xml")) { filenames.addFirst(fileName); com.commander4j.util.JWait.milliSec(50); } } else { try { chld[i].delete(); } catch (Exception ex) { } } } catch (IOException e) { } } if (filenames.size() > 0) { logger.debug("Begin processing " + String.valueOf(filenames.size()) + " files."); for (int i = filenames.size() - 1; i >= 0; i--) { if (allDone) { if (dbconnected) { Common.hostList.getHost(hostID).disconnect(getSessionID()); } return; } fromFile = filenames.get(i); try { logger.debug("<--- START OF PROCESSING " + fromFile + " ---->"); logger.debug("Reading message header : " + inputPath + fromFile); if (gmh.readAddressInfo(inputPath + fromFile, getSessionID()) == true) { messageProcessedOK = true; errorMessage = ""; if (gmh.getInterfaceType().length() == 0) { messageProcessedOK = false; errorMessage = "Unrecognised Commander4j XML message format in file " + fromFile; logger.debug(errorMessage); String datetime = ""; datetime = JUtility .getISOTimeStampStringFormat(JUtility.getSQLDateTime()); gmh.setMessageDate(datetime); gmh.setInterfaceDirection("Unknown"); gmh.setMessageInformation(fromFile); gmh.setInterfaceType("Unknown"); gmh.setMessageRef("Unknown"); } else { if (gmh.getInterfaceDirection().equals("Input") == false) { messageProcessedOK = false; errorMessage = "Inbound message ignored - Interface Direction = " + gmh.getInterfaceDirection(); } else { String interfaceType = gmh.getInterfaceType(); logger.debug("Processing " + interfaceType + " started."); if (interfaceType.equals("Despatch Confirmation") == true) { messageProcessedOK = idc.processMessage(gmh); errorMessage = idc.getErrorMessage(); } if (interfaceType.equals("Material Definition") == true) { messageProcessedOK = imd.processMessage(gmh); errorMessage = imd.getErrorMessage(); } if (interfaceType.equals("Process Order") == true) { messageProcessedOK = ipo.processMessage(gmh); errorMessage = ipo.getErrorMessage(); } if (interfaceType.equals("Location") == true) { messageProcessedOK = ilocn.processMessage(gmh); errorMessage = ilocn.getErrorMessage(); } if (interfaceType.equals("Pallet Status Change") == true) { messageProcessedOK = ipsc.processMessage(gmh); errorMessage = ipsc.getErrorMessage(); } if (interfaceType.equals("Pallet Move") == true) { messageProcessedOK = ipmv.processMessage(gmh); errorMessage = ipmv.getErrorMessage(); } if (interfaceType.equals("Batch Status Change") == true) { messageProcessedOK = bsc.processMessage(gmh); errorMessage = bsc.getErrorMessage(); } if (interfaceType.equals("Journey Definition") == true) { messageProcessedOK = ij.processMessage(gmh); errorMessage = ij.getErrorMessage(); } if (interfaceType.equals("Process Order Status Change") == true) { messageProcessedOK = iposc.processMessage(gmh); errorMessage = iposc.getErrorMessage(); } if (interfaceType.equals("Production Declaration") == true) { messageProcessedOK = ipd.processMessage(gmh); errorMessage = ipd.getErrorMessage(); } if (interfaceType.equals("QM Inspection Request") == true) { messageProcessedOK = iireq.processMessage(gmh); errorMessage = iireq.getErrorMessage(); } if (interfaceType.equals("QM Inspection Result") == true) { messageProcessedOK = iirslt.processMessage(gmh); errorMessage = iirslt.getErrorMessage(); } if (interfaceType.equals("Material Auto Move") == true) { messageProcessedOK = imam.processMessage(gmh); errorMessage = imam.getErrorMessage(); } GenericMessageHeader.updateStats("Input", interfaceType, messageProcessedOK.toString()); logger.debug("Processing " + interfaceType + " finished."); } } logger.debug( " === RESULT " + messageProcessedOK.toString() + " ==="); if (messageProcessedOK) { il.write(gmh, GenericMessageHeader.msgStatusSuccess, "Processed OK", "DB Update", fromFile); reader.deleteFile(backupPath + gmh.getInterfaceType() + File.separator + fromFile); reader.move_FileToDirectory(inputPath + fromFile, backupPath + gmh.getInterfaceType(), true); } else { il.write(gmh, GenericMessageHeader.msgStatusError, errorMessage, "DB Update", fromFile); if (inter.getInterfaceProperties(gmh.getInterfaceType(), "Input") == true) { if (inter.getEmailError() == true) { String emailaddresses = inter.getEmailAddresses(); StringConverter stringConverter = new StringConverter(); ArrayConverter arrayConverter = new ArrayConverter( String[].class, stringConverter); arrayConverter.setDelimiter(';'); arrayConverter.setAllowedChars(new char[] { '@', '_' }); String[] emailList = (String[]) arrayConverter .convert(String[].class, emailaddresses); if (emailList.length > 0) { String siteName = Common.hostList.getHost(getHostID()) .getSiteDescription(); String attachedFilename = Common.base_dir + java.io.File.separator + inputPath + fromFile; logger.debug("Attaching file " + Common.base_dir + java.io.File.separator + inputPath + fromFile); mail.postMail(emailList, "Error Processing Incoming " + gmh.getInterfaceType() + " for [" + siteName + "] on " + JUtility.getClientName(), errorMessage, fromFile, attachedFilename); com.commander4j.util.JWait.milliSec(2000); } } } reader.deleteFile( errorPath + gmh.getInterfaceType() + File.separator + fromFile); reader.move_FileToDirectory(inputPath + fromFile, errorPath + gmh.getInterfaceType(), true); } } logger.debug("<--- END OF PROCESSING " + fromFile + " ---->"); } catch (Exception e) { e.printStackTrace(); } } } } } } } }
From source file:com.feilong.core.bean.ConvertUtilTest.java
/** * Test to string2./*from ww w . java 2s. com*/ */ @Test public void testToString2() { assertEquals("2", ConvertUtil.toString(toArray(2, null, 1, null))); ArrayConverter arrayConverter = new ArrayConverter(ArrayUtils.EMPTY_INT_ARRAY.getClass(), new IntegerConverter()); arrayConverter.setOnlyFirstToString(false); arrayConverter.setDelimiter(','); arrayConverter.setAllowedChars(new char[] { '.', '-' }); LOGGER.debug(arrayConverter.convert(String.class, toArray(2, null, 1, null))); }
From source file:com.commander4j.db.JDBUserReport.java
public boolean runReport() { PreparedStatement prepStatement; boolean result = true; try {/* w w w .j ava 2 s . c om*/ prepStatement = Common.hostList.getHost(getHostID()).getConnection(getSessionID()) .prepareStatement(getSQL(), ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); prepStatement.setFetchSize(25); if (isParamDateRequired()) { prepStatement.setTimestamp(1, getParamFromDate()); prepStatement.setTimestamp(2, getParamToDate()); } if (getDestination().equals("SYSTEM")) { for (int x = 0; x < systemParams.size(); x++) { String type = systemParams.get(x).parameterType; if (type.toLowerCase().equals("string")) { prepStatement.setString(systemParams.get(x).parameterPosition, systemParams.get(x).parameterStringValue); } if (type.toLowerCase().equals("integer")) { prepStatement.setInt(systemParams.get(x).parameterPosition, systemParams.get(x).parameterIntegerValue); } if (type.toLowerCase().equals("long")) { prepStatement.setLong(systemParams.get(x).parameterPosition, systemParams.get(x).parameterLongValue); } if (type.toLowerCase().equals("timestamp")) { prepStatement.setTimestamp(systemParams.get(x).parameterPosition, systemParams.get(x).parameterTimestampValue); } } } ResultSet tempResult = prepStatement.executeQuery(); boolean dataReturned = true; if (!tempResult.next()) { dataReturned = false; } tempResult.beforeFirst(); if (dataReturned) { if (getDestination().equals("EXCEL")) { generateExcel(tempResult); } if (getDestination().equals("JASPER_REPORTS")) { generateJasper(prepStatement); } if (getDestination().equals("PDF")) { generatePDF(prepStatement); } if (getDestination().equals("ACCESS")) { generateAccess(tempResult); } if (getDestination().equals("CSV")) { generateCSV(tempResult); } if (getDestination().equals("SYSTEM")) { generateSYSTEM(tempResult); } if (isPreviewRequired()) { try { Desktop.getDesktop().open(new File(getExportFilename())); } catch (IOException e) { e.printStackTrace(); } } if (isEmailEnabled()) { String emailaddresses = getEmailAddresses(); if (isEmailPromptEnabled()) { emailaddresses = JUtility.replaceNullStringwithBlank( JOptionPane.showInputDialog(lang.get("lbl_Email_Addresses"))); } StringConverter stringConverter = new StringConverter(); ArrayConverter arrayConverter = new ArrayConverter(String[].class, stringConverter); arrayConverter.setDelimiter(';'); arrayConverter.setAllowedChars(new char[] { '@', '_' }); String[] emailList = (String[]) arrayConverter.convert(String[].class, emailaddresses); if (emailList.length > 0) { String shortFilename = JUtility.getFilenameFromPath(getExportFilename()); mail.postMail(emailList, "Commande4j User Report requested by " + Common.userList.getUser(Common.sessionID).getUserId() + " from [" + Common.hostList.getHost(getHostID()).getSiteDescription() + "] on " + JUtility.getClientName(), "See attached report.\n", shortFilename, getExportFilename()); com.commander4j.util.JWait.milliSec(2000); } } } else { result = false; setErrorMessage("No data returned by query."); } } catch (Exception ex) { setErrorMessage(ex.getMessage()); result = false; } return result; }