aIdCounters[0] = aIdCounters[0]+1;
oAttrs.put("id_project", String.valueOf(aIdCounters[0]));
String sXml = toXML(oConn, sIdent, "\n", oAttrs);
DBSubset oDuties = new DBSubset (DB.k_duties, "*", DB.gu_project+"=? ORDER BY "+DB.dt_modified+" DESC", 50);
int nDuties = oDuties.load(oConn, new Object[]{getString(DB.gu_project)});
if (DebugFile.trace) DebugFile.writeln("duties count is "+String.valueOf(nDuties));
DBSubset oBugs = new DBSubset (DB.k_bugs, "*", DB.gu_project+"=? ORDER BY "+DB.dt_modified+" DESC", 50);
int nBugs = oBugs.load(oConn, new Object[]{getString(DB.gu_project)});
if (DebugFile.trace) DebugFile.writeln("bugs count is "+String.valueOf(nBugs));
DBSubset oSubp = new DBSubset (DB.k_projects, "*", DB. id_parent+"=? ORDER BY "+DB.dt_start+","+DB.dt_end, 20);
int nSubp = oSubp.load(oConn, new Object[]{getString(DB.gu_project)});
if (DebugFile.trace) DebugFile.writeln("subprojects count is "+String.valueOf(nSubp));
StringBuffer oSS = new StringBuffer(sXml.length()+256*nDuties+256*nBugs+4000*nSubp);
oSS.append(sXml.substring(0,sXml.length()-(sIdent+"</Project>").length()));
Duty oDut = new Duty();
oDut.getTable(oConn);
oSS.append(s2+"<Duties count=\""+String.valueOf(nDuties)+"\">\n");
for (int d=0; d<nDuties; d++) {
oDut.clear();
oDut.putAll(oDuties.getRowAsMap(d));
if (oDut.isNull(DB.ti_duration))
oDut.replace(DB.ti_duration, new BigDecimal(1d));
oAttrs.clear();
aIdCounters[0] = aIdCounters[0]+1;
oAttrs.put("id_duty", String.valueOf(aIdCounters[0]));
oSS.append(oDut.toXML(s3,"\n",oAttrs));
oSS.append("\n");
Resource[] aResources = oDut.resources(oConn);
if (aResources!=null) {
int nResources = aResources.length;
for (int r=0; r<nResources; r++) {
if (!oResources.containsKey(aResources[r].getValue())) {
aIdCounters[1] = aIdCounters[1]+1;
aResources[r].setProgressive(aIdCounters[1]);
oResources.put(aResources[r].getValue(), aResources[r]);
} // fi
oAllocations.append(" <Allocation id_duty=\""+String.valueOf(aIdCounters[0])+"\" pg_resource=\""+String.valueOf(aIdCounters[1])+"\" load=\""+String.valueOf(aResources[r].getWorkLoadPercentage())+"\" />\n");
} // next
}
} // next
oDuties = null;
oDut = null;
oSS.append(s2+"</Duties>\n");
Bug oBug = new Bug();
oBug.getTable(oConn);
oSS.append(s2+"<Bugs count=\""+String.valueOf(nBugs)+"\">\n");
for (int b=0; b<nBugs; b++) {
oBug.clear();
oBug.putAll(oBugs.getRowAsMap(b));
oSS.append(oBug.toXML(s3));
oSS.append("\n");
} // next
oBugs = null;
oBug = null;
oSS.append(s2+"</Bugs>\n");
Project oSub = new Project();
oSub.getTable(oConn);
oSS.append(s2+"<Subprojects count=\""+String.valueOf(nSubp)+"\">\n");
for (int p=0; p<nSubp; p++) {
oSub.clear();
oSub.putAll(oSubp.getRowAsMap(p));
oSS.append(oSub.snapshotBuilder(oConn,s3,aIdCounters,oResources,oAllocations));
} // next
oSubp = null;
oSub = null;
oSS.append(s2+"</Subprojects>\n");