monitor.log().debug(" Target folder already exists " + existing.getObjectId());
cnt++;
monitor.worked(cnt);
dql = "select r_object_id from dm_sysobject where FOLDER(ID('"+src.getObjectId()+"'))";
IDfCollection res = new DfQuery(dql).execute(session, IDfQuery.READ_QUERY);
LinkedList<String> children = new LinkedList<String>();
while (res.next())
children.add(res.getString("r_object_id"));
res.close();
for(String id : children) {
IDfSysObject newSrc = (IDfSysObject) session.getObject(new DfId(id));
cnt = copy((IDfFolder)existing,newSrc,cnt);
}
return cnt;
}
}
LinkedList<String> tmp = new LinkedList<String>();
for ( int i = 0; i < src.getFolderIdCount(); i++)
tmp.add(src.getFolderId(i).getId());
src.link(trg.getObjectId().getId());
for (String id : tmp )
src.unlink(id);
IDfId newId = src.saveAsNew(true);
monitor.log().debug(" Created: " + newId);
src.revert();
IDfPersistentObject newItem = session.getObject(newId);
cnt++;
monitor.worked(cnt);
// fire events
if (useTransaction) {
events.add(new String[] {newId.getId(),trg.getObjectId().getId()});
} else {
target.getConnection().fireElementCreated( newId.getId() );
target.getConnection().fireElementLink(trg.getObjectId().getId(), newId.getId());
}
if (src instanceof IDfFolder) {
IDfFolder srcFolder = (IDfFolder)src;
IDfFolder trgFolder = (IDfFolder)newItem;
String dql = "select r_object_id from dm_sysobject where FOLDER(ID('"+srcFolder.getObjectId()+"'))";
IDfCollection res = new DfQuery(dql).execute(session, IDfQuery.READ_QUERY);
LinkedList<String> children = new LinkedList<String>();
while (res.next())
children.add(res.getString("r_object_id"));
res.close();