use of org.compiere.model.X_EXP_ProcessorParameter in project adempiere by adempiere.
the class TopicExportProcessor method process.
/**
*
*/
public void process(Properties ctx, MEXPProcessor expProcessor, Document document, Trx trx) throws Exception {
String host = expProcessor.getHost();
int port = expProcessor.getPort();
String account = expProcessor.getAccount();
String password = expProcessor.getPasswordInfo();
String protocol = null;
String topicName = "";
String clientID = null;
String timeToLiveStr = null;
int timeToLive = 10000;
boolean isDeliveryModePersistent = true;
// Read all processor parameters and set them!
X_EXP_ProcessorParameter[] processorParameters = expProcessor.getEXP_ProcessorParameters(trx.getTrxName());
if (processorParameters != null && processorParameters.length > 0) {
for (int i = 0; i < processorParameters.length; i++) {
log.info("ProcesParameter Value = " + processorParameters[i].getValue());
log.info("ProcesParameter ParameterValue = " + processorParameters[i].getParameterValue());
if (processorParameters[i].getValue().equals("topicName")) {
topicName = processorParameters[i].getParameterValue();
} else if (processorParameters[i].getValue().equals("protocol")) {
protocol = processorParameters[i].getParameterValue();
} else if (processorParameters[i].getValue().equals("clientID")) {
clientID = processorParameters[i].getParameterValue();
} else if (processorParameters[i].getValue().equals("timeToLive")) {
timeToLiveStr = processorParameters[i].getParameterValue();
timeToLive = Integer.parseInt(timeToLiveStr);
} else if (processorParameters[i].getValue().equals("isDeliveryModePersistent")) {
isDeliveryModePersistent = Boolean.parseBoolean(processorParameters[i].getParameterValue());
} else {
// Some other mandatory parameter here
}
}
}
if (topicName == null || topicName.length() == 0) {
throw new Exception("Missing " + X_EXP_ProcessorParameter.Table_Name + " with key 'topicName'!");
}
if (protocol == null || protocol.length() == 0) {
throw new Exception("Missing " + X_EXP_ProcessorParameter.Table_Name + " with key 'protocol'!");
}
if (clientID == null || clientID.length() == 0) {
throw new Exception("Missing " + X_EXP_ProcessorParameter.Table_Name + " with key 'clientID'!");
}
if (timeToLiveStr == null || timeToLiveStr.length() == 0) {
throw new Exception("Missing " + X_EXP_ProcessorParameter.Table_Name + " with key 'timeToLive'!");
}
// Construct Transformer Factory and Transformer
TransformerFactory tranFactory = TransformerFactory.newInstance();
String jVersion = System.getProperty("java.version");
if (jVersion.startsWith("1.5.0"))
tranFactory.setAttribute("indent-number", Integer.valueOf(1));
Transformer aTransformer = tranFactory.newTransformer();
aTransformer.setOutputProperty(OutputKeys.INDENT, "yes");
Source src = new DOMSource(document);
// =================================== Write to String
Writer writer = new StringWriter();
Result dest2 = new StreamResult(writer);
aTransformer.transform(src, dest2);
sendJMSMessage(host, port, writer.toString(), protocol, topicName, clientID, account, password, timeToLive, isDeliveryModePersistent);
}
use of org.compiere.model.X_EXP_ProcessorParameter in project adempiere by adempiere.
the class HDDExportProcessor method process.
public void process(Properties ctx, MEXPProcessor expProcessor, Document document, Trx trx) throws Exception {
//String host = expProcessor.getHost();
//int port = expProcessor.getPort();
//String account = expProcessor.getAccount();
//String password = expProcessor.getPasswordInfo();
String fileName = "";
String folder = "";
// Read all processor parameters and set them!
X_EXP_ProcessorParameter[] processorParameters = expProcessor.getEXP_ProcessorParameters(trx.getTrxName());
if (processorParameters != null && processorParameters.length > 0) {
for (int i = 0; i < processorParameters.length; i++) {
// One special parameter which will be used for remote folder name.
// Or could add flag to ProcessorParameters table which will distinguish between
// connection parameters and FTP Upload parameters.
log.info("ProcesParameter Value = " + processorParameters[i].getValue());
log.info("ProcesParameter ParameterValue = " + processorParameters[i].getParameterValue());
if (processorParameters[i].getValue().equals("fileName")) {
fileName = processorParameters[i].getParameterValue();
} else if (processorParameters[i].getValue().equals("folder")) {
folder = processorParameters[i].getParameterValue();
}
}
}
if (fileName == null || fileName.length() == 0) {
throw new Exception("Missing EXP_ProcessorParameter with key 'fileName'!");
}
// Save the document to the disk file
TransformerFactory tranFactory = TransformerFactory.newInstance();
tranFactory.setAttribute("indent-number", Integer.valueOf(1));
Transformer aTransformer = tranFactory.newTransformer();
aTransformer.setOutputProperty(OutputKeys.INDENT, "yes");
Source src = new DOMSource(document);
// =================================== Write to String
Writer writer = new StringWriter();
Result dest2 = new StreamResult(writer);
aTransformer.transform(src, dest2);
System.err.println(writer.toString());
// =================================== Write to Disk
try {
Result dest = new StreamResult(new File(folder + fileName));
aTransformer.transform(src, dest);
writer.close();
} catch (TransformerException ex) {
ex.printStackTrace();
throw ex;
}
}
Aggregations