diff options
author | kelvingoodson <kelvingoodson@13f79535-47bb-0310-9956-ffa450edef68> | 2010-02-01 16:56:53 +0000 |
---|---|---|
committer | kelvingoodson <kelvingoodson@13f79535-47bb-0310-9956-ffa450edef68> | 2010-02-01 16:56:53 +0000 |
commit | 667d3a02bc5867d349b548ac5eee5212026a2551 (patch) | |
tree | b8d197336a3c835f11fc93c12ba7df0e5da5ec0c /sandbox/kgoodson/jagg/src/main/java/services | |
parent | 666eea81f0ac8ea88c04da729bf98a4542453344 (diff) |
adding work items to existing milestone working - new milstone missing some logic, i/f needs tidying, backup of old plan not yet good enough
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@905337 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/kgoodson/jagg/src/main/java/services')
-rw-r--r-- | sandbox/kgoodson/jagg/src/main/java/services/PlanView.java | 1 | ||||
-rw-r--r-- | sandbox/kgoodson/jagg/src/main/java/services/PlanViewImpl.java | 67 |
2 files changed, 61 insertions, 7 deletions
diff --git a/sandbox/kgoodson/jagg/src/main/java/services/PlanView.java b/sandbox/kgoodson/jagg/src/main/java/services/PlanView.java index e3d9080246..101e1d1e01 100644 --- a/sandbox/kgoodson/jagg/src/main/java/services/PlanView.java +++ b/sandbox/kgoodson/jagg/src/main/java/services/PlanView.java @@ -31,5 +31,6 @@ import com.example.ipo.jaxb.Plan; public interface PlanView { Plan get(); + void post(String newMSName,String msChoice, String jira); }
\ No newline at end of file diff --git a/sandbox/kgoodson/jagg/src/main/java/services/PlanViewImpl.java b/sandbox/kgoodson/jagg/src/main/java/services/PlanViewImpl.java index 5c4f115a6c..79d835ecb2 100644 --- a/sandbox/kgoodson/jagg/src/main/java/services/PlanViewImpl.java +++ b/sandbox/kgoodson/jagg/src/main/java/services/PlanViewImpl.java @@ -20,6 +20,7 @@ package services; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; @@ -29,6 +30,7 @@ import java.util.List; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; import javax.xml.bind.Unmarshaller; +import javax.xml.bind.Marshaller; import org.oasisopen.sca.annotation.Init; import org.xml.sax.InputSource; @@ -55,7 +57,6 @@ public class PlanViewImpl implements PlanView { @Init public void init() { - } private Plan getPlan() { @@ -70,7 +71,7 @@ public class PlanViewImpl implements PlanView { // Reader r = new XMLReader() // InputSource s = new InputSource(r); - _p = ((JAXBElement<Plan>) m.unmarshal(inputFile)).getValue(); + _p = (Plan)m.unmarshal(inputFile); augment_plan(_p); } catch (Exception e) { e.printStackTrace(); @@ -99,11 +100,6 @@ public class PlanViewImpl implements PlanView { JAXBContext jaxbContext = JAXBContext .newInstance("com.example.ipo.jaxb"); Unmarshaller m2 = jaxbContext.createUnmarshaller(); - - // File inputFile = new File("src/main/resources/exampleJira.xml") - // .getAbsoluteFile(); - // - // RSS j = ((JAXBElement<RSS>) m2.unmarshal(inputFile)).getValue(); InputStream is = null; RSS j; try{ @@ -118,6 +114,7 @@ public class PlanViewImpl implements PlanView { Item i = j.getChannel().getItem(); System.out.println(i.toString()); List<JAXBElement<?>> c = i.getContent(); + // TODO see if there's a better way to get this data out for (JAXBElement<?> element : c) { if("title".equals(element.getName().getLocalPart())) { String jtitle = (String)element.getValue(); @@ -148,4 +145,60 @@ public class PlanViewImpl implements PlanView { return modelplan; } + private Milestone getMS(String id) { + + Milestone m = null; + Plan p = getPlan(); + for(Milestone mi : p.getMilestone()) { + if(id.equals(mi.getID())) { + m = mi; + break; + } + } + return m; + } + + public void post(String newMSName,String msChoice, String jira) { + + String msName = msChoice; + Plan p = getPlan(); + if(!"".equals(newMSName)) { + List<Milestone> mis = p.getMilestone(); + Milestone newm = new Milestone(); + newm.setID(newMSName); + mis.add(new Milestone()); + msName = newMSName; + } + + Milestone m = getMS(msName); + WorkItem wi = new WorkItem(); + wi.setJira(jira); + m.getWorkItem().add(wi); + + writePlan(); + } + + private void writePlan() + { + try { + JAXBContext jaxbContext = JAXBContext + .newInstance("com.example.ipo.jaxb"); + Marshaller m = jaxbContext.createMarshaller(); + m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); + File oldInputFile = new File("src/main/resources/jiraSideBand.xml").getAbsoluteFile(); + String oldPath = oldInputFile.getAbsolutePath(); + oldInputFile.renameTo(new File(oldPath+".old")); + File outputFile = new File("src/main/resources/jiraSideBand.xml").getAbsoluteFile(); + FileOutputStream fos = new FileOutputStream(outputFile); + + + m.marshal(getPlan(), fos); + } catch (Exception e) { + e.printStackTrace(); + } finally { + + } + } + + }
\ No newline at end of file |