proj_name stringclasses 131
values | relative_path stringlengths 30 228 | class_name stringlengths 1 68 | func_name stringlengths 1 48 | masked_class stringlengths 78 9.82k | func_body stringlengths 46 9.61k | len_input int64 29 2.01k | len_output int64 14 1.94k | total int64 55 2.05k | relevant_context stringlengths 0 38.4k |
|---|---|---|---|---|---|---|---|---|---|
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/notify-component/notify-sms/src/main/java/org/jetlinks/community/notify/sms/aliyun/web/AliyunSmsController.java | AliyunSmsController | getAliyunSmsTemplates | class AliyunSmsController {
private final NotifierManager notifierManager;
@GetMapping("/{configId}/signs")
@QueryAction
@Operation(summary = "获取短信标签列表")
public Flux<SmsSign> getAliyunSmsSigns(@PathVariable String configId) {
return notifierManager
.getNotifier(DefaultNotifyTy... |
return notifierManager
.getNotifier(DefaultNotifyType.sms, configId)
.filter(notifier -> notifier.isWrapperFor(AliyunSmsNotifier.class))
.map(notifier -> notifier.unwrap(AliyunSmsNotifier.class))
.flatMapMany(AliyunSmsNotifier::getSmsTemplates);
| 258 | 100 | 358 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/notify-component/notify-voice/src/main/java/org/jetlinks/community/notify/voice/aliyun/AliyunVoiceNotifier.java | AliyunVoiceNotifier | handleRequest | class AliyunVoiceNotifier extends AbstractNotifier<AliyunVoiceTemplate> {
private final IAcsClient client;
private final int connectTimeout = 1000;
private final int readTimeout = 5000;
@Getter
private String notifierId;
private String domain = "dyvmsapi.aliyuncs.com";
private String regi... |
try {
CommonResponse response = client.getCommonResponse(request);
if (response == null) {
throw new BusinessException("error.unsupported_voice_notification_type");
}
log.info("发起语音通知完成 {}:{}", response.getHttpResponse().getStatus(), response.ge... | 1,204 | 178 | 1,382 | <methods>public non-sealed void <init>() ,public Mono<java.lang.Void> send(java.lang.String, org.jetlinks.core.Values) <variables>private final non-sealed org.jetlinks.community.notify.template.TemplateManager templateManager |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/notify-component/notify-voice/src/main/java/org/jetlinks/community/notify/voice/aliyun/AliyunVoiceTemplate.java | AliyunVoiceTemplate | getEmbeddedVariables | class AliyunVoiceTemplate extends AbstractTemplate<AliyunVoiceTemplate> {
public static final String CALLED_NUMBER_KEY = "calledNumber";
@Schema(description = "通知模版ID")
@NotBlank(message = "[ttsCode]不能为空")
@Deprecated
private String ttsCode;
@Schema(description = "通知模版ID")
private String t... |
//指定了固定的收信人
if (StringUtils.hasText(calledNumber)) {
return Collections.emptyList();
}
return Collections.singletonList(
VariableDefinition
.builder()
.id(CALLED_NUMBER_KEY)
.name("被叫号码")
.descriptio... | 469 | 141 | 610 | <methods>public void <init>() ,public final Optional<org.jetlinks.community.notify.template.VariableDefinition> getVariable(java.lang.String) ,public final Map<java.lang.String,org.jetlinks.community.notify.template.VariableDefinition> getVariables() ,public Map<java.lang.String,java.lang.Object> toMap() ,public org.je... |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/notify-component/notify-webhook/src/main/java/org/jetlinks/community/notify/webhook/http/HttpWebHookNotifier.java | HttpWebHookNotifier | send | class HttpWebHookNotifier extends AbstractNotifier<HttpWebHookTemplate> {
private final String id;
private final WebClient webClient;
private final HttpWebHookProperties properties;
public HttpWebHookNotifier(String id,
HttpWebHookProperties properties,
... |
HttpMethod method = template.getMethod();
WebClient.RequestBodyUriSpec bodyUriSpec = webClient
.method(template.getMethod());
if (StringUtils.hasText(template.getUrl())) {
bodyUriSpec.uri(template.getUrl());
}
if (method == HttpMethod.POST
||... | 292 | 297 | 589 | <methods>public non-sealed void <init>() ,public Mono<java.lang.Void> send(java.lang.String, org.jetlinks.core.Values) <variables>private final non-sealed org.jetlinks.community.notify.template.TemplateManager templateManager |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/notify-component/notify-webhook/src/main/java/org/jetlinks/community/notify/webhook/http/HttpWebHookNotifierProvider.java | HttpWebHookNotifierProvider | createNotifier | class HttpWebHookNotifierProvider implements NotifierProvider, TemplateProvider {
private final TemplateManager templateManager;
private final WebClient.Builder builder;
@Nonnull
@Override
public NotifyType getType() {
return DefaultNotifyType.webhook;
}
@Nonnull
@Override
... |
HttpWebHookProperties hookProperties = FastBeanCopier.copy(properties.getConfiguration(),new HttpWebHookProperties());
ValidatorUtils.tryValidate(hookProperties);
WebClient.Builder client = builder.clone();
client.baseUrl(hookProperties.getUrl());
return Mono.just(new HttpWe... | 211 | 122 | 333 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/notify-component/notify-webhook/src/main/java/org/jetlinks/community/notify/webhook/http/HttpWebHookTemplate.java | HttpWebHookTemplate | resolveBody | class HttpWebHookTemplate extends AbstractTemplate<HttpWebHookTemplate> {
@Schema(description = "请求地址")
private String url = "";
@Schema(description = "请求头")
private List<HttpWebHookProperties.Header> headers;
@Schema(description = "请求方式,默认POST")
private HttpMethod method = HttpMethod.POST;
... |
//字符串,支持变量:${var}
if (val instanceof String) {
return render(String.valueOf(val), context);
}
if (val instanceof Map) {
return resolveBody(((Map<?, ?>) val), context);
}
if (val instanceof List) {
return resolveBody(((List<?>) val), co... | 610 | 106 | 716 | <methods>public void <init>() ,public final Optional<org.jetlinks.community.notify.template.VariableDefinition> getVariable(java.lang.String) ,public final Map<java.lang.String,org.jetlinks.community.notify.template.VariableDefinition> getVariables() ,public Map<java.lang.String,java.lang.Object> toMap() ,public org.je... |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/notify-component/notify-wechat/src/main/java/org/jetlinks/community/notify/wechat/corp/WechatCorpNotifier.java | WechatCorpNotifier | execute | class WechatCorpNotifier extends AbstractNotifier<WechatMessageTemplate> implements CommandSupport, ExchangeFilterFunction {
private final WebClient apiClient;
private final WechatCorpProperties properties;
@Getter
private final String notifierId;
private volatile Mono<String> token;
public... |
if (command instanceof ApiRequest) {
return (R) ((ApiRequest<?>) command).execute(apiClient);
}
throw new UnsupportedOperationException();
| 894 | 46 | 940 | <methods>public non-sealed void <init>() ,public Mono<java.lang.Void> send(java.lang.String, org.jetlinks.core.Values) <variables>private final non-sealed org.jetlinks.community.notify.template.TemplateManager templateManager |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/notify-component/notify-wechat/src/main/java/org/jetlinks/community/notify/wechat/corp/WechatMessageTemplate.java | WechatMessageTemplate | getToUser | class WechatMessageTemplate extends AbstractTemplate<WechatMessageTemplate> {
public static final String TO_USER_KEY = "toUser";
public static final String TO_PARTY_KEY = "toParty";
public static final String TO_TAG_KEY = "toTag";
/**
* 应用ID
*/
@NotBlank(message = "[agentId]不能为空")
pr... |
return VariableSource
.resolveValue(TO_USER_KEY, context, relationPropertyPath)
.map(String::valueOf)
.filter(StringUtils::hasText)
.defaultIfEmpty(toUser == null ? "" : toUser)
.collect(Collectors.joining(","));
| 1,515 | 78 | 1,593 | <methods>public void <init>() ,public final Optional<org.jetlinks.community.notify.template.VariableDefinition> getVariable(java.lang.String) ,public final Map<java.lang.String,org.jetlinks.community.notify.template.VariableDefinition> getVariables() ,public Map<java.lang.String,java.lang.Object> toMap() ,public org.je... |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/notify-component/notify-wechat/src/main/java/org/jetlinks/community/notify/wechat/corp/WechatNotifierProvider.java | WechatNotifierProvider | createNotifier | class WechatNotifierProvider implements NotifierProvider, TemplateProvider {
private final WebClient.Builder clientBuilder;
private final TemplateManager templateManager;
public WechatNotifierProvider(TemplateManager templateManager, WebClient.Builder builder) {
this.templateManager = templateMa... |
return Mono.defer(() -> {
WechatCorpProperties wechatCorpProperties = FastBeanCopier.copy(properties.getConfiguration(), new WechatCorpProperties());
return Mono.just(new WechatCorpNotifier(properties.getId(), clientBuilder, ValidatorUtils.tryValidate(wechatCorpProperties), templateMana... | 554 | 102 | 656 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/notify-component/notify-wechat/src/main/java/org/jetlinks/community/notify/wechat/corp/request/AccessTokenRequest.java | AccessTokenRequest | execute | class AccessTokenRequest extends ApiRequest<AccessTokenResponse> {
private final String corpId;
private final String corpSecret;
@Override
public Mono<AccessTokenResponse> execute(WebClient client) {<FILL_FUNCTION_BODY>}
} |
return client
.get()
.uri("/cgi-bin/gettoken", uriBuilder -> uriBuilder
.queryParam("corpid", corpId)
.queryParam("corpsecret", corpSecret)
.build())
.retrieve()
.bodyToMono(AccessTokenResponse.class)
.d... | 67 | 95 | 162 | <methods>public non-sealed void <init>() ,public abstract Mono<org.jetlinks.community.notify.wechat.corp.response.AccessTokenResponse> execute(org.springframework.web.reactive.function.client.WebClient) <variables> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/notify-component/notify-wechat/src/main/java/org/jetlinks/community/notify/wechat/corp/request/GetUserDetailRequest.java | GetUserDetailRequest | execute | class GetUserDetailRequest extends ApiRequest<GetUserDetailResponse> {
private final String userId;
@Override
public Mono<GetUserDetailResponse> execute(WebClient client) {<FILL_FUNCTION_BODY>}
} |
return client
.get()
.uri("/cgi-bin/user/get", builder -> builder
.queryParam("userid", userId)
.build())
.retrieve()
.bodyToMono(GetUserDetailResponse.class)
.doOnNext(ApiResponse::assertSuccess);
| 63 | 81 | 144 | <methods>public non-sealed void <init>() ,public abstract Mono<org.jetlinks.community.notify.wechat.corp.response.GetUserDetailResponse> execute(org.springframework.web.reactive.function.client.WebClient) <variables> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/notify-component/notify-wechat/src/main/java/org/jetlinks/community/notify/wechat/corp/request/GetUserInfoRequest.java | GetUserInfoRequest | execute | class GetUserInfoRequest extends ApiRequest<GetUserInfoResponse> {
private final String code;
@Override
public Mono<GetUserInfoResponse> execute(WebClient client) {<FILL_FUNCTION_BODY>}
} |
return client
.get()
.uri("/cgi-bin/auth/getuserinfo", builder -> builder
.queryParam("code", code)
.build())
.retrieve()
.bodyToMono(GetUserInfoResponse.class)
.doOnNext(ApiResponse::assertSuccess);
| 62 | 81 | 143 | <methods>public non-sealed void <init>() ,public abstract Mono<org.jetlinks.community.notify.wechat.corp.response.GetUserInfoResponse> execute(org.springframework.web.reactive.function.client.WebClient) <variables> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/notify-component/notify-wechat/src/main/java/org/jetlinks/community/notify/wechat/corp/request/GetUserRequest.java | GetUserRequest | execute | class GetUserRequest extends ApiRequest<GetUserResponse> {
private final String departmentId;
private final boolean fetchChild;
@Override
public Mono<GetUserResponse> execute(WebClient client) {<FILL_FUNCTION_BODY>}
} |
return client
.post()
.uri("/cgi-bin/user/list", builder -> builder
.queryParam("department_id", departmentId)
.queryParam("fetch_child", fetchChild ? "1" : 0)
.build())
.retrieve()
.bodyToMono(GetUserResponse.class... | 68 | 103 | 171 | <methods>public non-sealed void <init>() ,public abstract Mono<org.jetlinks.community.notify.wechat.corp.response.GetUserResponse> execute(org.springframework.web.reactive.function.client.WebClient) <variables> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/notify-component/notify-wechat/src/main/java/org/jetlinks/community/notify/wechat/corp/response/ApiResponse.java | ApiResponse | assertSuccess | class ApiResponse {
@JsonProperty
@JsonAlias("errcode")
private int errorCode;
@JsonProperty
@JsonAlias("errmsg")
private String errorMessage;
public boolean isSuccess() {
return errorCode == 0;
}
public void assertSuccess() {<FILL_FUNCTION_BODY>}
} |
if (!isSuccess()) {
throw new BusinessException("error.qy_wx_request_error", 500, errorMessage);
}
| 95 | 40 | 135 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/notify-component/notify-wechat/src/main/java/org/jetlinks/community/notify/wechat/corp/response/GetTagResponse.java | GetTagResponse | getTagList | class GetTagResponse extends ApiResponse {
@JsonProperty
@JsonAlias("taglist")
private List<CorpTag> tagList;
public List<CorpTag> getTagList() {<FILL_FUNCTION_BODY>}
} |
if (tagList == null) {
return Collections.emptyList();
}
return tagList;
| 67 | 31 | 98 | <methods>public non-sealed void <init>() ,public void assertSuccess() ,public boolean isSuccess() <variables>private int errorCode,private java.lang.String errorMessage |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/notify-component/notify-wechat/src/main/java/org/jetlinks/community/notify/wechat/corp/response/GetUserDetailResponse.java | GetUserDetailResponse | getUnionId | class GetUserDetailResponse extends ApiResponse {
@JsonProperty
@JsonAlias("userid")
private String id;
@JsonProperty
private String name;
@JsonProperty
private String alias;
@JsonProperty
private List<String> department;
@JsonProperty
@JsonAlias("main_department")
p... |
if (StringUtils.hasText(mainDepartment)) {
return mainDepartment;
}
if (CollectionUtils.isEmpty(department)) {
return null;
}
return String.join(",", department);
| 238 | 61 | 299 | <methods>public non-sealed void <init>() ,public void assertSuccess() ,public boolean isSuccess() <variables>private int errorCode,private java.lang.String errorMessage |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/notify-component/notify-wechat/src/main/java/org/jetlinks/community/notify/wechat/web/WechatCoreNotifierController.java | WechatCoreNotifierController | getOauth2UserBindCode | class WechatCoreNotifierController {
private final NotifierManager notifierManager;
private final NotifyConfigManager notifyConfigManager;
private final UserBindService userBindService;
private final TemplateManager templateManager;
@GetMapping("/{configId}/tags")
@Operation(summary = "获取微信... |
return Authentication
.currentReactive()
.switchIfEmpty(Mono.error(UnAuthorizedException::new))
.flatMap(authentication -> notifierManager
.getNotifier(DefaultNotifyType.weixin, configId)
.map(notifier -> notifier.unwrap(WechatCorpNotifier.cla... | 1,308 | 236 | 1,544 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/protocol-component/src/main/java/org/jetlinks/community/protocol/AutoDownloadJarProtocolSupportLoader.java | AutoDownloadJarProtocolSupportLoader | load | class AutoDownloadJarProtocolSupportLoader extends JarProtocolSupportLoader {
final WebClient webClient;
final File tempPath;
private final Duration loadTimeout = TimeUtils.parse(System.getProperty("jetlinks.protocol.load.timeout", "30s"));
private final FileManager fileManager;
public AutoDown... |
//复制新的配置信息
ProtocolSupportDefinition newDef = FastBeanCopier.copy(definition, new ProtocolSupportDefinition());
Map<String, Object> config = newDef.getConfiguration();
String location = Optional
.ofNullable(config.get("location"))
.map(String::valueOf)
... | 449 | 697 | 1,146 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/protocol-component/src/main/java/org/jetlinks/community/protocol/ProtocolDetail.java | ProtocolDetail | of | class ProtocolDetail {
@Schema(description = "协议ID")
private String id;
@Schema(description = "协议名称")
private String name;
@Schema(description = "协议说明")
private String description;
private List<TransportDetail> transports;
public static Mono<ProtocolDetail> of(ProtocolSupport support... |
return support
.getSupportedTransport()
.flatMap(trans -> TransportDetail.of(support, trans))
.collectList()
.map(details -> new ProtocolDetail(support.getId(), support.getName(),support.getDescription(), details));
| 104 | 68 | 172 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/protocol-component/src/main/java/org/jetlinks/community/protocol/SpringProtocolSupportLoader.java | SpringProtocolSupportLoader | load | class SpringProtocolSupportLoader implements ProtocolSupportLoader {
private final Map<String, ProtocolSupportLoaderProvider> providers = new ConcurrentHashMap<>();
private final EventBus eventBus;
public void register(ProtocolSupportLoaderProvider provider) {
this.providers.put(provider.getProvi... |
return Mono
.justOrEmpty(this.providers.get(definition.getProvider()))
.switchIfEmpty(Mono.error(() -> new UnsupportedOperationException("unsupported provider:" + definition.getProvider())))
.flatMap((provider) -> provider.load(definition))
.map(loaded -> new Ren... | 119 | 106 | 225 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/protocol-component/src/main/java/org/jetlinks/community/protocol/SpringServiceContext.java | SpringServiceContext | getService | class SpringServiceContext implements ServiceContext {
private final ApplicationContext applicationContext;
public SpringServiceContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}
@Override
public Optional<Value> getConfig(ConfigKey<String> key... |
try {
return Optional.of(applicationContext.getBean(service));
} catch (Exception e) {
log.error("load service [{}] error", service, e);
return Optional.empty();
}
| 383 | 58 | 441 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/protocol-component/src/main/java/org/jetlinks/community/protocol/TransportDetail.java | TransportDetail | of | class TransportDetail {
@Schema(description = "ID")
private String id;
@Schema(description = "名称")
private String name;
@Schema(description = "其他设置")
private List<ProtocolFeature> features;
@Schema(description = "路由信息")
private List<Route> routes;
@Schema(description = "文档信息")
... |
return Mono
.zip(
support
//T1: 路由信息
.getRoutes(transport)
.collectList(),
support
//T2: 协议特性
.getFeatures(transport)
.map(ProtocolFeature::of)
... | 158 | 199 | 357 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/protocol-component/src/main/java/org/jetlinks/community/protocol/configuration/LazyProtocolSupports.java | LazyProtocolSupports | postProcessAfterInitialization | class LazyProtocolSupports extends CompositeProtocolSupports implements BeanPostProcessor {
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {<FILL_FUNCTION_BODY>}
} |
if(bean instanceof ProtocolSupports){
register(((ProtocolSupports) bean));
}
return BeanPostProcessor.super.postProcessAfterInitialization(bean, beanName);
| 60 | 50 | 110 | <methods>public void <init>() ,public Mono<org.jetlinks.core.ProtocolSupport> getProtocol(java.lang.String) ,public Flux<org.jetlinks.core.ProtocolSupport> getProtocols() ,public boolean isSupport(java.lang.String) ,public void register(org.jetlinks.core.ProtocolSupports) <variables>private final List<org.jetlinks.core... |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/protocol-component/src/main/java/org/jetlinks/community/protocol/configuration/ProtocolAutoConfiguration.java | ProtocolAutoConfiguration | inSpringProtocolSupports | class ProtocolAutoConfiguration {
// @Bean
// public ProtocolSupportManager protocolSupportManager(ClusterManager clusterManager) {
// return new ClusterProtocolSupportManager(clusterManager);
// }
@Bean
public ServiceContext serviceContext(ApplicationContext applicationContext) {
retu... |
StaticProtocolSupports protocolSupports = new StaticProtocolSupports();
for (ProtocolSupport protocol : supports) {
protocolSupports.register(
new RenameProtocolSupport(
protocol.getId(),
protocol.getName(),
protoco... | 402 | 91 | 493 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/protocol-component/src/main/java/org/jetlinks/community/protocol/local/LocalProtocolSupportLoader.java | LocalProtocolSupportLoader | load | class LocalProtocolSupportLoader implements ProtocolSupportLoaderProvider {
private final ServiceContext serviceContext;
@Override
public String getProvider() {
return "local";
}
@Override
public Mono<LocalFileProtocolSupport> load(ProtocolSupportDefinition definition) {<FILL_FUNCTION... |
return Mono
.fromCallable(() -> {
ValueObject config = ValueObject.of(definition.getConfiguration());
String location = config
.getString("location")
.orElseThrow(() -> new IllegalArgumentException("location cannot be null"))... | 83 | 199 | 282 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/relation-component/src/main/java/org/jetlinks/community/relation/RelationManagerInitializer.java | RelationManagerInitializer | dispose | class RelationManagerInitializer implements Disposable {
private final RelationManager temp;
private final RelationManager target;
public RelationManagerInitializer(RelationManager manager) {
temp = RelationManagerHolder.hold;
target = manager;
RelationManagerHolder.hold = manager;... |
if (RelationManagerHolder.hold == target) {
RelationManagerHolder.hold = temp;
}
| 105 | 31 | 136 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/relation-component/src/main/java/org/jetlinks/community/relation/configuration/RelationConfiguration.java | RelationConfiguration | relationManager | class RelationConfiguration {
@Bean
@ConditionalOnMissingBean(RelationManager.class)
public RelationManager relationManager(ReactiveRepository<RelatedEntity, String> relatedRepository,
ReactiveRepository<RelationEntity, String> relationRepository,
... |
DefaultRelationManager manager = new DefaultRelationManager(relatedRepository, relationRepository);
objectProvider.forEach(manager::addProvider);
return manager;
| 132 | 40 | 172 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/relation-component/src/main/java/org/jetlinks/community/relation/entity/RelatedEntity.java | RelatedEntity | getRelatedKey | class RelatedEntity extends GenericEntity<String> {
@Schema(description = "对象类型",accessMode = Schema.AccessMode.READ_ONLY)
@Column(length = 32, nullable = false, updatable = false)
@NotBlank(groups = CreateGroup.class)
private String objectType;
@Schema(description = "对象ID",accessMode = Schema.Acc... |
if (!StringUtils.hasText(relatedKey)
&& StringUtils.hasText(relatedType)
&& StringUtils.hasText(relatedId)) {
relatedKey = generateKey(relatedType, relatedId);
}
return relatedKey;
| 877 | 64 | 941 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/relation-component/src/main/java/org/jetlinks/community/relation/entity/RelationEntity.java | RelationEntity | getId | class RelationEntity extends GenericEntity<String> {
@Schema(description = "对象类型")
@Column(length = 32, nullable = false, updatable = false)
private String objectType;
@Schema(description = "对象名称")
@Column(length = 64, nullable = false)
private String objectTypeName;
@Schema(description =... |
if (StringUtils.hasText(super.getId())) {
return super.getId();
}
if (StringUtils.hasText(objectType) &&
StringUtils.hasText(relation) &&
StringUtils.hasText(targetType)) {
generateId();
}
return super.getId();
| 576 | 80 | 656 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/relation-component/src/main/java/org/jetlinks/community/relation/impl/CompositeObjectType.java | CompositeObjectType | getExpands | class CompositeObjectType implements ObjectType {
private final ObjectType main;
private final ObjectType second;
@Override
public List<PropertyMetadata> getProperties() {
return Stream
.concat(main.getProperties().stream(), second.getProperties().stream())
.collect(Coll... |
Map<String, Object> expands = new HashMap<>();
if (MapUtils.isNotEmpty(main.getExpands())) {
expands.putAll(main.getExpands());
}
if (MapUtils.isNotEmpty(second.getExpands())) {
expands.putAll(second.getExpands());
}
return expands;
| 350 | 95 | 445 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/relation-component/src/main/java/org/jetlinks/community/relation/impl/DefaultRelationManager.java | DefaultRelationManager | getObjectType | class DefaultRelationManager implements RelationManager {
private final ReactiveRepository<RelatedEntity, String> relatedRepository;
private final ReactiveRepository<RelationEntity, String> relationRepository;
protected final Map<String, RelationObjectProvider> providers = new ConcurrentHashMap<>();
... |
RelationObjectProvider provider = getProvider(typeId);
return provider
.getType()
.flatMap(type -> relationRepository
.createQuery()
.where(RelationEntity::getObjectType, typeId)
.fetch()
.collect(Collectors.groupi... | 436 | 214 | 650 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/relation-component/src/main/java/org/jetlinks/community/relation/impl/DefaultRelationOperation.java | DefaultRelationOperation | get | class DefaultRelationOperation implements RelationOperation {
final String type;
final String id;
final ReactiveRepository<RelatedEntity, String> relatedRepository;
final Function<String, RelationObjectProvider> objectProvider;
final boolean reverse;
@Override
public Flux<RelatedObject> sav... |
return relatedRepository
.createQuery()
.where(reverse ? RelatedEntity::getRelatedKey : RelatedEntity::getObjectKey, RelatedEntity.generateKey(this.type, this.id))
.and(RelatedEntity::getRelation, relation)
.when(CollectionUtils.isNotEmpty(targetId),
... | 479 | 159 | 638 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/relation-component/src/main/java/org/jetlinks/community/relation/impl/SimpleObjectType.java | SimpleObjectType | withRelation | class SimpleObjectType implements ObjectType, Externalizable {
private String id;
private String name;
private String description;
private Map<String, Object> expands;
private Map<String, List<Relation>> relations;
private List<ObjectType> relatedTypes;
private List<PropertyMetadata> proper... |
if (relations == null) {
relations = new HashMap<>();
}
relations.computeIfAbsent(type, (ignore) -> new ArrayList<>())
.addAll(relation);
return this;
| 983 | 57 | 1,040 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/relation-component/src/main/java/org/jetlinks/community/relation/impl/SimpleRelation.java | SimpleRelation | readExternal | class SimpleRelation implements Relation , Externalizable {
private String id;
private String name;
private Map<String,Object> expands;
public static SimpleRelation of(RelationEntity entity){
return of(entity.getId(),entity.getName(),entity.getExpands());
}
@Override
public void w... |
id = in.readUTF();
name = in.readUTF();
expands = (Map<String,Object>)SerializeUtils.readObject(in);
| 177 | 43 | 220 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/relation-component/src/main/java/org/jetlinks/community/relation/impl/property/CompositePropertyOperation.java | CompositePropertyOperation | getStrategy | class CompositePropertyOperation implements PropertyOperationStrategy {
private final List<PropertyOperationStrategy> strategies;
@Override
public boolean isSupported(String key) {
return getStrategy(key) != null;
}
private PropertyOperationStrategy getStrategy(String key) {<FILL_FUNCTION... |
for (PropertyOperationStrategy strategy : strategies) {
if (strategy.isSupported(key)) {
return strategy;
}
}
return null;
| 150 | 45 | 195 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/relation-component/src/main/java/org/jetlinks/community/relation/impl/property/DetectPropertyOperationStrategy.java | DetectPropertyOperationStrategy | get | class DetectPropertyOperationStrategy implements PropertyOperationStrategy {
private final Map<String, PropertyOperation> mappers = new ConcurrentHashMap<>();
public DetectPropertyOperationStrategy addOperation(String key,
PropertyOperation operation) {
... |
String[] detect = detect(key);
if (detect == null || detect.length == 0) {
return Mono.empty();
}
PropertyOperation operation = mappers.get(detect[0]);
if (null == operation) {
return Mono.empty();
}
String relKey;
if (detect.lengt... | 194 | 131 | 325 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/relation-component/src/main/java/org/jetlinks/community/relation/impl/property/SimplePropertyOperation.java | SimplePropertyOperation | get | class SimplePropertyOperation<O> implements PropertyOperationStrategy {
private final Map<String, Function<O, ?>> mappers = new HashMap<>();
private final Mono<O> supplier;
public SimplePropertyOperation(Mono<O> supplier) {
this.supplier = supplier;
}
@Override
public boolean isSuppo... |
Function<O, ?> mapper = mappers.get(key);
if (mapper == null) {
return Mono.empty();
}
return supplier
.flatMap((obj) -> {
Object val = mapper.apply(obj);
if (val instanceof Publisher) {
return Mono.from(((Publi... | 312 | 115 | 427 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/relation-component/src/main/java/org/jetlinks/community/relation/service/RelationDataReferenceProvider.java | RelationDataReferenceProvider | getReferences | class RelationDataReferenceProvider implements DataReferenceProvider {
private final ReactiveRepository<RelatedEntity, String> reletedRepository;
public RelationDataReferenceProvider(ReactiveRepository<RelatedEntity, String> reletedRepository) {
this.reletedRepository = reletedRepository;
}
@... |
return reletedRepository
.createQuery()
.where()
.notNull(RelatedEntity::getRelation)
.fetch()
.map(e -> DataReferenceInfo.of(e.getId(), getId(), e.getRelation(), e.getRelatedName()));
| 221 | 71 | 292 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/relation-component/src/main/java/org/jetlinks/community/relation/service/RelationService.java | RelationService | saveRelated | class RelationService extends GenericReactiveCrudService<RelationEntity, String> {
private final ReactiveRepository<RelatedEntity, String> relatedRepository;
public Flux<RelatedInfo> getRelationInfo(String type, Collection<String> idList) {
return Mono
.zip(
//关系定义
... |
return requestFlux
.groupBy(request -> Tuples.of(request.getRelatedType(), request.getRelation()))
.flatMap(group -> relatedRepository
.createDelete()
.where(RelatedEntity::getObjectKey, RelatedEntity.generateKey(type, id))
.and(RelatedEn... | 722 | 232 | 954 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/relation-component/src/main/java/org/jetlinks/community/relation/terms/RelatedTermBuilder.java | RelatedTermBuilder | createFragments | class RelatedTermBuilder extends AbstractTermFragmentBuilder {
public RelatedTermBuilder() {
super("relation", "按关系信息查询");
}
@Override
public SqlFragments createFragments(String columnFullName, RDBColumnMetadata column, Term term) {<FILL_FUNCTION_BODY>}
protected PrepareSqlFragments accep... |
ObjectSpec spec = convertSpec(term);
PrepareSqlFragments outside = PrepareSqlFragments.of();
PrepareSqlFragments fragments= acceptRelation(PrepareSqlFragments.of(), spec.getRelated(), 1, (last, index, frag) -> {
String tName = "r" + index;
String preName = "r" + (ind... | 638 | 636 | 1,274 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/relation-component/src/main/java/org/jetlinks/community/relation/utils/VariableObjectSpec.java | VariableObjectSpec | init | class VariableObjectSpec extends ObjectSpec {
/**
* 对象变量来源,通过此来源来指定对象ID.
* <p>
* 此变量仅支持 fixed(固定值)和upper(来自上游)类型
*/
private VariableSource objectSource;
public void init(Map<String, Object> context) {<FILL_FUNCTION_BODY>}
public void validate() {
Assert.hasText(getObjectTy... |
if (objectSource != null) {
switch (objectSource.getSource()) {
case fixed:
setObjectId((String) objectSource.getValue());
case upper:
DefaultPropertyFeature.GLOBAL
.getProperty(objectSource.getUpperKey(... | 350 | 101 | 451 | <methods>public void <init>() ,public java.lang.String getObjectId() ,public java.lang.String getObjectType() ,public org.jetlinks.core.things.relation.RelationSpec getRelated() ,public static org.jetlinks.core.things.relation.ObjectSpec parse(java.lang.String) ,public void setObjectId(java.lang.String) ,public void se... |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/relation-component/src/main/java/org/jetlinks/community/relation/utils/VariableSource.java | VariableSource | wrap | class VariableSource implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "来源")
private Source source;
@Schema(description = "固定值,[source]为[fixed]时不能为空")
private Object value;
@Schema(description = "上游key,[source]为[upper]时不能为空")
private String u... |
Map<String, Object> vars = Maps.newLinkedHashMapWithExpectedSize(def.size());
for (Map.Entry<String, Object> entry : def.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (value instanceof Collection) {
List<VariableSourc... | 1,838 | 182 | 2,020 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/relation-component/src/main/java/org/jetlinks/community/relation/web/RelationController.java | ObjectTypeInfo | of | class ObjectTypeInfo {
@Schema(description = "类型ID")
private String id;
@Schema(description = "名称")
private String name;
@Schema(description = "说明")
private String description;
@Schema(description = "可建立关系的其他类型ID")
private List<String> relatable;
... |
ObjectTypeInfo info = new ObjectTypeInfo();
info.setId(type.getId());
info.setName(type.getName());
info.setDescription(type.getDescription());
info.setRelatable(relatable);
return info;
| 122 | 65 | 187 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/rule-engine-component/src/main/java/org/jetlinks/community/rule/engine/commons/ShakeLimit.java | ShakeLimit | transfer | class ShakeLimit implements Serializable {
private static final long serialVersionUID = -6849794470754667710L;
@Schema(description = "是否开启防抖")
private boolean enabled;
//时间限制,单位时间内发生多次告警时,只算一次。单位:秒
@Schema(description = "时间间隔(秒)")
private int time;
//触发阈值,单位时间内发生n次告警,只算一次。
@Schema(des... |
if (!enabled || time <= 0) {
return source;
}
int thresholdNumber = getThreshold();
Duration windowTime = Duration.ofSeconds(getTime());
return source
.as(flux -> windowFunction.apply(windowTime, flux))
//处理每一组数据
.flatMap(group ->... | 700 | 242 | 942 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/rule-engine-component/src/main/java/org/jetlinks/community/rule/engine/commons/TermsConditionEvaluator.java | TermsConditionEvaluator | createCondition | class TermsConditionEvaluator implements ConditionEvaluatorStrategy {
public static final String TYPE = "terms";
public static Condition createCondition(List<Term> terms) {<FILL_FUNCTION_BODY>}
@Override
public String getType() {
return TYPE;
}
@Override
public boolean evaluate(Co... |
Condition condition = new Condition();
condition.setType(TYPE);
condition.setConfiguration(Collections.singletonMap("terms", terms));
return condition;
| 310 | 42 | 352 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/rule-engine-component/src/main/java/org/jetlinks/community/rule/engine/configuration/RuleEngineConfiguration.java | RuleEngineConfiguration | autoRegisterStrategy | class RuleEngineConfiguration {
@Bean
public DefaultRuleModelParser defaultRuleModelParser() {
return new DefaultRuleModelParser();
}
@Bean
public DefaultConditionEvaluator defaultConditionEvaluator() {
return new DefaultConditionEvaluator();
}
@Bean
public TermsCondit... |
return new BeanPostProcessor() {
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String ... | 426 | 182 | 608 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/rule-engine-component/src/main/java/org/jetlinks/community/rule/engine/entity/RuleEngineExecuteEventInfo.java | RuleEngineExecuteEventInfo | of | class RuleEngineExecuteEventInfo {
private String id;
private String event;
private long createTime = System.currentTimeMillis();
private String instanceId;
private String nodeId;
private String ruleData;
private String contextId;
public static RuleEngineExecuteEventInfo of(TopicP... |
Map<String, String> vars = message.getTopicVars("/rule-engine/{instanceId}/{nodeId}/event/{event}");
RuleEngineExecuteEventInfo info = FastBeanCopier.copy(vars, new RuleEngineExecuteEventInfo());
JSONObject json = message.bodyToJson();
info.id=json.getString("id");
info.contextI... | 101 | 121 | 222 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/rule-engine-component/src/main/java/org/jetlinks/community/rule/engine/event/handler/RuleLogHandler.java | RuleLogHandler | handleLog | class RuleLogHandler {
@Autowired
private ElasticSearchService elasticSearchService;
@Subscribe("/rule-engine/*/*/event/${rule.engine.event.level:error}")
public Mono<Void> handleEvent(TopicPayload event) {
return elasticSearchService.commit(RuleEngineLoggerIndexProvider.RULE_EVENT_LOG, RuleEn... |
JSONObject jsonObject = FastBeanCopier.copy(event, new JSONObject());
jsonObject.put("createTime", System.currentTimeMillis());
return elasticSearchService.commit(RuleEngineLoggerIndexProvider.RULE_LOG, jsonObject);
| 169 | 64 | 233 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/rule-engine-component/src/main/java/org/jetlinks/community/rule/engine/executor/DataMappingTaskExecutorProvider.java | Mapping | getTypeClass | class Mapping {
private String target;
private String source;
private String type;
private transient Class typeClass;
public Mapping() {
}
public Mapping(String target, String source) {
this.target = target;
this.source = source;
... |
if (typeClass == null && type != null) {
String lowerType = type.toLowerCase();
switch (lowerType) {
case "int":
case "integer":
return typeClass = Integer.class;
case "string":
... | 289 | 193 | 482 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/rule-engine-component/src/main/java/org/jetlinks/community/rule/engine/executor/DelayTaskExecutorProvider.java | DelayTaskExecutor | doStart | class DelayTaskExecutor extends AbstractTaskExecutor {
private DelayTaskExecutorConfig config;
private final Scheduler scheduler;
public DelayTaskExecutor(ExecutionContext context, Scheduler scheduler) {
super(context);
this.scheduler = scheduler;
init();
... |
if (this.disposable != null) {
this.disposable.dispose();
}
return config
.create(context.getInput().accept(), context, scheduler)
.map(context::newRuleData)
.flatMap(ruleData ->
context
... | 188 | 140 | 328 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/rule-engine-component/src/main/java/org/jetlinks/community/rule/engine/executor/DeviceMessageSendTaskExecutorProvider.java | DeviceMessageSendTaskExecutor | apply | class DeviceMessageSendTaskExecutor extends FunctionTaskExecutor {
private DeviceMessageSendConfig config;
private Function<Map<String, Object>, Flux<DeviceOperator>> selector;
public DeviceMessageSendTaskExecutor(ExecutionContext context) {
super("发送设备消息", context);
r... |
Map<String, Object> ctx = RuleDataHelper.toContextMap(input);
Flux<DeviceOperator> readySendDevice =
"ignoreOffline".equals(config.getStateOperator())
? selectDevice(ctx).filterWhen(DeviceOperator::isOnline)
: selectDevice(ctx);
... | 510 | 254 | 764 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/rule-engine-component/src/main/java/org/jetlinks/community/rule/engine/executor/ReactorQLTaskExecutorProvider.java | ReactorQLTaskExecutor | doStart | class ReactorQLTaskExecutor extends AbstractTaskExecutor {
private ReactorQL reactorQL;
public ReactorQLTaskExecutor(ExecutionContext context) {
super(context);
reactorQL = createQl();
}
@Override
public String getName() {
return "ReactorQL"... |
Flux<Object> dataStream;
//有上游节点
if (!CollectionUtils.isEmpty(context.getJob().getInputs())) {
dataStream = context
.getInput()
.accept()
.flatMap(ruleData -> reactorQL
.start(Flux.j... | 327 | 503 | 830 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/rule-engine-component/src/main/java/org/jetlinks/community/rule/engine/executor/ScriptTaskExecutorProvider.java | ScriptTaskExecutorProvider | createExecutor | class ScriptTaskExecutorProvider implements TaskExecutorProvider {
@Override
public String getExecutor() {
return "script";
}
@Override
public Mono<TaskExecutor> createTask(ExecutionContext context) {
return Mono.just(new LambdaTaskExecutor("script", context, () -> {
r... |
DynamicScriptEngine engine = DynamicScriptEngineFactory.getEngine(config.getLang());
if (engine == null) {
throw new UnsupportedOperationException("不支持的脚本语言:" + config.getLang());
}
if (StringUtils.isEmpty(config.getScript())) {
log.warn("script is empty");
... | 256 | 380 | 636 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/rule-engine-component/src/main/java/org/jetlinks/community/rule/engine/executor/SqlExecutorTaskExecutorProvider.java | Config | getSql | class Config {
private String dataSourceId;
private NodeType nodeType = NodeType.MAP;
private String sql;
private boolean stream;
private boolean transaction;
public boolean isQuery() {
return sql.trim().startsWith("SELECT") ||
sql.trim(... |
if (!sql.contains("${")) {
return sql;
}
return ExpressionUtils.analytical(sql, RuleDataHelper.toContextMap(data), "spel");
| 124 | 50 | 174 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/rule-engine-component/src/main/java/org/jetlinks/community/rule/engine/executor/TimerTaskExecutorProvider.java | TimerTaskExecutor | execute | class TimerTaskExecutor extends AbstractTaskExecutor {
TimerSpec spec;
public TimerTaskExecutor(ExecutionContext context) {
super(context);
spec = FastBeanCopier.copy(context.getJob().getConfiguration(), new TimerSpec());
}
@Override
public String getNa... |
return spec
.flux()
.onBackpressureDrop()
.concatMap(t -> {
Map<String, Object> data = new HashMap<>();
long currentTime = System.currentTimeMillis();
data.put("timestamp", currentTime);
... | 297 | 189 | 486 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/rule-engine-component/src/main/java/org/jetlinks/community/rule/engine/executor/device/CompositeDeviceSelectorProvider.java | CompositeDeviceSelectorProvider | createLazy | class CompositeDeviceSelectorProvider implements DeviceSelectorProvider {
public static final String PROVIDER = "composite";
@Override
public String getProvider() {
return PROVIDER;
}
@Override
public String getName() {
return "组合选择";
}
@Override
public <T extends... |
BiFunction<NestConditional<T>, Map<String, Object>, Mono<NestConditional<T>>> function = null;
for (SelectorValue selectorValue : source.getSelectorValues()) {
DeviceSelectorSpec spec = FastBeanCopier.copy(selectorValue.getValue(), new DeviceSelectorSpec());
DeviceSelectorProv... | 447 | 261 | 708 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/rule-engine-component/src/main/java/org/jetlinks/community/rule/engine/executor/device/DeviceSelectorSpec.java | DeviceSelectorSpec | resolveSelectorValues | class DeviceSelectorSpec extends VariableSource {
/**
* @see DeviceSelectorProvider#getProvider()
*/
@Schema(description = "选择器标识")
@NotBlank
private String selector;
/**
* <pre>{@code
*
* // org.hswebframework.ezorm.core.param.Term
* 设备标签 : [{"value":[{"column":"tagK... |
if (CollectionUtils.isNotEmpty(selectorValues)) {
return Flux
.fromIterable(selectorValues)
.mapNotNull(SelectorValue::getValue);
}
return super.resolve(context);
| 640 | 56 | 696 | <methods>public non-sealed void <init>() ,public static org.jetlinks.community.relation.utils.VariableSource fixed(java.lang.Object) ,public static java.lang.Object getNestProperty(java.lang.String, Map<java.lang.String,java.lang.Object>) ,public static org.jetlinks.community.relation.utils.VariableSource of(java.lang.... |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/rule-engine-component/src/main/java/org/jetlinks/community/rule/engine/executor/device/SimpleDeviceSelectorProvider.java | SimpleDeviceSelectorProvider | of | class SimpleDeviceSelectorProvider implements DeviceSelectorProvider {
private final String provider;
private final String name;
private final BiFunction<List<?>, NestConditional<?>, Mono<NestConditional<?>>> function;
public static SimpleDeviceSelectorProvider of(
String provider,
Str... |
return new SimpleDeviceSelectorProvider(provider, name, (args, condition) -> {
return Mono.just(function.apply(args, condition));
});
| 292 | 43 | 335 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/rule-engine-component/src/main/java/org/jetlinks/community/rule/engine/messaging/RuleEngineSubscriptionProvider.java | RuleEngineSubscriptionProvider | subscribe | class RuleEngineSubscriptionProvider implements SubscriptionProvider {
private final EventBus eventBus;
public RuleEngineSubscriptionProvider(EventBus eventBus) {
this.eventBus = eventBus;
}
@Override
public String id() {
return "rule-engine";
}
@Override
public Strin... |
String subscriber=request.getId();
org.jetlinks.core.event.Subscription subscription = org.jetlinks.core.event.Subscription.of(subscriber,request.getTopic(), org.jetlinks.core.event.Subscription.Feature.local, Subscription.Feature.broker);
return eventBus
.subscribe(subscription)
... | 165 | 117 | 282 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/script-component/src/main/java/org/jetlinks/community/script/AbstractScriptFactory.java | Utils | min | class Utils {
private Utils(){}
public Object toJavaType(Object obj) {
return AbstractScriptFactory.this.convertToJavaType(obj);
}
public long now() {
return System.currentTimeMillis();
}
public String now(String format) {
return Lo... |
Object min = null;
for (Object param : params) {
if (param instanceof Map) {
param = ((Map<?, ?>) param).values();
}
if (param instanceof Collection) {
param = min(((Collection<?>) param).toArray());
... | 553 | 133 | 686 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/script-component/src/main/java/org/jetlinks/community/script/Scripts.java | Scripts | lookup | class Scripts {
private final static List<ScriptFactoryProvider> providers = new CopyOnWriteArrayList<>();
private final static Map<String, ScriptFactory> globals = new ConcurrentHashMap<>();
static {
providers.add(new NashornScriptFactoryProvider());
try {
for (ScriptFactoryP... |
for (ScriptFactoryProvider provider : providers) {
if (provider.isSupport(lang)) {
return provider;
}
}
throw new UnsupportedOperationException("unsupported script lang:" + lang);
| 213 | 55 | 268 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/script-component/src/main/java/org/jetlinks/community/script/context/CompositeExecutionContext.java | CompositeExecutionContext | getReader | class CompositeExecutionContext implements ExecutionContext {
private ExecutionContext[] contexts;
@Override
public synchronized ExecutionContext merge(ExecutionContext target) {
contexts = Arrays.copyOf(contexts, contexts.length + 1);
contexts[contexts.length - 1] = target;
retur... |
for (ExecutionContext context : contexts) {
Reader reader = context.getReader();
if (reader != null) {
return reader;
}
}
return null;
| 725 | 50 | 775 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/script-component/src/main/java/org/jetlinks/community/script/context/DefaultExecutionContext.java | DefaultExecutionContext | self | class DefaultExecutionContext implements ExecutionContext {
static final List<Integer> scopes = Arrays.asList(ENGINE_SCOPE, GLOBAL_SCOPE);
private final Map<String, Object>[] ctx;
private final Function<String, Object> fallback;
public DefaultExecutionContext(Map<String, Object>[] ctx) {
thi... |
Map<String, Object> self = ctx[ctx.length - 1];
return self == null ?
ctx[ctx.length - 1] = Maps.newHashMapWithExpectedSize(16)
: self;
| 691 | 60 | 751 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/script-component/src/main/java/org/jetlinks/community/script/jsr223/JavaScriptFactory.java | JavaScriptFactory | compileExpose | class JavaScriptFactory extends Jsr223ScriptFactory {
public JavaScriptFactory() {
super();
}
protected final String prepare(Script script) {
StringJoiner wrap = new StringJoiner("\n");
//使用匿名函数包装,防止变量逃逸
wrap.add("(function(){");
//注入安全性控制代码
//✨企业版还支持资源限制(防止... |
StringJoiner joiner = new StringJoiner("\n");
Set<String> distinct = new HashSet<>();
joiner.add("var _$this = $this;");
joiner.add(
Arrays.stream(expose.getMethods())
.filter(method -> !ignoreMethod.contains(method))
.sorted(Comparator.co... | 554 | 549 | 1,103 | <methods>public void <init>() ,public final T bind(org.jetlinks.community.script.Script, Class<T>, org.jetlinks.community.script.context.ExecutionContext) ,public final org.jetlinks.community.script.CompiledScript compile(org.jetlinks.community.script.Script) ,public java.lang.Object convertToJavaType(java.lang.Object)... |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/script-component/src/main/java/org/jetlinks/community/script/jsr223/Jsr223ScriptFactory.java | Console | bind | class Console {
private final Logger logger;
public void trace(String text, Object... args) {
logger.trace(text, args);
}
public void warn(String text, Object... args) {
logger.warn(text, args);
}
public void log(String text, Object... args) {
... |
String returns = createFunctionMapping(interfaceType.getDeclaredMethods());
String content = script.getContent() + "\n return " + returns + ";";
CompiledScript compiledScript = compile(script.content(content), false);
Object source = compiledScript.call(context);
Set<Method> ig... | 179 | 273 | 452 | <methods>public void <init>() ,public final void allows(Collection<Class<?>>) ,public final transient void allows(Class<?>[]) ,public transient void allowsPattern(java.lang.String[]) ,public void allowsPattern(Collection<java.lang.String>) ,public final void denies(Collection<Class<?>>) ,public final transient void den... |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/script-component/src/main/java/org/jetlinks/community/script/nashorn/NashornScriptFactory.java | NashornScriptFactory | jsIsArray | class NashornScriptFactory extends JavaScriptFactory {
static final Class<?> undefinedClass;
static final Class<?> jsObjectClass;
static final Class<?> classFilterClass;
static final Class<?> scriptFactoryClass;
static final Method jsIsArrayMethod;
static final Method jsArrayValuesMethod;
... |
if (jsIsArrayMethod == null) {
return false;
}
try {
return (boolean) jsIsArrayMethod.invoke(obj);
} catch (IllegalAccessException | InvocationTargetException ignore) {
}
return false;
| 1,386 | 67 | 1,453 | <methods>public void <init>() ,public ExposedScript<T> compileExpose(org.jetlinks.community.script.Script, Class<? super T>) <variables>private final Set<java.lang.reflect.Method> ignoreMethod |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/tdengine-component/src/main/java/org/jetlinks/community/tdengine/TDEngineUtils.java | TDEngineUtils | checkExecuteResult | class TDEngineUtils {
public static final DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSS");
public static String formatTime(long timestamp) {
return new DateTime(timestamp).toString(format);
}
public static Mono<JSONObject> checkExecuteResult(ClientResponse re... |
if (response.statusCode().isError()) {
return response
.bodyToMono(String.class)
.doOnNext(str -> {
throw new TDengineException(null, str);
})
.switchIfEmpty(Mono.error(() -> new TDengineException(null, response.sta... | 270 | 164 | 434 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/tdengine-component/src/main/java/org/jetlinks/community/tdengine/TDengineConfiguration.java | TDengineConfiguration | tDengineOperations | class TDengineConfiguration {
@Bean(destroyMethod = "dispose")
@ConditionalOnMissingBean(TDengineOperations.class)
public TDengineOperations tDengineOperations(TDengineProperties properties) {<FILL_FUNCTION_BODY>}
} |
WebClient client = properties.getRestful().createClient();
SchemalessTDEngineDataWriter writer = new SchemalessTDEngineDataWriter(client,
properties.getDatabase(),
... | 71 | 92 | 163 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/tdengine-component/src/main/java/org/jetlinks/community/tdengine/TDengineProperties.java | RestfulConnector | createClient | class RestfulConnector {
private List<URI> endpoints = new ArrayList<>(Collections.singletonList(URI.create("http://localhost:6041/")));
private String username = "root";
private String password = "taosdata";
private int maxConnections = Runtime.getRuntime().availableProcessors() * 8... |
WebClient.Builder builder = WebClient.builder();
URI endpoint = endpoints.get(0);
if (endpoints.size() > 1) {
builder = builder.filter((request, next) -> {
URI target = selectURI();
if (target.equals(endpoint)) {
... | 267 | 285 | 552 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/tdengine-component/src/main/java/org/jetlinks/community/tdengine/metadata/TDengineAlterTableSqlBuilder.java | TDengineAlterTableSqlBuilder | appendAlterColumnSql | class TDengineAlterTableSqlBuilder extends CommonAlterTableSqlBuilder {
@Override
protected void appendAddColumnCommentSql(DefaultBatchSqlRequest batch, RDBColumnMetadata column) {
}
protected PrepareSqlFragments createAlterTable(RDBColumnMetadata column) {
return of()
.addSql("AL... |
if (newColumn.getProperty(TDengineConstants.COLUMN_IS_TS).isTrue()) {
return;
}
PrepareSqlFragments fragments = createAlterTable(newColumn);
fragments.addSql("MODIFY",newColumn.getProperty(TDengineConstants.COLUMN_IS_TAG).isTrue() ? "COLUMN" : "TAG")
.addSql(new... | 456 | 135 | 591 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/tdengine-component/src/main/java/org/jetlinks/community/tdengine/metadata/TDengineCreateTableSqlBuilder.java | TDengineCreateTableSqlBuilder | build | class TDengineCreateTableSqlBuilder implements CreateTableSqlBuilder {
@Override
public SqlRequest build(RDBTableMetadata table) {<FILL_FUNCTION_BODY>}
} |
PrepareSqlFragments sql = PrepareSqlFragments.of();
List<String> columns = new ArrayList<>(table.getColumns().size());
sql.addSql("CREATE STABLE IF NOT EXISTS", table.getFullName(), "(")
.addSql("_ts timestamp");
List<RDBColumnMetadata> tags = new ArrayList<>();
f... | 49 | 342 | 391 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/tdengine-component/src/main/java/org/jetlinks/community/tdengine/metadata/TDengineMetadataParser.java | TDengineMetadataParser | parseByNameReactive | class TDengineMetadataParser implements TableMetadataParser {
private final RDBSchemaMetadata schema;
private ReactiveSqlExecutor sql() {
return schema.findFeatureNow(ReactiveSqlExecutor.ID);
}
@Override
public List<String> parseAllTableName() {
throw new UnsupportedOperationExcep... |
RDBTableMetadata table = schema.newTable(name);
return sql()
.select("describe "+table.getFullName(), ResultWrappers.map())
.doOnNext(column -> table.addColumn(convertToColumn(column)))
.then(Mono.fromSupplier(() -> table.getColumns().isEmpty() ? null : table));
| 556 | 92 | 648 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/tdengine-component/src/main/java/org/jetlinks/community/tdengine/metadata/TDengineRestfulSqlExecutor.java | TDengineRestfulSqlExecutor | convertQueryResult | class TDengineRestfulSqlExecutor implements ReactiveSqlExecutor {
private final WebClient client;
@Override
public Mono<Integer> update(Publisher<SqlRequest> request) {
return this
.doExecute(request)
.then(Reactors.ALWAYS_ONE);
}
@Override
public Mono<Void> ex... |
JSONArray head = result.getJSONArray("column_meta");
JSONArray data = result.getJSONArray("data");
if (CollectionUtils.isEmpty(head) || CollectionUtils.isEmpty(data)) {
return Flux.empty();
}
List<String> columns = head.stream()
.map(v-> ((JSONArray) v)... | 590 | 325 | 915 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/tdengine-component/src/main/java/org/jetlinks/community/tdengine/restful/RestfulTDEngineQueryOperations.java | RestfulTDEngineQueryOperations | convertQueryResult | class RestfulTDEngineQueryOperations implements TDEngineQueryOperations {
private final WebClient client;
private final String database;
@Override
public <E> Flux<E> query(String sql, ResultWrapper<E, ?> wrapper) {
log.trace("Execute ==> {}", sql);
return client
.post()
... |
JSONArray head = result.getJSONArray("column_meta");
JSONArray data = result.getJSONArray("data");
if (CollectionUtils.isEmpty(head) || CollectionUtils.isEmpty(data)) {
return Flux.empty();
}
List<String> columns = head.stream()
.map(v -> ((JSONArray) v... | 232 | 325 | 557 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/tdengine-component/src/main/java/org/jetlinks/community/tdengine/restful/SchemalessTDEngineDataWriter.java | SchemalessTDEngineDataWriter | convertToLine | class SchemalessTDEngineDataWriter implements TDEngineDataWriter, Disposable {
private final WebClient client;
private final String database;
private final DataBufferFactory factory = new NettyDataBufferFactory(ByteBufAllocator.DEFAULT);
private final PersistenceBuffer<String> buffer;
public Sche... |
return org.influxdb.dto.Point.measurement(point.getMetric())
.tag((Map) point.getTags())
.fields(point.getValues())
.time(point.getTimestamp(), TimeUnit.MILLISECONDS)
... | 636 | 78 | 714 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/tdengine-component/src/main/java/org/jetlinks/community/tdengine/term/TDengineQueryConditionBuilder.java | TDengineQueryConditionBuilder | build | class TDengineQueryConditionBuilder extends AbstractTermsFragmentBuilder<Object> {
public static String build(List<Term> terms) {<FILL_FUNCTION_BODY>}
@Override
protected SqlFragments createTermFragments(Object parameter, Term term) {
String type = term.getTermType();
TDengineTermType ter... |
if(CollectionUtils.isEmpty(terms)){
return "";
}
SqlFragments fragments = new TDengineQueryConditionBuilder().createTermFragments(null, terms);
if(fragments.isEmpty()){
return "";
}
return fragments.toRequest().toString();
| 144 | 78 | 222 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/tdengine-component/src/main/java/org/jetlinks/community/tdengine/things/TDengineColumnModeQueryOperations.java | TDengineColumnModeQueryOperations | doAggregation | class TDengineColumnModeQueryOperations extends ColumnModeQueryOperationsBase {
final TDengineThingDataHelper helper;
public TDengineColumnModeQueryOperations(String thingType,
String thingTemplateId,
String thingId,
... |
StringJoiner joiner = new StringJoiner("", "select ", "");
joiner.add("last(`_ts`) _ts");
for (PropertyAggregation property : context.getProperties()) {
joiner.add(",");
joiner.add(TDengineThingDataHelper.convertAggFunction(property))
.add("(`").add(pr... | 300 | 502 | 802 | <methods>public void <init>(java.lang.String, java.lang.String, java.lang.String, org.jetlinks.community.things.data.operations.MetricBuilder, org.jetlinks.community.things.data.operations.DataSettings, org.jetlinks.core.things.ThingsRegistry) ,public Flux<org.jetlinks.community.things.data.ThingProperties> queryAllPro... |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/tdengine-component/src/main/java/org/jetlinks/community/tdengine/things/TDengineColumnModeStrategy.java | TDengineColumnModeStrategy | createForQuery | class TDengineColumnModeStrategy extends AbstractThingDataRepositoryStrategy {
private final ThingsRegistry registry;
private final TDengineThingDataHelper helper;
public TDengineColumnModeStrategy(ThingsRegistry registry, TDengineThingDataHelper helper) {
this.registry = registry;
this.he... |
return new TDengineColumnModeQueryOperations(
thingType,
templateId,
thingId,
context.getMetricBuilder(),
context.getSettings(),
registry,
helper);
| 363 | 55 | 418 | <methods>public non-sealed void <init>() ,public abstract org.jetlinks.community.things.data.operations.SaveOperations createOpsForSave(org.jetlinks.community.things.data.ThingsDataRepositoryStrategy.OperationsContext) ,public final org.jetlinks.community.things.data.operations.TemplateOperations opsForTemplate(java.la... |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/tdengine-component/src/main/java/org/jetlinks/community/tdengine/things/TDengineRowModeQueryOperations.java | TDengineRowModeQueryOperations | doAggregation | class TDengineRowModeQueryOperations extends RowModeQueryOperationsBase {
final TDengineThingDataHelper helper;
public TDengineRowModeQueryOperations(String thingType,
String thingTemplateId,
String thingId,
... |
PropertyAggregation[] properties = context.getProperties();
//聚合
StringJoiner agg = new StringJoiner("");
agg.add("property,last(`_ts`) _ts");
for (PropertyAggregation property : properties) {
agg.add(",");
agg.add(TDengineThingDataHelper.convertAggFun... | 386 | 992 | 1,378 | <methods>public void <init>(java.lang.String, java.lang.String, java.lang.String, org.jetlinks.community.things.data.operations.MetricBuilder, org.jetlinks.community.things.data.operations.DataSettings, org.jetlinks.core.things.ThingsRegistry) <variables> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/tdengine-component/src/main/java/org/jetlinks/community/tdengine/things/TDengineRowModeSaveOperations.java | TDengineRowModeSaveOperations | createRowPropertyData | class TDengineRowModeSaveOperations extends RowModeSaveOperationsBase {
private final TDengineThingDataHelper helper;
public TDengineRowModeSaveOperations(ThingsRegistry registry,
MetricBuilder metricBuilder,
DataSettings setting... |
Map<String, Object> data = super.createRowPropertyData(id, timestamp, message, property, value);
IGNORE_COLUMN.forEach(data::remove);
return data;
| 501 | 52 | 553 | <methods>public void <init>(org.jetlinks.core.things.ThingsRegistry, org.jetlinks.community.things.data.operations.MetricBuilder, org.jetlinks.community.things.data.operations.DataSettings) <variables> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/tdengine-component/src/main/java/org/jetlinks/community/tdengine/things/TDengineRowModeStrategy.java | TDengineRowModeStrategy | createForDDL | class TDengineRowModeStrategy extends AbstractThingDataRepositoryStrategy {
private final ThingsRegistry registry;
private final TDengineThingDataHelper helper;
public TDengineRowModeStrategy(ThingsRegistry registry, TDengineThingDataHelper helper) {
this.registry = registry;
this.helper =... |
return new TDengineRowModeDDLOperations(
thingType,
templateId,
thingId,
context.getSettings(),
context.getMetricBuilder(),
helper);
| 425 | 52 | 477 | <methods>public non-sealed void <init>() ,public abstract org.jetlinks.community.things.data.operations.SaveOperations createOpsForSave(org.jetlinks.community.things.data.ThingsDataRepositoryStrategy.OperationsContext) ,public final org.jetlinks.community.things.data.operations.TemplateOperations opsForTemplate(java.la... |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/things-component/src/main/java/org/jetlinks/community/things/configuration/AutoRegisterThingsRegistry.java | AutoRegisterThingsRegistry | postProcessAfterInitialization | class AutoRegisterThingsRegistry extends DefaultThingsRegistry implements BeanPostProcessor {
@Override
public Object postProcessAfterInitialization(@Nonnull Object bean,@Nonnull String beanName) throws BeansException {<FILL_FUNCTION_BODY>}
} |
if(bean instanceof ThingsRegistrySupport){
addSupport(((ThingsRegistrySupport) bean));
}
return BeanPostProcessor.super.postProcessAfterInitialization(bean, beanName);
| 64 | 50 | 114 | <methods>public void <init>() ,public void <init>(Iterable<org.jetlinks.core.things.ThingsRegistrySupport>) ,public reactor.core.Disposable addSupport(org.jetlinks.core.things.ThingsRegistrySupport) ,public Mono<org.jetlinks.core.things.ThingTemplate> getTemplate(java.lang.String, java.lang.String) ,public Mono<org.jet... |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/things-component/src/main/java/org/jetlinks/community/things/configuration/ThingsConfiguration.java | ThingsConfiguration | thingDataService | class ThingsConfiguration {
@Bean
public NoneThingsDataRepositoryStrategy noneThingsDataRepositoryStrategy() {
return new NoneThingsDataRepositoryStrategy();
}
@Bean(destroyMethod = "shutdown")
public AutoUpdateThingsDataManager thingsDataManager(EventBus eventBus) {
String fileNam... |
DefaultThingsDataRepository service = new DefaultThingsDataRepository(registry);
policies.forEach(service::addPolicy);
for (ThingsDataCustomizer customizer : customizers) {
customizer.custom(service);
}
return service;
| 344 | 67 | 411 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/things-component/src/main/java/org/jetlinks/community/things/data/AggregationRequest.java | AggregationRequest | prepareTimestampCondition | class AggregationRequest {
//时间间隔
//为空时,不按时间分组
@Schema(description = "间隔,如: 1d", type = "string", defaultValue = "1d")
@Nullable
@Builder.Default
Interval interval = Interval.ofDays(1);
//时间格式
@Schema(defaultValue = "时间格式,如:yyyy-MM-dd", description = "yyyy-MM-dd")
@Builder.Default
... |
for (Term term : filter.getTerms()) {
if ("timestamp".equals(term.getColumn())) {
if (TermType.btw.equals(term.getTermType())) {
List<Object> values = ConverterUtils.convertToList(term.getValue());
if (!values.isEmpty()) {
... | 618 | 263 | 881 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/things-component/src/main/java/org/jetlinks/community/things/data/AutoUpdateThingsDataManager.java | AutoUpdateThingsDataManager | getLastProperty | class AutoUpdateThingsDataManager extends LocalFileThingsDataManager {
private final Map<ThingId, Updater> updaters = Caffeine
.newBuilder()
//10分钟没有任何读取则dispose取消订阅
.expireAfterAccess(Duration.ofMinutes(10))
.<ThingId, Updater>removalListener((key, value, cause) -> {
if... |
Updater updater = getUpdater(thingType, thingId);
updater.tryLoad(property);
Mono<Void> loader = updater.loader;
if (updater.loading && loader != null) {
return loader
.then(Mono.defer(() -> super.getLastProperty(thingType, thingId, property, baseTime)));
... | 1,583 | 121 | 1,704 | <methods>public void <init>(java.lang.String) ,public void <init>(MVStore) ,public Mono<org.jetlinks.core.things.ThingProperty> getFirstProperty(java.lang.String, java.lang.String, java.lang.String) ,public Mono<java.lang.Long> getFirstPropertyTime(java.lang.String, java.lang.String) ,public Mono<org.jetlinks.community... |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/things-component/src/main/java/org/jetlinks/community/things/data/DefaultMetricMetadataManager.java | DefaultMetricMetadataManager | register | class DefaultMetricMetadataManager implements MetricMetadataManager {
private final Map<String, Map<String, PropertyMetadata>> repo = new ConcurrentHashMap<>();
@Override
public void register(String metric, List<PropertyMetadata> properties) {<FILL_FUNCTION_BODY>}
@Override
public Optional<Propert... |
repo.compute(metric, (key, old) -> {
if (old != null) {
old.clear();
} else {
old = new ConcurrentHashMap<>();
}
for (PropertyMetadata property : properties) {
old.put(property.getId(), property);
}
... | 173 | 88 | 261 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/things-component/src/main/java/org/jetlinks/community/things/data/DefaultThingsDataRepository.java | DefaultThingsDataRepository | customSettings | class DefaultThingsDataRepository implements ThingsDataRepository, ThingsDataContext, SaveOperations {
private final Map<String, ThingsDataRepositoryStrategy> policies = new ConcurrentHashMap<>();
private final Map<String, ThingsDataRepositoryStrategy.OperationsContext> contexts = new ConcurrentHashMap<>();
... |
contexts.compute(thingType, (k, old) -> {
if (old == null) {
return new ThingsDataRepositoryStrategy.OperationsContext(defaultContext.getMetricBuilder(), settings);
}
return old.settings(settings);
});
| 1,328 | 68 | 1,396 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/things-component/src/main/java/org/jetlinks/community/things/data/PropertyAggregation.java | PropertyAggregation | getDefaultValue | class PropertyAggregation {
@Schema(description = "属性ID")
@NotBlank
private String property; //要聚合对字段
@Schema(description = "别名,默认和property一致")
private String alias; //别名
@Schema(description = "聚合方式,支持(count,sum,max,min,avg)", type = "string")
@NotNull
private Aggregation agg; //聚合函数
... |
if (defaultValue != null) {
return defaultValue;
}
if (agg != null) {
return defaultValue = agg.getDefaultValue();
}
return null;
| 262 | 54 | 316 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/things-component/src/main/java/org/jetlinks/community/things/data/ThingEvent.java | ThingEvent | putFormat | class ThingEvent extends HashMap<String, Object> {
private String thingId;
public ThingEvent() {
}
public ThingEvent(Map<String, Object> map, String thingIdProperty) {
super(map);
this.thingId = (String) map.get(thingIdProperty);
}
public ThingEvent(TimeSeriesData data, Stri... |
if (metadata != null) {
DataType type = metadata.getType();
if (type instanceof ObjectType) {
Map<String, Object> val = (Map<String, Object>) type.format(this);
val.forEach((k, v) -> put(k + "_format", v));
} else {
put("value_... | 309 | 179 | 488 | <methods>public void <init>() ,public void <init>(int) ,public void <init>(Map<? extends java.lang.String,? extends java.lang.Object>) ,public void <init>(int, float) ,public void clear() ,public java.lang.Object clone() ,public java.lang.Object compute(java.lang.String, BiFunction<? super java.lang.String,? super java... |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/things-component/src/main/java/org/jetlinks/community/things/data/ThingMessageLog.java | ThingMessageLog | of | class ThingMessageLog implements Serializable {
private String id;
private String thingId;
private long createTime;
private long timestamp;
private ThingLogType type;
private String content;
public static ThingMessageLog of(TimeSeriesData data, String thingIdProperty) {<FILL_FUNCTION_... |
ThingMessageLog log = data.as(ThingMessageLog.class);
log.thingId = data.getString(thingIdProperty, log.thingId);
return log;
| 123 | 47 | 170 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/things-component/src/main/java/org/jetlinks/community/things/data/ThingPropertyDetail.java | ThingPropertyDetail | of | class ThingPropertyDetail implements ThingProperty {
@Schema(description = "ID")
private String id;
@Schema(description = "物实例ID")
private String thingId;
@Schema(description = "属性ID")
private String property;
@Schema(description = "状态")
private String state;
@Schema(description... |
ThingPropertyDetail deviceProperty = data.as(ThingPropertyDetail.class);
deviceProperty.setCreateTime(data.getLong("createTime", data.getTimestamp()));
deviceProperty.setTimestamp(data.getTimestamp());
deviceProperty.setValue(value);
return deviceProperty.withProperty(metadata);... | 1,146 | 80 | 1,226 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/things-component/src/main/java/org/jetlinks/community/things/data/operations/AbstractDDLOperations.java | AbstractDDLOperations | doWith | class AbstractDDLOperations implements DDLOperations {
protected final String thingType;
protected final String templateId;
protected final String thingId;
protected final DataSettings settings;
protected final MetricBuilder metricBuilder;
protected List<PropertyMetadata> createBasicColumns... |
Mono<Void> properties = handler.apply(
MetricType.properties,
metricBuilder.createPropertyMetric(thingType, templateId, thingId),
createPropertyProperties(metadata.getProperties()));
Mono<Void> log = handler.apply(
MetricType.log,
metricBuil... | 889 | 275 | 1,164 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/things-component/src/main/java/org/jetlinks/community/things/data/operations/ColumnModeQueryOperationsBase.java | ColumnModeQueryOperationsBase | queryProperty | class ColumnModeQueryOperationsBase extends AbstractQueryOperations implements ColumnModeQueryOperations {
public ColumnModeQueryOperationsBase(String thingType,
String thingTemplateId,
String thingId,
... |
String metric = metricBuilder.createPropertyMetric(thingType, thingTemplateId, thingId);
return queryProperty(metric, param.toNestQuery(this::applyQuery), metadata, properties);
| 1,145 | 50 | 1,195 | <methods>public non-sealed void <init>() ,public final transient Flux<org.jetlinks.community.timeseries.query.AggregationData> aggregationProperties(org.jetlinks.community.things.data.AggregationRequest, org.jetlinks.community.things.data.PropertyAggregation[]) ,public final transient Flux<org.jetlinks.community.things... |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/things-component/src/main/java/org/jetlinks/community/things/data/operations/ColumnModeSaveOperationsBase.java | ColumnModeSaveOperationsBase | convertPropertyValue | class ColumnModeSaveOperationsBase extends AbstractSaveOperations {
public ColumnModeSaveOperationsBase(ThingsRegistry registry, MetricBuilder metricBuilder, DataSettings settings) {
super(registry, metricBuilder, settings);
}
protected String createPropertyDataId(ThingMessage message) {
r... |
if (value == null || metadata == null) {
return value;
}
//使用json字符串来存储
if (propertyIsJsonStringStorage(metadata)) {
return value instanceof String ? String.valueOf(value) : ObjectMappers.toJsonString(value);
}
//数字类型直接返回
if (metadata.getV... | 899 | 170 | 1,069 | <methods>public non-sealed void <init>() ,public Flux<org.jetlinks.core.metadata.Feature> getFeatures() ,public final Mono<java.lang.Void> save(org.jetlinks.core.message.ThingMessage) ,public final Mono<java.lang.Void> save(Collection<? extends org.jetlinks.core.message.ThingMessage>) ,public final Mono<java.lang.Void>... |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/things-component/src/main/java/org/jetlinks/community/things/data/operations/RowModeDDLOperationsBase.java | RowModeDDLOperationsBase | createPropertyProperties | class RowModeDDLOperationsBase extends AbstractDDLOperations{
public RowModeDDLOperationsBase(String thingType,
String templateId,
String thingId,
DataSettings settings,
M... |
List<PropertyMetadata> props = new ArrayList<>(createBasicColumns());
props.add(SimplePropertyMetadata.of(ThingsDataConstants.COLUMN_PROPERTY_ID, "属性ID", StringType.GLOBAL));
props.add(SimplePropertyMetadata.of(ThingsDataConstants.COLUMN_PROPERTY_NUMBER_VALUE, "数字值", DoubleType.GLOBAL));
... | 120 | 309 | 429 | <methods>public non-sealed void <init>() ,public final Mono<java.lang.Void> registerMetadata(org.jetlinks.core.things.ThingMetadata) ,public final Mono<java.lang.Void> reloadMetadata(org.jetlinks.core.things.ThingMetadata) <variables>protected final non-sealed org.jetlinks.community.things.data.operations.MetricBuilder... |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/things-component/src/main/java/org/jetlinks/community/things/data/operations/RowModeQueryOperationsBase.java | RowModeQueryOperationsBase | applyProperty | class RowModeQueryOperationsBase extends AbstractQueryOperations {
public RowModeQueryOperationsBase(String thingType,
String thingTemplateId,
String thingId,
MetricBuilder metricBuilder,
... |
if (detail == null) {
return null;
}
if (detail.getThingId() == null) {
detail.thingId((String) data.get(metricBuilder.getThingIdProperty()));
}
return detail;
| 919 | 65 | 984 | <methods>public non-sealed void <init>() ,public final transient Flux<org.jetlinks.community.timeseries.query.AggregationData> aggregationProperties(org.jetlinks.community.things.data.AggregationRequest, org.jetlinks.community.things.data.PropertyAggregation[]) ,public final transient Flux<org.jetlinks.community.things... |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/things-component/src/main/java/org/jetlinks/community/things/data/operations/RowModeSaveOperationsBase.java | RowModeSaveOperationsBase | fillRowPropertyValue | class RowModeSaveOperationsBase extends AbstractSaveOperations {
public RowModeSaveOperationsBase(ThingsRegistry registry, MetricBuilder metricBuilder, DataSettings settings) {
super(registry, metricBuilder, settings);
}
@Override
protected final Flux<Tuple2<String, TimeSeriesData>> convertPro... |
if (value == null) {
return;
}
DataType type = property.getValueType();
target.put(COLUMN_PROPERTY_TYPE, type.getId());
String convertedValue;
if (type instanceof NumberType) {
NumberType<?> numberType = (NumberType<?>) type;
Number nu... | 1,132 | 570 | 1,702 | <methods>public non-sealed void <init>() ,public Flux<org.jetlinks.core.metadata.Feature> getFeatures() ,public final Mono<java.lang.Void> save(org.jetlinks.core.message.ThingMessage) ,public final Mono<java.lang.Void> save(Collection<? extends org.jetlinks.core.message.ThingMessage>) ,public final Mono<java.lang.Void>... |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/things-component/src/main/java/org/jetlinks/community/things/impl/entity/PropertyMetricEntity.java | PropertyMetricEntity | toMetric | class PropertyMetricEntity extends GenericEntity<String> implements RecordCreationEntity {
@Schema(description = "物类型,如: device")
@Column(length = 32, nullable = false, updatable = false)
private String thingType;
@Schema(description = "物ID,如: 设备ID")
@Column(length = 64, nullable = false, updatabl... |
PropertyMetric propertyMetric=new PropertyMetric();
propertyMetric.setId(metric);
propertyMetric.setValue(value);
propertyMetric.setRange(range);
propertyMetric.setName(metricName);
return propertyMetric;
| 492 | 69 | 561 | <no_super_class> |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/things-component/src/main/java/org/jetlinks/community/things/impl/metric/DefaultPropertyMetricManager.java | DefaultPropertyMetricManager | getPropertyMetrics | class DefaultPropertyMetricManager extends AbstractPropertyMetricManager {
private final EventBus eventBus;
private final ReactiveRepository<PropertyMetricEntity, String> repository;
public DefaultPropertyMetricManager(ThingsRegistry registry,
EventBus eventBus,
... |
return Mono
.zip(
//数据库中记录的
repository
.createQuery()
.where(PropertyMetricEntity::getThingType, thingType)
.and(PropertyMetricEntity::getThingId, thingId)
.and(PropertyMetricEntity::getP... | 869 | 371 | 1,240 | <methods>public non-sealed void <init>() ,public Mono<org.jetlinks.community.PropertyMetric> getPropertyMetric(org.jetlinks.core.things.ThingId, java.lang.String, java.lang.String) <variables>protected final Map<org.jetlinks.community.things.metric.AbstractPropertyMetricManager.CacheKey,Mono<org.jetlinks.community.Prop... |
jetlinks_jetlinks-community | jetlinks-community/jetlinks-components/things-component/src/main/java/org/jetlinks/community/things/metric/AbstractPropertyMetricManager.java | AbstractPropertyMetricManager | loadFromTemplate | class AbstractPropertyMetricManager implements PropertyMetricManager {
protected final Map<CacheKey, Mono<PropertyMetric>> cache = new ConcurrentHashMap<>();
protected final ThingsRegistry registry;
@Override
public Mono<PropertyMetric> getPropertyMetric(ThingId thingId, String property, String metri... |
return registry
.getThing(thingId.getType(), thingId.getId())
.flatMap(Thing::getTemplate)
.flatMap(ThingTemplate::getMetadata)
.flatMap(metadata -> Mono
.justOrEmpty(
metadata
.getProperty(property)
... | 316 | 110 | 426 | <no_super_class> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.