Java Code Examples for org.jooq.Record#get()

The following examples show how to use org.jooq.Record#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EnsemblDAO.java    From hmftools with GNU General Public License v3.0 6 votes vote down vote up
private int findCoordSystemId()
{
    final String version = mRefGenomeVersion == HG37 ? "GRCh37" : "GRCh38";

    final String queryStr = "select coord_system_id from coord_system"
            + " where version = '" + version + "'"
            + " order by rank  limit 1";

    LNX_LOGGER.debug("gene query: {}", queryStr);

    Result<?> results = mDbContext.fetch(queryStr);

    for(final Record record : results)
    {
        UInteger coordSystemId = (UInteger) record.get("coord_system_id");
        return coordSystemId.intValue();
    }

    return -1;
}
 
Example 2
Source File: Dao.java    From StubbornJava with MIT License 5 votes vote down vote up
/**
 * [#2700] [#3582] If a POJO attribute is NULL, but the column is NOT NULL
 * then we should let the database apply DEFAULT values
 */
private static final void resetChangedOnNotNull(Record record) {
    int size = record.size();

    for (int i = 0; i < size; i++)
        if (record.get(i) == null)
            if (!record.field(i).getDataType().nullable())
                record.changed(i, false);
}
 
Example 3
Source File: EnsemblDAO.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
private void writeGeneData(final String outputFile)
{
    LNX_LOGGER.info("caching gene data to {}", outputFile);

    try
    {
        BufferedWriter writer = createBufferedWriter(outputFile, false);

        writer.write("GeneId,GeneName,Chromosome,Strand,GeneStart,GeneEnd,EntrezIds,KaryotypeBand,Synonyms");
        writer.newLine();

        Result<?> results = queryAllGeneData();

        for(final Record record : results)
        {
            UInteger geneStart = (UInteger) record.get("GeneStart");
            UInteger geneEnd = (UInteger) record.get("GeneEnd");
            Byte strand = (Byte) record.get("Strand");

            writer.write(String.format("%s,%s,%s,%d,%d,%d,%s,%s,%s",
                    record.get("GeneId"), record.get("GeneName"), record.get("Chromosome"),
                    strand.intValue(), geneStart.intValue(), geneEnd.intValue(),
                    record.get("EntrezIds"), record.get("KaryotypeBand"), record.get("Synonyms")));

            writer.newLine();
        }

        writer.close();
    }
    catch (final IOException e)
    {
        LNX_LOGGER.error("error writing Ensembl gene data file: {}", e.toString());
    }
}
 
Example 4
Source File: EnsemblDAO.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
private void writeTranscriptProteinData(final String outputFile)
{
    LNX_LOGGER.info("caching protein data to {}", outputFile);

    try
    {
        BufferedWriter writer = createBufferedWriter(outputFile, false);

        writer.write("TranscriptId,TranslationId,ProteinFeatureId,SeqStart,SeqEnd,HitDescription");
        writer.newLine();

        Result<?> results = queryAllProteinData();

        for(final Record record : results)
        {
            UInteger transcriptId = (UInteger) record.get("TranscriptId");
            UInteger translationId = (UInteger) record.get("TranslationId");
            UInteger proteinId = (UInteger) record.get("ProteinFeatureId");
            Integer seqStart = (Integer) record.get("SeqStart");
            Integer seqEnd = (Integer) record.get("SeqEnd");

            writer.write(String.format("%d,%d,%d,%d,%d,%s",
                    transcriptId.intValue(), translationId.intValue(), proteinId.intValue(),
                    seqStart.intValue(), seqEnd.intValue(), record.get("HitDescription")));

            writer.newLine();
        }

        writer.close();
    }
    catch (final IOException e)
    {
        LNX_LOGGER.error("error writing Ensembl trans-protein data file: {}", e.toString());
    }
}
 
Example 5
Source File: Dao.java    From StubbornJava with MIT License 5 votes vote down vote up
/**
 * [#2700] [#3582] If a POJO attribute is NULL, but the column is NOT NULL
 * then we should let the database apply DEFAULT values
 */
private static final void resetChangedOnNotNull(Record record) {
    int size = record.size();

    for (int i = 0; i < size; i++)
        if (record.get(i) == null)
            if (!record.field(i).getDataType().nullable())
                record.changed(i, false);
}
 
Example 6
Source File: CMSCrawler.java    From oneops with Apache License 2.0 4 votes vote down vote up
public Map<String, Cloud> getCloudsDataForPlatform(Connection conn, long platformId) {
  DSLContext create = DSL.using(conn, SQLDialect.POSTGRES);

  Map<String, Cloud> platformCloudMap = new HashMap<String, Cloud>();

  // Fetching All Clouds for platform
  Result<Record> cloudsInPlatformRecords = create.select().from(CM_CI_RELATIONS)
      .join(MD_RELATIONS).on(MD_RELATIONS.RELATION_ID.eq(CM_CI_RELATIONS.RELATION_ID)).join(CM_CI)
      .on(CM_CI.CI_ID.eq(CM_CI_RELATIONS.TO_CI_ID))
      .where(MD_RELATIONS.RELATION_NAME.eq("base.Consumes"))
      .and(CM_CI_RELATIONS.FROM_CI_ID.eq(platformId)).fetch();

  for (Record cloudsInPlatformRecord : cloudsInPlatformRecords) {

    long relationID = cloudsInPlatformRecord.get(CM_CI_RELATIONS.CI_RELATION_ID);
    long cloudCid = cloudsInPlatformRecord.get(CM_CI_RELATIONS.TO_CI_ID);
    String cloudName = cloudsInPlatformRecord.get(CM_CI.CI_NAME);

    Result<Record> cloudsPlatformRelationshipAttributesRecords =
        create.select().from(CM_CI_RELATION_ATTRIBUTES).join(MD_RELATION_ATTRIBUTES)
            .on(CM_CI_RELATION_ATTRIBUTES.ATTRIBUTE_ID.eq(MD_RELATION_ATTRIBUTES.ATTRIBUTE_ID))
            .where(CM_CI_RELATION_ATTRIBUTES.CI_RELATION_ID.eq(relationID)).fetch();
    Cloud cloud = new Cloud();
    cloud.setId(cloudName);
    for (Record cloudsPlatformRelationshipAttributesRecord : cloudsPlatformRelationshipAttributesRecords) {

        String attributeValue = cloudsPlatformRelationshipAttributesRecord
              .get(CM_CI_ATTRIBUTES.DF_ATTRIBUTE_VALUE);

      switch (cloudsPlatformRelationshipAttributesRecord
          .get(MD_RELATION_ATTRIBUTES.ATTRIBUTE_NAME)) {
        case "priority":
            if (NumberUtils.isNumber(attributeValue)) {
                int priority = Integer.valueOf(attributeValue.trim());
                cloud.setPriority(priority);
            } else {
                log.warn("can not set priority attribute for cloudCid: " + cloudCid
                        + " , cloudName: " + cloudName + " attributeValue: " + attributeValue);
            }

          break;
        case "adminstatus":
          cloud.setAdminstatus(attributeValue);
          break;
        case "dpmt_order":
          if (NumberUtils.isNumber(attributeValue)) {
              cloud.setDeploymentorder(Integer.valueOf(attributeValue.trim()));
          } else {
              log.warn("can not set dpmt order attribute for cloudCid: " + cloudCid
                      + " , cloudName: " + cloudName + " attributeValue: " + attributeValue);
          }
          break;
        case "pct_scale":
            if (NumberUtils.isNumber(attributeValue)) {
                cloud.setScalepercentage(Integer.valueOf(attributeValue.trim()));
            } else {
                log.warn("can not set pct_scale attribute for cloudCid: " + cloudCid
                        + " , cloudName: " + " attributeValue: " + attributeValue);
            }
          break;
      }
    }
    platformCloudMap.put(cloudName, cloud);


  }

  return platformCloudMap;

}
 
Example 7
Source File: EnsemblDAO.java    From hmftools with GNU General Public License v3.0 4 votes vote down vote up
private void writeTranscriptExonData(final String outputFile)
{
    LNX_LOGGER.info("caching transcript & exon data to {}", outputFile);

    try
    {
        BufferedWriter writer = createBufferedWriter(outputFile, false);

        writer.write("GeneId,CanonicalTranscriptId,Strand,TransId,TransName,BioType,TransStart,TransEnd");
        writer.write(",ExonRank,ExonStart,ExonEnd,ExonPhase,ExonEndPhase,CodingStart,CodingEnd");
        writer.newLine();

        Result<?> results = queryAllTranscriptExonData();

        for(final Record record : results)
        {
            UInteger canTransId = (UInteger) record.get("CanonicalTranscriptId");
            UInteger transId = (UInteger) record.get("TransId");
            Byte strand = (Byte) record.get("Strand");
            UInteger transStart = (UInteger) record.get("TransStart");
            UInteger transEnd = (UInteger) record.get("TransEnd");
            Integer exonRank = (Integer) record.get("ExonRank");
            UInteger exonStart = (UInteger) record.get("ExonStart");
            UInteger exonEnd = (UInteger) record.get("ExonEnd");
            Byte exonPhase = (Byte) record.get("ExonPhase");
            Byte exonPhaseEnd = (Byte) record.get("ExonEndPhase");
            ULong codingStart = (ULong) record.get("CodingStart");
            ULong codingEnd = (ULong) record.get("CodingEnd");

            writer.write(String.format("%s,%d,%d,%d,%s,%s,%d,%d",
                    record.get("GeneId"), canTransId.intValue(), strand, transId.intValue(),
                    record.get("Trans"), record.get("BioType"), transStart.intValue(), transEnd.intValue()));

            writer.write(String.format(",%d,%d,%d,%d,%d,%s,%s",
                    exonRank.intValue(), exonStart.intValue(), exonEnd.intValue(), exonPhase, exonPhaseEnd,
                    codingStart != null ? codingStart.intValue() : "NULL",
                    codingEnd != null ? codingEnd.intValue() : "NULL"));

            writer.newLine();
        }

        writer.close();
    }
    catch (final IOException e)
    {
        LNX_LOGGER.error("error writing Ensembl trans-exon data file: {}", e.toString());
    }
}
 
Example 8
Source File: Utils.java    From FROST-Server with GNU Lesser General Public License v3.0 3 votes vote down vote up
/**
 * Get the given Field from the record, or null if the record does not have
 * the Field.
 *
 * @param <T> The type of the requested Field.
 * @param record The record to fetch the field from.
 * @param field The field to fetch from the record.
 * @return The value of the field, or null if the record does not have the
 * Field.
 */
public static <T> T getFieldOrNull(Record record, Field<T> field) {
    if (record.field(field) != null) {
        return record.get(field);
    }
    return null;
}