Package org.molgenis.model.elements

Examples of org.molgenis.model.elements.Field


          // && field.getType() instanceof MrefField) throw new
          // MolgenisModelException(
          // "interfaces cannot have mref therefore remove '"
          // + entityname + "." + fieldname + "'");

          Field xref_field = xref_entity.getField(xref_field_name, false, true, true);

          if (xref_field == null) throw new MolgenisModelException("xref field '" + xref_field_name
              + "' does not exist for field " + entityname + "." + fieldname);

          // if (xref_field == null) xref_field =
          // xref_entity.getPrimaryKey();
          // throw new MolgenisModelException("xref field '" +
          // xref_field_name
          // + "' does not exist for field " + entityname + "." +
          // fieldname);

          for (String xref_label_name : xref_label_names)
          {
            Field xref_label = null;
            // test if label is defined as {entity}.{field}
            if (xref_label_name.contains("."))
            {
              xref_label = model.findField(xref_label_name);
            }
View Full Code Here


        // a primary key can have only one field.
        // usually it is a auto_number int
        // composite keys are ignored
        try
        {
          Field pkeyField = null;
          if (iface.getKeyFields(Entity.PRIMARY_KEY).size() == 1)
          {
            pkeyField = iface.getKeyFields(Entity.PRIMARY_KEY).get(0);
            // if not already exists
            if (entity.getField(pkeyField.getName()) == null)
            {
              Field field = new Field(pkeyField);
              field.setEntity(entity);
              field.setAuto(pkeyField.isAuto());
              field.setNillable(pkeyField.isNillable());
              field.setReadonly(pkeyField.isReadOnly());
              field.setXRefVariables(iface.getName(), pkeyField.getName(), null);
              field.setHidden(true);

              logger.debug("copy primary key " + field.getName() + " from interface " + iface.getName()
                  + " to " + entity.getName());
              entity.addField(field);

            }
          }
View Full Code Here

          // copy key fields to interface and unset auto key in child
          Vector<Field> keyfields = entity.getKey(0).getFields();
          Vector<String> keyfields_copy = new Vector<String>();
          for (Field f : keyfields)
          {
            Field key_field = new Field(rootAncestor, f.getType(), f.getName(), f.getName(), f.isAuto(),
                f.isNillable(), f.isReadOnly(), f.getDefaultValue());
            key_field.setDescription("Primary key field unique in " + entity.getName()
                + " and its subclasses.");
            if (key_field.getType() instanceof StringField) key_field.setVarCharLength(key_field
                .getVarCharLength());
            rootAncestor.addField(key_field);
            keyfields_copy.add(key_field.getName());

            if (f.isAuto())
            {
              // unset auto key in original, but

              // SOLVED BY TRIGGERS Field autoField =
              // entity.getField(f.getName());
              // SOLVED BY TRIGGERS autoField.setAuto(false);

            }
          }
          rootAncestor.addKey(keyfields_copy, entity.getKey(0).isSubclass(), null);

          Vector<String> parents = new Vector<String>();
          parents.add(rootAncestor.getName());
          entity.setParents(parents);
        }

        // add the type enum to the root element
        Vector<Entity> subclasses = entity.getAllDescendants();
        Vector<String> enumOptions = new Vector<String>();
        enumOptions.add(entity.getName());
        for (Entity subclass : subclasses)
        {
          enumOptions.add(subclass.getName());
        }
        Field type_field = new Field(rootAncestor, new EnumField(), Field.TYPE_FIELD, Field.TYPE_FIELD, true,
            false, false, null);
        type_field.setDescription("Subtypes of " + entity.getName() + ". Have to be set to allow searching");
        type_field.setEnumOptions(enumOptions);
        type_field.setHidden(true);
        rootAncestor.addField(0, type_field);
      }
    }
  }
View Full Code Here

  {
    FieldType type = field.getType();
    if (type instanceof XrefField || type instanceof MrefField)
    {
      // Entity e_ref = field.getXrefEntity();
      Field f_ref = field.getXrefField();
      return getFieldType(model, f_ref);
    }
    else
    {
      return type;
View Full Code Here

          for (Field f : aKey.getFields())
          {
            if (e.getField(f.getName()) == null)
            {
              // copy the field
              Field copy = new Field(f);
              copy.setEntity(e);
              copy.setAuto(f.isAuto());
              e.addField(copy);

              logger.debug(aKey.toString() + " cannot be enforced on " + e.getName() + ", copying "
                  + f.getEntity().getName() + "." + f.getName() + " to subclass as " + copy.getName());
            }
          }
        }

      }
View Full Code Here

    load();
    if (rs.size() > 0)
    {
      List<Field> columns = new ArrayList<Field>();
      for (String colName : rs.get(0).getColNames())
        columns.add(new Field(colName));
      return columns;
    }
    return new ArrayList<Field>();
  }
View Full Code Here

   */
  private void loadColumns() throws Exception
  {
    for (Iterator<String> it = csvReader.colNamesIterator(); it.hasNext();)
    {
      Field f = new Field(it.next());
      columns.add(f);
    }
  }
View Full Code Here

      {
        if (metadata.getColumnName(i) == null)
        {
          System.out.println("column name for column " + i + " unknown,sql=" + sql);
        }
        Field f = new Field(metadata.getColumnLabel(i));
        f.setType(MolgenisFieldTypes.getTypeBySqlTypesCode(metadata.getColumnType(i)));
        fieldTypes.add(f);
      }

      // transform result set in entity list
      List<Tuple> tuples = new ArrayList<Tuple>();
View Full Code Here

TOP

Related Classes of org.molgenis.model.elements.Field

Copyright © 2018 www.massapicom. 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.