]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc.core/src/main/java/org/argeo/slc/core/structure/tree/TreeSRegistry.java
Introduce examples modules
[gpl/argeo-slc.git] / org.argeo.slc.core / src / main / java / org / argeo / slc / core / structure / tree / TreeSRegistry.java
index 10125678c4fb5181a402dc0e210247eae192e80a..36c85728fe32c2dcdb75f52acf664a667aef3b23 100644 (file)
@@ -12,11 +12,8 @@ import org.argeo.slc.core.structure.StructureRegistry;
 \r
 /** Tree based implementation of a structure registry. */\r
 public class TreeSRegistry implements StructureRegistry<TreeSPath> {\r
-       public final static String STATUS_ACTIVE = "STATUS_ACTIVE";\r
-\r
        /** For ORM */\r
        private Long tid;\r
-       private String status;\r
        private Map<TreeSPath, SimpleSElement> elements = new TreeMap<TreeSPath, SimpleSElement>();\r
 \r
        private String mode = StructureRegistry.ALL;\r
@@ -24,7 +21,7 @@ public class TreeSRegistry implements StructureRegistry<TreeSPath> {
        private List<TreeSPath> activePaths;\r
 \r
        public <T extends StructureElement> T getElement(TreeSPath path) {\r
-               return (T)elements.get(path);\r
+               return (T) elements.get(path);\r
        }\r
 \r
        public List<StructureElement> listElements() {\r
@@ -36,6 +33,16 @@ public class TreeSRegistry implements StructureRegistry<TreeSPath> {
        }\r
 \r
        public void register(TreeSPath path, StructureElement element) {\r
+               if (path == null)\r
+                       throw new UnsupportedException("Cannot register under a null path.");\r
+               if (element == null)\r
+                       throw new UnsupportedException(\r
+                                       "Cannot register null element for path " + path);\r
+               if (element.getLabel() == null)\r
+                       throw new UnsupportedException(\r
+                                       "Cannot register an element with null label for path "\r
+                                                       + path);\r
+\r
                final SimpleSElement simpleSElement;\r
                if (element instanceof SimpleSElement) {\r
                        simpleSElement = (SimpleSElement) element;\r
@@ -43,11 +50,7 @@ public class TreeSRegistry implements StructureRegistry<TreeSPath> {
                        simpleSElement = new SimpleSElement(element.getLabel());\r
                }\r
 \r
-               if (path == null)\r
-                       throw new UnsupportedException("Path cannot be null.");\r
-\r
                elements.put(path, simpleSElement);\r
-\r
        }\r
 \r
        public String getMode() {\r
@@ -66,14 +69,6 @@ public class TreeSRegistry implements StructureRegistry<TreeSPath> {
                this.activePaths = activePaths;\r
        }\r
 \r
-       public String getStatus() {\r
-               return status;\r
-       }\r
-\r
-       public void setStatus(String status) {\r
-               this.status = status;\r
-       }\r
-\r
        /** Gets the elements. */\r
        public Map<TreeSPath, SimpleSElement> getElements() {\r
                return elements;\r