* under the License.
*/
+import org.codehaus.jackson.annotate.JsonIgnore;
+
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.ArrayList;
private List<TreeEntry> childs = new ArrayList<TreeEntry>();
-
private Artifact artifact;
+ @JsonIgnore
+ private TreeEntry parent;
+
public TreeEntry()
{
// no op
{
this.childs = childs;
}
+
+ @JsonIgnore
+ public TreeEntry getParent()
+ {
+ return parent;
+ }
+
+ @JsonIgnore
+ public void setParent( TreeEntry parent )
+ {
+ this.parent = parent;
+ }
}
private static class TreeDependencyNodeVisitor
implements DependencyNodeVisitor
{
+
final List<TreeEntry> treeEntries;
private TreeEntry currentEntry;
+
private DependencyNode firstNode;
+
+ boolean firstChild = true;
+
private TreeDependencyNodeVisitor( List<TreeEntry> treeEntries )
{
this.treeEntries = treeEntries;
public boolean visit( DependencyNode node )
{
+ TreeEntry entry = new TreeEntry( new BeanReplicator().replicateBean( node.getArtifact(), Artifact.class ) );
+ entry.setParent( currentEntry );
+ currentEntry = entry;
+
if ( firstNode == null )
{
firstNode = node;
- }
- if ( currentEntry == null )
- {
- currentEntry =
- new TreeEntry( new BeanReplicator().replicateBean( node.getArtifact(), Artifact.class ) );
treeEntries.add( currentEntry );
}
else
{
- if ( node.getChildren().isEmpty() )
- {
- currentEntry.getChilds().add(
- new TreeEntry( new BeanReplicator().replicateBean( node.getArtifact(), Artifact.class ) ) );
- }
- }
-
- if ( !node.getChildren().isEmpty() )
- {
- for ( DependencyNode dependencyNode : (List<DependencyNode>) node.getChildren() )
- {
- if ( dependencyNode.getChildren().isEmpty() )
- {
- this.currentEntry.getChilds().add( new TreeEntry(
- new BeanReplicator().replicateBean( dependencyNode.getArtifact(), Artifact.class ) ) );
- }
- else
- {
- TreeEntry backup = this.currentEntry;
- this.currentEntry = new TreeEntry(
- new BeanReplicator().replicateBean( dependencyNode.getArtifact(), Artifact.class ) );
- visit( dependencyNode );
- this.currentEntry = backup;
- }
- }
+ currentEntry.getParent().getChilds().add( currentEntry );
}
-
return true;
}
public boolean endVisit( DependencyNode node )
{
- firstNode = null;
+ /*
+ if ( node.getChildren().isEmpty() )
+ {
+ currentEntry = currentEntry.getParent();
+ }
+ else
+ {
+
+ } */
+ currentEntry = currentEntry.getParent();
+ firstChild = false;
return true;
}