|
@@ -0,0 +1,135 @@
|
|
|
|
|
+package com.lingyue.graph.constant;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 实体类型常量
|
|
|
|
|
+ *
|
|
|
|
|
+ * 统一管理实体类型的显示名称、图标、颜色映射
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author lingyue
|
|
|
|
|
+ * @since 2026-01-21
|
|
|
|
|
+ */
|
|
|
|
|
+public final class EntityTypeConstants {
|
|
|
|
|
+
|
|
|
|
|
+ private EntityTypeConstants() {}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 类型到显示名称的映射
|
|
|
|
|
+ */
|
|
|
|
|
+ public static final Map<String, String> TYPE_NAMES = Map.ofEntries(
|
|
|
|
|
+ Map.entry("person", "人物"),
|
|
|
|
|
+ Map.entry("org", "机构"),
|
|
|
|
|
+ Map.entry("loc", "地点"),
|
|
|
|
|
+ Map.entry("location", "地点"),
|
|
|
|
|
+ Map.entry("date", "日期"),
|
|
|
|
|
+ Map.entry("number", "数值"),
|
|
|
|
|
+ Map.entry("money", "金额"),
|
|
|
|
|
+ Map.entry("data", "数据"),
|
|
|
|
|
+ Map.entry("concept", "概念"),
|
|
|
|
|
+ Map.entry("device", "设备"),
|
|
|
|
|
+ Map.entry("term", "术语"),
|
|
|
|
|
+ Map.entry("entity", "实体"),
|
|
|
|
|
+ Map.entry("project", "项目"),
|
|
|
|
|
+ Map.entry("other", "其他")
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 类型到图标的映射(emoji)
|
|
|
|
|
+ */
|
|
|
|
|
+ public static final Map<String, String> TYPE_ICONS = Map.ofEntries(
|
|
|
|
|
+ Map.entry("person", "👤"),
|
|
|
|
|
+ Map.entry("org", "🏢"),
|
|
|
|
|
+ Map.entry("loc", "📍"),
|
|
|
|
|
+ Map.entry("location", "📍"),
|
|
|
|
|
+ Map.entry("date", "📅"),
|
|
|
|
|
+ Map.entry("number", "🔢"),
|
|
|
|
|
+ Map.entry("money", "💰"),
|
|
|
|
|
+ Map.entry("data", "📊"),
|
|
|
|
|
+ Map.entry("concept", "💡"),
|
|
|
|
|
+ Map.entry("device", "🔧"),
|
|
|
|
|
+ Map.entry("term", "📝"),
|
|
|
|
|
+ Map.entry("entity", "🏷️"),
|
|
|
|
|
+ Map.entry("project", "📋"),
|
|
|
|
|
+ Map.entry("other", "📌")
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 类型到颜色的映射(用于前端渲染)
|
|
|
|
|
+ */
|
|
|
|
|
+ public static final Map<String, String> TYPE_COLORS = Map.ofEntries(
|
|
|
|
|
+ Map.entry("person", "#1890ff"),
|
|
|
|
|
+ Map.entry("org", "#52c41a"),
|
|
|
|
|
+ Map.entry("loc", "#fa8c16"),
|
|
|
|
|
+ Map.entry("location", "#fa8c16"),
|
|
|
|
|
+ Map.entry("date", "#722ed1"),
|
|
|
|
|
+ Map.entry("number", "#13c2c2"),
|
|
|
|
|
+ Map.entry("money", "#52c41a"),
|
|
|
|
|
+ Map.entry("data", "#13c2c2"),
|
|
|
|
|
+ Map.entry("concept", "#722ed1"),
|
|
|
|
|
+ Map.entry("device", "#eb2f96"),
|
|
|
|
|
+ Map.entry("term", "#2f54eb"),
|
|
|
|
|
+ Map.entry("entity", "#1890ff"),
|
|
|
|
|
+ Map.entry("project", "#faad14"),
|
|
|
|
|
+ Map.entry("other", "#8c8c8c")
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 类型到 Neo4j 标签的映射
|
|
|
|
|
+ */
|
|
|
|
|
+ public static final Map<String, String> TYPE_LABELS = Map.ofEntries(
|
|
|
|
|
+ Map.entry("person", "Person"),
|
|
|
|
|
+ Map.entry("org", "Organization"),
|
|
|
|
|
+ Map.entry("loc", "Location"),
|
|
|
|
|
+ Map.entry("location", "Location"),
|
|
|
|
|
+ Map.entry("date", "Date"),
|
|
|
|
|
+ Map.entry("number", "Number"),
|
|
|
|
|
+ Map.entry("money", "Money"),
|
|
|
|
|
+ Map.entry("data", "Data"),
|
|
|
|
|
+ Map.entry("concept", "Concept"),
|
|
|
|
|
+ Map.entry("device", "Device"),
|
|
|
|
|
+ Map.entry("term", "Term"),
|
|
|
|
|
+ Map.entry("entity", "Entity"),
|
|
|
|
|
+ Map.entry("project", "Project")
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 预定义的类型排序顺序
|
|
|
|
|
+ */
|
|
|
|
|
+ public static final java.util.List<String> TYPE_ORDER = java.util.List.of(
|
|
|
|
|
+ "entity", "concept", "project", "data", "number", "money",
|
|
|
|
|
+ "person", "org", "loc", "location", "date", "device", "term", "other"
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取类型的显示名称
|
|
|
|
|
+ */
|
|
|
|
|
+ public static String getTypeName(String type) {
|
|
|
|
|
+ if (type == null) return TYPE_NAMES.get("other");
|
|
|
|
|
+ return TYPE_NAMES.getOrDefault(type.toLowerCase(), type);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取类型的图标
|
|
|
|
|
+ */
|
|
|
|
|
+ public static String getTypeIcon(String type) {
|
|
|
|
|
+ if (type == null) return TYPE_ICONS.get("other");
|
|
|
|
|
+ return TYPE_ICONS.getOrDefault(type.toLowerCase(), "📌");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取类型的颜色
|
|
|
|
|
+ */
|
|
|
|
|
+ public static String getTypeColor(String type) {
|
|
|
|
|
+ if (type == null) return TYPE_COLORS.get("other");
|
|
|
|
|
+ return TYPE_COLORS.getOrDefault(type.toLowerCase(), "#8c8c8c");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取类型的 Neo4j 标签
|
|
|
|
|
+ */
|
|
|
|
|
+ public static String getTypeLabel(String type) {
|
|
|
|
|
+ if (type == null) return "Entity";
|
|
|
|
|
+ return TYPE_LABELS.getOrDefault(type.toLowerCase(), "Entity");
|
|
|
|
|
+ }
|
|
|
|
|
+}
|