dataMap.addQuery(query);
QueryType.fireQueryEvent(this, mediator, dataMap, query);
}
else if (content instanceof Procedure) {
// paste Procedure to DataMap
Procedure procedure = (Procedure) content;
procedure.setName(getFreeName(new ProcedureNameChecker(domain), procedure
.getName()));
dataMap.addProcedure(procedure);
CreateProcedureAction.fireProcedureEvent(
this,
mediator,
dataMap,
procedure);
}
}
else if (where instanceof DbEntity) {
final DbEntity dbEntity = (DbEntity) where;
// attrs and rels must be unique in entity namespace
FreeNameChecker checker = new FreeNameChecker() {
public boolean isNameFree(String name) {
return dbEntity.getAttribute(name) == null
&& dbEntity.getRelationship(name) == null;
}
};
if (content instanceof DbAttribute) {
DbAttribute attr = (DbAttribute) content;
attr.setName(getFreeName(checker, attr.getName()));
dbEntity.addAttribute(attr);
CreateAttributeAction.fireDbAttributeEvent(this, mediator, mediator
.getCurrentDataMap(), dbEntity, attr);
}
else if (content instanceof DbRelationship) {
DbRelationship rel = (DbRelationship) content;
rel.setName(getFreeName(checker, rel.getName()));
dbEntity.addRelationship(rel);
CreateRelationshipAction.fireDbRelationshipEvent(
this,
mediator,
dbEntity,
rel);
}
}
else if (where instanceof ObjEntity) {
final ObjEntity objEntity = (ObjEntity) where;
// attrs and rels must be unique in entity namespace
FreeNameChecker checker = new FreeNameChecker() {
public boolean isNameFree(String name) {
return objEntity.getAttribute(name) == null
&& objEntity.getRelationship(name) == null;
}
};
if (content instanceof ObjAttribute) {
ObjAttribute attr = (ObjAttribute) content;
attr.setName(getFreeName(checker, attr.getName()));
objEntity.addAttribute(attr);
CreateAttributeAction.fireObjAttributeEvent(this, mediator, mediator
.getCurrentDataMap(), objEntity, attr);
}
else if (content instanceof ObjRelationship) {
ObjRelationship rel = (ObjRelationship) content;
rel.setName(getFreeName(checker, rel.getName()));
objEntity.addRelationship(rel);
CreateRelationshipAction.fireObjRelationshipEvent(
this,
mediator,
objEntity,
rel);
}
}
else if (where instanceof Embeddable) {
final Embeddable embeddable = (Embeddable) where;
// attrs and rels must be unique in entity namespace
FreeNameChecker checker = new FreeNameChecker() {
public boolean isNameFree(String name) {
return embeddable.getAttribute(name) == null;
}
};
if (content instanceof EmbeddableAttribute) {
EmbeddableAttribute attr = (EmbeddableAttribute) content;
attr.setName(getFreeName(checker, attr.getName()));
embeddable.addAttribute(attr);
CreateAttributeAction.fireEmbeddableAttributeEvent(
this,
mediator,
embeddable,
attr);
}
}
else if (where instanceof Procedure) {
// paste param to procedure
final Procedure procedure = (Procedure) where;
if (content instanceof ProcedureParameter) {
ProcedureParameter param = (ProcedureParameter) content;
param.setName(getFreeName(new FreeNameChecker() {
public boolean isNameFree(String name) {
for (ProcedureParameter existingParam : procedure
.getCallParameters()) {
if (name.equals(existingParam.getName())) {
return false;
}
}
return true;
}
}, param.getName()));
procedure.addCallParameter(param);
CreateProcedureParameterAction.fireProcedureParameterEvent(
this,
mediator,
procedure,
param);