Я пытаюсь обновить плагин apoc для Gephi, чтобы я мог отправлять веса из Neo4j в Gephi. Это исходная версия плагина. О чем я думал, что могу легко переставить
private Map<String, Object> data(PropertyContainer pc, Map<String, Map<String, Object>> colors) {
if (pc instanceof Node) {
Node n = (Node) pc;
String labels = Util.labelString(n);
Map<String, Object> attributes = map("label", caption(n), "TYPE", labels);
attributes.putAll(positions());
attributes.putAll(color(labels,colors));
return map(idStr(n), attributes);
}
if (pc instanceof Relationship) {
Relationship r = (Relationship) pc;
String type = r.getType().name();
Map<String, Object> attributes = map("label", type, "TYPE", type);
attributes.putAll(map("source", idStr(r.getStartNode()), "target", idStr(r.getEndNode()), "directed", true));
attributes.putAll(color(type, colors));
return map(String.valueOf(r.getId()), attributes);
}
return map();
}
на что-то вроде этого, где я бы изменил способ анализа отношений и добавил вес для возврата
private Map<String, Object> data(PropertyContainer pc, Map<String, Map<String, Object>> colors) {
if (pc instanceof Node) {
Node n = (Node) pc;
String labels = Util.labelString(n);
Map<String, Object> attributes = map("label", caption(n), "TYPE", labels);
attributes.putAll(positions());
attributes.putAll(color(labels,colors));
return map(idStr(n), attributes);
}
if (pc instanceof Relationship) {
Relationship r = (Relationship) pc;
String type = r.getType().name();
String weight = r.getProperty("weight");
Map<String, Object> attributes = map("label", type, "TYPE", type);
attributes.putAll(map("source", idStr(r.getStartNode()), "target", idStr(r.getEndNode()), "directed", false,"weight",weight));
attributes.putAll(color(type, colors));
return map(String.valueOf(r.getId()), attributes);
}
return map();
}
Теперь возникает проблема, что я новичок в JAVA и понятия не имею, как взаимодействовать с типами данных JAVA. Я нашел эту документацию по контейнеру свойств, где я нашел метод getProperty(String key)
и попытался использовать его, как указано выше, но получил следующую ошибку
/Users/Hal/Job/neo4j-apoc-procedures/src/main/java/apoc/gephi/Gephi.java:81: ошибка: несовместимые типы: объект не может быть преобразован в String String weight = r.getProperty("weight" );
Я думаю, что это какая-то основная проблема JAVA, но я понятия не имею, как ее отлаживать. Я также пробовал String weight = r.getProperty(weight);
, но получил ту же ошибку. Помощь приветствуется