Simplify project structure
[gpl/argeo-suite.git] / core / org.argeo.suite.core / src / org / argeo / suite / core / SuiteTypology.java
diff --git a/core/org.argeo.suite.core/src/org/argeo/suite/core/SuiteTypology.java b/core/org.argeo.suite.core/src/org/argeo/suite/core/SuiteTypology.java
deleted file mode 100644 (file)
index d9d6673..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-package org.argeo.suite.core;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.Node;
-
-import org.argeo.entity.Term;
-import org.argeo.entity.Typology;
-import org.argeo.jcr.Jcr;
-
-/** A typology. Helper to optimise {@link SuiteTermsManager} implementation. */
-class SuiteTypology implements Typology {
-       private final String name;
-       private final Node node;
-       private boolean isFlat = true;
-
-       private final List<SuiteTerm> subTerms = new ArrayList<>();
-
-       public SuiteTypology(Node node) {
-               this.node = node;
-               this.name = Jcr.getName(this.node);
-       }
-
-       @Override
-       public String getId() {
-               return name;
-       }
-
-       public String getName() {
-               return name;
-       }
-
-       public Node getNode() {
-               return node;
-       }
-
-       void markNotFlat() {
-               if (isFlat)
-                       isFlat = false;
-       }
-
-       @Override
-       public boolean isFlat() {
-               return isFlat;
-       }
-
-       @Override
-       public List<SuiteTerm> getSubTerms() {
-               return subTerms;
-       }
-
-       public List<SuiteTerm> getAllTerms() {
-               if (isFlat)
-                       return subTerms;
-               else {
-                       List<SuiteTerm> terms = new ArrayList<>();
-                       for (SuiteTerm subTerm : subTerms) {
-                               terms.add(subTerm);
-                               collectSubTerms(terms, subTerm);
-                       }
-                       return terms;
-               }
-       }
-
-       public Term findTermByName(String name) {
-               List<SuiteTerm> collected = new ArrayList<>();
-               for (SuiteTerm subTerm : subTerms) {
-                       collectTermsByName(subTerm, name, collected);
-               }
-               if (collected.isEmpty())
-                       return null;
-               if (collected.size() == 1)
-                       return collected.get(0);
-               throw new IllegalArgumentException(
-                               "There are " + collected.size() + " terms with name " + name + " in typology " + getId());
-       }
-
-       private void collectTermsByName(SuiteTerm term, String name, List<SuiteTerm> collected) {
-               if (term.getName().equals(name)) {
-                       collected.add(term);
-               }
-               for (SuiteTerm subTerm : term.getSubTerms()) {
-                       collectTermsByName(subTerm, name, collected);
-               }
-       }
-
-       private void collectSubTerms(List<SuiteTerm> terms, SuiteTerm term) {
-               for (SuiteTerm subTerm : term.getSubTerms()) {
-                       terms.add(subTerm);
-                       collectSubTerms(terms, subTerm);
-               }
-       }
-
-}