Search in sources :

Example 6 with RuleChainId

use of org.thingsboard.server.common.data.id.RuleChainId in project thingsboard by thingsboard.

the class DeviceProfileEntity method toData.

@Override
public DeviceProfile toData() {
    DeviceProfile deviceProfile = new DeviceProfile(new DeviceProfileId(this.getUuid()));
    deviceProfile.setCreatedTime(createdTime);
    if (tenantId != null) {
        deviceProfile.setTenantId(TenantId.fromUUID(tenantId));
    }
    deviceProfile.setName(name);
    deviceProfile.setType(type);
    deviceProfile.setImage(image);
    deviceProfile.setTransportType(transportType);
    deviceProfile.setProvisionType(provisionType);
    deviceProfile.setDescription(description);
    deviceProfile.setDefault(isDefault);
    deviceProfile.setProfileData(JacksonUtil.convertValue(profileData, DeviceProfileData.class));
    if (defaultRuleChainId != null) {
        deviceProfile.setDefaultRuleChainId(new RuleChainId(defaultRuleChainId));
    }
    if (defaultDashboardId != null) {
        deviceProfile.setDefaultDashboardId(new DashboardId(defaultDashboardId));
    }
    deviceProfile.setDefaultQueueName(defaultQueueName);
    deviceProfile.setProvisionDeviceKey(provisionDeviceKey);
    if (firmwareId != null) {
        deviceProfile.setFirmwareId(new OtaPackageId(firmwareId));
    }
    if (softwareId != null) {
        deviceProfile.setSoftwareId(new OtaPackageId(softwareId));
    }
    return deviceProfile;
}
Also used : DeviceProfile(org.thingsboard.server.common.data.DeviceProfile) DeviceProfileId(org.thingsboard.server.common.data.id.DeviceProfileId) OtaPackageId(org.thingsboard.server.common.data.id.OtaPackageId) RuleChainId(org.thingsboard.server.common.data.id.RuleChainId) DashboardId(org.thingsboard.server.common.data.id.DashboardId) DeviceProfileData(org.thingsboard.server.common.data.device.profile.DeviceProfileData)

Example 7 with RuleChainId

use of org.thingsboard.server.common.data.id.RuleChainId in project thingsboard by thingsboard.

the class RuleChainEntity method toData.

@Override
public RuleChain toData() {
    RuleChain ruleChain = new RuleChain(new RuleChainId(this.getUuid()));
    ruleChain.setCreatedTime(createdTime);
    ruleChain.setTenantId(TenantId.fromUUID(tenantId));
    ruleChain.setName(name);
    ruleChain.setType(type);
    if (firstRuleNodeId != null) {
        ruleChain.setFirstRuleNodeId(new RuleNodeId(firstRuleNodeId));
    }
    ruleChain.setRoot(root);
    ruleChain.setDebugMode(debugMode);
    ruleChain.setConfiguration(configuration);
    ruleChain.setAdditionalInfo(additionalInfo);
    return ruleChain;
}
Also used : RuleChain(org.thingsboard.server.common.data.rule.RuleChain) RuleChainId(org.thingsboard.server.common.data.id.RuleChainId) RuleNodeId(org.thingsboard.server.common.data.id.RuleNodeId)

Example 8 with RuleChainId

use of org.thingsboard.server.common.data.id.RuleChainId in project thingsboard by thingsboard.

the class RuleNodeEntity method toData.

@Override
public RuleNode toData() {
    RuleNode ruleNode = new RuleNode(new RuleNodeId(this.getUuid()));
    ruleNode.setCreatedTime(createdTime);
    if (ruleChainId != null) {
        ruleNode.setRuleChainId(new RuleChainId(ruleChainId));
    }
    ruleNode.setType(type);
    ruleNode.setName(name);
    ruleNode.setDebugMode(debugMode);
    ruleNode.setConfiguration(configuration);
    ruleNode.setAdditionalInfo(additionalInfo);
    return ruleNode;
}
Also used : RuleNode(org.thingsboard.server.common.data.rule.RuleNode) RuleChainId(org.thingsboard.server.common.data.id.RuleChainId) RuleNodeId(org.thingsboard.server.common.data.id.RuleNodeId)

Example 9 with RuleChainId

use of org.thingsboard.server.common.data.id.RuleChainId in project thingsboard by thingsboard.

the class TbRuleChainInputNode method init.

@Override
public void init(TbContext ctx, TbNodeConfiguration configuration) throws TbNodeException {
    this.config = TbNodeUtils.convert(configuration, TbRuleChainInputNodeConfiguration.class);
    this.ruleChainId = new RuleChainId(UUID.fromString(config.getRuleChainId()));
}
Also used : RuleChainId(org.thingsboard.server.common.data.id.RuleChainId)

Example 10 with RuleChainId

use of org.thingsboard.server.common.data.id.RuleChainId in project thingsboard by thingsboard.

the class EdgeController method setEdgeRootRuleChain.

@ApiOperation(value = "Set root rule chain for provided edge (setEdgeRootRuleChain)", notes = "Change root rule chain of the edge to the new provided rule chain. \n" + "This operation will send a notification to update root rule chain on remote edge service." + TENANT_AUTHORITY_PARAGRAPH, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN')")
@RequestMapping(value = "/edge/{edgeId}/{ruleChainId}/root", method = RequestMethod.POST)
@ResponseBody
public Edge setEdgeRootRuleChain(@ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true) @PathVariable(EDGE_ID) String strEdgeId, @ApiParam(value = RULE_CHAIN_ID_PARAM_DESCRIPTION, required = true) @PathVariable("ruleChainId") String strRuleChainId) throws ThingsboardException {
    checkParameter(EDGE_ID, strEdgeId);
    checkParameter("ruleChainId", strRuleChainId);
    try {
        RuleChainId ruleChainId = new RuleChainId(toUUID(strRuleChainId));
        checkRuleChain(ruleChainId, Operation.WRITE);
        EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
        Edge edge = checkEdgeId(edgeId, Operation.WRITE);
        accessControlService.checkPermission(getCurrentUser(), Resource.EDGE, Operation.WRITE, edge.getId(), edge);
        Edge updatedEdge = edgeNotificationService.setEdgeRootRuleChain(getTenantId(), edge, ruleChainId);
        tbClusterService.broadcastEntityStateChangeEvent(updatedEdge.getTenantId(), updatedEdge.getId(), ComponentLifecycleEvent.UPDATED);
        logEntityAction(updatedEdge.getId(), updatedEdge, null, ActionType.UPDATED, null);
        return updatedEdge;
    } catch (Exception e) {
        logEntityAction(emptyId(EntityType.EDGE), null, null, ActionType.UPDATED, e, strEdgeId);
        throw handleException(e);
    }
}
Also used : EdgeId(org.thingsboard.server.common.data.id.EdgeId) RuleChainId(org.thingsboard.server.common.data.id.RuleChainId) Edge(org.thingsboard.server.common.data.edge.Edge) IncorrectParameterException(org.thingsboard.server.dao.exception.IncorrectParameterException) DataValidationException(org.thingsboard.server.dao.exception.DataValidationException) ThingsboardException(org.thingsboard.server.common.data.exception.ThingsboardException) IOException(java.io.IOException) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

RuleChainId (org.thingsboard.server.common.data.id.RuleChainId)60 RuleChain (org.thingsboard.server.common.data.rule.RuleChain)22 RuleNodeId (org.thingsboard.server.common.data.id.RuleNodeId)20 Test (org.junit.Test)17 TbMsg (org.thingsboard.server.common.msg.TbMsg)16 ThingsboardException (org.thingsboard.server.common.data.exception.ThingsboardException)12 EntityId (org.thingsboard.server.common.data.id.EntityId)12 ApiOperation (io.swagger.annotations.ApiOperation)11 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)11 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)11 TenantId (org.thingsboard.server.common.data.id.TenantId)11 TbMsgMetaData (org.thingsboard.server.common.msg.TbMsgMetaData)11 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)10 DeviceId (org.thingsboard.server.common.data.id.DeviceId)9 RuleNode (org.thingsboard.server.common.data.rule.RuleNode)8 Futures (com.google.common.util.concurrent.Futures)7 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)7 IOException (java.io.IOException)7 Uuids (com.datastax.oss.driver.api.core.uuid.Uuids)6 JsonNode (com.fasterxml.jackson.databind.JsonNode)6