19 package org.turro.erp.time;
22 import java.io.IOException;
23 import java.io.OutputStreamWriter;
24 import java.util.List;
25 import java.util.TreeSet;
26 import java.util.logging.Level;
27 import java.util.logging.Logger;
28 import org.turro.string.ObjectString;
29 import org.jdom.Document;
30 import org.jdom.Element;
31 import org.jdom.JDOMException;
32 import org.jdom.input.SAXBuilder;
33 import org.jdom.output.Format;
34 import org.jdom.output.XMLOutputter;
35 import org.turro.elephant.context.ElephantContext;
36 import org.turro.elephant.context.IConstructor;
37 import org.turro.elephant.impl.util.FileUtil;
50 this.constructor = constructor;
64 Document doc =
new Document(
new Element(
"human-resources"));
65 writeXML(doc.getRootElement());
69 Format fm = Format.getPrettyFormat();
71 XMLOutputter xo =
new XMLOutputter(fm);
74 }
catch (IOException ex) {
79 private void loadCollection() {
80 SAXBuilder builder =
new SAXBuilder();
84 if(confFile.exists()) {
85 doc = builder.build(confFile);
86 readXML(doc.getRootElement());
88 }
catch (IOException ex) {
90 }
catch (JDOMException ex) {
95 private void writeXML(Element rootElement) {
96 for(XMLHumanResource hr :
this) {
97 Element el =
new Element(
"human-resource");
98 el.setAttribute(
"name", hr.getName());
99 el.setAttribute(
"id", hr.getId() +
"");
100 rootElement.addContent(el);
104 private void readXML(Element rootElement) {
106 for(Element el : (List<Element>) rootElement.getChildren(
"human-resource")) {
107 XMLHumanResource hr =
new XMLHumanResource();
108 hr.setName(el.getAttributeValue(
"name"));
109 hr.setId((Long) ObjectString.parseString(el.getAttributeValue(
"id"), Long.class,
false));
static String getRealPath(String path)
static String getEncoding()
static OutputStreamWriter getFileWriter(String folder, String file)
static final String XML_HUMANRESOURCE
XMLHumanResourceSet(IConstructor constructor)
String getName(XMLTimeControl tc)
long getHumanResourceId()