Package org.molgenis.util.tuple

Examples of org.molgenis.util.tuple.WritableTuple


    { "fam", "ind", "fa", "mo", "sex", "phen" };
  }

  public static Tuple famToTuple(FamEntry fam)
  {
    WritableTuple tuple = new KeyValueTuple();
    tuple.set("fam", fam.getFamily());
    tuple.set("ind", fam.getIndividual());
    tuple.set("fa", fam.getFather());
    tuple.set("mo", fam.getMother());
    tuple.set("sex", fam.getSex());
    tuple.set("phen", fam.getPhenotype());
    return tuple;
  }
View Full Code Here


    { "fam", "ind", "fa", "mo", "sex", "phen", "bial" };
  }

  public static Tuple pedToTuple(PedEntry ped)
  {
    WritableTuple tuple = new KeyValueTuple();
    tuple.set("fam", ped.getFamily());
    tuple.set("ind", ped.getIndividual());
    tuple.set("fa", ped.getFather());
    tuple.set("mo", ped.getMother());
    tuple.set("sex", ped.getSex());
    tuple.set("phen", ped.getPhenotype());
    tuple.set("bial", ped.getBialleles());
    return tuple;
  }
View Full Code Here

    { "chr", "snp", "cm", "bp", "al1", "al2" };
  }

  public static Tuple bimToTuple(BimEntry bim)
  {
    WritableTuple tuple = new KeyValueTuple();
    tuple.set("chr", bim.getChromosome());
    tuple.set("snp", bim.getSNP());
    tuple.set("cm", bim.getcM());
    tuple.set("bp", bim.getBpPos());
    tuple.set("al1", bim.getBiallele().getAllele1());
    tuple.set("al2", bim.getBiallele().getAllele2());
    return tuple;
  }
View Full Code Here

    { "chr", "snp", "cm", "bp" };
  }

  public static Tuple mapToTuple(MapEntry map)
  {
    WritableTuple tuple = new KeyValueTuple();
    tuple.set("chr", map.getChromosome());
    tuple.set("snp", map.getSNP());
    tuple.set("cm", map.getcM());
    tuple.set("bp", map.getBpPos());
    return tuple;
  }
View Full Code Here

    { "chr", "snp", "cm", "bp", "bial" };
  }

  public static Tuple tpedToTuple(TpedEntry tped)
  {
    WritableTuple tuple = new KeyValueTuple();
    tuple.set("chr", tped.getChromosome());
    tuple.set("snp", tped.getSNP());
    tuple.set("cm", tped.getcM());
    tuple.set("bp", tped.getBpPos());
    tuple.set("bial", tped.getBialleles());
    return tuple;
  }
View Full Code Here

    TupleTable tableModel = mock(TupleTable.class);
    Field field1 = when(mock(Field.class).getName()).thenReturn("col1").getMock();
    Field field2 = when(mock(Field.class).getName()).thenReturn("col2").getMock();
    Field field3 = when(mock(Field.class).getName()).thenReturn("col3").getMock();
    when(tableModel.getColumns()).thenReturn(Arrays.asList(field1, field2, field3));
    WritableTuple row1 = new KeyValueTuple();
    row1.set("col1", "val1.1");
    row1.set("col2", "val1.2");
    row1.set("col3", "val1.3");
    WritableTuple row2 = new KeyValueTuple();
    row2.set("col1", "val2.1");
    row2.set("col2", "val2.2");
    row2.set("col3", "val2.3");
    when(tableModel.iterator()).thenReturn(Arrays.<Tuple> asList(row1, row2).iterator());

    ExcelExporter excelExporter = new ExcelExporter(tableModel);
    File xlsFile = File.createTempFile("table", ".xls");
    try
    {
      excelExporter.export(new FileOutputStream(xlsFile));

      // check output
      ExcelReader excelReader = new ExcelReader(xlsFile);
      ExcelSheetReader sheetReader = excelReader.getSheet("Sheet1");
      try
      {
        Iterator<Tuple> it = sheetReader.iterator();
        assertTrue(it.hasNext());
        Tuple tuple1 = it.next();
        assertEquals(tuple1.getString("col1"), row1.getString("col1"));
        assertEquals(tuple1.getString("col2"), row1.getString("col2"));
        assertEquals(tuple1.getString("col3"), row1.getString("col3"));
        assertTrue(it.hasNext());
        Tuple tuple2 = it.next();
        assertEquals(tuple2.getString("col1"), row2.getString("col1"));
        assertEquals(tuple2.getString("col2"), row2.getString("col2"));
        assertEquals(tuple2.getString("col3"), row2.getString("col3"));
        assertFalse(it.hasNext());
      }
      finally
      {
        IOUtils.closeQuietly(sheetReader);
View Full Code Here

    // verify that offsets and limits are ignored during export
    Field field1 = when(mock(Field.class).getName()).thenReturn("col1").getMock();
    Field field2 = when(mock(Field.class).getName()).thenReturn("col2").getMock();
    Field field3 = when(mock(Field.class).getName()).thenReturn("col3").getMock();
    when(tableModel.getColumns()).thenReturn(Arrays.asList(field1, field2, field3));
    WritableTuple row1 = new KeyValueTuple();
    row1.set("col1", "val1.1");
    row1.set("col2", "val1.2");
    row1.set("col3", "val1.3");
    WritableTuple row2 = new KeyValueTuple();
    row2.set("col1", "val2.1");
    row2.set("col2", "val2.2");
    row2.set("col3", "val2.3");
    when(tableModel.iterator()).thenReturn(Arrays.<Tuple> asList(row1, row2).iterator());

    ExcelExporter excelExporter = new ExcelExporter(tableModel);
    File xlsFile = File.createTempFile("table", ".xls");
    try
    {
      excelExporter.export(new FileOutputStream(xlsFile));

      // check output
      ExcelReader excelReader = new ExcelReader(xlsFile);
      ExcelSheetReader sheetReader = excelReader.getSheet("Sheet1");
      try
      {
        Iterator<Tuple> it = sheetReader.iterator();
        assertTrue(it.hasNext());
        Tuple tuple1 = it.next();
        assertEquals(tuple1.getString("col1"), row1.getString("col1"));
        assertEquals(tuple1.getString("col2"), row1.getString("col2"));
        assertEquals(tuple1.getString("col3"), row1.getString("col3"));
        assertTrue(it.hasNext());
        Tuple tuple2 = it.next();
        assertEquals(tuple2.getString("col1"), row2.getString("col1"));
        assertEquals(tuple2.getString("col2"), row2.getString("col2"));
        assertEquals(tuple2.getString("col3"), row2.getString("col3"));
        assertFalse(it.hasNext());
      }
      finally
      {
        IOUtils.closeQuietly(sheetReader);
View Full Code Here

      }

      ScreenMessage msg = null;

      // cleanup the request, only use ticked (marked with 'use_'
      WritableTuple tuple = new KeyValueTuple();
      for (HtmlInput<?> input : this.getFormScreen().getNewRecordForm().getInputs())
      {
        if (!request.isNull("use_" + input.getName()))
        {
          tuple.set(input.getName(), request.get(input.getName()));
        }
      }

      int row = 0;
      try
View Full Code Here

      QueryRule rule = new QueryRule(request.getString("attribute"), QueryRule.Operator.valueOf(request
          .getString("operator")), request.getString("value"));
      pager.addFilter(rule);

      // tell "my" menu to select me
      WritableTuple tuple = new KeyValueTuple();
      String aChildName = getModel().getName();
      ScreenController<?> aParent = getParent();
      while (aParent != null)
      {
        if (aParent instanceof MenuController)
        {
          tuple.set("select", aChildName);
          MenuController c = (MenuController) aParent;
          c.doSelect(tuple);
        }
        aChildName = aParent.getName();
        aParent = aParent.getParent();
View Full Code Here

    { "rawtypes" })
    @Override
    public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
    {
      // transform params
      WritableTuple tuple = new KeyValueTuple();
      for (Object key : params.keySet())
      {
        if (params.get(key) instanceof SimpleScalar)
        {
          tuple.set(key.toString(), ((SimpleScalar) params.get(key)).toString());
        }
        else
        {
          tuple.set(key.toString(), params.get(key));
        }
      }

      // try to get html
      try
View Full Code Here

TOP

Related Classes of org.molgenis.util.tuple.WritableTuple

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.