コード例 #1
0
  public Response processInsert(ObjectList insert) {
    // EntityTransaction tx = null;
    // EntityManager em = null;
    Response response = null;
    mapper = new CreateObjectsFromXml(requestCredentials, insert, null);
    try { // add objects to database

      // em = MorphbankConfig.getEntityManager();
      // tx = em.getTransaction();
      // tx.begin();
      response = mapper.processObjects();
      // tx.commit();
    } catch (Exception e) {
      e.printStackTrace();
      mapper.reportSuccess(null, null);
      // if (tx.isActive()) {
      // tx.rollback();
      // }
    }
    return finalizeResponse(mapper.getResponse());
  }
コード例 #2
0
 public Response processUpdate(Credentials requestCredentials, ObjectList update) {
   EntityTransaction tx = null;
   EntityManager em = null;
   boolean localTransaction = false;
   mapper =
       new UpdateObjectsFromXml(requestCredentials, update, MorphbankConfig.getRemoteServer());
   try { // add objects to database
     // TODO process updates one object per transaction!
     //			em = MorphbankConfig.getEntityManager();
     //			tx = em.getTransaction();
     //			if (!tx.isActive()) {
     //				localTransaction = true;
     //				tx.begin();
     //			}
     mapper.processObjects();
     //			if (localTransaction) tx.commit();
   } catch (Exception e) {
     e.printStackTrace();
     mapper.reportSuccess(null, null);
     if (localTransaction) tx.rollback();
   }
   return finalizeResponse(mapper.getResponse());
 }