Java Code Examples for org.jooq.DSLContext

The following examples show how to use org.jooq.DSLContext. These examples are extracted from open source projects. 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
private CommonTableExpression<Record7<Long, Long, Long, Long, String, Timestamp, Integer>>
    withRecursiveExpression(DSLContext sql, Long postId) {
    return name(PCS).fields("id", "root_id", "post_id", "parent_id", "review", "created_on", "score")
        .as(sql.select(
            POST_COMMENT.ID, POST_COMMENT.ID, POST_COMMENT.POST_ID, POST_COMMENT.PARENT_ID, POST_COMMENT.REVIEW,
            POST_COMMENT.CREATED_ON, POST_COMMENT.SCORE)
        .from(POST_COMMENT)
        .where(POST_COMMENT.POST_ID.eq(postId).and(POST_COMMENT.PARENT_ID.isNull()))
        .unionAll(
            sql.select(
                POST_COMMENT.ID, field(name("post_comment_score", "root_id"), Long.class),
                POST_COMMENT.POST_ID, POST_COMMENT.PARENT_ID, POST_COMMENT.REVIEW, POST_COMMENT.CREATED_ON,
                POST_COMMENT.SCORE)
            .from(POST_COMMENT)
            .innerJoin(table(name(PCS)))
            .on(POST_COMMENT.PARENT_ID.eq(field(name(PCS, "id"), Long.class)))
        )
    );
}
 
Example 2
Source Project: waltz   Source File: SampleDataGenerator.java    License: Apache License 2.0 6 votes vote down vote up
default boolean deleteRatingsForCategory(DSLContext dsl,
                                         long category) {
    Condition sampleMeasurableCondition = MEASURABLE.MEASURABLE_CATEGORY_ID.eq(category)
            .and(MEASURABLE.PROVENANCE.eq(SAMPLE_DATA_PROVENANCE));

    List<Long> mIds = dsl
            .select(MEASURABLE.ID)
            .from(MEASURABLE)
            .where(sampleMeasurableCondition)
            .fetch(MEASURABLE.ID);

    dsl.deleteFrom(MEASURABLE_RATING)
            .where(MEASURABLE_RATING.MEASURABLE_ID.in(mIds));

    dsl.deleteFrom(MEASURABLE)
            .where(sampleMeasurableCondition)
            .execute();

    return true;
}
 
Example 3
Source Project: SimpleFlatMapper   Source File: Issue318Test.java    License: MIT License 6 votes vote down vote up
@Test
public void testHsqlDb() throws SQLException {
    Connection conn = DbHelper.objectDb();

    DSLContext dsl = DSL
            .using(new DefaultConfiguration().set(conn)
                    .set(SQLDialect.HSQLDB)
                    .set(SfmRecordMapperProviderFactory.newInstance().ignorePropertyNotFound().newProvider()));

    List<Issue318> list = dsl.select()
            .from("issue318").fetchInto(Issue318.class);

    assertEquals(1, list.size());

    Issue318 value = list.get(0);

    assertTrue(Math.abs(value.getT().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() - System.currentTimeMillis()) < 10000);
    assertNotNull(value.getId());

}
 
Example 4
Source Project: oneops   Source File: CMSCrawler.java    License: Apache License 2.0 6 votes vote down vote up
private List<String> getActiveClouds(Platform platform, Connection conn) {
    DSLContext create = DSL.using(conn, SQLDialect.POSTGRES);
    List<String> clouds = new ArrayList<>();
    Result<Record> consumesRecords = create.select().from(CM_CI_RELATIONS)
            .join(MD_RELATIONS).on(MD_RELATIONS.RELATION_ID.eq(CM_CI_RELATIONS.RELATION_ID))
            .join(CM_CI_RELATION_ATTRIBUTES).on(CM_CI_RELATION_ATTRIBUTES.CI_RELATION_ID.eq(CM_CI_RELATIONS.CI_RELATION_ID))
            .where(CM_CI_RELATIONS.FROM_CI_ID.eq(platform.getId()))
            .and(CM_CI_RELATION_ATTRIBUTES.DF_ATTRIBUTE_VALUE.eq("active"))
            .fetch();
    for (Record r : consumesRecords) {
        String comments = r.getValue(CM_CI_RELATIONS.COMMENTS);
        String cloudName = comments.split(":")[1];
        cloudName = cloudName.split("\"")[1];
        clouds.add(cloudName);
    }
    return clouds;
}
 
Example 5
Source Project: bouncr   Source File: V2__CreateGroups.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void migrate(Context context) throws Exception {
    Connection connection = context.getConnection();
    try (Statement stmt = connection.createStatement()) {
        DSLContext create = DSL.using(connection);
        String ddl = create.createTable(table("groups"))
                .column(field("group_id", SQLDataType.BIGINT.identity(true)))
                .column(field("name", SQLDataType.VARCHAR(100).nullable(false)))
                .column(field("description", SQLDataType.VARCHAR(100).nullable(false)))
                .column(field("write_protected", SQLDataType.BOOLEAN.nullable(false)))
                .constraints(
                        constraint().primaryKey(field("group_id")),
                        constraint().unique(field("name"))
                ).getSQL();
        stmt.execute(ddl);
    }
}
 
Example 6
Source Project: waltz   Source File: LogicalFlowHarness.java    License: Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws ParseException {

        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
        DSLContext dsl = ctx.getBean(DSLContext.class);
        LogicalFlowDao dao = ctx.getBean(LogicalFlowDao.class);
        LogicalFlowService service = ctx.getBean(LogicalFlowService.class);
        ApplicationIdSelectorFactory factory = new ApplicationIdSelectorFactory();

        IdSelectionOptions options = IdSelectionOptions.mkOpts(
                mkRef(EntityKind.PERSON, 262508),
                HierarchyQueryScope.CHILDREN);

        for (int i = 0; i < 5; i++) {
            List<LogicalFlow> flows = FunctionUtilities.time("Get flows", () -> service.findBySelector(options));
        }
    }
 
Example 7
public CompletionStage<Result> update(final String queries) {
    return getRandomWorlds(queryCount(queries)).thenApplyAsync(worlds -> {
        final Random random = ThreadLocalRandom.current();
        for (final WorldRecord world : worlds) {
            world.setRandomnumber((random.nextInt(10000) + 1));
        }

        final int batchSize = 25;
        final int batches = ((worlds.size() / batchSize) + 1);
        this.db.withConnection(connection -> {
            final DSLContext sql = DSL.using(connection, DIALECT);
            for ( int i = 0 ; i < batches ; ++i ) {
                sql.batchUpdate(worlds.subList(i * batchSize, Math.min((i + 1) * batchSize, worlds.size()))).execute();
            }
            return null;
        });

        return ok(worlds.formatJSON(JSON_FORMAT)).as(JSON);
    }, dbEc);
}
 
Example 8
Source Project: waltz   Source File: MeasurableExporterHarness.java    License: Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);


    long categoryId = 1L;

    SelectConditionStep<Record> qry = dsl
            .select(MEASURABLE.NAME, MEASURABLE.DESCRIPTION, MEASURABLE.ID, MEASURABLE.PARENT_ID, MEASURABLE.EXTERNAL_ID)
            .select(INVOLVEMENT_KIND.NAME)
            .select(PERSON.DISPLAY_NAME)
            .from(MEASURABLE)
            .leftJoin(INVOLVEMENT)
            .on(INVOLVEMENT.ENTITY_ID.eq(MEASURABLE.ID).and(INVOLVEMENT.ENTITY_KIND.eq(EntityKind.MEASURABLE.name())))
            .leftJoin(INVOLVEMENT_KIND)
            .on(INVOLVEMENT_KIND.ID.eq(INVOLVEMENT.KIND_ID))
            .leftJoin(PERSON)
            .on(PERSON.EMPLOYEE_ID.eq(INVOLVEMENT.EMPLOYEE_ID))
            .where(MEASURABLE.MEASURABLE_CATEGORY_ID.eq(categoryId));

    qry.fetch().forEach(System.out::println);

}
 
Example 9
public Delete buildDelete(PathElementEntitySet set) {
    gatherData();

    DSLContext dslContext = pm.getDslContext();
    final StaMainTable<J> table = tableCollection.getTablesByType().get(set.getEntityType());
    if (table == null) {
        throw new AssertionError("Don't know how to delete" + set.getEntityType().name(), new IllegalArgumentException("Unknown type for delete"));
    }

    SelectConditionStep<Record1<J>> idSelect = DSL.select(queryState.getSqlMainIdField())
            .from(queryState.getSqlFrom())
            .where(queryState.getSqlWhere());

    DeleteConditionStep<? extends Record> delete = dslContext
            .deleteFrom(table)
            .where(
                    table.getId().in(idSelect)
            );

    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace(GENERATED_SQL, delete.getSQL(ParamType.INDEXED));
    }
    return delete;
}
 
Example 10
private void linkExistingObservations(Datastream d, PostgresPersistenceManager<J> pm, DSLContext dslContext, J dsId) throws NoSuchEntityException {
    for (Observation o : d.getObservations()) {
        if (o.getId() == null || !entityFactories.entityExists(pm, o)) {
            throw new NoSuchEntityException(EntityType.OBSERVATION.entityName + NO_ID_OR_NOT_FOUND);
        }
        J obsId = (J) o.getId().getValue();
        AbstractTableObservations<J> tableObs = entityFactories.tableCollection.getTableObservations();
        long oCount = dslContext.update(tableObs)
                .set(tableObs.getDatastreamId(), dsId)
                .where(tableObs.getId().eq(obsId))
                .execute();
        if (oCount > 0) {
            LOGGER.debug("Assigned datastream {} to Observation {}.", dsId, obsId);
        }
    }
}
 
Example 11
Source Project: guice-persist-jooq   Source File: JooqPersistService.java    License: Apache License 2.0 6 votes vote down vote up
public void end() {
 DSLContext jooqFactory = threadFactory.get();
 DefaultConnectionProvider conn = threadConnection.get();
  // Let's not penalize users for calling end() multiple times.
  if (null == jooqFactory) {
    return;
  }

  try {
    logger.debug("Closing JDBC connection");
    conn.acquire().close();
  } catch (SQLException e) {
    throw new RuntimeException(e);
  }
  threadFactory.remove();
  threadConnection.remove();
}
 
Example 12
Source Project: waltz   Source File: HigherEducationTaxonomyImport.java    License: Apache License 2.0 6 votes vote down vote up
private int updateParentIdsUsingExtIds(DSLContext tx, long categoryId) {
    // clear existing parent ids
    dsl.update(MEASURABLE)
            .setNull(MEASURABLE.PARENT_ID)
            .where(MEASURABLE.MEASURABLE_CATEGORY_ID.eq(categoryId))
            .execute();

    Measurable c = MEASURABLE.as("c");
    Measurable p = MEASURABLE.as("p");
    return tx
            .update(c)
            .set(c.PARENT_ID, DSL
                    .select(p.ID)
                    .from(p)
                    .where(p.EXTERNAL_ID.eq(c.EXTERNAL_PARENT_ID))
                    .and(p.MEASURABLE_CATEGORY_ID.eq(categoryId)))
            .where(c.MEASURABLE_CATEGORY_ID.eq(categoryId))
            .execute();
}
 
Example 13
Source Project: bouncr   Source File: V21__CreateUserProfiles.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private void createProfileVerification(Connection connection) throws SQLException {
    DSLContext create = DSL.using(connection);

    try (Statement stmt = connection.createStatement()) {
        String ddl = create.createTable(table("user_profile_verifications"))
                .column(field("user_profile_field_id", SQLDataType.BIGINT.nullable(false)))
                .column(field("user_id", SQLDataType.BIGINT.nullable(false)))
                .column(field("code", SQLDataType.VARCHAR(255).nullable(false)))
                .column(field("expires_at", SQLDataType.TIMESTAMP.nullable(false)))
                .constraints(
                        constraint().primaryKey(field("user_profile_field_id"), field("user_id")),
                        constraint().foreignKey(field("user_profile_field_id"))
                                .references(table("user_profile_fields"), field("user_profile_field_id")).onDeleteCascade(),
                        constraint().foreignKey(field("user_id"))
                                .references(table("users"), field("user_id")).onDeleteCascade()
                )
                .getSQL();
        stmt.execute(ddl);
    }
}
 
Example 14
Source Project: bouncr   Source File: V8__CreateRolePermissions.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void migrate(Context context) throws Exception {
    Connection connection = context.getConnection();
    try (Statement stmt = connection.createStatement()) {
        DSLContext create = DSL.using(connection);
        String ddl = create.createTable(table("role_permissions"))
                .column(field("role_id", SQLDataType.BIGINT.nullable(false)))
                .column(field("permission_id", SQLDataType.BIGINT.nullable(false)))
                .constraints(
                        constraint().primaryKey(field("role_id"), field("permission_id")),
                        constraint().foreignKey(field("role_id")).references(table("roles"), field("role_id")).onDeleteCascade(),
                        constraint().foreignKey(field("permission_id")).references(table("permissions"), field("permission_id")).onDeleteCascade()
                ).getSQL();
        stmt.execute(ddl);
    }
}
 
Example 15
Source Project: waltz   Source File: ChangeUnitGenerator.java    License: Apache License 2.0 6 votes vote down vote up
private AttributeChangeRecord mkDataTypeChange(DSLContext dsl, ChangeUnit cu, PhysicalFlow flow, String name) {
    List<DataType> allDataTypes = dsl.selectFrom(DATA_TYPE)
            .fetch(DataTypeDao.TO_DOMAIN);

    List<DataType> newDataTypes = randomPick(allDataTypes, randomIntBetween(1, 5));
    String json = "["
            + joinUsing(newDataTypes, d -> String.format("{\"dataTypeId\": %s}", d.id().get()), ",")
            + "]";

    AttributeChangeRecord record = dsl.newRecord(ATTRIBUTE_CHANGE);
    record.setChangeUnitId(cu.id().get());
    record.setType("json");
    record.setOldValue("[]");
    record.setNewValue(json);
    record.setName(name);
    record.setLastUpdatedAt(DateTimeUtilities.nowUtcTimestamp());
    record.setLastUpdatedBy("admin");
    record.setProvenance(SAMPLE_DATA_PROVENANCE);
    return record;
}
 
Example 16
Source Project: hmftools   Source File: JaxDAOFunctions.java    License: GNU General Public License v3.0 5 votes vote down vote up
static void deleteAll(@NotNull DSLContext context) {
    context.deleteFrom(JAXMOLECULARPROFILE).execute();
    context.deleteFrom(JAXTHERAPY).execute();
    context.deleteFrom(JAXINDICATION).execute();
    context.deleteFrom(JAXREFERENCE).execute();

    context.deleteFrom(JAX).execute();
}
 
Example 17
Source Project: waltz   Source File: DatabaseHarness.java    License: Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws ParseException {

        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);

        DatabaseInformationService databaseInfoService = ctx.getBean(DatabaseInformationService.class);
        DatabaseInformationDao databaseDao = ctx.getBean(DatabaseInformationDao.class);
        DSLContext dsl = ctx.getBean(DSLContext.class);

        /*
        List<DatabaseInformation> dbs = databaseDao.findByApplicationId(801L);
        System.out.println(dbs.size());


        List<Tally<String>> eolCounts = calculateStringTallies(
                dsl,
                DATABASE_INFORMATION,
                DSL.when(DATABASE_INFORMATION.END_OF_LIFE_DATE.lt(DSL.currentDate()), DSL.inline(EndOfLifeStatus.END_OF_LIFE.name()))
                        .otherwise(DSL.inline(EndOfLifeStatus.NOT_END_OF_LIFE.name())),
                DSL.trueCondition());

        System.out.println(eolCounts);
        */

        IdSelectionOptions options = IdSelectionOptions.mkOpts(
                EntityReference.mkRef(EntityKind.ORG_UNIT, 10),
                HierarchyQueryScope.CHILDREN);

        for (int i = 0; i < 5; i++) {
            HarnessUtilities.time("stats", () -> databaseInfoService.calculateStatsForAppIdSelector(options));
        }


    }
 
Example 18
Source Project: keywhiz   Source File: SecretSeriesDAO.java    License: Apache License 2.0 5 votes vote down vote up
private SecretSeriesDAO(DSLContext dslContext, ObjectMapper mapper,
    SecretSeriesMapper secretSeriesMapper, RowHmacGenerator rowHmacGenerator) {
  this.dslContext = dslContext;
  this.mapper = mapper;
  this.secretSeriesMapper = secretSeriesMapper;
  this.rowHmacGenerator = rowHmacGenerator;
}
 
Example 19
Source Project: waltz   Source File: AppGroupEntryGenerator.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, Integer> create(ApplicationContext ctx) {
    DSLContext dsl = getDsl(ctx);

    List<Long> appIds = getAppIds(dsl);
    List<Long> groupIds = dsl
            .select(APPLICATION_GROUP.ID)
            .from(APPLICATION_GROUP)
            .fetch(APPLICATION_GROUP.ID);


    List<ApplicationGroupEntryRecord> records = groupIds
            .stream()
            .flatMap(id -> randomlySizedIntStream(0, 25)
                    .mapToLong(idx -> randomPick(appIds))
                    .distinct()
                    .mapToObj(appId -> {
                        ApplicationGroupEntryRecord record = dsl.newRecord(APPLICATION_GROUP_ENTRY);
                        record.setGroupId(id);
                        record.setApplicationId(appId);
                        return record;
                    }))
            .collect(Collectors.toList());

    dsl.batchStore(records).execute();

    return null;
}
 
Example 20
Source Project: waltz   Source File: SqlServerChangeInitiativeSearch.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<ChangeInitiative> searchFullText(DSLContext dsl, EntitySearchOptions options) {
    List<String> terms = mkTerms(options.searchQuery());
    return dsl.select(CHANGE_INITIATIVE.fields())
            .from(CHANGE_INITIATIVE)
            .where(JooqUtilities.MSSQL.mkContainsPrefix(terms))
            .limit(options.limit())
            .fetch(ChangeInitiativeDao.TO_DOMAIN_MAPPER);
}
 
Example 21
Source Project: StubbornJava   Source File: PostTags.java    License: MIT License 5 votes vote down vote up
public static void linkTagsToPost(DSLContext ctx, int appId, long postId, List<PostTag> tags) {
    ctx.deleteFrom(Tables.POST_TAG_LINKS)
       .where(Tables.POST_TAG_LINKS.POST_ID.eq(postId));
    List<PostTagLinksRecord> records = Seq.seq(tags)
                                          .map(t -> new PostTagLinksRecord(postId, t.getPostTagId()))
                                          .toList();
    ctx.batchInsert(records).execute();
}
 
Example 22
Source Project: keywhiz   Source File: ServiceModule.java    License: Apache License 2.0 5 votes vote down vote up
@Provides @Singleton
@Readonly DSLContext readonlyJooqContext(@Readonly ManagedDataSource dataSource)
    throws SQLException {
  DSLContext dslContext = DSLContexts.databaseAgnostic(dataSource);
  org.jooq.Configuration configuration = dslContext.configuration();
  // Disable support for nested transactions via savepoints (required for MySQL)
  // See: https://groups.google.com/forum/#!topic/jooq-user/zG0U6CkxI5o
  configuration.set(new DefaultTransactionProvider(configuration.connectionProvider(), false));
  return dslContext;
}
 
Example 23
private void createOtpKeys(Connection connection) throws SQLException {
    try (Statement stmt = connection.createStatement()) {
        DSLContext create = DSL.using(connection);
        String ddl = create.createTable(table("otp_keys"))
                .column(field("user_id", SQLDataType.BIGINT.nullable(false)))//
                .column(field("otp_key", SQLDataType.BINARY(20).nullable(false)))
                .constraints(
                        constraint().primaryKey(field("user_id")),
                        constraint().foreignKey(field("user_id")).references(table("users"), field("user_id")).onDeleteCascade()
                ).getSQL();
        stmt.execute(ddl);
    }
}
 
Example 24
Source Project: waltz   Source File: HigherEducationTaxonomyImport.java    License: Apache License 2.0 5 votes vote down vote up
private int removeNoLongerNeederCapabilities(DSLContext tx, Set<String> noLongerNeededIds) {
    return tx
            .update(MEASURABLE)
            .set(MEASURABLE.ENTITY_LIFECYCLE_STATUS, EntityLifecycleStatus.REMOVED.name())
            .where(MEASURABLE.ID.in(noLongerNeededIds))
            .execute();
}
 
Example 25
Source Project: waltz   Source File: SampleDataGenerator.java    License: Apache License 2.0 5 votes vote down vote up
default <T> List<T> loadAllIds(DSLContext dsl,
                               TableField<? extends Record, T> idCol,
                               Condition condition) {
    return dsl
            .select(idCol)
            .from(idCol.getTable())
            .where(condition)
            .fetch(idCol);
}
 
Example 26
Source Project: bouncr   Source File: V1__CreateUserLicense.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private void createUserLicense(DSLContext create, Statement stmt) throws SQLException {
    String ddl = create.createTable(table("user_licenses"))
            .column(field("user_license_id", SQLDataType.BIGINT.identity(true)))
            .column(field("user_id", SQLDataType.BIGINT.nullable(false)))
            .column(field("license_key", SQLDataType.VARBINARY(16).nullable(false)))
            .constraints(
                    constraint().primaryKey(field("user_license_id")),
                    constraint().foreignKey(field("user_id")).references(table("users"), field("user_id"))
                            .onDeleteCascade(),
                    constraint().unique(field("license_key"))
            ).getSQL();
    stmt.execute(ddl);
}
 
Example 27
private void upsertPostDetails(
    DSLContext sql, BigInteger id, String owner, Timestamp timestamp) {
    sql
    .insertInto(POST_DETAILS)
    .columns(POST_DETAILS.ID, POST_DETAILS.CREATED_BY, POST_DETAILS.CREATED_ON)
    .values(id, owner, timestamp)
    .onDuplicateKeyUpdate()
    .set(POST_DETAILS.UPDATED_BY, owner)
    .set(POST_DETAILS.UPDATED_ON, timestamp)
    .execute();
}
 
Example 28
Source Project: waltz   Source File: PhysicalFlowParticipantGenerator.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean remove(ApplicationContext ctx) {
    DSLContext dsl = getDsl(ctx);
    log("---removing demo records");
    dsl.deleteFrom(PHYSICAL_FLOW_PARTICIPANT)
            .where(PHYSICAL_FLOW_PARTICIPANT.PROVENANCE.eq(SAMPLE_DATA_PROVENANCE))
            .execute();
    return false;
}
 
Example 29
Source Project: samantha   Source File: SQLBasedRetrieverConfig.java    License: MIT License 5 votes vote down vote up
public Retriever getRetriever(RequestContext requestContext) {
    Settings settings = new Settings()
            .withStatementType(StatementType.STATIC_STATEMENT);
    DSLContext create = DSL.using(DB.getDataSource(db), SQLDialect.DEFAULT, settings);
    return new SQLBasedRetriever(config, setCursorKey,
            limit, offset, selectSqlKey, matchFields,
            greaterFields, lessFields, matchFieldTypes, greaterFieldTypes, lessFieldTypes,
            create, selectFields, table, orderByFields, renameMap, requestContext, injector);
}
 
Example 30
Source Project: hmftools   Source File: CgiDAOFunctions.java    License: GNU General Public License v3.0 5 votes vote down vote up
static void deleteAll(@NotNull DSLContext context) {
    context.deleteFrom(CGITRANSCRIPT).execute();
    context.deleteFrom(CGIINDIVIDUALMUTATION).execute();
    context.deleteFrom(CGIGDNA).execute();
    context.deleteFrom(CGICDNA).execute();
    context.deleteFrom(CGIINFO).execute();
    context.deleteFrom(CGIREGION).execute();
    context.deleteFrom(CGISTRAND).execute();

    context.deleteFrom(CGI).execute();
}