Package org.molgenis.util

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


   */
  public abstract Vector<String> getHeaders();

  public List<HtmlInput<?>> getInputs(String... fieldNames)
  {
    Entity entity = this.getEntity();
    List<HtmlInput<?>> inputs = this.getInputs();
    List<HtmlInput<?>> result = new ArrayList<HtmlInput<?>>();

    for (String fieldName : fieldNames)
    {
      if (!entity.getFields().contains(fieldName))
      {
        throw new RuntimeException(fieldName + " not known in " + this.getClass().getSimpleName());
      }

      for (HtmlInput<?> input : inputs)
      {
        // will this work always??
        if (input.getName().equalsIgnoreCase(entity.getClass().getSimpleName() + "_" + fieldName))
        {
          result.add(input);
        }
      }
    }
View Full Code Here

      if (attributeName.contains(".") || root.get(attributeName).getJavaType().getName().equals("java.util.List")
          || root.get(attributeName).getJavaType().newInstance() instanceof Entity)
      {

        Entity entity = root.getJavaType().newInstance();
        String xrefAttribtename = entity.getXrefIdFieldName(attributeName);

        String[] attributeNameSplit = StringUtils.split(attributeName, ".");
        if (attributeNameSplit.length == 0)
        {
          return null;
View Full Code Here

  }

  @Test
  public void getString()
  {
    Entity entity = when(mock(Entity.class).get("col1")).thenReturn("val1").getMock();
    assertEquals(new EntityTuple(entity).get("col1"), "val1");
  }
View Full Code Here

  {
    Vector<String> fields = new Vector<String>();
    fields.add("col1");
    fields.add("col2");

    Entity entity = mock(Entity.class);
    when(entity.get("col1")).thenReturn("val1").getMock();
    when(entity.get("col2")).thenReturn("val2").getMock();
    when(entity.getFields()).thenReturn(fields);

    EntityTuple entityTuple = new EntityTuple(entity);
    assertEquals(entityTuple.get("col1"), "val1");
    assertEquals(entityTuple.get("col2"), "val2");
  }
View Full Code Here

  {
    Vector<String> fields = new Vector<String>();
    fields.add("col1");
    fields.add("col2");

    Entity entity = when(mock(Entity.class).getFields()).thenReturn(fields).getMock();

    EntityTuple entityTuple = new EntityTuple(entity);
    Iterator<String> colNames = entityTuple.getColNames().iterator();
    assertEquals(colNames.next(), "col1");
    assertEquals(colNames.next(), "col2");
View Full Code Here

  {
    Vector<String> fields = new Vector<String>();
    fields.add("col1");
    fields.add("col2");

    Entity entity = when(mock(Entity.class).getFields()).thenReturn(fields).getMock();
    assertEquals(new EntityTuple(entity).getNrCols(), 2);
  }
View Full Code Here

   * @throws IOException
   */
  public boolean doAdd(Database db, MolgenisRequest request) throws ParseException, DatabaseException, IOException
  {
    ScreenMessage msg = null;
    Entity entity = getModel().create();
    boolean result = false;

    try
    {
      db.beginTx();
      entity.set(request, false);
      int updatedRows = 0;
      if (request.get(FormModel.INPUT_BATCHADD) != null && request.getInt(FormModel.INPUT_BATCHADD) > 1)
      {
        // batch
        int i;
View Full Code Here

  }

  // helper method
  protected void doUpdate(Database db, MolgenisRequest request) throws DatabaseException, IOException, ParseException
  {
    Entity entity = getModel().create();
    ScreenMessage msg = null;
    try
    {
      entity.set(request, false);
      int updatedRows = db.update(entity);
      msg = new ScreenMessage("UPDATE SUCCESS: affected " + updatedRows, null, true);
    }
    catch (Exception e)
    {
View Full Code Here

  }

  // helper method
  protected void doRemove(Database db, MolgenisRequest request) throws DatabaseException, ParseException, IOException
  {
    Entity entity = getModel().create();
    ScreenMessage msg = null;
    try
    {
      entity.set(request);
      int updatedRows = db.remove(entity);
      if (updatedRows > 0) msg = new ScreenMessage("REMOVE SUCCESS: affected " + updatedRows, null, true);
      else
        msg = new ScreenMessage("REMOVE FAILED: call system administrator", null, false);
    }
View Full Code Here

TOP

Related Classes of org.molgenis.util.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.