if(resultsTmp.size() >= 1 )
{
DaoCommunityClan2 myPrevDaoCommunityClan = resultsTmp.get(0);
//construction de la hashMap des id et name du ser
CommunityClan prevCommunityClan = TransformDtoObject.TransformCommunityDaoCommunityClanToCommunityClan(myPrevDaoCommunityClan);
if (prevCommunityClan != null) {
DataCommunityClan myDataCommunityClan = prevCommunityClan.getData();
List<DataCommunityClanMembers> listClanMembers = myDataCommunityClan.getMembers();
for (DataCommunityClanMembers dataClanMember : listClanMembers) {
for (DataCommunityMembers member : dataClanMember.getMembers()) {
log.warning("previous member " + member.getAccount_name() + " " + member.getAccount_id() );
String idUser = member.getAccount_id();
//log.warning("Previous User " + member.getAccount_name());
mapPrevDaoMembers.put(idUser, member.getAccount_name());
}
}//for (DataCommunityClanMembers
} else {
log.severe("Erreur de parse sur myPrevDaoCommunityClan");
}
//recup des membres courant
if (mapPrevDaoMembers != null && mapPrevDaoMembers.size() > 0 ) {
CommunityClan currentCommunityClan = TransformDtoObject.TransformCommunityDaoCommunityClanToCommunityClan(daoCommunityClan);
if (currentCommunityClan != null) {
DataCommunityClan myDataCommunityClan = currentCommunityClan.getData();
List<DataCommunityClanMembers> listClanMembers = myDataCommunityClan.getMembers();
for (DataCommunityClanMembers dataClanMember : listClanMembers) {
for (DataCommunityMembers member : dataClanMember.getMembers()) {
log.warning("member " + member.getAccount_name() + " " + member.getAccount_id() );
String idUser = member.getAccount_id();
//log.warning("Previous User " + member.getAccount_name());
mapCurrentDaoMembers.put(idUser, member.getAccount_name());
}
}//for (DataCommunityClanMembers
} else {
log.severe("Erreur de parse sur currentCommunityClan");
}
}
//comparaison des 2 liste de users
Set<Entry<String, String>> entryCurrentDaoMembers = mapCurrentDaoMembers.entrySet();
Set<Entry<String, String>> entryPrevDaoMembers = mapPrevDaoMembers.entrySet();
String userAdded = "";
String userDeleted = "";
for(Entry<String, String> entryCurrentDaoMember : entryCurrentDaoMembers) {
if (!mapPrevDaoMembers.containsKey(entryCurrentDaoMember.getKey()) ) {
//joueur nouveau ds Clan
log.warning("joueur ajouté " + entryCurrentDaoMember.getValue());
userAdded = userAdded + " " + entryCurrentDaoMember.getValue();
}else {
log.warning("joueur deja la " + entryCurrentDaoMember.getValue());
}
}
for(Entry<String, String> entryPrevDaoMember : entryPrevDaoMembers) {
if (!mapCurrentDaoMembers.containsKey(entryPrevDaoMember.getKey())) {
//Joueur parti du clan
log.warning("joueur parti du clan " + entryPrevDaoMember.getValue());
userDeleted = userDeleted + " " + entryPrevDaoMember.getValue();
}else {
log.warning("joueur tjrs la " + entryPrevDaoMember.getValue());
}
}
daoCommunityClan.setUserAdded(userAdded);
daoCommunityClan.setUserDeleted(userDeleted);
}
}
catch(Exception e){
e.printStackTrace();
log.log(Level.SEVERE, "Exception while saving daoCommunityClan", e);
pm.currentTransaction().rollback();
}
//On persist le clan et ses joueurs pour trouver ceux qui partent et qui arrivent
//pm = PMF.get().getPersistenceManager();
pm =null;
pm = PMF.get().getPersistenceManager();
try {
pm.currentTransaction().begin();
pm.makePersistent(daoCommunityClan);
pm.currentTransaction().commit();
}
catch(Exception e){
e.printStackTrace();
log.log(Level.SEVERE, "Exception while saving daoCommunityClan", e);
pm.currentTransaction().rollback();
}
//construction de la hashMap des id et name du ser
CommunityClan communityClan = TransformDtoObject.TransformCommunityDaoCommunityClanToCommunityClan(daoCommunityClan);
if (communityClan != null) {
DataCommunityClan myDataCommunityClan = communityClan.getData();
List<DataCommunityClanMembers> listClanMembers = myDataCommunityClan.getMembers();
for (DataCommunityClanMembers dataClanMember : listClanMembers) {
for (DataCommunityMembers member : dataClanMember.getMembers()) {
log.warning("membermember " + member.getAccount_name() + " " + member.getAccount_id() );