public static GroupPersistence convert(GroupDescriptor gd){
if(gd==null){
return null;
}
GroupPersistence persist=new GroupPersistence();
JSONArray resArray=new JSONArray();
for(Map<String, String> map:gd.getResources()){
JSONObject o=new JSONObject();
for(String key:map.keySet()){
o.put(key, map.get(key));
}
resArray.add(o);
}
persist.setResources(resArray.toString());
JSONObject object=new JSONObject();
for(Object key:gd.getProperties().keySet()){
object.put(key, gd.getProperties().get(key.toString()));
}
persist.setConfigs(object.toString());
persist.setDescr(gd.getDesc());
persist.setDirectory(gd.isDirectory()?0:1);
if(gd.getId()!=null){
persist.setId(Integer.valueOf(gd.getId()));
}
persist.setName(gd.getName());
persist.setOwner(gd.getOwner());
persist.setParent(gd.getParent()==null?null:Integer.valueOf(gd.getParent()));
return persist;
}