01: /*
02: * ChainBuilder ESB
03: * Visual Enterprise Integration
04: *
05: * Copyright (C) 2006 Bostech Corporation
06: *
07: * This program is free software; you can redistribute it and/or modify
08: * it under the terms of the GNU General Public License as published by
09: * the Free Software Foundation; either version 2 of the License, or
10: * (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public License
18: * along with this program; if not, write to the Free Software
19: * Foundation, Inc.,59 Temple Place, Suite 330, Boston, MA 02111-1307
20: * USA
21: *
22: * $Id: FileConversion.java 6998 2007-04-24 01:13:00Z jzhang $
23: *
24: */
25: package com.bostechcorp.cbesb.ui.util.version;
26:
27: import org.jdom.Element;
28:
29: /**
30: *
31: */
32: public class FileConversion {
33:
34: public static void convert(Element element, Element file) {
35: Element fileWSDLDocument = element.getChild("fileWSDLDocument");
36:
37: Element newConsumerCCSL;
38: if (fileWSDLDocument.getChild("fileConsumerCCSL") == null) {
39: newConsumerCCSL = ConversionUtil.convertCCSL(
40: ConversionUtil.CONSUMER, element, "consumerCCSL");
41: } else {
42: newConsumerCCSL = ConversionUtil.createCCSL(
43: ConversionUtil.CONSUMER, fileWSDLDocument
44: .getChild("fileConsumerCCSL"));
45: }
46: Element newPeoviderCCSL;
47: if (fileWSDLDocument.getChild("fileProviderCCSL") == null) {
48: newPeoviderCCSL = ConversionUtil.convertCCSL(
49: ConversionUtil.PROVIDER, element, "providerCCSL");
50: } else {
51: newPeoviderCCSL = ConversionUtil.createCCSL(
52: ConversionUtil.PROVIDER, fileWSDLDocument
53: .getChild("fileProviderCCSL"));
54: }
55:
56: Element fileRead = fileWSDLDocument.getChild("fileRead");
57: Element fileCompletion = fileRead.getChild("fileCompletion");
58: Element fileReply = fileRead.getChild("fileReply");
59: Element fileHold = fileRead.getChild("fileHold");
60: Element fileTwoPassMode = fileRead.getChild("fileTwoPassMode");
61: Element newFileConsumer = new Element("fileConsumer");
62: Element newFileCompletion = new Element("fileCompletion");
63: Element newFileReply = new Element("fileReply");
64:
65: if (fileWSDLDocument.getAttributeValue("mode") != null) {
66: if ("both".equals(fileWSDLDocument
67: .getAttributeValue("mode"))) {
68: file.setAttribute("role", "both");
69: } else {
70: file.setAttribute("role", "provider");
71: }
72: }
73: if (fileHold.getAttribute("enabled") != null) {
74: newFileCompletion.setAttribute("holdEnabled", "true");
75: newFileCompletion.setAttribute("holdDirectory", fileHold
76: .getAttributeValue("holdDirectory"));
77: }
78: if (fileTwoPassMode.getAttribute("enabled") != null) {
79: newFileCompletion.setAttribute("twoPassModeIntevalEnabled",
80: "true");
81: newFileCompletion.setAttribute("twoPassModeInterval",
82: fileTwoPassMode.getAttributeValue("interval"));
83: }
84: ConversionUtil.convertAttribute(fileRead, newFileConsumer);
85: ConversionUtil.convertAttribute(fileCompletion,
86: newFileCompletion);
87: ConversionUtil.convertAttribute(fileReply, newFileReply);
88: Element fileWrite = fileWSDLDocument.getChild("fileWrite");
89: Element newFileProvider = new Element("fileProvider");
90: ConversionUtil.convertAttribute(fileWrite, newFileProvider);
91: newFileConsumer.addContent(newFileReply);
92: newFileConsumer.addContent(newFileCompletion);
93: file.addContent(newConsumerCCSL);
94: file.addContent(newPeoviderCCSL);
95: file.addContent(newFileConsumer);
96: file.addContent(newFileProvider);
97: }
98: }
|