use of com.serotonin.m2m2.i18n.ProcessResult in project ma-core-public by infiniteautomation.
the class SystemSettingsDwr method saveThreadPoolSettings.
@DwrPermission(admin = true)
public ProcessResult saveThreadPoolSettings(int highPriorityCorePoolSize, int highPriorityMaxPoolSize, int medPriorityCorePoolSize, int lowPriorityCorePoolSize) {
ProcessResult response = new ProcessResult();
SystemSettingsDao systemSettingsDao = SystemSettingsDao.instance;
if (highPriorityCorePoolSize > 0) {
systemSettingsDao.setIntValue(SystemSettingsDao.HIGH_PRI_CORE_POOL_SIZE, highPriorityCorePoolSize);
} else {
response.addContextualMessage(SystemSettingsDao.HIGH_PRI_CORE_POOL_SIZE, "validate.greaterThanZero");
}
if (highPriorityMaxPoolSize < BackgroundProcessing.HIGH_PRI_MAX_POOL_SIZE_MIN) {
response.addContextualMessage(SystemSettingsDao.HIGH_PRI_MAX_POOL_SIZE, "validate.greaterThanOrEqualTo", BackgroundProcessing.HIGH_PRI_MAX_POOL_SIZE_MIN);
} else if (highPriorityMaxPoolSize < highPriorityCorePoolSize) {
response.addContextualMessage(SystemSettingsDao.HIGH_PRI_MAX_POOL_SIZE, "systemSettings.threadPools.validate.maxPoolMustBeGreaterThanCorePool");
} else {
systemSettingsDao.setIntValue(SystemSettingsDao.HIGH_PRI_MAX_POOL_SIZE, highPriorityMaxPoolSize);
}
// core pool thread is available
if (medPriorityCorePoolSize >= BackgroundProcessing.MED_PRI_MAX_POOL_SIZE_MIN) {
// Due to the pool type we should set these to the same values
systemSettingsDao.setIntValue(SystemSettingsDao.MED_PRI_CORE_POOL_SIZE, medPriorityCorePoolSize);
} else {
response.addContextualMessage(SystemSettingsDao.MED_PRI_CORE_POOL_SIZE, "validate.greaterThanOrEqualTo", BackgroundProcessing.MED_PRI_MAX_POOL_SIZE_MIN);
}
if (lowPriorityCorePoolSize >= BackgroundProcessing.LOW_PRI_MAX_POOL_SIZE_MIN) {
systemSettingsDao.setIntValue(SystemSettingsDao.LOW_PRI_CORE_POOL_SIZE, lowPriorityCorePoolSize);
} else {
response.addContextualMessage(SystemSettingsDao.LOW_PRI_CORE_POOL_SIZE, "validate.greaterThanOrEqualTo", BackgroundProcessing.LOW_PRI_MAX_POOL_SIZE_MIN);
}
return response;
}
use of com.serotonin.m2m2.i18n.ProcessResult in project ma-core-public by infiniteautomation.
the class TemplateDwr method getDataPointTemplate.
/**
* Save a template
* @return
*/
@DwrPermission(user = true)
public ProcessResult getDataPointTemplate(int id) {
ProcessResult result = new ProcessResult();
result.addData("template", dao.get(id));
return result;
}
use of com.serotonin.m2m2.i18n.ProcessResult in project ma-core-public by infiniteautomation.
the class TemplateDwr method getNewDataPointTemplate.
/**
* Get a new Data Point Template
* @return
*/
@DwrPermission(user = true)
public ProcessResult getNewDataPointTemplate() {
ProcessResult response = new ProcessResult();
DataPointPropertiesTemplateVO vo = new DataPointPropertiesTemplateVO();
vo.setDefinition(new DataPointPropertiesTemplateDefinition());
response.addData("vo", vo);
return response;
}
use of com.serotonin.m2m2.i18n.ProcessResult in project ma-core-public by infiniteautomation.
the class TemplateDwr method saveDataPointTemplate.
/**
* Save a Data Point template
* @return
*/
@DwrPermission(user = true)
public ProcessResult saveDataPointTemplate(DataPointPropertiesTemplateVO vo) {
ProcessResult response = new ProcessResult();
if (vo.getXid() == null) {
vo.setXid(dao.generateUniqueXid());
}
// we need a name for validation so set XID and name to the same thing.
if (StringUtils.isEmpty(vo.getName())) {
vo.setName(vo.getXid());
}
vo.validate(response);
if (!response.getHasMessages()) {
try {
dao.save(vo);
updateDataPointsUsingTemplate(vo, response);
} catch (Exception e) {
// Handle the exceptions.
LOG.error(e);
String context = vo.getName();
if (context == null) {
context = vo.getXid();
}
if (context == null) {
context = vo.getXid();
}
if (context == null) {
context = Integer.toString(vo.getId());
}
if (e instanceof DuplicateKeyException)
response.addContextualMessage(context, "table.edit.alreadyExists");
else
response.addContextualMessage(context, "table.edit.unableToSave", e.getMessage());
}
}
response.addData("vo", vo);
// Add in case it fails
response.addData("id", vo.getId());
return response;
}
use of com.serotonin.m2m2.i18n.ProcessResult in project ma-core-public by infiniteautomation.
the class TemplateDwr method getDataPointTemplates.
/**
* Save a template
* @return
*/
@DwrPermission(user = true)
public ProcessResult getDataPointTemplates(int dataTypeId) {
ProcessResult result = new ProcessResult();
List<DataPointPropertiesTemplateVO> templates = dao.getDataPointTemplatesByDataTypeId(dataTypeId);
result.addData(TemplateDao.instance.tableName, templates);
return result;
}
Aggregations