org.jooq.Record4 Java Examples

The following examples show how to use org.jooq.Record4. 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: InformationSchemaRepository.java    From sql-to-jdl with MIT License 4 votes vote down vote up
private TableRelationInformation map(final Record4<String, String, String, String> r) {
    return new TableRelationInformation(r.value1(), r.value2(), r.value3(), r.value4());
}
 
Example #2
Source File: CMSCrawler.java    From oneops with Apache License 2.0 4 votes vote down vote up
public Map<String, Organization> populateOrganizations(Connection conn) {

    log.info("Populating organizations cache");
    DSLContext create = DSL.using(conn, SQLDialect.POSTGRES);
    Map<String, Organization> organizationsMap = new HashMap<>();

    Result<Record4<Long, String, Integer, String>> OrganizationsWithAttributesRecords = create
        .select(CM_CI.CI_ID, CM_CI.CI_NAME, CM_CI_ATTRIBUTES.ATTRIBUTE_ID,
            CM_CI_ATTRIBUTES.DF_ATTRIBUTE_VALUE)
        .from(CM_CI).join(CM_CI_ATTRIBUTES).on(CM_CI.CI_ID.eq(CM_CI_ATTRIBUTES.CI_ID))
        .where(CM_CI.CLASS_ID.in(create.select(MD_CLASSES.CLASS_ID).from(MD_CLASSES)
            .where(MD_CLASSES.CLASS_NAME.eq("account.Organization"))))
        .fetch();

    List<Long> OrganizationIds = OrganizationsWithAttributesRecords.getValues(CM_CI.CI_ID);
    log.debug("OrganizationIds: " + OrganizationIds.toString());

    Set<Long> setOfOrganizationIds = new HashSet<Long>(OrganizationIds);
    log.debug("setOfOrganizationIds <" + setOfOrganizationIds.size() + "> " + setOfOrganizationIds);

    List<String> OrganizationNames = OrganizationsWithAttributesRecords.getValues(CM_CI.CI_NAME);
    log.debug("OrganizationNames: " + OrganizationNames.toString());

    Set<String> setOfOrganizationNames = new HashSet<String>(OrganizationNames);
    log.debug("setOfOrganizationNames: <" + setOfOrganizationNames.size() + "> "
        + setOfOrganizationNames);

    int description_AttribID =
        this.baseOrganizationMDClassAttributes_NameIdMapCache.get("description");
    int full_name_AttribID = this.baseOrganizationMDClassAttributes_NameIdMapCache.get("full_name");
    int owner_AttribID = this.baseOrganizationMDClassAttributes_NameIdMapCache.get("owner");
    int tags_AttribID = this.baseOrganizationMDClassAttributes_NameIdMapCache.get("tags");

    for (Record4<Long, String, Integer, String> OrganizationsWithAttributesRecord : OrganizationsWithAttributesRecords) {
      long organizationId = OrganizationsWithAttributesRecord.getValue(CM_CI.CI_ID);

      String organizationName = OrganizationsWithAttributesRecord.getValue(CM_CI.CI_NAME);
      Organization organization = organizationsMap.get(organizationName);
      log.debug("organizationId: " + organizationId);
      if (organization == null) {
        organization = new Organization();
        organizationsMap.put(organizationName, organization);

      }

      int attributeID = OrganizationsWithAttributesRecord.getValue(CM_CI_ATTRIBUTES.ATTRIBUTE_ID);

      if (attributeID == description_AttribID) {
        organization.setDescription(
            OrganizationsWithAttributesRecord.getValue(CM_CI_ATTRIBUTES.DF_ATTRIBUTE_VALUE));

        continue;
      } else if (attributeID == full_name_AttribID) {
        organization.setFull_name(
            OrganizationsWithAttributesRecord.getValue(CM_CI_ATTRIBUTES.DF_ATTRIBUTE_VALUE));

        continue;

      } else if (attributeID == owner_AttribID) {
        organization.setOwner(
            OrganizationsWithAttributesRecord.getValue(CM_CI_ATTRIBUTES.DF_ATTRIBUTE_VALUE));

        continue;
      } else if (attributeID == tags_AttribID) {
        @SuppressWarnings("unchecked") 
        Map<String, String> tags = gson.fromJson(
            OrganizationsWithAttributesRecord.getValue(CM_CI_ATTRIBUTES.DF_ATTRIBUTE_VALUE),
            Map.class);
        organization.setTags(tags);
        
        continue;
      }


    }

    log.info("Caching for Org Data Complete");
    return organizationsMap;
  }