From ba30725032d80fd0bcbc56576b8d645b95ea4895 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Mon, 6 Feb 2023 18:52:08 +0100 Subject: [PATCH] Fixing code --- .../gcube/informationsystem/discovery/Discovery.java | 12 ++++++------ .../java/org/gcube/informationsystem/tree/Node.java | 4 ++-- .../java/org/gcube/informationsystem/tree/Tree.java | 7 +++++-- ...informationsystem.discovery.RegistrationProvider} | 0 src/test/resources/logback-test.xml | 6 ++---- 5 files changed, 15 insertions(+), 14 deletions(-) rename src/main/resources/META-INF/services/{org.gcube.informationsystem.utils.discovery.RegistrationProvider => org.gcube.informationsystem.discovery.RegistrationProvider} (100%) diff --git a/src/main/java/org/gcube/informationsystem/discovery/Discovery.java b/src/main/java/org/gcube/informationsystem/discovery/Discovery.java index 2a4ee7d..d9d14bc 100644 --- a/src/main/java/org/gcube/informationsystem/discovery/Discovery.java +++ b/src/main/java/org/gcube/informationsystem/discovery/Discovery.java @@ -6,12 +6,12 @@ package org.gcube.informationsystem.discovery; import java.lang.reflect.Method; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; +import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.TreeSet; import org.gcube.informationsystem.base.reference.Element; import org.gcube.informationsystem.base.reference.properties.PropertyElement; @@ -29,8 +29,8 @@ public class Discovery { protected final Class root; protected final Set packages; - protected final Set> discoveredElement; - protected final Set> discoveredElementActions; + protected final List> discoveredElement; + protected final List> discoveredElementActions; protected boolean discovered; @@ -38,12 +38,12 @@ public class Discovery { this.root = root; this.packages = new HashSet<>(); this.discovered = false; - this.discoveredElement = new TreeSet<>(); - this.discoveredElementActions = new TreeSet<>(); + this.discoveredElement = new ArrayList<>(); + this.discoveredElementActions = new ArrayList<>(); add(root); } - public Set> getDiscoveredElement() { + public List> getDiscoveredElement() { return discoveredElement; } diff --git a/src/main/java/org/gcube/informationsystem/tree/Node.java b/src/main/java/org/gcube/informationsystem/tree/Node.java index f9dca90..fe70e9f 100644 --- a/src/main/java/org/gcube/informationsystem/tree/Node.java +++ b/src/main/java/org/gcube/informationsystem/tree/Node.java @@ -25,7 +25,7 @@ public class Node implements Comparable> { return tree; } - private void setTree(Tree tree) { + void setTree(Tree tree) { this.tree = tree; } @@ -77,7 +77,7 @@ public class Node implements Comparable> { for (int i = 0; i < level; ++i) { stringBuffer.append(Node.INDENTATION); } - stringBuffer.append(tree.getNodeInformation().getIdentifier(t)); + stringBuffer.append(tree.getNodeInformation().getIdentifier(node.getNodeElement())); stringBuffer.append("\n"); } diff --git a/src/main/java/org/gcube/informationsystem/tree/Tree.java b/src/main/java/org/gcube/informationsystem/tree/Tree.java index 4022129..fd3ce02 100644 --- a/src/main/java/org/gcube/informationsystem/tree/Tree.java +++ b/src/main/java/org/gcube/informationsystem/tree/Tree.java @@ -19,8 +19,10 @@ public class Tree { this.allowMultipleInheritance = true; this.ni = ni; this.locate = new HashMap<>(); - this.root = addNode(t); - + this.root = new Node<>(t); + this.root.setTree(this); + String identifier = ni.getIdentifier(t); + this.locate.put(identifier, root); } public void setAllowMultipleInheritance(boolean allowMultipleInheritance) { @@ -39,6 +41,7 @@ public class Tree { } Node node = new Node<>(t); + node.setTree(this); Set parentIdentifiers = ni.getParentIdentifiers(root.getNodeElement(), t); for(String parentIdentifier : parentIdentifiers) { diff --git a/src/main/resources/META-INF/services/org.gcube.informationsystem.utils.discovery.RegistrationProvider b/src/main/resources/META-INF/services/org.gcube.informationsystem.discovery.RegistrationProvider similarity index 100% rename from src/main/resources/META-INF/services/org.gcube.informationsystem.utils.discovery.RegistrationProvider rename to src/main/resources/META-INF/services/org.gcube.informationsystem.discovery.RegistrationProvider diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml index 14f1c8d..53d26fa 100644 --- a/src/test/resources/logback-test.xml +++ b/src/test/resources/logback-test.xml @@ -9,11 +9,9 @@ - + - - - +