Index: /DCWoRMS/trunk/src/test/DEBBTranslator/src/DEBB2DCWoRMSTranslator.java
===================================================================
--- /DCWoRMS/trunk/src/test/DEBBTranslator/src/DEBB2DCWoRMSTranslator.java	(revision 568)
+++ /DCWoRMS/trunk/src/test/DEBBTranslator/src/DEBB2DCWoRMSTranslator.java	(revision 584)
@@ -53,4 +53,6 @@
 	private static HashMap<String, String> computingResourceClasses = null;
 	private static HashMap<String, String> resourceUnitClasses;
+	private static XPath xpath;
+	private static Document dcwormsDocument;
 
 	/**
@@ -87,5 +89,5 @@
 
 			XPathFactory xpathFactory = XPathFactory.newInstance();
-			XPath xpath = xpathFactory.newXPath();
+			xpath = xpathFactory.newXPath();
 			NamespaceContext nsContext = new DEBBNamespaceContext();
 			xpath.setNamespaceContext(nsContext);
@@ -100,5 +102,5 @@
 
 			// Creating destination, dcworms document
-			Document dcwormsDocument = xmlDocumentBuilder.newDocument();
+			dcwormsDocument = xmlDocumentBuilder.newDocument();
 			// Creating root, environment, element
 			Element rootElement = dcwormsDocument.createElement("environment");
@@ -125,5 +127,5 @@
 			// Transform top level DEBB and all nested DEBBs
 			transformDEBB(plmxmlDocument, dcwormsDocument, resourcesElement,
-					xpath, rootIdNode.getNodeValue());
+					rootIdNode.getNodeValue());
 
 			// write the content into xml file
@@ -167,5 +169,5 @@
 		computingResourceClasses.put("Node", "Node");
 		computingResourceClasses.put("Processor", "Processor");
-		
+
 		resourceUnitClasses = new HashMap<String, String>();
 		resourceUnitClasses.put("Sensor", "Sensor");
@@ -244,5 +246,4 @@
 	 * @param dcwormsDocument
 	 *            TODO
-	 * @param xpath
 	 * @param instanceId
 	 * @return
@@ -250,5 +251,5 @@
 	 */
 	public static void transformDEBB(Document plmxmlDocument,
-			Document dcwormsDocument, Element debbParentElement, XPath xpath,
+			Document dcwormsDocument, Element debbParentElement,
 			String instanceId) throws Exception {
 
@@ -437,118 +438,21 @@
 				System.out.println("id=" + debbComponentNode.getNodeName());
 
-				//	Get all baseboards
-				expr = xpath.compile("Baseboard");
-				result = expr.evaluate(debbComponentNode,
-						XPathConstants.NODESET);
-				NodeList baseboardNodeList = (NodeList) result;
-				if (baseboardNodeList != null) {
-					for (int i = 0; i < baseboardNodeList.getLength(); i++) {
-						Node baseboardNode = baseboardNodeList.item(i);
-
-						Element resourceUnitElement = dcwormsDocument
-								.createElement("resourceUnit");
-						Attr baseboardClassAttribute = dcwormsDocument.createAttribute("class");
-						baseboardClassAttribute.setValue(resourceUnitClasses.get(baseboardNode.getNodeName()));
-						resourceUnitElement.setAttributeNode(baseboardClassAttribute);
-						computingResourceElement
-								.appendChild(resourceUnitElement);
-					}
-				}
-				
-				//	Get all memory units
-				expr = xpath.compile("Memory");
-				result = expr.evaluate(debbComponentNode,
-						XPathConstants.NODESET);
-				NodeList memoryNodeList = (NodeList) result;
-				if (memoryNodeList != null) {
-					for (int i = 0; i < memoryNodeList.getLength(); i++) {
-						Node memoryNode = memoryNodeList.item(i);
-
-						Element resourceUnitElement = dcwormsDocument
-								.createElement("resourceUnit");
-						Attr memoryClassAttribute = dcwormsDocument.createAttribute("class");
-						memoryClassAttribute.setValue(resourceUnitClasses.get(memoryNode.getNodeName()));
-						resourceUnitElement.setAttributeNode(memoryClassAttribute);
-						computingResourceElement
-								.appendChild(resourceUnitElement);
-					}
-				}
-
-				//	Get all storages
-				expr = xpath.compile("Storage");
-				result = expr.evaluate(debbComponentNode,
-						XPathConstants.NODESET);
-				NodeList storageNodeList = (NodeList) result;
-				if (storageNodeList != null) {
-					for (int i = 0; i < storageNodeList.getLength(); i++) {
-						Node storageNode = storageNodeList.item(i);
-
-						Element resourceUnitElement = dcwormsDocument
-								.createElement("resourceUnit");
-						Attr storageClassAttribute = dcwormsDocument.createAttribute("class");
-						storageClassAttribute.setValue(resourceUnitClasses.get(storageNode.getNodeName()));
-						resourceUnitElement.setAttributeNode(storageClassAttribute);
-						computingResourceElement
-								.appendChild(resourceUnitElement);
-					}
-				}
-				
-				// Get all sensors				
-				expr = xpath.compile("Sensor");
-				result = expr.evaluate(debbComponentNode,
-						XPathConstants.NODESET);
-				NodeList sensorsNodeList = (NodeList) result;
-				if (sensorsNodeList != null) {
-					for (int i = 0; i < sensorsNodeList.getLength(); i++) {
-						Node sensorNode = sensorsNodeList.item(i);
-
-						Element resourceUnitElement = dcwormsDocument
-								.createElement("resourceUnit");
-						Attr sensorClassAttribute = dcwormsDocument.createAttribute("class");
-						sensorClassAttribute.setValue(resourceUnitClasses.get(sensorNode.getNodeName()));
-						resourceUnitElement.setAttributeNode(sensorClassAttribute);
-						computingResourceElement
-								.appendChild(resourceUnitElement);
-					}
-				}
-				
-				//	Get all cooling devices
-				expr = xpath.compile("CoolingDevice");
-				result = expr.evaluate(debbComponentNode,
-						XPathConstants.NODESET);
-				NodeList coolingDeviceNodeList = (NodeList) result;
-				if (coolingDeviceNodeList != null) {
-					for (int i = 0; i < coolingDeviceNodeList.getLength(); i++) {
-						Node coolingDeviceNode = coolingDeviceNodeList.item(i);
-
-						Element resourceUnitElement = dcwormsDocument
-								.createElement("resourceUnit");
-						Attr coolingDeviceClassAttribute = dcwormsDocument.createAttribute("class");
-						coolingDeviceClassAttribute.setValue(resourceUnitClasses.get(coolingDeviceNode.getNodeName()));
-						resourceUnitElement.setAttributeNode(coolingDeviceClassAttribute);
-						computingResourceElement
-								.appendChild(resourceUnitElement);
-					}
-				}
-			
-				//	Get all processors
-				expr = xpath.compile("Processor");
-				result = expr.evaluate(debbComponentNode,
-						XPathConstants.NODESET);
-				NodeList processorNodeList = (NodeList) result;
-				if (processorNodeList != null) {
-					for (int i = 0; i < processorNodeList.getLength(); i++) {
-						Node processorNode = processorNodeList.item(i);
-
-						Element processorElement = dcwormsDocument
-								.createElement("computingResource");
-						Attr processorClassAttribute = dcwormsDocument.createAttribute("class");
-						processorClassAttribute.setValue(computingResourceClasses.get(processorNode.getNodeName()));
-						processorElement.setAttributeNode(processorClassAttribute);
-						computingResourceElement
-								.appendChild(processorElement);
-					}
-				}
-				
+				// Get all processors
+				transformProcessors(debbComponentNode, computingResourceElement);
+
+				// Get all memory units
+				transformMemoryUnits(debbComponentNode,
+						computingResourceElement);
+
+				// Get all storages
+				transformStorages(debbComponentNode, computingResourceElement);
+
+				// Get all cooling devices
+				transformCoolingDevices(debbComponentNode,
+						computingResourceElement);
+				// Get all baseboards
+				transformBaseboards(debbComponentNode, computingResourceElement);
+				// Get all sensors
+				transformSensors(debbComponentNode, computingResourceElement);
 			}
 
@@ -571,5 +475,5 @@
 					// Go down in the hierarchy
 					transformDEBB(plmxmlDocument, dcwormsDocument,
-							computingResourceElement, xpath, instance);
+							computingResourceElement, instance);
 					System.out.println();
 				}
@@ -578,3 +482,170 @@
 	}
 
+	private static void transformCoolingDevices(Node debbComponentNode,
+			Element computingResourceElement) throws XPathExpressionException {
+		XPathExpression expr = xpath.compile("CoolingDevice");
+		Object result = expr
+				.evaluate(debbComponentNode, XPathConstants.NODESET);
+		NodeList coolingDeviceNodeList = (NodeList) result;
+		if (coolingDeviceNodeList != null) {
+			for (int i = 0; i < coolingDeviceNodeList.getLength(); i++) {
+				Node coolingDeviceNode = coolingDeviceNodeList.item(i);
+
+				Element resourceUnitElement = dcwormsDocument
+						.createElement("resourceUnit");
+				Attr coolingDeviceClassAttribute = dcwormsDocument
+						.createAttribute("class");
+				coolingDeviceClassAttribute.setValue(resourceUnitClasses
+						.get(coolingDeviceNode.getNodeName()));
+				resourceUnitElement
+						.setAttributeNode(coolingDeviceClassAttribute);
+				computingResourceElement.appendChild(resourceUnitElement);
+			}
+		}
+
+	}
+
+	private static void transformProcessors(Node debbComponentNode,
+			Element computingResourceElement) throws XPathExpressionException {
+		XPathExpression expr = xpath.compile("Processor");
+		Object result = expr
+				.evaluate(debbComponentNode, XPathConstants.NODESET);
+		NodeList processorNodeList = (NodeList) result;
+		if (processorNodeList != null) {
+			for (int i = 0; i < processorNodeList.getLength(); i++) {
+				Node processorNode = processorNodeList.item(i);
+
+				Element processorElement = dcwormsDocument
+						.createElement("computingResource");
+				Attr processorClassAttribute = dcwormsDocument
+						.createAttribute("class");
+				processorClassAttribute.setValue(computingResourceClasses
+						.get(processorNode.getNodeName()));
+				processorElement.setAttributeNode(processorClassAttribute);
+//
+//				// Device attributes
+//				NodeList parameterNodes = processorNode.getChildNodes();
+//				String tmp = "";
+//				for (int j = 0; j < parameterNodes.getLength(); j++) {
+//					Node child = parameterNodes.item(j);
+//
+//					short type = child.getNodeType();
+//					System.out.println("type=" + type);
+//					if (type == Node.ELEMENT_NODE) {
+//						Element parameterElement = dcwormsDocument
+//								.createElement("parameter");
+//						Attr parameterNameAttribute = dcwormsDocument
+//								.createAttribute("name");
+//						parameterNameAttribute.setValue(child.getNodeName());
+//						parameterElement
+//								.setAttributeNode(parameterNameAttribute);
+//						Element valueElement = dcwormsDocument
+//								.createElement("value");
+//						valueElement.appendChild(dcwormsDocument
+//								.createTextNode(tmp));
+//						parameterElement.appendChild(valueElement);
+//						computingResourceElement.appendChild(parameterElement);
+//
+//					} else if (type == Node.TEXT_NODE) {
+//						tmp = child.getNodeValue();
+//
+//					}
+//
+//				}
+			}
+		}
+
+	}
+
+	private static void transformSensors(Node debbComponentNode,
+			Element computingResourceElement) throws XPathExpressionException {
+
+		// TODO: Take them from PLM XML
+		/*
+		 * XPathExpression expr = xpath.compile("Sensor"); Object result =
+		 * expr.evaluate(debbComponentNode, XPathConstants.NODESET); NodeList
+		 * sensorsNodeList = (NodeList) result; if (sensorsNodeList != null) {
+		 * for (int i = 0; i < sensorsNodeList.getLength(); i++) { Node
+		 * sensorNode = sensorsNodeList.item(i);
+		 * 
+		 * Element resourceUnitElement = dcwormsDocument
+		 * .createElement("resourceUnit"); Attr sensorClassAttribute =
+		 * dcwormsDocument.createAttribute("class");
+		 * sensorClassAttribute.setValue
+		 * (resourceUnitClasses.get(sensorNode.getNodeName()));
+		 * resourceUnitElement.setAttributeNode(sensorClassAttribute);
+		 * computingResourceElement .appendChild(resourceUnitElement); } }
+		 */
+
+	}
+
+	private static void transformStorages(Node debbComponentNode,
+			Element computingResourceElement) throws XPathExpressionException {
+		XPathExpression expr = xpath.compile("Storage");
+		Object result = expr
+				.evaluate(debbComponentNode, XPathConstants.NODESET);
+		NodeList storageNodeList = (NodeList) result;
+		if (storageNodeList != null) {
+			for (int i = 0; i < storageNodeList.getLength(); i++) {
+				Node storageNode = storageNodeList.item(i);
+
+				Element resourceUnitElement = dcwormsDocument
+						.createElement("resourceUnit");
+				Attr storageClassAttribute = dcwormsDocument
+						.createAttribute("class");
+				storageClassAttribute.setValue(resourceUnitClasses
+						.get(storageNode.getNodeName()));
+				resourceUnitElement.setAttributeNode(storageClassAttribute);
+				computingResourceElement.appendChild(resourceUnitElement);
+			}
+		}
+
+	}
+
+	private static void transformMemoryUnits(Node debbComponentNode,
+			Element computingResourceElement) throws XPathExpressionException {
+		XPathExpression expr = xpath.compile("Memory");
+		Object result = expr
+				.evaluate(debbComponentNode, XPathConstants.NODESET);
+		NodeList memoryNodeList = (NodeList) result;
+		if (memoryNodeList != null) {
+			for (int i = 0; i < memoryNodeList.getLength(); i++) {
+				Node memoryNode = memoryNodeList.item(i);
+
+				Element resourceUnitElement = dcwormsDocument
+						.createElement("resourceUnit");
+				Attr memoryClassAttribute = dcwormsDocument
+						.createAttribute("class");
+				memoryClassAttribute.setValue(resourceUnitClasses
+						.get(memoryNode.getNodeName()));
+				resourceUnitElement.setAttributeNode(memoryClassAttribute);
+				computingResourceElement.appendChild(resourceUnitElement);
+			}
+		}
+	}
+
+	private static void transformBaseboards(Node debbComponentNode,
+			Element computingResourceElement) throws XPathExpressionException {
+
+		XPathExpression expr = xpath.compile("Baseboard");
+		Object result = expr
+				.evaluate(debbComponentNode, XPathConstants.NODESET);
+		NodeList baseboardNodeList = (NodeList) result;
+		if (baseboardNodeList != null) {
+			for (int i = 0; i < baseboardNodeList.getLength(); i++) {
+				Node baseboardNode = baseboardNodeList.item(i);
+
+				Element resourceUnitElement = dcwormsDocument
+						.createElement("resourceUnit");
+				Attr baseboardClassAttribute = dcwormsDocument
+						.createAttribute("class");
+				baseboardClassAttribute.setValue(resourceUnitClasses
+						.get(baseboardNode.getNodeName()));
+				resourceUnitElement.setAttributeNode(baseboardClassAttribute);
+				computingResourceElement.appendChild(resourceUnitElement);
+			}
+		}
+
+	}
+
 }
