Examples of EntityManager


Examples of com.cloud.utils.db.EntityManager

        return Mockito.mock(EndPointSelector.class);
    }

    @Bean
    public EntityManager entityManager() {
        EntityManager mock = Mockito.mock(EntityManager.class);
        try {
            Mockito.when(mock.findById(Matchers.same(Account.class), Matchers.anyLong())).thenReturn(_accountDao.findById(Account.ACCOUNT_ID_SYSTEM));
            Mockito.when(mock.findById(Matchers.same(User.class), Matchers.anyLong())).thenReturn(_userDao.findById(User.UID_SYSTEM));
            Mockito.when(mock.findById(Matchers.same(NetworkOffering.class), Matchers.any(Long.class))).thenAnswer(new Answer<NetworkOffering>() {
                @Override
                public NetworkOffering answer(final InvocationOnMock invocation) throws Throwable {
                    Long id = (Long)invocation.getArguments()[1];
                    return _networkOfferingDao.findById(id);
                }
            });
            Mockito.when(mock.findById(Matchers.same(IpAddress.class), Matchers.any(Long.class))).thenAnswer(new Answer<IpAddress>() {
                @Override
                public IpAddress answer(final InvocationOnMock invocation) throws Throwable {
                    Long id = (Long)invocation.getArguments()[1];
                    return _ipAddressDao.findById(id);
                }
            });
            Mockito.when(mock.findById(Matchers.same(DataCenter.class), Matchers.any(Long.class))).thenAnswer(new Answer<DataCenter>() {
                @Override
                public DataCenter answer(final InvocationOnMock invocation) throws Throwable {
                    Long id = (Long)invocation.getArguments()[1];
                    return _zoneDao.findById(id);
                }
View Full Code Here

Examples of com.echoeight.bison.entity.EntityManager

    public MainMenuState(Game game, int id) {
    super(id);
    this.game = game;
    WIDTH = game.dm.getWidth();
    HEIGHT = game.dm.getHeight();
    em = new EntityManager();
  }
View Full Code Here

Examples of com.l2client.controller.entity.EntityManager

    return singleton;
  }

  @Override
  public void onUpdateOf(Component c, float tpf) {
    EntityManager em = Singleton.get().getEntityManager();
    if(c instanceof TargetComponent){
      TargetComponent tgt = (TargetComponent)c;
      L2JComponent l2j = (L2JComponent)em.getComponent(em.getEntityId(tgt),L2JComponent.class);
      if(l2j != null && !l2j.isPlayer) {
        //
        // NPC UPDATE
        if(tgt.getCurrentTarget() != tgt.getLastTarget()){ 
          //reset targeting creation changes by setting old target to current
          tgt.setTarget(tgt.getCurrentTarget());
        } else {
          //update position only
          //check if target is set and moved out of distance
          if(!tgt.hasTarget())
            return;
          //TODO distance check only on client side? server still has our last target?
          IdentityComponent e = (IdentityComponent) em.getComponent(tgt.getCurrentTarget(), IdentityComponent.class);
          if(e != null){
            IdentityComponent me = em.getEntity(tgt);
            Entity i = me.getEntity();
            Entity them = e.getEntity();
            if(them != null && i != null){
              //update our target positin (ev. used by others), ev. rotation to target in positioning system
              tgt.pos = them.getLocalTranslation().clone();
            }
          }
        }
        //
        // ENDOF NPC UPDATE
      } else {
        //----------- target changed to new target -----------
        if(tgt.getCurrentTarget() != tgt.getLastTarget()){ 
          //
          // PLAYER UPDATE
            //----------- remove last marked -----------
            if(tgt.getLastTarget() != TargetComponent.NO_TARGET){
              log.fine("Player target changed, removing Selection on:"+tgt.getLastTarget());
              //target was set to a new entity
              //get visual and REMOVE selection from it
              VisualComponent vis = (VisualComponent) em
                .getComponent(tgt.getLastTarget(), VisualComponent.class);
              if(vis!=null){
                if (vis.vis != null) {
                  ((VisibleModel) vis.vis).removeSelectionMarker();
                  log.finest("Player target changed, Selection removed:"+tgt.getLastTarget());
                } else {
                  log.severe("Player target changed, Selection VIS not found on:"+tgt.getLastTarget());
                }
              } else
                log.severe("Player target changed, Selection NO VIS not found on:"+tgt.getLastTarget());

//FIXME this causes side effects with entity deletion, it seems, l2j deletes dead entities quite fast
//              LoggingComponent l = (LoggingComponent) em.getComponent(tgt.getLastTarget(), LoggingComponent.class);
//              if(l != null) {
//                Singleton.get().getPosSystem().removeComponentForUpdate(l);
//                em.removeComponent(tgt.getLastTarget(), l);
//              }
            }
            //----------- set current -----------
            if(tgt.hasTarget()){
              log.fine("Player target changed, adding Selection on:"+tgt.getCurrentTarget());
              //target was set to a new entity
              //get visual and add selection to it
              VisualComponent vis = (VisualComponent) em
                .getComponent(tgt.getCurrentTarget(), VisualComponent.class);
              if (vis != null && vis.vis != null) {
                ((VisibleModel) vis.vis).addSelectionMarker(tgt.color);
                log.fine("Player target changed, Selection added:"+tgt.getCurrentTarget());
              } else {
                log.severe("Player target changed, Selection VIS not found on on:"+tgt.getCurrentTarget());
              }

//FIXME this causes side effects with entity deletion, it seems, l2j deletes dead entities quite fast             
//              LoggingComponent l = (LoggingComponent) em.getComponent(tgt.getCurrentTarget(), LoggingComponent.class);
//              if(l == null){
//                l = new LoggingComponent();
//                em.addComponent(tgt.getCurrentTarget(), l);
//                Singleton.get().getPosSystem().addComponentForUpdate(l);
//              } else {
//                log.severe("Logging comp still on changed ent!!?");
//              }
            } else {
              //reset target creation by setting old target to current
              tgt.setNoTarget();
              tgt.pos = Vector3f.ZERO;
              log.fine("Player target changed, set to NOTARGET");
            }
          //----------- reset targeting creation changes by setting old target to current -----------
          tgt.setTarget(tgt.getCurrentTarget());
          log.fine("Player target changed, setting last to current, current to current target");
        } else {
          //check if target is set and moved out of distance
          if(!tgt.hasTarget())
            return;
          //TODO distance check only on client side? server still has our last target?
          IdentityComponent e = (IdentityComponent) em.getComponent(tgt.getCurrentTarget(), IdentityComponent.class);
          if(e != null){
            IdentityComponent me = em.getEntity(tgt);
            Entity i = me.getEntity();
            Entity them = e.getEntity();
            if(them != null && i != null){
              //update our target positin (ev. used by others)
              tgt.pos = them.getLocalTranslation();
//              if(tgt.pos.distance(i.getLocalTranslation()) > MAX_TARGETING_DISTANCE) {
//                //remove next time in above code
//                tgt.setNoTarget();
//              } else {
                //update health bar of highlighted target
                VisualComponent vis = (VisualComponent) em
                    .getComponent(tgt.getCurrentTarget(), VisualComponent.class);
                if (vis != null && vis.vis != null) {
                  ((VisibleModel) vis.vis).updateHealthbar((float)l2j.l2jEntity.getCurrentHp()/(float)l2j.l2jEntity.getMaxHp());
                }else
                  log.severe("Player target changed, VIS not found on :"+tgt.getCurrentTarget()+" for HealthBar update");
//              }
              //update target information for environment
              EnvironmentComponent env = (EnvironmentComponent) Singleton.get().getEntityManager().getComponent(i.getId(), EnvironmentComponent.class);
              if (env != null) {
                env.changed = true;
                log.finer("Should update stance");
              } else
                log.severe("No EnvironmentComponent found with entity id "
                        + i.getId() + ", perhaps just create one?");
            } else {
              //remove next time in above code
              tgt.setNoTarget();
            }
          } else {
            //remove next time in above code
            tgt.setNoTarget();
          }
        }
      }
      //
      // END OF PLAYER UPDATE
    } else
      if(c instanceof PositioningComponent){
        PositioningComponent com = (PositioningComponent) c;
        IdentityComponent e = em.getEntity(com);
        if(e != null)
        {
          Entity ent = e.getEntity();
          ent.setLocalTranslation(com.position.x, com.position.y+com.heightOffset, com.position.z);
          ent.setLocalRotation(new Quaternion().fromAngleNormalAxis(com.heading, Vector3f.UNIT_Y.negate()));
        } else {
          log.severe("Positioning component without identity component found! comp:"+
              c+" at "+ com.position.x+ ", "+(com.position.y+com.heightOffset)+", "+com.position.z);
          //FIXME this is a workaround, investigate why this can happen! was it added twice? should we better use a hasmap for components
          dumpComponents();
          System.out.println("----- now em ----------");
          em.dumpComponents(em.getEntityId(c));
          em.dumpAllComponents();
          removeComponentForUpdate(com);
        }
//    }else
//      if(c instanceof SimplePositionComponent){
//        SimplePositionComponent com = (SimplePositionComponent) c;
View Full Code Here

Examples of com.pointcliki.core.EntityManager

    if (fManagers != null) return;
       
    // Create the managers
    fResourceManager = new GruntzResourceManager();
    fInputManager = new InputManager();
    fEntityManager = new EntityManager();
   
    // Add to the manager set
    fManagers = new HashMap<Class<? extends Manager>, Manager>();
    fManagers.put(GruntzResourceManager.class, fResourceManager);
    fManagers.put(InputManager.class, fInputManager);
View Full Code Here

Examples of com.teamjmonkey.entity.EntityManager

        effectsManager = new EffectsManager();
        controlManager = new ControlManager();
        preloadManager = new PreloadManager();
        graphicManager = new GraphicManager();
        materialManager = new MaterialManager();
        entityManager = new EntityManager();
        userSettings = new UserSettings();
        monkeyAppStateManager = new MonkeyAppStateManager();
        physicsManager = new PhysicsManager();
        soundManager = new SoundManager();
        animManager = new AnimManager();
View Full Code Here

Examples of games.stendhal.server.core.rule.EntityManager

        final Sheep sheep = new Sheep();
        sheep.setPosition(x, y);
        add(sheep);
      } else if (clazz.contains("logic/creature")) {
        // get the default EntityManager
        final EntityManager manager = SingletonRepository.getEntityManager();

        // Is the entity a creature
        if (manager.isCreature(clazz, type)) {
          final Creature creature = manager.getCreature(clazz, type);
          final CreatureRespawnPoint point = new CreatureRespawnPoint(this,
              x, y, creature, 1);
          add(point);
        } else {
          logger.error("Unknown Entity (class/type: " + clazz + ":"
View Full Code Here

Examples of gwlpr.mapshard.entitysystem.EntityManager

{
    @Test
    public void testEntityManager()
    {
        // create the entity manager
        EntityManager eMan = new EntityManager();
       
        // before adding any entities, try to retrieve some...
        Collection<Entity> ents = eMan.getEntitiesWith(Name.class, AgentIdentifiers.class, Position.class, Direction.class);
        assert ents.isEmpty();
       
        // now lets add some entities
        Name n1 = new Name();
        Name n2 = new Name();
        Name n3 = new Name();
        Name n4 = new Name();

        AgentIdentifiers a1 = new AgentIdentifiers();
        AgentIdentifiers a2 = new AgentIdentifiers();
        AgentIdentifiers a3 = new AgentIdentifiers();

        Position p1 = new Position();
        Position p2 = new Position();
       
        Direction d1 = new Direction();

        // register the entities
        Entity e1 = new Entity(eMan, n1, a1, p1, d1);
        Entity e2 = new Entity(eMan, n2, a2, p2);
        Entity e3 = new Entity(eMan, n3, a3);
        Entity e4 = new Entity(eMan, n4);
        Entity e5 = new Entity(eMan);

        // retrieve entities with specific components
        ents = eMan.getEntitiesWith(Name.class, AgentIdentifiers.class, Position.class, Direction.class);
        assert ents.size() == 1;
        assert ents.contains(e1);

        ents = eMan.getEntitiesWith(Name.class, AgentIdentifiers.class, Position.class);
        assert ents.size() == 2;
        assert ents.contains(e1);
        assert ents.contains(e2);

        ents = eMan.getEntitiesWith(Name.class, AgentIdentifiers.class);
        assert ents.size() == 3;
        assert ents.contains(e1);
        assert ents.contains(e2);
        assert ents.contains(e3);

        ents = eMan.getEntitiesWith(Name.class);
        assert ents.size() == 4;
        assert ents.contains(e1);
        assert ents.contains(e2);
        assert ents.contains(e3);
        assert ents.contains(e4);

        ents = eMan.getEntitiesWith();
        assert ents.isEmpty();

        // retrieve components of specific entities
        Name n = e1.get(Name.class); // e1 has a Name
        assert n == n1;
View Full Code Here

Examples of javax.persistence.EntityManager

    public void persist(Event event) {

        try {

            // get entity manager
            EntityManager entityManager = defaultLocator.locate();

            // It's managed by JACORB
            // Hence we don't deal with the TX here           
            entityManager.persist(event);

        } catch (Exception e) {
            log.error("Error persisting event", e);
        }
View Full Code Here

Examples of javax.persistence.EntityManager

                                Notification notification,
                                List<OrganizationalEntity> recipients,
                                List<OrganizationalEntity> businessAdministrators,
                                WorkItemManager workItemManager,
                                EntityManagerFactory emf) {
        EntityManager em = emf.createEntityManager();
       
        TaskData taskData = task.getTaskData();
       
        // First compile the associated document, we assume this returns a single structure
        // That can be used in the main work item evaluation.
        Content content = null;
        if ( taskData.getDocumentAccessType() == AccessType.Inline ) {
            content = em.find( Content.class,
                               taskData.getDocumentContentId() );
        }
        ExpressionCompiler compiler = new ExpressionCompiler( new String( content.getContent() ) );
        Serializable expr = compiler.compile();
        Object object = MVEL.executeExpression( expr );
View Full Code Here

Examples of javax.persistence.EntityManager

        this.escalatedDeadlineHandler = escalatedDeadlineHandler;
    }

    public void executeEscalatedDeadline(long taskId,
                                         long deadlineId) {
        EntityManager localEm = emf.createEntityManager();
        Task task = localEm.find(Task.class,
                taskId);
        Deadline deadline = localEm.find(Deadline.class,
                deadlineId);

        if (escalatedDeadlineHandler == null) {
            escalatedDeadlineHandler = new DefaultEscalatedDeadlineHandler();
        }

        escalatedDeadlineHandler.executeEscalatedDeadline(task,
                deadline,
                localEm,
                this);
        localEm.close();
    }
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.