use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-core-public by infiniteautomation.
the class AbstractBasicDwr method get.
/**
* Get a VO
* @param id
* @return
*/
@DwrPermission(user = true)
public ProcessResult get(int id) {
VO vo = dao.get(id);
ProcessResult response = new ProcessResult();
response.addData("vo", vo);
return response;
}
use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-core-public by infiniteautomation.
the class AbstractBasicDwr method dojoQuery.
/**
* Load a list of VOs
* @return
*/
@DwrPermission(user = true)
public ProcessResult dojoQuery(Map<String, String> query, List<SortOption> sort, Integer start, Integer count, boolean or) {
ProcessResult response = new ProcessResult();
ResultsWithTotal results = dao.dojoQuery(query, sort, start, count, or);
response.addData("list", results.getResults());
response.addData("total", results.getTotal());
return response;
}
use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-core-public by infiniteautomation.
the class AbstractDwr method getCopy.
@DwrPermission(user = true)
public ProcessResult getCopy(int id) {
// Get a Full Copy
VO vo = dao.getFull(id);
ProcessResult response = new ProcessResult();
String name = StringUtils.abbreviate(TranslatableMessage.translate(getTranslations(), "common.copyPrefix", vo.getName()), 40);
// Setup the Copy
VO copy = (VO) vo.copy();
copy.setId(Common.NEW_ID);
copy.setName(name);
copy.setXid(dao.generateUniqueXid());
response.addData("vo", copy);
return response;
}
use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-core-public by infiniteautomation.
the class AbstractDwr method get.
/* (non-Javadoc)
* @see com.deltamation.mango.downtime.web.AbstractBasicDwr#get(int)
*/
@DwrPermission(user = true)
@Override
public ProcessResult get(int id) {
VO vo;
if (id == Common.NEW_ID) {
vo = dao.getNewVo();
} else {
vo = dao.get(id);
}
ProcessResult response = new ProcessResult();
response.addData("vo", vo);
return response;
}
use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-core-public by infiniteautomation.
the class AbstractDwr method saveFull.
/**
* Save the VO AND FDAO Data
*
* Conversion for the VO must be added by extending DwrConversionDefinition
*
* @return
*/
@DwrPermission(admin = true)
public ProcessResult saveFull(VO vo) {
// TODO combine with save()
ProcessResult response = new ProcessResult();
if (vo.getXid() == null) {
vo.setXid(dao.generateUniqueXid());
}
vo.validate(response);
if (!response.getHasMessages()) {
try {
dao.saveFull(vo);
} 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;
}
Aggregations