From ad54d139dd301cb2f855b934563c73be7a103917 Mon Sep 17 00:00:00 2001 From: James Maina Date: Tue, 25 Oct 2016 14:14:35 +0300 Subject: [PATCH] Fix: Build errors --- .../service/XlsFormDownloaderService.java | 107 +++++++++--------- .../controller/FormSubmissionController.java | 3 +- .../listener/ApplicationStartupListener.java | 2 +- 3 files changed, 54 insertions(+), 58 deletions(-) diff --git a/opensrp-core/src/main/java/org/opensrp/service/XlsFormDownloaderService.java b/opensrp-core/src/main/java/org/opensrp/service/XlsFormDownloaderService.java index b39b1c7cd7..1fbf109241 100644 --- a/opensrp-core/src/main/java/org/opensrp/service/XlsFormDownloaderService.java +++ b/opensrp-core/src/main/java/org/opensrp/service/XlsFormDownloaderService.java @@ -2,24 +2,16 @@ -import httpdowload.JustForFun; - import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; import java.io.Writer; -import java.util.Arrays; -import java.util.Date; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import org.apache.commons.lang3.ArrayUtils; import org.codehaus.jackson.JsonProcessingException; -import org.joda.time.DateTime; -import org.joda.time.Hours; -import org.joda.time.Years; import org.opensrp.util.FileCreator; import org.opensrp.util.JsonParser; import org.opensrp.util.NetClientGet; @@ -33,7 +25,8 @@ import com.sun.org.apache.xml.internal.serialize.OutputFormat; import com.sun.org.apache.xml.internal.serialize.XMLSerializer; -import com.sun.xml.internal.txw2.Document; + +//import httpdowload.JustForFun; /** * @author muhammad.ahmed@ihsinformatics.com @@ -41,31 +34,31 @@ */ @Service public class XlsFormDownloaderService { - private NetClientGet netClientGet; - private FileCreator fileCreator; - private JsonParser jsonParser; - - private byte[] formJson=null; - public XlsFormDownloaderService() { - netClientGet=new NetClientGet(); - fileCreator=new FileCreator(); - - jsonParser=new JsonParser(); - } +// private NetClientGet netClientGet; +// private FileCreator fileCreator; +// private JsonParser jsonParser; +// +// private byte[] formJson=null; +// public XlsFormDownloaderService() { +// netClientGet=new NetClientGet(); +// fileCreator=new FileCreator(); +// +// jsonParser=new JsonParser(); +// } public static void main(String[] args) { - try { - new XlsFormDownloaderService().downloadFormFiles("D:\\opensrpVaccinatorWkspc\\forms", - "maimoonak", "opensrp", JustForFun.Form, "child_vaccination_enrollment", "135187"); - //------------------------- - new XlsFormDownloaderService().downloadFormFiles("D:\\opensrpVaccinatorWkspc\\forms", - "maimoonak", "opensrp", JustForFun.Form, "child_vaccination_followup", "135199"); - //--------------------------- - new XlsFormDownloaderService().downloadFormFiles("D:\\opensrpVaccinatorWkspc\\forms", - "maimoonak", "opensrp", JustForFun.Form, "woman_tt_enrollement_form", "135200"); - //---------------------------- - new XlsFormDownloaderService().downloadFormFiles("D:\\opensrpVaccinatorWkspc\\forms", - "maimoonak", "opensrp", JustForFun.Form, "woman_tt_followup_form", "135203"); +// try { +// new XlsFormDownloaderService().downloadFormFiles("D:\\opensrpVaccinatorWkspc\\forms", +// "maimoonak", "opensrp", JustForFun.Form, "child_vaccination_enrollment", "135187"); +// //------------------------- +// new XlsFormDownloaderService().downloadFormFiles("D:\\opensrpVaccinatorWkspc\\forms", +// "maimoonak", "opensrp", JustForFun.Form, "child_vaccination_followup", "135199"); +// //--------------------------- +// new XlsFormDownloaderService().downloadFormFiles("D:\\opensrpVaccinatorWkspc\\forms", +// "maimoonak", "opensrp", JustForFun.Form, "woman_tt_enrollement_form", "135200"); +// //---------------------------- +// new XlsFormDownloaderService().downloadFormFiles("D:\\opensrpVaccinatorWkspc\\forms", +// "maimoonak", "opensrp", JustForFun.Form, "woman_tt_followup_form", "135203"); /*new XlsFormDownloaderService().downloadFormFiles("D:\\opensrpVaccinatorWkspc\\forms", "maimoonak", "opensrp", JustForFun.Form, "vaccine_stock_position", "115142"); @@ -77,9 +70,9 @@ public static void main(String[] args) { new XlsFormDownloaderService().downloadFormFiles("D:\\opensrpVaccinatorWkspc\\forms", "maimoonak", "opensrp", JustForFun.Form, "offsite_woman_followup_form", "115135");*/ - } catch (IOException e) { - e.printStackTrace(); - } +// } catch (IOException e) { +// e.printStackTrace(); +// } } public String formatXML(String input) @@ -144,30 +137,32 @@ private org.w3c.dom.Document parseXmlFile(String in) { public boolean downloadFormFiles(String directory,String username ,String formPath, String password,String formId, String formPk) throws IOException{ - String xmlData=netClientGet.convertToString("", formPath, formId); - String modelData=netClientGet.getModel(xmlData); - String formData=fileCreator.prettyFormat(netClientGet.getForm(xmlData)); - - modelData=format(modelData); - - formData = formData.replaceAll("selected\\(", "contains("); - formData = formData.replaceAll("", ""); - formData = formData.replaceAll("", ""); - - formJson=netClientGet.downloadJson(username,password, formPk); - - //formData=fileCreator.prettyFormat(formData); - System.out.println(getFormDefinition()); - fileCreator.createFile("form_definition.json", fileCreator.osDirectorySet(directory)+formId, getFormDefinition().getBytes()); - return fileCreator.createFormFiles(fileCreator.osDirectorySet(directory)+formId, formId, formData.getBytes(), modelData.getBytes(), formJson); +// String xmlData=netClientGet.convertToString("", formPath, formId); +// String modelData=netClientGet.getModel(xmlData); +// String formData=fileCreator.prettyFormat(netClientGet.getForm(xmlData)); +// +// modelData=format(modelData); +// +// formData = formData.replaceAll("selected\\(", "contains("); +// formData = formData.replaceAll("", ""); +// formData = formData.replaceAll("", ""); +// +// formJson=netClientGet.downloadJson(username,password, formPk); +// +// //formData=fileCreator.prettyFormat(formData); +// System.out.println(getFormDefinition()); +// fileCreator.createFile("form_definition.json", fileCreator.osDirectorySet(directory)+formId, getFormDefinition().getBytes()); +// return fileCreator.createFormFiles(fileCreator.osDirectorySet(directory)+formId, formId, formData.getBytes(), modelData.getBytes(), formJson); + return false; } public String getFormDefinition() throws JsonProcessingException, IOException{ - if(formJson==null){ - return "Data not found on server . Please retry again !"; - - } - return jsonParser.getFormDefinition(formJson); +// if(formJson==null){ +// return "Data not found on server . Please retry again !"; +// +// } +// return jsonParser.getFormDefinition(formJson); + return null; } } diff --git a/opensrp-web/src/main/java/org/opensrp/web/controller/FormSubmissionController.java b/opensrp-web/src/main/java/org/opensrp/web/controller/FormSubmissionController.java index 6570f3c9ca..54917ab244 100644 --- a/opensrp-web/src/main/java/org/opensrp/web/controller/FormSubmissionController.java +++ b/opensrp-web/src/main/java/org/opensrp/web/controller/FormSubmissionController.java @@ -13,6 +13,7 @@ import java.util.List; import java.util.Map; +import org.joda.time.DateTime; import org.json.JSONException; import org.json.JSONObject; import org.opensrp.common.AllConstants; @@ -139,7 +140,7 @@ public FormSubmission convert(FormSubmissionDTO submission) { } catch(Exception e){ e.printStackTrace(); - ErrorTrace errorTrace=new ErrorTrace(new Date(), "Parse Exception", "", e.getStackTrace().toString(), "Unsolved", formSubmission.formName()); + ErrorTrace errorTrace=new ErrorTrace(new DateTime(), "Parse Exception", "", e.getStackTrace().toString(), "Unsolved", formSubmission.formName()); errorTrace.setRecordId(formSubmission.instanceId()); errorTraceService.addError(errorTrace); } diff --git a/opensrp-web/src/main/java/org/opensrp/web/listener/ApplicationStartupListener.java b/opensrp-web/src/main/java/org/opensrp/web/listener/ApplicationStartupListener.java index 9bc6c06594..57e1ed9acb 100644 --- a/opensrp-web/src/main/java/org/opensrp/web/listener/ApplicationStartupListener.java +++ b/opensrp-web/src/main/java/org/opensrp/web/listener/ApplicationStartupListener.java @@ -47,7 +47,7 @@ public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) { scheduler.startJob(formSchedule); //scheduler.startJob(anmReportScheduler); //scheduler.startJob(mctsReportScheduler); - scheduler.startJob(openmrsScheduleSyncerScheduler); + // scheduler.startJob(openmrsScheduleSyncerScheduler); scheduler.startJob(atomfeedSchedule); scheduler.startJob(encounterSchedule);