use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class JAXBI18nLabel method extractLabels.
public ApsProperties extractLabels() {
ApsProperties properties = new ApsProperties();
if (null != this.getLabels()) {
for (int i = 0; i < this.getLabels().size(); i++) {
JAXBLabel jAXBLabel = this.getLabels().get(i);
properties.put(jAXBLabel.getLangCode(), jAXBLabel.getValue());
}
}
return properties;
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class LabelService method removeLabelGroup.
@Override
public void removeLabelGroup(String code) {
try {
ApsProperties labelGroup = this.getI18nManager().getLabelGroup(code);
if (null == labelGroup) {
logger.warn("no label found with key {}", code);
return;
}
this.getI18nManager().deleteLabelGroup(code);
} catch (ApsSystemException t) {
logger.error("error in delete label group with code {}", code, t);
throw new RestServerError("error in delete label group", t);
}
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class LabelService method validateAddLabelGroup.
protected BeanPropertyBindingResult validateAddLabelGroup(LabelDto labelDto) {
try {
BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(labelDto, "labelGroup");
String code = labelDto.getKey();
ApsProperties labelGroup = this.getI18nManager().getLabelGroup(code);
if (null != labelGroup) {
bindingResult.reject(LabelValidator.ERRCODE_LABELGROUP_EXISTS, new String[] { code }, "labelGroup.code.already.present");
return bindingResult;
}
String defaultLang = this.getLangManager().getDefaultLang().getCode();
boolean isDefaultLangValid = validateDefaultLang(labelDto, bindingResult, defaultLang);
if (!isDefaultLangValid) {
return bindingResult;
}
List<String> configuredLangs = this.getLangManager().getLangs().stream().map(i -> i.getCode()).collect(Collectors.toList());
labelDto.getTitles().entrySet().forEach(i -> validateLangEntry(i, configuredLangs, defaultLang, bindingResult));
return bindingResult;
} catch (ApsSystemException t) {
logger.error("error in validate add label group with code {}", labelDto.getKey(), t);
throw new RestServerError("error in validate add label group", t);
}
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class LabelService method getLabelGroups.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public PagedMetadata<LabelDto> getLabelGroups(RestListRequest restRequest) {
Map<String, ApsProperties> result = this.i18nManager.getLabelGroups();
List<LabelDto> dtoList = this.getDtoBuilder().convert(result);
if (restRequest.getDirection().equals(FieldSearchFilter.DESC_ORDER)) {
dtoList = dtoList.stream().sorted(Comparator.comparing(LabelDto::getKey).reversed()).collect(Collectors.toList());
} else {
dtoList = dtoList.stream().sorted(Comparator.comparing(LabelDto::getKey)).collect(Collectors.toList());
}
if (null != restRequest.getFilters()) {
for (Filter f : restRequest.getFilters()) {
if (f.getAttributeName().equals(LABEL_KEY_FILTER_KEY)) {
dtoList = dtoList.stream().filter(i -> i.getKey().toLowerCase().contains(f.getValue().toLowerCase())).collect(Collectors.toList());
}
if (f.getAttributeName().equals(LABEL_KEY_FILTER_VALUE)) {
dtoList = dtoList.stream().filter(i -> i.getTitles().values().stream().filter(k -> k.contains(f.getValue())).collect(Collectors.toList()).size() > 0).collect(Collectors.toList());
}
}
}
List<?> subList = restRequest.getSublist(dtoList);
SearcherDaoPaginatedResult<LabelDto> resultx = new SearcherDaoPaginatedResult(dtoList.size(), subList);
PagedMetadata<LabelDto> pagedMetadata = new PagedMetadata<>(restRequest, resultx);
pagedMetadata.setBody((List<LabelDto>) subList);
return pagedMetadata;
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class PageService method updateWidgetConfiguration.
@Override
public WidgetConfigurationDto updateWidgetConfiguration(String pageCode, int frameId, WidgetConfigurationRequest widgetReq) {
try {
IPage page = this.loadPage(pageCode, STATUS_DRAFT);
if (null == page) {
throw new RestRourceNotFoundException(ERRCODE_PAGE_NOT_FOUND, "page", pageCode);
}
if (frameId > page.getWidgets().length) {
throw new RestRourceNotFoundException(ERRCODE_FRAME_INVALID, "frame", String.valueOf(frameId));
}
if (null == this.getWidgetType(widgetReq.getCode())) {
throw new RestRourceNotFoundException(ERRCODE_WIDGET_INVALID, "widget", String.valueOf(widgetReq.getCode()));
}
BeanPropertyBindingResult validation = this.getWidgetValidatorFactory().get(widgetReq.getCode()).validate(widgetReq, page);
if (null != validation && validation.hasErrors()) {
throw new ValidationConflictException(validation);
}
ApsProperties properties = (ApsProperties) this.getWidgetProcessorFactory().get(widgetReq.getCode()).buildConfiguration(widgetReq);
WidgetType widgetType = this.getWidgetType(widgetReq.getCode());
Widget widget = new Widget();
widget.setType(widgetType);
widget.setConfig(properties);
this.getPageManager().joinWidget(pageCode, widget, frameId);
ApsProperties outProperties = this.getWidgetProcessorFactory().get(widgetReq.getCode()).extractConfiguration(widget.getConfig());
return new WidgetConfigurationDto(widget.getType().getCode(), outProperties);
} catch (ApsSystemException e) {
logger.error("Error in update widget configuration {}", pageCode, e);
throw new RestServerError("error in update widget configuration", e);
}
}
Aggregations