Package systole.synchronization.remote.entities

Examples of systole.synchronization.remote.entities.MedicineRemote


        try {
            this.logger.logDebug("getting medicine by remote id");
            Session currentSession = FacadeDB.getInstance().getCurrentSession();
            Criteria criteria = currentSession.createCriteria(
                    MedicineRemote.class).add(Restrictions.eq("remoteId", remoteId)).setMaxResults(1);
            MedicineRemote medicineRemote = (MedicineRemote) criteria.uniqueResult();
            this.logger.logDebug("get successfully");
            return (medicineRemote != null ? medicineRemote.getMedicine() : null);
        } catch (HibernateException e) {
            this.logger.logError("error on get medicine by remote id, msg: " + e.getMessage());
            throw new ExceptionDAO("No se pudieron obtener los medicamentos", e.fillInStackTrace());
        }
    }
View Full Code Here


        try {
            this.logger.logDebug("getting medicine remote by local medicine");
            Session currentSession = FacadeDB.getInstance().getCurrentSession();
            Criteria criteria = currentSession.createCriteria(
                    MedicineRemote.class).add(Restrictions.eq("medicine", medicine)).setMaxResults(1);
            MedicineRemote medicineRemote = (MedicineRemote) criteria.uniqueResult();
            this.logger.logDebug("get successfully");
            return medicineRemote;
        } catch (HibernateException e) {
            this.logger.logError("error on get remote medicine by medicine, msg: " + e.getMessage());
            throw new ExceptionDAO("No se pudieron obtener los medicamentos", e.fillInStackTrace());
View Full Code Here

        try {
            this.logger.logDebug("getting last remote medicine sync");
            Session currentSession = FacadeDB.getInstance().getCurrentSession();
            Criteria criteria = currentSession.createCriteria(
                    MedicineRemote.class).addOrder(Order.desc("remoteId")).setMaxResults(1);
            MedicineRemote medicineRemote = (MedicineRemote) criteria.uniqueResult();
            this.logger.logDebug("get successfully");
            return (medicineRemote != null ? medicineRemote.getRemoteId() : -1);
        } catch (HibernateException e) {
            this.logger.logError("error on get last remote medicine synchronized, msg: " + e.getMessage());
            throw new ExceptionDAO("No se pudieron obtener los medicamentos", e.fillInStackTrace());
        }
    }
View Full Code Here

                Medicine medicine = medicinesToUpload.next();
                MedicineWs medicineWs = this.toRemoteEntity.generateRemoteMedicine(medicine);
                if (medicineWs != null) {
                    int remoteId = this.systoleSync.uploadMedicine(medicineWs);
                    if (remoteId > 0) {
                        MedicineRemote medicineRemote = new MedicineRemote(medicine);
                        medicineRemote.setRemoteId(remoteId);
                        FacadeDB.getInstance().startTransaction();
                        FacadeDB.getInstance().getMedicineSyncBroker().saveMedicineRemote(medicineRemote);
                        FacadeDB.getInstance().commitTransaction();
                    }
                }
View Full Code Here

    private PatientMedicineWs convertToRemoteMedicinePatient(MedicinePatient medicinePatient) throws ExceptionDAO {
        if (medicinePatient == null) {
            return null;
        }

        MedicineRemote medicineRemote = FacadeDB.getInstance().getMedicineSyncBroker().getMedicineRemoteByMedicine(medicinePatient.getMedicine());
        if (medicineRemote == null) {
            return null;
        }
        PatientMedicineWs patientMedicineWs = new PatientMedicineWs();
        patientMedicineWs.setAgeAtStart(medicinePatient.getAgeAtStartAsInteger() > 0 ? medicinePatient.getPatient().getAge() - medicinePatient.getAgeAtStartAsInteger() : 0);
        patientMedicineWs.setDosage(medicinePatient.getDosage());
        patientMedicineWs.setMedicineId(medicineRemote.getRemoteId());
        return patientMedicineWs;
    }
View Full Code Here

        if (medicine == null) {
            medicine = new Medicine();
            medicine.setName(medicineWS.getName());
            medicine.setDescription(medicine.getDescription());
            FacadeDB.getInstance().getMedicineBroker().insert(medicine);
            MedicineRemote medicineRemote = new MedicineRemote(medicine);
            medicineRemote.setRemoteId(medicineWS.getId());
            FacadeDB.getInstance().getMedicineSyncBroker().saveMedicineRemote(medicineRemote);
        } else {
            if (FacadeDB.getInstance().getMedicineSyncBroker().getMedicineRemoteByMedicine(medicine) == null) {
                MedicineRemote medicineRemote = new MedicineRemote(medicine);
                medicineRemote.setRemoteId(medicineWS.getId());
                FacadeDB.getInstance().getMedicineSyncBroker().saveMedicineRemote(medicineRemote);
            }
        }
        FacadeDB.getInstance().commitTransaction();
    }
View Full Code Here

TOP

Related Classes of systole.synchronization.remote.entities.MedicineRemote

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.