/** * @param nameSMD : le Nom de SMD a mettre à jour * @return "SMD Not Found" : si le SMD n'existe pas "Connected OK" : sinon */ @POST @Path("setConnected") public String setConnected( @FormParam("nameSMD") String nameSMD, @FormParam("what") boolean what) { OperationInformationResources.logger.log( Level.INFO, "Connect with (SMD = " + nameSMD + ", what = " + what + " )"); Session connect = HibernateUtil.getSessionFactory().openSession(); SiteSMD smd = SiteSMD.findByName(connect, nameSMD); String result = "SMD Not Found"; if (smd != null) { smd.setConnected(what); connect.beginTransaction(); connect.saveOrUpdate(smd); connect.getTransaction().commit(); result = "Connected OK"; } connect.close(); OperationInformationResources.logger.log(Level.FINEST, "Returned Value " + result); return result; }
/** * @param nameSMD : le Nom de SMD qui a envoyer la requete * @param newVersion : la nouvelle versions (le cas de MAJ) * @return "SMD Not Found" : si le SMD n'existe pas "Version Updated" : sinon */ @POST @Path("setVersion") public String setVersion( @FormParam("nameSMD") String nameSMD, @FormParam("newVersion") String newVersion) { OperationInformationResources.logger.log( Level.INFO, "Version with (SMD = " + nameSMD + ", newVersion = " + newVersion + ")"); Session connect = HibernateUtil.getSessionFactory().openSession(); SiteSMD smd = SiteSMD.findByName(connect, nameSMD); String result = "SMD Not Found"; if (smd != null) { String lst[] = newVersion.split("-"); if (lst.length == 2) { smd.setVersion_code(lst[0]); smd.setVersion_system(lst[1]); connect.beginTransaction(); connect.saveOrUpdate(smd); connect.getTransaction().commit(); result = "Version Updated"; } else { result = "Version Envoyer Incorrect"; } } connect.close(); OperationInformationResources.logger.log(Level.FINEST, "Returned Value " + result); return result; }
@POST @Path("progressSMD") public String setProgressSMD( @FormParam("nameSMD") String nameSMD, @FormParam("id_progress") long idProgress, @FormParam("title") String title, @FormParam("value") double valueProgress) { OperationInformationResources.logger.log( Level.INFO, "NAME: " + nameSMD + " Progress with (id = " + idProgress + ", etat = " + valueProgress + ") \n contenu " + title); String result = "Progress with (id = " + idProgress + ", etat = " + valueProgress + ")"; Session connect = HibernateUtil.getSessionFactory().openSession(); if (idProgress < 0) { result += " PROBLEM ID <0"; } else { if (valueProgress < 0) { SiteSMD site = SiteSMD.findByName(connect, nameSMD); site.setHave_a_probleme(true); connect.beginTransaction(); connect.saveOrUpdate(site); connect.getTransaction().commit(); } ProgressData getProgress = ProgressData.findById(connect, idProgress); if (getProgress != null) { // remplire DATA getProgress.setTitle(title); getProgress.setValue(valueProgress); getProgress.setLast_date(Calendar.getInstance().getTime()); if (valueProgress == 100) { getProgress.setFinished(true); } connect.beginTransaction(); connect.saveOrUpdate(getProgress); connect.getTransaction().commit(); result = "Status is updated"; } else { // remplire DATA SiteSMD site = SiteSMD.findByName(connect, nameSMD); if (site == null) { result = "SMD Not Found"; } else { getProgress = new ProgressData(); getProgress.setId(idProgress); getProgress.setTitle(title); getProgress.setValue(valueProgress); getProgress.setLast_date(Calendar.getInstance().getTime()); if (valueProgress == 100) { getProgress.setFinished(true); } getProgress.setSmd(site); connect.beginTransaction(); connect.save(getProgress); connect.getTransaction().commit(); result = "Status is updated"; } } } connect.close(); OperationInformationResources.logger.log(Level.FINEST, "Returned Value " + result); return result; }