Java 类org.jooq.ForeignKey 实例源码

项目:cloud-cattle    文件:DefaultObjectMetaDataManager.java   
protected void registerRelationships() {
    for ( TypeSet typeSet : typeSets ) {
        for ( Class<?> clz : typeSet.getTypeClasses() ) {
            Table<?> table = JooqUtils.getTableFromRecordClass(clz);
            if ( table == null ) {
                continue;
            }

            registerTableFields(table);
            for ( ForeignKey<?, ?> reference : table.getReferences() ) {
                register(reference);
            }
        }
    }

    findMappings();
}
项目:dstack    文件:DefaultObjectMetaDataManager.java   
protected void registerRelationships() {
    for ( TypeSet typeSet : typeSets ) {
        for ( Class<?> clz : typeSet.getTypeClasses() ) {
            Table<?> table = JooqUtils.getTableFromRecordClass(clz);
            if ( table == null ) {
                continue;
            }

            registerTableFields(table);
            for ( ForeignKey<?, ?> reference : table.getReferences() ) {
                register(reference);
            }
        }
    }

    findMappings();
}
项目:dstack    文件:DefaultObjectMetaDataManager.java   
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));
}
项目:cattle    文件:TableCleanup.java   
/**
 * Returns a listSupport of foreign keys referencing a table
 *
 * @param table
 * @param others
 * @return
 */
public static List<ForeignKey<?, ?>> getReferencesFrom(CleanableTable table, List<CleanableTable> others) {
    List<ForeignKey<?, ?>> keys = new ArrayList<>();
    for (CleanableTable other : others) {
        keys.addAll(table.table.getReferencesFrom(other.table));
    }
    return keys;
}
项目:cattle    文件:ForeignKeyRelationship.java   
public ForeignKeyRelationship(RelationshipType relationshipType, String name, String propertyName, Class<?> objectType, ForeignKey<?, ?> foreignKey) {
    super();
    this.name = name;
    this.relationshipType = relationshipType;
    this.propertyName = propertyName;
    this.objectType = objectType;
    this.foreignKey = foreignKey;
}
项目:cattle    文件:DefaultObjectMetaDataManager.java   
protected void registerRelationships() {
    for (TypeSet typeSet : typeSets) {
        for (Class<?> clz : typeSet.getTypeClasses()) {
            Table<?> table = JooqUtils.getTableFromRecordClass(clz);
            if (table == null) {
                continue;
            }

            registerTableFields(table);
            for (ForeignKey<?, ?> reference : table.getReferences()) {
                register(reference);
            }
        }
    }
}
项目:cattle    文件:DefaultObjectMetaDataManager.java   
protected void register(ForeignKey<?, ?> foreignKey) {
    TableField<?, ?>[] fields = foreignKey.getFieldsArray();
    if (fields.length == 0 || fields.length > 1) {
        return;
    }
    TableField<?, ?> field = fields[0];

    if (!field.getDataType().isNumeric()) {
        return;
    }

    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();

    String childNameOverride = ArchaiusUtil.getString(
            String.format("object.link.name.%s.%s.override", localType.getSimpleName(), propertyName).toLowerCase()).get();

    if (childNameOverride != null) {
        childName = childNameOverride;
    }

    register(localType, new ForeignKeyRelationship(REFERENCE, referenceName, propertyName, foreignType, foreignKey));
    register(foreignType, new ForeignKeyRelationship(CHILD, childName, propertyName, localType, foreignKey));
}
项目:cattle    文件:JooqUtils.java   
/**
 * Determines if a table's primary key is referenced at all by other tables.
 * 
 * @param table
 * @param others
 * @return
 */
public static boolean isReferencedBy(Table<?> table, List<Table<?>> others) {
  for (Table<?> other : others) {
    for (ForeignKey<?, ?> key : other.getReferences()) {
      if (key.getKey().getTable().equals(table)) {
        return true;
      }
    }
  }
  return false;
}
项目:cloud-cattle    文件:MappedResourceChangeHandlerDaoImpl.java   
@SuppressWarnings("unchecked")
protected TableField<Record, Field<Long>> getReferenceField(Table<?> mappingTable, Table<?> otherTable) {
    List<?> foreignKeys = mappingTable.getReferencesTo(otherTable);
    if ( foreignKeys.size() != 1 ) {
        throw new IllegalStateException("Expected one foreign key from [" + mappingTable +
                "] to [" + otherTable + "]");
    }

    List<TableField<Record, ?>> fields = ((ForeignKey<Record, Record>)foreignKeys.get(0)).getFields();
    if ( fields.size() != 1 ) {
        throw new IllegalStateException("Expected on field for foreign key [" + foreignKeys.get(0) + "]");
    }

    return (TableField<Record, Field<Long>>)fields.get(0);
}
项目:cloud-cattle    文件:ForeignKeyRelationship.java   
public ForeignKeyRelationship(RelationshipType relationshipType, String name, String propertyName,
        Class<?> objectType, ForeignKey<?, ?> foreignKey) {
    super();
    this.name = name;
    this.relationshipType = relationshipType;
    this.propertyName = propertyName;
    this.objectType = objectType;
    this.foreignKey = foreignKey;
}
项目:cloud-cattle    文件:DefaultObjectMetaDataManager.java   
protected void register(ForeignKey<?, ?> foreignKey) {
    TableField<?, ?>[] fields = foreignKey.getFieldsArray();
    if ( fields.length == 0 || fields.length > 1 ) {
        return;
    }
    TableField<?, ?> field = fields[0];

    if ( ! field.getDataType().isNumeric() ) {
        return;
    }

    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();

    String childNameOverride = ArchaiusUtil.getString(String.format("object.link.name.%s.%s.override",
            localType.getSimpleName(), propertyName).toLowerCase()).get();

    if ( childNameOverride != null ) {
        childName = childNameOverride;
    }

    register(localType, new ForeignKeyRelationship(REFERENCE, referenceName, propertyName, foreignType, foreignKey));
    register(foreignType, new ForeignKeyRelationship(CHILD, childName, propertyName, localType, foreignKey));
}
项目:dstack    文件:MappedResourceChangeHandlerDaoImpl.java   
@SuppressWarnings("unchecked")
protected TableField<Record, Field<Long>> getReferenceField(Table<?> mappingTable, Table<?> otherTable) {
    List<?> foreignKeys = mappingTable.getReferencesTo(otherTable);
    if ( foreignKeys.size() != 1 ) {
        throw new IllegalStateException("Expected one foreign key from [" + mappingTable +
                "] to [" + otherTable + "]");
    }

    List<TableField<Record, ?>> fields = ((ForeignKey<Record, Record>)foreignKeys.get(0)).getFields();
    if ( fields.size() != 1 ) {
        throw new IllegalStateException("Expected on field for foreign key [" + foreignKeys.get(0) + "]");
    }

    return (TableField<Record, Field<Long>>)fields.get(0);
}
项目:dstack    文件:ForeignKeyRelationship.java   
public ForeignKeyRelationship(RelationshipType relationshipType, String name, String propertyName,
        Class<?> objectType, ForeignKey<?, ?> foreignKey) {
    super();
    this.name = name;
    this.relationshipType = relationshipType;
    this.propertyName = propertyName;
    this.objectType = objectType;
    this.foreignKey = foreignKey;
}
项目:dstack    文件:JooqObjectManager.java   
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public <T> List<T> children(Object obj, Class<T> type) {
    if ( obj == null ) {
        return Collections.emptyList();
    }
    UpdatableRecord<?> recordObject = JooqUtils.getRecordObject(obj);
    Class<UpdatableRecord<?>> parent = JooqUtils.getRecordClass(schemaFactory, obj.getClass());
    Class<UpdatableRecord<?>> child = JooqUtils.getRecordClass(schemaFactory, type);
    ChildReferenceCacheKey key = new ChildReferenceCacheKey(parent, child);

    ForeignKey<?, ?> foreignKey = childReferenceCache.get(key);
    if ( foreignKey == null ) {
        Table<?> childTable = JooqUtils.getTableFromRecordClass(child);
        for ( ForeignKey<?, ?> foreignKeyTest : childTable.getReferences() ) {
            if ( foreignKeyTest.getKey().getTable().getRecordType() == parent ) {
                if ( foreignKey == null ) {
                    foreignKey = foreignKeyTest;
                } else {
                    throw new IllegalStateException("Found more that one foreign key from [" + child + "] to [" + parent + "]");
                }
            }
        }

        if ( foreignKey == null ) {
            throw new IllegalStateException("Failed to find a foreign key from [" + child + "] to [" + parent + "]");
        }

        childReferenceCache.put(key, foreignKey);
    }

    recordObject.attach(getConfiguration());
    return recordObject.fetchChildren((ForeignKey)foreignKey);
}
项目:SA-Jericho    文件:Jokes.java   
/**
 * {@inheritDoc}
 */
@Override
public List<ForeignKey<JokesRecord, ?>> getReferences() {
    return Arrays.<ForeignKey<JokesRecord, ?>>asList(Keys.JOKES__FK_CATEGORY_ID);
}
项目:oneops    文件:CmCiRelations.java   
/**
 * {@inheritDoc}
 */
@Override
public List<ForeignKey<CmCiRelationsRecord, ?>> getReferences() {
    return Arrays.<ForeignKey<CmCiRelationsRecord, ?>>asList(Keys.CM_CI_RELATIONS__CM_CI_RELATIONS_NS_FK, Keys.CM_CI_RELATIONS__CM_CI_RELATIONS_FRID_FK, Keys.CM_CI_RELATIONS__DF_CI_RELATIONS_MDRID_FK, Keys.CM_CI_RELATIONS__CM_CI_RELATIONS_TOID_FK, Keys.CM_CI_RELATIONS__CM_CI_RELATIONS_STID_FK);
}
项目:oneops    文件:DjRfcRelationAttributes.java   
/**
 * {@inheritDoc}
 */
@Override
public List<ForeignKey<DjRfcRelationAttributesRecord, ?>> getReferences() {
    return Arrays.<ForeignKey<DjRfcRelationAttributesRecord, ?>>asList(Keys.DJ_RFC_RELATION_ATTRIBUTES__RFC_RELATION_ATTRIBUTES_RFCRID_FK, Keys.DJ_RFC_RELATION_ATTRIBUTES__MD_RELATION_ATTRIBUTES_DJ_RFC_RELATION_ATTRIBUTES_FK);
}
项目:oneops    文件:DjRfcCiAttributes.java   
/**
 * {@inheritDoc}
 */
@Override
public List<ForeignKey<DjRfcCiAttributesRecord, ?>> getReferences() {
    return Arrays.<ForeignKey<DjRfcCiAttributesRecord, ?>>asList(Keys.DJ_RFC_CI_ATTRIBUTES__DJ_RFC_CI_ATTRIBUTES_CIID_FK, Keys.DJ_RFC_CI_ATTRIBUTES__DJ_RFC_CI_ATTRIBUTES_ATRID_FK);
}
项目:oneops    文件:CmsEventQueue.java   
/**
 * {@inheritDoc}
 */
@Override
public List<ForeignKey<CmsEventQueueRecord, ?>> getReferences() {
    return Arrays.<ForeignKey<CmsEventQueueRecord, ?>>asList(Keys.CMS_EVENT_QUEUE__CMS_EVENT_QUEUE_ETID_FK);
}
项目:oneops    文件:DjDeployment.java   
/**
 * {@inheritDoc}
 */
@Override
public List<ForeignKey<DjDeploymentRecord, ?>> getReferences() {
    return Arrays.<ForeignKey<DjDeploymentRecord, ?>>asList(Keys.DJ_DEPLOYMENT__CM_NAMESPACES_DJ_DEPLOYMENT_FK, Keys.DJ_DEPLOYMENT__DJ_DEPLOYMENT_RID_FK, Keys.DJ_DEPLOYMENT__DJ_DEPLOYMENT_STATES_DJ_DEPLOYMENT_FK);
}
项目:oneops    文件:MdClassAttributes.java   
/**
 * {@inheritDoc}
 */
@Override
public List<ForeignKey<MdClassAttributesRecord, ?>> getReferences() {
    return Arrays.<ForeignKey<MdClassAttributesRecord, ?>>asList(Keys.MD_CLASS_ATTRIBUTES__MD_CLASS_ATTRIBUTES_CLID_FK);
}
项目:oneops    文件:CmOpsActions.java   
/**
 * {@inheritDoc}
 */
@Override
public List<ForeignKey<CmOpsActionsRecord, ?>> getReferences() {
    return Arrays.<ForeignKey<CmOpsActionsRecord, ?>>asList(Keys.CM_OPS_ACTIONS__CM_OPS_ACTIONS_PROC_FK, Keys.CM_OPS_ACTIONS__CM_OPS_ACTIONS_CI_FK, Keys.CM_OPS_ACTIONS__CM_OPS_ACTIONS_ST_FK);
}
项目:oneops    文件:DjRfcRelation.java   
/**
 * {@inheritDoc}
 */
@Override
public List<ForeignKey<DjRfcRelationRecord, ?>> getReferences() {
    return Arrays.<ForeignKey<DjRfcRelationRecord, ?>>asList(Keys.DJ_RFC_RELATION__DJ_RELATION_RFC_RELID_FK, Keys.DJ_RFC_RELATION__DJ_RFC_RELATION_NS_FK, Keys.DJ_RFC_RELATION__DJ_RFC_CI_DJ_RFC_RELATION_FK, Keys.DJ_RFC_RELATION__DJ_RELATION_RFC_RID_FK, Keys.DJ_RFC_RELATION__DJ_RFC_CI_DJ_RFC_RELATION_FK1, Keys.DJ_RFC_RELATION__DJ_RELATION_RFC_ACTID_FK);
}
项目:oneops    文件:MdClassActions.java   
/**
 * {@inheritDoc}
 */
@Override
public List<ForeignKey<MdClassActionsRecord, ?>> getReferences() {
    return Arrays.<ForeignKey<MdClassActionsRecord, ?>>asList(Keys.MD_CLASS_ACTIONS__MD_CLASS_ACTIONS_CL_FK);
}
项目:oneops    文件:DjNsOpt.java   
/**
 * {@inheritDoc}
 */
@Override
public List<ForeignKey<DjNsOptRecord, ?>> getReferences() {
    return Arrays.<ForeignKey<DjNsOptRecord, ?>>asList(Keys.DJ_NS_OPT__DJ_RFC_CI_DJ_NS_OPT_FK, Keys.DJ_NS_OPT__NS_DJ_NS_OPT_FK, Keys.DJ_NS_OPT__NS_OPT_TAG_DJ_NS_OPT_FK);
}
项目:oneops    文件:CmsCiEventQueue.java   
/**
 * {@inheritDoc}
 */
@Override
public List<ForeignKey<CmsCiEventQueueRecord, ?>> getReferences() {
    return Arrays.<ForeignKey<CmsCiEventQueueRecord, ?>>asList(Keys.CMS_CI_EVENT_QUEUE__CMS_CI_EVENT_QUEUE_ETID_FK);
}
项目:oneops    文件:DjDeploymentStateHist.java   
/**
 * {@inheritDoc}
 */
@Override
public List<ForeignKey<DjDeploymentStateHistRecord, ?>> getReferences() {
    return Arrays.<ForeignKey<DjDeploymentStateHistRecord, ?>>asList(Keys.DJ_DEPLOYMENT_STATE_HIST__DJ_DEPLOYMENT_STATE_HIST_FK);
}
项目:oneops    文件:MdRelationAttributes.java   
/**
 * {@inheritDoc}
 */
@Override
public List<ForeignKey<MdRelationAttributesRecord, ?>> getReferences() {
    return Arrays.<ForeignKey<MdRelationAttributesRecord, ?>>asList(Keys.MD_RELATION_ATTRIBUTES__MD_RELATION_ATTRIBUTES_MDRID_FK);
}
项目:oneops    文件:DjDeploymentRfc.java   
/**
 * {@inheritDoc}
 */
@Override
public List<ForeignKey<DjDeploymentRfcRecord, ?>> getReferences() {
    return Arrays.<ForeignKey<DjDeploymentRfcRecord, ?>>asList(Keys.DJ_DEPLOYMENT_RFC__DJ_DEPLOYMENT_DJ_DEPLOYMENT_RFC_FK, Keys.DJ_DEPLOYMENT_RFC__DJ_DEPLOYMENT_RFC_DPRFCSTID_FK);
}
项目:oneops    文件:DjReleases.java   
/**
 * {@inheritDoc}
 */
@Override
public List<ForeignKey<DjReleasesRecord, ?>> getReferences() {
    return Arrays.<ForeignKey<DjReleasesRecord, ?>>asList(Keys.DJ_RELEASES__CM_NAMESPACES_DJ_RELEASES_FK, Keys.DJ_RELEASES__DJ_RELEASES_RSID_FK);
}
项目:oneops    文件:CmOpsProcedures.java   
/**
 * {@inheritDoc}
 */
@Override
public List<ForeignKey<CmOpsProceduresRecord, ?>> getReferences() {
    return Arrays.<ForeignKey<CmOpsProceduresRecord, ?>>asList(Keys.CM_OPS_PROCEDURES__CM_OPS_PROCEDURES_CI_FK, Keys.CM_OPS_PROCEDURES__CM_OPS_PROCEDURES_ST_FK);
}
项目:oneops    文件:MdClassRelations.java   
/**
 * {@inheritDoc}
 */
@Override
public List<ForeignKey<MdClassRelationsRecord, ?>> getReferences() {
    return Arrays.<ForeignKey<MdClassRelationsRecord, ?>>asList(Keys.MD_CLASS_RELATIONS__MD_CLASS_RELATIONS_FRCL_FK, Keys.MD_CLASS_RELATIONS__MD_CLASS_RELATIONS_MDRID_FK, Keys.MD_CLASS_RELATIONS__MD_CLASS_RELATIONS_TOCL_FK);
}
项目:oneops    文件:CmCi.java   
/**
 * {@inheritDoc}
 */
@Override
public List<ForeignKey<CmCiRecord, ?>> getReferences() {
    return Arrays.<ForeignKey<CmCiRecord, ?>>asList(Keys.CM_CI__CM_CI_NS_FK, Keys.CM_CI__CM_CI_CLID_FK, Keys.CM_CI__CM_CI_STID_FK);
}
项目:oneops    文件:CmCiRelationAttributes.java   
/**
 * {@inheritDoc}
 */
@Override
public List<ForeignKey<CmCiRelationAttributesRecord, ?>> getReferences() {
    return Arrays.<ForeignKey<CmCiRelationAttributesRecord, ?>>asList(Keys.CM_CI_RELATION_ATTRIBUTES__CM_CI_RELATION_ATTRIBUTES_CRID_FK, Keys.CM_CI_RELATION_ATTRIBUTES__CM_CI_RELATION_ATTRIBUTES_RAID_FK);
}
项目:oneops    文件:CmCiAttributes.java   
/**
 * {@inheritDoc}
 */
@Override
public List<ForeignKey<CmCiAttributesRecord, ?>> getReferences() {
    return Arrays.<ForeignKey<CmCiAttributesRecord, ?>>asList(Keys.CM_CI_ATTRIBUTES__CM_CI_ATTRIBUTES_CIID_FK, Keys.CM_CI_ATTRIBUTES__CM_CI_ATTRIBUTES_ATTR_FK);
}
项目:oneops    文件:DjRfcCi.java   
/**
 * {@inheritDoc}
 */
@Override
public List<ForeignKey<DjRfcCiRecord, ?>> getReferences() {
    return Arrays.<ForeignKey<DjRfcCiRecord, ?>>asList(Keys.DJ_RFC_CI__DJ_RFC_RID_FK, Keys.DJ_RFC_CI__DJ_CI_RFC_NS_FK, Keys.DJ_RFC_CI__DJ_RFC_CI_CLID_FK, Keys.DJ_RFC_CI__DJ_RFC_CI_CIAID_FK);
}
项目:oneops    文件:NsOpt.java   
/**
 * {@inheritDoc}
 */
@Override
public List<ForeignKey<NsOptRecord, ?>> getReferences() {
    return Arrays.<ForeignKey<NsOptRecord, ?>>asList(Keys.NS_OPT__NS_PATH_NS_OPT_FK);
}
项目:oneops    文件:DjDpmtApprovals.java   
/**
 * {@inheritDoc}
 */
@Override
public List<ForeignKey<DjDpmtApprovalsRecord, ?>> getReferences() {
    return Arrays.<ForeignKey<DjDpmtApprovalsRecord, ?>>asList(Keys.DJ_DPMT_APPROVALS__DJ_DPMT_APPROVALS_DPMT_ID_FK, Keys.DJ_DPMT_APPROVALS__DJ_DPMT_APPROVALS_STATES_FK);
}
项目:oneops    文件:CmNsOpt.java   
/**
 * {@inheritDoc}
 */
@Override
public List<ForeignKey<CmNsOptRecord, ?>> getReferences() {
    return Arrays.<ForeignKey<CmNsOptRecord, ?>>asList(Keys.CM_NS_OPT__CM_CI_CM_NS_OPT_FK, Keys.CM_NS_OPT__NS_PATH_CM_NS_OPT_FK, Keys.CM_NS_OPT__NS_OPT_TAG_CM_NS_OPT_FK);
}
项目:sunshine-security    文件:Function.java   
/**
 * {@inheritDoc}
 */
@Override
public List<ForeignKey<FunctionRecord, ?>> getReferences() {
    return Arrays.<ForeignKey<FunctionRecord, ?>>asList(Keys.FK_ROLE_FUNCTION_ID);
}