Examples of PersistenceService


Examples of com.krminc.phr.dao.PersistenceService

     * @return an instance of TemperatureConverter
     */
    @GET
    @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
    public TemperatureConverter get() {
        PersistenceService persistenceSvc = PersistenceService.getInstance();
        try {
            persistenceSvc.beginTx();
            return new TemperatureConverter(getEntity(), uriInfo.getAbsolutePath(), Api.DEFAULT_EXPAND_LEVEL);
        } finally {
            PersistenceService.getInstance().close();
        }
    }
View Full Code Here

Examples of com.krminc.phr.dao.PersistenceService

        }
        catch(NullPointerException ex) {
            throw new WebApplicationException(Response.Status.FORBIDDEN);
        }
       
        PersistenceService persistenceSvc = PersistenceService.getInstance();
        try {
            //check updateable
            if (getEntity().getDataSourceId() != 1) {
                throw new WebApplicationException(Response.Status.FORBIDDEN);
            }

            if (data.hasError) {
                throw new WebApplicationException(Response.Status.PRECONDITION_FAILED);
            }

            persistenceSvc.beginTx();
            EntityManager em = persistenceSvc.getEntityManager();
            updateEntity(getEntity(), data.resolveEntity(em));
            persistenceSvc.commitTx();
        } finally {
            persistenceSvc.close();
        }
    }
View Full Code Here

Examples of com.krminc.phr.dao.PersistenceService

        }
        catch(NullPointerException ex) {
                throw new WebApplicationException(Response.Status.FORBIDDEN);
        }

        PersistenceService persistenceSvc = PersistenceService.getInstance();
        try {
            //check updateable
            if (getEntity().getDataSourceId() != 1) {
                throw new WebApplicationException(Response.Status.FORBIDDEN);
            }

            persistenceSvc.beginTx();
            deleteEntity(getEntity());
            persistenceSvc.commitTx();
        } finally {
            persistenceSvc.close();
        }
    }
View Full Code Here

Examples of com.krminc.phr.dao.PersistenceService

  }
  catch(NullPointerException ex) {
    throw new WebApplicationException(Response.Status.FORBIDDEN);
  }

        PersistenceService persistenceSvc = PersistenceService.getInstance();
        try {
            //check updateable
            if (getEntity().getDataSourceId() != 1) {
                throw new WebApplicationException(Response.Status.FORBIDDEN);
            }
           
            persistenceSvc.beginTx();
            deleteEntity(getEntity());
            persistenceSvc.commitTx();
        } finally {
            persistenceSvc.close();
        }
    }
View Full Code Here

Examples of com.krminc.phr.dao.PersistenceService

            @QueryParam("max") @DefaultValue("10") int max,
            @QueryParam("source") @DefaultValue("self") String source,
            @QueryParam("orderBy") @DefaultValue("dateadded") String orderBy,
            @QueryParam("desc") @DefaultValue("1") int desc)
    {
        PersistenceService persistenceSvc = PersistenceService.getInstance();
        try {
            persistenceSvc.beginTx();
            return new PainsConverter(
                getEntities(start, max, source, orderBy, desc),
                uriInfo.getAbsolutePath(),
                Api.DEFAULT_EXPAND_LEVEL
            );
        } finally {
            persistenceSvc.commitTx();
            persistenceSvc.close();
        }
    }
View Full Code Here

Examples of com.krminc.phr.dao.PersistenceService

        }
        catch(NullPointerException ex) {
            throw new WebApplicationException(Response.Status.FORBIDDEN);
        }

        PersistenceService persistenceSvc = PersistenceService.getInstance();
        try {
            if (data.hasError) {
                throw new WebApplicationException(Response.Status.PRECONDITION_FAILED);
            }
           
            persistenceSvc.beginTx();
            EntityManager em = persistenceSvc.getEntityManager();
            Pain entity = data.resolveEntity(em);
            createEntity(data.resolveEntity(em));
            persistenceSvc.commitTx();
            return Response.created(uriInfo.getAbsolutePath().resolve(entity.getPainId() + "/")).build();
        } finally {
            persistenceSvc.close();
        }
    }
View Full Code Here

Examples of com.krminc.phr.dao.PersistenceService

     * @return an instance of BloodSugarConverter
     */
    @GET
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public BloodSugarConverter get() {
        PersistenceService persistenceSvc = PersistenceService.getInstance();
        try {
            persistenceSvc.beginTx();
            return new BloodSugarConverter(getEntity(), uriInfo.getAbsolutePath(), Api.DEFAULT_EXPAND_LEVEL);
        } finally {
            PersistenceService.getInstance().close();
        }
    }
View Full Code Here

Examples of com.krminc.phr.dao.PersistenceService

        }
        catch(NullPointerException ex) {
            throw new WebApplicationException(Response.Status.FORBIDDEN);
        }

        PersistenceService persistenceSvc = PersistenceService.getInstance();
        try {
            //check updateable
            if (getEntity().getDataSourceId() != 1) {
                throw new WebApplicationException(Response.Status.FORBIDDEN);
            }

            if (data.hasError) {
                throw new WebApplicationException(Response.Status.PRECONDITION_FAILED);
            }

            persistenceSvc.beginTx();
            EntityManager em = persistenceSvc.getEntityManager();
            updateEntity(getEntity(), data.resolveEntity(em));
            persistenceSvc.commitTx();
        } finally {
            persistenceSvc.close();
        }
    }
View Full Code Here

Examples of com.wideplay.warp.persist.PersistenceService

@RunWith(Enclosed.class)
public class HibernateInitializerTest {
  public static class Creating_A_Hibernate_Initializer {
    @Test
    public void itStartsAPersistenceService() throws Exception {
      final PersistenceService service = mock(PersistenceService.class);
     
      final Injector injector = Guice.createInjector(new AbstractModule() {
        @Override
        protected void configure() {
          bind(PersistenceService.class).toInstance(service);
View Full Code Here

Examples of com.wordpress.salaboy.model.persistence.PersistenceService

    @Test
    public void simpleAPIPlusCypherQueryTest() throws IOException {
        PersistenceServiceProvider.configFile = "local-config-beans.xml";
        ContextTrackingProvider.configFile = "local-config-beans.xml";
        PersistenceService persistenceService = PersistenceServiceProvider.getPersistenceService();
        ContextTrackingService trackingService = ContextTrackingProvider.getTrackingService();
       
       
        Call call = new Call(1, 1, new Date());
        persistenceService.storeCall(call);
       
        assertNotSame("", call.getId());

        call = persistenceService.loadCall(call.getId());
        assertNotNull(call);

        Emergency emergency = new Emergency();
        persistenceService.storeEmergency(emergency);
        assertNotSame("", emergency.getId());

        emergency = persistenceService.loadEmergency(emergency.getId());
        assertNotNull(emergency);
       
        trackingService.attachEmergency(call.getId(), emergency.getId());

        Procedure procedure = new Procedure("MyProcedure");
        persistenceService.storeProcedure(procedure);
        assertNotSame("", procedure.getId());

        procedure = persistenceService.loadProcedure(procedure.getId());
        assertNotNull(procedure);

        trackingService.attachProcedure(emergency.getId(), procedure.getId());


        Vehicle vehicle = new Ambulance();

        persistenceService.storeVehicle(vehicle);
        assertNotSame("", vehicle.getId());

        vehicle = persistenceService.loadVehicle(vehicle.getId());
        assertNotNull(vehicle);


        trackingService.attachVehicle(procedure.getId(), vehicle.getId());

        Vehicle vehicle2 = new FireTruck();
        persistenceService.storeVehicle(vehicle2);
        assertNotSame("", vehicle2.getId());

        vehicle2 = persistenceService.loadVehicle(vehicle2.getId());
        assertNotNull(vehicle2);

        trackingService.attachVehicle(procedure.getId(), vehicle2.getId());

        ServiceChannel channel = new ServiceChannel("MyChannel");
        persistenceService.storeServiceChannel(channel);
        assertNotSame("", channel.getId());
       
        channel = persistenceService.loadServiceChannel(channel.getId());
        assertNotNull(channel);
       
        trackingService.attachServiceChannel(emergency.getId(), channel.getId());

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.