Index: /DCWoRMS/trunk/src/test/DEBBTranslator/src/DEBB2DCWoRMSTranslator.java
===================================================================
--- /DCWoRMS/trunk/src/test/DEBBTranslator/src/DEBB2DCWoRMSTranslator.java	(revision 566)
+++ /DCWoRMS/trunk/src/test/DEBBTranslator/src/DEBB2DCWoRMSTranslator.java	(revision 567)
@@ -42,7 +42,9 @@
 	// 3)
 
-	private static final String DEFAULT_OUTPUT_FILE_NAME = "xml/DCWORMS_TEST.xml";
-//	private static final String DEFAULT_INPUT_FILE_NAME = "xml/PLMXML_PSNCRECS.xml";
-	private static final String DEFAULT_INPUT_FILE_NAME = "xml/PLMXML_HLRSSmallServerRoom.xml";
+	private static final String DEFAULT_DCWORMS_OUTPUT_FILE_NAME = "xml/DCWORMS_TEST.xml";
+	// private static final String DEFAULT_INPUT_FILE_NAME =
+	// "xml/PLMXML_PSNCRECS.xml";
+	private static final String DEFAULT_PLMXML_INPUT_FILE_NAME = "xml/PLMXML_HLRSSmallServerRoom.xml";
+	private static final String DEFAULT_DEBB_COMPONENT_INPUT_FILE_NAME = "xml/DEBBComponents.xml";
 	private static DocumentBuilder xmlDocumentBuilder;
 	private static DocumentBuilderFactory domFactory;
@@ -61,16 +63,16 @@
 	 */
 	public static void main(String[] args) {
-		String inputFileName = DEFAULT_INPUT_FILE_NAME;
-		String outputFileName = DEFAULT_OUTPUT_FILE_NAME;
+		String inputFileName = DEFAULT_PLMXML_INPUT_FILE_NAME;
+		String outputFileName = DEFAULT_DCWORMS_OUTPUT_FILE_NAME;
 
 		if (args != null && args.length > 0) {
 			inputFileName = args[0];
 			if (inputFileName != null && inputFileName.isEmpty() == false) {
-				inputFileName = DEFAULT_INPUT_FILE_NAME;
+				inputFileName = DEFAULT_PLMXML_INPUT_FILE_NAME;
 			}
 
 			outputFileName = args[1];
 			if (outputFileName != null && outputFileName.isEmpty() == false) {
-				outputFileName = DEFAULT_OUTPUT_FILE_NAME;
+				outputFileName = DEFAULT_DCWORMS_OUTPUT_FILE_NAME;
 			}
 		}
@@ -80,5 +82,5 @@
 
 			// Open and read content of the input file (i.e. PLM XML document)
-			Document plmxmlDocument = readInputFile(inputFileName);
+			Document plmxmlDocument = readPLMXMLInputFile(inputFileName);
 
 			XPathFactory xpathFactory = XPathFactory.newInstance();
@@ -91,7 +93,7 @@
 					.compile("//plm:ProductDef/plm:InstanceGraph/@rootRefs");
 			Object result = expr.evaluate(plmxmlDocument, XPathConstants.NODE);
-			Node rootId = (Node) result;
-			System.out.println(rootId.getNodeName());
-			System.out.println(rootId.getNodeValue());
+			Node rootIdNode = (Node) result;
+			System.out.println(rootIdNode.getNodeName());
+			System.out.println(rootIdNode.getNodeValue());
 
 			// Creating destination, dcworms document
@@ -109,5 +111,5 @@
 			rootElement.appendChild(resourcesElement);
 
-			//*****************************************************************
+			// *****************************************************************
 			// Creating (main) scheduler element
 			// TODO: Fill scheduler with reasonable data!
@@ -118,11 +120,11 @@
 			resourcesElement.appendChild(schedulerElement);
 
-			//*****************************************************************
+			// *****************************************************************
 			// Transform top level DEBB and all nested DEBBs
 			transformDEBB(plmxmlDocument, dcwormsDocument, resourcesElement,
-					xpath, rootId.getNodeValue());
+					xpath, rootIdNode.getNodeValue());
 
 			// write the content into xml file
-			saveOutputFile(outputFileName, dcwormsDocument);
+			saveDCWoRMSOutputFile(outputFileName, dcwormsDocument);
 
 		} catch (ParserConfigurationException e) {
@@ -165,5 +167,5 @@
 	}
 
-	private static Document readInputFile(String inputFileName) {
+	private static Document readPLMXMLInputFile(String inputFileName) {
 		Document plmxmlDocument;
 		try {
@@ -180,5 +182,20 @@
 	}
 
-	private static void saveOutputFile(String outputFileName,
+	private static Document readDEBBComponentInputFile(String inputFileName) {
+		Document debbComponentDocument;
+		try {
+			debbComponentDocument = xmlDocumentBuilder.parse(inputFileName);
+			return debbComponentDocument;
+		} catch (SAXException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	private static void saveDCWoRMSOutputFile(String outputFileName,
 			Document dcwormsDocument) {
 
@@ -238,5 +255,5 @@
 
 		// Find DEBB with given id and transform it
-		//*****************************************************************
+		// *****************************************************************
 		// 1) ProductInstance -
 		XPathExpression expr = xpath
@@ -244,36 +261,40 @@
 						+ instanceId + "']");
 		Object result = expr.evaluate(plmxmlDocument, XPathConstants.NODE);
-		Node productInstance = (Node) result;
-		Node debbName = productInstance.getAttributes().getNamedItem("name");
-		System.out.println("name=" + debbName.getNodeValue());
-		Node partRef = productInstance.getAttributes().getNamedItem("partRef");
-		System.out.println("partRef=" + partRef.getNodeValue());
-		String partId = partRef.getNodeValue().substring(1); // Get rid of # at
-																// the beginning
+		Node productInstanceNode = (Node) result;
+		Node debbNameNode = productInstanceNode.getAttributes().getNamedItem(
+				"name");
+		System.out.println("name=" + debbNameNode.getNodeValue());
+		Node partRefNode = productInstanceNode.getAttributes().getNamedItem(
+				"partRef");
+		System.out.println("partRef=" + partRefNode.getNodeValue());
+		String partId = partRefNode.getNodeValue().substring(1); // Get rid of #
+																	// at
+																	// the
+																	// beginning
 		// UserData - hostname
 		expr = xpath
 				.compile("plm:UserData/plm:UserValue[@title='hostname']/@value");
-		result = expr.evaluate(productInstance, XPathConstants.NODE);
-		Node debbHostName = (Node) result;
-
-		//	UserData - sequence
+		result = expr.evaluate(productInstanceNode, XPathConstants.NODE);
+		Node debbHostNameNode = (Node) result;
+
+		// UserData - sequence
 		expr = xpath
 				.compile("plm:UserData/plm:UserValue[@title='sequence']/@value");
-		result = expr.evaluate(productInstance, XPathConstants.NODE);
-		Node debbSequence = (Node) result;
-
-		//	UserData - label
+		result = expr.evaluate(productInstanceNode, XPathConstants.NODE);
+		Node debbSequenceNode = (Node) result;
+
+		// UserData - label
 		expr = xpath
 				.compile("plm:UserData/plm:UserValue[@title='label']/@value");
-		result = expr.evaluate(productInstance, XPathConstants.NODE);
-		Node debbLabel = (Node) result;
-
-		//	UserData - location
+		result = expr.evaluate(productInstanceNode, XPathConstants.NODE);
+		Node debbLabelNode = (Node) result;
+
+		// UserData - location
 		expr = xpath
 				.compile("plm:UserData/plm:UserValue[@title='location']/@value");
-		result = expr.evaluate(productInstance, XPathConstants.NODE);
-		Node debbLocation = (Node) result;
-		
-		//*****************************************************************
+		result = expr.evaluate(productInstanceNode, XPathConstants.NODE);
+		Node debbLocationNode = (Node) result;
+
+		// *****************************************************************
 		// 2) ProductRevisionView
 		expr = xpath
@@ -281,5 +302,5 @@
 						+ partId + "']");
 		result = expr.evaluate(plmxmlDocument, XPathConstants.NODE);
-		Node productRevisionView = (Node) result;
+		Node productRevisionViewNode = (Node) result;
 		// debbName = productRevisionView.getAttributes().getNamedItem("name");
 		// System.out.println("name=" + debbName.getNodeValue());
@@ -289,9 +310,9 @@
 		expr = xpath
 				.compile("plm:UserData/plm:UserValue[@title='DEBBComponentId']/@value");
-		result = expr.evaluate(productRevisionView, XPathConstants.NODE);
-		Node debbComponentId = (Node) result;
-		if (debbComponentId != null) {
+		result = expr.evaluate(productRevisionViewNode, XPathConstants.NODE);
+		Node debbComponentIdNode = (Node) result;
+		if (debbComponentIdNode != null) {
 			System.out.println("debbComponentId="
-					+ debbComponentId.getNodeValue());
+					+ debbComponentIdNode.getNodeValue());
 		}
 
@@ -299,8 +320,8 @@
 		expr = xpath
 				.compile("plm:UserData/plm:UserValue[@title='DEBBLevel']/@value");
-		result = expr.evaluate(productRevisionView, XPathConstants.NODE);
-		Node debbLevel = (Node) result;
-		if (debbLevel != null) {
-			System.out.println("debbLevel=" + debbLevel.getNodeValue());
+		result = expr.evaluate(productRevisionViewNode, XPathConstants.NODE);
+		Node debbLevelNode = (Node) result;
+		if (debbLevelNode != null) {
+			System.out.println("debbLevel=" + debbLevelNode.getNodeValue());
 		}
 
@@ -308,84 +329,105 @@
 		expr = xpath
 				.compile("plm:UserData/plm:UserValue[@title='DEBBComponentFile']/@value");
-		result = expr.evaluate(productRevisionView, XPathConstants.NODE);
-		Node debbComponentFileName = (Node) result;
-		if (debbComponentFileName == null) {
+		result = expr.evaluate(productRevisionViewNode, XPathConstants.NODE);
+		Node debbComponentFileNameNode = (Node) result;
+		String debbComponentFileName = null;
+		if (debbComponentFileNameNode != null) {
 			// Default DEBBComponent file is assumed
-
-		}
-		System.out.println("debbComponentFileName=" + debbComponentFileName);
-
-		//*****************************************************************
+			debbComponentFileName = debbComponentFileNameNode.getNodeValue();
+		} else {
+			debbComponentFileName = DEFAULT_DEBB_COMPONENT_INPUT_FILE_NAME;
+		}
+		System.out.println("debbComponentFileToOpen=" + debbComponentFileName);
+
+		// *****************************************************************
 		// Add computingResource element for the DEBB
-		if (debbLevel != null) {
+		if (debbLevelNode != null) {
 			Element computingResourceElement = dcwormsDocument
 					.createElement("computingResource");
 			Attr nameAttribute = dcwormsDocument.createAttribute("name");
-			nameAttribute.setValue(debbName.getNodeValue());
+			nameAttribute.setValue(debbNameNode.getNodeValue());
 			computingResourceElement.setAttributeNode(nameAttribute);
 
 			Attr classAttribute = dcwormsDocument.createAttribute("class");
-			String dcwormsClass = computingResourceClasses.get(debbLevel
+			String dcwormsClass = computingResourceClasses.get(debbLevelNode
 					.getNodeValue());
 			classAttribute.setValue(dcwormsClass);
 			computingResourceElement.setAttributeNode(classAttribute);
 
-			if (debbHostName != null) {				
-				Element parameterElement =dcwormsDocument.createElement("parameter");
-				Attr parameterNameAttribute = dcwormsDocument.createAttribute("name");
+			if (debbHostNameNode != null) {
+				Element parameterElement = dcwormsDocument
+						.createElement("parameter");
+				Attr parameterNameAttribute = dcwormsDocument
+						.createAttribute("name");
 				parameterNameAttribute.setValue("hostname");
 				parameterElement.setAttributeNode(parameterNameAttribute);
 				Element valueElement = dcwormsDocument.createElement("value");
-				valueElement.appendChild(dcwormsDocument.createTextNode(debbHostName.getNodeValue()));
+				valueElement.appendChild(dcwormsDocument
+						.createTextNode(debbHostNameNode.getNodeValue()));
 				parameterElement.appendChild(valueElement);
 				computingResourceElement.appendChild(parameterElement);
 			}
 
-			if (debbSequence != null) {
+			if (debbSequenceNode != null) {
 				// TODO: Sequence is described unclearly in the deliverable, not
 				// used in any example. Not sure what to do with it.
-				Element parameterElement =dcwormsDocument.createElement("parameter");
-				Attr parameterNameAttribute = dcwormsDocument.createAttribute("name");
+				Element parameterElement = dcwormsDocument
+						.createElement("parameter");
+				Attr parameterNameAttribute = dcwormsDocument
+						.createAttribute("name");
 				parameterNameAttribute.setValue("sequence");
 				parameterElement.setAttributeNode(parameterNameAttribute);
 				Element valueElement = dcwormsDocument.createElement("value");
-				valueElement.appendChild(dcwormsDocument.createTextNode(debbSequence.getNodeValue()));
+				valueElement.appendChild(dcwormsDocument
+						.createTextNode(debbSequenceNode.getNodeValue()));
 				parameterElement.appendChild(valueElement);
-				computingResourceElement.appendChild(parameterElement);				
+				computingResourceElement.appendChild(parameterElement);
 			}
 			debbParentElement.appendChild(computingResourceElement);
 
-			if (debbLabel != null) {				
-				Element parameterElement =dcwormsDocument.createElement("parameter");
-				Attr parameterNameAttribute = dcwormsDocument.createAttribute("name");
+			if (debbLabelNode != null) {
+				Element parameterElement = dcwormsDocument
+						.createElement("parameter");
+				Attr parameterNameAttribute = dcwormsDocument
+						.createAttribute("name");
 				parameterNameAttribute.setValue("label");
 				parameterElement.setAttributeNode(parameterNameAttribute);
 				Element valueElement = dcwormsDocument.createElement("value");
-				valueElement.appendChild(dcwormsDocument.createTextNode(debbLabel.getNodeValue()));
+				valueElement.appendChild(dcwormsDocument
+						.createTextNode(debbLabelNode.getNodeValue()));
 				parameterElement.appendChild(valueElement);
 				computingResourceElement.appendChild(parameterElement);
-				
-			}
-
-			if (debbLocation != null) {
-				Element parameterElement =dcwormsDocument.createElement("parameter");
-				Attr parameterNameAttribute = dcwormsDocument.createAttribute("name");
+
+			}
+
+			if (debbLocationNode != null) {
+				Element parameterElement = dcwormsDocument
+						.createElement("parameter");
+				Attr parameterNameAttribute = dcwormsDocument
+						.createAttribute("name");
 				parameterNameAttribute.setValue("location");
 				parameterElement.setAttributeNode(parameterNameAttribute);
 				Element valueElement = dcwormsDocument.createElement("value");
-				valueElement.appendChild(dcwormsDocument.createTextNode(debbLocation.getNodeValue()));
+				valueElement.appendChild(dcwormsDocument
+						.createTextNode(debbLocationNode.getNodeValue()));
 				parameterElement.appendChild(valueElement);
 				computingResourceElement.appendChild(parameterElement);
-				
-			}
-			
-			//*****************************************************************
+
+			}
+
+			// *****************************************************************
+			// Read data from DEBBComponent file(s)
+			Document debbComponentDocument = readDEBBComponentInputFile(debbComponentFileName);
+
+			// Find component
+
+			// *****************************************************************
 			// Get nested instances - nested DEBBs and ask them to transform
 			// themselves
-			Node instanceRefs = productRevisionView.getAttributes()
+			Node instanceRefsNode = productRevisionViewNode.getAttributes()
 					.getNamedItem("instanceRefs");
 			// Check if anything is nested at all
-			if (instanceRefs != null) {
-				String instances = instanceRefs.getNodeValue();
+			if (instanceRefsNode != null) {
+				String instances = instanceRefsNode.getNodeValue();
 				System.out.println("instances=" + instances);
 				// Separate instance ids
