use of com.serotonin.m2m2.vo.publish.PublishedPointVO in project ma-core-public by MangoAutomation.
the class PublishedPointService method setPublishedPointState.
/**
* Enable/Disable/Restart a published point
*
* @param xid - xid of point to restart
* @param enabled - Enable or disable the published point
* @param restart - Restart the published point, enabled must equal true
*/
public boolean setPublishedPointState(String xid, boolean enabled, boolean restart) throws NotFoundException, PermissionException {
PermissionHolder user = Common.getUser();
PublishedPointVO vo = get(xid);
ensureEditPermission(user, vo);
return setPublishedPointState(vo, enabled, restart);
}
use of com.serotonin.m2m2.vo.publish.PublishedPointVO in project ma-core-public by MangoAutomation.
the class PublishedPointService method delete.
@Override
protected PublishedPointVO delete(PublishedPointVO vo) throws PermissionException, NotFoundException {
PermissionHolder user = Common.getUser();
ensureDeletePermission(user, vo);
getRuntimeManager().stopPublishedPoint(vo.getId());
dao.delete(vo);
return vo;
}
use of com.serotonin.m2m2.vo.publish.PublishedPointVO in project ma-core-public by MangoAutomation.
the class PublishedPointService method validate.
@Override
public ProcessResult validate(PublishedPointVO vo) {
// validate XID and name
ProcessResult result = super.validate(vo);
// Ensure the definition exists
PublisherDefinition<? extends PublisherVO> definition = ModuleRegistry.getPublisherDefinition(vo.getPublisherTypeName());
if (definition == null) {
result.addContextualMessage("publisherTypeName", "validate.invalidValue");
}
// Check the publisher exists
PublisherVO pub = publisherDao.get(vo.getPublisherId());
if (pub == null) {
result.addContextualMessage("publisherId", "validate.publisher.missingPublisher", vo.getPublisherId());
} else {
vo.setPublisherXid(pub.getXid());
}
// Ensure data point exists
String dataPointXid = dataPointDao.getXidById(vo.getDataPointId());
if (dataPointXid == null) {
result.addContextualMessage("dataPointId", "validate.publisher.missingPoint", vo.getDataPointId());
} else {
vo.setDataPointXid(dataPointXid);
}
if (definition != null && pub != null) {
definition.validate(result, vo, pub);
}
return result;
}
use of com.serotonin.m2m2.vo.publish.PublishedPointVO in project ma-core-public by MangoAutomation.
the class MockRuntimeManager method stopPublishedPoint.
@Override
public void stopPublishedPoint(int id) {
if (useDatabase) {
PublishedPointVO vo = PublishedPointDao.getInstance().get(id);
vo.setEnabled(false);
PublishedPointDao.getInstance().saveEnabledColumn(vo);
}
}
use of com.serotonin.m2m2.vo.publish.PublishedPointVO in project ma-core-public by MangoAutomation.
the class PublisherRT method initializePoints.
/**
* The {@link PublishedPointGroupInitializer} calls
* {@link RuntimeManager#startPublishedPoint(PublishedPointVO) startPublishedPoint()}
* which adds the points to the cache in the RTM and initializes them.
*/
private void initializePoints() {
ExecutorService executorService = Common.getBean(ExecutorService.class);
// Add the enabled points to the data source.
List<PublishedPointVO> points = publishedPointDao.getEnabledPublishedPoints(getId());
// Startup multi threaded
int pointsPerThread = Common.envProps.getInt("runtime.publishedPoint.startupThreads.pointsPerThread", 1000);
int startupThreads = Common.envProps.getInt("runtime.publishedPoint.startupThreads", Runtime.getRuntime().availableProcessors());
PublishedPointGroupInitializer pointInitializer = new PublishedPointGroupInitializer(executorService, startupThreads);
pointInitializer.initialize(points, pointsPerThread);
}
Aggregations