private org.jdom2.Element getDataforCase(String specName, String caseID, String data) { String caseData = ""; try { caseData = _ibClient.getCaseData(caseID, _handle); } catch (IOException e) { e.printStackTrace(); } org.jdom2.Element result = new org.jdom2.Element(specName); SAXBuilder builder = new SAXBuilder(); org.jdom2.Element root = null; List<org.jdom2.Element> ls = null; try { org.jdom2.Document document = builder.build(new StringReader(data)); root = document.getRootElement(); ls = document.getRootElement().getChildren(); } catch (Exception e) { System.out.println(e); } for (org.jdom2.Element l : ls) { String paramName = l.getName(); org.jdom2.Element advElem = root.getChild(paramName); try { if (advElem != null) { org.jdom2.Element copy = (org.jdom2.Element) advElem.clone(); result.addContent(copy); } else { result.addContent(new org.jdom2.Element(paramName)); } } catch (IllegalAddException iae) { } } return result; }
private void handleProceedPlaceholder(WorkItemRecord enabledWorkItem) { connect(); try { WorkItemRecord childWorkItem = checkOut(enabledWorkItem.getID(), _handle); AdviceQuery query = new AdviceQuery(); List<Advice> advs = query.getByAdviceName(enabledWorkItem.getSpecURI()); System.out.println(">>>> Number of the same advices are " + advs.size()); if ((advs != null) && (advs.size() > 0)) { System.out.println(">>>> Number of the launched advices are " + advs.size()); do { advs = query.getByAdviceCaseID(enabledWorkItem.getCaseID()); } while ((advs == null) || (advs.size() == 0)); System.out.println(">>>> Number of the launched advices are " + advs.size()); Advice advice = (Advice) advs.get(0); advice.setSynched(true); advice.setProceedName(enabledWorkItem.getTaskName()); advice.setProceedID(childWorkItem.getID()); this._Persister.beginTransaction(); this._Persister.update(advice); this._Persister.commit(); System.out.println(">>>> Proceed Name is " + advice.getProceedName()); System.out.println(">>>> Proceed ID is " + advice.getProceedID()); org.jdom2.Element d = getDataforCase( advice.getParentSpecName(), advice.getParentCaseID(), _ibClient.getCaseData(enabledWorkItem.getCaseID(), _handle)); this._ixClient.updateCaseData(advice.getParentCaseID(), d, _handle); weaving(advice.getParentCaseID(), advice.getAdjpID(), false); } } catch (IOException | YAWLException e) { e.printStackTrace(); } }