Search in sources :

Example 1 with Record5

use of org.jooq.Record5 in project jOOQ by jOOQ.

the class MySQLDatabase method getEnums0.

@Override
protected List<EnumDefinition> getEnums0() throws SQLException {
    List<EnumDefinition> result = new ArrayList<EnumDefinition>();
    Result<Record5<String, String, String, String, String>> records = create().select(Columns.TABLE_SCHEMA, Columns.COLUMN_COMMENT, Columns.TABLE_NAME, Columns.COLUMN_NAME, Columns.COLUMN_TYPE).from(COLUMNS).where(Columns.COLUMN_TYPE.like("enum(%)").and(Columns.TABLE_SCHEMA.in(getInputSchemata()))).orderBy(Columns.TABLE_SCHEMA.asc(), Columns.TABLE_NAME.asc(), Columns.COLUMN_NAME.asc()).fetch();
    for (Record record : records) {
        SchemaDefinition schema = getSchema(record.get(Columns.TABLE_SCHEMA));
        String comment = record.get(Columns.COLUMN_COMMENT);
        String table = record.get(Columns.TABLE_NAME);
        String column = record.get(Columns.COLUMN_NAME);
        String name = table + "_" + column;
        String columnType = record.get(Columns.COLUMN_TYPE);
        // [#1237] Don't generate enum classes for columns in MySQL tables
        // that are excluded from code generation
        TableDefinition tableDefinition = getTable(schema, table);
        if (tableDefinition != null) {
            ColumnDefinition columnDefinition = tableDefinition.getColumn(column);
            if (columnDefinition != null) {
                // are explicitly forced to another type
                if (getConfiguredForcedType(columnDefinition, columnDefinition.getType()) == null) {
                    DefaultEnumDefinition definition = new DefaultEnumDefinition(schema, name, comment);
                    CSVReader reader = new CSVReader(new StringReader(columnType.replaceAll("(^enum\\()|(\\)$)", "")), // Separator
                    ',', // Quote character
                    '\'', // Strict quotes
                    true);
                    for (String string : reader.next()) {
                        definition.addLiteral(string);
                    }
                    result.add(definition);
                }
            }
        }
    }
    return result;
}
Also used : SchemaDefinition(org.jooq.util.SchemaDefinition) CSVReader(org.jooq.tools.csv.CSVReader) ArrayList(java.util.ArrayList) DefaultEnumDefinition(org.jooq.util.DefaultEnumDefinition) EnumDefinition(org.jooq.util.EnumDefinition) DefaultEnumDefinition(org.jooq.util.DefaultEnumDefinition) ColumnDefinition(org.jooq.util.ColumnDefinition) StringReader(java.io.StringReader) TableDefinition(org.jooq.util.TableDefinition) Record(org.jooq.Record) Record5(org.jooq.Record5)

Example 2 with Record5

use of org.jooq.Record5 in project textdb by TextDB.

the class UserFileResource method listUserFiles.

@GET
@Path("/list")
public List<UserFile> listUserFiles(@Session HttpSession session) {
    UInteger userID = UserResource.getUser(session).getUserID();
    Result<Record5<UInteger, String, String, String, UInteger>> result = getUserFileRecord(userID);
    if (result == null)
        return new ArrayList<>();
    List<UserFile> fileList = result.stream().map(record -> new UserFile(record.get(FILE.FID), record.get(FILE.NAME), record.get(FILE.PATH), record.get(FILE.DESCRIPTION), record.get(FILE.SIZE))).collect(Collectors.toList());
    return fileList;
}
Also used : HttpSession(javax.servlet.http.HttpSession) TexeraWebException(edu.uci.ics.texera.web.TexeraWebException) SqlServer(edu.uci.ics.texera.dataflow.sqlServerInfo.SqlServer) FormDataContentDisposition(org.glassfish.jersey.media.multipart.FormDataContentDisposition) FILE(edu.uci.ics.texera.dataflow.jooq.generated.Tables.FILE) FileManager(edu.uci.ics.texera.dataflow.resource.file.FileManager) Result(org.jooq.Result) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Record5(org.jooq.Record5) FormDataParam(org.glassfish.jersey.media.multipart.FormDataParam) MediaType(javax.ws.rs.core.MediaType) List(java.util.List) DSL.defaultValue(org.jooq.impl.DSL.defaultValue) Pair(org.apache.commons.lang3.tuple.Pair) javax.ws.rs(javax.ws.rs) Record1(org.jooq.Record1) UInteger(org.jooq.types.UInteger) Paths(java.nio.file.Paths) Session(io.dropwizard.jersey.sessions.Session) GenericWebResponse(edu.uci.ics.texera.web.response.GenericWebResponse) InputStream(java.io.InputStream) UInteger(org.jooq.types.UInteger) Record5(org.jooq.Record5)

Example 3 with Record5

use of org.jooq.Record5 in project waltz by khartec.

the class PeopleExtractor method registerExtractForApp.

private void registerExtractForApp(String path) {
    post(path, (request, response) -> {
        EntityReference entityRef = WebUtilities.getEntityReference(request);
        IdSelectionOptions selectionOptions = mkOpts(entityRef, HierarchyQueryScope.determineUpwardsScopeForKind(entityRef.kind()));
        GenericSelector selector = genericSelectorFactory.apply(selectionOptions);
        SelectSeekStep1<Record5<String, String, String, String, String>, String> qry = dsl.select(PERSON.DISPLAY_NAME.as("Name"), PERSON.TITLE.as("Title"), PERSON.OFFICE_PHONE.as("Telephone"), PERSON.EMAIL.as("Email"), INVOLVEMENT_KIND.NAME.as("Role")).from(PERSON).innerJoin(INVOLVEMENT).on(INVOLVEMENT.EMPLOYEE_ID.eq(PERSON.EMPLOYEE_ID)).innerJoin(INVOLVEMENT_KIND).on(INVOLVEMENT_KIND.ID.eq(INVOLVEMENT.KIND_ID)).where(INVOLVEMENT.ENTITY_ID.in(selector.selector()).and(INVOLVEMENT.ENTITY_KIND.eq(selector.kind().name()))).orderBy(PERSON.DISPLAY_NAME);
        return writeExtract("involved_people", qry, request, response);
    });
}
Also used : EntityReference(org.finos.waltz.model.EntityReference) WebUtilities.getEntityReference(org.finos.waltz.web.WebUtilities.getEntityReference) GenericSelector(org.finos.waltz.data.GenericSelector) Record5(org.jooq.Record5) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions)

Aggregations

Record5 (org.jooq.Record5)3 ArrayList (java.util.ArrayList)2 FILE (edu.uci.ics.texera.dataflow.jooq.generated.Tables.FILE)1 FileManager (edu.uci.ics.texera.dataflow.resource.file.FileManager)1 SqlServer (edu.uci.ics.texera.dataflow.sqlServerInfo.SqlServer)1 TexeraWebException (edu.uci.ics.texera.web.TexeraWebException)1 GenericWebResponse (edu.uci.ics.texera.web.response.GenericWebResponse)1 Session (io.dropwizard.jersey.sessions.Session)1 InputStream (java.io.InputStream)1 StringReader (java.io.StringReader)1 Paths (java.nio.file.Paths)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 HttpSession (javax.servlet.http.HttpSession)1 javax.ws.rs (javax.ws.rs)1 MediaType (javax.ws.rs.core.MediaType)1 Pair (org.apache.commons.lang3.tuple.Pair)1 GenericSelector (org.finos.waltz.data.GenericSelector)1 EntityReference (org.finos.waltz.model.EntityReference)1 IdSelectionOptions (org.finos.waltz.model.IdSelectionOptions)1