|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
@ -0,0 +1,32 @@ |
|||
/** |
|||
* Copyright © 2016-2024 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.dao.service.validator; |
|||
|
|||
import org.springframework.stereotype.Component; |
|||
import org.thingsboard.server.common.data.domain.Domain; |
|||
import org.thingsboard.server.common.data.id.TenantId; |
|||
import org.thingsboard.server.dao.exception.IncorrectParameterException; |
|||
|
|||
@Component |
|||
public class DomainDataValidator extends AbstractHasOtaPackageValidator<Domain> { |
|||
|
|||
@Override |
|||
protected void validateDataImpl(TenantId tenantId, Domain domain) { |
|||
if (!isValidDomain(domain.getName())) { |
|||
throw new IncorrectParameterException("Domain name " + domain.getName() + " is invalid"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,117 @@ |
|||
/** |
|||
* Copyright © 2016-2024 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.rule.engine.api; |
|||
|
|||
import com.google.common.util.concurrent.FutureCallback; |
|||
import com.google.common.util.concurrent.SettableFuture; |
|||
import lombok.AccessLevel; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
import lombok.ToString; |
|||
import org.thingsboard.server.common.data.AttributeScope; |
|||
import org.thingsboard.server.common.data.id.EntityId; |
|||
import org.thingsboard.server.common.data.id.TenantId; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Getter |
|||
@ToString |
|||
@AllArgsConstructor(access = AccessLevel.PRIVATE) |
|||
public class AttributesDeleteRequest { |
|||
|
|||
private final TenantId tenantId; |
|||
private final EntityId entityId; |
|||
private final AttributeScope scope; |
|||
private final List<String> keys; |
|||
private final boolean notifyDevice; |
|||
private final FutureCallback<Void> callback; |
|||
|
|||
public static Builder builder() { |
|||
return new Builder(); |
|||
} |
|||
|
|||
public static class Builder { |
|||
|
|||
private TenantId tenantId; |
|||
private EntityId entityId; |
|||
private AttributeScope scope; |
|||
private List<String> keys; |
|||
private boolean notifyDevice; |
|||
private FutureCallback<Void> callback; |
|||
|
|||
Builder() {} |
|||
|
|||
public Builder tenantId(TenantId tenantId) { |
|||
this.tenantId = tenantId; |
|||
return this; |
|||
} |
|||
|
|||
public Builder entityId(EntityId entityId) { |
|||
this.entityId = entityId; |
|||
return this; |
|||
} |
|||
|
|||
public Builder scope(AttributeScope scope) { |
|||
this.scope = scope; |
|||
return this; |
|||
} |
|||
|
|||
@Deprecated |
|||
public Builder scope(String scope) { |
|||
try { |
|||
this.scope = AttributeScope.valueOf(scope); |
|||
} catch (IllegalArgumentException e) { |
|||
throw new IllegalArgumentException("Invalid attribute scope '" + scope + "'"); |
|||
} |
|||
return this; |
|||
} |
|||
|
|||
public Builder keys(List<String> keys) { |
|||
this.keys = keys; |
|||
return this; |
|||
} |
|||
|
|||
public Builder notifyDevice(boolean notifyDevice) { |
|||
this.notifyDevice = notifyDevice; |
|||
return this; |
|||
} |
|||
|
|||
public Builder callback(FutureCallback<Void> callback) { |
|||
this.callback = callback; |
|||
return this; |
|||
} |
|||
|
|||
public Builder future(SettableFuture<Void> future) { |
|||
return callback(new FutureCallback<>() { |
|||
@Override |
|||
public void onSuccess(Void result) { |
|||
future.set(result); |
|||
} |
|||
|
|||
@Override |
|||
public void onFailure(Throwable t) { |
|||
future.setException(t); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
public AttributesDeleteRequest build() { |
|||
return new AttributesDeleteRequest(tenantId, entityId, scope, keys, notifyDevice, callback); |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,128 @@ |
|||
/** |
|||
* Copyright © 2016-2024 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.rule.engine.api; |
|||
|
|||
import com.google.common.util.concurrent.FutureCallback; |
|||
import com.google.common.util.concurrent.SettableFuture; |
|||
import lombok.AccessLevel; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
import lombok.ToString; |
|||
import org.thingsboard.server.common.data.AttributeScope; |
|||
import org.thingsboard.server.common.data.id.EntityId; |
|||
import org.thingsboard.server.common.data.id.TenantId; |
|||
import org.thingsboard.server.common.data.kv.AttributeKvEntry; |
|||
import org.thingsboard.server.common.data.kv.BaseAttributeKvEntry; |
|||
import org.thingsboard.server.common.data.kv.KvEntry; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Getter |
|||
@ToString |
|||
@AllArgsConstructor(access = AccessLevel.PRIVATE) |
|||
public class AttributesSaveRequest { |
|||
|
|||
private final TenantId tenantId; |
|||
private final EntityId entityId; |
|||
private final AttributeScope scope; |
|||
private final List<AttributeKvEntry> entries; |
|||
private final boolean notifyDevice; |
|||
private final FutureCallback<Void> callback; |
|||
|
|||
public static Builder builder() { |
|||
return new Builder(); |
|||
} |
|||
|
|||
public static class Builder { |
|||
|
|||
private TenantId tenantId; |
|||
private EntityId entityId; |
|||
private AttributeScope scope; |
|||
private List<AttributeKvEntry> entries; |
|||
private boolean notifyDevice = true; |
|||
private FutureCallback<Void> callback; |
|||
|
|||
Builder() {} |
|||
|
|||
public Builder tenantId(TenantId tenantId) { |
|||
this.tenantId = tenantId; |
|||
return this; |
|||
} |
|||
|
|||
public Builder entityId(EntityId entityId) { |
|||
this.entityId = entityId; |
|||
return this; |
|||
} |
|||
|
|||
public Builder scope(AttributeScope scope) { |
|||
this.scope = scope; |
|||
return this; |
|||
} |
|||
|
|||
@Deprecated |
|||
public Builder scope(String scope) { |
|||
try { |
|||
this.scope = AttributeScope.valueOf(scope); |
|||
} catch (IllegalArgumentException e) { |
|||
throw new IllegalArgumentException("Invalid attribute scope '" + scope + "'"); |
|||
} |
|||
return this; |
|||
} |
|||
|
|||
public Builder entries(List<AttributeKvEntry> entries) { |
|||
this.entries = entries; |
|||
return this; |
|||
} |
|||
|
|||
public Builder entry(AttributeKvEntry entry) { |
|||
return entries(List.of(entry)); |
|||
} |
|||
|
|||
public Builder entry(KvEntry kvEntry) { |
|||
return entry(new BaseAttributeKvEntry(kvEntry, System.currentTimeMillis())); |
|||
} |
|||
|
|||
public Builder notifyDevice(boolean notifyDevice) { |
|||
this.notifyDevice = notifyDevice; |
|||
return this; |
|||
} |
|||
|
|||
public Builder callback(FutureCallback<Void> callback) { |
|||
this.callback = callback; |
|||
return this; |
|||
} |
|||
|
|||
public Builder future(SettableFuture<Void> future) { |
|||
return callback(new FutureCallback<>() { |
|||
@Override |
|||
public void onSuccess(Void result) { |
|||
future.set(result); |
|||
} |
|||
|
|||
@Override |
|||
public void onFailure(Throwable t) { |
|||
future.setException(t); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
public AttributesSaveRequest build() { |
|||
return new AttributesSaveRequest(tenantId, entityId, scope, entries, notifyDevice, callback); |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,85 @@ |
|||
/** |
|||
* Copyright © 2016-2024 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.rule.engine.api; |
|||
|
|||
import com.google.common.util.concurrent.FutureCallback; |
|||
import lombok.AccessLevel; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
import lombok.ToString; |
|||
import org.thingsboard.server.common.data.id.EntityId; |
|||
import org.thingsboard.server.common.data.id.TenantId; |
|||
import org.thingsboard.server.common.data.kv.DeleteTsKvQuery; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Getter |
|||
@ToString |
|||
@AllArgsConstructor(access = AccessLevel.PRIVATE) |
|||
public class TimeseriesDeleteRequest { |
|||
|
|||
private final TenantId tenantId; |
|||
private final EntityId entityId; |
|||
private final List<String> keys; |
|||
private final List<DeleteTsKvQuery> deleteHistoryQueries; |
|||
private final FutureCallback<List<String>> callback; |
|||
|
|||
public static Builder builder() { |
|||
return new Builder(); |
|||
} |
|||
|
|||
public static class Builder { |
|||
|
|||
private TenantId tenantId; |
|||
private EntityId entityId; |
|||
private List<String> keys; |
|||
private List<DeleteTsKvQuery> deleteHistoryQueries; |
|||
private FutureCallback<List<String>> callback; |
|||
|
|||
Builder() {} |
|||
|
|||
public Builder tenantId(TenantId tenantId) { |
|||
this.tenantId = tenantId; |
|||
return this; |
|||
} |
|||
|
|||
public Builder entityId(EntityId entityId) { |
|||
this.entityId = entityId; |
|||
return this; |
|||
} |
|||
|
|||
public Builder keys(List<String> keys) { |
|||
this.keys = keys; |
|||
return this; |
|||
} |
|||
|
|||
public Builder deleteHistoryQueries(List<DeleteTsKvQuery> deleteHistoryQueries) { |
|||
this.deleteHistoryQueries = deleteHistoryQueries; |
|||
return this; |
|||
} |
|||
|
|||
public Builder callback(FutureCallback<List<String>> callback) { |
|||
this.callback = callback; |
|||
return this; |
|||
} |
|||
|
|||
public TimeseriesDeleteRequest build() { |
|||
return new TimeseriesDeleteRequest(tenantId, entityId, keys, deleteHistoryQueries, callback); |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,131 @@ |
|||
/** |
|||
* Copyright © 2016-2024 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.rule.engine.api; |
|||
|
|||
import com.google.common.util.concurrent.FutureCallback; |
|||
import com.google.common.util.concurrent.SettableFuture; |
|||
import lombok.AccessLevel; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
import org.thingsboard.server.common.data.id.CustomerId; |
|||
import org.thingsboard.server.common.data.id.EntityId; |
|||
import org.thingsboard.server.common.data.id.TenantId; |
|||
import org.thingsboard.server.common.data.kv.BasicTsKvEntry; |
|||
import org.thingsboard.server.common.data.kv.KvEntry; |
|||
import org.thingsboard.server.common.data.kv.TsKvEntry; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Getter |
|||
@AllArgsConstructor(access = AccessLevel.PRIVATE) |
|||
public class TimeseriesSaveRequest { |
|||
|
|||
private final TenantId tenantId; |
|||
private final CustomerId customerId; |
|||
private final EntityId entityId; |
|||
private final List<TsKvEntry> entries; |
|||
private final long ttl; |
|||
private final boolean saveLatest; |
|||
private final boolean onlyLatest; |
|||
private final FutureCallback<Void> callback; |
|||
|
|||
public static Builder builder() { |
|||
return new Builder(); |
|||
} |
|||
|
|||
public static class Builder { |
|||
|
|||
private TenantId tenantId; |
|||
private CustomerId customerId; |
|||
private EntityId entityId; |
|||
private List<TsKvEntry> entries; |
|||
private long ttl; |
|||
private FutureCallback<Void> callback; |
|||
private boolean saveLatest = true; |
|||
private boolean onlyLatest; |
|||
|
|||
Builder() {} |
|||
|
|||
public Builder tenantId(TenantId tenantId) { |
|||
this.tenantId = tenantId; |
|||
return this; |
|||
} |
|||
|
|||
public Builder customerId(CustomerId customerId) { |
|||
this.customerId = customerId; |
|||
return this; |
|||
} |
|||
|
|||
public Builder entityId(EntityId entityId) { |
|||
this.entityId = entityId; |
|||
return this; |
|||
} |
|||
|
|||
public Builder entries(List<TsKvEntry> entries) { |
|||
this.entries = entries; |
|||
return this; |
|||
} |
|||
|
|||
public Builder entry(TsKvEntry entry) { |
|||
return entries(List.of(entry)); |
|||
} |
|||
|
|||
public Builder entry(KvEntry kvEntry) { |
|||
return entry(new BasicTsKvEntry(System.currentTimeMillis(), kvEntry)); |
|||
} |
|||
|
|||
public Builder ttl(long ttl) { |
|||
this.ttl = ttl; |
|||
return this; |
|||
} |
|||
|
|||
public Builder saveLatest(boolean saveLatest) { |
|||
this.saveLatest = saveLatest; |
|||
return this; |
|||
} |
|||
|
|||
public Builder onlyLatest(boolean onlyLatest) { |
|||
this.onlyLatest = onlyLatest; |
|||
this.saveLatest = true; |
|||
return this; |
|||
} |
|||
|
|||
public Builder callback(FutureCallback<Void> callback) { |
|||
this.callback = callback; |
|||
return this; |
|||
} |
|||
|
|||
public Builder future(SettableFuture<Void> future) { |
|||
return callback(new FutureCallback<>() { |
|||
@Override |
|||
public void onSuccess(Void result) { |
|||
future.set(result); |
|||
} |
|||
|
|||
@Override |
|||
public void onFailure(Throwable t) { |
|||
future.setException(t); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
public TimeseriesSaveRequest build() { |
|||
return new TimeseriesSaveRequest(tenantId, customerId, entityId, entries, ttl, saveLatest, onlyLatest, callback); |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||