throws Exception {
if (log.isDebugEnabled()) {
log.debug("entering 'onSubmit' method...");
}
Strength strength = (Strength) command;
boolean isNew = (strength.getPointId() == null);
Locale locale = request.getLocale();
if (request.getParameter("delete") != null) {
Integer exampleId = strength.getExampleId();
// strengthManager.removeStrength(strength.getPointId().toString());
ConstructionExample constructionExample = constructionExampleManager.getConstructionExample(exampleId.toString());
constructionExample.getStrengthPoints().remove(strength);
// constructionExampleManager.saveConstructionExample(constructionExample);
saveMessage(request, getText("strength.deleted", locale));
} else {
//adding this point to the list of the construction example
ConstructionExample constructionExample1 = constructionExampleManager.getConstructionExample(strength.getExampleId().toString());
if (constructionExample1.getWayToPowerEsckiz() != null) {
File eskizFile = new File(FileHelper.getCurrentPath(request) + constructionExample1.getWayToPowerEsckiz());
if (eskizFile.exists()) {
constructionExample1.setPowerEsckizBlob(Hibernate.createBlob(new FileInputStream(FileHelper.getCurrentPath(request) + constructionExample1.getWayToPowerEsckiz())));
}
}
constructionExampleManager.saveConstructionExample(constructionExample1);
constructionExampleManager.evict(constructionExample1);
if (isNew) {
Integer exampleId = strength.getExampleId();
ConstructionExample constructionExample = constructionExampleManager.getConstructionExample(exampleId.toString());
// BuildingObject buildingObject=buildingObjectManager.getBuildingObject(constructionExample.getObjectId().toString());
constructionExample.getStrengthPoints().add(strength);
constructionExampleManager.saveConstructionExample(constructionExample);
// buildingObjectManager.saveBuildingObject(buildingObject);
// constructionExampleManager.saveConstructionExample(constructionExample);
ObjectConstruction objectConstruction = objectConstructionManager.getObjectConstruction(constructionExample.getObjectConstructionId().toString());
String fileName = FileHelper.getCurrentPath(request) + objectConstruction.getWayToDefectMap();
paintStrength(constructionExample, strength, fileName,"save");
} else {
strengthManager.saveStrength(strength);
Integer exampleId = strength.getExampleId();
ConstructionExample constructionExample = constructionExampleManager.getConstructionExample(exampleId.toString());
ObjectConstruction objectConstruction = objectConstructionManager.getObjectConstruction(constructionExample.getObjectConstructionId().toString());
String fileName = FileHelper.getCurrentPath(request) + objectConstruction.getWayToDefectMap();
paintStrength(constructionExample, strength, fileName,"update");
}
String key = (isNew) ? "strength.added" : "strength.updated";
saveMessage(request, getText(key, locale));
if (strength.isEdited()) {
return new ModelAndView("redirect:updating.html?id=" + strength.getPointId() + "&fieldId=" + request.getParameter("fieldId"));
}
}
return new ModelAndView("redirect:" + strength.getDocLocation());
}