void populateXml(Element materials, Modifications modifications, XmlWriterContext writerContext) { Element materialElement = materials.addElement("material"); materialElement.addAttribute("materialUri", writerContext.getBaseUrl() + "/api/materials/" + material.getId() + ".xml"); for (Map.Entry<String, Object> criterion : material.getAttributesForXml().entrySet()) { if (criterion.getValue() != null) { materialElement.addAttribute(criterion.getKey(), criterion.getValue().toString()); } } Element modificationsTag = materialElement.addElement("modifications"); populateXmlForModifications(modifications, writerContext, modificationsTag); }
@Override void populateXmlForModifications(Modifications modifications, XmlWriterContext writerContext, Element modificationsTag) { for (Modification modification : modifications) { Element changeset = modificationsTag.addElement("changeset"); changeset.addAttribute("changesetUri", ScmMaterial.changesetUrl(modification, writerContext.getBaseUrl(), material.getId())); changeset.addElement("user").addCDATA(modification.getUserDisplayName()); changeset.addElement("checkinTime").addText(DateUtils.formatISO8601(modification.getModifiedTime())); changeset.addElement("revision").addCDATA(modification.getRevision()); changeset.addElement("message").addCDATA(modification.getComment()); } } }
@Override void populateXmlForModifications(Modifications modifications, XmlWriterContext writerContext, Element modificationsTag) { for (Modification modification : modifications) { Element changeset = modificationsTag.addElement("changeset"); changeset.addAttribute("changesetUri", ScmMaterial.changesetUrl(modification, writerContext.getBaseUrl(), material.getId())); changeset.addElement("user").addCDATA(modification.getUserDisplayName()); changeset.addElement("checkinTime").addText(DateUtils.formatISO8601(modification.getModifiedTime())); changeset.addElement("revision").addCDATA(modification.getRevision()); changeset.addElement("message").addCDATA(modification.getComment()); List<ModifiedFile> modifiedFiles = modification.getModifiedFiles(); for (ModifiedFile modifiedFile : modifiedFiles) { changeset.addElement("file").addAttribute("name", modifiedFile.getFileName()).addAttribute("action", modifiedFile.getAction().toString()); } } } }