當前位置: 首頁>>代碼示例>>Java>>正文


Java TableField類代碼示例

本文整理匯總了Java中org.jooq.TableField的典型用法代碼示例。如果您正苦於以下問題:Java TableField類的具體用法?Java TableField怎麽用?Java TableField使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TableField類屬於org.jooq包,在下文中一共展示了TableField類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getCountStats

import org.jooq.TableField; //導入依賴的package包/類
private <T extends CountStats> T getCountStats(final TableImpl table,
                                             final TableField<? extends Record, Timestamp> createdField,
                                             final T countStats) {
    final Field<Integer> totalField = DSL.selectCount().from(table).asField();
    final Field<Integer> last7daysField =
            DSL.selectCount()
               .from(table)
               .where(createdField.ge(DSL.currentTimestamp().minus(7)))
               .asField();
    final Field<Integer> last30daysField =
            DSL.selectCount()
               .from(table)
               .where(createdField.ge(DSL.currentTimestamp().minus(30)))
               .asField();

    return jooq.select(totalField, last7daysField, last30daysField)
               .fetchOne()
               .map(r -> {
                   countStats.setTotal(r.getValue(totalField));
                   countStats.setLast7days(r.getValue(last7daysField));
                   countStats.setLast30days(r.getValue(last30daysField));
                   return countStats;
               });
}
 
開發者ID:kTT,項目名稱:adjule,代碼行數:25,代碼來源:JooqStatsDao.java

示例2: delete

import org.jooq.TableField; //導入依賴的package包/類
@Override
public void delete(Object obj) {
    if (obj == null) {
        return;
    }

    Object id = ObjectUtils.getId(obj);
    String type = getType(obj);
    Table<?> table = JooqUtils.getTableFromRecordClass(JooqUtils.getRecordClass(getSchemaFactory(), obj.getClass()));
    TableField<?, Object> idField = JooqUtils.getTableField(getMetaDataManager(), type, ObjectMetaDataManager.ID_FIELD);

    if (idField == null) {
        throw new IllegalStateException("No ID field to delete object [" + obj + "]");
    }

    create().delete(table).where(idField.eq(id)).execute();
}
 
開發者ID:rancher,項目名稱:cattle,代碼行數:18,代碼來源:JooqObjectManager.java

示例3: findById

import org.jooq.TableField; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public static <T extends UpdatableRecord<?>> T findById(DSLContext context, Class<T> clz, Object id) {
    if (id == null)
        return null;

    Table<?> table = getTableFromRecordClass(clz);
    if (table == null)
        return null;

    UniqueKey<?> key = table.getPrimaryKey();
    if (key == null || key.getFieldsArray().length != 1)
        return null;

    TableField<?, Object> keyField = (TableField<?, Object>) key.getFieldsArray()[0];

    /* Convert object because we are abusing type safety here */
    Object converted = keyField.getDataType().convert(id);

    return (T) context.selectFrom(table).where(keyField.eq(converted)).fetchOne();
}
 
開發者ID:rancher,項目名稱:cattle,代碼行數:21,代碼來源:JooqUtils.java

示例4: findNonRemoved

import org.jooq.TableField; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public <T> List<? extends T> findNonRemoved(Class<T> mapType, Class<?> resourceType, long resourceId) {
    String type = schemaFactory.getSchemaName(mapType);

    Table<?> table = getTable(mapType);

    Relationship reference = getRelationship(mapType, resourceType);
    TableField<?, Object> removed = JooqUtils.getTableField(metaDataManager, type, ObjectMetaDataManager.REMOVED_FIELD);
    TableField<?, Object> referenceField = JooqUtils.getTableField(metaDataManager, type, reference.getPropertyName());

    if ( removed == null || referenceField == null ) {
        throw new IllegalArgumentException("Type [" + mapType + "] is missing required removed or reference column");
    }

    return (List<? extends T>)create()
            .selectFrom(table)
            .where(
                    removed.isNull()
                    .and(referenceField.eq(resourceId)))
            .fetch();
}
 
開發者ID:cloudnautique,項目名稱:cloud-cattle,代碼行數:23,代碼來源:GenericMapDaoImpl.java

示例5: findToRemove

import org.jooq.TableField; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public <T> List<? extends T> findToRemove(Class<T> mapType, Class<?> resourceType, long resourceId) {
    String type = schemaFactory.getSchemaName(mapType);

    Table<?> table = getTable(mapType);

    Relationship reference = getRelationship(mapType, resourceType);
    TableField<?, Object> removed = JooqUtils.getTableField(metaDataManager, type, ObjectMetaDataManager.REMOVED_FIELD);
    TableField<?, Object> referenceField = JooqUtils.getTableField(metaDataManager, type, reference.getPropertyName());
    TableField<?, Object> state = JooqUtils.getTableField(metaDataManager, type, ObjectMetaDataManager.STATE_FIELD);

    if ( removed == null || referenceField == null || state == null ) {
        throw new IllegalArgumentException("Type [" + mapType + "] is missing required removed, reference, or state column");
    }

    return (List<? extends T>)create()
            .selectFrom(table)
            .where(
                    referenceField.eq(resourceId)
                    .and(
                            removed.isNull()
                            .or(state.eq(CommonStatesConstants.REMOVING))))
            .fetch();
}
 
開發者ID:cloudnautique,項目名稱:cloud-cattle,代碼行數:26,代碼來源:GenericMapDaoImpl.java

示例6: addMappingJoins

import org.jooq.TableField; //導入依賴的package包/類
protected void addMappingJoins(SelectQuery<?> query, Table<?> toTable, SchemaFactory schemaFactory, String fromType, Table<?> from, String asName, MapRelationship rel) {
    Table<?> mappingTable = JooqUtils.getTableFromRecordClass(rel.getMappingType());
    /* We don't required the mapping type to be visible external, that's why we use the schemaFactory
     * from the objectManager, because it is the superset schemaFactory.
     */
    String mappingType = getObjectManager().getSchemaFactory().getSchemaName(rel.getMappingType());

    TableField<?, Object> fieldFrom = JooqUtils.getTableField(getMetaDataManager(), fromType, ObjectMetaDataManager.ID_FIELD);
    TableField<?, Object> fieldTo = JooqUtils.getTableField(getMetaDataManager(), mappingType, rel.getPropertyName());
    TableField<?, Object> fieldRemoved = JooqUtils.getTableField(getMetaDataManager(), mappingType, ObjectMetaDataManager.REMOVED_FIELD);

    org.jooq.Condition cond = fieldFrom.eq(fieldTo.getTable().field(fieldTo.getName())).and(fieldRemoved == null ? DSL.trueCondition() : fieldRemoved.isNull());
    query.addJoin(mappingTable, JoinType.LEFT_OUTER_JOIN, cond);

    fieldFrom = JooqUtils.getTableField(getMetaDataManager(), mappingType, rel.getOtherRelationship().getPropertyName());
    fieldTo = JooqUtils.getTableField(getMetaDataManager(), schemaFactory.getSchemaName(rel.getObjectType()), ObjectMetaDataManager.ID_FIELD);

    cond = fieldFrom.eq(fieldTo.getTable().asTable(asName).field(fieldTo.getName()));
    query.addJoin(toTable, JoinType.LEFT_OUTER_JOIN, cond);
}
 
開發者ID:cloudnautique,項目名稱:cloud-cattle,代碼行數:21,代碼來源:AbstractJooqResourceManager.java

示例7: getJoinCondition

import org.jooq.TableField; //導入依賴的package包/類
protected org.jooq.Condition getJoinCondition(SchemaFactory schemaFactory, String fromType, Table<?> from, String asName, Relationship rel) {
    TableField<?, Object> fieldFrom = null;
    TableField<?, Object> fieldTo = null;

    switch(rel.getRelationshipType()) {
    case REFERENCE:
        fieldFrom = JooqUtils.getTableField(getMetaDataManager(), fromType, rel.getPropertyName());
        fieldTo = JooqUtils.getTableField(getMetaDataManager(), schemaFactory.getSchemaName(rel.getObjectType()),
                ObjectMetaDataManager.ID_FIELD);
        break;
    case CHILD:
        fieldFrom = JooqUtils.getTableField(getMetaDataManager(), fromType, ObjectMetaDataManager.ID_FIELD);
        fieldTo = JooqUtils.getTableField(getMetaDataManager(), schemaFactory.getSchemaName(rel.getObjectType()), rel.getPropertyName());
        break;
    default:
        throw new IllegalArgumentException("Illegal Relationship type [" + rel.getRelationshipType() + "]");
    }

    if ( fieldFrom == null || fieldTo == null ) {
        throw new IllegalStateException("Failed to construction join query for [" + fromType + "] [" + from + "] [" + rel + "]");
    }

    return fieldFrom.eq(fieldTo.getTable().as(asName).field(fieldTo.getName()));
}
 
開發者ID:cloudnautique,項目名稱:cloud-cattle,代碼行數:25,代碼來源:AbstractJooqResourceManager.java

示例8: addSort

import org.jooq.TableField; //導入依賴的package包/類
protected void addSort(SchemaFactory schemaFactory, String type, Sort sort, SelectQuery<?> query) {
    if ( sort == null ) {
        return;
    }

    TableField<?, Object> sortField = JooqUtils.getTableField(getMetaDataManager(), type, sort.getName());
    if ( sortField == null ) {
        return;
    }

    switch (sort.getOrderEnum()) {
    case DESC:
        query.addOrderBy(sortField.desc());
    default:
        query.addOrderBy(sortField.asc());
    }
}
 
開發者ID:cloudnautique,項目名稱:cloud-cattle,代碼行數:18,代碼來源:AbstractJooqResourceManager.java

示例9: addAccountAuthorization

import org.jooq.TableField; //導入依賴的package包/類
@Override
protected void addAccountAuthorization(String type, Map<Object, Object> criteria, Policy policy) {
    super.addAccountAuthorization(type, criteria, policy);

    if ( ! policy.isOption(Policy.AUTHORIZED_FOR_ALL_ACCOUNTS) ) {
        TableField<?, Object> accountField = JooqUtils.getTableField(getMetaDataManager(), type, ObjectMetaDataManager.ACCOUNT_FIELD);
        TableField<?, Object> publicField = JooqUtils.getTableField(getMetaDataManager(), type, ObjectMetaDataManager.PUBLIC_FIELD);
        Object accountValue = criteria.get(ObjectMetaDataManager.ACCOUNT_FIELD);

        if ( accountField == null || publicField == null || accountValue == null ) {
            return;
        }

        criteria.remove(ObjectMetaDataManager.ACCOUNT_FIELD);
        Condition accountCondition = null;
        if ( accountValue instanceof io.github.ibuildthecloud.gdapi.condition.Condition ) {
            accountCondition = accountField.in(((io.github.ibuildthecloud.gdapi.condition.Condition)accountValue).getValues());
        } else {
            accountCondition = accountField.eq(accountValue);
        }

        criteria.put(Condition.class, publicField.isTrue().or(accountCondition));
    }
}
 
開發者ID:cloudnautique,項目名稱:cloud-cattle,代碼行數:25,代碼來源:AbstractJooqResourceManager.java

示例10: removeFromStore

import org.jooq.TableField; //導入依賴的package包/類
@Override
protected Object removeFromStore(String type, String id, Object obj, ApiRequest request) {
    Table<?> table = JooqUtils.getTableFromRecordClass(JooqUtils.getRecordClass(request.getSchemaFactory(), obj.getClass()));
    TableField<?, Object> idField = JooqUtils.getTableField(getMetaDataManager(), type, ObjectMetaDataManager.ID_FIELD);

    int result = create()
        .delete(table)
        .where(idField.eq(id))
        .execute();

    if ( result != 1 ) {
        log.error("While deleting type [{}] and id [{}] got a result of [{}]", type, id, result);
        throw new ClientVisibleException(ResponseCodes.CONFLICT);
    }

    return obj;
}
 
開發者ID:cloudnautique,項目名稱:cloud-cattle,代碼行數:18,代碼來源:AbstractJooqResourceManager.java

示例11: getListByRelationshipMap

import org.jooq.TableField; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Override
protected <T> List<T> getListByRelationshipMap(Object obj, MapRelationship rel) {
    Class<UpdatableRecord<?>> typeClass = JooqUtils.getRecordClass(schemaFactory, rel.getObjectType());

    String mappingType = schemaFactory.getSchemaName(rel.getMappingType());
    String fromType = schemaFactory.getSchemaName(rel.getObjectType());

    TableField<?, Object> fieldFrom = JooqUtils.getTableField(getMetaDataManager(), fromType, ObjectMetaDataManager.ID_FIELD);
    TableField<?, Object> mappingTo = JooqUtils.getTableField(getMetaDataManager(), mappingType, rel.getOtherRelationship().getPropertyName());
    TableField<?, Object> mappingOther = JooqUtils.getTableField(getMetaDataManager(), mappingType, rel.getPropertyName());
    TableField<?, Object> mappingRemoved = JooqUtils.getTableField(getMetaDataManager(), mappingType, ObjectMetaDataManager.REMOVED_FIELD);

    Table<?> table = JooqUtils.getTable(schemaFactory, typeClass);
    Table<?> mapTable = JooqUtils.getTable(schemaFactory, rel.getMappingType());

    SelectQuery<?> query = create().selectQuery();
    query.addFrom(table);
    query.addSelect(table.fields());
    query.addJoin(mapTable, fieldFrom.eq(mappingTo)
            .and(mappingRemoved == null ? DSL.trueCondition() : mappingRemoved.isNull())
            .and(mappingOther.eq(ObjectUtils.getId(obj))));

    return (List<T>)query.fetchInto(typeClass);
}
 
開發者ID:cloudnautique,項目名稱:cloud-cattle,代碼行數:26,代碼來源:JooqObjectManager.java

示例12: delete

import org.jooq.TableField; //導入依賴的package包/類
@Override
public void delete(Object obj) {
    if ( obj == null ) {
        return;
    }

    Object id = ObjectUtils.getId(obj);
    String type = getType(obj);
    Table<?> table = JooqUtils.getTableFromRecordClass(JooqUtils.getRecordClass(getSchemaFactory(), obj.getClass()));
    TableField<?, Object> idField = JooqUtils.getTableField(getMetaDataManager(), type, ObjectMetaDataManager.ID_FIELD);

    int result = create()
            .delete(table)
            .where(idField.eq(id))
            .execute();

    if ( result != 1 ) {
        throw new IllegalStateException("Failed to delete [" + type + "] id [" + id + "]");
    }
}
 
開發者ID:cloudnautique,項目名稱:cloud-cattle,代碼行數:21,代碼來源:JooqObjectManager.java

示例13: findById

import org.jooq.TableField; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public static <T extends UpdatableRecord<?>> T findById(DSLContext context, Class<T> clz, Object id) {
    if ( id == null )
        return null;

    Table<?> table = getTableFromRecordClass(clz);
    if ( table == null )
        return null;

    UniqueKey<?> key = table.getPrimaryKey();
    if ( key == null || key.getFieldsArray().length != 1 )
        return null;

    TableField<?, Object> keyField = (TableField<?, Object>)key.getFieldsArray()[0];

    /* Convert object because we are abusing type safety here */
    Object converted = keyField.getDataType().convert(id);

    return (T)context.selectFrom(table)
            .where(keyField.eq(converted))
            .fetchOne();
}
 
開發者ID:cloudnautique,項目名稱:cloud-cattle,代碼行數:23,代碼來源:JooqUtils.java

示例14: addMappingJoins

import org.jooq.TableField; //導入依賴的package包/類
protected void addMappingJoins(SelectQuery<?> query, Table<?> toTable, SchemaFactory schemaFactory, String fromType, Table<?> from, String asName, MapRelationship rel) {
    Table<?> mappingTable = JooqUtils.getTableFromRecordClass(rel.getMappingType());
    String mappingType = schemaFactory.getSchemaName(rel.getMappingType());

    TableField<?, Object> fieldFrom = JooqUtils.getTableField(getMetaDataManager(), fromType, ObjectMetaDataManager.ID_FIELD);
    TableField<?, Object> fieldTo = JooqUtils.getTableField(getMetaDataManager(), mappingType, rel.getPropertyName());
    TableField<?, Object> fieldRemoved = JooqUtils.getTableField(getMetaDataManager(), mappingType, ObjectMetaDataManager.REMOVED_FIELD);

    org.jooq.Condition cond = fieldFrom.eq(fieldTo.getTable().field(fieldTo.getName())).and(fieldRemoved == null ? DSL.trueCondition() : fieldRemoved.isNull());
    query.addJoin(mappingTable, JoinType.LEFT_OUTER_JOIN, cond);

    fieldFrom = JooqUtils.getTableField(getMetaDataManager(), mappingType, rel.getOtherRelationship().getPropertyName());
    fieldTo = JooqUtils.getTableField(getMetaDataManager(), schemaFactory.getSchemaName(rel.getObjectType()), ObjectMetaDataManager.ID_FIELD);

    cond = fieldFrom.eq(fieldTo.getTable().asTable(asName).field(fieldTo.getName()));
    query.addJoin(toTable, JoinType.LEFT_OUTER_JOIN, cond);
}
 
開發者ID:ibuildthecloud,項目名稱:dstack,代碼行數:18,代碼來源:AbstractJooqResourceManager.java

示例15: register

import org.jooq.TableField; //導入依賴的package包/類
protected void register(ForeignKey<?, ?> foreignKey) {
    TableField<?, ?>[] fields = foreignKey.getFieldsArray();
    if ( fields.length == 0 || fields.length > 1 ) {
        return;
    }
    TableField<?, ?> field = fields[0];

    String propertyName = getNameFromField(field.getTable().getRecordType(), field.getName());
    String referenceName = propertyName;
    if ( field.getName().endsWith(ID_FIELD) ) {
        referenceName = referenceName.substring(0, referenceName.length() - 2);
    }

    Class<?> localType = foreignKey.getTable().getRecordType();
    Class<?> foreignType = foreignKey.getKey().getTable().getRecordType();

    Schema localSchema = schemaFactory.getSchema(localType);
    String childName = localSchema.getPluralName();

    register(localType, new ForeignKeyRelationship(REFERENCE, referenceName, propertyName, foreignType, foreignKey));
    register(foreignType, new ForeignKeyRelationship(CHILD, childName, propertyName, localType, foreignKey));
}
 
開發者ID:ibuildthecloud,項目名稱:dstack,代碼行數:23,代碼來源:DefaultObjectMetaDataManager.java


注:本文中的org.jooq.TableField類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。