Search in sources :

Example 6 with PublishedPointVO

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);
}
Also used : PermissionHolder(com.serotonin.m2m2.vo.permission.PermissionHolder) PublishedPointVO(com.serotonin.m2m2.vo.publish.PublishedPointVO)

Example 7 with PublishedPointVO

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;
}
Also used : PermissionHolder(com.serotonin.m2m2.vo.permission.PermissionHolder)

Example 8 with PublishedPointVO

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;
}
Also used : ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) PublisherVO(com.serotonin.m2m2.vo.publish.PublisherVO)

Example 9 with PublishedPointVO

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);
    }
}
Also used : PublishedPointVO(com.serotonin.m2m2.vo.publish.PublishedPointVO)

Example 10 with PublishedPointVO

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);
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) PublishedPointGroupInitializer(com.serotonin.m2m2.rt.PublishedPointGroupInitializer) PublishedPointVO(com.serotonin.m2m2.vo.publish.PublishedPointVO)

Aggregations

PublishedPointVO (com.serotonin.m2m2.vo.publish.PublishedPointVO)34 MockPublishedPointVO (com.serotonin.m2m2.vo.publish.mock.MockPublishedPointVO)16 Test (org.junit.Test)12 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)9 IDataPoint (com.serotonin.m2m2.vo.IDataPoint)8 MockPublisherVO (com.serotonin.m2m2.vo.publish.mock.MockPublisherVO)8 JsonException (com.serotonin.json.JsonException)6 PermissionHolder (com.serotonin.m2m2.vo.permission.PermissionHolder)6 PublisherVO (com.serotonin.m2m2.vo.publish.PublisherVO)6 NonNull (org.checkerframework.checker.nullness.qual.NonNull)6 NotFoundException (com.infiniteautomation.mango.util.exception.NotFoundException)4 ValidationException (com.infiniteautomation.mango.util.exception.ValidationException)4 ProcessResult (com.serotonin.m2m2.i18n.ProcessResult)4 TranslatableJsonException (com.serotonin.m2m2.i18n.TranslatableJsonException)4 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)4 PublisherRT (com.serotonin.m2m2.rt.publish.PublisherRT)4 ApiOperation (io.swagger.annotations.ApiOperation)4 ArrayList (java.util.ArrayList)4 URI (java.net.URI)3 HttpHeaders (org.springframework.http.HttpHeaders)3