use of org.compiere.model.X_IMP_ProcessorParameter 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.compiere.model.X_IMP_ProcessorParameter in project adempiere by adempiere.
the class TopicImportProcessor method process.
public void process(Properties ctx, ReplicationProcessor replicationProcessor, String trxName) throws Exception {
log.info("replicationProcessor = " + replicationProcessor);
log.info("replicationProcessor.getMImportProcessor() = " + replicationProcessor.getMImportProcessor());
MIMPProcessor impProcessor = replicationProcessor.getMImportProcessor();
X_IMP_ProcessorParameter[] processorParameters = impProcessor.getIMP_ProcessorParameters(trxName);
String host = impProcessor.getHost();
int port = impProcessor.getPort();
String account = impProcessor.getAccount();
String password = impProcessor.getPasswordInfo();
// mandatory parameters!
String topicName = null;
String protocol = null;
boolean isDurableSubscription = true;
String subscriptionName = null;
String options = null;
String clientID = null;
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("isDurableSubscription")) {
isDurableSubscription = Boolean.parseBoolean(processorParameters[i].getParameterValue());
} else if (processorParameters[i].getValue().equals("subscriptionName")) {
subscriptionName = processorParameters[i].getParameterValue();
} else if (processorParameters[i].getValue().equals("clientID")) {
clientID = processorParameters[i].getParameterValue();
} else {
// Some other mandatory parameter here
}
}
}
if (topicName == null || topicName.length() == 0) {
throw new Exception("Missing " + X_IMP_ProcessorParameter.Table_Name + " with key 'topicName'!");
}
if (protocol == null || protocol.length() == 0) {
throw new Exception("Missing " + X_IMP_ProcessorParameter.Table_Name + " with key 'protocol'!");
}
if (isDurableSubscription && subscriptionName == null || subscriptionName.length() == 0) {
throw new Exception("Missing " + X_IMP_ProcessorParameter.Table_Name + " with key 'subscriptionName'!");
}
if (clientID == null || clientID.length() == 0) {
throw new Exception("Missing " + X_IMP_ProcessorParameter.Table_Name + " with key 'clientID'!");
}
topicListener = new TopicListener(ctx, replicationProcessor, protocol, host, port, isDurableSubscription, subscriptionName, topicName, clientID, account, password, options, trxName);
topicListener.run();
log.info("Started topicListener = " + topicListener);
}
Aggregations