Package org.molgenis.model.elements

Examples of org.molgenis.model.elements.Entity


    {
      // Generate the interface if rootAncestor (so has subclasses) and
      // itself is not an interface...
      if (entity.isRootAncestor())
      {
        Entity rootAncestor = entity;
        if (!entity.isAbstract())
        {

          // generate a new interface
          rootAncestor = new Entity("_" + entity.getName() + "Interface", entity.getName(),
              model.getDatabase());
          rootAncestor
              .setDescription("Identity map table for "
                  + entity.getName()
                  + " and all its subclasses. "
                  + "For each row that is added to "
                  + entity.getName()
                  + " or one of its subclasses, first a row must be added to this table to get a valid primary key value.");
          // rootAncestor.setAbstract( true );

          // 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


                mrefEntityName = mrefEntityName.substring(0, 25)
                    + Integer.toString(mrefEntityName.hashCode()).substring(0, 5);
              }

              // paranoia check on uniqueness
              Entity mrefEntity = null;
              try
              {
                mrefEntity = model.getEntity(mrefEntityName);
              }
              catch (Exception exc)
View Full Code Here

        if (f.getType() instanceof XrefField || f.getType() instanceof MrefField)
        {
          try
          {
            // correct for uppercase/lowercase typo's
            Entity xrefEntity = f.getXrefEntity();
            f.setXRefEntity(xrefEntity.getName());

            String xrefField = f.getXrefField().getName();

            List<String> xrefLabels = f.getXrefLabelsTemp();
            List<String> correctedXrefLabels = new ArrayList<String>();
            for (String xrefLabel : xrefLabels)
            {
              correctedXrefLabels.add(xrefEntity.getAllField(xrefLabel).getName());
            }
            f.setXRefVariables(xrefEntity.getName(), xrefField, correctedXrefLabels);
          }
          catch (Exception exception)
          {
            // exception.printStackTrace();
            // logger.error(exception);
View Full Code Here

    {
      if (field.getType() instanceof XrefField)
      {
        dependencies.add(model.getEntity(field.getXrefEntityName()).getName());

        Entity xrefEntity = field.getXrefEntity();

        // also all subclasses have this xref!!!!
        for (Entity e : xrefEntity.getAllDescendants())
        {
          if (!dependencies.contains(e.getName())) dependencies.add(e.getName());
        }
      }
      if (field.getType() instanceof MrefField)
View Full Code Here

TOP

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

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.