refactor(fw-nifi):重构 Nifi 相关代码- 更新 Jackson 配置,增加忽略未知属性的功能
- 新增多个 Nifi 模型类,包括 Breadcrumb2、Breadcrumb3、ParentBreadcrumb2 和 Permissions2 - 修改现有模型类,增加新字段以适应 Nifi API 变更 - 调整 NifiApiService 中的 queryFlowProcessGroupsRoot 方法,支持返回不同类型的响应
This commit is contained in:
parent
10aeddff70
commit
5d9fb90fb1
|
@ -1,10 +1,13 @@
|
||||||
package com.hzya.frame.nifi.config;
|
package com.hzya.frame.nifi.config;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* jackson配置类
|
||||||
|
*
|
||||||
* @Author:liuyang
|
* @Author:liuyang
|
||||||
* @Package:com.hzya.frame.nifi.config
|
* @Package:com.hzya.frame.nifi.config
|
||||||
* @Project:fw-nifi
|
* @Project:fw-nifi
|
||||||
|
@ -14,12 +17,13 @@ import org.springframework.context.annotation.Configuration;
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
public class JacksonConfig {
|
public class JacksonConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ObjectMapper objectMapper() {
|
public ObjectMapper objectMapper() {
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
// 可根据需求自定义配置,例如:
|
// 自动注册模块
|
||||||
objectMapper.findAndRegisterModules(); // 自动注册模块
|
objectMapper.findAndRegisterModules();
|
||||||
|
// 忽略 JSON 中存在但实体类中缺少的字段
|
||||||
|
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
return objectMapper;
|
return objectMapper;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,6 +4,8 @@ import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* nifi service配置类
|
||||||
|
*
|
||||||
* @Author:liuyang
|
* @Author:liuyang
|
||||||
* @Package:com.hzya.frame.nifi.config
|
* @Package:com.hzya.frame.nifi.config
|
||||||
* @Project:fw-nifi
|
* @Project:fw-nifi
|
||||||
|
|
|
@ -6,4 +6,5 @@ import lombok.Data;
|
||||||
public class AllowableValue {
|
public class AllowableValue {
|
||||||
private String displayName;
|
private String displayName;
|
||||||
private String value;
|
private String value;
|
||||||
|
private String description;
|
||||||
}
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.hzya.frame.nifi.model.processgroupid;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Breadcrumb2 {
|
||||||
|
private String id;
|
||||||
|
private Permissions2 permissions;
|
||||||
|
private Breadcrumb3 breadcrumb;
|
||||||
|
private ParentBreadcrumb2 parentBreadcrumb;
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.hzya.frame.nifi.model.processgroupid;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:liuyang
|
||||||
|
* @Package:com.hzya.frame.nifi.model.processgroupid
|
||||||
|
* @Project:fw-nifi
|
||||||
|
* @name:Breadcrumb3
|
||||||
|
* @Date:2025/5/14 17:57
|
||||||
|
* @Filename:Breadcrumb3
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class Breadcrumb3 {
|
||||||
|
private String id;
|
||||||
|
private String name;
|
||||||
|
}
|
|
@ -28,4 +28,5 @@ public class Component2 {
|
||||||
private String inputRequirement;
|
private String inputRequirement;
|
||||||
private String validationStatus;
|
private String validationStatus;
|
||||||
private String extensionMissing;
|
private String extensionMissing;
|
||||||
|
private Config config;
|
||||||
}
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.hzya.frame.nifi.model.processgroupid;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:liuyang
|
||||||
|
* @Package:com.hzya.frame.nifi.model.processgroupid
|
||||||
|
* @Project:fw-nifi
|
||||||
|
* @name:ParentBreadcrumb2
|
||||||
|
* @Date:2025/5/14 17:58
|
||||||
|
* @Filename:ParentBreadcrumb2
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ParentBreadcrumb2 {
|
||||||
|
private String id;
|
||||||
|
private Permissions2 permissions;
|
||||||
|
private Breadcrumb3 breadcrumb;
|
||||||
|
private ParentBreadcrumb2 parentBreadcrumb;
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.hzya.frame.nifi.model.processgroupid;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:liuyang
|
||||||
|
* @Package:com.hzya.frame.nifi.model.processgroupid
|
||||||
|
* @Project:fw-nifi
|
||||||
|
* @name:Permissions2
|
||||||
|
* @Date:2025/5/14 17:57
|
||||||
|
* @Filename:Permissions2
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class Permissions2 {
|
||||||
|
private String canRead;
|
||||||
|
private String canWrite;
|
||||||
|
}
|
|
@ -8,7 +8,7 @@ public class ProcessGroupFlow {
|
||||||
private String uri;
|
private String uri;
|
||||||
private String parentGroupId;
|
private String parentGroupId;
|
||||||
private ParameterContext parameterContext;
|
private ParameterContext parameterContext;
|
||||||
private Breadcrumb breadcrumb;
|
private Breadcrumb2 breadcrumb;
|
||||||
private Flow flow;
|
private Flow flow;
|
||||||
private String lastRefreshed;
|
private String lastRefreshed;
|
||||||
}
|
}
|
|
@ -41,4 +41,7 @@ public class Properties {
|
||||||
|
|
||||||
@JsonProperty("character-set")
|
@JsonProperty("character-set")
|
||||||
private String characterSet;
|
private String characterSet;
|
||||||
|
|
||||||
|
@JsonProperty("Database Connection Pooling Service")
|
||||||
|
private String databaseConnectionPoolingService;
|
||||||
}
|
}
|
|
@ -10,7 +10,7 @@ public class ProcessGroupFlow {
|
||||||
private Flow flow;
|
private Flow flow;
|
||||||
private String lastRefreshed;
|
private String lastRefreshed;
|
||||||
//查询单个流程组
|
//查询单个流程组
|
||||||
private String parentGroupId;
|
// private String parentGroupId;
|
||||||
//查询单个流程组
|
//查询单个流程组
|
||||||
private ParameterContext parameterContext;
|
// private ParameterContext parameterContext;
|
||||||
}
|
}
|
|
@ -2,6 +2,7 @@ package com.hzya.frame.nifi.service;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.hzya.frame.nifi.client.NifiClient;
|
import com.hzya.frame.nifi.client.NifiClient;
|
||||||
|
import com.hzya.frame.nifi.model.processgroupid.ProcessGroupsId;
|
||||||
import com.hzya.frame.nifi.model.processgrouproot.ProcessGroupsRoot;
|
import com.hzya.frame.nifi.model.processgrouproot.ProcessGroupsRoot;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -34,13 +35,11 @@ public class NifiApiService {
|
||||||
/**
|
/**
|
||||||
* 查询全部流程组或指定流程组
|
* 查询全部流程组或指定流程组
|
||||||
*/
|
*/
|
||||||
public ProcessGroupsRoot queryFlowProcessGroupsRoot(String flowGroupId) throws Exception {
|
public Object queryFlowProcessGroupsRoot(String flowGroupId) throws Exception {
|
||||||
ProcessGroupsRoot processGroupsRoot = null;
|
|
||||||
if (flowGroupId != null) {
|
if (flowGroupId != null) {
|
||||||
processGroupsRoot = client.get(StrUtil.format("/flow/process-groups/{}", flowGroupId), ProcessGroupsRoot.class);
|
return client.get(StrUtil.format("/flow/process-groups/{}", flowGroupId), ProcessGroupsId.class);
|
||||||
} else {
|
} else {
|
||||||
processGroupsRoot = client.get("/flow/process-groups/root", ProcessGroupsRoot.class);
|
return client.get("/flow/process-groups/root", ProcessGroupsRoot.class);
|
||||||
}
|
}
|
||||||
return processGroupsRoot;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue