Search in sources :

Example 1 with GroupsRecord

use of keywhiz.jooq.tables.records.GroupsRecord in project keywhiz by square.

the class GroupDAO method createGroup.

public long createGroup(String name, String creator, String description, ImmutableMap<String, String> metadata) {
    GroupsRecord r = dslContext.newRecord(GROUPS);
    String jsonMetadata;
    try {
        jsonMetadata = mapper.writeValueAsString(metadata);
    } catch (JsonProcessingException e) {
        // Serialization of a Map<String, String> can never fail.
        throw Throwables.propagate(e);
    }
    long now = OffsetDateTime.now().toEpochSecond();
    r.setName(name);
    r.setCreatedby(creator);
    r.setCreatedat(now);
    r.setUpdatedby(creator);
    r.setUpdatedat(now);
    r.setDescription(description);
    r.setMetadata(jsonMetadata);
    r.store();
    return r.getId();
}
Also used : GroupsRecord(keywhiz.jooq.tables.records.GroupsRecord) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Aggregations

JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 GroupsRecord (keywhiz.jooq.tables.records.GroupsRecord)1