@Override public Collection call(Element element) { Collection collection = new Collection(); for (Element child : XmlHelper.childElements(element)) { String tagName = child.getTagName(); Tag t = tagLookup.get(tagName); if (t != null) { switch (t) { case id: collection.setId(getLong(child)); break; case name: collection.setName(getText(child)); break; case qname: collection.setQname(getText(child)); break; case description: collection.setDescription(getText(child)); break; case owner_id: collection.setOwnerId(getLong(child)); break; case datasets: collection.setDataSetQnames(getDatasets(child)); break; case deleted: collection.setDeleted(getBoolean(child)); break; default: break; } } } return collection; }
@Override public Element call(Document document, Collection collection) { Element element = createElement(document, TAG); append(element, Tag.id, collection.getId()); append(element, Tag.name, collection.getName()); append(element, Tag.qname, collection.getQname()); append(element, Tag.description, collection.getDescription()); append(element, Tag.owner_id, collection.getOwnerId()); List<String> datasets = collection.getDataSetQnames(); if (datasets != null) { Element datasetsElement = createElement(document, Tag.datasets); element.appendChild(datasetsElement); for (String dataset : datasets) { append(datasetsElement, Tag.dataset, dataset); } } append(element, Tag.deleted, collection.getDeleted()); return element; }