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: ScriptConversion.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 ScriptConversion {
33:
34: public static void convert(Element element, Element newElement) {
35: Element newConsumerCCSL;
36: if (element.getChild("scriptConsumerCCSL") == null) {
37: if ("consumer".equals(newElement.getAttributeValue("role"))) {
38: newConsumerCCSL = ConversionUtil.convertCCSL(
39: ConversionUtil.CONSUMER, element, "CCSL");
40: } else {
41: newConsumerCCSL = ConversionUtil.convertCCSL(
42: ConversionUtil.CONSUMER, null, "CCSL");
43: }
44: } else {
45: newConsumerCCSL = ConversionUtil.createCCSL(
46: ConversionUtil.CONSUMER, element
47: .getChild("scriptConsumerCCSL"));
48: }
49: Element newProviderCCSL;
50: if (element.getChild("scriptProviderCCSL") == null) {
51: if ("consumer".equals(newElement.getAttributeValue("role"))) {
52: newProviderCCSL = ConversionUtil.convertCCSL(
53: ConversionUtil.PROVIDER, null, "CCSL");
54: } else {
55: newProviderCCSL = ConversionUtil.convertCCSL(
56: ConversionUtil.PROVIDER, element, "CCSL");
57: }
58: } else {
59: newProviderCCSL = ConversionUtil.createCCSL(
60: ConversionUtil.PROVIDER, element
61: .getChild("scriptProviderCCSL"));
62: }
63: Element newScriptConsumer = new Element("scriptConsumer");
64: Element newScriptProvider = new Element("scriptProvider");
65: if ("consumer".equals(element.getAttributeValue("role"))) {
66: newElement.removeAttribute("role");
67: if ("in-out"
68: .equals(element.getAttributeValue("defaultMep"))) {
69: newScriptConsumer.setAttribute("defaultMep", "in-out");
70: } else if ("reliablein".equals(element
71: .getAttributeValue("defaultMep"))) {
72: newScriptConsumer.setAttribute("defaultMep",
73: "reliablein");
74: }
75: } else {
76: newElement.setAttribute("role", "provider");
77: }
78: newElement.removeAttribute("defaultMep");
79: newElement.addContent(newConsumerCCSL);
80: newElement.addContent(newProviderCCSL);
81: newElement.addContent(newScriptConsumer);
82: newElement.addContent(newScriptProvider);
83: }
84: }
|