コード例 #1
0
  private void initMaps(Model model) {
    // TODO: decide whether caching here is okay
    EnterpriseBeans allBeans = getBundleDescriptor().getEnterpriseBeans();
    Entity[] entityBeans = allBeans.getEntity();
    int i, count = ((entityBeans != null) ? entityBeans.length : 0);
    DevelopmentNameMapper mapper = getNameMapper();

    for (i = 0; i < count; i++) {
      Entity ejb = entityBeans[i];

      if (Entity.PERSISTENCE_TYPE_CONTAINER.equals(ejb.getPersistenceType())) {
        String ejbName = ejb.getEjbName();

        // cache entity objects by name
        entityMap.put(ejbName, ejb);

        // cache cmp/cmr fields by ejb name
        cmpFieldMap.put(ejbName, mapper.getFieldsForEjb(ejbName));

        // collect all keys
        ejbKeyMap.put(ejbName, getPKFields(model, ejb));
      }
    }

    initRelationshipMap();
  }
コード例 #2
0
 public void func_994_a(Entity entity, AxisAlignedBB axisalignedbb, List list) {
   int i = MathHelper.func_1108_b((axisalignedbb.field_1697_b - 2D) / 16D);
   int j = MathHelper.func_1108_b((axisalignedbb.field_1702_e + 2D) / 16D);
   if (i < 0) {
     i = 0;
   }
   if (j >= field_1528_m.length) {
     j = field_1528_m.length - 1;
   }
   for (int k = i; k <= j; k++) {
     List list1 = field_1528_m[k];
     for (int l = 0; l < list1.size(); l++) {
       Entity entity1 = (Entity) list1.get(l);
       if (entity1 == entity || !entity1.field_601_au.func_1178_a(axisalignedbb)) {
         continue;
       }
       list.add(entity1);
       Entity aentity[] = entity1.func_40048_X();
       if (aentity == null) {
         continue;
       }
       for (int i1 = 0; i1 < aentity.length; i1++) {
         Entity entity2 = aentity[i1];
         if (entity2 != entity && entity2.field_601_au.func_1178_a(axisalignedbb)) {
           list.add(entity2);
         }
       }
     }
   }
 }
コード例 #3
0
 public void fireSimEvent() {
   SimEvent se = new SimEvent(this, entity.getTimeNow());
   for (Iterator<?> i = listeners.iterator(); i.hasNext(); ) {
     ((SimEventListener) i.next()).simEventOccurred(se);
   }
   entity.schedule("fireSimEvent", period);
 }
コード例 #4
0
  private Collection getPKFields(Model model, Entity ejb) {
    String pkeyField = ejb.getPrimkeyField();
    String primaryKeyClass = ejb.getPrimKeyClass();
    Set pkeyFields = new HashSet();

    if (!StringHelper.isEmpty(pkeyField)) // primkey-field was set
    pkeyFields.add(pkeyField);
    else if (!primaryKeyClass.equals("java.lang.Object")) {
      // get fields of primaryKeyClass
      Iterator iterator = model.getAllFields(primaryKeyClass).iterator();

      while (iterator.hasNext()) {
        // ignore static or final fields
        String fieldName = (String) iterator.next();
        int m = model.getModifiers(model.getField(primaryKeyClass, fieldName));

        if (Modifier.isStatic(m) || Modifier.isFinal(m)) continue;
        pkeyFields.add(fieldName);
      }
    } else {
      // this is the case of unknown pk - use generated name
      pkeyFields.add(getGeneratedPKFieldName());
    }

    return pkeyFields;
  }
コード例 #5
0
  /**
   * Base tick method for the level. Updates all entities, tiles, and player. Has slow repopulation
   * algorithm
   */
  public void tick() {
    player.tick();
    List<Entity> toTick = new ArrayList<Entity>();
    int lr = 7;
    for (int x = -lr; x < lr; x++) {
      for (int y = -lr; y < lr; y++) {
        Tile tile = getTile(player.x + x, player.z + y);
        tile.addToTick(toTick);
        tile.tick();
      }
    }

    for (int i = 0; i < toTick.size(); i++) {
      Entity e = toTick.get(i);
      e.tick(this);
    }
    tickcount++;
    if (tickcount % 1800 == 0) {
      System.out.println("Adding entity to world");
      if (r != null) {
        int rx = r.nextInt(w);
        int ry = r.nextInt(h);

        if (skillNoise.noise(rx / 80d, ry / 80d) > 0.0) {
          SmallMob mob = new SmallMob();
          if (!tiles[rx + ry * w].blocks(mob)) {
            tiles[rx + ry * w].addEntity(r.nextInt(4), mob);
          }
        }
      }
    }
  }
コード例 #6
0
ファイル: Audit.java プロジェクト: bgarrels/xpert-framework
  public static String getEntityName(Class entity) {

    if (mappedName.get(entity) != null) {
      return mappedName.get(entity);
    }

    String name = null;

    Table table = (Table) entity.getAnnotation(Table.class);
    if (table != null && table.name() != null && !table.name().isEmpty()) {
      name = table.name();
    } else {
      Entity entityAnnotation = (Entity) entity.getAnnotation(Entity.class);
      if (entityAnnotation != null
          && entityAnnotation.name() != null
          && !entityAnnotation.name().isEmpty()) {
        name = entityAnnotation.name();
      } else {
        name = entity.getSimpleName();
      }
    }

    mappedName.put(entity, name);

    return name;
  }
コード例 #7
0
  private void verifyCurrentUserIsAuthorized(Process process, Task task)
      throws ForbiddenError, BadRequestError {
    if (process == null) throw new BadRequestError(Constants.ExceptionCodes.process_does_not_exist);

    String taskId = task != null ? task.getTaskInstanceId() : null;

    Entity principal = identityHelper.getPrincipal();
    if (principal == null || StringUtils.isEmpty(principal.getEntityId())) {
      LOG.error(
          "Forbidden: Unauthorized user or user with no userId (e.g. system user) attempting to create a request for task: "
              + taskId);
      throw new ForbiddenError();
    }

    if (!principal.hasRole(process, AuthorizationRole.OVERSEER)) {
      if (task != null && !task.isCandidateOrAssignee(principal)) {
        LOG.warn(
            "Forbidden: Unauthorized principal "
                + principal.toString()
                + " attempting to access task "
                + taskId);
        throw new ForbiddenError();
      }
    }
  }
コード例 #8
0
  private Entity closest(List list) {
    double d4 = 9000D;
    Entity ent = null;

    for (int i = 0; i < list.size(); i++) {
      Entity ent1 = (Entity) list.get(i);

      boolean okay = true;
      if (ent1 instanceof AM_EntityChopper) {
        okay = false;
      } else if (ent1 instanceof EntityWolf) {
        EntityWolf ew = (EntityWolf) ent1;
        okay = AutomatonUniversal.angrywolf(ew);
      }

      if (okay) {
        double d5 = ent1.getDistanceSq(posX, posY, posZ);
        if (d5 < d4) {
          d4 = d5;
          ent = ent1;
        }
      }
    }

    return ent;
  }
コード例 #9
0
 @Override
 public Entity getEntityById(int id) {
   synchronized (entities) {
     for (Entity entity : entities) if (id == entity.getId()) return entity;
     return null;
   }
 }
コード例 #10
0
ファイル: View.java プロジェクト: granum41/graphicstest
  public void update(Graphics2D g) {

    for (Entity entity : entities) {

      entity.render(g);
    }
  }
コード例 #11
0
ファイル: EnemyManager.java プロジェクト: Dephon/mothership
 public void update(Vector2f loc, int dt) {
   for (Entity alien : entities) {
     if (!alien.isDead()) {
       alien.update(loc, dt);
     }
   }
   if (spawnsEnabled) updateSpawns(dt);
 }
コード例 #12
0
 // remove an entity from the controller
 // returns true if an entity was removed
 // returns false if there is no entity with the given id
 public boolean removeEntity(long id) {
   for (Entity e : this.entity_list) {
     if (e.getId() == id) {
       this.removeEntity(e);
     }
   }
   return false;
 }
コード例 #13
0
ファイル: EnemyManager.java プロジェクト: Dephon/mothership
 @Override
 public void update(int dt) {
   for (Entity alien : entities) {
     if (!alien.isDead()) {
       alien.update(dt);
     } else {
       remove(alien);
     }
   }
   if (spawnsEnabled) updateSpawns(dt);
 }
コード例 #14
0
 public void clearCache() {
   if (entities != null) {
     for (Entity entity : entities) entity.clearCache();
   }
   try {
     processor.close();
   } catch (Exception e) {
     /*no op*/
   }
   processor = null;
   if (dataSrc != null) dataSrc.close();
   dataSrc = null;
 }
コード例 #15
0
 public void die(DamageSource damagesource) {
   if (village != null) {
     Entity entity = damagesource.getEntity();
     if (entity != null) {
       if (entity instanceof EntityHuman) village.a(entity.getName(), -2);
       else if (entity instanceof IMonster) village.h();
     } else if (entity == null) {
       EntityHuman entityhuman = world.findNearbyPlayer(this, 16D);
       if (entityhuman != null) village.h();
     }
   }
   super.die(damagesource);
 }
コード例 #16
0
ファイル: Skill.java プロジェクト: DonnieSantos/TempestMUD
  public void init(Entity Owner, int Level) {

    owner = Owner;
    level = Level;

    if (Owner != null) {

      mn = owner.getName();
      Mn = owner.getPName();
      my = Utility.possessive(mn);
      My = Utility.possessive(Mn);
    }
  }
コード例 #17
0
ファイル: Skill.java プロジェクト: DonnieSantos/TempestMUD
  public void skillOutput(boolean passive, boolean failed, boolean peaceful) {

    owner.getRoom().setSkillRedirect(true);

    if (passive) owner.passiveOutput(target, selfOut, targOut, grupOut, obsvOut);
    else owner.combatOutput(target, selfOut, targOut, grupOut, obsvOut);

    if (!failed) {
      if (peaceful) trainPeaceful();
      else train();
    }

    owner.getRoom().setSkillRedirect(false);
  }
コード例 #18
0
ファイル: TranxTest.java プロジェクト: oabdoun/tranx
  @Test
  public void createTransactionReturnsOk() {
    // create "cars" transaction
    Response response =
        client
            .path("/transactionservice/transaction/10")
            .request()
            .put(Entity.json(new Transaction("cars", new BigDecimal(5000), 0l)));

    assertEquals(200, response.getStatus());
    assertEquals(
        TransactionService.OperationResult.OK,
        response.readEntity(TransactionService.OperationResult.class));

    // create "shopping" transaction
    response =
        client
            .path("/transactionservice/transaction/11")
            .request()
            .put(Entity.json(new Transaction("shopping", new BigDecimal(10000), 10l)));

    assertEquals(200, response.getStatus());
    assertEquals(
        TransactionService.OperationResult.OK,
        response.readEntity(TransactionService.OperationResult.class));

    // get "cars" transactions
    response = client.path("/transactionservice/type/cars").request().get();

    assertEquals(200, response.getStatus());
    @SuppressWarnings("unchecked")
    List<Integer> ids = response.readEntity(List.class);
    assertEquals(1, ids.size());
    assertEquals(10, ids.get(0).intValue());

    // get "sum" for transaction 10
    response = client.path("/transactionservice/sum/10").request().get();

    assertEquals(200, response.getStatus());
    AggregatorService.Sum sum = response.readEntity(AggregatorService.Sum.class);
    assertEquals(15000, sum.getSum().intValue());

    // get "sum" for transaction 11
    response = client.path("/transactionservice/sum/11").request().get();

    assertEquals(200, response.getStatus());
    sum = response.readEntity(AggregatorService.Sum.class);
    assertEquals(10000, sum.getSum().intValue());
  }
コード例 #19
0
  public void func_70383_a(Entity par1Entity) {
    if (field_70391_e != null) {
      NBTTagCompound nbttagcompound = new NBTTagCompound();
      par1Entity.addEntityID(nbttagcompound);
      NBTBase nbtbase;

      for (Iterator iterator = field_70391_e.getTags().iterator();
          iterator.hasNext();
          nbttagcompound.setTag(nbtbase.getName(), nbtbase.copy())) {
        nbtbase = (NBTBase) iterator.next();
      }

      par1Entity.readFromNBT(nbttagcompound);
    }
  }
コード例 #20
0
  private Entity closestSlime(List list) {
    double d4 = 9000D;
    Entity ent = null;

    for (int i = 0; i < list.size(); i++) {
      Entity ent1 = (Entity) list.get(i);

      double d5 = ent1.getDistanceSq(posX, posY, posZ);
      if (d5 < d4) {
        d4 = d5;
        ent = ent1;
      }
    }

    return ent;
  }
コード例 #21
0
ファイル: DEVPackage.java プロジェクト: hrf1159/RavenD
  @SuppressWarnings("rawtypes")
  public static void initDevPackage(DEVPackage devPackage) {

    Gson gson = new Gson();
    if (devPackage != null && devPackage.getOwnedElements() != null) {
      List ownedElements = (List) devPackage.getOwnedElements();

      /*
      Entity entityManageApi = new Entity();
      entityManageApi.setName(devPackage.getName() + "EntityManageApi");
      entityManageApi.set_parent(new StarUmlReference(devPackage.get_id()));
      entityManageApi.setTemplatePath(devPackage.getTemplatePath());
      entityManageApi.setStereotype("Api");
      devPackage.getOwnedElements().add(entityManageApi);*/

      for (int i = 0; i < ownedElements.size(); i++) {
        Entity entity = null;
        Object aa = ownedElements.get(i);
        if (aa.getClass().toString().contains("Entity")) {
          entity = (Entity) aa;
        } else {
          LinkedHashMap data = (LinkedHashMap) ownedElements.get(i);
          String type = (String) data.get("_type");
          String id = (String) data.get("_id");
          String stereotype = (String) data.get("stereotype");
          if (type.equals("UMLClass")) {
            String eleJson = gson.toJson(data);
            entity = gson.fromJson(eleJson, Entity.class);
          }
        }

        if (entity != null) {
          entity.collectExtraAttributes();
          entity.setDevPackage(devPackage);
          entity.setTemplatePath(devPackage.getTemplatePath());
          StarUmlObjectContainer.addObject(entity.get_id(), entity);
          StarUmlObjectContainer.addObjectByName(entity.getName(), entity);
          devPackage.addEntity(entity.get_id(), entity);
          StarUmlReference ref = new StarUmlReference(devPackage.get_id());
          entity.set_parent(ref);
          ownedElements.set(i, entity);

          // auto generate ApiManage Entity
          /*
          if (entity.getStereotype() != null && entity.getStereotype().equals("Entity")) {
              EntityOperation entityManageOp = new EntityOperation(entityManageApi);
              entityManageOp.setName("manage" + entity.getName());
              entityManageApi.addOperation(entityManageOp);
              entityManageApi.addDepend(entity.getName(), entity);
          }*/
        }
      }
      //	devPackage.normalizeTypes();
    }
  }
コード例 #22
0
  // add an entity to the controller
  // returns true if entity is added
  // returns false if entity is already in the list
  public boolean addEntity(Entity e) {
    for (Entity e2 : this.entity_list) {
      if (e == e2) return false;
    }

    this.entity_list.add(e);
    e.addSubscriber(this, MsgType.MSG_ALL);
    return true;
  }
コード例 #23
0
ファイル: Entity.java プロジェクト: leasual/greenDAO
  private void init3rdPassAdditionalImports() {
    if (active && !javaPackage.equals(javaPackageDao)) {
      additionalImportsEntity.add(javaPackageDao + "." + classNameDao);
    }

    for (ToOne toOne : toOneRelations) {
      Entity targetEntity = toOne.getTargetEntity();
      checkAdditionalImportsEntityTargetEntity(targetEntity);
      // For deep loading
      if (!targetEntity.getJavaPackage().equals(javaPackageDao)) {
        additionalImportsDao.add(targetEntity.getJavaPackage() + "." + targetEntity.getClassName());
      }
    }

    for (ToMany toMany : toManyRelations) {
      Entity targetEntity = toMany.getTargetEntity();
      checkAdditionalImportsEntityTargetEntity(targetEntity);
    }
  }
コード例 #24
0
ファイル: DEVPackage.java プロジェクト: hrf1159/RavenD
  public String[] exportDotNetCode(String path) {
    path = path + "/" + projectName + "/";
    Iterator<Entry<String, Entity>> entityIter = entities.entrySet().iterator();

    String sqlMap = "";

    String csprojectContent = "";

    while (entityIter.hasNext()) {
      Entry<String, Entity> entry = entityIter.next();
      Entity val = entry.getValue();

      val.setTemplatePath(templatePath);
      val.setDevPackage(this);
      /*
      PersistEntityDotNet persistDN = new PersistEntityDotNet(val);
      persistDN.setTemplatePath(templatePath);
      PersistEntityDotNet.projectName = projectName;
      if ("Api".equals(val.getStereotype())) {
          csprojectContent += persistDN.genOperations(path);
      } else if ("Entity".equals(val.getStereotype())) {
          csprojectContent += persistDN.genEntity(path);
          csprojectContent += persistDN.genMapper(path);
          csprojectContent += persistDN.genControl(path);
          csprojectContent += persistDN.genResponse(path);

          sqlMap += MessageFormat.format("\t<sqlMap resource=\"Mapper/{0}.xml\"/>\r\n", persistDN.getBaseEntity().getName());
      } else if (val.getStereotype() != null && val.getStereotype().startsWith("Html")) {
      } else if (val.getStereotype() == null || !val.getStereotype().startsWith("Ele")) {
          csprojectContent += persistDN.genItem(path);
          csprojectContent += persistDN.genResponse(path);
          sqlMap += MessageFormat.format("\t<sqlMap resource=\"Mapper/{0}.xml\"/>\r\n", persistDN.getBaseEntity().getName());
      }

      */
    }

    String[] s = new String[2];
    s[0] = sqlMap;
    s[1] = csprojectContent;
    return s;
  }
コード例 #25
0
ファイル: Chunk.java プロジェクト: talmor/WorldDownloader
 public void getEntitiesOfTypeWithinAAAB(Class class1, AxisAlignedBB axisalignedbb, List list) {
   int i = MathHelper.floor_double((axisalignedbb.minY - 2D) / 16D);
   int j = MathHelper.floor_double((axisalignedbb.maxY + 2D) / 16D);
   if (i < 0) {
     i = 0;
   }
   if (j >= entities.length) {
     j = entities.length - 1;
   }
   for (int k = i; k <= j; k++) {
     List list1 = entities[k];
     for (int l = 0; l < list1.size(); l++) {
       Entity entity = (Entity) list1.get(l);
       if (class1.isAssignableFrom(entity.getClass())
           && entity.boundingBox.intersectsWith(axisalignedbb)) {
         list.add(entity);
       }
     }
   }
 }
コード例 #26
0
 // for the application
 @GET
 @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
 public TaskData getTaskData() {
   // same code as above method
   DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
   MemcacheService syncCache = MemcacheServiceFactory.getMemcacheService();
   if (syncCache.get(keyname) != null) {
     TaskData ts = (TaskData) syncCache.get(keyname);
     return ts;
   }
   Key entKey = KeyFactory.createKey("TaskData", keyname);
   try {
     Entity ent = datastore.get(entKey);
     TaskData ts =
         new TaskData(keyname, (String) ent.getProperty("value"), (Date) ent.getProperty("date"));
     return ts;
   } catch (EntityNotFoundException e) {
     throw new RuntimeException("Get: TaskData with " + keyname + " not found");
   }
 }
コード例 #27
0
 public void func_712_a(int i, Entity entity) {
   Entity entity1 = func_709_b(i);
   if (entity1 != null) {
     func_607_d(entity1);
   }
   field_20914_E.add(entity);
   entity.field_620_ab = i;
   if (!func_674_a(entity)) {
     field_1053_F.add(entity);
   }
   field_1055_D.func_1061_a(i, entity);
 }
コード例 #28
0
ファイル: Skill.java プロジェクト: DonnieSantos/TempestMUD
  public boolean tryDamageSkill(String rem, String cut, String output) {

    if (cut.length() > 0)
      if (rem.indexOf(cut) == 0) {
        rem = rem.substring(cut.length(), rem.length());
        rem = Utility.clearWhiteSpace(rem);
      }

    target = owner.getRoom().findEntity(owner, rem);

    if ((target == null) && (owner.getPlayerState() == Utility.PSTATE_FIGHTING))
      target = owner.getTarget();

    if (target == null) {
      owner.echo(output);
      return false;
    }

    if (!Combat.canAttack(owner, target, false, true)) return false;

    tn = target.getName();
    Tn = target.getPName();
    ty = Utility.possessive(tn);
    Ty = Utility.possessive(Tn);

    return true;
  }
コード例 #29
0
 @PUT
 @Consumes(MediaType.APPLICATION_XML)
 public Response putTaskData(String value) {
   Response res = null;
   // add your code here
   // first check if the Entity exists in the datastore
   DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
   MemcacheService syncCache = MemcacheServiceFactory.getMemcacheService();
   syncCache.setErrorHandler(ErrorHandlers.getConsistentLogAndContinue(Level.INFO));
   Key entKey = KeyFactory.createKey("TaskData", keyname);
   Date date = new Date();
   try {
     // if it is, signal that we updated the entity
     Entity ts = datastore.get(entKey);
     ts.setProperty("value", value);
     ts.setProperty("date", date);
     datastore.put(ts);
     res = Response.noContent().build();
   } catch (EntityNotFoundException e) {
     // if it is not, create it and
     // signal that we created the entity in the datastore
     Entity taskdata = new Entity("TaskData", keyname);
     taskdata.setProperty("value", value);
     taskdata.setProperty("date", date);
     datastore.put(taskdata);
     res = Response.created(uriInfo.getAbsolutePath()).build();
   }
   TaskData td = new TaskData(keyname, value, date);
   syncCache.put(keyname, td);
   return res;
 }
コード例 #30
0
 // for the browser
 @GET
 @Produces(MediaType.TEXT_XML)
 public TaskData getTaskDataHTML() {
   // add your code here (get Entity from datastore using this.keyname)
   // throw new RuntimeException("Get: TaskData with " + keyname +  " not found");
   // if not found
   DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
   MemcacheService syncCache = MemcacheServiceFactory.getMemcacheService();
   if (syncCache.get(keyname) != null) {
     TaskData ts = (TaskData) syncCache.get(keyname);
     return ts;
   }
   Key entKey = KeyFactory.createKey("TaskData", keyname);
   try {
     Entity ent = datastore.get(entKey);
     TaskData ts =
         new TaskData(keyname, (String) ent.getProperty("value"), (Date) ent.getProperty("date"));
     return ts;
   } catch (EntityNotFoundException e) {
     throw new RuntimeException("Get: TaskData with " + keyname + " not found");
   }
 }