Search in sources :

Example 1 with ERDElement

use of org.jkiss.dbeaver.erd.model.ERDElement in project dbeaver by serge-rider.

the class AssociationReconnectTargetCommand method canExecute.

/**
 * Makes sure that foreign key doesn't reconnect to itself or try to create
 * a relationship which already exists
 */
@Override
public boolean canExecute() {
    boolean returnVal = true;
    ERDElement foreignKeyEntity = relationship.getSourceEntity();
    if (foreignKeyEntity.equals(targetEntity)) {
        returnVal = false;
    } else {
        List<ERDAssociation> relationships = targetEntity.getReferences();
        for (ERDAssociation relationship : relationships) {
            if (relationship.getSourceEntity().equals(sourceEntity) && relationship.getTargetEntity().equals(targetEntity)) {
                returnVal = false;
                break;
            }
        }
    }
    return returnVal;
}
Also used : ERDElement(org.jkiss.dbeaver.erd.model.ERDElement) ERDAssociation(org.jkiss.dbeaver.erd.model.ERDAssociation)

Example 2 with ERDElement

use of org.jkiss.dbeaver.erd.model.ERDElement in project dbeaver by dbeaver.

the class AssociationReconnectTargetCommand method canExecute.

/**
 * Makes sure that foreign key doesn't reconnect to itself or try to create
 * a relationship which already exists
 */
@Override
public boolean canExecute() {
    boolean returnVal = true;
    ERDElement foreignKeyEntity = relationship.getSourceEntity();
    if (foreignKeyEntity.equals(targetEntity)) {
        returnVal = false;
    } else {
        List<ERDAssociation> relationships = targetEntity.getReferences();
        for (ERDAssociation relationship : relationships) {
            if (relationship.getSourceEntity().equals(sourceEntity) && relationship.getTargetEntity().equals(targetEntity)) {
                returnVal = false;
                break;
            }
        }
    }
    return returnVal;
}
Also used : ERDElement(org.jkiss.dbeaver.erd.model.ERDElement) ERDAssociation(org.jkiss.dbeaver.erd.model.ERDAssociation)

Example 3 with ERDElement

use of org.jkiss.dbeaver.erd.model.ERDElement in project dbeaver by dbeaver.

the class AssociationReconnectSourceCommand method canExecute.

/**
 * Makes sure that primary key doesn't reconnect to itself or try to create
 * a relationship which already exists
 */
@Override
public boolean canExecute() {
    boolean returnVal = true;
    ERDElement primaryEntity = association.getTargetEntity();
    // cannot connect to itself
    if (primaryEntity.equals(sourceEntity)) {
        returnVal = false;
    } else {
        List<ERDAssociation> relationships = sourceEntity.getAssociations();
        for (ERDAssociation relationship : relationships) {
            if (relationship.getTargetEntity().equals(targetEntity) && relationship.getSourceEntity().equals(sourceEntity)) {
                returnVal = false;
                break;
            }
        }
    }
    return returnVal;
}
Also used : ERDElement(org.jkiss.dbeaver.erd.model.ERDElement) ERDAssociation(org.jkiss.dbeaver.erd.model.ERDAssociation)

Example 4 with ERDElement

use of org.jkiss.dbeaver.erd.model.ERDElement in project dbeaver by serge-rider.

the class AssociationReconnectSourceCommand method canExecute.

/**
 * Makes sure that primary key doesn't reconnect to itself or try to create
 * a relationship which already exists
 */
@Override
public boolean canExecute() {
    boolean returnVal = true;
    ERDElement primaryEntity = association.getTargetEntity();
    // cannot connect to itself
    if (primaryEntity.equals(sourceEntity)) {
        returnVal = false;
    } else {
        List<ERDAssociation> relationships = sourceEntity.getAssociations();
        for (ERDAssociation relationship : relationships) {
            if (relationship.getTargetEntity().equals(targetEntity) && relationship.getSourceEntity().equals(sourceEntity)) {
                returnVal = false;
                break;
            }
        }
    }
    return returnVal;
}
Also used : ERDElement(org.jkiss.dbeaver.erd.model.ERDElement) ERDAssociation(org.jkiss.dbeaver.erd.model.ERDAssociation)

Aggregations

ERDAssociation (org.jkiss.dbeaver.erd.model.ERDAssociation)4 ERDElement (org.jkiss.dbeaver.erd.model.ERDElement)4