Package org.molgenis.model.elements

Examples of org.molgenis.model.elements.Field


        {
          enumOptions.add(firstToUpper(subclass.getName()));
        }
        if (e.getField(Field.TYPE_FIELD) == null)
        {
          Field type_field = new Field(e, new EnumField(), Field.TYPE_FIELD, Field.TYPE_FIELD, true, false,
              true, null);
          type_field.setDescription("Subtypes have to be set to allow searching");
          // FIXME should be true, but breaks existing apps
          // type_field.setSystem(true);
          type_field.setHidden(true);
          e.addField(0, type_field);
        }
        e.getField(Field.TYPE_FIELD).setEnumOptions(enumOptions);
      }
      else
View Full Code Here


      {
        try
        {
          // retrieve the references to the entity+field
          Entity xref_entity_to = xref_field_from.getXrefEntity();
          Field xref_field_to = xref_field_from.getXrefField();

          // TODO: check whether this link is already present

          // create the new entity for the link, if explicitly named
          String mref_name = xref_field_from.getMrefName(); // explicit

          // if mref_name longer than 30 throw error
          if (options.db_driver.toLowerCase().contains("oracle") && mref_name.length() > 30)
          {
            throw new MolgenisModelException("mref_name cannot be longer then 30 characters, found: "
                + mref_name);
          }

          // check if the mref already exists
          Entity mrefEntity = null;
          try
          {
            mrefEntity = model.getEntity(mref_name);
          }
          catch (Exception e)
          {
          }

          // if mref entity doesn't exist: create
          if (mrefEntity == null)
          {
            mrefEntity = new Entity(mref_name, mref_name, model.getDatabase());
            mrefEntity.setNamespace(xref_entity_from.getNamespace());
            mrefEntity.setAssociation(true);
            mrefEntity.setDescription("Link table for many-to-many relationship '"
                + xref_entity_from.getName() + "." + xref_field_from.getName() + "'.");
            mrefEntity.setSystem(true);

            // create id field to ensure ordering
            Field idField = new Field(mrefEntity, new IntField(), "autoid", "autoid", true, false, false,
                null);
            idField.setHidden(true);
            idField.setDescription("automatic id field to ensure ordering of mrefs");
            mrefEntity.addField(idField);
            mrefEntity.addKey(idField.getName(), "unique auto key to ensure ordering of mrefs");

            // create the fields for the linktable
            Field field;
            Vector<String> unique = new Vector<String>();

            field = new Field(mrefEntity, new XrefField(), xref_field_from.getMrefRemoteid(), null, false,
                false, false, null);
            field.setXRefVariables(xref_entity_to.getName(), xref_field_to.getName(),
                xref_field_from.getXrefLabelNames());
            if (xref_field_from.isXrefCascade()) field.setXrefCascade(true);
            mrefEntity.addField(field);

            unique.add(field.getName());

            // add all the key-fields of xref_entity_from
            for (Field key : xref_entity_from.getKeyFields(Entity.PRIMARY_KEY))
            {
              field = new Field(mrefEntity, new XrefField(), xref_field_from.getMrefLocalid(), null,
                  false, false, false, null);

              // null xreflabel
              field.setXRefVariables(xref_entity_from.getName(), key.getName(), null);

              mrefEntity.addField(field);
              unique.add(field.getName());
            }

            // create the unique combination
            mrefEntity.addKey(unique, false, null);

          }
          // if mrefEntity does not exist, check xref_labels
          else
          {
            // field is xref_field, does it have label(s)?
            Field xrefField = mrefEntity.getAllField(xref_field_to.getName());

            // verify xref_label
            if (xrefField != null)
            {
              // logger.debug("adding xref_label "+xref_field_to.getXrefLabelNames()+"'back' for "+xrefField.getName());
              xrefField.setXrefLabelNames(xref_field_from.getXrefLabelNames());

            }
          }

          // set the linktable reference in the xref-field
View Full Code Here

  @Override
  public String getJavaPropertyType() throws MolgenisModelException
  {
    // Entity e_ref = f.getXrefEntity();
    Field f_ref = f.getXrefField();
    return "java.util.List<" + getFieldType(f_ref).getJavaPropertyType() + ">";
  }
View Full Code Here

  @Override
  public String getJavaPropertyDefault() throws MolgenisModelException
  {
    // Entity e_ref = f.getXrefEntity();
    Field f_ref = f.getXrefField();
    // if(f.getDefaultValue() == null || f.getDefaultValue() == "")
    // "new java.util.ArrayList<"+getFieldType(f_ref).getJavaPropertyType(f_ref)+">()";
    // FIXME can there be defaults here?
    return "new java.util.ArrayList<" + getFieldType(f_ref).getJavaPropertyType() + ">()";
  }
View Full Code Here

  @Override
  public String getJavaSetterType() throws MolgenisModelException
  {
    // Entity e_ref = f.getXrefEntity();
    Field f_ref = f.getXrefField();
    return "new java.util.ArrayList<" + getFieldType(f_ref).getJavaSetterType() + ">()";
  }
View Full Code Here

  // }

  @Override
  public String getCppPropertyType() throws MolgenisModelException
  {
    Field f_ref = f.getXrefField();
    return "vector<" + getFieldType(f_ref).getCppPropertyType() + ">";
  }
View Full Code Here

    // use first row
    if (rows.size() > 0)
    {
      for (String field : rows.get(0).getColNames())
      {
        Field f = new Field(field);
        f.setType(new StringField());
        columns.add(f);
      }
    }
  }
View Full Code Here

  }

  @Override
  public String getJavaPropertyType() throws MolgenisModelException
  {
    Field f_ref = f.getXrefField();
    return getFieldType(f_ref).getJavaPropertyType();
  }
View Full Code Here

  }

  @Override
  public String getCppPropertyType() throws MolgenisModelException
  {
    Field f_ref = f.getXrefField();
    return getFieldType(f_ref).getCppPropertyType();
  }
View Full Code Here

  }

  @Override
  public String getCppJavaPropertyType() throws MolgenisModelException
  {
    Field f_ref = f.getXrefField();
    return getFieldType(f_ref).getCppJavaPropertyType();
  }
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.