private String name;\r
private Character separator = DEFAULT_SEPARATOR;\r
\r
+ private String asUniqueString;\r
+\r
/** For ORM */\r
private Long tid;\r
\r
public String getAsUniqueString() {\r
- String parentStr = parent != null ? parent.getAsUniqueString() : "";\r
- return parentStr + separator + name;\r
+ if (asUniqueString == null) {\r
+ String parentStr = parent != null ? parent.getAsUniqueString() : "";\r
+ asUniqueString = parentStr + separator + name;\r
+ }\r
+ return asUniqueString;\r
}\r
\r
/** Sets all the required data from a string. */\r
TreeSPath twin = parseToCreatePath(str, getSeparator());\r
name = twin.name;\r
parent = twin.parent;\r
+ asUniqueString = getAsUniqueString();\r
}\r
\r
/** The separator actually used by this path. */\r
return depthImpl(this);\r
}\r
\r
- private static int depthImpl(TreeSPath path) {\r
+ protected int depthImpl(TreeSPath path) {\r
if (path.getParent() == null) {\r
return 1;\r
} else {\r
}\r
}\r
\r
+ public List<TreeSPath> getHierarchyAsList() {\r
+ List<TreeSPath> lst = new Vector<TreeSPath>();\r
+ addParentToList(lst, this);\r
+ lst.add(this);\r
+ return lst;\r
+ }\r
+\r
+ protected void addParentToList(List<TreeSPath> lst, TreeSPath current) {\r
+ TreeSPath parent = current.getParent();\r
+ if (parent != null) {\r
+ addParentToList(lst, parent);\r
+ lst.add(parent);\r
+ }\r
+ }\r
+\r
@Override\r
public String toString() {\r
return getAsUniqueString();\r
return false;\r
}\r
\r
+ @Override\r
+ public int hashCode() {\r
+ return getAsUniqueString().hashCode();\r
+ }\r
+\r
public int compareTo(StructurePath o) {\r
return getAsUniqueString().compareTo(o.getAsUniqueString());\r
}\r
this.tid = tid;\r
}\r
\r
- /** Sets the separator character to use. */\r
+ /**\r
+ * Sets the separator character to use.\r
+ * \r
+ * @deprecated\r
+ */\r
public void setSeparator(Character separator) {\r
this.separator = separator;\r
}\r
import org.argeo.slc.core.process.SlcExecutionAware;\r
import org.argeo.slc.core.process.SlcExecutionStep;\r
import org.argeo.slc.core.structure.StructureAware;\r
+import org.argeo.slc.core.structure.StructureElement;\r
import org.argeo.slc.core.structure.StructureRegistry;\r
import org.argeo.slc.core.structure.tree.TreeSPath;\r
import org.argeo.slc.core.test.NumericTRId;\r
* Complex implementation of a test result compatible with a tree based\r
* structure.\r
*/\r
-public class TreeTestResult implements TestResult, StructureAware<TreeSPath>, SlcExecutionAware {\r
+public class TreeTestResult implements TestResult, StructureAware<TreeSPath>,\r
+ SlcExecutionAware {\r
private Log log = LogFactory.getLog(TreeTestResult.class);\r
/** For ORM */\r
private Long tid;\r
}\r
}\r
\r
- public void notifyCurrentPath(StructureRegistry<TreeSPath> registry, TreeSPath path) {\r
+ public void notifyCurrentPath(StructureRegistry<TreeSPath> registry,\r
+ TreeSPath path) {\r
+ if (registry != null) {\r
+ for (TreeSPath p : path.getHierarchyAsList()) {\r
+ if (!pathNames.containsKey(p)) {\r
+ StructureElement elem = registry.getElement(p);\r
+ if (elem != null) {\r
+ pathNames.put(p, elem.getLabel());\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
currentPath = (TreeSPath) path;\r
this.registry = registry;\r
}\r
}\r
\r
/** Sets the related registry. */\r
-// public void setRegistry(StructureRegistry<TreeSPath> registry) {\r
-// this.registry = registry;\r
-// }\r
-\r
+ // public void setRegistry(StructureRegistry<TreeSPath> registry) {\r
+ // this.registry = registry;\r
+ // }\r
public Date getCloseDate() {\r
return closeDate;\r
}\r
public void notifySlcExecution(SlcExecution slcExecution) {\r
currentSlcExecutionUuid = slcExecution.getUuid();\r
SlcExecutionStep step = slcExecution.currentStep();\r
- if(step!=null){\r
+ if (step != null) {\r
currentSlcExecutionStepUuid = step.getUuid();\r
}\r
}\r
\r
+ public SortedMap<TreeSPath, String> getPathNames() {\r
+ return pathNames;\r
+ }\r
+\r
+ public void setPathNames(SortedMap<TreeSPath, String> pathNames) {\r
+ this.pathNames = pathNames;\r
+ }\r
+\r
}\r
try {\r
TreeTestResult persistedResult = testResultDao\r
.getTestResult(partStruct.resultId);\r
-\r
+ \r
+ if(persistedResult==null){\r
+ testResultDao.create(partStruct.result);\r
+ }\r
+ else{\r
+ testResultDao.update(partStruct.result);\r
+ }\r
+/*\r
TreeSPath path = treeSPathDao.getOrCreate(partStruct.path);\r
\r
StructureRegistry<TreeSPath> localRegistry = partStruct.result\r
log.trace("Part: " + partStruct.part);\r
}\r
testResultDao.update(persistedResult);\r
- }\r
+ }*/\r
} catch (Exception e) {\r
log.error("Could not persist part for result #"\r
+ partStruct.resultId, e);\r
public void setTreeSRegistryDao(TreeSRegistryDao treeSRegistryDao) {\r
this.treeSRegistryDao = treeSRegistryDao;\r
}\r
-/*\r
- private void syncPath(TreeSRegistry registry,\r
- StructureRegistry<TreeSPath> localRegistry, TreeSPath path) {\r
- if (path.getParent() != null) {\r
- TreeSPath parent = treeSPathDao.getOrCreate(path.getParent());\r
- syncPath(registry, localRegistry, parent);\r
- }\r
-\r
- if (registry.getElement(path) == null) {\r
- if (localRegistry != null) {\r
- registry.register(path, localRegistry.getElement(path));\r
- } else {\r
- registry.register(path, new SimpleSElement(path.getName()));\r
- }\r
- treeSRegistryDao.update(registry);\r
- } else {\r
- if (localRegistry != null) {\r
- StructureElement sElement = localRegistry.getElement(path);\r
- if (sElement != null) {\r
- registry.register(path, sElement);\r
- treeSRegistryDao.update(registry);\r
- }\r
- }\r
- }\r
\r
- }*/\r
}\r
public List<TreeTestResult> listResults(TreeSPath path) {\r
List<TreeTestResult> list = getHibernateTemplate().find(\r
"from TreeTestResult res where ? in indices(res.resultParts)",\r
- path);\r
+ path.getAsUniqueString());\r
return list;\r
}\r
\r
<map name="resultParts" table="RESULT_PARTS_MAP" cascade="all"\r
lazy="false" sort="natural">\r
<key column="PARENT_ID" />\r
- <map-key-many-to-many\r
+ <!-- \r
+ <map-key-many-to-many\r
class="org.argeo.slc.core.structure.tree.TreeSPath" column="PATH" />\r
+ -->\r
+ <composite-map-key\r
+ class="org.argeo.slc.core.structure.tree.TreeSPath">\r
+ <key-property name="asUniqueString" column="PATH" />\r
+ </composite-map-key>\r
<many-to-many class="PartSubList" column="PART_SUB_LIST_ID"\r
unique="true" lazy="false" />\r
</map>\r
+\r
+ <map name="pathNames" table="RESULT_PATH_NAMES_MAP"\r
+ cascade="all" lazy="false" sort="natural">\r
+ <key column="PARENT_ID" />\r
+ <composite-map-key\r
+ class="org.argeo.slc.core.structure.tree.TreeSPath">\r
+ <key-property name="asUniqueString" column="PATH" />\r
+ </composite-map-key>\r
+ <element column="NAME" type="string" />\r
+ </map>\r
</class>\r
</hibernate-mapping>
\ No newline at end of file
String pathParentStr = "/root/testParent";\r
String pathStr = pathParentStr + "/test";\r
TreeSPath path = TreeSPath.parseToCreatePath(pathStr);\r
- treeSPathDao.create(path);\r
+ //treeSPathDao.create(path);\r
\r
TreeTestResult treeTestResult = new TreeTestResult();\r
treeTestResult.notifySlcExecution(slcExecution);\r