use of org.adempiere.process.rpl.imp.ImportHelper in project adempiere by adempiere.
the class FileImportProcessor method process.
public void process(Properties ctx, ReplicationProcessor replicationProcessor, String trxName) throws Exception {
MIMPProcessor impProcessor = replicationProcessor.getMImportProcessor();
X_IMP_ProcessorParameter[] processorParameters = impProcessor.getIMP_ProcessorParameters(trxName);
String fileName = null;
String folder = "";
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("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 IMP_ProcessorParameter with key 'fileName'!");
}
Document documentToBeImported = XMLHelper.createDocumentFromFile(folder + fileName);
StringBuffer result = new StringBuffer();
ImportHelper impHelper = new ImportHelper(ctx);
impHelper.importXMLDocument(result, documentToBeImported, trxName);
// addLog(0, null, null, Msg.getMsg(ctx, "ImportModelProcessResult") + "\n" + result.toString());
}
use of org.adempiere.process.rpl.imp.ImportHelper in project adempiere by adempiere.
the class TopicListener method onMessage.
/**
*
*/
public void onMessage(Message message) {
if (message instanceof TextMessage) {
try {
TextMessage txtMessage = (TextMessage) message;
String text = txtMessage.getText();
log.finest("Received message: \n" + text);
Document documentToBeImported = XMLHelper.createDocumentFromString(text);
StringBuffer result = new StringBuffer();
ImportHelper impHelper = new ImportHelper(ctx);
impHelper.importXMLDocument(result, documentToBeImported, trxName);
log.finest("Message processed ...");
if (replicationProcessor != null) {
MIMPProcessorLog pLog = new MIMPProcessorLog(replicationProcessor.getMImportProcessor(), "Imported Document!");
//pLog.setReference("topicName = " + topicName );
if (text.length() > 2000) {
pLog.setTextMsg(text.substring(0, 1999));
} else {
pLog.setTextMsg(text);
}
pLog.saveEx();
}
session.commit();
} catch (Exception e) {
log.finest("Rollback = " + e.toString());
try {
session.rollback();
stop();
//replicationProcessor.interrupt();
//replicationProcessor.join();
replicationProcessor.setProcessRunning(false);
}/*catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}*/
catch (JMSException e2) {
e2.printStackTrace();
}
e.printStackTrace();
}
} else {
log.finest("Received NO TEXT Message: ");
}
}
Aggregations