super();
this.node = node;
}
private void saveRequirements() {
RequirementsDTO reqs = this.node.getFabric().getFabricService().getRequirements();
try {
if (formModel.getMinInstances() == null &&
formModel.getMaxInstances() == null &&
formModel.getDependencies().size()==0) {
// no requirements at all
if (reqs.findProfileRequirements(this.node.getProfile().getId()) == null) {
// there is no requirement so we don't save anything
return;
} else {
// there was a requirement but user wants to delete it
reqs.removeProfileRequirements(this.node.getProfile().getId());
return;
}
}
pReqs = reqs.getOrCreateProfileRequirement(this.node.getProfile().getId());
pReqs.setMinimumInstances(this.formModel.getMinInstances());
pReqs.setMaximumInstances(this.formModel.getMaxInstances());
// create the id list
List<String> profileDepList = new ArrayList<String>();
//fill the list
for (ProfileDTO p : formModel.getDependencies()) {
profileDepList.add(p.getId());
}
// assign it
pReqs.setDependentProfiles(profileDepList);
// then save it
reqs.addOrUpdateProfileRequirements(pReqs);
} finally {
this.node.getFabric().getFabricService().setRequirements(reqs);
}
}