use of com.serotonin.m2m2.vo.DataPointVO in project ma-core-public by infiniteautomation.
the class DataPointDwr method getFull.
/*
* (non-Javadoc)
*
* @see com.deltamation.mango.downtime.web.AbstractBasicDwr#getFull(int)
*/
@DwrPermission(user = true)
@Override
public ProcessResult getFull(int id) {
DataPointVO vo;
User user = Common.getUser();
if (id == Common.NEW_ID) {
vo = dao.getNewVo();
// TODO Need to sort this out another way, this will wreck
// when users have mulitple tabs open in a browser
DataSourceVO<?> ds = user.getEditDataSource();
vo.setXid(dao.generateUniqueXid());
vo.setPointLocator(ds.createPointLocator());
vo.setDataSourceId(ds.getId());
vo.setDataSourceName(ds.getName());
vo.setDataSourceTypeName(ds.getDefinition().getDataSourceTypeName());
vo.setDataSourceXid(ds.getXid());
vo.setDeviceName(ds.getName());
vo.setEventDetectors(new ArrayList<AbstractPointEventDetectorVO<?>>(0));
vo.defaultTextRenderer();
} else {
vo = dao.getFull(id);
}
// Should check permissions?
// Permissions.ensureDataSourcePermission(user, vo.getDataSourceId());
user.setEditPoint(vo);
// TODO Need to deal with point value defaulter
ProcessResult response = new ProcessResult();
response.addData("vo", vo);
return response;
}
use of com.serotonin.m2m2.vo.DataPointVO in project ma-core-public by infiniteautomation.
the class DataPointDwr method jsonExportUsingFilter.
/**
* Export VOs based on a filter
*
* @param id
* @return
*/
@SuppressWarnings("unchecked")
@DwrPermission(user = true)
public String jsonExportUsingFilter(Map<String, String> query, List<SortOption> sort, Integer start, Integer count, boolean or) {
Map<String, Object> data = new LinkedHashMap<>();
List<DataPointVO> vos = new ArrayList<>();
ResultsWithTotal results = dao.dojoQuery(query, sort, start, count, or);
List<DataPointVO> filteredPoints = (List<DataPointVO>) results.getResults();
// Filter list on User Permissions
User user = Common.getUser();
for (DataPointVO vo : filteredPoints) {
if (Permissions.hasDataPointReadPermission(user, vo)) {
dao.loadRelationalData(vo);
vos.add(vo);
}
}
// Get the Full VO for the export
data.put(keyName, vos);
return EmportDwr.export(data, 3);
}
use of com.serotonin.m2m2.vo.DataPointVO in project ma-core-public by infiniteautomation.
the class DataPointDwr method toggle.
@DwrPermission(user = true)
public ProcessResult toggle(int dataPointId) {
DataPointVO dataPoint = DataPointDao.instance.getFull(dataPointId);
Permissions.ensureDataSourcePermission(Common.getUser(), dataPoint.getDataSourceId());
dataPoint.setEnabled(!dataPoint.isEnabled());
Common.runtimeManager.saveDataPoint(dataPoint);
ProcessResult response = new ProcessResult();
response.addData("id", dataPointId);
response.addData("enabled", dataPoint.isEnabled());
return response;
}
use of com.serotonin.m2m2.vo.DataPointVO in project ma-core-public by infiniteautomation.
the class DataPointDwr method getPoints.
@DwrPermission(user = true)
public ProcessResult getPoints() {
ProcessResult result = new ProcessResult();
User user = Common.getUser();
if (user == null) {
result.addData("list", new ArrayList<DataPointVO>());
return result;
}
DataSourceVO<?> ds = user.getEditDataSource();
if (ds.getId() == Common.NEW_ID) {
result.addData("list", new ArrayList<DataPointVO>());
return result;
}
List<DataPointVO> points = DataPointDao.instance.getDataPoints(ds.getId(), DataPointNameComparator.instance, false);
result.addData("list", points);
return result;
}
use of com.serotonin.m2m2.vo.DataPointVO in project ma-core-public by infiniteautomation.
the class DataPointDwr method remove.
/**
* Delete a VO
*
* @param id
* @return
*/
@Override
@DwrPermission(user = true)
public ProcessResult remove(int id) {
ProcessResult response = new ProcessResult();
try {
DataPointVO dp = dao.get(id);
if (dp != null)
Common.runtimeManager.deleteDataPoint(dp);
} catch (Exception e) {
// Handle the exceptions.
LOG.error(e);
DataPointVO vo = dao.get(id);
if (e instanceof DataIntegrityViolationException)
response.addContextualMessage(vo.getName(), "table.edit.unableToDeleteDueToConstraints");
else
response.addContextualMessage(vo.getName(), "table.edit.unableToDelete", e.getMessage());
}
response.addData("id", id);
return response;
}
Aggregations