/**
   * Send the Cared Person current Plan as XML. The method receciedCaredPersonStatus and this method
   * will be a synchronous call. Logic :
   *
   * <p>1. ReCalc the Rx State and send the updated Rx Snapshot to CaredPerson 2. Assess the
   * CaredPerson health status a. Alert CareGiver b. Alert Physician c. Send a message to
   * CaredPerson - something how they are doing on their progress.
   */
  public StringBuffer sendCaredPersonCurrentRxPlan(Long caredPersonKey) throws Exception {

    ICareDAO _careDAO = getCareDAO();
    Key _key = Datastore.createKey(CaredPerson.class, caredPersonKey);
    CaredPerson _caredPerson = _careDAO.loadCaredPerson(_key);

    IPrescriptionDAO _iRxDAO = getPrescriptionDAO();
    List<Prescription> _prescriptionList =
        _iRxDAO.loadPrescriptionsByCaredPerson(_caredPerson.getKey());
    ArrayList<Prescription> _updPrescriptionList = new ArrayList<Prescription>();

    for (Iterator<Prescription> iterator = _prescriptionList.iterator(); iterator.hasNext(); ) {
      Prescription _prescriptionIn = (Prescription) iterator.next();

      // Expire the Rx Lines before use

      _iRxDAO.expireRxLines(_prescriptionIn.getKey());

      List<PrescriptionLines> _rxLines =
          _iRxDAO.loadPrescriptionLines(_prescriptionIn.getKey(), false);
      _prescriptionIn.setPrescriptionLines(_rxLines);
      _updPrescriptionList.add(_prescriptionIn);
      iterator.remove();
    }

    _caredPerson.setPrescription(_updPrescriptionList);

    /**
     * Temp fix to show only default symptoms List<PreExistingCondition> _preExCondList = _careDAO
     * .loadAllPreExistingConditonsForCaredPerson(_caredPerson .getKey());
     */

    // @todo Temp fix start : Hard coded to show only default predcondition
    CommonPreExistingDiseases _defaultCommonDisease =
        _careDAO.loadDefaultCommonPreExistingDisease();
    PreExistingCondition _preExCond = new PreExistingCondition();
    // All the default condition to have a hard key of 999999
    // It is not store in the database
    Key _preconditionkey = Datastore.createKey(PreExistingCondition.class, new Long(999999));
    _preExCond.setKey(_preconditionkey);
    _preExCond.getPreExisitingDiseases().setModel(_defaultCommonDisease);
    _preExCond.getCaredPerson().setModel(_caredPerson);

    ArrayList<PreExistingCondition> _preExCondList = new ArrayList<PreExistingCondition>();
    _preExCondList.add(_preExCond);
    // @todo Temp Fix End

    _caredPerson.setPreExistingCondition(_preExCondList);

    EmergencyResponse _emResponse =
        _careDAO.loadEmergemcyResponseForCaredPerson(_caredPerson.getKey());
    _caredPerson.setEmergencyResponse(_emResponse);

    StringBuffer _xml = MobileDataExchangeHelper.fillCaredPersonData(_caredPerson);

    return _xml;
  }
Exemplo n.º 2
0
  public static void putDisplayName(String displayName) throws JEDuplicateException {
    final String UNIQUE_KEY_DISPLAY_NAME = "UniqueKeyDisplayName";
    final User user = getUser();
    final Key key = Datastore.createKey(JEUser.class, user.getEmail());
    if (Datastore.putUniqueValue(UNIQUE_KEY_DISPLAY_NAME, displayName) == false) {
      throw new JEDuplicateException("the display name is already used");
    }
    Transaction tx = Datastore.beginTransaction();
    try {
      JEUser jeUser = Datastore.getOrNull(tx, JEUser.class, key);
      final long now = new Date().getTime();
      if (jeUser == null) {
        jeUser = new JEUser();
        jeUser.setKey(key);
        jeUser.setCreatedAt(now);
      }
      jeUser.setDisplayName(displayName);
      jeUser.setUpdatedAt(now);
      Datastore.put(tx, jeUser);

      // TODO: Run TQ to update past's memos.

      Datastore.commit(tx);

    } catch (Exception e) {
      Datastore.rollback(tx);
      Datastore.deleteUniqueValue(UNIQUE_KEY_DISPLAY_NAME, displayName);
    }
  }
 @DELETE
 @Path("{id}")
 @Consumes({MediaType.APPLICATION_JSON})
 public void delete(@PathParam("id") Long id) {
   log.info("delete:" + id);
   Datastore.delete(Datastore.createKey(ShopModel.class, id));
 }
  @Override
  public Navigation run() throws Exception {

    Validators v = new Validators(request);
    v.add("id", v.longType());
    v.add("salary", v.required(), v.integerType());
    if (!v.validate()) {
      System.out.println("validation error: " + errors);
      return null;
    }

    long id = asLong("id");
    int salary = asInteger("salary");

    Key key = Datastore.createKey(Employee.class, id);
    Transaction tx = Datastore.beginTransaction();
    try {
      Employee e = Datastore.get(tx, Employee.class, key);
      e.setSalary(salary);
      Datastore.put(tx, e);
      tx.commit();
    } finally {
      if (tx.isActive()) {
        tx.rollback();
      }
    }

    return forward("updateSalary.jsp");
  }
Exemplo n.º 5
0
  @Override
  public void setUp() throws Exception {
    super.setUp();
    account = new Account();
    account.setKey(Datastore.createKey(Account.class, 1));
    Datastore.put(account);

    discussions = new ArrayList<Submission>();
    for (int i = 0; i < 10; i++) {
      Submission submission = new Submission();
      submission.setTitle("title" + i);
      submission.setDescription("description" + i);
      submission.setAuthor(Datastore.createKey(Account.class, i + 1));
      submission.setAuthorName("author" + i);
      discussions.add(submission);
    }
    Datastore.put(discussions);
  }
Exemplo n.º 6
0
 public static String getDisplayName() {
   final User user = getUser();
   if (user == null) {
     return null;
   }
   Key key = Datastore.createKey(JEUser.class, user.getEmail());
   JEUser jeUser = Datastore.getOrNull(JEUser.class, key);
   return (jeUser == null) ? null : jeUser.getDisplayName();
 }
 @PUT
 @Path("{id}")
 @Consumes({MediaType.APPLICATION_JSON})
 public void update(@PathParam("id") Long id, Shop shop) {
   log.info("put:" + id + " " + shop.getName());
   Key key = Datastore.createKey(ShopModel.class, id);
   ShopModel shopModel = Datastore.get(ShopModel.class, key);
   shopModel.setName(shop.getName());
   Datastore.put(shopModel);
 }
Exemplo n.º 8
0
 @Test
 public void testSearchFromKey() throws Exception {
   Member m = memberSvc.searchFromId("test1");
   Practice p =
       practiceSvc.searchFromStartDateTime(
           DateUtil.toDate("2010-10-01T10:00:00", DateUtil.ISO_DATE_TIME_PATTERN));
   assertNotNull(service.searchFromKey(service.generateKey(m.getKey(), p.getKey())));
   assertNull(service.searchFromKey(Datastore.createKey(Attendance.class, "XXX")));
   assertNull(service.searchFromKey(null));
 }
 @GET
 @Path("{id}")
 @Produces("application/x-javascript")
 public JSONWithPadding get(
     @PathParam("id") Long id, @QueryParam("jsoncallback") @DefaultValue("fn") String callback) {
   log.info("get:" + id);
   Key key = Datastore.createKey(ShopModel.class, id);
   ShopModel shopModel = Datastore.get(ShopModel.class, key);
   Shop shop = new Shop(shopModel);
   return new JSONWithPadding(shop, callback);
 }
Exemplo n.º 10
0
  @Override
  public Navigation run() throws Exception {

    Employee employee = new Employee();
    employee.setKey(Datastore.createKey(Employee.class, 9999));
    employee.setName("ŽÐ’{Žl˜Y");
    employee.setDeptId(1L);
    Key key = Datastore.put(employee);
    requestScope("key", key);

    return forward("create2.jsp");
  }
  @Override
  public Navigation run() throws Exception {

    Integer id = asInteger("id");
    if (id != null) {
      Key key = Datastore.createKey(PrizeRule.class, id);

      GlobalTransaction tx = Datastore.beginGlobalTransaction();
      Datastore.delete(key);
      tx.commit();

    } else {
      return redirect("prizeRules");
    }
    return redirect("prizeRules");
  }
Exemplo n.º 12
0
 @Override
 public Navigation run() throws Exception {
   // Se il parametro non � vuoto
   if (!request.getParameter("imgId").equals("")) {
     long imgId = Long.parseLong((String) request.getParameter("imgId"));
     Key imgKey = Datastore.createKey(Photo.class, imgId);
     Photo photo = service.getPhoto(imgKey);
     if (photo != null) {
       // Set the appropriate Content-Type header and write the raw bytes
       // to the response's output stream
       response.setContentType("image/jpeg");
       response.getOutputStream().write(photo.getBytes());
     }
   } else {
     // If no image is found with the given title, redirect the user to
     // a static image
     response.sendRedirect("/resources/noimage.jpg");
   }
   return null;
 }
Exemplo n.º 13
0
  @Override
  protected Map<String, Object> handle() throws Exception {
    Map<String, Object> result = new HashMap<String, Object>();
    String id = request.getParameter("id");
    String name = request.getParameter("name");
    String category = request.getParameter("category");

    Joshi joshi = service.findJoshi(id);
    if (joshi != null) {
      Transaction tx = Datastore.beginTransaction();
      if (!Utils.isNull(name)) {
        joshi.setName(name);
      }
      if (!Utils.isNull(category)) {
        joshi.setCategory(category);
      }
      Datastore.put(joshi);
      tx.commit();
    } else {
      Transaction tx = Datastore.beginTransaction();
      joshi = new Joshi();
      Key key = Datastore.createKey(Joshi.class, id);
      joshi.setKey(key);
      joshi.setKawaii(0);
      if (!Utils.isNull(name)) {
        joshi.setName(name);
      }
      if (!Utils.isNull(category)) {
        joshi.setCategory(category);
      }
      Datastore.put(joshi);
      tx.commit();
    }

    result.put("result", "true");
    return result;
  }
Exemplo n.º 14
0
 private static Key createKey(String userID) {
   return Datastore.createKey(UserModelMeta.get(), userID);
 }
Exemplo n.º 15
0
 public Item(long id, String name, int price) {
   setKey(Datastore.createKey(Item.class, id));
   setName(name);
   setPrice(price);
 }
Exemplo n.º 16
0
 public GameData getGameData(Long id) {
   return Datastore.get(GameData.class, Datastore.createKey(GameData.class, id));
 }
Exemplo n.º 17
0
  public GameData load(long id) {

    return Datastore.get(GameData.class, Datastore.createKey(GameData.class, id));
  }
Exemplo n.º 18
0
 /*
  * (non-Javadoc)
  *
  * @see yanitime4u.yanitime.logic.UserLogic#findByKey(java.lang.Long)
  */
 @Override
 public Users findByKey(Long id) {
   AssertionUtil.assertNotNull(id);
   Key key = Datastore.createKey(Users.class, id);
   return Datastore.get(meta, key);
 }