public String produceFeatureElement( FeatureTreeNode feature, Map featureData, String templateFileName) { String output = ""; try { if (featureElementTemplate == null) { featureElementTemplate = cfg.getTemplate(templateFileName); } featureData.putAll(produceBasicFeatureData(feature)); FeatureTreeNode parentNode = (FeatureTreeNode) ((feature instanceof FeatureGroup) ? feature.getParent() : feature); List children = new ArrayList(parentNode.getChildCount()); for (int i = 0; i < parentNode.getChildCount(); i++) { FeatureTreeNode childNode = (FeatureTreeNode) parentNode.getChildAt(i); if (childNode instanceof FeatureGroup) { for (int j = 0; j < childNode.getChildCount(); j++) { FeatureTreeNode groupedNode = (FeatureTreeNode) childNode.getChildAt(j); children.add(produceBasicFeatureData(groupedNode)); } } else { children.add(produceBasicFeatureData(childNode)); } } featureData.put("children", children); StringWriter outputWriter = new StringWriter(); featureElementTemplate.process(featureData, outputWriter); output = outputWriter.toString(); } catch (Exception e) { output = e.getMessage(); } return output; }
protected void extractComponentsFromFeatureModel(FeatureTreeNode featureNode) { if (featureNode.isLeaf()) { if (getParentNode(featureNode) != null) { String componentKey = getParentNode(featureNode).getID(); String componentName = getParentNode(featureNode).getName(); ProductComponent component = concreteComponents.get(componentKey); if (component == null) { component = new ProductComponent(componentKey, componentName); concreteComponents.put(componentKey, component); } component.addComponentType(featureNode.getID()); } } for (int i = 0; i < featureNode.getChildCount(); i++) { extractComponentsFromFeatureModel((FeatureTreeNode) featureNode.getChildAt(i)); } }