@Override public void redo() throws CannotRedoException { relationship.addJoin(join); }
@Override public void undo() throws CannotUndoException { relationship.addJoin(join); }
private void processStartDbAttributePair(Attributes atts) { DbJoin join = new DbJoin(dbRelationship); join.setSourceName(atts.getValue("", "source")); join.setTargetName(atts.getValue("", "target")); dbRelationship.addJoin(join); }
private void processStartDbAttributePair(Attributes atts) { DbJoin join = new DbJoin(dbRelationship); join.setSourceName(atts.getValue("", "source")); join.setTargetName(atts.getValue("", "target")); dbRelationship.addJoin(join); }
private void addJoin(DbRelationship relationship, String sourceName, String targetName){ for (DbJoin join : relationship.getJoins()) { if (join.getSourceName().equals(sourceName) && join.getTargetName().equals(targetName)) { return; } } relationship.addJoin(new DbJoin(relationship, sourceName, targetName)); } }
/** * Creates a new relationship with the same set of joins, but going in the opposite * direction. * * @since 1.0.5 */ public DbRelationship createReverseRelationship() { DbRelationship reverse = new DbRelationship(); reverse.setSourceEntity(getTargetEntity()); reverse.setTargetEntityName(getSourceEntity().getName()); // TODO: must set toDepPK correctly // must set toMany correctly reverse.setToMany(!toMany); Iterator it = joins.iterator(); while (it.hasNext()) { DbJoin join = (DbJoin) it.next(); DbJoin reverseJoin = join.createReverseJoin(); reverseJoin.setRelationship(reverse); reverse.addJoin(reverseJoin); } return reverse; }
targetAttributes, targetAttributeName)); dbRel.addJoin(join);
join.setSourceName(protoJoin.getSourceName()); join.setTargetName(protoJoin.getTargetName()); rel.addJoin(join);
/** * Creates a new relationship with the same set of joins, but going in the * opposite direction. * * @since 1.0.5 */ public DbRelationship createReverseRelationship() { DbEntity targetEntity = (DbEntity) getTargetEntity(); DbRelationship reverse = new DbRelationship(); reverse.setSourceEntity(targetEntity); reverse.setTargetEntityName(getSourceEntity().getName()); // TODO: andrus 12/24/2007 - one more case to handle - set reverse // toDepPK = true // if this relationship toDepPK is false, but the entities are joined on // a PK... // on the other hand, these can still be two independent entities... if (isToDependentPK() && !toMany && joins.size() == targetEntity.getPrimaryKeys().size()) { reverse.setToMany(false); } else { reverse.setToMany(!toMany); } for (DbJoin join : joins) { DbJoin reverseJoin = join.createReverseJoin(); reverseJoin.setRelationship(reverse); reverse.addJoin(reverseJoin); } return reverse; }
protected void createNames() { for (InferredRelationship myir : inferredRelationships) { DbRelationship localRelationship = new DbRelationship(); localRelationship.setToMany(myir.isToMany()); if (myir.getJoinSource().isPrimaryKey()) { localRelationship.addJoin( new DbJoin(localRelationship, myir.getJoinSource().getName(), myir.getJoinTarget().getName()) ); localRelationship.setSourceEntity(myir.getSource()); localRelationship.setTargetEntityName(myir.getTarget().getName()); } else { localRelationship.addJoin( new DbJoin(localRelationship, myir.getJoinTarget().getName(), myir.getJoinSource().getName()) ); localRelationship.setSourceEntity(myir.getTarget()); localRelationship.setTargetEntityName(myir.getSource().getName()); } myir.setName(strategy.relationshipName(localRelationship)); } }
public void generateAction() { ProjectController mediator = application .getFrameController() .getProjectController(); InferRelationshipsUndoableEdit undoableEdit = new InferRelationshipsUndoableEdit(); for (InferredRelationship temp : selectedEntities) { DbRelationship rel = new DbRelationship(uniqueRelName(temp.getSource(), temp .getName())); RelationshipEvent e = new RelationshipEvent(Application.getFrame(), rel, temp .getSource(), MapEvent.ADD); mediator.fireDbRelationshipEvent(e); rel.setSourceEntity(temp.getSource()); rel.setTargetEntityName(temp.getTarget()); DbJoin join = new DbJoin(rel, temp.getJoinSource().getName(), temp .getJoinTarget() .getName()); rel.addJoin(join); rel.setToMany(temp.isToMany()); temp.getSource().addRelationship(rel); undoableEdit.addEdit(new CreateRelationshipUndoableEdit(temp.getSource(), new DbRelationship[] { rel })); } JOptionPane.showMessageDialog(this.getView(), getSelectedEntitiesSize() + " relationships generated"); view.dispose(); }