use of com.serotonin.m2m2.vo.publish.PublishedPointVO in project ma-core-public by MangoAutomation.
the class PublishedPointServiceTest method testNonAdminDelete.
@Test(expected = PermissionException.class)
public void testNonAdminDelete() {
PublishedPointVO vo = insertNewVO(readUser);
PublishedPointVO fromDb = service.get(vo.getId());
assertVoEqual(vo, fromDb);
runAs.runAs(readUser, () -> {
service.delete(vo);
});
}
use of com.serotonin.m2m2.vo.publish.PublishedPointVO in project ma-core-public by MangoAutomation.
the class RuntimeManagerImpl method startPublisher.
@Override
public void startPublisher(PublisherVO vo) {
// Ensure that the publisher is saved and enabled.
Assert.isTrue(vo.getId() > 0, "Publisher must be saved");
Assert.isTrue(vo.isEnabled(), "Publisher must be enabled");
ensureState(ILifecycleState.INITIALIZING, ILifecycleState.RUNNING);
PublisherRT<? extends PublisherVO, ? extends PublishedPointVO, ? extends SendThread> publisher = runningPublishers.computeIfAbsent(vo.getId(), k -> vo.createPublisherRT());
long startTime = System.nanoTime();
// Initialize the runtime of the publisher.
publisher.initialize(false);
long duration = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime);
stateMessage = new TranslatableMessage("runtimeManager.initialize.publisher", vo.getName(), duration);
LOG.info(String.format("%s took %dms to start", publisher.readableIdentifier(), duration));
}
use of com.serotonin.m2m2.vo.publish.PublishedPointVO in project ma-core-public by MangoAutomation.
the class RuntimeManagerImpl method startPublishedPoint.
@Override
public void startPublishedPoint(PublishedPointVO vo) {
// Ensure that the published point is saved and enabled.
Assert.isTrue(vo.getId() > 0, "Published point must be saved");
Assert.isTrue(vo.isEnabled(), "Published point not enabled");
ensureState(ILifecycleState.INITIALIZING, ILifecycleState.RUNNING);
// Only add the published point if its publisher is enabled.
PublisherRT<? extends PublisherVO, ? extends PublishedPointVO, ? extends SendThread> pub = runningPublishers.get(vo.getPublisherId());
if (pub != null) {
PublishedPointRT point = publishedPointCache.computeIfAbsent(vo.getId(), k -> new PublishedPointRT(vo, pub));
// Initialize it, will fail if published point is already initializing or running
point.initialize(false);
}
}
use of com.serotonin.m2m2.vo.publish.PublishedPointVO in project ma-core-public by MangoAutomation.
the class PublishedPointService method update.
@Override
protected PublishedPointVO update(PublishedPointVO existing, PublishedPointVO vo) throws PermissionException, ValidationException {
PermissionHolder user = Common.getUser();
ensureEditPermission(user, existing);
vo.setId(existing.getId());
ensureValid(existing, vo);
getRuntimeManager().stopPublishedPoint(vo.getId());
dao.update(existing, vo);
if (vo.isEnabled()) {
getRuntimeManager().startPublishedPoint(vo);
}
return vo;
}
use of com.serotonin.m2m2.vo.publish.PublishedPointVO in project ma-core-public by MangoAutomation.
the class PublisherDefinition method createPublishedPointVO.
/**
* Create a point with the publisher id, type and data point id set
*/
@NonNull
public <T extends PublishedPointVO> T createPublishedPointVO(int publisherId, int dataPointId) {
T vo = newPublishedPointVO();
vo.setPublisherId(publisherId);
vo.setDataPointId(dataPointId);
vo.setPublisherTypeName(getPublisherTypeName());
return vo;
}
Aggregations