Examples of Entity


Examples of org.jdesktop.mtgame.Entity

  // (and, for drag events, attach the raw hit pick info).
  MouseEvent3D event = (MouseEvent3D) createWonderlandEvent(awtMouseEvent);

  // Get the destination entity and move pick details into the event
  PickDetails pickDetails = destPickInfo.get(0);
        Entity entity = pickDetails.getEntity();
  logger.fine("Picker: pickDetails = " + pickDetails);
        logger.fine("Picker: entity = " + entity);
        event.setPickDetails(pickDetails);
        if (eventID == MouseEvent.MOUSE_DRAGGED && hitPickInfo != null) {
            MouseDraggedEvent3D de3d = (MouseDraggedEvent3D) event;
            if (hitPickInfo.size() > 0) {
                de3d.setHitPickDetails(hitPickInfo.get(0));
            }
        }

        if (isWindowSwingEntity(entity)) {
            logger.info("Hit window swing entity = " + entity);

            // Get the WindowSwing of the entity
            WindowSwingEventConsumer eventConsumer =
                (WindowSwingEventConsumer) entity.getComponent(WindowSwingEventConsumer.class);
           
            // Treat change control events as 3D events, regardless of control or focus
            EventAction eventAction =  eventConsumer.consumesEvent(event);
            logger.info("Event action = " + eventAction);
View Full Code Here

Examples of org.jpokemon.overworld.Entity

  @Override
  public void execute(Player player) throws ServiceException {
    OverworldService overworldService = (OverworldService) PlayerManager.getService("overworld");
    Map nextMap = overworldService.getMap(nextMapId);
    Entity nextDoor = nextMap.getEntity(mapId);
    Location nextLocation = nextDoor.getLocation().clone();
    nextLocation.setWidth(1);
    nextLocation.setHeight(1);
    nextLocation.setDirection("down");

    overworldService.teleportPlayer(player, nextLocation);
View Full Code Here

Examples of org.kuali.rice.kim.api.identity.entity.Entity

    String entityId = null;
    for (EntityExternalIdentifierBo extId: results) {
      entityId = extId.getEntityId();
    }
    // get the first principal and return details
    Entity entity = getIdentityService().getEntity(entityId);
    Principal principal = entity.getPrincipals().get(0);
    List<GrantedAuthority> auths = new ArrayList<GrantedAuthority>();
    auths.add(new SimpleGrantedAuthority("ROLE_USER"));
    if (principal.isActive()) {
      return new User(principal.getPrincipalName(), "password", true, true, true, true, auths);
    } else {
View Full Code Here

Examples of org.mitre.sim.Entity

  protected IdentityHashMap compute() {
    IdentityHashMap patrimony = parent.compute();
    IdentityHashMap partialDB = new IdentityHashMap();
    for (Iterator i = patrimony.keySet().iterator(); i.hasNext(); ) {
      Entity e = (Entity)i.next();
      if (!filter.passesFilter(e)) partialDB.put(e, null);
    }
    return partialDB;
  }
View Full Code Here

Examples of org.molgenis.model.elements.Entity

      logger.error(message);
      throw new MolgenisModelException(message);
    }

    // construct
    Entity entity = new Entity(element.getAttribute("name").trim(), element.getAttribute("label"),
        model.getDatabase());
    entity.setNamespace(model.getName());

    // add optional properties
    // EXTENDS exactly one
    String _extends = element.getAttribute("extends");
    if (_extends != null)
    {
      Vector<String> parents = new Vector<String>();
      StringTokenizer tokenizer = new StringTokenizer(_extends, ",");
      while (tokenizer.hasMoreTokens())
      {
        parents.add(tokenizer.nextToken().trim());
      }

      entity.setParents(parents);
    }

    // IMPLEMENTS
    String _implements = element.getAttribute("implements");
    if (_implements != null && !_implements.isEmpty())
    {
      entity.setImplements(new Vector<String>(Arrays.asList(_implements.split(","))));
    }

    // ABSTRACT
    entity.setAbstract(Boolean.parseBoolean(element.getAttribute("abstract")));

    // SYSTEM
    entity.setSystem(Boolean.parseBoolean(element.getAttribute("system")));

    // XREF_LABEL
    String xref_label = element.getAttribute("xref_label");
    if (xref_label != null && !xref_label.isEmpty())
    {
      List<String> xref_labels = new ArrayList<String>();
      xref_labels.addAll(Arrays.asList(xref_label.split(",")));
      entity.setXrefLabels(xref_labels);
    }
    else
    {
      entity.setXrefLabels(null);
    }

    // TRIGGER
    if (element.hasAttribute("decorator"))
    {
      entity.setDecorator(element.getAttribute("decorator"));
    }

    // DESCRIPTION
    NodeList elements = element.getElementsByTagName("description");
    for (int j = 0; j < elements.getLength(); j++)
    {
      // parse the contents, including markup...
      entity.setDescription(elementValueToString((Element) elements.item(j)));
    }

    // FIELD
    elements = element.getElementsByTagName("field");
    for (int j = 0; j < elements.getLength(); j++)
    {
      Element elem = (Element) elements.item(j);
      parseField(entity, elem);
    }

    // UNIQUE
    elements = element.getElementsByTagName("unique");
    for (int j = 0; j < elements.getLength(); j++)
    {
      Element elem = (Element) elements.item(j);
      Vector<String> keys = new Vector<String>();

      // keys from keyfield="a,b" attribute
      if (elem.hasAttribute("fields"))
      {
        for (String name : elem.getAttribute("fields").split(","))
        {
          // Field f = entity.getField(name);
          // if (f == null)
          // {
          // // try to get superclass field (need to copy it then)
          // f = entity.getAllField(name);
          // if (f == null) throw new
          // MolgenisModelException("Missing unique field '" + name
          // + "' in entity '" + entity.getName() + "'");
          //
          // // copy the field so it will end up in the table (as
          // // redundant copy) to enforce unique
          // // f = new Field(f);
          // // f.setEntity(entity);
          // // f.setSystem(true);
          // // entity.addField(f);
          // }

          keys.add(name);
        }

      }

      // keys from <keyfield> elements
      NodeList key_elements = elem.getElementsByTagName("keyfield");
      for (int k = 0; k < key_elements.getLength(); k++)
      {
        elem = (Element) key_elements.item(k);

        String name = elem.getAttribute("name");
        // should include superclass methods now
        // if (f == null)
        // {
        // throw new MolgenisModelException("Missing unique field: " +
        // elem.getAttribute("name"));
        // // return null;
        // }

        keys.add(name);
      }

      // description
      String key_description = null;
      if (elem.hasAttribute("description"))
      {
        key_description = elem.getAttribute("description");
      }

      // check if keys
      if (keys.size() == 0)
      {
        throw new MolgenisModelException("missing fields on unique of '" + entity.getName()
            + "'. Expected <unique fields=\"field1[,field2,..]\" description=\"...\"/>");
      }

      try
      {
        entity.addKey(keys, elem.getAttribute("subclass").equals("true"), key_description);
        // might be duplicate key
      }
      catch (Exception e)
      {
        throw new MolgenisModelException(e.getMessage());
      }
    }

    elements = element.getElementsByTagName("indices");
    if (elements.getLength() == 1)
    {
      Element elem = (Element) elements.item(0);

      NodeList index_elements = elem.getElementsByTagName("index");
      for (int k = 0; k < index_elements.getLength(); k++)
      {
        elem = (Element) index_elements.item(k);

        Index index = new Index(elem.getAttribute("name"));

        NodeList indexfield_elements = elem.getElementsByTagName("indexfield");
        for (int l = 0; l < indexfield_elements.getLength(); l++)
        {
          elem = (Element) indexfield_elements.item(l);

          Field f = entity.getField(elem.getAttribute("name"));
          if (f == null)
          {
            // System.err.println(String.format(Error.
            // MISSING_INDEX_FIELD.msg,
            // elem.getAttribute("name")));
            throw new MolgenisModelException("Missing index field: " + elem.getAttribute("name"));
            // return null;
          }

          try
          {
            index.addField(elem.getAttribute("name"));
          }
          catch (Exception e)
          {
            throw new MolgenisModelException(e.getMessage());
          }
        }

        try
        {
          entity.addIndex(index);
        }
        catch (Exception e)
        {
        }
      }
    }
    else if (elements.getLength() > 1)
    {
      // System.err.println(Error.MULTIPLE_INDICES_ELEMENTS.msg);
      // return null;
      throw new MolgenisModelException("Multiple indices elements");
    }
    // done

    // Todo: change if(molgenisOptions.jpa_use_sequence &&
    // element.hasAttribute("allocationSize"))
    if (element.hasAttribute("allocationSize"))
    {
      int allocationSize = Integer.parseInt(element.getAttribute("allocationSize"));
      entity.setAllocationSize(allocationSize);
    }

    logger.debug("read: " + entity.getName());
    return entity;
  }
View Full Code Here

Examples of org.molgenis.model.jaxb.Entity

      while (tableInfo.next())
      {
        logger.debug("TABLE: " + tableInfo);

        Entity e = new Entity();
        e.setName(tableInfo.getString("TABLE_NAME"));
        m.getEntities().add(e);

        // ADD THE COLUMNS
        ResultSet fieldInfo = md.getColumns(SCHEMA_NAME, null, tableInfo.getString("TABLE_NAME"), null);
        while (fieldInfo.next())
        {
          logger.debug("COLUMN: " + fieldInfo);

          Field f = new Field();
          f.setName(fieldInfo.getString("COLUMN_NAME"));
          f.setType(Field.Type.getType(fieldInfo.getInt("DATA_TYPE")));
          f.setDefaultValue(fieldInfo.getString("COLUMN_DEF"));

          if (md.getDatabaseProductName().toLowerCase().contains("mysql"))
          {
            // accomodate mysql CURRENT_TIMESTAMP
            if ("CURRENT_TIMESTAMP".equals(f.getDefaultValue())
                && (f.getType().equals(Field.Type.DATETIME) || f.getType().equals(Field.Type.DATE)))
            {
              f.setDefaultValue(null);
              f.setAuto(true);
            }

            // accomodate mysql text/string fields +
            // nillable="false" -> mysql ignore not null and so
            // should we!
          }

          if (fieldInfo.getString("REMARKS") != null && !"".equals(fieldInfo.getString("REMARKS").trim())) f
              .setDescription(fieldInfo.getString("REMARKS"));
          if (fieldInfo.getBoolean("NULLABLE")) f.setNillable(true);

          // auto increment?
          if (f.getType().equals(Field.Type.INT))
          {
            if (fieldInfo.getObject("IS_AUTOINCREMENT") != null) f.setAuto(fieldInfo
                .getBoolean("IS_AUTOINCREMENT"));
          }

          if (f.getType().equals(Field.Type.STRING) || f.getType().equals(Field.Type.CHAR))
          {
            if (fieldInfo.getInt("COLUMN_SIZE") > 255)
            {
              f.setType(Field.Type.TEXT);
              f.setLength(fieldInfo.getInt("COLUMN_SIZE"));
            }
            else
            {
              if (fieldInfo.getInt("COLUMN_SIZE") != 255) f.setLength(fieldInfo.getInt("COLUMN_SIZE"));
              f.setType(null); // defaults to string
            }
          }

          ResultSet xrefInfo = md.getImportedKeys(SCHEMA_NAME, null, tableInfo.getString("TABLE_NAME"));
          while (xrefInfo.next())
          {
            if (xrefInfo.getString("FKCOLUMN_NAME").equals(fieldInfo.getString("COLUMN_NAME")))
            {
              f.setType(Field.Type.XREF_SINGLE);
              // problem: PKTABLE_NAME is lowercase, need to be
              // corrected later?
              f.setXrefField(xrefInfo.getString("PKTABLE_NAME") + "."
                  + xrefInfo.getString("PKCOLUMN_NAME"));
            }
          }

          e.getFields().add(f);
        }

        // GET AUTO INCREMENT

        // mysql workaround
        Statement stmt = null;
        try
        {
          String sql = "select * from " + e.getName() + " where 1=0";
          stmt = conn.createStatement();

          ResultSet autoincRs = stmt.executeQuery(sql);
          ResultSetMetaData rowMeta = autoincRs.getMetaData();
          for (int i = 1; i <= rowMeta.getColumnCount(); i++)
          {
            if (rowMeta.isAutoIncrement(i))
            {
              e.getFields().get(i - 1).setAuto(true);
            }
          }
        }
        catch (Exception exc)
        {
          logger.error("didn't retrieve autoinc/sequence: " + exc.getMessage());
          // e.printStackTrace();
        }
        finally
        {
          stmt.close();
        }

        // ADD UNIQUE CONTRAINTS
        ResultSet rsIndex = md.getIndexInfo(SCHEMA_NAME, null, tableInfo.getString("TABLE_NAME"), true, false);
        // indexed list of uniques
        Map<String, List<String>> uniques = new LinkedHashMap<String, List<String>>();
        while (rsIndex.next())
        {
          logger.debug("UNIQUE: " + rsIndex);

          // TABLE_CAT='molgenistest' TABLE_SCHEM='null'
          // TABLE_NAME='boolentity' NON_UNIQUE='false'
          // INDEX_QUALIFIER='' INDEX_NAME='PRIMARY' TYPE='3'
          // ORDINAL_POSITION='1' COLUMN_NAME='id' ASC_OR_DESC='A'
          // CARDINALITY='0' PAGES='0' FILTER_CONDITION='null'
          if (uniques.get(rsIndex.getString("INDEX_NAME")) == null) uniques.put(
              rsIndex.getString("INDEX_NAME"), new ArrayList<String>());
          uniques.get(rsIndex.getString("INDEX_NAME")).add(rsIndex.getString("COLUMN_NAME"));
        }
        for (List<String> index : uniques.values())
        {
          if (index.size() == 1)
          {
            e.getField(index.get(0)).setUnique(true);
          }
          else
          {
            StringBuilder fieldsBuilder = new StringBuilder();
            for (String field_name : index)
            {
              fieldsBuilder.append(',').append(field_name);
            }
            Unique u = new Unique();
            u.setFields(fieldsBuilder.substring(1));
            e.getUniques().add(u);
          }

        }

        // FIND type="autoid"
        for (Field f : e.getFields())
        {
          if (f.getAuto() != null && f.getAuto() && f.getType().equals(Type.INT) && f.getUnique() != null
              && f.getUnique())
          {
            f.setType(Field.Type.AUTOID);
            f.setAuto(null);
            f.setUnique(null);
          }
        }
      }

      // GUESS type="xref"
      // normally they should be defined as foreign key but sometimes
      // designers leave this out
      // rule: if the field name is the same and one is autoid,
      // then other fields having the same name are likely to be xref to
      // the autoid
      for (Entity e : m.getEntities())
      {
        for (Field f : e.getFields())
        {
          if (Field.Type.AUTOID.equals(f.getType()))
          {
            for (Entity otherE : m.getEntities())
            {
              for (Field otherF : otherE.getFields())
              {
                // assume xref if
                // name == name
                // otherF.type == int
                if (otherF.getName().equals(f.getName()) && otherF.getType().equals(Field.Type.INT))
                {
                  logger.debug("Guessed that " + otherE.getName() + "." + otherF.getName()
                      + " references " + e.getName() + "." + f.getName());
                  otherF.setType(Field.Type.XREF_SINGLE);
                  // otherF.setXrefEntity(;
                  otherF.setXrefField(e.getName() + "." + f.getName());
                }
              }
            }
          }

        }
      }

      // GUESS the xref labels
      // guess the xreflabel as being the non-autoid field that is unique
      // and not null
      // rule: if there is another unique field in the referenced table
      // then that probably is usable as label
      for (Entity e : m.getEntities())
      {
        for (Field f : e.getFields())
        {
          if (Field.Type.XREF_SINGLE.equals(f.getType()))
          {
            String xrefEntityName = f.getXrefField().substring(0, f.getXrefField().indexOf("."));
            String xrefFieldName = f.getXrefField().substring(f.getXrefField().indexOf(".") + 1);
            // reset the xref entity to the uppercase version
            f.setXrefField(m.getEntity(xrefEntityName).getName() + "." + xrefFieldName);

            for (Field labelField : m.getEntity(xrefEntityName).getFields())
            {
              // find the other unique, nillable="false" field, if
              // any
              if (!labelField.getName().equals(xrefFieldName)
                  && Boolean.TRUE.equals(labelField.getUnique())
                  && Boolean.FALSE.equals(labelField.getNillable()))
              {
                logger.debug("guessed label " + e.getName() + "." + labelField.getName());
                f.setXrefLabel(labelField.getName());
              }
            }
          }
        }
      }

      // GUESS the inheritance relationship
      // rule: if there is a foreign key that is unique itself it is
      // probably inheriting...
      // action: change to inheritance and remove the xref field
      for (Entity e : m.getEntities())
      {
        List<Field> toBeRemoved = new ArrayList<Field>();
        for (Field f : e.getFields())
        {
          if (Field.Type.XREF_SINGLE.equals(f.getType()) && Boolean.TRUE.equals(f.getUnique()))
          {
            String entityName = f.getXrefField().substring(0, f.getXrefField().indexOf("."));
            e.setExtends(entityName);
            toBeRemoved.add(f);
          }
        }
        for (Field f : toBeRemoved)
        {
          e.getFields().remove(f);
        }
      }

      // TODO GUESS the type="mref"
      // rule: any entity that is not a subclass and that has maximum two
      // xref fields and autoid field
      // should be a mref
      List<Entity> toBeRemoved = new ArrayList<Entity>();
      for (Entity e : m.getEntities())
        if ("".equals(e.getExtends()))
        {

          if (e.getFields().size() <= 3)
          {
            int xrefs = 0;
            String idField = null;
            // the column refering to 'localEntity'
            String localIdField = null;
            // the localEntiy
            String localEntity = null;
            // the column referring to 'remoteEntity'
            String localEntityField = null;
            // the column the localIdField is referning to
            String remoteIdField = null;
            // the column remoteEntity
            String remoteEntity = null;
            // the column the remoteIdField is referring to
            String remoteEntityField = null;

            for (Field f : e.getFields())
            {
              if (Field.Type.AUTOID.equals(f.getType()))
              {
                idField = f.getName();
              }
              else if (Field.Type.XREF_SINGLE.equals(f.getType()))
              {
                xrefs++;
                if (xrefs == 1)
                {
                  localIdField = f.getName();
                  // localEntityField is just the idField of
                  // the
                  // localEntity
                  localEntity = f.getXrefField().substring(0, f.getXrefField().indexOf("."));
                  localEntityField = f.getXrefField().substring(f.getXrefField().indexOf(".") + 1);
                }
                else
                {
                  remoteIdField = f.getName();
                  // should be the id field of the remote
                  // entity
                  remoteEntity = f.getXrefField().substring(0, f.getXrefField().indexOf("."));
                  remoteEntityField = f.getXrefField().substring(f.getXrefField().indexOf(".") + 1);
                }
              }
            }

            // if valid mref, drop this entity and add mref fields
            // to
            // the other entities.
            if (xrefs == 2 && (e.getFields().size() == 2 || idField != null))
            {
              // add mref on 'local' end
              Entity localContainer = m.getEntity(localEntity);
              Field localField = new Field();
              if (localContainer.getField(e.getName()) == null)
              {
                localField.setName(e.getName());
              }

              localField.setType(Field.Type.XREF_MULTIPLE);
              localField.setXrefField(remoteEntity + "." + remoteEntityField);
              localField.setMrefName(e.getName());
              localField.setMrefLocalid(localIdField);
              localField.setMrefRemoteid(remoteIdField);
              localContainer.getFields().add(localField);

              // add mref to remote end
              Entity remoteContainer = m.getEntity(remoteEntity);
              Field remoteField = new Field();
              remoteField.setType(Field.Type.XREF_MULTIPLE);
              remoteField.setXrefField(localEntity + "." + localEntityField);
              remoteField.setMrefName(e.getName());
              // don't need to add local id as it is refering back
              remoteField.setMrefLocalid(remoteIdField);
              remoteField.setMrefRemoteid(localIdField);

              if (remoteContainer.getField(e.getName()) == null)
              {
                remoteField.setName(e.getName());
              }
              else
              {
                throw new RuntimeException("MREF creation failed: there is already a field "
                    + remoteContainer.getName() + "." + e.getName());
              }

              remoteContainer.getFields().add(remoteField);

              // remove the link table as separate entity
              toBeRemoved.add(e);
              logger.debug("guessed mref " + e.getName());
            }
View Full Code Here

Examples of org.molgenis.util.Entity

   */
  protected void setXrefEntity(Class<? extends Entity> xrefEntity)
  {
    try
    {
      Entity instance = xrefEntity.newInstance();
      this.xrefField = instance.getIdField();
      this.xrefLabels = instance.getLabelFields();
      this.placeholder = "Choose " + instance.getClass().getSimpleName();
      // this.xrefEntity = xrefEntity;
    }
    catch (Exception e)
    {
      this.error = e.getMessage();
View Full Code Here

Examples of org.mongodb.morphia.annotations.Entity

        this.ds = ((DatastoreImpl) ds);
        dbColl = coll;
        cache = this.ds.getMapper().createEntityCache();

        final MappedClass mc = this.ds.getMapper().getMappedClass(clazz);
        final Entity entAn = mc == null ? null : mc.getEntityAnnotation();
        if (entAn != null) {
            readPref = this.ds.getMapper().getMappedClass(clazz).getEntityAnnotation().queryNonPrimary()
                       ? ReadPreference.secondaryPreferred()
                       : null;
        }
View Full Code Here

Examples of org.moparscape.msc.gs.model.Entity

        updates.addByte((byte) p.getCurStat(3));
        updates.addByte((byte) p.getMaxStat(3));
      }
      for (Projectile p : projectilesNeedingDisplayed) { // 3/4 - Draws a
        // projectile
        Entity victim = p.getVictim();
        if (victim instanceof Npc) {
          updates.addShort(p.getCaster().getIndex());
          updates.addByte((byte) 3);
          updates.addShort(p.getType());
          updates.addShort(((Npc) victim).getIndex());
View Full Code Here

Examples of org.nutz.dao.entity.Entity

  }
  public String getClassNameByTableName(String tableName){
    EntityHolder entities=(EntityHolder) CommonUtils.getProperty(dao, "entities");
    Map<Class<?>, Entity<?>> mappings=(Map<Class<?>, Entity<?>>) CommonUtils.getProperty(entities, "mappings");
    Collection<Entity<?>> beanEntities=mappings.values();
    Entity beanEntity=null;
    for (Entity<?> entity : beanEntities) {
      if(entity.getTableName().equals(tableName)){
        beanEntity=entity;
        break;
      }
    }
    if(beanEntity!=null){
      return beanEntity.getType().getName();
    }
    return null;
  }
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.