if (entry == null) {
// try to fix the context
// System.out.println("Need to fix the context!!");
ModelChangeRequest cr2 =
(ModelChangeRequest) modelsToAdd
.get(((BasicCouplingChangeRequest) cr).getModel1());
if (cr2 != null) {
entry = cr2.getContext();
}
if (entry == null) {
throw new InvalidChangeRequestException(
"Coupling change request from model ["
+ ((BasicCouplingChangeRequest) cr).getModel1()
.getFullName()
+ "] and port ["
+ ((BasicCouplingChangeRequest) cr).getPort1().getName()
+ "]. There is no valid context in which this change can take place");
}
}
// System.out.println("CR in context "+entry.REMOTEgetFullName()+" type
// "+cr.getClass().getName()+" \n "+cr.toString());
List<ChangeRequest<?>> schg = strucChangesPerModel.get(entry);
if (schg == null) {
schg = new ArrayList<>();
schg.add(cr);
strucChangesPerModel.put(entry, schg);
} else {
schg.add(cr);
}
} else if (cr instanceof ModelChangeRequest) {
entry = ((ModelChangeRequest) cr).getContext();
if (entry == null) {
throw new InvalidChangeRequestException("Model change request for "
+ ((ModelChangeRequest) cr).getModelName()
+ " But this model has no context model to be inserted in!!");
}
List<ChangeRequest<?>> schg = strucChangesPerModel.get(entry);
if (schg == null) {
schg = new ArrayList<>();
schg.add(cr);
strucChangesPerModel.put(entry, schg);
} else {
schg.add(cr);
}
} else if (cr instanceof PortChangeRequest) {
// Test whether model already exists
entry = ((PortChangeRequest) cr).getModel();
// It may be that the model whose ports should be changed needs to be
// added before (has to be looked up in the hash map)
if (entry == null) {
ModelChangeRequest cr2 =
(ModelChangeRequest) modelsToAdd.get(((PortChangeRequest) cr)
.getModel());
if (cr2 != null) {
entry = cr2.getContext();
}
if (entry == null) {
throw new InvalidChangeRequestException(
"Port change request from model ["