[Monitor Service | master]: Indicator.java: In method "copyFromDefault()", get visibility as parameter and set the visibility of the new-copied indicator accordingly | IndicatorController.java: When creating indicators copied from a new default indicator, set the visibility of each new indicator same as of its parent subcategory.
This commit is contained in:
parent
0184da8a8e
commit
09b8d2188f
|
@ -88,10 +88,10 @@ public class IndicatorController {
|
||||||
List<Indicator> indicators = section.getIndicators();
|
List<Indicator> indicators = section.getIndicators();
|
||||||
for (Indicator indicator : indicators) {
|
for (Indicator indicator : indicators) {
|
||||||
if (indicator.getType().equals("chart")) {
|
if (indicator.getType().equals("chart")) {
|
||||||
saveIndicatorAndAddInSection(indicator, date, stakeholder, chart_section, chart_indicators);
|
saveIndicatorAndAddInSection(indicator, date, stakeholder, subcategoryId, chart_section, chart_indicators);
|
||||||
|
|
||||||
} else if (indicator.getType().equals("number")) {
|
} else if (indicator.getType().equals("number")) {
|
||||||
saveIndicatorAndAddInSection(indicator, date, stakeholder, number_section, number_indicators);
|
saveIndicatorAndAddInSection(indicator, date, stakeholder, subcategoryId, number_section, number_indicators);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,14 +118,18 @@ public class IndicatorController {
|
||||||
return section;
|
return section;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveIndicatorAndAddInSection(Indicator indicator, Date date, Stakeholder stakeholder, Section section, List<String> indicators) throws UnsupportedEncodingException {
|
// private void saveIndicatorAndAddInSection(Indicator indicator, Date date, Stakeholder stakeholder, Section section, List<String> indicators) throws UnsupportedEncodingException {
|
||||||
|
// saveIndicatorAndAddInSection(indicator, date, stakeholder, section, indicators);
|
||||||
|
// }
|
||||||
|
|
||||||
|
private void saveIndicatorAndAddInSection(Indicator indicator, Date date, Stakeholder stakeholder, String subcategoryId, Section section, List<String> indicators) throws UnsupportedEncodingException {
|
||||||
// indicator does not exist in DB
|
// indicator does not exist in DB
|
||||||
indicator.setCreationDate(date);
|
indicator.setCreationDate(date);
|
||||||
indicator.setUpdateDate(date);
|
indicator.setUpdateDate(date);
|
||||||
|
|
||||||
if (stakeholder.getDefaultId() == null) { // this indicator belongs in default profile and it is new
|
if (stakeholder.getDefaultId() == null) { // this indicator belongs in default profile and it is new
|
||||||
indicatorDAO.save(indicator);
|
indicatorDAO.save(indicator);
|
||||||
onSaveDefaultIndicator(indicator, section.getId());
|
onSaveDefaultIndicator(indicator, section, subcategoryId);
|
||||||
} else { // this indicator belongs in a stakeholder's profile and it is new
|
} else { // this indicator belongs in a stakeholder's profile and it is new
|
||||||
indicatorDAO.save(indicator);
|
indicatorDAO.save(indicator);
|
||||||
}
|
}
|
||||||
|
@ -168,7 +172,7 @@ public class IndicatorController {
|
||||||
if(stakeholder.getDefaultId() == null) {
|
if(stakeholder.getDefaultId() == null) {
|
||||||
if(indicatorId == null) {
|
if(indicatorId == null) {
|
||||||
indicatorDAO.save(indicator);
|
indicatorDAO.save(indicator);
|
||||||
onSaveDefaultIndicator(indicator, sectionId);
|
onSaveDefaultIndicator(indicator, section, subcategoryId);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
onUpdateDefaultIndicator(indicator, stakeholder, oldIndicator);
|
onUpdateDefaultIndicator(indicator, stakeholder, oldIndicator);
|
||||||
|
@ -190,15 +194,25 @@ public class IndicatorController {
|
||||||
return indicator;
|
return indicator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSaveDefaultIndicator(Indicator indicator, String defaultSectionId) throws UnsupportedEncodingException {
|
public void onSaveDefaultIndicator(Indicator indicator, Section defaultSection, String defaultSubcategoryId) throws UnsupportedEncodingException {
|
||||||
log.debug("On save default indicator");
|
log.debug("On save default indicator");
|
||||||
|
|
||||||
// new indicator in default profile - add it on profiles of the same type
|
// new indicator in default profile - add it on profiles of the same type
|
||||||
List<Section> sections = sectionDAO.findByDefaultId(defaultSectionId);
|
List<SubCategory> subCategories = subCategoryDAO.findByDefaultId(defaultSubcategoryId);
|
||||||
|
for (SubCategory subCategory : subCategories) {
|
||||||
|
|
||||||
for (Section section : sections) {
|
List<String> sections = null;
|
||||||
|
if(defaultSection.getType().equals("chart")) {
|
||||||
|
sections = subCategory.getCharts();
|
||||||
|
} else {
|
||||||
|
sections = subCategory.getNumbers();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String sectionId : sections) {
|
||||||
|
Section section = sectionDAO.findById(sectionId);
|
||||||
|
if(section.getDefaultId().equals(defaultSection.getId())) {
|
||||||
Indicator indicatorNew = new Indicator();
|
Indicator indicatorNew = new Indicator();
|
||||||
indicatorNew.copyFromDefault(indicator);
|
indicatorNew.copyFromDefault(indicator, subCategory.getVisibility());
|
||||||
for (IndicatorPath indicatorPath : indicatorNew.getIndicatorPaths()) {
|
for (IndicatorPath indicatorPath : indicatorNew.getIndicatorPaths()) {
|
||||||
Stakeholder stakeholder = stakeholderDAO.findByAlias(section.getStakeholderAlias());
|
Stakeholder stakeholder = stakeholderDAO.findByAlias(section.getStakeholderAlias());
|
||||||
parameterMapping(indicatorPath, stakeholder);
|
parameterMapping(indicatorPath, stakeholder);
|
||||||
|
@ -212,6 +226,8 @@ public class IndicatorController {
|
||||||
sectionDAO.save(section);
|
sectionDAO.save(section);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void onUpdateDefaultIndicator(Indicator indicator, Stakeholder stakeholder, Indicator oldIndicator) throws UnsupportedEncodingException {
|
public void onUpdateDefaultIndicator(Indicator indicator, Stakeholder stakeholder, Indicator oldIndicator) throws UnsupportedEncodingException {
|
||||||
log.debug("On update default indicator");
|
log.debug("On update default indicator");
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class Indicator {
|
||||||
private String defaultId;
|
private String defaultId;
|
||||||
private List<IndicatorPath> indicatorPaths;
|
private List<IndicatorPath> indicatorPaths;
|
||||||
|
|
||||||
public void copyFromDefault(Indicator defaultIndicator) {
|
public void copyFromDefault(Indicator defaultIndicator, Visibility visibility) {
|
||||||
setName(defaultIndicator.getName());
|
setName(defaultIndicator.getName());
|
||||||
setDescription(defaultIndicator.getDescription());
|
setDescription(defaultIndicator.getDescription());
|
||||||
setAdditionalDescription(defaultIndicator.getAdditionalDescription());
|
setAdditionalDescription(defaultIndicator.getAdditionalDescription());
|
||||||
|
@ -44,7 +44,7 @@ public class Indicator {
|
||||||
setWidth(defaultIndicator.getWidth());
|
setWidth(defaultIndicator.getWidth());
|
||||||
setHeight(defaultIndicator.getHeight());
|
setHeight(defaultIndicator.getHeight());
|
||||||
setTags(defaultIndicator.getTags());
|
setTags(defaultIndicator.getTags());
|
||||||
setVisibility(Visibility.RESTRICTED);
|
setVisibility(visibility);
|
||||||
setCreationDate(defaultIndicator.getCreationDate());
|
setCreationDate(defaultIndicator.getCreationDate());
|
||||||
setUpdateDate(defaultIndicator.getUpdateDate());
|
setUpdateDate(defaultIndicator.getUpdateDate());
|
||||||
setDefaultId(defaultIndicator.getId());
|
setDefaultId(defaultIndicator.getId());
|
||||||
|
|
Loading…
Reference in New Issue