Skip to content

Instantly share code, notes, and snippets.

@gidili
Created October 5, 2015 08:57
Show Gist options
  • Save gidili/49e3a75852c9bca9f488 to your computer and use it in GitHub Desktop.
Save gidili/49e3a75852c9bca9f488 to your computer and use it in GitHub Desktop.
pull properties from neuroml
public Collection<ANode> createStandaloneChildren(Standalone standaloneComponent)
{
Collection<ANode> standaloneChildren = new ArrayList<ANode>();
standaloneChildren.addAll(createBaseChildren(standaloneComponent));
// TODO: Improve to parse all the attribute in an annotation
Annotation annotation = standaloneComponent.getAnnotation();
if(annotation != null)
{
CompositeNode annotationNode = new CompositeNode(Resources.ANOTATION.getId(), Resources.ANOTATION.get());
for(Element element : annotation.getAny())
{
for(int i = 0; i < element.getChildNodes().getLength(); i++)
{
Node node = element.getChildNodes().item(i);
if(node.getLocalName() != null && node.getLocalName().equals(Resources.DESCRIPTION.get()))
{
// TODO: Still need to extract about from node component
CompositeNode descriptionNode = new CompositeNode(Resources.DESCRIPTION.getId(), Resources.DESCRIPTION.get());
for(int j = 0; j < node.getChildNodes().getLength(); j++)
{
descriptionNode.addChild(createAnnotationChild(node.getChildNodes().item(j)));
}
annotationNode.addChild(descriptionNode);
}
}
}
standaloneChildren.add(annotationNode);
}
standaloneChildren.add(PopulateNodesModelTreeUtils.createTextMetadataNode(Resources.NOTES.getId(), Resources.NOTES.get(), new StringValue(standaloneComponent.getNotes())));
standaloneChildren.add(PopulateNodesModelTreeUtils.createTextMetadataNode(Resources.METAID.getId(), Resources.METAID.get(), new StringValue(standaloneComponent.getMetaid())));
for (Property property : standaloneComponent.getProperty()){
standaloneChildren.add(PopulateNodesModelTreeUtils.createTextMetadataNode(property.getTag(), property.getTag(), new StringValue(property.getValue())));
}
return standaloneChildren;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment